@oceanum/datamesh 0.5.2 → 0.6.3

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.
Files changed (48) hide show
  1. package/dist/index.cjs +5 -5
  2. package/dist/index.d.ts +6 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +5447 -4501
  5. package/dist/lib/cftime.d.ts +127 -0
  6. package/dist/lib/cftime.d.ts.map +1 -0
  7. package/dist/lib/connector.d.ts +142 -0
  8. package/dist/lib/connector.d.ts.map +1 -0
  9. package/dist/lib/datamodel.d.ts +227 -0
  10. package/dist/lib/datamodel.d.ts.map +1 -0
  11. package/dist/lib/datasource.d.ts +117 -0
  12. package/dist/lib/datasource.d.ts.map +1 -0
  13. package/dist/lib/observe.d.ts +3 -0
  14. package/dist/lib/observe.d.ts.map +1 -0
  15. package/dist/lib/query.d.ts +135 -0
  16. package/dist/lib/query.d.ts.map +1 -0
  17. package/dist/lib/session.d.ts +61 -0
  18. package/dist/lib/session.d.ts.map +1 -0
  19. package/dist/lib/zarr.d.ts +59 -0
  20. package/dist/lib/zarr.d.ts.map +1 -0
  21. package/package.json +15 -2
  22. package/eslint.config.cjs +0 -22
  23. package/project.json +0 -4
  24. package/proxy/cloudflare/index.js +0 -42
  25. package/proxy/express/README.md +0 -54
  26. package/proxy/express/index.js +0 -126
  27. package/proxy/guide.md +0 -140
  28. package/src/index.js +0 -20
  29. package/src/index.ts +0 -4
  30. package/src/lib/connector.ts +0 -388
  31. package/src/lib/datamodel.ts +0 -820
  32. package/src/lib/datasource.ts +0 -161
  33. package/src/lib/observe.ts +0 -21
  34. package/src/lib/query.ts +0 -212
  35. package/src/lib/session.ts +0 -173
  36. package/src/lib/workers/README.md +0 -3
  37. package/src/lib/zarr.ts +0 -236
  38. package/src/test/dataframe.test.ts +0 -108
  39. package/src/test/dataset.test.ts +0 -180
  40. package/src/test/datasource.test.ts +0 -28
  41. package/src/test/fixtures.ts +0 -297
  42. package/src/test/query.test.ts +0 -49
  43. package/tsconfig.json +0 -13
  44. package/tsconfig.lib.json +0 -25
  45. package/tsconfig.spec.json +0 -31
  46. package/tsconfig.vitest-temp.json +0 -61
  47. package/typedoc.json +0 -8
  48. package/vite.config.ts +0 -67
package/dist/index.cjs CHANGED
@@ -1,9 +1,9 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class Mr extends Error{constructor(t,e={}){super(`Node not found: ${t}`,e),this.name="NodeNotFoundError"}}class hi extends Error{constructor(t){super(`Missing key: ${t}`),this.name="KeyError"}}class qi{#t;constructor(t,e,n){typeof t=="number"?this.#t=new Uint8Array(t):t instanceof ArrayBuffer?this.#t=new Uint8Array(t,e,n):this.#t=new Uint8Array(Array.from(t,o=>o?1:0))}get BYTES_PER_ELEMENT(){return 1}get byteOffset(){return this.#t.byteOffset}get byteLength(){return this.#t.byteLength}get buffer(){return this.#t.buffer}get length(){return this.#t.length}get(t){let e=this.#t[t];return typeof e=="number"?e!==0:e}set(t,e){this.#t[t]=e?1:0}fill(t){this.#t.fill(t?1:0)}*[Symbol.iterator](){for(let t=0;t<this.length;t++)yield this.get(t)}}class Ki{_data;chars;#t;constructor(t,e,n,o){if(this.chars=t,this.#t=new TextEncoder,typeof e=="number")this._data=new Uint8Array(e*t);else if(e instanceof ArrayBuffer)o&&(o=o*t),this._data=new Uint8Array(e,n,o);else{let i=Array.from(e);this._data=new Uint8Array(i.length*t);for(let a=0;a<i.length;a++)this.set(a,i[a])}}get BYTES_PER_ELEMENT(){return this.chars}get byteOffset(){return this._data.byteOffset}get byteLength(){return this._data.byteLength}get buffer(){return this._data.buffer}get length(){return this.byteLength/this.BYTES_PER_ELEMENT}get(t){const e=new Uint8Array(this.buffer,this.byteOffset+this.chars*t,this.chars);return new TextDecoder().decode(e).replace(/\x00/g,"")}set(t,e){const n=new Uint8Array(this.buffer,this.byteOffset+this.chars*t,this.chars);n.fill(0),n.set(this.#t.encode(e))}fill(t){const e=this.#t.encode(t);for(let n=0;n<this.length;n++)this._data.set(e,n*this.chars)}*[Symbol.iterator](){for(let t=0;t<this.length;t++)yield this.get(t)}}class hn{#t;chars;constructor(t,e,n,o){if(this.chars=t,typeof e=="number")this.#t=new Int32Array(e*t);else if(e instanceof ArrayBuffer)o&&(o*=t),this.#t=new Int32Array(e,n,o);else{const i=e,a=new hn(t,1);this.#t=new Int32Array(function*(){for(let c of i)a.set(0,c),yield*a.#t}())}}get BYTES_PER_ELEMENT(){return this.#t.BYTES_PER_ELEMENT*this.chars}get byteLength(){return this.#t.byteLength}get byteOffset(){return this.#t.byteOffset}get buffer(){return this.#t.buffer}get length(){return this.#t.length/this.chars}get(t){const e=this.chars*t;let n="";for(let o=0;o<this.chars;o++)n+=String.fromCodePoint(this.#t[e+o]);return n.replace(/\u0000/g,"")}set(t,e){const n=this.chars*t,o=this.#t.subarray(n,n+this.chars);o.fill(0);for(let i=0;i<this.chars;i++)o[i]=e.codePointAt(i)??0}fill(t){this.set(0,t);let e=this.#t.subarray(0,this.chars);for(let n=1;n<this.length;n++)this.#t.set(e,n*this.chars)}*[Symbol.iterator](){for(let t=0;t<this.length;t++)yield this.get(t)}}function Xi(r){const t=JSON.stringify(r,null,2);return new TextEncoder().encode(t)}function er(r){const t=new TextDecoder().decode(r);return JSON.parse(t)}function ks(r,t){const e=t/2,n=t-1;let o=0;for(let i=0;i<r.length;i+=t)for(let a=0;a<e;a+=1)o=r[i+a],r[i+a]=r[i+n-a],r[i+n-a]=o}const hu={int8:Int8Array,int16:Int16Array,int32:Int32Array,int64:globalThis.BigInt64Array,uint8:Uint8Array,uint16:Uint16Array,uint32:Uint32Array,uint64:globalThis.BigUint64Array,float32:Float32Array,float64:Float64Array,bool:qi},lu=/v2:([US])(\d+)/;function jo(r){if(r==="v2:object")return globalThis.Array;let t=r.match(lu);if(t){let[,n,o]=t;return(n==="U"?hn:Ki).bind(null,Number(o))}let e=hu[r];return Yt(e,`Unknown or unsupported data_type: ${r}`),e}function Qe(r,t){const e=r.length;typeof t=="string"&&(t=t==="C"?Array.from({length:e},(i,a)=>a):Array.from({length:e},(i,a)=>e-1-a)),Yt(e===t.length,"Order length must match the number of dimensions.");let n=1,o=new Array(e);for(let i=t.length-1;i>=0;i--)o[t[i]]=n,n*=r[t[i]];return o}function fu({name:r,configuration:t}){if(r==="default"){const e=t?.separator??"/";return n=>["c",...n].join(e)}if(r==="v2"){const e=t?.separator??".";return n=>n.join(e)||"0"}throw new Error(`Unknown chunk key encoding: ${r}`)}function du(r){if(r==="|O")return{data_type:"v2:object"};let t=r.match(/^([<|>])(.*)$/);Yt(t,`Invalid dtype: ${r}`);let[,e,n]=t,o={b1:"bool",i1:"int8",u1:"uint8",i2:"int16",u2:"uint16",i4:"int32",u4:"uint32",i8:"int64",u8:"uint64",f4:"float32",f8:"float64"}[n]??(n.startsWith("S")||n.startsWith("U")?`v2:${n}`:void 0);return Yt(o,`Unsupported or unknown dtype: ${r}`),e==="|"?{data_type:o}:{data_type:o,endian:e==="<"?"little":"big"}}function pu(r,t={}){let e=[],n=du(r.dtype);r.order==="F"&&e.push({name:"transpose",configuration:{order:"F"}}),"endian"in n&&n.endian==="big"&&e.push({name:"bytes",configuration:{endian:"big"}});for(let{id:o,...i}of r.filters??[])e.push({name:o,configuration:i});if(r.compressor){let{id:o,...i}=r.compressor;e.push({name:o,configuration:i})}return{zarr_format:3,node_type:"array",shape:r.shape,data_type:n.data_type,chunk_grid:{name:"regular",configuration:{chunk_shape:r.chunks}},chunk_key_encoding:{name:"v2",configuration:{separator:r.dimension_separator??"."}},codecs:e,fill_value:r.fill_value,attributes:t}}function yu(r,t={}){return{zarr_format:3,node_type:"group",attributes:t}}function gu(r,t){if(t!=="number"&&t!=="bigint"&&t!=="boolean"&&t!=="object"&&t!=="string")return r===t;let e=r==="bool";if(t==="boolean")return e;let n=r.startsWith("v2:U")||r.startsWith("v2:S");if(t==="string")return n;let o=r==="int64"||r==="uint64";if(t==="bigint")return o;let i=r==="v2:object";return t==="object"?i:!n&&!o&&!e&&!i}function mu(r){return r?.name==="sharding_indexed"}function Vo(r){return(r.data_type==="uint64"||r.data_type==="int64")&&r.fill_value!=null?BigInt(r.fill_value):r.fill_value}function Wo(r,...t){if(!t.some(e=>r instanceof e))throw r}function Yt(r,t=""){if(!r)throw new Error(t)}class Qi{kind="array_to_array";constructor(t,e){Yt(t.keepbits>=0,"keepbits must be zero or positive")}static fromConfig(t,e){return new Qi(t,e)}encode(t){throw new Error("`BitroundCodec.encode` is not implemented. Please open an issue at https://github.com/manzt/zarrita.js/issues.")}decode(t){return t}}const Ds=wu();function wu(){const r=new Uint32Array([305419896]);return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)[0]!==18}function Us(r){return"BYTES_PER_ELEMENT"in r?r.BYTES_PER_ELEMENT:4}class li{kind="array_to_bytes";#t;#e;#n;#i;#r;constructor(t,e){this.#r=t?.endian,this.#e=jo(e.data_type),this.#i=e.shape,this.#t=Qe(e.shape,"C");const n=new this.#e(0);this.#n=n.BYTES_PER_ELEMENT}static fromConfig(t,e){return new li(t,e)}encode(t){let e=new Uint8Array(t.data.buffer);return Ds&&this.#r==="big"&&ks(e,Us(this.#e)),e}decode(t){return Ds&&this.#r==="big"&&ks(t,Us(this.#e)),{data:new this.#e(t.buffer,t.byteOffset,t.byteLength/this.#n),shape:this.#i,stride:this.#t}}}class ts{kind="bytes_to_bytes";static fromConfig(){return new ts}encode(t){throw new Error("Not implemented")}decode(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength-4)}}function bu(r,t){return Yt(!Number.isNaN(t),"JsonCodec allow_nan is false but NaN was encountered during encoding."),Yt(t!==Number.POSITIVE_INFINITY,"JsonCodec allow_nan is false but Infinity was encountered during encoding."),Yt(t!==Number.NEGATIVE_INFINITY,"JsonCodec allow_nan is false but -Infinity was encountered during encoding."),t}function _u(r,t){return t instanceof Object&&!Array.isArray(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t}class es{configuration;kind="array_to_bytes";#t;#e;constructor(t={}){this.configuration=t;const{encoding:e="utf-8",skipkeys:n=!1,ensure_ascii:o=!0,check_circular:i=!0,allow_nan:a=!0,sort_keys:c=!0,indent:f,strict:p=!0}=t;let g=t.separators;g||(f?g=[", ",": "]:g=[",",":"]),this.#t={encoding:e,skipkeys:n,ensure_ascii:o,check_circular:i,allow_nan:a,indent:f,separators:g,sort_keys:c},this.#e={strict:p}}static fromConfig(t){return new es(t)}encode(t){const{indent:e,encoding:n,ensure_ascii:o,check_circular:i,allow_nan:a,sort_keys:c}=this.#t;Yt(n==="utf-8","JsonCodec does not yet support non-utf-8 encoding.");const f=[];Yt(i,"JsonCodec does not yet support skipping the check for circular references during encoding."),a||f.push(bu),c&&f.push(_u);const p=Array.from(t.data);p.push("|O"),p.push(t.shape);let g;f.length&&(g=(C,F)=>{let T=F;for(let U of f)T=U(C,T);return T});let v=JSON.stringify(p,g,e);return o&&(v=v.replace(/[\u007F-\uFFFF]/g,C=>{const F=`0000${C.charCodeAt(0).toString(16)}`;return`\\u${F.substring(F.length-4)}`})),new TextEncoder().encode(v)}decode(t){const{strict:e}=this.#e;Yt(e,"JsonCodec does not yet support non-strict decoding.");const n=er(t),o=n.pop();n.pop(),Yt(o,"0D not implemented for JsonCodec.");const i=Qe(o,"C");return{data:n,shape:o,stride:i}}}const rs={};function Ls(r){return r instanceof qi||r instanceof Ki||r instanceof hn?new Proxy(r,{get(e,n){return e.get(Number(n))},set(e,n,o){return e.set(Number(n),o),!0}}):r}function Su(r,t){let e;return r.data instanceof Ki||r.data instanceof hn?e=new r.constructor(r.data.length,r.data.chars):e=new r.constructor(r.data.length),{data:e,shape:r.shape,stride:Qe(r.shape,t)}}function Iu(r,t){let e=Su(r,t),n=r.shape.length,o=r.data.length,i=Array(n).fill(0),a=Ls(r.data),c=Ls(e.data);for(let f=0;f<o;f++){let p=0;for(let g=0;g<n;g++)p+=i[g]*e.stride[g];c[p]=a[f],i[0]+=1;for(let g=0;g<n;g++)if(i[g]===r.shape[g]){if(g+1===n)break;i[g]=0,i[g+1]+=1}}return e}function Bu(r){let t=r.shape.length;return rs(t===r.stride.length,"Shape and stride must have the same length."),r.stride.map((e,n)=>({stride:e,index:n})).sort((e,n)=>n.stride-e.stride).map(e=>e.index)}function vu(r,t){let e=Bu(r);return rs(e.length===t.length,"Orders must match"),e.every((n,o)=>n===t[o])}class ns{kind="array_to_array";#t;#e;constructor(t,e){let n=t.order??"C",o=e.shape.length,i=new Array(o),a=new Array(o);if(n==="C")for(let c=0;c<o;++c)i[c]=c,a[c]=c;else if(n==="F")for(let c=0;c<o;++c)i[c]=o-c-1,a[c]=o-c-1;else i=n,i.forEach((c,f)=>{rs(a[c]===void 0,`Invalid permutation: ${JSON.stringify(n)}`),a[c]=f});this.#t=i,this.#e=a}static fromConfig(t,e){return new ns(t,e)}encode(t){return vu(t,this.#e)?t:Iu(t,this.#e)}decode(t){return{data:t.data,shape:t.shape,stride:Qe(t.shape,this.#t)}}}class is{kind="array_to_bytes";#t;#e;constructor(t){this.#t=t,this.#e=Qe(t,"C")}static fromConfig(t,e){return new is(e.shape)}encode(t){throw new Error("Method not implemented.")}decode(t){let e=new TextDecoder,n=new DataView(t.buffer),o=Array(n.getUint32(0,!0)),i=4;for(let a=0;a<o.length;a++){let c=n.getUint32(i,!0);i+=4,o[a]=e.decode(t.buffer.slice(i,i+c)),i+=c}return{data:o,shape:this.#t,stride:this.#e}}}function Au(){return new Map().set("blosc",()=>Promise.resolve().then(()=>require("./blosc-XU68L2JO.cjs")).then(r=>r.default)).set("gzip",()=>Promise.resolve().then(()=>require("./gzip-9a4q5uuM.cjs")).then(r=>r.default)).set("lz4",()=>Promise.resolve().then(()=>require("./lz4-DyL8MHib.cjs")).then(r=>r.default)).set("zlib",()=>Promise.resolve().then(()=>require("./zlib-BviSziX3.cjs")).then(r=>r.default)).set("zstd",()=>Promise.resolve().then(()=>require("./zstd-BJg46wpa.cjs")).then(r=>r.default)).set("transpose",()=>ns).set("bytes",()=>li).set("crc32c",()=>ts).set("vlen-utf8",()=>is).set("json2",()=>es).set("bitround",()=>Qi)}const xu=Au();function Di(r){let t;return{async encode(e){t||(t=await Rs(r));for(const o of t.array_to_array)e=await o.encode(e);let n=await t.array_to_bytes.encode(e);for(const o of t.bytes_to_bytes)n=await o.encode(n);return n},async decode(e){t||(t=await Rs(r));for(let o=t.bytes_to_bytes.length-1;o>=0;o--)e=await t.bytes_to_bytes[o].decode(e);let n=await t.array_to_bytes.decode(e);for(let o=t.array_to_array.length-1;o>=0;o--)n=await t.array_to_array[o].decode(n);return n}}}async function Rs(r){let t=r.codecs.map(async i=>{let a=await xu.get(i.name)?.();return Yt(a,`Unknown codec: ${i.name}`),{Codec:a,meta:i}}),e=[],n,o=[];for await(let{Codec:i,meta:a}of t){let c=i.fromConfig(a.configuration,r);switch(c.kind){case"array_to_array":e.push(c);break;case"array_to_bytes":n=c;break;default:o.push(c)}}return n||(Yt(Eu(r),`Cannot encode ${r.data_type} to bytes without a codec`),n=li.fromConfig({endian:"little"},r)),{array_to_array:e,array_to_bytes:n,bytes_to_bytes:o}}function Eu(r){return r.data_type!=="v2:object"}const Cs=18446744073709551615n;function Tu(r,t,e,n){Yt(r.store.getRange,"Store does not support range requests");let o=r.store.getRange.bind(r.store),i=t.map((f,p)=>f/n.chunk_shape[p]),a=Di({data_type:"uint64",shape:[...i,2],codecs:n.index_codecs}),c={};return async f=>{let p=f.map((P,R)=>Math.floor(P/i[R])),g=r.resolve(e(p)).path,v;if(g in c)v=c[g];else{let P=4,R=16*i.reduce((G,A)=>G*A,1),V=await o(g,{suffixLength:R+P});v=c[g]=V?await a.decode(V):null}if(v===null)return;let{data:C,shape:F,stride:T}=v,U=f.map((P,R)=>P%F[R]).reduce((P,R,V)=>P+R*T[V],0),M=C[U],k=C[U+1];if(!(M===Cs&&k===Cs))return o(g,{offset:Number(M),length:Number(k)})}}class rr{store;path;constructor(t,e="/"){this.store=t,this.path=e}resolve(t){let e=new URL(`file://${this.path.endsWith("/")?this.path:`${this.path}/`}`);return new rr(this.store,new URL(t,e).pathname)}}class fi extends rr{kind="group";#t;constructor(t,e,n){super(t,e),this.#t=n}get attrs(){return this.#t.attributes}}function Ps(r){return r.find(e=>e.name==="transpose")?.configuration?.order??"C"}const Jr=Symbol("zarrita.context");function Zo(r){return r[Jr]}function Ou(r,t){let{configuration:e}=t.codecs.find(mu)??{},n={encode_chunk_key:fu(t.chunk_key_encoding),TypedArray:jo(t.data_type),fill_value:t.fill_value};if(e){let i=Ps(e.codecs);return{...n,kind:"sharded",chunk_shape:e.chunk_shape,codec:Di({data_type:t.data_type,shape:e.chunk_shape,codecs:e.codecs}),get_strides(a,c){return Qe(a,c??i)},get_chunk_bytes:Tu(r,t.chunk_grid.configuration.chunk_shape,n.encode_chunk_key,e)}}let o=Ps(t.codecs);return{...n,kind:"regular",chunk_shape:t.chunk_grid.configuration.chunk_shape,codec:Di({data_type:t.data_type,shape:t.chunk_grid.configuration.chunk_shape,codecs:t.codecs}),get_strides(i,a){return Qe(i,a??o)},async get_chunk_bytes(i,a){let c=n.encode_chunk_key(i),f=r.resolve(c).path;return r.store.get(f,a)}}}let Br=class extends rr{kind="array";#t;[Jr];constructor(t,e,n){super(t,e),this.#t={...n,fill_value:Vo(n)},this[Jr]=Ou(this,n)}get attrs(){return this.#t.attributes}get shape(){return this.#t.shape}get chunks(){return this[Jr].chunk_shape}get dtype(){return this.#t.data_type}async getChunk(t,e){let n=this[Jr],o=await n.get_chunk_bytes(t,e);if(!o){let i=n.chunk_shape.reduce((c,f)=>c*f,1),a=new n.TypedArray(i);return a.fill(n.fill_value),{data:a,shape:n.chunk_shape,stride:n.get_strides(n.chunk_shape)}}return n.codec.decode(o)}is(t){return gu(this.dtype,t)}},di=Mu();function Mu(){let r=new WeakMap;function t(e){let n=r.get(e)??{v2:0,v3:0};return r.set(e,n),n}return{increment(e,n){t(e)[n]+=1},version_max(e){let n=t(e);return n.v3>n.v2?"v3":"v2"}}}async function Fu(r){let t=await r.store.get(r.resolve(".zattrs").path);return t?er(t):{}}async function Nu(r,t={}){let e="store"in r?r:new rr(r),n={};return(t.attrs??!0)&&(n=await Fu(e)),t.kind==="array"?$s(e,n):t.kind==="group"?zs(e,n):$s(e,n).catch(o=>(Wo(o,Mr),zs(e,n)))}async function $s(r,t){let{path:e}=r.resolve(".zarray"),n=await r.store.get(e);if(!n)throw new Mr("v2 array",{cause:new hi(e)});return di.increment(r.store,"v2"),new Br(r.store,r.path,pu(er(n),t))}async function zs(r,t){let{path:e}=r.resolve(".zgroup"),n=await r.store.get(e);if(!n)throw new Mr("v2 group",{cause:new hi(e)});return di.increment(r.store,"v2"),new fi(r.store,r.path,yu(er(n),t))}async function ku(r){let{store:t,path:e}=r.resolve("zarr.json"),n=await r.store.get(e);if(!n)throw new Mr("v3 array or group",{cause:new hi(e)});let o=er(n);return o.node_type==="array"&&(o.fill_value=Vo(o)),o.node_type==="array"?new Br(t,r.path,o):new fi(t,r.path,o)}async function Du(r,t={}){let e="store"in r?r:new rr(r),n=await ku(e);if(di.increment(e.store,"v3"),t.kind===void 0||t.kind==="array"&&n instanceof Br||t.kind==="group"&&n instanceof fi)return n;let o=n instanceof Br?"array":"group";throw new Error(`Expected node of kind ${t.kind}, found ${o}.`)}async function Ze(r,t={}){let e="store"in r?r.store:r,n=di.version_max(e),o=n==="v2"?Ze.v2:Ze.v3,i=n==="v2"?Ze.v3:Ze.v2;return o(r,t).catch(a=>(Wo(a,Mr),i(r,t)))}Ze.v2=Nu;Ze.v3=Du;async function js(r,t={}){let e="store"in r?r:new rr(r);return"shape"in t?await Lu(e,t):Uu(e,t)}async function Uu(r,t={}){let e={zarr_format:3,node_type:"group",attributes:t.attributes??{}};return await r.store.set(r.resolve("zarr.json").path,Xi(e)),new fi(r.store,r.path,e)}async function Lu(r,t){let e={zarr_format:3,node_type:"array",shape:t.shape,data_type:t.data_type,chunk_grid:{name:"regular",configuration:{chunk_shape:t.chunk_shape}},chunk_key_encoding:{name:"default",configuration:{separator:t.chunk_separator??"/"}},codecs:t.codecs??[],fill_value:t.fill_value??null,attributes:t.attributes??{}};return await r.store.set(r.resolve("zarr.json").path,Xi(e)),new Br(r.store,r.path,e)}async function Ru(r){let t=await r.get("/.zmetadata");if(!t)throw new Mr("v2 consolidated metadata",{cause:new hi("/.zmetadata")});let e=er(t);return Yt(e.zarr_consolidated_format===1,"Unsupported consolidated format."),e}function Cu(r){return r.endsWith(".zarray")||r.endsWith(".zgroup")||r.endsWith(".zattrs")||r.endsWith("zarr.json")}function Pu(r){return"zarr_format"in r&&r.zarr_format===3}async function $u(r){let t=await Ru(r),e={};for(let[n,o]of Object.entries(t.metadata))e[`/${n}`]=o;return{async get(...n){let[o,i]=n;if(e[o])return Xi(e[o]);let a=await r.get(o,i);if(Cu(o)&&a){let c=er(a);e[o]=c}return a},getRange:r.getRange?.bind(r),contents(){let n=[];for(let[o,i]of Object.entries(e)){let a=o.split("/"),c=a.pop(),f=a.join("/")||"/";c===".zarray"&&n.push({path:f,kind:"array"}),c===".zgroup"&&n.push({path:f,kind:"group"}),Pu(i)&&n.push({path:f,kind:i.node_type})}return n}}}function*zu(r,t,e=1){t===void 0&&(t=r,r=0);for(let n=r;n<t;n+=e)yield n}function*ju(...r){if(r.length===0)return;const t=r.map(n=>n[Symbol.iterator]()),e=t.map(n=>n.next());if(e.some(n=>n.done))throw new Error("Input contains an empty iterator.");for(let n=0;;){if(e[n].done){if(t[n]=r[n][Symbol.iterator](),e[n]=t[n].next(),++n>=t.length)return}else yield e.map(({value:o})=>o),n=0;e[n]=t[n].next()}}function Vu({start:r,stop:t,step:e},n){if(e===0)throw new Error("slice step cannot be zero");e=e??1;const o=e<0,[i,a]=o?[-1,n-1]:[0,n];return r===null?r=o?a:i:r<0?(r+=n,r<i&&(r=i)):r>a&&(r=a),t===null?t=o?i:a:t<0?(t+=n,t<i&&(t=i)):t>a&&(t=a),[r,t,e]}function Ui(r,t,e=null){return t===void 0&&(t=r,r=null),{start:r,stop:t,step:e}}function Go(){const r=[];return{add:t=>r.push(t()),onIdle:()=>Promise.all(r)}}class ss extends Error{constructor(t){super(t),this.name="IndexError"}}function Wu(r,t){throw new ss(`too many indicies for array; expected ${t.length}, got ${r.length}`)}function Zu(r){throw new ss(`index out of bounds for dimension with length ${r}`)}function Gu(){throw new ss("only slices with step >= 1 are supported")}function Yu(r,t){r.length>t.length&&Wu(r,t)}function Ju(r,t){return r=Math.trunc(r),r<0&&(r=t+r),(r>=t||r<0)&&Zu(t),r}class Hu{dim_sel;dim_len;dim_chunk_len;nitems;constructor({dim_sel:t,dim_len:e,dim_chunk_len:n}){t=Ju(t,e),this.dim_sel=t,this.dim_len=e,this.dim_chunk_len=n,this.nitems=1}*[Symbol.iterator](){const t=Math.floor(this.dim_sel/this.dim_chunk_len),e=t*this.dim_chunk_len,n=this.dim_sel-e;yield{dim_chunk_ix:t,dim_chunk_sel:n}}}class Vs{start;stop;step;dim_len;dim_chunk_len;nitems;nchunks;constructor({dim_sel:t,dim_len:e,dim_chunk_len:n}){const[o,i,a]=Vu(t,e);this.start=o,this.stop=i,this.step=a,this.step<1&&Gu(),this.dim_len=e,this.dim_chunk_len=n,this.nitems=Math.max(0,Math.ceil((this.stop-this.start)/this.step)),this.nchunks=Math.ceil(this.dim_len/this.dim_chunk_len)}*[Symbol.iterator](){const t=Math.floor(this.start/this.dim_chunk_len),e=Math.ceil(this.stop/this.dim_chunk_len);for(const n of zu(t,e)){const o=n*this.dim_chunk_len,i=Math.min(this.dim_len,(n+1)*this.dim_chunk_len),a=i-o;let c=0,f=0;if(this.start<o){const F=(o-this.start)%this.step;F&&(f+=this.step-F),c=Math.ceil((o-this.start)/this.step)}else f=this.start-o;const p=this.stop>i?a:this.stop-o,g=[f,p,this.step],v=Math.ceil((p-f)/this.step),C=[c,c+v,1];yield{dim_chunk_ix:n,dim_chunk_sel:g,dim_out_sel:C}}}}function qu(r,t){let e=[];return r===null?e=t.map(n=>Ui(null)):Array.isArray(r)&&(e=r.map(n=>n??Ui(null))),Yu(e,t),e}class Yo{dim_indexers;shape;constructor({selection:t,shape:e,chunk_shape:n}){this.dim_indexers=qu(t,e).map((o,i)=>new(typeof o=="number"?Hu:Vs)({dim_sel:o,dim_len:e[i],dim_chunk_len:n[i]})),this.shape=this.dim_indexers.filter(o=>o instanceof Vs).map(o=>o.nitems)}*[Symbol.iterator](){for(const t of ju(...this.dim_indexers)){const e=t.map(o=>o.dim_chunk_ix),n=t.map(o=>"dim_out_sel"in o?{from:o.dim_chunk_sel,to:o.dim_out_sel}:{from:o.dim_chunk_sel,to:null});yield{chunk_coords:e,mapping:n}}}}function Ku(r,t){return"get"in r?r.get(t):r[t]}async function Xu(r,t,e,n){let o=Zo(r),i=new Yo({selection:t,shape:r.shape,chunk_shape:r.chunks}),a=n.prepare(new o.TypedArray(i.shape.reduce((f,p)=>f*p,1)),i.shape,o.get_strides(i.shape,e.order)),c=e.create_queue?.()??Go();for(const{chunk_coords:f,mapping:p}of i)c.add(async()=>{let{data:g,shape:v,stride:C}=await r.getChunk(f,e.opts),F=n.prepare(g,v,C);n.set_from_chunk(a,F,p)});return await c.onIdle(),i.shape.length===0?Ku(a.data,0):a}function Qu(r){return r.to==null?{from:r.to,to:r.from}:{from:r.to,to:r.from}}async function th(r,t,e,n,o){const i=Zo(r);if(i.kind==="sharded")throw new Error("Set not supported for sharded arrays.");const a=new Yo({selection:t,shape:r.shape,chunk_shape:r.chunks}),c=r.chunks.reduce((p,g)=>p*g,1),f=n.create_queue?n.create_queue():Go();for(const{chunk_coords:p,mapping:g}of a){const v=g.map(F=>F.from),C=g.map(Qu);f.add(async()=>{const F=r.resolve(i.encode_chunk_key(p)).path;let T;const U=r.chunks.slice(),M=i.get_strides(U);if(eh(v,U))if(T=new i.TypedArray(c),typeof e=="object"){const k=o.prepare(T,U.slice(),M.slice());o.set_from_chunk(k,e,C)}else T.fill(e);else{T=await r.getChunk(p).then(({data:P})=>P);const k=o.prepare(T,U.slice(),M.slice());typeof e=="object"?o.set_from_chunk(k,e,C):o.set_scalar(k,v,e)}await r.store.set(F,await i.codec.encode({data:T,shape:U,stride:M}))})}await f.onIdle()}function eh(r,t){return r.every((e,n)=>{if(typeof e=="number")return!1;const[o,i,a]=e;return i-o===t[n]&&a===1})}function os(r,t=0,e){let n=e??r.length-t;return{length:n,subarray(o,i=n){return os(r,t+o,i-o)},set(o,i=0){for(let a=0;a<o.length;a++)r[t+i+a]=o.get(a)},get(o){return r[t+o]}}}function Si(r){return globalThis.Array.isArray(r.data)?{data:os(r.data),stride:r.stride,bytes_per_element:1}:{data:new Uint8Array(r.data.buffer,r.data.byteOffset,r.data.byteLength),stride:r.stride,bytes_per_element:r.data.BYTES_PER_ELEMENT}}function rh(r){return"chars"in r?r.constructor.bind(null,r.chars):r.constructor}function nh(r,t){if(globalThis.Array.isArray(r.data))return os([t]);let e=rh(r.data),n=new e([t]);return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}const Jo={prepare(r,t,e){return{data:r,shape:t,stride:e}},set_scalar(r,t,e){let n=Si(r);Li(n,t,nh(r,e),n.bytes_per_element)},set_from_chunk(r,t,e){let n=Si(r);_n(n,Si(t),n.bytes_per_element,e)}};async function ih(r,t=null,e={}){return Xu(r,t,e,Jo)}async function sh(r,t,e,n={}){return th(r,t,e,n,Jo)}function Ho(r,t,e){return e<0&&t<r?Math.floor((r-t-1)/-e)+1:r<t?Math.floor((t-r-1)/e)+1:0}function Li(r,t,e,n){if(t.length===0){r.data.set(e,0);return}const[o,...i]=t,[a,...c]=r.stride;if(typeof o=="number"){const C=r.data.subarray(a*o*n);Li({data:C,stride:c},i,e,n);return}const[f,p,g]=o,v=Ho(f,p,g);if(i.length===0){for(let C=0;C<v;C++)r.data.set(e,a*(f+g*C)*n);return}for(let C=0;C<v;C++){const F=r.data.subarray(a*(f+g*C)*n);Li({data:F,stride:c},i,e,n)}}function _n(r,t,e,n){const[o,...i]=n,[a,...c]=r.stride,[f,...p]=t.stride;if(o.from===null){if(i.length===0){r.data.set(t.data.subarray(0,e),o.to*e);return}_n({data:r.data.subarray(a*o.to*e),stride:c},t,e,i);return}if(o.to===null){if(i.length===0){let k=o.from*e;r.data.set(t.data.subarray(k,k+e),0);return}_n(r,{data:t.data.subarray(f*o.from*e),stride:p},e,i);return}const[g,v,C]=o.to,[F,T,U]=o.from,M=Ho(g,v,C);if(i.length===0){if(C===1&&U===1&&a===1&&f===1){let k=F*e,P=M*e;r.data.set(t.data.subarray(k,k+P),g*e);return}for(let k=0;k<M;k++){let P=f*(F+U*k)*e;r.data.set(t.data.subarray(P,P+e),a*(g+C*k)*e)}return}for(let k=0;k<M;k++)_n({data:r.data.subarray(a*(g+k*C)*e),stride:c},{data:t.data.subarray(f*(F+k*U)*e),stride:p},e,i)}function gt(r,t,e,n){function o(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function c(g){try{p(n.next(g))}catch(v){a(v)}}function f(g){try{p(n.throw(g))}catch(v){a(v)}}function p(g){g.done?i(g.value):o(g.value).then(c,f)}p((n=n.apply(r,t||[])).next())})}function Ws(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],n=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function wt(r){return this instanceof wt?(this.v=r,this):new wt(r)}function Ae(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(r,t||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",a),o[Symbol.asyncIterator]=function(){return this},o;function a(F){return function(T){return Promise.resolve(T).then(F,v)}}function c(F,T){n[F]&&(o[F]=function(U){return new Promise(function(M,k){i.push([F,U,M,k])>1||f(F,U)})},T&&(o[F]=T(o[F])))}function f(F,T){try{p(n[F](T))}catch(U){C(i[0][3],U)}}function p(F){F.value instanceof wt?Promise.resolve(F.value.v).then(g,v):C(i[0][2],F)}function g(F){f("next",F)}function v(F){f("throw",F)}function C(F,T){F(T),i.shift(),i.length&&f(i[0][0],i[0][1])}}function Sn(r){var t,e;return t={},n("next"),n("throw",function(o){throw o}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(o,i){t[o]=r[o]?function(a){return(e=!e)?{value:wt(r[o](a)),done:!1}:i?i(a):a}:i}}function wr(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 Ws=="function"?Ws(r):r[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(i){e[i]=r[i]&&function(a){return new Promise(function(c,f){a=r[i](a),o(c,f,a.done,a.value)})}}function o(i,a,c,f){Promise.resolve(f).then(function(p){i({value:p,done:c})},a)}}const oh=new TextDecoder("utf-8"),Ri=r=>oh.decode(r),ah=new TextEncoder,as=r=>ah.encode(r),ch=r=>typeof r=="number",uh=r=>typeof r=="boolean",qt=r=>typeof r=="function",ge=r=>r!=null&&Object(r)===r,sn=r=>ge(r)&&qt(r.then),pi=r=>ge(r)&&qt(r[Symbol.iterator]),cs=r=>ge(r)&&qt(r[Symbol.asyncIterator]),Ci=r=>ge(r)&&ge(r.schema),qo=r=>ge(r)&&"done"in r&&"value"in r,Ko=r=>ge(r)&&qt(r.stat)&&ch(r.fd),Xo=r=>ge(r)&&us(r.body),Qo=r=>"_getDOMStream"in r&&"_getNodeStream"in r,us=r=>ge(r)&&qt(r.cancel)&&qt(r.getReader)&&!Qo(r),ta=r=>ge(r)&&qt(r.read)&&qt(r.pipe)&&uh(r.readable)&&!Qo(r),hh=r=>ge(r)&&qt(r.clear)&&qt(r.bytes)&&qt(r.position)&&qt(r.setPosition)&&qt(r.capacity)&&qt(r.getBufferIdentifier)&&qt(r.createLong),hs=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function lh(r){const t=r[0]?[r[0]]:[];let e,n,o,i;for(let a,c,f=0,p=0,g=r.length;++f<g;){if(a=t[p],c=r[f],!a||!c||a.buffer!==c.buffer||c.byteOffset<a.byteOffset){c&&(t[++p]=c);continue}if({byteOffset:e,byteLength:o}=a,{byteOffset:n,byteLength:i}=c,e+o<n||n+i<e){c&&(t[++p]=c);continue}t[p]=new Uint8Array(a.buffer,e,n-e+i)}return t}function Zs(r,t,e=0,n=t.byteLength){const o=r.byteLength,i=new Uint8Array(r.buffer,r.byteOffset,o),a=new Uint8Array(t.buffer,t.byteOffset,Math.min(n,o));return i.set(a,e),r}function xe(r,t){const e=lh(r),n=e.reduce((g,v)=>g+v.byteLength,0);let o,i,a,c=0,f=-1;const p=Math.min(t||Number.POSITIVE_INFINITY,n);for(const g=e.length;++f<g;){if(o=e[f],i=o.subarray(0,Math.min(o.length,p-c)),p<=c+i.length){i.length<o.length?e[f]=o.subarray(i.length):i.length===o.length&&f++,a?Zs(a,i,c):a=i;break}Zs(a||(a=new Uint8Array(p)),i,c),c+=i.length}return[a||new Uint8Array(0),e.slice(f),n-(a?a.byteLength:0)]}function Ot(r,t){let e=qo(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=as(e)),e instanceof ArrayBuffer?new r(e):e instanceof hs?new r(e):hh(e)?Ot(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)}const kr=r=>Ot(Int32Array,r),Gs=r=>Ot(BigInt64Array,r),It=r=>Ot(Uint8Array,r),Pi=r=>(r.next(),r);function*fh(r,t){const e=function*(o){yield o},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof hs?e(t):pi(t)?t:e(t);return yield*Pi(function*(o){let i=null;do i=o.next(yield Ot(r,i));while(!i.done)}(n[Symbol.iterator]())),new r}const dh=r=>fh(Uint8Array,r);function ea(r,t){return Ae(this,arguments,function*(){if(sn(t))return yield wt(yield wt(yield*Sn(wr(ea(r,yield wt(t))))));const n=function(a){return Ae(this,arguments,function*(){yield yield wt(yield wt(a))})},o=function(a){return Ae(this,arguments,function*(){yield wt(yield*Sn(wr(Pi(function*(c){let f=null;do f=c.next(yield f?.value);while(!f.done)}(a[Symbol.iterator]())))))})},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof hs?n(t):pi(t)?o(t):cs(t)?t:n(t);return yield wt(yield*Sn(wr(Pi(function(a){return Ae(this,arguments,function*(){let c=null;do c=yield wt(a.next(yield yield wt(Ot(r,c))));while(!c.done)})}(i[Symbol.asyncIterator]()))))),yield wt(new r)})}const ph=r=>ea(Uint8Array,r);function yh(r,t){let e=0;const n=r.length;if(n!==t.length)return!1;if(n>0)do if(r[e]!==t[e])return!1;while(++e<n);return!0}const ae={fromIterable(r){return yn(gh(r))},fromAsyncIterable(r){return yn(mh(r))},fromDOMStream(r){return yn(wh(r))},fromNodeStream(r){return yn(_h(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')}},yn=r=>(r.next(),r);function*gh(r){let t,e=!1,n=[],o,i,a,c=0;function f(){return i==="peek"?xe(n,a)[0]:([o,n,c]=xe(n,a),o)}({cmd:i,size:a}=(yield null)||{cmd:"read",size:0});const p=dh(r)[Symbol.iterator]();try{do if({done:t,value:o}=Number.isNaN(a-c)?p.next():p.next(a-c),!t&&o.byteLength>0&&(n.push(o),c+=o.byteLength),t||a<=c)do({cmd:i,size:a}=yield f());while(a<c);while(!t)}catch(g){(e=!0)&&typeof p.throw=="function"&&p.throw(g)}finally{e===!1&&typeof p.return=="function"&&p.return(null)}return null}function mh(r){return Ae(this,arguments,function*(){let e,n=!1,o=[],i,a,c,f=0;function p(){return a==="peek"?xe(o,c)[0]:([i,o,f]=xe(o,c),i)}({cmd:a,size:c}=(yield yield wt(null))||{cmd:"read",size:0});const g=ph(r)[Symbol.asyncIterator]();try{do if({done:e,value:i}=Number.isNaN(c-f)?yield wt(g.next()):yield wt(g.next(c-f)),!e&&i.byteLength>0&&(o.push(i),f+=i.byteLength),e||c<=f)do({cmd:a,size:c}=yield yield wt(p()));while(c<f);while(!e)}catch(v){(n=!0)&&typeof g.throw=="function"&&(yield wt(g.throw(v)))}finally{n===!1&&typeof g.return=="function"&&(yield wt(g.return(new Uint8Array(0))))}return yield wt(null)})}function wh(r){return Ae(this,arguments,function*(){let e=!1,n=!1,o=[],i,a,c,f=0;function p(){return a==="peek"?xe(o,c)[0]:([i,o,f]=xe(o,c),i)}({cmd:a,size:c}=(yield yield wt(null))||{cmd:"read",size:0});const g=new bh(r);try{do if({done:e,value:i}=Number.isNaN(c-f)?yield wt(g.read()):yield wt(g.read(c-f)),!e&&i.byteLength>0&&(o.push(It(i)),f+=i.byteLength),e||c<=f)do({cmd:a,size:c}=yield yield wt(p()));while(c<f);while(!e)}catch(v){(n=!0)&&(yield wt(g.cancel(v)))}finally{n===!1?yield wt(g.cancel()):r.locked&&g.releaseLock()}return yield wt(null)})}class bh{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 gt(this,void 0,void 0,function*(){const{reader:e,source:n}=this;e&&(yield e.cancel(t).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(t){return gt(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};const e=yield this.reader.read();return!e.done&&(e.value=It(e)),e})}}const Ii=(r,t)=>{const e=o=>n([t,o]);let n;return[t,e,new Promise(o=>(n=o)&&r.once(t,e))]};function _h(r){return Ae(this,arguments,function*(){const e=[];let n="error",o=!1,i=null,a,c,f=0,p=[],g;function v(){return a==="peek"?xe(p,c)[0]:([g,p,f]=xe(p,c),g)}if({cmd:a,size:c}=(yield yield wt(null))||{cmd:"read",size:0},r.isTTY)return yield yield wt(new Uint8Array(0)),yield wt(null);try{e[0]=Ii(r,"end"),e[1]=Ii(r,"error");do{if(e[2]=Ii(r,"readable"),[n,i]=yield wt(Promise.race(e.map(F=>F[2]))),n==="error")break;if((o=n==="end")||(Number.isFinite(c-f)?(g=It(r.read(c-f)),g.byteLength<c-f&&(g=It(r.read()))):g=It(r.read()),g.byteLength>0&&(p.push(g),f+=g.byteLength)),o||c<=f)do({cmd:a,size:c}=yield yield wt(v()));while(c<f)}while(!o)}finally{yield wt(C(e,n==="error"?i:null))}return yield wt(null);function C(F,T){return g=p=null,new Promise((U,M)=>{for(const[k,P]of F)r.off(k,P);try{const k=r.destroy;k&&k.call(r,T),T=void 0}catch(k){T=k||T}finally{T!=null?M(T):U()}})}})}var zt;(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"})(zt||(zt={}));var re;(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(re||(re={}));var Jt;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(Jt||(Jt={}));var le;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(le||(le={}));var at;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(at||(at={}));var Ee;(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"})(Ee||(Ee={}));const Bi=2,Ie=4,Ne=4,At=4,Ve=new Int32Array(2),Ys=new Float32Array(Ve.buffer),Js=new Float64Array(Ve.buffer),gn=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var $i;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})($i||($i={}));let vr=class ra{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new ra(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 Ve[0]=this.readInt32(t),Ys[0]}readFloat64(t){return Ve[gn?0:1]=this.readInt32(t),Ve[gn?1:0]=this.readInt32(t+4),Js[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){Ys[0]=e,this.writeInt32(t,Ve[0])}writeFloat64(t,e){Js[0]=e,this.writeInt32(t,Ve[gn?0:1]),this.writeInt32(t+4,Ve[gn?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+Ie+Ne)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<Ne;e++)t+=String.fromCharCode(this.readInt8(this.position_+Ie+e));return t}__offset(t,e){const n=t-this.readInt32(t);return e<this.readInt16(n)?this.readInt16(n+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const n=this.readInt32(t);t+=Ie;const o=this.bytes_.subarray(t,t+n);return e===$i.UTF8_BYTES?o:this.text_decoder_.decode(o)}__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)+Ie}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=Ne)throw new Error("FlatBuffers: file identifier must be length "+Ne);for(let e=0;e<Ne;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+Ie+e))return!1;return!0}createScalarList(t,e){const n=[];for(let o=0;o<e;++o){const i=t(o);i!==null&&n.push(i)}return n}createObjList(t,e){const n=[];for(let o=0;o<e;++o){const i=t(o);i!==null&&n.push(i.unpack())}return n}},na=class ia{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=vr.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);const n=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<n+t+e;){const o=this.bb.capacity();this.bb=ia.growByteBuffer(this.bb),this.space+=this.bb.capacity()-o}this.pad(n)}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,n){(this.force_defaults||e!=n)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,n){(this.force_defaults||e!=n)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,n){(this.force_defaults||e!=n)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,n){(this.force_defaults||e!==n)&&(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,n){(this.force_defaults||e!=n)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,n){e!=n&&(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){const e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const n=e<<1,o=vr.allocate(n);return o.setPosition(n-e),o.bytes().set(t.bytes(),n-e),o}addOffset(t){this.prep(Ie,0),this.writeInt32(this.offset()-t+Ie)}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);const t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);const n=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);const o=2;this.addInt16(t-this.object_start);const i=(n+o)*Bi;this.addInt16(i);let a=0;const c=this.space;t:for(e=0;e<this.vtables.length;e++){const f=this.bb.capacity()-this.vtables[e];if(i==this.bb.readInt16(f)){for(let p=Bi;p<i;p+=Bi)if(this.bb.readInt16(c+p)!=this.bb.readInt16(f+p))continue t;a=this.vtables[e];break}}return a?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,a-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,n){const o=n?At:0;if(e){const i=e;if(this.prep(this.minalign,Ie+Ne+o),i.length!=Ne)throw new TypeError("FlatBuffers: file identifier must be length "+Ne);for(let a=Ne-1;a>=0;a--)this.writeInt8(i.charCodeAt(a))}this.prep(this.minalign,Ie+o),this.addOffset(t),o&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const n=this.bb.capacity()-t,o=n-this.bb.readInt32(n);if(!(e<this.bb.readInt16(o)&&this.bb.readInt16(o+e)!=0))throw new TypeError("FlatBuffers: field "+e+" must be set")}startVector(t,e,n){this.notNested(),this.vector_num_elems=e,this.prep(Ie,t*e),this.prep(n,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);const 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){const e=[];for(let n=0;n<t.length;++n){const o=t[n];if(o!==null)e.push(this.createObjectOffset(o));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 Nn;(function(r){r[r.BUFFER=0]="BUFFER"})(Nn||(Nn={}));var kn;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(kn||(kn={}));class We{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 We).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+At),(e||new We).__init(t.readInt32(t.position())+t.position(),t)}codec(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):kn.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Nn.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,kn.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,Nn.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return We.startBodyCompression(t),We.addCodec(t,e),We.addMethod(t,n),We.endBodyCompression(t)}}class sa{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n??0)),t.writeInt64(BigInt(e??0)),t.offset()}}let oa=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n??0)),t.writeInt64(BigInt(e??0)),t.offset()}},Oe=class zi{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 zi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+At),(e||new zi).__init(t.readInt32(t.position())+t.position(),t)}length(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new oa).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}nodesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new sa).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}buffersLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){const e=this.bb.__offset(this.bb_pos,10);return e?(t||new We).__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()}},or=class ji{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 ji).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+At),(e||new ji).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new Oe).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isDelta(){const 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 Ar;(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})(Ar||(Ar={}));var Dn;(function(r){r[r.DenseArray=0]="DenseArray"})(Dn||(Dn={}));class se{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 se).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+At),(e||new se).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){const 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,n){return se.startInt(t),se.addBitWidth(t,e),se.addIsSigned(t,n),se.endInt(t)}}class ke{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 ke).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+At),(e||new ke).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new se).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isOrdered(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):Dn.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,Dn.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}}class jt{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 jt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,e){return t.setPosition(t.position()+At),(e||new jt).__init(t.readInt32(t.position())+t.position(),t)}key(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}value(t){const 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,n){return jt.startKeyValue(t),jt.addKey(t,e),jt.addValue(t,n),jt.endKeyValue(t)}}let Hs=class Hr{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 Hr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+At),(e||new Hr).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return Hr.startBinary(t),Hr.endBinary(t)}},qs=class qr{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 qr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+At),(e||new qr).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return qr.startBool(t),qr.endBool(t)}},In=class ar{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 ar).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+At),(e||new ar).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):le.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,le.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return ar.startDate(t),ar.addUnit(t,e),ar.endDate(t)}},cr=class je{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 je).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+At),(e||new je).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){const 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,n,o){return je.startDecimal(t),je.addPrecision(t,e),je.addScale(t,n),je.addBitWidth(t,o),je.endDecimal(t)}},Bn=class ur{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 ur).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,e){return t.setPosition(t.position()+At),(e||new ur).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):at.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,at.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,e){return ur.startDuration(t),ur.addUnit(t,e),ur.endDuration(t)}},vn=class hr{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 hr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+At),(e||new hr).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){const 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 hr.startFixedSizeBinary(t),hr.addByteWidth(t,e),hr.endFixedSizeBinary(t)}},An=class lr{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 lr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+At),(e||new lr).__init(t.readInt32(t.position())+t.position(),t)}listSize(){const 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 lr.startFixedSizeList(t),lr.addListSize(t,e),lr.endFixedSizeList(t)}};class Be{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 Be).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+At),(e||new Be).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Jt.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,Jt.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return Be.startFloatingPoint(t),Be.addPrecision(t,e),Be.endFloatingPoint(t)}}class ve{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 ve).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+At),(e||new ve).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Ee.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,Ee.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return ve.startInterval(t),ve.addUnit(t,e),ve.endInterval(t)}}let Ks=class Kr{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 Kr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,e){return t.setPosition(t.position()+At),(e||new Kr).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return Kr.startLargeBinary(t),Kr.endLargeBinary(t)}},Xs=class Xr{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 Xr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,e){return t.setPosition(t.position()+At),(e||new Xr).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return Xr.startLargeUtf8(t),Xr.endLargeUtf8(t)}},Qs=class Qr{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 Qr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+At),(e||new Qr).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return Qr.startList(t),Qr.endList(t)}},xn=class fr{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 fr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+At),(e||new fr).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){const 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 fr.startMap(t),fr.addKeysSorted(t,e),fr.endMap(t)}},to=class tn{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 tn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+At),(e||new tn).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return tn.startNull(t),tn.endNull(t)}};class Xe{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 Xe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+At),(e||new Xe).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return Xe.startStruct_(t),Xe.endStruct_(t)}}class ce{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 ce).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+At),(e||new ce).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):at.MILLISECOND}bitWidth(){const 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,at.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,n){return ce.startTime(t),ce.addUnit(t,e),ce.addBitWidth(t,n),ce.endTime(t)}}class ue{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 ue).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+At),(e||new ue).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):at.SECOND}timezone(t){const 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,at.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,n){return ue.startTimestamp(t),ue.addUnit(t,e),ue.addTimezone(t,n),ue.endTimestamp(t)}}class ee{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 ee).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+At),(e||new ee).__init(t.readInt32(t.position())+t.position(),t)}mode(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):re.Sparse}typeIds(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+t*4):0}typeIdsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){const 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,re.Sparse)}static addTypeIds(t,e){t.addFieldOffset(1,e,0)}static createTypeIdsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addInt32(e[n]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,n){return ee.startUnion(t),ee.addMode(t,e),ee.addTypeIds(t,n),ee.endUnion(t)}}let eo=class en{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 en).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+At),(e||new en).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return en.startUtf8(t),en.endUtf8(t)}};var Dt;(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"})(Dt||(Dt={}));let oe=class En{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 En).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+At),(e||new En).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}nullable(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):Dt.NONE}type(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){const e=this.bb.__offset(this.bb_pos,12);return e?(t||new ke).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){const n=this.bb.__offset(this.bb_pos,14);return n?(e||new En).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}childrenLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,16);return n?(e||new jt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){const 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,Dt.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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endField(t){return t.endObject()}},_e=class Te{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 Te).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+At),(e||new Te).__init(t.readInt32(t.position())+t.position(),t)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Ar.Little}fields(t,e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new oe).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}fieldsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new jt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){const 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(){const 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,Ar.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static 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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 n=e.length-1;n>=0;n--)t.addInt64(e[n]);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,n,o,i){return Te.startSchema(t),Te.addEndianness(t,e),Te.addFields(t,n),Te.addCustomMetadata(t,o),Te.addFeatures(t,i),Te.endSchema(t)}};var Bt;(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"})(Bt||(Bt={}));var x;(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"})(x||(x={}));var Me;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(Me||(Me={}));const Sh=void 0;function on(r){if(r===null)return"null";if(r===Sh)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=>on(t))}]`:`[${r}]`:ArrayBuffer.isView(r)?`[${r}]`:JSON.stringify(r,(t,e)=>typeof e=="bigint"?`${e}`:e)}function Lt(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 aa(r,t){return Lt(r/t)+Lt(r%t)/Lt(t)}const Ih=Symbol.for("isArrowBigNum");function we(r,...t){return t.length===0?Object.setPrototypeOf(Ot(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}we.prototype[Ih]=!0;we.prototype.toJSON=function(){return`"${cn(this)}"`};we.prototype.valueOf=function(r){return ca(this,r)};we.prototype.toString=function(){return cn(this)};we.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return ca(this);case"string":return cn(this);case"default":return Ah(this)}return cn(this)};function br(...r){return we.apply(this,r)}function _r(...r){return we.apply(this,r)}function an(...r){return we.apply(this,r)}Object.setPrototypeOf(br.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(_r.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(an.prototype,Object.create(Uint32Array.prototype));Object.assign(br.prototype,we.prototype,{constructor:br,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(_r.prototype,we.prototype,{constructor:_r,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(an.prototype,we.prototype,{constructor:an,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Bh=BigInt(4294967296)*BigInt(4294967296),vh=Bh-BigInt(1);function ca(r,t){const{buffer:e,byteOffset:n,byteLength:o,signed:i}=r,a=new BigUint64Array(e,n,o/8),c=i&&a.at(-1)&BigInt(1)<<BigInt(63);let f=BigInt(0),p=0;if(c){for(const g of a)f|=(g^vh)*(BigInt(1)<<BigInt(64*p++));f*=BigInt(-1),f-=BigInt(1)}else for(const g of a)f|=g*(BigInt(1)<<BigInt(64*p++));if(typeof t=="number"){const g=BigInt(Math.pow(10,t)),v=f/g,C=f%g;return Lt(v)+Lt(C)/Lt(g)}return Lt(f)}function cn(r){if(r.byteLength===8)return`${new r.BigIntArray(r.buffer,r.byteOffset,1)[0]}`;if(!r.signed)return vi(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return vi(r);t=t.slice();let n=1;for(let i=0;i<t.length;i++){const a=t[i],c=~a+n;t[i]=c,n&=a===0?1:0}return`-${vi(t)}`}function Ah(r){return r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:cn(r)}function vi(r){let t="";const e=new Uint32Array(2);let n=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);const o=new Uint32Array((n=new Uint16Array(n).reverse()).buffer);let i=-1;const a=n.length-1;do{for(e[0]=n[i=0];i<a;)n[i++]=e[1]=e[0]/10,e[0]=(e[0]-e[1]*10<<16)+n[i];n[i]=e[1]=e[0]/10,e[0]=e[0]-e[1]*10,t=`${e[0]}${t}`}while(o[0]||o[1]||o[2]||o[3]);return t??"0"}class ls{static new(t,e){switch(e){case!0:return new br(t);case!1:return new _r(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new br(t)}return t.byteLength===16?new an(t):new _r(t)}static signed(t){return new br(t)}static unsigned(t){return new _r(t)}static decimal(t){return new an(t)}constructor(t,e){return ls.new(t,e)}}var ua,ha,la,fa,da,pa,ya,ga,ma,wa,ba,_a,Sa,Ia,Ba,va,Aa,xa,Ea,Ta,Oa,Ma;class tt{static isNull(t){return t?.typeId===x.Null}static isInt(t){return t?.typeId===x.Int}static isFloat(t){return t?.typeId===x.Float}static isBinary(t){return t?.typeId===x.Binary}static isLargeBinary(t){return t?.typeId===x.LargeBinary}static isUtf8(t){return t?.typeId===x.Utf8}static isLargeUtf8(t){return t?.typeId===x.LargeUtf8}static isBool(t){return t?.typeId===x.Bool}static isDecimal(t){return t?.typeId===x.Decimal}static isDate(t){return t?.typeId===x.Date}static isTime(t){return t?.typeId===x.Time}static isTimestamp(t){return t?.typeId===x.Timestamp}static isInterval(t){return t?.typeId===x.Interval}static isDuration(t){return t?.typeId===x.Duration}static isList(t){return t?.typeId===x.List}static isStruct(t){return t?.typeId===x.Struct}static isUnion(t){return t?.typeId===x.Union}static isFixedSizeBinary(t){return t?.typeId===x.FixedSizeBinary}static isFixedSizeList(t){return t?.typeId===x.FixedSizeList}static isMap(t){return t?.typeId===x.Map}static isDictionary(t){return t?.typeId===x.Dictionary}static isDenseUnion(t){return tt.isUnion(t)&&t.mode===re.Dense}static isSparseUnion(t){return tt.isUnion(t)&&t.mode===re.Sparse}constructor(t){this.typeId=t}}ua=Symbol.toStringTag;tt[ua]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(tt.prototype);class Ye extends tt{constructor(){super(x.Null)}toString(){return"Null"}}ha=Symbol.toStringTag;Ye[ha]=(r=>r[Symbol.toStringTag]="Null")(Ye.prototype);class tr extends tt{constructor(t,e){super(x.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}`}}la=Symbol.toStringTag;tr[la]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(tr.prototype);class un extends tr{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(un.prototype,"ArrayType",{value:Int32Array});class Un extends tt{constructor(t){super(x.Float),this.precision=t}get ArrayType(){switch(this.precision){case Jt.HALF:return Uint16Array;case Jt.SINGLE:return Float32Array;case Jt.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}fa=Symbol.toStringTag;Un[fa]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(Un.prototype);class Ln extends tt{constructor(){super(x.Binary)}toString(){return"Binary"}}da=Symbol.toStringTag;Ln[da]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(Ln.prototype);class Rn extends tt{constructor(){super(x.LargeBinary)}toString(){return"LargeBinary"}}pa=Symbol.toStringTag;Rn[pa]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(Rn.prototype);class Cn extends tt{constructor(){super(x.Utf8)}toString(){return"Utf8"}}ya=Symbol.toStringTag;Cn[ya]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(Cn.prototype);class Pn extends tt{constructor(){super(x.LargeUtf8)}toString(){return"LargeUtf8"}}ga=Symbol.toStringTag;Pn[ga]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(Pn.prototype);class $n extends tt{constructor(){super(x.Bool)}toString(){return"Bool"}}ma=Symbol.toStringTag;$n[ma]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))($n.prototype);class zn extends tt{constructor(t,e,n=128){super(x.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}wa=Symbol.toStringTag;zn[wa]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(zn.prototype);class jn extends tt{constructor(t){super(x.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${le[this.unit]}>`}get ArrayType(){return this.unit===le.DAY?Int32Array:BigInt64Array}}ba=Symbol.toStringTag;jn[ba]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(jn.prototype);class Vn extends tt{constructor(t,e){super(x.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${at[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}_a=Symbol.toStringTag;Vn[_a]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(Vn.prototype);class Wn extends tt{constructor(t,e){super(x.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${at[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}Sa=Symbol.toStringTag;Wn[Sa]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(Wn.prototype);class Zn extends tt{constructor(t){super(x.Interval),this.unit=t}toString(){return`Interval<${Ee[this.unit]}>`}}Ia=Symbol.toStringTag;Zn[Ia]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(Zn.prototype);class Gn extends tt{constructor(t){super(x.Duration),this.unit=t}toString(){return`Duration<${at[this.unit]}>`}}Ba=Symbol.toStringTag;Gn[Ba]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(Gn.prototype);class Yn extends tt{constructor(t){super(x.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}}va=Symbol.toStringTag;Yn[va]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(Yn.prototype);class Kt extends tt{constructor(t){super(x.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}Aa=Symbol.toStringTag;Kt[Aa]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(Kt.prototype);class Jn extends tt{constructor(t,e,n){super(x.Union),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((o,i,a)=>(o[i]=a)&&o||o,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}xa=Symbol.toStringTag;Jn[xa]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(Jn.prototype);class Hn extends tt{constructor(t){super(x.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}Ea=Symbol.toStringTag;Hn[Ea]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(Hn.prototype);class qn extends tt{constructor(t,e){super(x.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}>`}}Ta=Symbol.toStringTag;qn[Ta]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(qn.prototype);class Kn extends tt{constructor(t,e=!1){var n,o,i;if(super(x.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((n=t?.type)===null||n===void 0)&&n.children)){const a=(o=t?.type)===null||o===void 0?void 0:o.children[0];a&&(a.name="key");const c=(i=t?.type)===null||i===void 0?void 0:i.children[1];c&&(c.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(", ")}}>`}}Oa=Symbol.toStringTag;Kn[Oa]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(Kn.prototype);const xh=(r=>()=>++r)(-1);class xr extends tt{constructor(t,e,n,o){super(x.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=o||!1,this.id=n==null?xh():Lt(n)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}Ma=Symbol.toStringTag;xr[Ma]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(xr.prototype);function Fe(r){const t=r;switch(r.typeId){case x.Decimal:return r.bitWidth/32;case x.Interval:return 1+t.unit;case x.FixedSizeList:return t.listSize;case x.FixedSizeBinary:return t.byteWidth;default:return 1}}class St{visitMany(t,...e){return t.map((n,o)=>this.visit(n,...e.map(i=>i[o])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return Eh(this,t,e)}getVisitFnByTypeId(t,e=!0){return dr(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 Eh(r,t,e=!0){return typeof t=="number"?dr(r,t,e):typeof t=="string"&&t in x?dr(r,x[t],e):t&&t instanceof tt?dr(r,ro(t),e):t?.type&&t.type instanceof tt?dr(r,ro(t.type),e):dr(r,x.NONE,e)}function dr(r,t,e=!0){let n=null;switch(t){case x.Null:n=r.visitNull;break;case x.Bool:n=r.visitBool;break;case x.Int:n=r.visitInt;break;case x.Int8:n=r.visitInt8||r.visitInt;break;case x.Int16:n=r.visitInt16||r.visitInt;break;case x.Int32:n=r.visitInt32||r.visitInt;break;case x.Int64:n=r.visitInt64||r.visitInt;break;case x.Uint8:n=r.visitUint8||r.visitInt;break;case x.Uint16:n=r.visitUint16||r.visitInt;break;case x.Uint32:n=r.visitUint32||r.visitInt;break;case x.Uint64:n=r.visitUint64||r.visitInt;break;case x.Float:n=r.visitFloat;break;case x.Float16:n=r.visitFloat16||r.visitFloat;break;case x.Float32:n=r.visitFloat32||r.visitFloat;break;case x.Float64:n=r.visitFloat64||r.visitFloat;break;case x.Utf8:n=r.visitUtf8;break;case x.LargeUtf8:n=r.visitLargeUtf8;break;case x.Binary:n=r.visitBinary;break;case x.LargeBinary:n=r.visitLargeBinary;break;case x.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case x.Date:n=r.visitDate;break;case x.DateDay:n=r.visitDateDay||r.visitDate;break;case x.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case x.Timestamp:n=r.visitTimestamp;break;case x.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case x.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case x.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case x.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case x.Time:n=r.visitTime;break;case x.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case x.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case x.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case x.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case x.Decimal:n=r.visitDecimal;break;case x.List:n=r.visitList;break;case x.Struct:n=r.visitStruct;break;case x.Union:n=r.visitUnion;break;case x.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case x.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case x.Dictionary:n=r.visitDictionary;break;case x.Interval:n=r.visitInterval;break;case x.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case x.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case x.Duration:n=r.visitDuration;break;case x.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case x.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case x.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case x.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case x.FixedSizeList:n=r.visitFixedSizeList;break;case x.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error(`Unrecognized type '${x[t]}'`)}function ro(r){switch(r.typeId){case x.Null:return x.Null;case x.Int:{const{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?x.Int8:x.Uint8;case 16:return e?x.Int16:x.Uint16;case 32:return e?x.Int32:x.Uint32;case 64:return e?x.Int64:x.Uint64}return x.Int}case x.Float:switch(r.precision){case Jt.HALF:return x.Float16;case Jt.SINGLE:return x.Float32;case Jt.DOUBLE:return x.Float64}return x.Float;case x.Binary:return x.Binary;case x.LargeBinary:return x.LargeBinary;case x.Utf8:return x.Utf8;case x.LargeUtf8:return x.LargeUtf8;case x.Bool:return x.Bool;case x.Decimal:return x.Decimal;case x.Time:switch(r.unit){case at.SECOND:return x.TimeSecond;case at.MILLISECOND:return x.TimeMillisecond;case at.MICROSECOND:return x.TimeMicrosecond;case at.NANOSECOND:return x.TimeNanosecond}return x.Time;case x.Timestamp:switch(r.unit){case at.SECOND:return x.TimestampSecond;case at.MILLISECOND:return x.TimestampMillisecond;case at.MICROSECOND:return x.TimestampMicrosecond;case at.NANOSECOND:return x.TimestampNanosecond}return x.Timestamp;case x.Date:switch(r.unit){case le.DAY:return x.DateDay;case le.MILLISECOND:return x.DateMillisecond}return x.Date;case x.Interval:switch(r.unit){case Ee.DAY_TIME:return x.IntervalDayTime;case Ee.YEAR_MONTH:return x.IntervalYearMonth}return x.Interval;case x.Duration:switch(r.unit){case at.SECOND:return x.DurationSecond;case at.MILLISECOND:return x.DurationMillisecond;case at.MICROSECOND:return x.DurationMicrosecond;case at.NANOSECOND:return x.DurationNanosecond}return x.Duration;case x.Map:return x.Map;case x.List:return x.List;case x.Struct:return x.Struct;case x.Union:switch(r.mode){case re.Dense:return x.DenseUnion;case re.Sparse:return x.SparseUnion}return x.Union;case x.FixedSizeBinary:return x.FixedSizeBinary;case x.FixedSizeList:return x.FixedSizeList;case x.Dictionary:return x.Dictionary}throw new Error(`Unrecognized type '${x[r.typeId]}'`)}St.prototype.visitInt8=null;St.prototype.visitInt16=null;St.prototype.visitInt32=null;St.prototype.visitInt64=null;St.prototype.visitUint8=null;St.prototype.visitUint16=null;St.prototype.visitUint32=null;St.prototype.visitUint64=null;St.prototype.visitFloat16=null;St.prototype.visitFloat32=null;St.prototype.visitFloat64=null;St.prototype.visitDateDay=null;St.prototype.visitDateMillisecond=null;St.prototype.visitTimestampSecond=null;St.prototype.visitTimestampMillisecond=null;St.prototype.visitTimestampMicrosecond=null;St.prototype.visitTimestampNanosecond=null;St.prototype.visitTimeSecond=null;St.prototype.visitTimeMillisecond=null;St.prototype.visitTimeMicrosecond=null;St.prototype.visitTimeNanosecond=null;St.prototype.visitDenseUnion=null;St.prototype.visitSparseUnion=null;St.prototype.visitIntervalDayTime=null;St.prototype.visitIntervalYearMonth=null;St.prototype.visitDuration=null;St.prototype.visitDurationSecond=null;St.prototype.visitDurationMillisecond=null;St.prototype.visitDurationMicrosecond=null;St.prototype.visitDurationNanosecond=null;const Fa=new Float64Array(1),sr=new Uint32Array(Fa.buffer);function Na(r){const t=(r&31744)>>10,e=(r&1023)/1024,n=Math.pow(-1,(r&32768)>>15);switch(t){case 31:return n*(e?Number.NaN:1/0);case 0:return n*(e?6103515625e-14*e:0)}return n*Math.pow(2,t-15)*(1+e)}function Th(r){if(r!==r)return 32256;Fa[0]=r;const t=(sr[1]&2147483648)>>16&65535;let e=sr[1]&2146435072,n=0;return e>=1089470464?sr[0]>0?e=31744:(e=(e&2080374784)>>16,n=(sr[1]&1048575)>>10):e<=1056964608?(n=1048576+(sr[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(sr[1]&1048575)+512>>10),t|e|n&65535}class ct extends St{}function ft(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}const Oh=(r,t,e)=>{r[t]=Math.floor(e/864e5)},ka=(r,t,e,n)=>{if(e+1<t.length){const o=Lt(t[e]),i=Lt(t[e+1]);r.set(n.subarray(0,i-o),o)}},Mh=({offset:r,values:t},e,n)=>{const o=r+e;n?t[o>>3]|=1<<o%8:t[o>>3]&=~(1<<o%8)},Re=({values:r},t,e)=>{r[t]=e},fs=({values:r},t,e)=>{r[t]=e},Da=({values:r},t,e)=>{r[t]=Th(e)},Fh=(r,t,e)=>{switch(r.type.precision){case Jt.HALF:return Da(r,t,e);case Jt.SINGLE:case Jt.DOUBLE:return fs(r,t,e)}},Ua=({values:r},t,e)=>{Oh(r,t,e.valueOf())},La=({values:r},t,e)=>{r[t]=BigInt(e)},Nh=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},Ra=({values:r,valueOffsets:t},e,n)=>ka(r,t,e,n),Ca=({values:r,valueOffsets:t},e,n)=>ka(r,t,e,as(n)),kh=(r,t,e)=>{r.type.unit===le.DAY?Ua(r,t,e):La(r,t,e)},Pa=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},$a=({values:r},t,e)=>{r[t]=BigInt(e)},za=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},ja=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},Dh=(r,t,e)=>{switch(r.type.unit){case at.SECOND:return Pa(r,t,e);case at.MILLISECOND:return $a(r,t,e);case at.MICROSECOND:return za(r,t,e);case at.NANOSECOND:return ja(r,t,e)}},Va=({values:r},t,e)=>{r[t]=e},Wa=({values:r},t,e)=>{r[t]=e},Za=({values:r},t,e)=>{r[t]=e},Ga=({values:r},t,e)=>{r[t]=e},Uh=(r,t,e)=>{switch(r.type.unit){case at.SECOND:return Va(r,t,e);case at.MILLISECOND:return Wa(r,t,e);case at.MICROSECOND:return Za(r,t,e);case at.NANOSECOND:return Ga(r,t,e)}},Lh=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},Rh=(r,t,e)=>{const n=r.children[0],o=r.valueOffsets,i=fe.getVisitFn(n);if(Array.isArray(e))for(let a=-1,c=o[t],f=o[t+1];c<f;)i(n,c++,e[++a]);else for(let a=-1,c=o[t],f=o[t+1];c<f;)i(n,c++,e.get(++a))},Ch=(r,t,e)=>{const n=r.children[0],{valueOffsets:o}=r,i=fe.getVisitFn(n);let{[t]:a,[t+1]:c}=o;const f=e instanceof Map?e.entries():Object.entries(e);for(const p of f)if(i(n,a,p),++a>=c)break},Ph=(r,t)=>(e,n,o,i)=>n&&e(n,r,t[i]),$h=(r,t)=>(e,n,o,i)=>n&&e(n,r,t.get(i)),zh=(r,t)=>(e,n,o,i)=>n&&e(n,r,t.get(o.name)),jh=(r,t)=>(e,n,o,i)=>n&&e(n,r,t[o.name]),Vh=(r,t,e)=>{const n=r.type.children.map(i=>fe.getVisitFn(i.type)),o=e instanceof Map?zh(t,e):e instanceof Ft?$h(t,e):Array.isArray(e)?Ph(t,e):jh(t,e);r.type.children.forEach((i,a)=>o(n[a],r.children[a],i,a))},Wh=(r,t,e)=>{r.type.mode===re.Dense?Ya(r,t,e):Ja(r,t,e)},Ya=(r,t,e)=>{const n=r.type.typeIdToChildIndex[r.typeIds[t]],o=r.children[n];fe.visit(o,r.valueOffsets[t],e)},Ja=(r,t,e)=>{const n=r.type.typeIdToChildIndex[r.typeIds[t]],o=r.children[n];fe.visit(o,t,e)},Zh=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},Gh=(r,t,e)=>{r.type.unit===Ee.DAY_TIME?Ha(r,t,e):qa(r,t,e)},Ha=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},qa=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},Ka=({values:r},t,e)=>{r[t]=e},Xa=({values:r},t,e)=>{r[t]=e},Qa=({values:r},t,e)=>{r[t]=e},tc=({values:r},t,e)=>{r[t]=e},Yh=(r,t,e)=>{switch(r.type.unit){case at.SECOND:return Ka(r,t,e);case at.MILLISECOND:return Xa(r,t,e);case at.MICROSECOND:return Qa(r,t,e);case at.NANOSECOND:return tc(r,t,e)}},Jh=(r,t,e)=>{const{stride:n}=r,o=r.children[0],i=fe.getVisitFn(o);if(Array.isArray(e))for(let a=-1,c=t*n;++a<n;)i(o,c+a,e[a]);else for(let a=-1,c=t*n;++a<n;)i(o,c+a,e.get(a))};ct.prototype.visitBool=ft(Mh);ct.prototype.visitInt=ft(Re);ct.prototype.visitInt8=ft(Re);ct.prototype.visitInt16=ft(Re);ct.prototype.visitInt32=ft(Re);ct.prototype.visitInt64=ft(Re);ct.prototype.visitUint8=ft(Re);ct.prototype.visitUint16=ft(Re);ct.prototype.visitUint32=ft(Re);ct.prototype.visitUint64=ft(Re);ct.prototype.visitFloat=ft(Fh);ct.prototype.visitFloat16=ft(Da);ct.prototype.visitFloat32=ft(fs);ct.prototype.visitFloat64=ft(fs);ct.prototype.visitUtf8=ft(Ca);ct.prototype.visitLargeUtf8=ft(Ca);ct.prototype.visitBinary=ft(Ra);ct.prototype.visitLargeBinary=ft(Ra);ct.prototype.visitFixedSizeBinary=ft(Nh);ct.prototype.visitDate=ft(kh);ct.prototype.visitDateDay=ft(Ua);ct.prototype.visitDateMillisecond=ft(La);ct.prototype.visitTimestamp=ft(Dh);ct.prototype.visitTimestampSecond=ft(Pa);ct.prototype.visitTimestampMillisecond=ft($a);ct.prototype.visitTimestampMicrosecond=ft(za);ct.prototype.visitTimestampNanosecond=ft(ja);ct.prototype.visitTime=ft(Uh);ct.prototype.visitTimeSecond=ft(Va);ct.prototype.visitTimeMillisecond=ft(Wa);ct.prototype.visitTimeMicrosecond=ft(Za);ct.prototype.visitTimeNanosecond=ft(Ga);ct.prototype.visitDecimal=ft(Lh);ct.prototype.visitList=ft(Rh);ct.prototype.visitStruct=ft(Vh);ct.prototype.visitUnion=ft(Wh);ct.prototype.visitDenseUnion=ft(Ya);ct.prototype.visitSparseUnion=ft(Ja);ct.prototype.visitDictionary=ft(Zh);ct.prototype.visitInterval=ft(Gh);ct.prototype.visitIntervalDayTime=ft(Ha);ct.prototype.visitIntervalYearMonth=ft(qa);ct.prototype.visitDuration=ft(Yh);ct.prototype.visitDurationSecond=ft(Ka);ct.prototype.visitDurationMillisecond=ft(Xa);ct.prototype.visitDurationMicrosecond=ft(Qa);ct.prototype.visitDurationNanosecond=ft(tc);ct.prototype.visitFixedSizeList=ft(Jh);ct.prototype.visitMap=ft(Ch);const fe=new ct,de=Symbol.for("parent"),Sr=Symbol.for("rowIndex");class ds{constructor(t,e){return this[de]=t,this[Sr]=e,new Proxy(this,Kh)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[Sr],e=this[de],n=e.type.children,o={};for(let i=-1,a=n.length;++i<a;)o[n[i].name]=ne.visit(e.children[i],t);return o}toString(){return`{${[...this].map(([t,e])=>`${on(t)}: ${on(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new Hh(this[de],this[Sr])}}class Hh{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(){const t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,ne.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}}Object.defineProperties(ds.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[de]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Sr]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});class qh{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[de].type.children.map(e=>e.name)}has(t,e){return t[de].type.children.some(n=>n.name===e)}getOwnPropertyDescriptor(t,e){if(t[de].type.children.some(n=>n.name===e))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const n=t[de].type.children.findIndex(o=>o.name===e);if(n!==-1){const o=ne.visit(t[de].children[n],t[Sr]);return Reflect.set(t,e,o),o}}set(t,e,n){const o=t[de].type.children.findIndex(i=>i.name===e);return o!==-1?(fe.visit(t[de].children[o],t[Sr],n),Reflect.set(t,e,n)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,n):!1}}const Kh=new qh;class nt extends St{}function ut(r){return(t,e)=>t.getValid(e)?r(t,e):null}const Xh=(r,t)=>864e5*r[t],Qh=(r,t)=>null,ec=(r,t,e)=>{if(e+1>=t.length)return null;const n=Lt(t[e]),o=Lt(t[e+1]);return r.subarray(n,o)},tl=({offset:r,values:t},e)=>{const n=r+e;return(t[n>>3]&1<<n%8)!==0},rc=({values:r},t)=>Xh(r,t),nc=({values:r},t)=>Lt(r[t]),He=({stride:r,values:t},e)=>t[r*e],el=({stride:r,values:t},e)=>Na(t[r*e]),ic=({values:r},t)=>r[t],rl=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),sc=({values:r,valueOffsets:t},e)=>ec(r,t,e),oc=({values:r,valueOffsets:t},e)=>{const n=ec(r,t,e);return n!==null?Ri(n):null},nl=({values:r},t)=>r[t],il=({type:r,values:t},e)=>r.precision!==Jt.HALF?t[e]:Na(t[e]),sl=(r,t)=>r.type.unit===le.DAY?rc(r,t):nc(r,t),ac=({values:r},t)=>1e3*Lt(r[t]),cc=({values:r},t)=>Lt(r[t]),uc=({values:r},t)=>aa(r[t],BigInt(1e3)),hc=({values:r},t)=>aa(r[t],BigInt(1e6)),ol=(r,t)=>{switch(r.type.unit){case at.SECOND:return ac(r,t);case at.MILLISECOND:return cc(r,t);case at.MICROSECOND:return uc(r,t);case at.NANOSECOND:return hc(r,t)}},lc=({values:r},t)=>r[t],fc=({values:r},t)=>r[t],dc=({values:r},t)=>r[t],pc=({values:r},t)=>r[t],al=(r,t)=>{switch(r.type.unit){case at.SECOND:return lc(r,t);case at.MILLISECOND:return fc(r,t);case at.MICROSECOND:return dc(r,t);case at.NANOSECOND:return pc(r,t)}},cl=({values:r,stride:t},e)=>ls.decimal(r.subarray(t*e,t*(e+1))),ul=(r,t)=>{const{valueOffsets:e,stride:n,children:o}=r,{[t*n]:i,[t*n+1]:a}=e,f=o[0].slice(i,a-i);return new Ft([f])},hl=(r,t)=>{const{valueOffsets:e,children:n}=r,{[t]:o,[t+1]:i}=e,a=n[0];return new ps(a.slice(o,i-o))},ll=(r,t)=>new ds(r,t),fl=(r,t)=>r.type.mode===re.Dense?yc(r,t):gc(r,t),yc=(r,t)=>{const e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return ne.visit(n,r.valueOffsets[t])},gc=(r,t)=>{const e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return ne.visit(n,t)},dl=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},pl=(r,t)=>r.type.unit===Ee.DAY_TIME?mc(r,t):wc(r,t),mc=({values:r},t)=>r.subarray(2*t,2*(t+1)),wc=({values:r},t)=>{const e=r[t],n=new Int32Array(2);return n[0]=Math.trunc(e/12),n[1]=Math.trunc(e%12),n},bc=({values:r},t)=>r[t],_c=({values:r},t)=>r[t],Sc=({values:r},t)=>r[t],Ic=({values:r},t)=>r[t],yl=(r,t)=>{switch(r.type.unit){case at.SECOND:return bc(r,t);case at.MILLISECOND:return _c(r,t);case at.MICROSECOND:return Sc(r,t);case at.NANOSECOND:return Ic(r,t)}},gl=(r,t)=>{const{stride:e,children:n}=r,i=n[0].slice(t*e,e);return new Ft([i])};nt.prototype.visitNull=ut(Qh);nt.prototype.visitBool=ut(tl);nt.prototype.visitInt=ut(nl);nt.prototype.visitInt8=ut(He);nt.prototype.visitInt16=ut(He);nt.prototype.visitInt32=ut(He);nt.prototype.visitInt64=ut(ic);nt.prototype.visitUint8=ut(He);nt.prototype.visitUint16=ut(He);nt.prototype.visitUint32=ut(He);nt.prototype.visitUint64=ut(ic);nt.prototype.visitFloat=ut(il);nt.prototype.visitFloat16=ut(el);nt.prototype.visitFloat32=ut(He);nt.prototype.visitFloat64=ut(He);nt.prototype.visitUtf8=ut(oc);nt.prototype.visitLargeUtf8=ut(oc);nt.prototype.visitBinary=ut(sc);nt.prototype.visitLargeBinary=ut(sc);nt.prototype.visitFixedSizeBinary=ut(rl);nt.prototype.visitDate=ut(sl);nt.prototype.visitDateDay=ut(rc);nt.prototype.visitDateMillisecond=ut(nc);nt.prototype.visitTimestamp=ut(ol);nt.prototype.visitTimestampSecond=ut(ac);nt.prototype.visitTimestampMillisecond=ut(cc);nt.prototype.visitTimestampMicrosecond=ut(uc);nt.prototype.visitTimestampNanosecond=ut(hc);nt.prototype.visitTime=ut(al);nt.prototype.visitTimeSecond=ut(lc);nt.prototype.visitTimeMillisecond=ut(fc);nt.prototype.visitTimeMicrosecond=ut(dc);nt.prototype.visitTimeNanosecond=ut(pc);nt.prototype.visitDecimal=ut(cl);nt.prototype.visitList=ut(ul);nt.prototype.visitStruct=ut(ll);nt.prototype.visitUnion=ut(fl);nt.prototype.visitDenseUnion=ut(yc);nt.prototype.visitSparseUnion=ut(gc);nt.prototype.visitDictionary=ut(dl);nt.prototype.visitInterval=ut(pl);nt.prototype.visitIntervalDayTime=ut(mc);nt.prototype.visitIntervalYearMonth=ut(wc);nt.prototype.visitDuration=ut(yl);nt.prototype.visitDurationSecond=ut(bc);nt.prototype.visitDurationMillisecond=ut(_c);nt.prototype.visitDurationMicrosecond=ut(Sc);nt.prototype.visitDurationNanosecond=ut(Ic);nt.prototype.visitFixedSizeList=ut(gl);nt.prototype.visitMap=ut(hl);const ne=new nt,pr=Symbol.for("keys"),Ir=Symbol.for("vals"),yr=Symbol.for("kKeysAsStrings"),Vi=Symbol.for("_kKeysAsStrings");class ps{constructor(t){return this[pr]=new Ft([t.children[0]]).memoize(),this[Ir]=t.children[1],new Proxy(this,new wl)}get[yr](){return this[Vi]||(this[Vi]=Array.from(this[pr].toArray(),String))}[Symbol.iterator](){return new ml(this[pr],this[Ir])}get size(){return this[pr].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[pr],e=this[Ir],n={};for(let o=-1,i=t.length;++o<i;)n[t.get(o)]=ne.visit(e,o);return n}toString(){return`{${[...this].map(([t,e])=>`${on(t)}: ${on(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class ml{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),ne.visit(this.vals,t)]})}}class wl{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[yr]}has(t,e){return t[yr].includes(e)}getOwnPropertyDescriptor(t,e){if(t[yr].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const n=t[yr].indexOf(e);if(n!==-1){const o=ne.visit(Reflect.get(t,Ir),n);return Reflect.set(t,e,o),o}}set(t,e,n){const o=t[yr].indexOf(e);return o!==-1?(fe.visit(Reflect.get(t,Ir),o,n),Reflect.set(t,e,n)):Reflect.has(t,e)?Reflect.set(t,e,n):!1}}Object.defineProperties(ps.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[pr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ir]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Vi]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let no;function Bc(r,t,e,n){const{length:o=0}=r;let i=typeof t!="number"?0:t,a=typeof e!="number"?o:e;return i<0&&(i=(i%o+o)%o),a<0&&(a=(a%o+o)%o),a<i&&(no=i,i=a,a=no),a>o&&(a=o),n?n(r,i,a):[i,a]}const ys=(r,t)=>r<0?t+r:r,io=r=>r!==r;function Fr(r){if(typeof r!=="object"||r===null)return io(r)?io:e=>e===r;if(r instanceof Date){const e=r.valueOf();return n=>n instanceof Date?n.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?yh(r,e):!1:r instanceof Map?_l(r):Array.isArray(r)?bl(r):r instanceof Ft?Sl(r):Il(r,!0)}function bl(r){const t=[];for(let e=-1,n=r.length;++e<n;)t[e]=Fr(r[e]);return yi(t)}function _l(r){let t=-1;const e=[];for(const n of r.values())e[++t]=Fr(n);return yi(e)}function Sl(r){const t=[];for(let e=-1,n=r.length;++e<n;)t[e]=Fr(r.get(e));return yi(t)}function Il(r,t=!1){const e=Object.keys(r);if(!t&&e.length===0)return()=>!1;const n=[];for(let o=-1,i=e.length;++o<i;)n[o]=Fr(r[e[o]]);return yi(n,e)}function yi(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return Bl(r,e);case Map:return so(r,e,e.keys());case ps:case ds:case Object:case void 0:return so(r,e,t||Object.keys(e))}return e instanceof Ft?vl(r,e):!1}}function Bl(r,t){const e=r.length;if(t.length!==e)return!1;for(let n=-1;++n<e;)if(!r[n](t[n]))return!1;return!0}function vl(r,t){const e=r.length;if(t.length!==e)return!1;for(let n=-1;++n<e;)if(!r[n](t.get(n)))return!1;return!0}function so(r,t,e){const n=e[Symbol.iterator](),o=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),i=t instanceof Map?t.values():Object.values(t)[Symbol.iterator]();let a=0;const c=r.length;let f=i.next(),p=n.next(),g=o.next();for(;a<c&&!p.done&&!g.done&&!f.done&&!(p.value!==g.value||!r[a](f.value));++a,p=n.next(),g=o.next(),f=i.next());return a===c&&p.done&&g.done&&f.done?!0:(n.return&&n.return(),o.return&&o.return(),i.return&&i.return(),!1)}function vc(r,t,e,n){return(e&1<<n)!==0}function Al(r,t,e,n){return(e&1<<n)>>n}function oo(r,t,e){const n=e.byteLength+7&-8;if(r>0||e.byteLength<n){const o=new Uint8Array(n);return o.set(r%8===0?e.subarray(r>>3):Wi(new gs(e,r,t,null,vc)).subarray(0,n)),o}return e}function Wi(r){const t=[];let e=0,n=0,o=0;for(const a of r)a&&(o|=1<<n),++n===8&&(t[e++]=o,o=n=0);(e===0||n>0)&&(t[e++]=o);const i=new Uint8Array(t.length+7&-8);return i.set(t),i}class gs{constructor(t,e,n,o,i){this.bytes=t,this.length=n,this.context=o,this.get=i,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 Zi(r,t,e){if(e-t<=0)return 0;if(e-t<8){let i=0;for(const a of new gs(r,t,e-t,r,Al))i+=a;return i}const n=e>>3<<3,o=t+(t%8===0?0:8-t%8);return Zi(r,t,o)+Zi(r,n,e)+xl(r,o>>3,n-o>>3)}function xl(r,t,e){let n=0,o=Math.trunc(t);const i=new DataView(r.buffer,r.byteOffset,r.byteLength),a=e===void 0?r.byteLength:o+e;for(;a-o>=4;)n+=Ai(i.getUint32(o)),o+=4;for(;a-o>=2;)n+=Ai(i.getUint16(o)),o+=2;for(;a-o>=1;)n+=Ai(i.getUint8(o)),o+=1;return n}function Ai(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const El=-1;class Et{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){const{type:t}=this;return tt.isSparseUnion(t)?this.children.some(e=>e.nullable):tt.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:e,values:n,nullBitmap:o,typeIds:i}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),o&&(t+=o.byteLength),i&&(t+=i.byteLength),this.children.reduce((a,c)=>a+c.byteLength,t)}get nullCount(){if(tt.isUnion(this.type))return this.children.reduce((n,o)=>n+o.nullCount,0);let t=this._nullCount,e;return t<=El&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-Zi(e,this.offset,this.offset+this.length)),t}constructor(t,e,n,o,i,a=[],c){this.type=t,this.children=a,this.dictionary=c,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(o||0,-1));let f;i instanceof Et?(this.stride=i.stride,this.values=i.values,this.typeIds=i.typeIds,this.nullBitmap=i.nullBitmap,this.valueOffsets=i.valueOffsets):(this.stride=Fe(t),i&&((f=i[0])&&(this.valueOffsets=f),(f=i[1])&&(this.values=f),(f=i[2])&&(this.nullBitmap=f),(f=i[3])&&(this.typeIds=f)))}getValid(t){const{type:e}=this;if(tt.isUnion(e)){const n=e,o=this.children[n.typeIdToChildIndex[this.typeIds[t]]],i=n.mode===re.Dense?this.valueOffsets[t]:t;return o.getValid(i)}if(this.nullable&&this.nullCount>0){const n=this.offset+t;return(this.nullBitmap[n>>3]&1<<n%8)!==0}return!0}setValid(t,e){let n;const{type:o}=this;if(tt.isUnion(o)){const i=o,a=this.children[i.typeIdToChildIndex[this.typeIds[t]]],c=i.mode===re.Dense?this.valueOffsets[t]:t;n=a.getValid(c),a.setValid(c,e)}else{let{nullBitmap:i}=this;const{offset:a,length:c}=this,f=a+t,p=1<<f%8,g=f>>3;(!i||i.byteLength<=g)&&(i=new Uint8Array((a+c+63&-64)>>3).fill(255),this.nullCount>0?(i.set(oo(a,c,this.nullBitmap),0),Object.assign(this,{nullBitmap:i})):Object.assign(this,{nullBitmap:i,_nullCount:0}));const v=i[g];n=(v&p)!==0,i[g]=e?v|p:v&~p}return n!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,n=this.length,o=this._nullCount,i=this,a=this.children){return new Et(t,e,n,o,i,a,this.dictionary)}slice(t,e){const{stride:n,typeId:o,children:i}=this,a=+(this._nullCount===0)-1,c=o===16?n:1,f=this._sliceBuffers(t,e,n,o);return this.clone(this.type,this.offset+t,e,a,f,i.length===0||this.valueOffsets?i:this._sliceChildren(i,c*t,c*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===x.Null)return this.clone(this.type,0,t,0);const{length:e,nullCount:n}=this,o=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);o[e>>3]=(1<<e-(e&-8))-1,n>0&&o.set(oo(this.offset,e,this.nullBitmap),0);const i=this.buffers;return i[Me.VALIDITY]=o,this.clone(this.type,0,t,n+(t-e),i)}_sliceBuffers(t,e,n,o){let i;const{buffers:a}=this;return(i=a[Me.TYPE])&&(a[Me.TYPE]=i.subarray(t,t+e)),(i=a[Me.OFFSET])&&(a[Me.OFFSET]=i.subarray(t,t+e+1))||(i=a[Me.DATA])&&(a[Me.DATA]=o===6?i:i.subarray(n*t,n*(t+e))),a}_sliceChildren(t,e,n){return t.map(o=>o.slice(e,n))}}Et.prototype.children=Object.freeze([]);class nn extends St{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:e,["offset"]:n=0,["length"]:o=0}=t;return new Et(e,n,o,o)}visitBool(t){const{["type"]:e,["offset"]:n=0}=t,o=It(t.nullBitmap),i=Ot(e.ArrayType,t.data),{["length"]:a=i.length>>3,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,o])}visitInt(t){const{["type"]:e,["offset"]:n=0}=t,o=It(t.nullBitmap),i=Ot(e.ArrayType,t.data),{["length"]:a=i.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,o])}visitFloat(t){const{["type"]:e,["offset"]:n=0}=t,o=It(t.nullBitmap),i=Ot(e.ArrayType,t.data),{["length"]:a=i.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,o])}visitUtf8(t){const{["type"]:e,["offset"]:n=0}=t,o=It(t.data),i=It(t.nullBitmap),a=kr(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:f=t.nullBitmap?-1:0}=t;return new Et(e,n,c,f,[a,o,i])}visitLargeUtf8(t){const{["type"]:e,["offset"]:n=0}=t,o=It(t.data),i=It(t.nullBitmap),a=Gs(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:f=t.nullBitmap?-1:0}=t;return new Et(e,n,c,f,[a,o,i])}visitBinary(t){const{["type"]:e,["offset"]:n=0}=t,o=It(t.data),i=It(t.nullBitmap),a=kr(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:f=t.nullBitmap?-1:0}=t;return new Et(e,n,c,f,[a,o,i])}visitLargeBinary(t){const{["type"]:e,["offset"]:n=0}=t,o=It(t.data),i=It(t.nullBitmap),a=Gs(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:f=t.nullBitmap?-1:0}=t;return new Et(e,n,c,f,[a,o,i])}visitFixedSizeBinary(t){const{["type"]:e,["offset"]:n=0}=t,o=It(t.nullBitmap),i=Ot(e.ArrayType,t.data),{["length"]:a=i.length/Fe(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,o])}visitDate(t){const{["type"]:e,["offset"]:n=0}=t,o=It(t.nullBitmap),i=Ot(e.ArrayType,t.data),{["length"]:a=i.length/Fe(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,o])}visitTimestamp(t){const{["type"]:e,["offset"]:n=0}=t,o=It(t.nullBitmap),i=Ot(e.ArrayType,t.data),{["length"]:a=i.length/Fe(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,o])}visitTime(t){const{["type"]:e,["offset"]:n=0}=t,o=It(t.nullBitmap),i=Ot(e.ArrayType,t.data),{["length"]:a=i.length/Fe(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,o])}visitDecimal(t){const{["type"]:e,["offset"]:n=0}=t,o=It(t.nullBitmap),i=Ot(e.ArrayType,t.data),{["length"]:a=i.length/Fe(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,o])}visitList(t){const{["type"]:e,["offset"]:n=0,["child"]:o}=t,i=It(t.nullBitmap),a=kr(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:f=t.nullBitmap?-1:0}=t;return new Et(e,n,c,f,[a,void 0,i],[o])}visitStruct(t){const{["type"]:e,["offset"]:n=0,["children"]:o=[]}=t,i=It(t.nullBitmap),{length:a=o.reduce((f,{length:p})=>Math.max(f,p),0),nullCount:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,void 0,i],o)}visitUnion(t){const{["type"]:e,["offset"]:n=0,["children"]:o=[]}=t,i=Ot(e.ArrayType,t.typeIds),{["length"]:a=i.length,["nullCount"]:c=-1}=t;if(tt.isSparseUnion(e))return new Et(e,n,a,c,[void 0,void 0,void 0,i],o);const f=kr(t.valueOffsets);return new Et(e,n,a,c,[f,void 0,void 0,i],o)}visitDictionary(t){const{["type"]:e,["offset"]:n=0}=t,o=It(t.nullBitmap),i=Ot(e.indices.ArrayType,t.data),{["dictionary"]:a=new Ft([new nn().visit({type:e.dictionary})])}=t,{["length"]:c=i.length,["nullCount"]:f=t.nullBitmap?-1:0}=t;return new Et(e,n,c,f,[void 0,i,o],[],a)}visitInterval(t){const{["type"]:e,["offset"]:n=0}=t,o=It(t.nullBitmap),i=Ot(e.ArrayType,t.data),{["length"]:a=i.length/Fe(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,o])}visitDuration(t){const{["type"]:e,["offset"]:n=0}=t,o=It(t.nullBitmap),i=Ot(e.ArrayType,t.data),{["length"]:a=i.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,o])}visitFixedSizeList(t){const{["type"]:e,["offset"]:n=0,["child"]:o=new nn().visit({type:e.valueType})}=t,i=It(t.nullBitmap),{["length"]:a=o.length/Fe(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,void 0,i],[o])}visitMap(t){const{["type"]:e,["offset"]:n=0,["child"]:o=new nn().visit({type:e.childType})}=t,i=It(t.nullBitmap),a=kr(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:f=t.nullBitmap?-1:0}=t;return new Et(e,n,c,f,[a,void 0,i],[o])}}const Tl=new nn;function _t(r){return Tl.visit(r)}class ao{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){const 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 Ol(r){return r.some(t=>t.nullable)}function Ac(r){return r.reduce((t,e)=>t+e.nullCount,0)}function xc(r){return r.reduce((t,e,n)=>(t[n+1]=t[n]+e.length,t),new Uint32Array(r.length+1))}function Ec(r,t,e,n){const o=[];for(let i=-1,a=r.length;++i<a;){const c=r[i],f=t[i],{length:p}=c;if(f>=n)break;if(e>=f+p)continue;if(f>=e&&f+p<=n){o.push(c);continue}const g=Math.max(0,e-f),v=Math.min(n-f,p);o.push(c.slice(g,v-g))}return o.length===0&&o.push(r[0].slice(0,0)),o}function ms(r,t,e,n){let o=0,i=0,a=t.length-1;do{if(o>=a-1)return e<t[a]?n(r,o,e-t[o]):null;i=o+Math.trunc((a-o)*.5),e<t[i]?a=i:o=i}while(o<a)}function ws(r,t){return r.getValid(t)}function Xn(r){function t(e,n,o){return r(e[n],o)}return function(e){const n=this.data;return ms(n,this._offsets,e,t)}}function Tc(r){let t;function e(n,o,i){return r(n[o],i,t)}return function(n,o){const i=this.data;t=o;const a=ms(i,this._offsets,n,e);return t=void 0,a}}function Oc(r){let t;function e(n,o,i){let a=i,c=0,f=0;for(let p=o-1,g=n.length;++p<g;){const v=n[p];if(~(c=r(v,t,a)))return f+c;a=0,f+=v.length}return-1}return function(n,o){t=n;const i=this.data,a=typeof o!="number"?e(i,0,0):ms(i,this._offsets,o,e);return t=void 0,a}}class it extends St{}function Ml(r,t){return t===null&&r.length>0?0:-1}function Fl(r,t){const{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(const o of new gs(e,r.offset+(t||0),r.length,e,vc)){if(!o)return n;++n}return-1}function dt(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case x.Union:break;case x.Dictionary:break;default:return Fl(r,e)}const n=ne.getVisitFn(r),o=Fr(t);for(let i=(e||0)-1,a=r.length;++i<a;)if(o(n(r,i)))return i;return-1}function Mc(r,t,e){const n=ne.getVisitFn(r),o=Fr(t);for(let i=(e||0)-1,a=r.length;++i<a;)if(o(n(r,i)))return i;return-1}it.prototype.visitNull=Ml;it.prototype.visitBool=dt;it.prototype.visitInt=dt;it.prototype.visitInt8=dt;it.prototype.visitInt16=dt;it.prototype.visitInt32=dt;it.prototype.visitInt64=dt;it.prototype.visitUint8=dt;it.prototype.visitUint16=dt;it.prototype.visitUint32=dt;it.prototype.visitUint64=dt;it.prototype.visitFloat=dt;it.prototype.visitFloat16=dt;it.prototype.visitFloat32=dt;it.prototype.visitFloat64=dt;it.prototype.visitUtf8=dt;it.prototype.visitLargeUtf8=dt;it.prototype.visitBinary=dt;it.prototype.visitLargeBinary=dt;it.prototype.visitFixedSizeBinary=dt;it.prototype.visitDate=dt;it.prototype.visitDateDay=dt;it.prototype.visitDateMillisecond=dt;it.prototype.visitTimestamp=dt;it.prototype.visitTimestampSecond=dt;it.prototype.visitTimestampMillisecond=dt;it.prototype.visitTimestampMicrosecond=dt;it.prototype.visitTimestampNanosecond=dt;it.prototype.visitTime=dt;it.prototype.visitTimeSecond=dt;it.prototype.visitTimeMillisecond=dt;it.prototype.visitTimeMicrosecond=dt;it.prototype.visitTimeNanosecond=dt;it.prototype.visitDecimal=dt;it.prototype.visitList=dt;it.prototype.visitStruct=dt;it.prototype.visitUnion=dt;it.prototype.visitDenseUnion=Mc;it.prototype.visitSparseUnion=Mc;it.prototype.visitDictionary=dt;it.prototype.visitInterval=dt;it.prototype.visitIntervalDayTime=dt;it.prototype.visitIntervalYearMonth=dt;it.prototype.visitDuration=dt;it.prototype.visitDurationSecond=dt;it.prototype.visitDurationMillisecond=dt;it.prototype.visitDurationMicrosecond=dt;it.prototype.visitDurationNanosecond=dt;it.prototype.visitFixedSizeList=dt;it.prototype.visitMap=dt;const Qn=new it;class st extends St{}function ht(r){const{type:t}=r;if(r.nullCount===0&&r.stride===1&&(tt.isInt(t)&&t.bitWidth!==64||tt.isTime(t)&&t.bitWidth!==64||tt.isFloat(t)&&t.precision!==Jt.HALF))return new ao(r.data.length,n=>{const o=r.data[n];return o.values.subarray(0,o.length)[Symbol.iterator]()});let e=0;return new ao(r.data.length,n=>{const i=r.data[n].length,a=r.slice(e,e+i);return e+=i,new Nl(a)})}class Nl{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}}st.prototype.visitNull=ht;st.prototype.visitBool=ht;st.prototype.visitInt=ht;st.prototype.visitInt8=ht;st.prototype.visitInt16=ht;st.prototype.visitInt32=ht;st.prototype.visitInt64=ht;st.prototype.visitUint8=ht;st.prototype.visitUint16=ht;st.prototype.visitUint32=ht;st.prototype.visitUint64=ht;st.prototype.visitFloat=ht;st.prototype.visitFloat16=ht;st.prototype.visitFloat32=ht;st.prototype.visitFloat64=ht;st.prototype.visitUtf8=ht;st.prototype.visitLargeUtf8=ht;st.prototype.visitBinary=ht;st.prototype.visitLargeBinary=ht;st.prototype.visitFixedSizeBinary=ht;st.prototype.visitDate=ht;st.prototype.visitDateDay=ht;st.prototype.visitDateMillisecond=ht;st.prototype.visitTimestamp=ht;st.prototype.visitTimestampSecond=ht;st.prototype.visitTimestampMillisecond=ht;st.prototype.visitTimestampMicrosecond=ht;st.prototype.visitTimestampNanosecond=ht;st.prototype.visitTime=ht;st.prototype.visitTimeSecond=ht;st.prototype.visitTimeMillisecond=ht;st.prototype.visitTimeMicrosecond=ht;st.prototype.visitTimeNanosecond=ht;st.prototype.visitDecimal=ht;st.prototype.visitList=ht;st.prototype.visitStruct=ht;st.prototype.visitUnion=ht;st.prototype.visitDenseUnion=ht;st.prototype.visitSparseUnion=ht;st.prototype.visitDictionary=ht;st.prototype.visitInterval=ht;st.prototype.visitIntervalDayTime=ht;st.prototype.visitIntervalYearMonth=ht;st.prototype.visitDuration=ht;st.prototype.visitDurationSecond=ht;st.prototype.visitDurationMillisecond=ht;st.prototype.visitDurationMicrosecond=ht;st.prototype.visitDurationNanosecond=ht;st.prototype.visitFixedSizeList=ht;st.prototype.visitMap=ht;const bs=new st;var Fc;const Nc={},kc={};class Ft{constructor(t){var e,n,o;const i=t[0]instanceof Ft?t.flatMap(c=>c.data):t;if(i.length===0||i.some(c=>!(c instanceof Et)))throw new TypeError("Vector constructor expects an Array of Data instances.");const a=(e=i[0])===null||e===void 0?void 0:e.type;switch(i.length){case 0:this._offsets=[0];break;case 1:{const{get:c,set:f,indexOf:p}=Nc[a.typeId],g=i[0];this.isValid=v=>ws(g,v),this.get=v=>c(g,v),this.set=(v,C)=>f(g,v,C),this.indexOf=v=>p(g,v),this._offsets=[0,g.length];break}default:Object.setPrototypeOf(this,kc[a.typeId]),this._offsets=xc(i);break}this.data=i,this.type=a,this.stride=Fe(a),this.numChildren=(o=(n=a.children)===null||n===void 0?void 0:n.length)!==null&&o!==void 0?o:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,e)=>t+e.byteLength,0)}get nullable(){return Ol(this.data)}get nullCount(){return Ac(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${x[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(ys(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return bs.visit(this)}concat(...t){return new Ft(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new Ft(Bc(this,t,e,({data:n,_offsets:o},i,a)=>Ec(n,o,i,a)))}toJSON(){return[...this]}toArray(){const{type:t,data:e,length:n,stride:o,ArrayType:i}=this;switch(t.typeId){case x.Int:case x.Float:case x.Decimal:case x.Time:case x.Timestamp:switch(e.length){case 0:return new i;case 1:return e[0].values.subarray(0,n*o);default:return e.reduce((a,{values:c,length:f})=>(a.array.set(c.subarray(0,f*o),a.offset),a.offset+=f*o,a),{array:new i(n*o),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(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new Ft(this.data.map(({children:e})=>e[t])):null}get isMemoized(){return tt.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(tt.isDictionary(this.type)){const t=new ti(this.data[0].dictionary),e=this.data.map(n=>{const o=n.clone();return o.dictionary=t,o});return new Ft(e)}return new ti(this)}unmemoize(){if(tt.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),e=this.data.map(n=>{const o=n.clone();return o.dictionary=t,o});return new Ft(e)}return this}}Fc=Symbol.toStringTag;Ft[Fc]=(r=>{r.type=tt.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0;const t=Object.keys(x).map(e=>x[e]).filter(e=>typeof e=="number"&&e!==x.NONE);for(const e of t){const n=ne.getVisitFnByTypeId(e),o=fe.getVisitFnByTypeId(e),i=Qn.getVisitFnByTypeId(e);Nc[e]={get:n,set:o,indexOf:i},kc[e]=Object.create(r,{isValid:{value:Xn(ws)},get:{value:Xn(ne.getVisitFnByTypeId(e))},set:{value:Tc(fe.getVisitFnByTypeId(e))},indexOf:{value:Oc(Qn.getVisitFnByTypeId(e))}})}return"Vector"})(Ft.prototype);class ti extends Ft{constructor(t){super(t.data);const e=this.get,n=this.set,o=this.slice,i=new Array(this.length);Object.defineProperty(this,"get",{value(a){const c=i[a];if(c!==void 0)return c;const f=e.call(this,a);return i[a]=f,f}}),Object.defineProperty(this,"set",{value(a,c){n.call(this,a,c),i[a]=c}}),Object.defineProperty(this,"slice",{value:(a,c)=>new ti(o.call(this,a,c))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Ft(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Gi{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,n,o){return t.prep(8,24),t.writeInt64(BigInt(o??0)),t.pad(4),t.writeInt32(n),t.writeInt64(BigInt(e??0)),t.offset()}}class ie{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 ie).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+At),(e||new ie).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):zt.V1}schema(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new _e).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new Gi).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}dictionariesLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,e){const n=this.bb.__offset(this.bb_pos,10);return n?(e||new Gi).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}recordBatchesLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,12);return n?(e||new jt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){const 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,zt.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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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)}}class vt{constructor(t=[],e,n,o=zt.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=Yi(this.fields)),this.dictionaries=n,this.metadataVersion=o}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){const e=new Set(t),n=this.fields.filter(o=>e.has(o.name));return new vt(n,this.metadata)}selectAt(t){const e=t.map(n=>this.fields[n]).filter(Boolean);return new vt(e,this.metadata)}assign(...t){const e=t[0]instanceof vt?t[0]:Array.isArray(t[0])?new vt(t[0]):new vt(t),n=[...this.fields],o=mn(mn(new Map,this.metadata),e.metadata),i=e.fields.filter(c=>{const f=n.findIndex(p=>p.name===c.name);return~f?(n[f]=c.clone({metadata:mn(mn(new Map,n[f].metadata),c.metadata)}))&&!1:!0}),a=Yi(i,new Map);return new vt([...n,...i],o,new Map([...this.dictionaries,...a]))}}vt.prototype.fields=null;vt.prototype.metadata=null;vt.prototype.dictionaries=null;class Rt{static new(...t){let[e,n,o,i]=t;return t[0]&&typeof t[0]=="object"&&({name:e}=t[0],n===void 0&&(n=t[0].type),o===void 0&&(o=t[0].nullable),i===void 0&&(i=t[0].metadata)),new Rt(`${e}`,n,o,i)}constructor(t,e,n=!1,o){this.name=t,this.type=e,this.nullable=n,this.metadata=o||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,n,o,i]=t;return!t[0]||typeof t[0]!="object"?[e=this.name,n=this.type,o=this.nullable,i=this.metadata]=t:{name:e=this.name,type:n=this.type,nullable:o=this.nullable,metadata:i=this.metadata}=t[0],Rt.new(e,n,o,i)}}Rt.prototype.type=null;Rt.prototype.name=null;Rt.prototype.nullable=null;Rt.prototype.metadata=null;function mn(r,t){return new Map([...r||new Map,...t||new Map])}function Yi(r,t=new Map){for(let e=-1,n=r.length;++e<n;){const i=r[e].type;if(tt.isDictionary(i)){if(!t.has(i.id))t.set(i.id,i.dictionary);else if(t.get(i.id)!==i.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}i.children&&i.children.length>0&&Yi(i.children,t)}return t}var kl=na,Dl=vr;class _s{static decode(t){t=new Dl(It(t));const e=ie.getRootAsFooter(t),n=vt.decode(e.schema(),new Map,e.version());return new Ul(n,e)}static encode(t){const e=new kl,n=vt.encode(e,t.schema);ie.startRecordBatchesVector(e,t.numRecordBatches);for(const a of[...t.recordBatches()].slice().reverse())Er.encode(e,a);const o=e.endVector();ie.startDictionariesVector(e,t.numDictionaries);for(const a of[...t.dictionaryBatches()].slice().reverse())Er.encode(e,a);const i=e.endVector();return ie.startFooter(e),ie.addSchema(e,n),ie.addVersion(e,zt.V5),ie.addRecordBatches(e,o),ie.addDictionaries(e,i),ie.finishFooterBuffer(e,ie.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=zt.V5,n,o){this.schema=t,this.version=e,n&&(this._recordBatches=n),o&&(this._dictionaryBatches=o)}*recordBatches(){for(let t,e=-1,n=this.numRecordBatches;++e<n;)(t=this.getRecordBatch(e))&&(yield t)}*dictionaryBatches(){for(let t,e=-1,n=this.numDictionaries;++e<n;)(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}}class Ul extends _s{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){const e=this._footer.recordBatches(t);if(e)return Er.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){const e=this._footer.dictionaries(t);if(e)return Er.decode(e)}return null}}class Er{static decode(t){return new Er(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,e){const{metaDataLength:n}=e,o=BigInt(e.offset),i=BigInt(e.bodyLength);return Gi.createBlock(t,o,n,i)}constructor(t,e,n){this.metaDataLength=t,this.offset=Lt(n),this.bodyLength=Lt(e)}}const Ct=Object.freeze({done:!0,value:void 0});class co{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class Dc{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())}}class Ll extends Dc{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return gt(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){const{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(Ct);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return ae.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return ae.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return gt(this,void 0,void 0,function*(){return yield this.abort(t),Ct})}return(t){return gt(this,void 0,void 0,function*(){return yield this.close(),Ct})}read(t){return gt(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return gt(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,n)=>{this.resolvers.push({resolve:e,reject:n})}):Promise.resolve(Ct)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class Rl extends Ll{write(t){if((t=It(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Ri(this.toUint8Array(!0)):this.toUint8Array(!1).then(Ri)}toUint8Array(t=!1){return t?xe(this._values)[0]:gt(this,void 0,void 0,function*(){var e,n,o,i;const a=[];let c=0;try{for(var f=!0,p=wr(this),g;g=yield p.next(),e=g.done,!e;f=!0){i=g.value,f=!1;const v=i;a.push(v),c+=v.byteLength}}catch(v){n={error:v}}finally{try{!f&&!e&&(o=p.return)&&(yield o.call(p))}finally{if(n)throw n.error}}return xe(a,c)[0]})}}class ei{constructor(t){t&&(this.source=new Cl(ae.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)}}class Tr{constructor(t){t instanceof Tr?this.source=t.source:t instanceof Rl?this.source=new Ke(ae.fromAsyncIterable(t)):ta(t)?this.source=new Ke(ae.fromNodeStream(t)):us(t)?this.source=new Ke(ae.fromDOMStream(t)):Xo(t)?this.source=new Ke(ae.fromDOMStream(t.body)):pi(t)?this.source=new Ke(ae.fromIterable(t)):sn(t)?this.source=new Ke(ae.fromAsyncIterable(t)):cs(t)&&(this.source=new Ke(ae.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)}}class Cl{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)||Ct)}return(t){return Object.create(this.source.return&&this.source.return(t)||Ct)}}class Ke{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return gt(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return gt(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return gt(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return gt(this,arguments,void 0,function*(e,n="read"){return yield this.source.next({cmd:n,size:e})})}throw(t){return gt(this,void 0,void 0,function*(){const e=this.source.throw&&(yield this.source.throw(t))||Ct;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return gt(this,void 0,void 0,function*(){const e=this.source.return&&(yield this.source.return(t))||Ct;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}}class uo extends ei{constructor(t,e){super(),this.position=0,this.buffer=It(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){const{buffer:e,byteOffset:n}=this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){const{buffer:e,size:n,position:o}=this;return e&&o<n?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(n,o+Math.min(n-o,t)),e.subarray(o,this.position)):null}readAt(t,e){const n=this.buffer,o=Math.min(this.size,t+e);return n?n.subarray(t,o):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}}}class ri extends Tr{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=gt(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return gt(this,void 0,void 0,function*(){const{buffer:e,byteOffset:n}=yield this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)})}seek(t){return gt(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 gt(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:e,size:n,position:o}=this;if(e&&o<n){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let i=o,a=0,c=0;const f=Math.min(n,i+Math.min(n-i,t)),p=new Uint8Array(Math.max(0,(this.position=f)-i));for(;(i+=c)<f&&(a+=c)<p.byteLength;)({bytesRead:c}=yield e.read(p,a,p.byteLength-a,i));return p}return null})}readAt(t,e){return gt(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:n,size:o}=this;if(n&&t+e<o){const i=Math.min(o,t+e),a=new Uint8Array(i-t);return(yield n.read(a,0,e,t)).buffer}return new Uint8Array(e)})}close(){return gt(this,void 0,void 0,function*(){const t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return gt(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return gt(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}}const Pl=65536;function mr(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}const Or=8,Ss=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class Uc{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){const e=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let o=e[3]*n[3];this.buffer[0]=o&65535;let i=o>>>16;return o=e[2]*n[3],i+=o,o=e[3]*n[2]>>>0,i+=o,this.buffer[0]+=i<<16,this.buffer[1]=i>>>0<o?Pl:0,this.buffer[1]+=i>>>16,this.buffer[1]+=e[1]*n[3]+e[2]*n[2]+e[3]*n[1],this.buffer[1]+=e[0]*n[3]+e[1]*n[2]+e[2]*n[1]+e[3]*n[0]<<16,this}_plus(t){const 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`${mr(this.buffer[1])} ${mr(this.buffer[0])}`}}class Tt extends Uc{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,e=new Uint32Array(2)){return Tt.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return Tt.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){const n=t.length,o=new Tt(e);for(let i=0;i<n;){const a=Or<n-i?Or:n-i,c=new Tt(new Uint32Array([Number.parseInt(t.slice(i,i+a),10),0])),f=new Tt(new Uint32Array([Ss[a],0]));o.times(f),o.plus(c),i+=a}return o}static convertArray(t){const e=new Uint32Array(t.length*2);for(let n=-1,o=t.length;++n<o;)Tt.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new Tt(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new Tt(new Uint32Array(t.buffer)).plus(e)}}class te extends Uc{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){const e=this.buffer[1]<<0,n=t.buffer[1]<<0;return e<n||e===n&&this.buffer[0]<t.buffer[0]}static from(t,e=new Uint32Array(2)){return te.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return te.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){const n=t.startsWith("-"),o=t.length,i=new te(e);for(let a=n?1:0;a<o;){const c=Or<o-a?Or:o-a,f=new te(new Uint32Array([Number.parseInt(t.slice(a,a+c),10),0])),p=new te(new Uint32Array([Ss[c],0]));i.times(p),i.plus(f),a+=c}return n?i.negate():i}static convertArray(t){const e=new Uint32Array(t.length*2);for(let n=-1,o=t.length;++n<o;)te.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new te(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new te(new Uint32Array(t.buffer)).plus(e)}}class Se{constructor(t){this.buffer=t}high(){return new te(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new te(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){const e=new Tt(new Uint32Array([this.buffer[3],0])),n=new Tt(new Uint32Array([this.buffer[2],0])),o=new Tt(new Uint32Array([this.buffer[1],0])),i=new Tt(new Uint32Array([this.buffer[0],0])),a=new Tt(new Uint32Array([t.buffer[3],0])),c=new Tt(new Uint32Array([t.buffer[2],0])),f=new Tt(new Uint32Array([t.buffer[1],0])),p=new Tt(new Uint32Array([t.buffer[0],0]));let g=Tt.multiply(i,p);this.buffer[0]=g.low();const v=new Tt(new Uint32Array([g.high(),0]));return g=Tt.multiply(o,p),v.plus(g),g=Tt.multiply(i,f),v.plus(g),this.buffer[1]=v.low(),this.buffer[3]=v.lessThan(g)?1:0,this.buffer[2]=v.high(),new Tt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(Tt.multiply(n,p)).plus(Tt.multiply(o,f)).plus(Tt.multiply(i,c)),this.buffer[3]+=Tt.multiply(e,p).plus(Tt.multiply(n,f)).plus(Tt.multiply(o,c)).plus(Tt.multiply(i,a)).low(),this}plus(t){const 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`${mr(this.buffer[3])} ${mr(this.buffer[2])} ${mr(this.buffer[1])} ${mr(this.buffer[0])}`}static multiply(t,e){return new Se(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new Se(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return Se.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return Se.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){const n=t.startsWith("-"),o=t.length,i=new Se(e);for(let a=n?1:0;a<o;){const c=Or<o-a?Or:o-a,f=new Se(new Uint32Array([Number.parseInt(t.slice(a,a+c),10),0,0,0])),p=new Se(new Uint32Array([Ss[c],0,0,0]));i.times(p),i.plus(f),a+=c}return n?i.negate():i}static convertArray(t){const e=new Uint32Array(t.length*4);for(let n=-1,o=t.length;++n<o;)Se.from(t[n],new Uint32Array(e.buffer,e.byteOffset+4*4*n,4));return e}}class Lc extends St{constructor(t,e,n,o,i=zt.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=e,this.buffers=n,this.dictionaries=o,this.metadataVersion=i}visit(t){return super.visit(t instanceof Rt?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return _t({type:t,length:e})}visitBool(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitInt(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDate(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTime(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitList(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),children:this.visitMany(t.children)})}visitUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return this.metadataVersion<zt.V5&&this.readNullBitmap(t,n),t.mode===re.Sparse?this.visitSparseUnion(t,{length:e,nullCount:n}):this.visitDenseUnion(t,{length:e,nullCount:n})}visitDenseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),child:this.visit(t.children[0])})}visitMap(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),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,n=this.nextBufferRange()){return e>0&&this.readData(t,n)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+e)}readDictionary(t){return this.dictionaries.get(t.id)}}class $l extends Lc{constructor(t,e,n,o,i){super(new Uint8Array(0),e,n,o,i),this.sources=t}readNullBitmap(t,e,{offset:n}=this.nextBufferRange()){return e<=0?new Uint8Array(0):Wi(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return Ot(Uint8Array,Ot(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return Ot(Uint8Array,Ot(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){const{sources:n}=this;return tt.isTimestamp(t)||(tt.isInt(t)||tt.isTime(t))&&t.bitWidth===64||tt.isDuration(t)||tt.isDate(t)&&t.unit===le.MILLISECOND?Ot(Uint8Array,te.convertArray(n[e])):tt.isDecimal(t)?Ot(Uint8Array,Se.convertArray(n[e])):tt.isBinary(t)||tt.isLargeBinary(t)||tt.isFixedSizeBinary(t)?zl(n[e]):tt.isBool(t)?Wi(n[e]):tt.isUtf8(t)||tt.isLargeUtf8(t)?as(n[e].join("")):Ot(Uint8Array,Ot(t.ArrayType,n[e].map(o=>+o)))}}function zl(r){const t=r.join(""),e=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)e[n>>1]=Number.parseInt(t.slice(n,n+2),16);return e}class ot extends St{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((n,o)=>this.compareFields(n,e[o]))}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 Xt(r,t){return t instanceof r.constructor}function nr(r,t){return r===t||Xt(r,t)}function Ce(r,t){return r===t||Xt(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function gi(r,t){return r===t||Xt(r,t)&&r.precision===t.precision}function jl(r,t){return r===t||Xt(r,t)&&r.byteWidth===t.byteWidth}function Is(r,t){return r===t||Xt(r,t)&&r.unit===t.unit}function ln(r,t){return r===t||Xt(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function fn(r,t){return r===t||Xt(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function Vl(r,t){return r===t||Xt(r,t)&&r.children.length===t.children.length&&Je.compareManyFields(r.children,t.children)}function Wl(r,t){return r===t||Xt(r,t)&&r.children.length===t.children.length&&Je.compareManyFields(r.children,t.children)}function Bs(r,t){return r===t||Xt(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&Je.compareManyFields(r.children,t.children)}function Zl(r,t){return r===t||Xt(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&Je.visit(r.indices,t.indices)&&Je.visit(r.dictionary,t.dictionary)}function vs(r,t){return r===t||Xt(r,t)&&r.unit===t.unit}function dn(r,t){return r===t||Xt(r,t)&&r.unit===t.unit}function Gl(r,t){return r===t||Xt(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&Je.compareManyFields(r.children,t.children)}function Yl(r,t){return r===t||Xt(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&Je.compareManyFields(r.children,t.children)}ot.prototype.visitNull=nr;ot.prototype.visitBool=nr;ot.prototype.visitInt=Ce;ot.prototype.visitInt8=Ce;ot.prototype.visitInt16=Ce;ot.prototype.visitInt32=Ce;ot.prototype.visitInt64=Ce;ot.prototype.visitUint8=Ce;ot.prototype.visitUint16=Ce;ot.prototype.visitUint32=Ce;ot.prototype.visitUint64=Ce;ot.prototype.visitFloat=gi;ot.prototype.visitFloat16=gi;ot.prototype.visitFloat32=gi;ot.prototype.visitFloat64=gi;ot.prototype.visitUtf8=nr;ot.prototype.visitLargeUtf8=nr;ot.prototype.visitBinary=nr;ot.prototype.visitLargeBinary=nr;ot.prototype.visitFixedSizeBinary=jl;ot.prototype.visitDate=Is;ot.prototype.visitDateDay=Is;ot.prototype.visitDateMillisecond=Is;ot.prototype.visitTimestamp=ln;ot.prototype.visitTimestampSecond=ln;ot.prototype.visitTimestampMillisecond=ln;ot.prototype.visitTimestampMicrosecond=ln;ot.prototype.visitTimestampNanosecond=ln;ot.prototype.visitTime=fn;ot.prototype.visitTimeSecond=fn;ot.prototype.visitTimeMillisecond=fn;ot.prototype.visitTimeMicrosecond=fn;ot.prototype.visitTimeNanosecond=fn;ot.prototype.visitDecimal=nr;ot.prototype.visitList=Vl;ot.prototype.visitStruct=Wl;ot.prototype.visitUnion=Bs;ot.prototype.visitDenseUnion=Bs;ot.prototype.visitSparseUnion=Bs;ot.prototype.visitDictionary=Zl;ot.prototype.visitInterval=vs;ot.prototype.visitIntervalDayTime=vs;ot.prototype.visitIntervalYearMonth=vs;ot.prototype.visitDuration=dn;ot.prototype.visitDurationSecond=dn;ot.prototype.visitDurationMillisecond=dn;ot.prototype.visitDurationMicrosecond=dn;ot.prototype.visitDurationNanosecond=dn;ot.prototype.visitFixedSizeList=Gl;ot.prototype.visitMap=Yl;const Je=new ot;function Jl(r,t){return Je.compareSchemas(r,t)}function xi(r,t){return Hl(r,t.map(e=>e.data.concat()))}function Hl(r,t){const e=[...r.fields],n=[],o={numBatches:t.reduce((v,C)=>Math.max(v,C.length),0)};let i=0,a=0,c=-1;const f=t.length;let p,g=[];for(;o.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,c=-1;++c<f;)g[c]=p=t[c].shift(),a=Math.min(a,p?p.length:a);Number.isFinite(a)&&(g=ql(e,a,g,t,o),a>0&&(n[i++]=_t({type:new Kt(e),length:a,nullCount:0,children:g.slice()})))}return[r=r.assign(e),n.map(v=>new pe(r,v))]}function ql(r,t,e,n,o){var i;const a=(t+63&-64)>>3;for(let c=-1,f=n.length;++c<f;){const p=e[c],g=p?.length;if(g>=t)g===t?e[c]=p:(e[c]=p.slice(0,t),o.numBatches=Math.max(o.numBatches,n[c].unshift(p.slice(t,g-t))));else{const v=r[c];r[c]=v.clone({nullable:!0}),e[c]=(i=p?._changeLengthAndBackfillNullBitmap(t))!==null&&i!==void 0?i:_t({type:v.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return e}var Rc;class he{constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new vt([]),this._offsets=[0],this;let o,i;t[0]instanceof vt&&(o=t.shift()),t.at(-1)instanceof Uint32Array&&(i=t.pop());const a=f=>{if(f){if(f instanceof pe)return[f];if(f instanceof he)return f.batches;if(f instanceof Et){if(f.type instanceof Kt)return[new pe(new vt(f.type.children),f)]}else{if(Array.isArray(f))return f.flatMap(p=>a(p));if(typeof f[Symbol.iterator]=="function")return[...f].flatMap(p=>a(p));if(typeof f=="object"){const p=Object.keys(f),g=p.map(F=>new Ft([f[F]])),v=o??new vt(p.map((F,T)=>new Rt(String(F),g[T].type,g[T].nullable))),[,C]=xi(v,g);return C.length===0?[new pe(f)]:C}}}return[]},c=t.flatMap(f=>a(f));if(o=(n=o??((e=c[0])===null||e===void 0?void 0:e.schema))!==null&&n!==void 0?n:new vt([]),!(o instanceof vt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const f of c){if(!(f instanceof pe))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Jl(o,f.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=o,this.batches=c,this._offsets=i??xc(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=Ac(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(ys(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?bs.visit(new Ft(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class Fr extends Error{constructor(t,e={}){super(`Node not found: ${t}`,e),this.name="NodeNotFoundError"}}class bi extends Error{constructor(t){super(`Missing key: ${t}`),this.name="KeyError"}}class $n{#t;constructor(t,e,n){typeof t=="number"?this.#t=new Uint8Array(t):t instanceof ArrayBuffer?this.#t=new Uint8Array(t,e,n):this.#t=new Uint8Array(Array.from(t,s=>s?1:0))}get BYTES_PER_ELEMENT(){return 1}get byteOffset(){return this.#t.byteOffset}get byteLength(){return this.#t.byteLength}get buffer(){return this.#t.buffer}get length(){return this.#t.length}get(t){let e=this.#t[t];return typeof e=="number"?e!==0:e}set(t,e){this.#t[t]=e?1:0}fill(t){this.#t.fill(t?1:0)}*[Symbol.iterator](){for(let t=0;t<this.length;t++)yield this.get(t)}}class ds{_data;chars;#t;constructor(t,e,n,s){if(this.chars=t,this.#t=new TextEncoder,typeof e=="number")this._data=new Uint8Array(e*t);else if(e instanceof ArrayBuffer)s&&(s=s*t),this._data=new Uint8Array(e,n,s);else{let i=Array.from(e);this._data=new Uint8Array(i.length*t);for(let a=0;a<i.length;a++)this.set(a,i[a])}}get BYTES_PER_ELEMENT(){return this.chars}get byteOffset(){return this._data.byteOffset}get byteLength(){return this._data.byteLength}get buffer(){return this._data.buffer}get length(){return this.byteLength/this.BYTES_PER_ELEMENT}get(t){const e=new Uint8Array(this.buffer,this.byteOffset+this.chars*t,this.chars);return new TextDecoder().decode(e).replace(/\x00/g,"")}set(t,e){const n=new Uint8Array(this.buffer,this.byteOffset+this.chars*t,this.chars);n.fill(0),n.set(this.#t.encode(e))}fill(t){const e=this.#t.encode(t);for(let n=0;n<this.length;n++)this._data.set(e,n*this.chars)}*[Symbol.iterator](){for(let t=0;t<this.length;t++)yield this.get(t)}}class yn{#t;chars;constructor(t,e,n,s){if(this.chars=t,typeof e=="number")this.#t=new Int32Array(e*t);else if(e instanceof ArrayBuffer)s&&(s*=t),this.#t=new Int32Array(e,n,s);else{const i=e,a=new yn(t,1);this.#t=new Int32Array(function*(){for(let c of i)a.set(0,c),yield*a.#t}())}}get BYTES_PER_ELEMENT(){return this.#t.BYTES_PER_ELEMENT*this.chars}get byteLength(){return this.#t.byteLength}get byteOffset(){return this.#t.byteOffset}get buffer(){return this.#t.buffer}get length(){return this.#t.length/this.chars}get(t){const e=this.chars*t;let n="";for(let s=0;s<this.chars;s++)n+=String.fromCodePoint(this.#t[e+s]);return n.replace(/\u0000/g,"")}set(t,e){const n=this.chars*t,s=this.#t.subarray(n,n+this.chars);s.fill(0);for(let i=0;i<this.chars;i++)s[i]=e.codePointAt(i)??0}fill(t){this.set(0,t);let e=this.#t.subarray(0,this.chars);for(let n=1;n<this.length;n++)this.#t.set(e,n*this.chars)}*[Symbol.iterator](){for(let t=0;t<this.length;t++)yield this.get(t)}}function fs(r){const t=JSON.stringify(r,null,2);return new TextEncoder().encode(t)}function rr(r){const t=new TextDecoder().decode(r);return JSON.parse(t)}function qs(r,t){const e=t/2,n=t-1;let s=0;for(let i=0;i<r.length;i+=t)for(let a=0;a<e;a+=1)s=r[i+a],r[i+a]=r[i+n-a],r[i+n-a]=s}const $u={int8:Int8Array,int16:Int16Array,int32:Int32Array,int64:globalThis.BigInt64Array,uint8:Uint8Array,uint16:Uint16Array,uint32:Uint32Array,uint64:globalThis.BigUint64Array,float32:Float32Array,float64:Float64Array,bool:$n},zu=/v2:([US])(\d+)/;function la(r){if(r==="v2:object")return globalThis.Array;let t=r.match(zu);if(t){let[,n,s]=t;return(n==="U"?yn:ds).bind(null,Number(s))}let e=$u[r];return Yt(e,`Unknown or unsupported data_type: ${r}`),e}function tr(r,t){const e=r.length;typeof t=="string"&&(t=t==="C"?Array.from({length:e},(i,a)=>a):Array.from({length:e},(i,a)=>e-1-a)),Yt(e===t.length,"Order length must match the number of dimensions.");let n=1,s=new Array(e);for(let i=t.length-1;i>=0;i--)s[t[i]]=n,n*=r[t[i]];return s}function ju({name:r,configuration:t}){if(r==="default"){const e=t?.separator??"/";return n=>["c",...n].join(e)}if(r==="v2"){const e=t?.separator??".";return n=>n.join(e)||"0"}throw new Error(`Unknown chunk key encoding: ${r}`)}function Vu(r){if(r==="|O")return{data_type:"v2:object"};let t=r.match(/^([<|>])(.*)$/);Yt(t,`Invalid dtype: ${r}`);let[,e,n]=t,s={b1:"bool",i1:"int8",u1:"uint8",i2:"int16",u2:"uint16",i4:"int32",u4:"uint32",i8:"int64",u8:"uint64",f4:"float32",f8:"float64"}[n]??(n.startsWith("S")||n.startsWith("U")?`v2:${n}`:void 0);return Yt(s,`Unsupported or unknown dtype: ${r}`),e==="|"?{data_type:s}:{data_type:s,endian:e==="<"?"little":"big"}}function Wu(r,t={}){let e=[],n=Vu(r.dtype);r.order==="F"&&e.push({name:"transpose",configuration:{order:"F"}}),"endian"in n&&n.endian==="big"&&e.push({name:"bytes",configuration:{endian:"big"}});for(let{id:s,...i}of r.filters??[])e.push({name:s,configuration:i});if(r.compressor){let{id:s,...i}=r.compressor;e.push({name:s,configuration:i})}return{zarr_format:3,node_type:"array",shape:r.shape,data_type:n.data_type,chunk_grid:{name:"regular",configuration:{chunk_shape:r.chunks}},chunk_key_encoding:{name:"v2",configuration:{separator:r.dimension_separator??"."}},codecs:e,fill_value:r.fill_value,attributes:t}}function Zu(r,t={}){return{zarr_format:3,node_type:"group",attributes:t}}function Gu(r,t){if(t!=="number"&&t!=="bigint"&&t!=="boolean"&&t!=="object"&&t!=="string")return r===t;let e=r==="bool";if(t==="boolean")return e;let n=r.startsWith("v2:U")||r.startsWith("v2:S");if(t==="string")return n;let s=r==="int64"||r==="uint64";if(t==="bigint")return s;let i=r==="v2:object";return t==="object"?i:!n&&!s&&!e&&!i}function Yu(r){return r?.name==="sharding_indexed"}function da(r){return(r.data_type==="uint64"||r.data_type==="int64")&&r.fill_value!=null?BigInt(r.fill_value):r.fill_value}function fa(r,...t){if(!t.some(e=>r instanceof e))throw r}function Yt(r,t=""){if(!r)throw new Error(t)}class ps{kind="array_to_array";constructor(t,e){Yt(t.keepbits>=0,"keepbits must be zero or positive")}static fromConfig(t,e){return new ps(t,e)}encode(t){throw new Error("`BitroundCodec.encode` is not implemented. Please open an issue at https://github.com/manzt/zarrita.js/issues.")}decode(t){return t}}const Ks=Ju();function Ju(){const r=new Uint32Array([305419896]);return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)[0]!==18}function Xs(r){return"BYTES_PER_ELEMENT"in r?r.BYTES_PER_ELEMENT:4}class _i{kind="array_to_bytes";#t;#e;#n;#i;#r;constructor(t,e){this.#r=t?.endian,this.#e=la(e.data_type),this.#i=e.shape,this.#t=tr(e.shape,"C");const n=new this.#e(0);this.#n=n.BYTES_PER_ELEMENT}static fromConfig(t,e){return new _i(t,e)}encode(t){let e=new Uint8Array(t.data.buffer);return Ks&&this.#r==="big"&&qs(e,Xs(this.#e)),e}decode(t){return Ks&&this.#r==="big"&&qs(t,Xs(this.#e)),{data:new this.#e(t.buffer,t.byteOffset,t.byteLength/this.#n),shape:this.#i,stride:this.#t}}}class ys{kind="bytes_to_bytes";static fromConfig(){return new ys}encode(t){throw new Error("Not implemented")}decode(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength-4)}}function Hu(r,t){return Yt(!Number.isNaN(t),"JsonCodec allow_nan is false but NaN was encountered during encoding."),Yt(t!==Number.POSITIVE_INFINITY,"JsonCodec allow_nan is false but Infinity was encountered during encoding."),Yt(t!==Number.NEGATIVE_INFINITY,"JsonCodec allow_nan is false but -Infinity was encountered during encoding."),t}function qu(r,t){return t instanceof Object&&!Array.isArray(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t}class gs{configuration;kind="array_to_bytes";#t;#e;constructor(t={}){this.configuration=t;const{encoding:e="utf-8",skipkeys:n=!1,ensure_ascii:s=!0,check_circular:i=!0,allow_nan:a=!0,sort_keys:c=!0,indent:d,strict:f=!0}=t;let y=t.separators;y||(d?y=[", ",": "]:y=[",",":"]),this.#t={encoding:e,skipkeys:n,ensure_ascii:s,check_circular:i,allow_nan:a,indent:d,separators:y,sort_keys:c},this.#e={strict:f}}static fromConfig(t){return new gs(t)}encode(t){const{indent:e,encoding:n,ensure_ascii:s,check_circular:i,allow_nan:a,sort_keys:c}=this.#t;Yt(n==="utf-8","JsonCodec does not yet support non-utf-8 encoding.");const d=[];Yt(i,"JsonCodec does not yet support skipping the check for circular references during encoding."),a||d.push(Hu),c&&d.push(qu);const f=Array.from(t.data);f.push("|O"),f.push(t.shape);let y;d.length&&(y=(L,x)=>{let M=x;for(let U of d)M=U(L,M);return M});let B=JSON.stringify(f,y,e);return s&&(B=B.replace(/[\u007F-\uFFFF]/g,L=>{const x=`0000${L.charCodeAt(0).toString(16)}`;return`\\u${x.substring(x.length-4)}`})),new TextEncoder().encode(B)}decode(t){const{strict:e}=this.#e;Yt(e,"JsonCodec does not yet support non-strict decoding.");const n=rr(t),s=n.pop();n.pop(),Yt(s,"0D not implemented for JsonCodec.");const i=tr(s,"C");return{data:n,shape:s,stride:i}}}const ms={};function Qs(r){return r instanceof $n||r instanceof ds||r instanceof yn?new Proxy(r,{get(e,n){return e.get(Number(n))},set(e,n,s){return e.set(Number(n),s),!0}}):r}function Ku(r,t){let e;return r.data instanceof ds||r.data instanceof yn?e=new r.constructor(r.data.length,r.data.chars):e=new r.constructor(r.data.length),{data:e,shape:r.shape,stride:tr(r.shape,t)}}function Xu(r,t){let e=Ku(r,t),n=r.shape.length,s=r.data.length,i=Array(n).fill(0),a=Qs(r.data),c=Qs(e.data);for(let d=0;d<s;d++){let f=0;for(let y=0;y<n;y++)f+=i[y]*e.stride[y];c[f]=a[d],i[0]+=1;for(let y=0;y<n;y++)if(i[y]===r.shape[y]){if(y+1===n)break;i[y]=0,i[y+1]+=1}}return e}function Qu(r){let t=r.shape.length;return ms(t===r.stride.length,"Shape and stride must have the same length."),r.stride.map((e,n)=>({stride:e,index:n})).sort((e,n)=>n.stride-e.stride).map(e=>e.index)}function th(r,t){let e=Qu(r);return ms(e.length===t.length,"Orders must match"),e.every((n,s)=>n===t[s])}class ws{kind="array_to_array";#t;#e;constructor(t,e){let n=t.order??"C",s=e.shape.length,i=new Array(s),a=new Array(s);if(n==="C")for(let c=0;c<s;++c)i[c]=c,a[c]=c;else if(n==="F")for(let c=0;c<s;++c)i[c]=s-c-1,a[c]=s-c-1;else i=n,i.forEach((c,d)=>{ms(a[c]===void 0,`Invalid permutation: ${JSON.stringify(n)}`),a[c]=d});this.#t=i,this.#e=a}static fromConfig(t,e){return new ws(t,e)}encode(t){return th(t,this.#e)?t:Xu(t,this.#e)}decode(t){return{data:t.data,shape:t.shape,stride:tr(t.shape,this.#t)}}}class bs{kind="array_to_bytes";#t;#e;constructor(t){this.#t=t,this.#e=tr(t,"C")}static fromConfig(t,e){return new bs(e.shape)}encode(t){throw new Error("Method not implemented.")}decode(t){let e=new TextDecoder,n=new DataView(t.buffer),s=Array(n.getUint32(0,!0)),i=4;for(let a=0;a<s.length;a++){let c=n.getUint32(i,!0);i+=4,s[a]=e.decode(t.buffer.slice(i,i+c)),i+=c}return{data:s,shape:this.#t,stride:this.#e}}}function eh(){return new Map().set("blosc",()=>Promise.resolve().then(()=>require("./blosc-XU68L2JO.cjs")).then(r=>r.default)).set("gzip",()=>Promise.resolve().then(()=>require("./gzip-9a4q5uuM.cjs")).then(r=>r.default)).set("lz4",()=>Promise.resolve().then(()=>require("./lz4-DyL8MHib.cjs")).then(r=>r.default)).set("zlib",()=>Promise.resolve().then(()=>require("./zlib-BviSziX3.cjs")).then(r=>r.default)).set("zstd",()=>Promise.resolve().then(()=>require("./zstd-BJg46wpa.cjs")).then(r=>r.default)).set("transpose",()=>ws).set("bytes",()=>_i).set("crc32c",()=>ys).set("vlen-utf8",()=>bs).set("json2",()=>gs).set("bitround",()=>ps)}const pa=eh();function Ji(r){let t;return{async encode(e){t||(t=await to(r));for(const s of t.array_to_array)e=await s.encode(e);let n=await t.array_to_bytes.encode(e);for(const s of t.bytes_to_bytes)n=await s.encode(n);return n},async decode(e){t||(t=await to(r));for(let s=t.bytes_to_bytes.length-1;s>=0;s--)e=await t.bytes_to_bytes[s].decode(e);let n=await t.array_to_bytes.decode(e);for(let s=t.array_to_array.length-1;s>=0;s--)n=await t.array_to_array[s].decode(n);return n}}}async function to(r){let t=r.codecs.map(async i=>{let a=await pa.get(i.name)?.();return Yt(a,`Unknown codec: ${i.name}`),{Codec:a,meta:i}}),e=[],n,s=[];for await(let{Codec:i,meta:a}of t){let c=i.fromConfig(a.configuration,r);switch(c.kind){case"array_to_array":e.push(c);break;case"array_to_bytes":n=c;break;default:s.push(c)}}return n||(Yt(rh(r),`Cannot encode ${r.data_type} to bytes without a codec`),n=_i.fromConfig({endian:"little"},r)),{array_to_array:e,array_to_bytes:n,bytes_to_bytes:s}}function rh(r){return r.data_type!=="v2:object"}const eo=18446744073709551615n;function nh(r,t,e,n){Yt(r.store.getRange,"Store does not support range requests");let s=r.store.getRange.bind(r.store),i=t.map((d,f)=>d/n.chunk_shape[f]),a=Ji({data_type:"uint64",shape:[...i,2],codecs:n.index_codecs}),c={};return async d=>{let f=d.map((C,P)=>Math.floor(C/i[P])),y=r.resolve(e(f)).path,B;if(y in c)B=c[y];else{let C=4,P=16*i.reduce((G,A)=>G*A,1),V=await s(y,{suffixLength:P+C});B=c[y]=V?await a.decode(V):null}if(B===null)return;let{data:L,shape:x,stride:M}=B,U=d.map((C,P)=>C%x[P]).reduce((C,P,V)=>C+P*M[V],0),F=L[U],O=L[U+1];if(!(F===eo&&O===eo))return s(y,{offset:Number(F),length:Number(O)})}}class nr{store;path;constructor(t,e="/"){this.store=t,this.path=e}resolve(t){let e=new URL(`file://${this.path.endsWith("/")?this.path:`${this.path}/`}`);return new nr(this.store,new URL(t,e).pathname)}}class Si extends nr{kind="group";#t;constructor(t,e,n){super(t,e),this.#t=n}get attrs(){return this.#t.attributes}}function ro(r){return r.find(e=>e.name==="transpose")?.configuration?.order??"C"}const Kr=Symbol("zarrita.context");function ya(r){return r[Kr]}function ih(r,t){let{configuration:e}=t.codecs.find(Yu)??{},n={encode_chunk_key:ju(t.chunk_key_encoding),TypedArray:la(t.data_type),fill_value:t.fill_value};if(e){let i=ro(e.codecs);return{...n,kind:"sharded",chunk_shape:e.chunk_shape,codec:Ji({data_type:t.data_type,shape:e.chunk_shape,codecs:e.codecs}),get_strides(a,c){return tr(a,c??i)},get_chunk_bytes:nh(r,t.chunk_grid.configuration.chunk_shape,n.encode_chunk_key,e)}}let s=ro(t.codecs);return{...n,kind:"regular",chunk_shape:t.chunk_grid.configuration.chunk_shape,codec:Ji({data_type:t.data_type,shape:t.chunk_grid.configuration.chunk_shape,codecs:t.codecs}),get_strides(i,a){return tr(i,a??s)},async get_chunk_bytes(i,a){let c=n.encode_chunk_key(i),d=r.resolve(c).path;return r.store.get(d,a)}}}let vr=class extends nr{kind="array";#t;[Kr];constructor(t,e,n){super(t,e),this.#t={...n,fill_value:da(n)},this[Kr]=ih(this,n)}get attrs(){return this.#t.attributes}get shape(){return this.#t.shape}get chunks(){return this[Kr].chunk_shape}get dtype(){return this.#t.data_type}async getChunk(t,e){let n=this[Kr],s=await n.get_chunk_bytes(t,e);if(!s){let i=n.chunk_shape.reduce((c,d)=>c*d,1),a=new n.TypedArray(i);return a.fill(n.fill_value),{data:a,shape:n.chunk_shape,stride:n.get_strides(n.chunk_shape)}}return n.codec.decode(s)}is(t){return Gu(this.dtype,t)}},Ii=sh();function sh(){let r=new WeakMap;function t(e){let n=r.get(e)??{v2:0,v3:0};return r.set(e,n),n}return{increment(e,n){t(e)[n]+=1},version_max(e){let n=t(e);return n.v3>n.v2?"v3":"v2"}}}async function oh(r){let t=await r.store.get(r.resolve(".zattrs").path);return t?rr(t):{}}async function ah(r,t={}){let e="store"in r?r:new nr(r),n={};return(t.attrs??!0)&&(n=await oh(e)),t.kind==="array"?no(e,n):t.kind==="group"?io(e,n):no(e,n).catch(s=>(fa(s,Fr),io(e,n)))}async function no(r,t){let{path:e}=r.resolve(".zarray"),n=await r.store.get(e);if(!n)throw new Fr("v2 array",{cause:new bi(e)});return Ii.increment(r.store,"v2"),new vr(r.store,r.path,Wu(rr(n),t))}async function io(r,t){let{path:e}=r.resolve(".zgroup"),n=await r.store.get(e);if(!n)throw new Fr("v2 group",{cause:new bi(e)});return Ii.increment(r.store,"v2"),new Si(r.store,r.path,Zu(rr(n),t))}async function ch(r){let{store:t,path:e}=r.resolve("zarr.json"),n=await r.store.get(e);if(!n)throw new Fr("v3 array or group",{cause:new bi(e)});let s=rr(n);return s.node_type==="array"&&(s.fill_value=da(s)),s.node_type==="array"?new vr(t,r.path,s):new Si(t,r.path,s)}async function uh(r,t={}){let e="store"in r?r:new nr(r),n=await ch(e);if(Ii.increment(e.store,"v3"),t.kind===void 0||t.kind==="array"&&n instanceof vr||t.kind==="group"&&n instanceof Si)return n;let s=n instanceof vr?"array":"group";throw new Error(`Expected node of kind ${t.kind}, found ${s}.`)}async function Ge(r,t={}){let e="store"in r?r.store:r,n=Ii.version_max(e),s=n==="v2"?Ge.v2:Ge.v3,i=n==="v2"?Ge.v3:Ge.v2;return s(r,t).catch(a=>(fa(a,Fr),i(r,t)))}Ge.v2=ah;Ge.v3=uh;async function _n(r,t={}){let e="store"in r?r:new nr(r);return"shape"in t?await lh(e,t):hh(e,t)}async function hh(r,t={}){let e={zarr_format:3,node_type:"group",attributes:t.attributes??{}};return await r.store.set(r.resolve("zarr.json").path,fs(e)),new Si(r.store,r.path,e)}async function lh(r,t){let e={zarr_format:3,node_type:"array",shape:t.shape,data_type:t.data_type,chunk_grid:{name:"regular",configuration:{chunk_shape:t.chunk_shape}},chunk_key_encoding:{name:"default",configuration:{separator:t.chunk_separator??"/"}},codecs:t.codecs??[],fill_value:t.fill_value??null,attributes:t.attributes??{}};return await r.store.set(r.resolve("zarr.json").path,fs(e)),new vr(r.store,r.path,e)}async function dh(r){let t=await r.get("/.zmetadata");if(!t)throw new Fr("v2 consolidated metadata",{cause:new bi("/.zmetadata")});let e=rr(t);return Yt(e.zarr_consolidated_format===1,"Unsupported consolidated format."),e}function fh(r){return r.endsWith(".zarray")||r.endsWith(".zgroup")||r.endsWith(".zattrs")||r.endsWith("zarr.json")}function ph(r){return"zarr_format"in r&&r.zarr_format===3}async function yh(r){let t=await dh(r),e={};for(let[n,s]of Object.entries(t.metadata))e[`/${n}`]=s;return{async get(...n){let[s,i]=n;if(e[s])return fs(e[s]);let a=await r.get(s,i);if(fh(s)&&a){let c=rr(a);e[s]=c}return a},getRange:r.getRange?.bind(r),contents(){let n=[];for(let[s,i]of Object.entries(e)){let a=s.split("/"),c=a.pop(),d=a.join("/")||"/";c===".zarray"&&n.push({path:d,kind:"array"}),c===".zgroup"&&n.push({path:d,kind:"group"}),ph(i)&&n.push({path:d,kind:i.node_type})}return n}}}function*gh(r,t,e=1){t===void 0&&(t=r,r=0);for(let n=r;n<t;n+=e)yield n}function*mh(...r){if(r.length===0)return;const t=r.map(n=>n[Symbol.iterator]()),e=t.map(n=>n.next());if(e.some(n=>n.done))throw new Error("Input contains an empty iterator.");for(let n=0;;){if(e[n].done){if(t[n]=r[n][Symbol.iterator](),e[n]=t[n].next(),++n>=t.length)return}else yield e.map(({value:s})=>s),n=0;e[n]=t[n].next()}}function wh({start:r,stop:t,step:e},n){if(e===0)throw new Error("slice step cannot be zero");e=e??1;const s=e<0,[i,a]=s?[-1,n-1]:[0,n];return r===null?r=s?a:i:r<0?(r+=n,r<i&&(r=i)):r>a&&(r=a),t===null?t=s?i:a:t<0?(t+=n,t<i&&(t=i)):t>a&&(t=a),[r,t,e]}function Hi(r,t,e=null){return t===void 0&&(t=r,r=null),{start:r,stop:t,step:e}}function ga(){const r=[];return{add:t=>r.push(t()),onIdle:()=>Promise.all(r)}}class _s extends Error{constructor(t){super(t),this.name="IndexError"}}function bh(r,t){throw new _s(`too many indicies for array; expected ${t.length}, got ${r.length}`)}function _h(r){throw new _s(`index out of bounds for dimension with length ${r}`)}function Sh(){throw new _s("only slices with step >= 1 are supported")}function Ih(r,t){r.length>t.length&&bh(r,t)}function Bh(r,t){return r=Math.trunc(r),r<0&&(r=t+r),(r>=t||r<0)&&_h(t),r}class vh{dim_sel;dim_len;dim_chunk_len;nitems;constructor({dim_sel:t,dim_len:e,dim_chunk_len:n}){t=Bh(t,e),this.dim_sel=t,this.dim_len=e,this.dim_chunk_len=n,this.nitems=1}*[Symbol.iterator](){const t=Math.floor(this.dim_sel/this.dim_chunk_len),e=t*this.dim_chunk_len,n=this.dim_sel-e;yield{dim_chunk_ix:t,dim_chunk_sel:n}}}class so{start;stop;step;dim_len;dim_chunk_len;nitems;nchunks;constructor({dim_sel:t,dim_len:e,dim_chunk_len:n}){const[s,i,a]=wh(t,e);this.start=s,this.stop=i,this.step=a,this.step<1&&Sh(),this.dim_len=e,this.dim_chunk_len=n,this.nitems=Math.max(0,Math.ceil((this.stop-this.start)/this.step)),this.nchunks=Math.ceil(this.dim_len/this.dim_chunk_len)}*[Symbol.iterator](){const t=Math.floor(this.start/this.dim_chunk_len),e=Math.ceil(this.stop/this.dim_chunk_len);for(const n of gh(t,e)){const s=n*this.dim_chunk_len,i=Math.min(this.dim_len,(n+1)*this.dim_chunk_len),a=i-s;let c=0,d=0;if(this.start<s){const x=(s-this.start)%this.step;x&&(d+=this.step-x),c=Math.ceil((s-this.start)/this.step)}else d=this.start-s;const f=this.stop>i?a:this.stop-s,y=[d,f,this.step],B=Math.ceil((f-d)/this.step),L=[c,c+B,1];yield{dim_chunk_ix:n,dim_chunk_sel:y,dim_out_sel:L}}}}function xh(r,t){let e=[];return r===null?e=t.map(n=>Hi(null)):Array.isArray(r)&&(e=r.map(n=>n??Hi(null))),Ih(e,t),e}class ma{dim_indexers;shape;constructor({selection:t,shape:e,chunk_shape:n}){this.dim_indexers=xh(t,e).map((s,i)=>new(typeof s=="number"?vh:so)({dim_sel:s,dim_len:e[i],dim_chunk_len:n[i]})),this.shape=this.dim_indexers.filter(s=>s instanceof so).map(s=>s.nitems)}*[Symbol.iterator](){for(const t of mh(...this.dim_indexers)){const e=t.map(s=>s.dim_chunk_ix),n=t.map(s=>"dim_out_sel"in s?{from:s.dim_chunk_sel,to:s.dim_out_sel}:{from:s.dim_chunk_sel,to:null});yield{chunk_coords:e,mapping:n}}}}function Ah(r,t){return"get"in r?r.get(t):r[t]}async function Eh(r,t,e,n){let s=ya(r),i=new ma({selection:t,shape:r.shape,chunk_shape:r.chunks}),a=n.prepare(new s.TypedArray(i.shape.reduce((d,f)=>d*f,1)),i.shape,s.get_strides(i.shape,e.order)),c=e.create_queue?.()??ga();for(const{chunk_coords:d,mapping:f}of i)c.add(async()=>{let{data:y,shape:B,stride:L}=await r.getChunk(d,e.opts),x=n.prepare(y,B,L);n.set_from_chunk(a,x,f)});return await c.onIdle(),i.shape.length===0?Ah(a.data,0):a}function Th(r){return r.to==null?{from:r.to,to:r.from}:{from:r.to,to:r.from}}async function Mh(r,t,e,n,s){const i=ya(r);if(i.kind==="sharded")throw new Error("Set not supported for sharded arrays.");const a=new ma({selection:t,shape:r.shape,chunk_shape:r.chunks}),c=r.chunks.reduce((f,y)=>f*y,1),d=n.create_queue?n.create_queue():ga();for(const{chunk_coords:f,mapping:y}of a){const B=y.map(x=>x.from),L=y.map(Th);d.add(async()=>{const x=r.resolve(i.encode_chunk_key(f)).path;let M;const U=r.chunks.slice(),F=i.get_strides(U);if(Nh(B,U))if(M=new i.TypedArray(c),typeof e=="object"){const O=s.prepare(M,U.slice(),F.slice());s.set_from_chunk(O,e,L)}else M.fill(e);else{M=await r.getChunk(f).then(({data:C})=>C);const O=s.prepare(M,U.slice(),F.slice());typeof e=="object"?s.set_from_chunk(O,e,L):s.set_scalar(O,B,e)}await r.store.set(x,await i.codec.encode({data:M,shape:U,stride:F}))})}await d.onIdle()}function Nh(r,t){return r.every((e,n)=>{if(typeof e=="number")return!1;const[s,i,a]=e;return i-s===t[n]&&a===1})}function Ss(r,t=0,e){let n=e??r.length-t;return{length:n,subarray(s,i=n){return Ss(r,t+s,i-s)},set(s,i=0){for(let a=0;a<s.length;a++)r[t+i+a]=s.get(a)},get(s){return r[t+s]}}}function Oi(r){return globalThis.Array.isArray(r.data)?{data:Ss(r.data),stride:r.stride,bytes_per_element:1}:{data:new Uint8Array(r.data.buffer,r.data.byteOffset,r.data.byteLength),stride:r.stride,bytes_per_element:r.data.BYTES_PER_ELEMENT}}function Fh(r){return"chars"in r?r.constructor.bind(null,r.chars):r.constructor}function Oh(r,t){if(globalThis.Array.isArray(r.data))return Ss([t]);let e=Fh(r.data),n=new e([t]);return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}const wa={prepare(r,t,e){return{data:r,shape:t,stride:e}},set_scalar(r,t,e){let n=Oi(r);qi(n,t,Oh(r,e),n.bytes_per_element)},set_from_chunk(r,t,e){let n=Oi(r);Tn(n,Oi(t),n.bytes_per_element,e)}};async function kh(r,t=null,e={}){return Eh(r,t,e,wa)}async function oo(r,t,e,n={}){return Mh(r,t,e,n,wa)}function ba(r,t,e){return e<0&&t<r?Math.floor((r-t-1)/-e)+1:r<t?Math.floor((t-r-1)/e)+1:0}function qi(r,t,e,n){if(t.length===0){r.data.set(e,0);return}const[s,...i]=t,[a,...c]=r.stride;if(typeof s=="number"){const L=r.data.subarray(a*s*n);qi({data:L,stride:c},i,e,n);return}const[d,f,y]=s,B=ba(d,f,y);if(i.length===0){for(let L=0;L<B;L++)r.data.set(e,a*(d+y*L)*n);return}for(let L=0;L<B;L++){const x=r.data.subarray(a*(d+y*L)*n);qi({data:x,stride:c},i,e,n)}}function Tn(r,t,e,n){const[s,...i]=n,[a,...c]=r.stride,[d,...f]=t.stride;if(s.from===null){if(i.length===0){r.data.set(t.data.subarray(0,e),s.to*e);return}Tn({data:r.data.subarray(a*s.to*e),stride:c},t,e,i);return}if(s.to===null){if(i.length===0){let O=s.from*e;r.data.set(t.data.subarray(O,O+e),0);return}Tn(r,{data:t.data.subarray(d*s.from*e),stride:f},e,i);return}const[y,B,L]=s.to,[x,M,U]=s.from,F=ba(y,B,L);if(i.length===0){if(L===1&&U===1&&a===1&&d===1){let O=x*e,C=F*e;r.data.set(t.data.subarray(O,O+C),y*e);return}for(let O=0;O<F;O++){let C=d*(x+U*O)*e;r.data.set(t.data.subarray(C,C+e),a*(y+L*O)*e)}return}for(let O=0;O<F;O++)Tn({data:r.data.subarray(a*(y+O*L)*e),stride:c},{data:t.data.subarray(d*(x+O*U)*e),stride:f},e,i)}function gt(r,t,e,n){function s(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function c(y){try{f(n.next(y))}catch(B){a(B)}}function d(y){try{f(n.throw(y))}catch(B){a(B)}}function f(y){y.done?i(y.value):s(y.value).then(c,d)}f((n=n.apply(r,t||[])).next())})}function ao(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],n=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function wt(r){return this instanceof wt?(this.v=r,this):new wt(r)}function Ae(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(r,t||[]),s,i=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(x){return function(M){return Promise.resolve(M).then(x,B)}}function c(x,M){n[x]&&(s[x]=function(U){return new Promise(function(F,O){i.push([x,U,F,O])>1||d(x,U)})},M&&(s[x]=M(s[x])))}function d(x,M){try{f(n[x](M))}catch(U){L(i[0][3],U)}}function f(x){x.value instanceof wt?Promise.resolve(x.value.v).then(y,B):L(i[0][2],x)}function y(x){d("next",x)}function B(x){d("throw",x)}function L(x,M){x(M),i.shift(),i.length&&d(i[0][0],i[0][1])}}function Mn(r){var t,e;return t={},n("next"),n("throw",function(s){throw s}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(s,i){t[s]=r[s]?function(a){return(e=!e)?{value:wt(r[s](a)),done:!1}:i?i(a):a}:i}}function br(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 ao=="function"?ao(r):r[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(i){e[i]=r[i]&&function(a){return new Promise(function(c,d){a=r[i](a),s(c,d,a.done,a.value)})}}function s(i,a,c,d){Promise.resolve(d).then(function(f){i({value:f,done:c})},a)}}const Dh=new TextDecoder("utf-8"),Ki=r=>Dh.decode(r),Uh=new TextEncoder,Is=r=>Uh.encode(r),Lh=r=>typeof r=="number",Ch=r=>typeof r=="boolean",qt=r=>typeof r=="function",me=r=>r!=null&&Object(r)===r,un=r=>me(r)&&qt(r.then),Bi=r=>me(r)&&qt(r[Symbol.iterator]),Bs=r=>me(r)&&qt(r[Symbol.asyncIterator]),Xi=r=>me(r)&&me(r.schema),_a=r=>me(r)&&"done"in r&&"value"in r,Sa=r=>me(r)&&qt(r.stat)&&Lh(r.fd),Ia=r=>me(r)&&vs(r.body),Ba=r=>"_getDOMStream"in r&&"_getNodeStream"in r,vs=r=>me(r)&&qt(r.cancel)&&qt(r.getReader)&&!Ba(r),va=r=>me(r)&&qt(r.read)&&qt(r.pipe)&&Ch(r.readable)&&!Ba(r),Rh=r=>me(r)&&qt(r.clear)&&qt(r.bytes)&&qt(r.position)&&qt(r.setPosition)&&qt(r.capacity)&&qt(r.getBufferIdentifier)&&qt(r.createLong),xs=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Ph(r){const t=r[0]?[r[0]]:[];let e,n,s,i;for(let a,c,d=0,f=0,y=r.length;++d<y;){if(a=t[f],c=r[d],!a||!c||a.buffer!==c.buffer||c.byteOffset<a.byteOffset){c&&(t[++f]=c);continue}if({byteOffset:e,byteLength:s}=a,{byteOffset:n,byteLength:i}=c,e+s<n||n+i<e){c&&(t[++f]=c);continue}t[f]=new Uint8Array(a.buffer,e,n-e+i)}return t}function co(r,t,e=0,n=t.byteLength){const s=r.byteLength,i=new Uint8Array(r.buffer,r.byteOffset,s),a=new Uint8Array(t.buffer,t.byteOffset,Math.min(n,s));return i.set(a,e),r}function Ee(r,t){const e=Ph(r),n=e.reduce((y,B)=>y+B.byteLength,0);let s,i,a,c=0,d=-1;const f=Math.min(t||Number.POSITIVE_INFINITY,n);for(const y=e.length;++d<y;){if(s=e[d],i=s.subarray(0,Math.min(s.length,f-c)),f<=c+i.length){i.length<s.length?e[d]=s.subarray(i.length):i.length===s.length&&d++,a?co(a,i,c):a=i;break}co(a||(a=new Uint8Array(f)),i,c),c+=i.length}return[a||new Uint8Array(0),e.slice(d),n-(a?a.byteLength:0)]}function Mt(r,t){let e=_a(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=Is(e)),e instanceof ArrayBuffer?new r(e):e instanceof xs?new r(e):Rh(e)?Mt(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)}const Dr=r=>Mt(Int32Array,r),uo=r=>Mt(BigInt64Array,r),It=r=>Mt(Uint8Array,r),Qi=r=>(r.next(),r);function*$h(r,t){const e=function*(s){yield s},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof xs?e(t):Bi(t)?t:e(t);return yield*Qi(function*(s){let i=null;do i=s.next(yield Mt(r,i));while(!i.done)}(n[Symbol.iterator]())),new r}const zh=r=>$h(Uint8Array,r);function xa(r,t){return Ae(this,arguments,function*(){if(un(t))return yield wt(yield wt(yield*Mn(br(xa(r,yield wt(t))))));const n=function(a){return Ae(this,arguments,function*(){yield yield wt(yield wt(a))})},s=function(a){return Ae(this,arguments,function*(){yield wt(yield*Mn(br(Qi(function*(c){let d=null;do d=c.next(yield d?.value);while(!d.done)}(a[Symbol.iterator]())))))})},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof xs?n(t):Bi(t)?s(t):Bs(t)?t:n(t);return yield wt(yield*Mn(br(Qi(function(a){return Ae(this,arguments,function*(){let c=null;do c=yield wt(a.next(yield yield wt(Mt(r,c))));while(!c.done)})}(i[Symbol.asyncIterator]()))))),yield wt(new r)})}const jh=r=>xa(Uint8Array,r);function Vh(r,t){let e=0;const n=r.length;if(n!==t.length)return!1;if(n>0)do if(r[e]!==t[e])return!1;while(++e<n);return!0}const ce={fromIterable(r){return Sn(Wh(r))},fromAsyncIterable(r){return Sn(Zh(r))},fromDOMStream(r){return Sn(Gh(r))},fromNodeStream(r){return Sn(Jh(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')}},Sn=r=>(r.next(),r);function*Wh(r){let t,e=!1,n=[],s,i,a,c=0;function d(){return i==="peek"?Ee(n,a)[0]:([s,n,c]=Ee(n,a),s)}({cmd:i,size:a}=(yield null)||{cmd:"read",size:0});const f=zh(r)[Symbol.iterator]();try{do if({done:t,value:s}=Number.isNaN(a-c)?f.next():f.next(a-c),!t&&s.byteLength>0&&(n.push(s),c+=s.byteLength),t||a<=c)do({cmd:i,size:a}=yield d());while(a<c);while(!t)}catch(y){(e=!0)&&typeof f.throw=="function"&&f.throw(y)}finally{e===!1&&typeof f.return=="function"&&f.return(null)}return null}function Zh(r){return Ae(this,arguments,function*(){let e,n=!1,s=[],i,a,c,d=0;function f(){return a==="peek"?Ee(s,c)[0]:([i,s,d]=Ee(s,c),i)}({cmd:a,size:c}=(yield yield wt(null))||{cmd:"read",size:0});const y=jh(r)[Symbol.asyncIterator]();try{do if({done:e,value:i}=Number.isNaN(c-d)?yield wt(y.next()):yield wt(y.next(c-d)),!e&&i.byteLength>0&&(s.push(i),d+=i.byteLength),e||c<=d)do({cmd:a,size:c}=yield yield wt(f()));while(c<d);while(!e)}catch(B){(n=!0)&&typeof y.throw=="function"&&(yield wt(y.throw(B)))}finally{n===!1&&typeof y.return=="function"&&(yield wt(y.return(new Uint8Array(0))))}return yield wt(null)})}function Gh(r){return Ae(this,arguments,function*(){let e=!1,n=!1,s=[],i,a,c,d=0;function f(){return a==="peek"?Ee(s,c)[0]:([i,s,d]=Ee(s,c),i)}({cmd:a,size:c}=(yield yield wt(null))||{cmd:"read",size:0});const y=new Yh(r);try{do if({done:e,value:i}=Number.isNaN(c-d)?yield wt(y.read()):yield wt(y.read(c-d)),!e&&i.byteLength>0&&(s.push(It(i)),d+=i.byteLength),e||c<=d)do({cmd:a,size:c}=yield yield wt(f()));while(c<d);while(!e)}catch(B){(n=!0)&&(yield wt(y.cancel(B)))}finally{n===!1?yield wt(y.cancel()):r.locked&&y.releaseLock()}return yield wt(null)})}class Yh{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 gt(this,void 0,void 0,function*(){const{reader:e,source:n}=this;e&&(yield e.cancel(t).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(t){return gt(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};const e=yield this.reader.read();return!e.done&&(e.value=It(e)),e})}}const ki=(r,t)=>{const e=s=>n([t,s]);let n;return[t,e,new Promise(s=>(n=s)&&r.once(t,e))]};function Jh(r){return Ae(this,arguments,function*(){const e=[];let n="error",s=!1,i=null,a,c,d=0,f=[],y;function B(){return a==="peek"?Ee(f,c)[0]:([y,f,d]=Ee(f,c),y)}if({cmd:a,size:c}=(yield yield wt(null))||{cmd:"read",size:0},r.isTTY)return yield yield wt(new Uint8Array(0)),yield wt(null);try{e[0]=ki(r,"end"),e[1]=ki(r,"error");do{if(e[2]=ki(r,"readable"),[n,i]=yield wt(Promise.race(e.map(x=>x[2]))),n==="error")break;if((s=n==="end")||(Number.isFinite(c-d)?(y=It(r.read(c-d)),y.byteLength<c-d&&(y=It(r.read()))):y=It(r.read()),y.byteLength>0&&(f.push(y),d+=y.byteLength)),s||c<=d)do({cmd:a,size:c}=yield yield wt(B()));while(c<d)}while(!s)}finally{yield wt(L(e,n==="error"?i:null))}return yield wt(null);function L(x,M){return y=f=null,new Promise((U,F)=>{for(const[O,C]of x)r.off(O,C);try{const O=r.destroy;O&&O.call(r,M),M=void 0}catch(O){M=O||M}finally{M!=null?F(M):U()}})}})}var zt;(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"})(zt||(zt={}));var re;(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(re||(re={}));var Jt;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(Jt||(Jt={}));var de;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(de||(de={}));var at;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(at||(at={}));var Te;(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"})(Te||(Te={}));const Di=2,Be=4,ke=4,xt=4,We=new Int32Array(2),ho=new Float32Array(We.buffer),lo=new Float64Array(We.buffer),In=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var ts;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(ts||(ts={}));let xr=class Aa{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new Aa(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 We[0]=this.readInt32(t),ho[0]}readFloat64(t){return We[In?0:1]=this.readInt32(t),We[In?1:0]=this.readInt32(t+4),lo[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){ho[0]=e,this.writeInt32(t,We[0])}writeFloat64(t,e){lo[0]=e,this.writeInt32(t,We[In?0:1]),this.writeInt32(t+4,We[In?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+Be+ke)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<ke;e++)t+=String.fromCharCode(this.readInt8(this.position_+Be+e));return t}__offset(t,e){const n=t-this.readInt32(t);return e<this.readInt16(n)?this.readInt16(n+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const n=this.readInt32(t);t+=Be;const s=this.bytes_.subarray(t,t+n);return e===ts.UTF8_BYTES?s:this.text_decoder_.decode(s)}__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)+Be}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=ke)throw new Error("FlatBuffers: file identifier must be length "+ke);for(let e=0;e<ke;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+Be+e))return!1;return!0}createScalarList(t,e){const n=[];for(let s=0;s<e;++s){const i=t(s);i!==null&&n.push(i)}return n}createObjList(t,e){const n=[];for(let s=0;s<e;++s){const i=t(s);i!==null&&n.push(i.unpack())}return n}},Ea=class Ta{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=xr.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);const n=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<n+t+e;){const s=this.bb.capacity();this.bb=Ta.growByteBuffer(this.bb),this.space+=this.bb.capacity()-s}this.pad(n)}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,n){(this.force_defaults||e!=n)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,n){(this.force_defaults||e!=n)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,n){(this.force_defaults||e!=n)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,n){(this.force_defaults||e!==n)&&(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,n){(this.force_defaults||e!=n)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,n){e!=n&&(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){const e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const n=e<<1,s=xr.allocate(n);return s.setPosition(n-e),s.bytes().set(t.bytes(),n-e),s}addOffset(t){this.prep(Be,0),this.writeInt32(this.offset()-t+Be)}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);const t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);const n=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);const s=2;this.addInt16(t-this.object_start);const i=(n+s)*Di;this.addInt16(i);let a=0;const c=this.space;t:for(e=0;e<this.vtables.length;e++){const d=this.bb.capacity()-this.vtables[e];if(i==this.bb.readInt16(d)){for(let f=Di;f<i;f+=Di)if(this.bb.readInt16(c+f)!=this.bb.readInt16(d+f))continue t;a=this.vtables[e];break}}return a?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,a-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,n){const s=n?xt:0;if(e){const i=e;if(this.prep(this.minalign,Be+ke+s),i.length!=ke)throw new TypeError("FlatBuffers: file identifier must be length "+ke);for(let a=ke-1;a>=0;a--)this.writeInt8(i.charCodeAt(a))}this.prep(this.minalign,Be+s),this.addOffset(t),s&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const n=this.bb.capacity()-t,s=n-this.bb.readInt32(n);if(!(e<this.bb.readInt16(s)&&this.bb.readInt16(s+e)!=0))throw new TypeError("FlatBuffers: field "+e+" must be set")}startVector(t,e,n){this.notNested(),this.vector_num_elems=e,this.prep(Be,t*e),this.prep(n,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);const 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){const e=[];for(let n=0;n<t.length;++n){const s=t[n];if(s!==null)e.push(this.createObjectOffset(s));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 zn;(function(r){r[r.BUFFER=0]="BUFFER"})(zn||(zn={}));var jn;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(jn||(jn={}));class Ze{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 Ze).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+xt),(e||new Ze).__init(t.readInt32(t.position())+t.position(),t)}codec(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):jn.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):zn.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,jn.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,zn.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return Ze.startBodyCompression(t),Ze.addCodec(t,e),Ze.addMethod(t,n),Ze.endBodyCompression(t)}}class Ma{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n??0)),t.writeInt64(BigInt(e??0)),t.offset()}}let Na=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n??0)),t.writeInt64(BigInt(e??0)),t.offset()}},Ne=class es{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 es).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+xt),(e||new es).__init(t.readInt32(t.position())+t.position(),t)}length(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new Na).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}nodesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new Ma).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}buffersLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){const e=this.bb.__offset(this.bb_pos,10);return e?(t||new Ze).__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()}},ar=class rs{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 rs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+xt),(e||new rs).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new Ne).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isDelta(){const 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 Ar;(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})(Ar||(Ar={}));var Vn;(function(r){r[r.DenseArray=0]="DenseArray"})(Vn||(Vn={}));class oe{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 oe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+xt),(e||new oe).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){const 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,n){return oe.startInt(t),oe.addBitWidth(t,e),oe.addIsSigned(t,n),oe.endInt(t)}}class De{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 De).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+xt),(e||new De).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new oe).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isOrdered(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):Vn.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,Vn.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}}class jt{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 jt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,e){return t.setPosition(t.position()+xt),(e||new jt).__init(t.readInt32(t.position())+t.position(),t)}key(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}value(t){const 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,n){return jt.startKeyValue(t),jt.addKey(t,e),jt.addValue(t,n),jt.endKeyValue(t)}}let fo=class Xr{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 Xr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+xt),(e||new Xr).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return Xr.startBinary(t),Xr.endBinary(t)}},po=class Qr{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 Qr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+xt),(e||new Qr).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return Qr.startBool(t),Qr.endBool(t)}},Nn=class cr{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 cr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+xt),(e||new cr).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):de.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,de.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return cr.startDate(t),cr.addUnit(t,e),cr.endDate(t)}},ur=class Ve{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 Ve).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+xt),(e||new Ve).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){const 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,n,s){return Ve.startDecimal(t),Ve.addPrecision(t,e),Ve.addScale(t,n),Ve.addBitWidth(t,s),Ve.endDecimal(t)}},Fn=class hr{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 hr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,e){return t.setPosition(t.position()+xt),(e||new hr).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):at.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,at.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,e){return hr.startDuration(t),hr.addUnit(t,e),hr.endDuration(t)}},On=class lr{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 lr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+xt),(e||new lr).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){const 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 lr.startFixedSizeBinary(t),lr.addByteWidth(t,e),lr.endFixedSizeBinary(t)}},kn=class dr{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 dr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+xt),(e||new dr).__init(t.readInt32(t.position())+t.position(),t)}listSize(){const 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 dr.startFixedSizeList(t),dr.addListSize(t,e),dr.endFixedSizeList(t)}};class ve{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 ve).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+xt),(e||new ve).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Jt.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,Jt.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return ve.startFloatingPoint(t),ve.addPrecision(t,e),ve.endFloatingPoint(t)}}class xe{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 xe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+xt),(e||new xe).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Te.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,Te.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return xe.startInterval(t),xe.addUnit(t,e),xe.endInterval(t)}}let yo=class tn{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 tn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,e){return t.setPosition(t.position()+xt),(e||new tn).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return tn.startLargeBinary(t),tn.endLargeBinary(t)}},go=class en{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 en).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,e){return t.setPosition(t.position()+xt),(e||new en).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return en.startLargeUtf8(t),en.endLargeUtf8(t)}},mo=class rn{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 rn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+xt),(e||new rn).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return rn.startList(t),rn.endList(t)}},Dn=class fr{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 fr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+xt),(e||new fr).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){const 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 fr.startMap(t),fr.addKeysSorted(t,e),fr.endMap(t)}},wo=class nn{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 nn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+xt),(e||new nn).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return nn.startNull(t),nn.endNull(t)}};class Qe{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 Qe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+xt),(e||new Qe).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return Qe.startStruct_(t),Qe.endStruct_(t)}}class ue{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 ue).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+xt),(e||new ue).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):at.MILLISECOND}bitWidth(){const 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,at.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,n){return ue.startTime(t),ue.addUnit(t,e),ue.addBitWidth(t,n),ue.endTime(t)}}class he{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 he).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+xt),(e||new he).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):at.SECOND}timezone(t){const 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,at.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,n){return he.startTimestamp(t),he.addUnit(t,e),he.addTimezone(t,n),he.endTimestamp(t)}}class ee{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 ee).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+xt),(e||new ee).__init(t.readInt32(t.position())+t.position(),t)}mode(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):re.Sparse}typeIds(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+t*4):0}typeIdsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){const 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,re.Sparse)}static addTypeIds(t,e){t.addFieldOffset(1,e,0)}static createTypeIdsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addInt32(e[n]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,n){return ee.startUnion(t),ee.addMode(t,e),ee.addTypeIds(t,n),ee.endUnion(t)}}let bo=class sn{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 sn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+xt),(e||new sn).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return sn.startUtf8(t),sn.endUtf8(t)}};var Dt;(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"})(Dt||(Dt={}));let ae=class Un{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 Un).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+xt),(e||new Un).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}nullable(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):Dt.NONE}type(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){const e=this.bb.__offset(this.bb_pos,12);return e?(t||new De).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){const n=this.bb.__offset(this.bb_pos,14);return n?(e||new Un).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}childrenLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,16);return n?(e||new jt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){const 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,Dt.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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endField(t){return t.endObject()}},Se=class Me{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 Me).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+xt),(e||new Me).__init(t.readInt32(t.position())+t.position(),t)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Ar.Little}fields(t,e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new ae).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}fieldsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new jt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){const 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(){const 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,Ar.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static 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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 n=e.length-1;n>=0;n--)t.addInt64(e[n]);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,n,s,i){return Me.startSchema(t),Me.addEndianness(t,e),Me.addFields(t,n),Me.addCustomMetadata(t,s),Me.addFeatures(t,i),Me.endSchema(t)}};var Bt;(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"})(Bt||(Bt={}));var E;(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"})(E||(E={}));var Fe;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(Fe||(Fe={}));const Hh=void 0;function hn(r){if(r===null)return"null";if(r===Hh)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=>hn(t))}]`:`[${r}]`:ArrayBuffer.isView(r)?`[${r}]`:JSON.stringify(r,(t,e)=>typeof e=="bigint"?`${e}`:e)}function Lt(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 Fa(r,t){return Lt(r/t)+Lt(r%t)/Lt(t)}const qh=Symbol.for("isArrowBigNum");function be(r,...t){return t.length===0?Object.setPrototypeOf(Mt(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}be.prototype[qh]=!0;be.prototype.toJSON=function(){return`"${dn(this)}"`};be.prototype.valueOf=function(r){return Oa(this,r)};be.prototype.toString=function(){return dn(this)};be.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return Oa(this);case"string":return dn(this);case"default":return Qh(this)}return dn(this)};function _r(...r){return be.apply(this,r)}function Sr(...r){return be.apply(this,r)}function ln(...r){return be.apply(this,r)}Object.setPrototypeOf(_r.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(Sr.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(ln.prototype,Object.create(Uint32Array.prototype));Object.assign(_r.prototype,be.prototype,{constructor:_r,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(Sr.prototype,be.prototype,{constructor:Sr,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(ln.prototype,be.prototype,{constructor:ln,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Kh=BigInt(4294967296)*BigInt(4294967296),Xh=Kh-BigInt(1);function Oa(r,t){const{buffer:e,byteOffset:n,byteLength:s,signed:i}=r,a=new BigUint64Array(e,n,s/8),c=i&&a.at(-1)&BigInt(1)<<BigInt(63);let d=BigInt(0),f=0;if(c){for(const y of a)d|=(y^Xh)*(BigInt(1)<<BigInt(64*f++));d*=BigInt(-1),d-=BigInt(1)}else for(const y of a)d|=y*(BigInt(1)<<BigInt(64*f++));if(typeof t=="number"){const y=BigInt(Math.pow(10,t)),B=d/y,L=d%y;return Lt(B)+Lt(L)/Lt(y)}return Lt(d)}function dn(r){if(r.byteLength===8)return`${new r.BigIntArray(r.buffer,r.byteOffset,1)[0]}`;if(!r.signed)return Ui(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Ui(r);t=t.slice();let n=1;for(let i=0;i<t.length;i++){const a=t[i],c=~a+n;t[i]=c,n&=a===0?1:0}return`-${Ui(t)}`}function Qh(r){return r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:dn(r)}function Ui(r){let t="";const e=new Uint32Array(2);let n=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);const s=new Uint32Array((n=new Uint16Array(n).reverse()).buffer);let i=-1;const a=n.length-1;do{for(e[0]=n[i=0];i<a;)n[i++]=e[1]=e[0]/10,e[0]=(e[0]-e[1]*10<<16)+n[i];n[i]=e[1]=e[0]/10,e[0]=e[0]-e[1]*10,t=`${e[0]}${t}`}while(s[0]||s[1]||s[2]||s[3]);return t??"0"}class As{static new(t,e){switch(e){case!0:return new _r(t);case!1:return new Sr(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new _r(t)}return t.byteLength===16?new ln(t):new Sr(t)}static signed(t){return new _r(t)}static unsigned(t){return new Sr(t)}static decimal(t){return new ln(t)}constructor(t,e){return As.new(t,e)}}var ka,Da,Ua,La,Ca,Ra,Pa,$a,za,ja,Va,Wa,Za,Ga,Ya,Ja,Ha,qa,Ka,Xa,Qa,tc;class tt{static isNull(t){return t?.typeId===E.Null}static isInt(t){return t?.typeId===E.Int}static isFloat(t){return t?.typeId===E.Float}static isBinary(t){return t?.typeId===E.Binary}static isLargeBinary(t){return t?.typeId===E.LargeBinary}static isUtf8(t){return t?.typeId===E.Utf8}static isLargeUtf8(t){return t?.typeId===E.LargeUtf8}static isBool(t){return t?.typeId===E.Bool}static isDecimal(t){return t?.typeId===E.Decimal}static isDate(t){return t?.typeId===E.Date}static isTime(t){return t?.typeId===E.Time}static isTimestamp(t){return t?.typeId===E.Timestamp}static isInterval(t){return t?.typeId===E.Interval}static isDuration(t){return t?.typeId===E.Duration}static isList(t){return t?.typeId===E.List}static isStruct(t){return t?.typeId===E.Struct}static isUnion(t){return t?.typeId===E.Union}static isFixedSizeBinary(t){return t?.typeId===E.FixedSizeBinary}static isFixedSizeList(t){return t?.typeId===E.FixedSizeList}static isMap(t){return t?.typeId===E.Map}static isDictionary(t){return t?.typeId===E.Dictionary}static isDenseUnion(t){return tt.isUnion(t)&&t.mode===re.Dense}static isSparseUnion(t){return tt.isUnion(t)&&t.mode===re.Sparse}constructor(t){this.typeId=t}}ka=Symbol.toStringTag;tt[ka]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(tt.prototype);class Je extends tt{constructor(){super(E.Null)}toString(){return"Null"}}Da=Symbol.toStringTag;Je[Da]=(r=>r[Symbol.toStringTag]="Null")(Je.prototype);class er extends tt{constructor(t,e){super(E.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}`}}Ua=Symbol.toStringTag;er[Ua]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(er.prototype);class fn extends er{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(fn.prototype,"ArrayType",{value:Int32Array});class Wn extends tt{constructor(t){super(E.Float),this.precision=t}get ArrayType(){switch(this.precision){case Jt.HALF:return Uint16Array;case Jt.SINGLE:return Float32Array;case Jt.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}La=Symbol.toStringTag;Wn[La]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(Wn.prototype);class Zn extends tt{constructor(){super(E.Binary)}toString(){return"Binary"}}Ca=Symbol.toStringTag;Zn[Ca]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(Zn.prototype);class Gn extends tt{constructor(){super(E.LargeBinary)}toString(){return"LargeBinary"}}Ra=Symbol.toStringTag;Gn[Ra]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(Gn.prototype);class Yn extends tt{constructor(){super(E.Utf8)}toString(){return"Utf8"}}Pa=Symbol.toStringTag;Yn[Pa]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(Yn.prototype);class Jn extends tt{constructor(){super(E.LargeUtf8)}toString(){return"LargeUtf8"}}$a=Symbol.toStringTag;Jn[$a]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(Jn.prototype);class Hn extends tt{constructor(){super(E.Bool)}toString(){return"Bool"}}za=Symbol.toStringTag;Hn[za]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(Hn.prototype);class qn extends tt{constructor(t,e,n=128){super(E.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}ja=Symbol.toStringTag;qn[ja]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(qn.prototype);class Kn extends tt{constructor(t){super(E.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${de[this.unit]}>`}get ArrayType(){return this.unit===de.DAY?Int32Array:BigInt64Array}}Va=Symbol.toStringTag;Kn[Va]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(Kn.prototype);class Xn extends tt{constructor(t,e){super(E.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${at[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}Wa=Symbol.toStringTag;Xn[Wa]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(Xn.prototype);class Qn extends tt{constructor(t,e){super(E.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${at[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}Za=Symbol.toStringTag;Qn[Za]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(Qn.prototype);class ti extends tt{constructor(t){super(E.Interval),this.unit=t}toString(){return`Interval<${Te[this.unit]}>`}}Ga=Symbol.toStringTag;ti[Ga]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(ti.prototype);class ei extends tt{constructor(t){super(E.Duration),this.unit=t}toString(){return`Duration<${at[this.unit]}>`}}Ya=Symbol.toStringTag;ei[Ya]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(ei.prototype);class ri extends tt{constructor(t){super(E.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}}Ja=Symbol.toStringTag;ri[Ja]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(ri.prototype);class Kt extends tt{constructor(t){super(E.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}Ha=Symbol.toStringTag;Kt[Ha]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(Kt.prototype);class ni extends tt{constructor(t,e,n){super(E.Union),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((s,i,a)=>(s[i]=a)&&s||s,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}qa=Symbol.toStringTag;ni[qa]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(ni.prototype);class ii extends tt{constructor(t){super(E.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}Ka=Symbol.toStringTag;ii[Ka]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(ii.prototype);class si extends tt{constructor(t,e){super(E.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}>`}}Xa=Symbol.toStringTag;si[Xa]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(si.prototype);class oi extends tt{constructor(t,e=!1){var n,s,i;if(super(E.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((n=t?.type)===null||n===void 0)&&n.children)){const a=(s=t?.type)===null||s===void 0?void 0:s.children[0];a&&(a.name="key");const c=(i=t?.type)===null||i===void 0?void 0:i.children[1];c&&(c.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(", ")}}>`}}Qa=Symbol.toStringTag;oi[Qa]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(oi.prototype);const tl=(r=>()=>++r)(-1);class Er extends tt{constructor(t,e,n,s){super(E.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=s||!1,this.id=n==null?tl():Lt(n)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}tc=Symbol.toStringTag;Er[tc]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(Er.prototype);function Oe(r){const t=r;switch(r.typeId){case E.Decimal:return r.bitWidth/32;case E.Interval:return 1+t.unit;case E.FixedSizeList:return t.listSize;case E.FixedSizeBinary:return t.byteWidth;default:return 1}}class St{visitMany(t,...e){return t.map((n,s)=>this.visit(n,...e.map(i=>i[s])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return el(this,t,e)}getVisitFnByTypeId(t,e=!0){return pr(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 el(r,t,e=!0){return typeof t=="number"?pr(r,t,e):typeof t=="string"&&t in E?pr(r,E[t],e):t&&t instanceof tt?pr(r,_o(t),e):t?.type&&t.type instanceof tt?pr(r,_o(t.type),e):pr(r,E.NONE,e)}function pr(r,t,e=!0){let n=null;switch(t){case E.Null:n=r.visitNull;break;case E.Bool:n=r.visitBool;break;case E.Int:n=r.visitInt;break;case E.Int8:n=r.visitInt8||r.visitInt;break;case E.Int16:n=r.visitInt16||r.visitInt;break;case E.Int32:n=r.visitInt32||r.visitInt;break;case E.Int64:n=r.visitInt64||r.visitInt;break;case E.Uint8:n=r.visitUint8||r.visitInt;break;case E.Uint16:n=r.visitUint16||r.visitInt;break;case E.Uint32:n=r.visitUint32||r.visitInt;break;case E.Uint64:n=r.visitUint64||r.visitInt;break;case E.Float:n=r.visitFloat;break;case E.Float16:n=r.visitFloat16||r.visitFloat;break;case E.Float32:n=r.visitFloat32||r.visitFloat;break;case E.Float64:n=r.visitFloat64||r.visitFloat;break;case E.Utf8:n=r.visitUtf8;break;case E.LargeUtf8:n=r.visitLargeUtf8;break;case E.Binary:n=r.visitBinary;break;case E.LargeBinary:n=r.visitLargeBinary;break;case E.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case E.Date:n=r.visitDate;break;case E.DateDay:n=r.visitDateDay||r.visitDate;break;case E.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case E.Timestamp:n=r.visitTimestamp;break;case E.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case E.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case E.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case E.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case E.Time:n=r.visitTime;break;case E.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case E.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case E.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case E.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case E.Decimal:n=r.visitDecimal;break;case E.List:n=r.visitList;break;case E.Struct:n=r.visitStruct;break;case E.Union:n=r.visitUnion;break;case E.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case E.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case E.Dictionary:n=r.visitDictionary;break;case E.Interval:n=r.visitInterval;break;case E.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case E.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case E.Duration:n=r.visitDuration;break;case E.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case E.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case E.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case E.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case E.FixedSizeList:n=r.visitFixedSizeList;break;case E.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error(`Unrecognized type '${E[t]}'`)}function _o(r){switch(r.typeId){case E.Null:return E.Null;case E.Int:{const{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?E.Int8:E.Uint8;case 16:return e?E.Int16:E.Uint16;case 32:return e?E.Int32:E.Uint32;case 64:return e?E.Int64:E.Uint64}return E.Int}case E.Float:switch(r.precision){case Jt.HALF:return E.Float16;case Jt.SINGLE:return E.Float32;case Jt.DOUBLE:return E.Float64}return E.Float;case E.Binary:return E.Binary;case E.LargeBinary:return E.LargeBinary;case E.Utf8:return E.Utf8;case E.LargeUtf8:return E.LargeUtf8;case E.Bool:return E.Bool;case E.Decimal:return E.Decimal;case E.Time:switch(r.unit){case at.SECOND:return E.TimeSecond;case at.MILLISECOND:return E.TimeMillisecond;case at.MICROSECOND:return E.TimeMicrosecond;case at.NANOSECOND:return E.TimeNanosecond}return E.Time;case E.Timestamp:switch(r.unit){case at.SECOND:return E.TimestampSecond;case at.MILLISECOND:return E.TimestampMillisecond;case at.MICROSECOND:return E.TimestampMicrosecond;case at.NANOSECOND:return E.TimestampNanosecond}return E.Timestamp;case E.Date:switch(r.unit){case de.DAY:return E.DateDay;case de.MILLISECOND:return E.DateMillisecond}return E.Date;case E.Interval:switch(r.unit){case Te.DAY_TIME:return E.IntervalDayTime;case Te.YEAR_MONTH:return E.IntervalYearMonth}return E.Interval;case E.Duration:switch(r.unit){case at.SECOND:return E.DurationSecond;case at.MILLISECOND:return E.DurationMillisecond;case at.MICROSECOND:return E.DurationMicrosecond;case at.NANOSECOND:return E.DurationNanosecond}return E.Duration;case E.Map:return E.Map;case E.List:return E.List;case E.Struct:return E.Struct;case E.Union:switch(r.mode){case re.Dense:return E.DenseUnion;case re.Sparse:return E.SparseUnion}return E.Union;case E.FixedSizeBinary:return E.FixedSizeBinary;case E.FixedSizeList:return E.FixedSizeList;case E.Dictionary:return E.Dictionary}throw new Error(`Unrecognized type '${E[r.typeId]}'`)}St.prototype.visitInt8=null;St.prototype.visitInt16=null;St.prototype.visitInt32=null;St.prototype.visitInt64=null;St.prototype.visitUint8=null;St.prototype.visitUint16=null;St.prototype.visitUint32=null;St.prototype.visitUint64=null;St.prototype.visitFloat16=null;St.prototype.visitFloat32=null;St.prototype.visitFloat64=null;St.prototype.visitDateDay=null;St.prototype.visitDateMillisecond=null;St.prototype.visitTimestampSecond=null;St.prototype.visitTimestampMillisecond=null;St.prototype.visitTimestampMicrosecond=null;St.prototype.visitTimestampNanosecond=null;St.prototype.visitTimeSecond=null;St.prototype.visitTimeMillisecond=null;St.prototype.visitTimeMicrosecond=null;St.prototype.visitTimeNanosecond=null;St.prototype.visitDenseUnion=null;St.prototype.visitSparseUnion=null;St.prototype.visitIntervalDayTime=null;St.prototype.visitIntervalYearMonth=null;St.prototype.visitDuration=null;St.prototype.visitDurationSecond=null;St.prototype.visitDurationMillisecond=null;St.prototype.visitDurationMicrosecond=null;St.prototype.visitDurationNanosecond=null;const ec=new Float64Array(1),or=new Uint32Array(ec.buffer);function rc(r){const t=(r&31744)>>10,e=(r&1023)/1024,n=Math.pow(-1,(r&32768)>>15);switch(t){case 31:return n*(e?Number.NaN:1/0);case 0:return n*(e?6103515625e-14*e:0)}return n*Math.pow(2,t-15)*(1+e)}function rl(r){if(r!==r)return 32256;ec[0]=r;const t=(or[1]&2147483648)>>16&65535;let e=or[1]&2146435072,n=0;return e>=1089470464?or[0]>0?e=31744:(e=(e&2080374784)>>16,n=(or[1]&1048575)>>10):e<=1056964608?(n=1048576+(or[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(or[1]&1048575)+512>>10),t|e|n&65535}class ct extends St{}function dt(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}const nl=(r,t,e)=>{r[t]=Math.floor(e/864e5)},nc=(r,t,e,n)=>{if(e+1<t.length){const s=Lt(t[e]),i=Lt(t[e+1]);r.set(n.subarray(0,i-s),s)}},il=({offset:r,values:t},e,n)=>{const s=r+e;n?t[s>>3]|=1<<s%8:t[s>>3]&=~(1<<s%8)},Re=({values:r},t,e)=>{r[t]=e},Es=({values:r},t,e)=>{r[t]=e},ic=({values:r},t,e)=>{r[t]=rl(e)},sl=(r,t,e)=>{switch(r.type.precision){case Jt.HALF:return ic(r,t,e);case Jt.SINGLE:case Jt.DOUBLE:return Es(r,t,e)}},sc=({values:r},t,e)=>{nl(r,t,e.valueOf())},oc=({values:r},t,e)=>{r[t]=BigInt(e)},ol=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},ac=({values:r,valueOffsets:t},e,n)=>nc(r,t,e,n),cc=({values:r,valueOffsets:t},e,n)=>nc(r,t,e,Is(n)),al=(r,t,e)=>{r.type.unit===de.DAY?sc(r,t,e):oc(r,t,e)},uc=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},hc=({values:r},t,e)=>{r[t]=BigInt(e)},lc=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},dc=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},cl=(r,t,e)=>{switch(r.type.unit){case at.SECOND:return uc(r,t,e);case at.MILLISECOND:return hc(r,t,e);case at.MICROSECOND:return lc(r,t,e);case at.NANOSECOND:return dc(r,t,e)}},fc=({values:r},t,e)=>{r[t]=e},pc=({values:r},t,e)=>{r[t]=e},yc=({values:r},t,e)=>{r[t]=e},gc=({values:r},t,e)=>{r[t]=e},ul=(r,t,e)=>{switch(r.type.unit){case at.SECOND:return fc(r,t,e);case at.MILLISECOND:return pc(r,t,e);case at.MICROSECOND:return yc(r,t,e);case at.NANOSECOND:return gc(r,t,e)}},hl=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},ll=(r,t,e)=>{const n=r.children[0],s=r.valueOffsets,i=fe.getVisitFn(n);if(Array.isArray(e))for(let a=-1,c=s[t],d=s[t+1];c<d;)i(n,c++,e[++a]);else for(let a=-1,c=s[t],d=s[t+1];c<d;)i(n,c++,e.get(++a))},dl=(r,t,e)=>{const n=r.children[0],{valueOffsets:s}=r,i=fe.getVisitFn(n);let{[t]:a,[t+1]:c}=s;const d=e instanceof Map?e.entries():Object.entries(e);for(const f of d)if(i(n,a,f),++a>=c)break},fl=(r,t)=>(e,n,s,i)=>n&&e(n,r,t[i]),pl=(r,t)=>(e,n,s,i)=>n&&e(n,r,t.get(i)),yl=(r,t)=>(e,n,s,i)=>n&&e(n,r,t.get(s.name)),gl=(r,t)=>(e,n,s,i)=>n&&e(n,r,t[s.name]),ml=(r,t,e)=>{const n=r.type.children.map(i=>fe.getVisitFn(i.type)),s=e instanceof Map?yl(t,e):e instanceof Ft?pl(t,e):Array.isArray(e)?fl(t,e):gl(t,e);r.type.children.forEach((i,a)=>s(n[a],r.children[a],i,a))},wl=(r,t,e)=>{r.type.mode===re.Dense?mc(r,t,e):wc(r,t,e)},mc=(r,t,e)=>{const n=r.type.typeIdToChildIndex[r.typeIds[t]],s=r.children[n];fe.visit(s,r.valueOffsets[t],e)},wc=(r,t,e)=>{const n=r.type.typeIdToChildIndex[r.typeIds[t]],s=r.children[n];fe.visit(s,t,e)},bl=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},_l=(r,t,e)=>{r.type.unit===Te.DAY_TIME?bc(r,t,e):_c(r,t,e)},bc=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},_c=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},Sc=({values:r},t,e)=>{r[t]=e},Ic=({values:r},t,e)=>{r[t]=e},Bc=({values:r},t,e)=>{r[t]=e},vc=({values:r},t,e)=>{r[t]=e},Sl=(r,t,e)=>{switch(r.type.unit){case at.SECOND:return Sc(r,t,e);case at.MILLISECOND:return Ic(r,t,e);case at.MICROSECOND:return Bc(r,t,e);case at.NANOSECOND:return vc(r,t,e)}},Il=(r,t,e)=>{const{stride:n}=r,s=r.children[0],i=fe.getVisitFn(s);if(Array.isArray(e))for(let a=-1,c=t*n;++a<n;)i(s,c+a,e[a]);else for(let a=-1,c=t*n;++a<n;)i(s,c+a,e.get(a))};ct.prototype.visitBool=dt(il);ct.prototype.visitInt=dt(Re);ct.prototype.visitInt8=dt(Re);ct.prototype.visitInt16=dt(Re);ct.prototype.visitInt32=dt(Re);ct.prototype.visitInt64=dt(Re);ct.prototype.visitUint8=dt(Re);ct.prototype.visitUint16=dt(Re);ct.prototype.visitUint32=dt(Re);ct.prototype.visitUint64=dt(Re);ct.prototype.visitFloat=dt(sl);ct.prototype.visitFloat16=dt(ic);ct.prototype.visitFloat32=dt(Es);ct.prototype.visitFloat64=dt(Es);ct.prototype.visitUtf8=dt(cc);ct.prototype.visitLargeUtf8=dt(cc);ct.prototype.visitBinary=dt(ac);ct.prototype.visitLargeBinary=dt(ac);ct.prototype.visitFixedSizeBinary=dt(ol);ct.prototype.visitDate=dt(al);ct.prototype.visitDateDay=dt(sc);ct.prototype.visitDateMillisecond=dt(oc);ct.prototype.visitTimestamp=dt(cl);ct.prototype.visitTimestampSecond=dt(uc);ct.prototype.visitTimestampMillisecond=dt(hc);ct.prototype.visitTimestampMicrosecond=dt(lc);ct.prototype.visitTimestampNanosecond=dt(dc);ct.prototype.visitTime=dt(ul);ct.prototype.visitTimeSecond=dt(fc);ct.prototype.visitTimeMillisecond=dt(pc);ct.prototype.visitTimeMicrosecond=dt(yc);ct.prototype.visitTimeNanosecond=dt(gc);ct.prototype.visitDecimal=dt(hl);ct.prototype.visitList=dt(ll);ct.prototype.visitStruct=dt(ml);ct.prototype.visitUnion=dt(wl);ct.prototype.visitDenseUnion=dt(mc);ct.prototype.visitSparseUnion=dt(wc);ct.prototype.visitDictionary=dt(bl);ct.prototype.visitInterval=dt(_l);ct.prototype.visitIntervalDayTime=dt(bc);ct.prototype.visitIntervalYearMonth=dt(_c);ct.prototype.visitDuration=dt(Sl);ct.prototype.visitDurationSecond=dt(Sc);ct.prototype.visitDurationMillisecond=dt(Ic);ct.prototype.visitDurationMicrosecond=dt(Bc);ct.prototype.visitDurationNanosecond=dt(vc);ct.prototype.visitFixedSizeList=dt(Il);ct.prototype.visitMap=dt(dl);const fe=new ct,pe=Symbol.for("parent"),Ir=Symbol.for("rowIndex");class Ts{constructor(t,e){return this[pe]=t,this[Ir]=e,new Proxy(this,xl)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[Ir],e=this[pe],n=e.type.children,s={};for(let i=-1,a=n.length;++i<a;)s[n[i].name]=ne.visit(e.children[i],t);return s}toString(){return`{${[...this].map(([t,e])=>`${hn(t)}: ${hn(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new Bl(this[pe],this[Ir])}}class Bl{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(){const t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,ne.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}}Object.defineProperties(Ts.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[pe]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ir]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});class vl{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[pe].type.children.map(e=>e.name)}has(t,e){return t[pe].type.children.some(n=>n.name===e)}getOwnPropertyDescriptor(t,e){if(t[pe].type.children.some(n=>n.name===e))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const n=t[pe].type.children.findIndex(s=>s.name===e);if(n!==-1){const s=ne.visit(t[pe].children[n],t[Ir]);return Reflect.set(t,e,s),s}}set(t,e,n){const s=t[pe].type.children.findIndex(i=>i.name===e);return s!==-1?(fe.visit(t[pe].children[s],t[Ir],n),Reflect.set(t,e,n)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,n):!1}}const xl=new vl;class nt extends St{}function ut(r){return(t,e)=>t.getValid(e)?r(t,e):null}const Al=(r,t)=>864e5*r[t],El=(r,t)=>null,xc=(r,t,e)=>{if(e+1>=t.length)return null;const n=Lt(t[e]),s=Lt(t[e+1]);return r.subarray(n,s)},Tl=({offset:r,values:t},e)=>{const n=r+e;return(t[n>>3]&1<<n%8)!==0},Ac=({values:r},t)=>Al(r,t),Ec=({values:r},t)=>Lt(r[t]),qe=({stride:r,values:t},e)=>t[r*e],Ml=({stride:r,values:t},e)=>rc(t[r*e]),Tc=({values:r},t)=>r[t],Nl=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),Mc=({values:r,valueOffsets:t},e)=>xc(r,t,e),Nc=({values:r,valueOffsets:t},e)=>{const n=xc(r,t,e);return n!==null?Ki(n):null},Fl=({values:r},t)=>r[t],Ol=({type:r,values:t},e)=>r.precision!==Jt.HALF?t[e]:rc(t[e]),kl=(r,t)=>r.type.unit===de.DAY?Ac(r,t):Ec(r,t),Fc=({values:r},t)=>1e3*Lt(r[t]),Oc=({values:r},t)=>Lt(r[t]),kc=({values:r},t)=>Fa(r[t],BigInt(1e3)),Dc=({values:r},t)=>Fa(r[t],BigInt(1e6)),Dl=(r,t)=>{switch(r.type.unit){case at.SECOND:return Fc(r,t);case at.MILLISECOND:return Oc(r,t);case at.MICROSECOND:return kc(r,t);case at.NANOSECOND:return Dc(r,t)}},Uc=({values:r},t)=>r[t],Lc=({values:r},t)=>r[t],Cc=({values:r},t)=>r[t],Rc=({values:r},t)=>r[t],Ul=(r,t)=>{switch(r.type.unit){case at.SECOND:return Uc(r,t);case at.MILLISECOND:return Lc(r,t);case at.MICROSECOND:return Cc(r,t);case at.NANOSECOND:return Rc(r,t)}},Ll=({values:r,stride:t},e)=>As.decimal(r.subarray(t*e,t*(e+1))),Cl=(r,t)=>{const{valueOffsets:e,stride:n,children:s}=r,{[t*n]:i,[t*n+1]:a}=e,d=s[0].slice(i,a-i);return new Ft([d])},Rl=(r,t)=>{const{valueOffsets:e,children:n}=r,{[t]:s,[t+1]:i}=e,a=n[0];return new Ms(a.slice(s,i-s))},Pl=(r,t)=>new Ts(r,t),$l=(r,t)=>r.type.mode===re.Dense?Pc(r,t):$c(r,t),Pc=(r,t)=>{const e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return ne.visit(n,r.valueOffsets[t])},$c=(r,t)=>{const e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return ne.visit(n,t)},zl=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},jl=(r,t)=>r.type.unit===Te.DAY_TIME?zc(r,t):jc(r,t),zc=({values:r},t)=>r.subarray(2*t,2*(t+1)),jc=({values:r},t)=>{const e=r[t],n=new Int32Array(2);return n[0]=Math.trunc(e/12),n[1]=Math.trunc(e%12),n},Vc=({values:r},t)=>r[t],Wc=({values:r},t)=>r[t],Zc=({values:r},t)=>r[t],Gc=({values:r},t)=>r[t],Vl=(r,t)=>{switch(r.type.unit){case at.SECOND:return Vc(r,t);case at.MILLISECOND:return Wc(r,t);case at.MICROSECOND:return Zc(r,t);case at.NANOSECOND:return Gc(r,t)}},Wl=(r,t)=>{const{stride:e,children:n}=r,i=n[0].slice(t*e,e);return new Ft([i])};nt.prototype.visitNull=ut(El);nt.prototype.visitBool=ut(Tl);nt.prototype.visitInt=ut(Fl);nt.prototype.visitInt8=ut(qe);nt.prototype.visitInt16=ut(qe);nt.prototype.visitInt32=ut(qe);nt.prototype.visitInt64=ut(Tc);nt.prototype.visitUint8=ut(qe);nt.prototype.visitUint16=ut(qe);nt.prototype.visitUint32=ut(qe);nt.prototype.visitUint64=ut(Tc);nt.prototype.visitFloat=ut(Ol);nt.prototype.visitFloat16=ut(Ml);nt.prototype.visitFloat32=ut(qe);nt.prototype.visitFloat64=ut(qe);nt.prototype.visitUtf8=ut(Nc);nt.prototype.visitLargeUtf8=ut(Nc);nt.prototype.visitBinary=ut(Mc);nt.prototype.visitLargeBinary=ut(Mc);nt.prototype.visitFixedSizeBinary=ut(Nl);nt.prototype.visitDate=ut(kl);nt.prototype.visitDateDay=ut(Ac);nt.prototype.visitDateMillisecond=ut(Ec);nt.prototype.visitTimestamp=ut(Dl);nt.prototype.visitTimestampSecond=ut(Fc);nt.prototype.visitTimestampMillisecond=ut(Oc);nt.prototype.visitTimestampMicrosecond=ut(kc);nt.prototype.visitTimestampNanosecond=ut(Dc);nt.prototype.visitTime=ut(Ul);nt.prototype.visitTimeSecond=ut(Uc);nt.prototype.visitTimeMillisecond=ut(Lc);nt.prototype.visitTimeMicrosecond=ut(Cc);nt.prototype.visitTimeNanosecond=ut(Rc);nt.prototype.visitDecimal=ut(Ll);nt.prototype.visitList=ut(Cl);nt.prototype.visitStruct=ut(Pl);nt.prototype.visitUnion=ut($l);nt.prototype.visitDenseUnion=ut(Pc);nt.prototype.visitSparseUnion=ut($c);nt.prototype.visitDictionary=ut(zl);nt.prototype.visitInterval=ut(jl);nt.prototype.visitIntervalDayTime=ut(zc);nt.prototype.visitIntervalYearMonth=ut(jc);nt.prototype.visitDuration=ut(Vl);nt.prototype.visitDurationSecond=ut(Vc);nt.prototype.visitDurationMillisecond=ut(Wc);nt.prototype.visitDurationMicrosecond=ut(Zc);nt.prototype.visitDurationNanosecond=ut(Gc);nt.prototype.visitFixedSizeList=ut(Wl);nt.prototype.visitMap=ut(Rl);const ne=new nt,yr=Symbol.for("keys"),Br=Symbol.for("vals"),gr=Symbol.for("kKeysAsStrings"),ns=Symbol.for("_kKeysAsStrings");class Ms{constructor(t){return this[yr]=new Ft([t.children[0]]).memoize(),this[Br]=t.children[1],new Proxy(this,new Gl)}get[gr](){return this[ns]||(this[ns]=Array.from(this[yr].toArray(),String))}[Symbol.iterator](){return new Zl(this[yr],this[Br])}get size(){return this[yr].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[yr],e=this[Br],n={};for(let s=-1,i=t.length;++s<i;)n[t.get(s)]=ne.visit(e,s);return n}toString(){return`{${[...this].map(([t,e])=>`${hn(t)}: ${hn(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Zl{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),ne.visit(this.vals,t)]})}}class Gl{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[gr]}has(t,e){return t[gr].includes(e)}getOwnPropertyDescriptor(t,e){if(t[gr].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const n=t[gr].indexOf(e);if(n!==-1){const s=ne.visit(Reflect.get(t,Br),n);return Reflect.set(t,e,s),s}}set(t,e,n){const s=t[gr].indexOf(e);return s!==-1?(fe.visit(Reflect.get(t,Br),s,n),Reflect.set(t,e,n)):Reflect.has(t,e)?Reflect.set(t,e,n):!1}}Object.defineProperties(Ms.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[yr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Br]:{writable:!0,enumerable:!1,configurable:!1,value:null},[ns]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let So;function Yc(r,t,e,n){const{length:s=0}=r;let i=typeof t!="number"?0:t,a=typeof e!="number"?s:e;return i<0&&(i=(i%s+s)%s),a<0&&(a=(a%s+s)%s),a<i&&(So=i,i=a,a=So),a>s&&(a=s),n?n(r,i,a):[i,a]}const Ns=(r,t)=>r<0?t+r:r,Io=r=>r!==r;function Or(r){if(typeof r!=="object"||r===null)return Io(r)?Io:e=>e===r;if(r instanceof Date){const e=r.valueOf();return n=>n instanceof Date?n.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?Vh(r,e):!1:r instanceof Map?Jl(r):Array.isArray(r)?Yl(r):r instanceof Ft?Hl(r):ql(r,!0)}function Yl(r){const t=[];for(let e=-1,n=r.length;++e<n;)t[e]=Or(r[e]);return vi(t)}function Jl(r){let t=-1;const e=[];for(const n of r.values())e[++t]=Or(n);return vi(e)}function Hl(r){const t=[];for(let e=-1,n=r.length;++e<n;)t[e]=Or(r.get(e));return vi(t)}function ql(r,t=!1){const e=Object.keys(r);if(!t&&e.length===0)return()=>!1;const n=[];for(let s=-1,i=e.length;++s<i;)n[s]=Or(r[e[s]]);return vi(n,e)}function vi(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return Kl(r,e);case Map:return Bo(r,e,e.keys());case Ms:case Ts:case Object:case void 0:return Bo(r,e,t||Object.keys(e))}return e instanceof Ft?Xl(r,e):!1}}function Kl(r,t){const e=r.length;if(t.length!==e)return!1;for(let n=-1;++n<e;)if(!r[n](t[n]))return!1;return!0}function Xl(r,t){const e=r.length;if(t.length!==e)return!1;for(let n=-1;++n<e;)if(!r[n](t.get(n)))return!1;return!0}function Bo(r,t,e){const n=e[Symbol.iterator](),s=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),i=t instanceof Map?t.values():Object.values(t)[Symbol.iterator]();let a=0;const c=r.length;let d=i.next(),f=n.next(),y=s.next();for(;a<c&&!f.done&&!y.done&&!d.done&&!(f.value!==y.value||!r[a](d.value));++a,f=n.next(),y=s.next(),d=i.next());return a===c&&f.done&&y.done&&d.done?!0:(n.return&&n.return(),s.return&&s.return(),i.return&&i.return(),!1)}function Jc(r,t,e,n){return(e&1<<n)!==0}function Ql(r,t,e,n){return(e&1<<n)>>n}function vo(r,t,e){const n=e.byteLength+7&-8;if(r>0||e.byteLength<n){const s=new Uint8Array(n);return s.set(r%8===0?e.subarray(r>>3):is(new Fs(e,r,t,null,Jc)).subarray(0,n)),s}return e}function is(r){const t=[];let e=0,n=0,s=0;for(const a of r)a&&(s|=1<<n),++n===8&&(t[e++]=s,s=n=0);(e===0||n>0)&&(t[e++]=s);const i=new Uint8Array(t.length+7&-8);return i.set(t),i}class Fs{constructor(t,e,n,s,i){this.bytes=t,this.length=n,this.context=s,this.get=i,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 ss(r,t,e){if(e-t<=0)return 0;if(e-t<8){let i=0;for(const a of new Fs(r,t,e-t,r,Ql))i+=a;return i}const n=e>>3<<3,s=t+(t%8===0?0:8-t%8);return ss(r,t,s)+ss(r,n,e)+td(r,s>>3,n-s>>3)}function td(r,t,e){let n=0,s=Math.trunc(t);const i=new DataView(r.buffer,r.byteOffset,r.byteLength),a=e===void 0?r.byteLength:s+e;for(;a-s>=4;)n+=Li(i.getUint32(s)),s+=4;for(;a-s>=2;)n+=Li(i.getUint16(s)),s+=2;for(;a-s>=1;)n+=Li(i.getUint8(s)),s+=1;return n}function Li(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const ed=-1;class Et{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){const{type:t}=this;return tt.isSparseUnion(t)?this.children.some(e=>e.nullable):tt.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:e,values:n,nullBitmap:s,typeIds:i}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),s&&(t+=s.byteLength),i&&(t+=i.byteLength),this.children.reduce((a,c)=>a+c.byteLength,t)}get nullCount(){if(tt.isUnion(this.type))return this.children.reduce((n,s)=>n+s.nullCount,0);let t=this._nullCount,e;return t<=ed&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-ss(e,this.offset,this.offset+this.length)),t}constructor(t,e,n,s,i,a=[],c){this.type=t,this.children=a,this.dictionary=c,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(s||0,-1));let d;i instanceof Et?(this.stride=i.stride,this.values=i.values,this.typeIds=i.typeIds,this.nullBitmap=i.nullBitmap,this.valueOffsets=i.valueOffsets):(this.stride=Oe(t),i&&((d=i[0])&&(this.valueOffsets=d),(d=i[1])&&(this.values=d),(d=i[2])&&(this.nullBitmap=d),(d=i[3])&&(this.typeIds=d)))}getValid(t){const{type:e}=this;if(tt.isUnion(e)){const n=e,s=this.children[n.typeIdToChildIndex[this.typeIds[t]]],i=n.mode===re.Dense?this.valueOffsets[t]:t;return s.getValid(i)}if(this.nullable&&this.nullCount>0){const n=this.offset+t;return(this.nullBitmap[n>>3]&1<<n%8)!==0}return!0}setValid(t,e){let n;const{type:s}=this;if(tt.isUnion(s)){const i=s,a=this.children[i.typeIdToChildIndex[this.typeIds[t]]],c=i.mode===re.Dense?this.valueOffsets[t]:t;n=a.getValid(c),a.setValid(c,e)}else{let{nullBitmap:i}=this;const{offset:a,length:c}=this,d=a+t,f=1<<d%8,y=d>>3;(!i||i.byteLength<=y)&&(i=new Uint8Array((a+c+63&-64)>>3).fill(255),this.nullCount>0?(i.set(vo(a,c,this.nullBitmap),0),Object.assign(this,{nullBitmap:i})):Object.assign(this,{nullBitmap:i,_nullCount:0}));const B=i[y];n=(B&f)!==0,i[y]=e?B|f:B&~f}return n!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,n=this.length,s=this._nullCount,i=this,a=this.children){return new Et(t,e,n,s,i,a,this.dictionary)}slice(t,e){const{stride:n,typeId:s,children:i}=this,a=+(this._nullCount===0)-1,c=s===16?n:1,d=this._sliceBuffers(t,e,n,s);return this.clone(this.type,this.offset+t,e,a,d,i.length===0||this.valueOffsets?i:this._sliceChildren(i,c*t,c*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===E.Null)return this.clone(this.type,0,t,0);const{length:e,nullCount:n}=this,s=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);s[e>>3]=(1<<e-(e&-8))-1,n>0&&s.set(vo(this.offset,e,this.nullBitmap),0);const i=this.buffers;return i[Fe.VALIDITY]=s,this.clone(this.type,0,t,n+(t-e),i)}_sliceBuffers(t,e,n,s){let i;const{buffers:a}=this;return(i=a[Fe.TYPE])&&(a[Fe.TYPE]=i.subarray(t,t+e)),(i=a[Fe.OFFSET])&&(a[Fe.OFFSET]=i.subarray(t,t+e+1))||(i=a[Fe.DATA])&&(a[Fe.DATA]=s===6?i:i.subarray(n*t,n*(t+e))),a}_sliceChildren(t,e,n){return t.map(s=>s.slice(e,n))}}Et.prototype.children=Object.freeze([]);class an extends St{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:e,["offset"]:n=0,["length"]:s=0}=t;return new Et(e,n,s,s)}visitBool(t){const{["type"]:e,["offset"]:n=0}=t,s=It(t.nullBitmap),i=Mt(e.ArrayType,t.data),{["length"]:a=i.length>>3,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,s])}visitInt(t){const{["type"]:e,["offset"]:n=0}=t,s=It(t.nullBitmap),i=Mt(e.ArrayType,t.data),{["length"]:a=i.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,s])}visitFloat(t){const{["type"]:e,["offset"]:n=0}=t,s=It(t.nullBitmap),i=Mt(e.ArrayType,t.data),{["length"]:a=i.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,s])}visitUtf8(t){const{["type"]:e,["offset"]:n=0}=t,s=It(t.data),i=It(t.nullBitmap),a=Dr(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:d=t.nullBitmap?-1:0}=t;return new Et(e,n,c,d,[a,s,i])}visitLargeUtf8(t){const{["type"]:e,["offset"]:n=0}=t,s=It(t.data),i=It(t.nullBitmap),a=uo(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:d=t.nullBitmap?-1:0}=t;return new Et(e,n,c,d,[a,s,i])}visitBinary(t){const{["type"]:e,["offset"]:n=0}=t,s=It(t.data),i=It(t.nullBitmap),a=Dr(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:d=t.nullBitmap?-1:0}=t;return new Et(e,n,c,d,[a,s,i])}visitLargeBinary(t){const{["type"]:e,["offset"]:n=0}=t,s=It(t.data),i=It(t.nullBitmap),a=uo(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:d=t.nullBitmap?-1:0}=t;return new Et(e,n,c,d,[a,s,i])}visitFixedSizeBinary(t){const{["type"]:e,["offset"]:n=0}=t,s=It(t.nullBitmap),i=Mt(e.ArrayType,t.data),{["length"]:a=i.length/Oe(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,s])}visitDate(t){const{["type"]:e,["offset"]:n=0}=t,s=It(t.nullBitmap),i=Mt(e.ArrayType,t.data),{["length"]:a=i.length/Oe(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,s])}visitTimestamp(t){const{["type"]:e,["offset"]:n=0}=t,s=It(t.nullBitmap),i=Mt(e.ArrayType,t.data),{["length"]:a=i.length/Oe(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,s])}visitTime(t){const{["type"]:e,["offset"]:n=0}=t,s=It(t.nullBitmap),i=Mt(e.ArrayType,t.data),{["length"]:a=i.length/Oe(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,s])}visitDecimal(t){const{["type"]:e,["offset"]:n=0}=t,s=It(t.nullBitmap),i=Mt(e.ArrayType,t.data),{["length"]:a=i.length/Oe(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,s])}visitList(t){const{["type"]:e,["offset"]:n=0,["child"]:s}=t,i=It(t.nullBitmap),a=Dr(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:d=t.nullBitmap?-1:0}=t;return new Et(e,n,c,d,[a,void 0,i],[s])}visitStruct(t){const{["type"]:e,["offset"]:n=0,["children"]:s=[]}=t,i=It(t.nullBitmap),{length:a=s.reduce((d,{length:f})=>Math.max(d,f),0),nullCount:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,void 0,i],s)}visitUnion(t){const{["type"]:e,["offset"]:n=0,["children"]:s=[]}=t,i=Mt(e.ArrayType,t.typeIds),{["length"]:a=i.length,["nullCount"]:c=-1}=t;if(tt.isSparseUnion(e))return new Et(e,n,a,c,[void 0,void 0,void 0,i],s);const d=Dr(t.valueOffsets);return new Et(e,n,a,c,[d,void 0,void 0,i],s)}visitDictionary(t){const{["type"]:e,["offset"]:n=0}=t,s=It(t.nullBitmap),i=Mt(e.indices.ArrayType,t.data),{["dictionary"]:a=new Ft([new an().visit({type:e.dictionary})])}=t,{["length"]:c=i.length,["nullCount"]:d=t.nullBitmap?-1:0}=t;return new Et(e,n,c,d,[void 0,i,s],[],a)}visitInterval(t){const{["type"]:e,["offset"]:n=0}=t,s=It(t.nullBitmap),i=Mt(e.ArrayType,t.data),{["length"]:a=i.length/Oe(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,s])}visitDuration(t){const{["type"]:e,["offset"]:n=0}=t,s=It(t.nullBitmap),i=Mt(e.ArrayType,t.data),{["length"]:a=i.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,i,s])}visitFixedSizeList(t){const{["type"]:e,["offset"]:n=0,["child"]:s=new an().visit({type:e.valueType})}=t,i=It(t.nullBitmap),{["length"]:a=s.length/Oe(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new Et(e,n,a,c,[void 0,void 0,i],[s])}visitMap(t){const{["type"]:e,["offset"]:n=0,["child"]:s=new an().visit({type:e.childType})}=t,i=It(t.nullBitmap),a=Dr(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:d=t.nullBitmap?-1:0}=t;return new Et(e,n,c,d,[a,void 0,i],[s])}}const rd=new an;function _t(r){return rd.visit(r)}class xo{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){const 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 nd(r){return r.some(t=>t.nullable)}function Hc(r){return r.reduce((t,e)=>t+e.nullCount,0)}function qc(r){return r.reduce((t,e,n)=>(t[n+1]=t[n]+e.length,t),new Uint32Array(r.length+1))}function Kc(r,t,e,n){const s=[];for(let i=-1,a=r.length;++i<a;){const c=r[i],d=t[i],{length:f}=c;if(d>=n)break;if(e>=d+f)continue;if(d>=e&&d+f<=n){s.push(c);continue}const y=Math.max(0,e-d),B=Math.min(n-d,f);s.push(c.slice(y,B-y))}return s.length===0&&s.push(r[0].slice(0,0)),s}function Os(r,t,e,n){let s=0,i=0,a=t.length-1;do{if(s>=a-1)return e<t[a]?n(r,s,e-t[s]):null;i=s+Math.trunc((a-s)*.5),e<t[i]?a=i:s=i}while(s<a)}function ks(r,t){return r.getValid(t)}function ai(r){function t(e,n,s){return r(e[n],s)}return function(e){const n=this.data;return Os(n,this._offsets,e,t)}}function Xc(r){let t;function e(n,s,i){return r(n[s],i,t)}return function(n,s){const i=this.data;t=s;const a=Os(i,this._offsets,n,e);return t=void 0,a}}function Qc(r){let t;function e(n,s,i){let a=i,c=0,d=0;for(let f=s-1,y=n.length;++f<y;){const B=n[f];if(~(c=r(B,t,a)))return d+c;a=0,d+=B.length}return-1}return function(n,s){t=n;const i=this.data,a=typeof s!="number"?e(i,0,0):Os(i,this._offsets,s,e);return t=void 0,a}}class it extends St{}function id(r,t){return t===null&&r.length>0?0:-1}function sd(r,t){const{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(const s of new Fs(e,r.offset+(t||0),r.length,e,Jc)){if(!s)return n;++n}return-1}function ft(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case E.Union:break;case E.Dictionary:break;default:return sd(r,e)}const n=ne.getVisitFn(r),s=Or(t);for(let i=(e||0)-1,a=r.length;++i<a;)if(s(n(r,i)))return i;return-1}function tu(r,t,e){const n=ne.getVisitFn(r),s=Or(t);for(let i=(e||0)-1,a=r.length;++i<a;)if(s(n(r,i)))return i;return-1}it.prototype.visitNull=id;it.prototype.visitBool=ft;it.prototype.visitInt=ft;it.prototype.visitInt8=ft;it.prototype.visitInt16=ft;it.prototype.visitInt32=ft;it.prototype.visitInt64=ft;it.prototype.visitUint8=ft;it.prototype.visitUint16=ft;it.prototype.visitUint32=ft;it.prototype.visitUint64=ft;it.prototype.visitFloat=ft;it.prototype.visitFloat16=ft;it.prototype.visitFloat32=ft;it.prototype.visitFloat64=ft;it.prototype.visitUtf8=ft;it.prototype.visitLargeUtf8=ft;it.prototype.visitBinary=ft;it.prototype.visitLargeBinary=ft;it.prototype.visitFixedSizeBinary=ft;it.prototype.visitDate=ft;it.prototype.visitDateDay=ft;it.prototype.visitDateMillisecond=ft;it.prototype.visitTimestamp=ft;it.prototype.visitTimestampSecond=ft;it.prototype.visitTimestampMillisecond=ft;it.prototype.visitTimestampMicrosecond=ft;it.prototype.visitTimestampNanosecond=ft;it.prototype.visitTime=ft;it.prototype.visitTimeSecond=ft;it.prototype.visitTimeMillisecond=ft;it.prototype.visitTimeMicrosecond=ft;it.prototype.visitTimeNanosecond=ft;it.prototype.visitDecimal=ft;it.prototype.visitList=ft;it.prototype.visitStruct=ft;it.prototype.visitUnion=ft;it.prototype.visitDenseUnion=tu;it.prototype.visitSparseUnion=tu;it.prototype.visitDictionary=ft;it.prototype.visitInterval=ft;it.prototype.visitIntervalDayTime=ft;it.prototype.visitIntervalYearMonth=ft;it.prototype.visitDuration=ft;it.prototype.visitDurationSecond=ft;it.prototype.visitDurationMillisecond=ft;it.prototype.visitDurationMicrosecond=ft;it.prototype.visitDurationNanosecond=ft;it.prototype.visitFixedSizeList=ft;it.prototype.visitMap=ft;const ci=new it;class st extends St{}function ht(r){const{type:t}=r;if(r.nullCount===0&&r.stride===1&&(tt.isInt(t)&&t.bitWidth!==64||tt.isTime(t)&&t.bitWidth!==64||tt.isFloat(t)&&t.precision!==Jt.HALF))return new xo(r.data.length,n=>{const s=r.data[n];return s.values.subarray(0,s.length)[Symbol.iterator]()});let e=0;return new xo(r.data.length,n=>{const i=r.data[n].length,a=r.slice(e,e+i);return e+=i,new od(a)})}class od{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}}st.prototype.visitNull=ht;st.prototype.visitBool=ht;st.prototype.visitInt=ht;st.prototype.visitInt8=ht;st.prototype.visitInt16=ht;st.prototype.visitInt32=ht;st.prototype.visitInt64=ht;st.prototype.visitUint8=ht;st.prototype.visitUint16=ht;st.prototype.visitUint32=ht;st.prototype.visitUint64=ht;st.prototype.visitFloat=ht;st.prototype.visitFloat16=ht;st.prototype.visitFloat32=ht;st.prototype.visitFloat64=ht;st.prototype.visitUtf8=ht;st.prototype.visitLargeUtf8=ht;st.prototype.visitBinary=ht;st.prototype.visitLargeBinary=ht;st.prototype.visitFixedSizeBinary=ht;st.prototype.visitDate=ht;st.prototype.visitDateDay=ht;st.prototype.visitDateMillisecond=ht;st.prototype.visitTimestamp=ht;st.prototype.visitTimestampSecond=ht;st.prototype.visitTimestampMillisecond=ht;st.prototype.visitTimestampMicrosecond=ht;st.prototype.visitTimestampNanosecond=ht;st.prototype.visitTime=ht;st.prototype.visitTimeSecond=ht;st.prototype.visitTimeMillisecond=ht;st.prototype.visitTimeMicrosecond=ht;st.prototype.visitTimeNanosecond=ht;st.prototype.visitDecimal=ht;st.prototype.visitList=ht;st.prototype.visitStruct=ht;st.prototype.visitUnion=ht;st.prototype.visitDenseUnion=ht;st.prototype.visitSparseUnion=ht;st.prototype.visitDictionary=ht;st.prototype.visitInterval=ht;st.prototype.visitIntervalDayTime=ht;st.prototype.visitIntervalYearMonth=ht;st.prototype.visitDuration=ht;st.prototype.visitDurationSecond=ht;st.prototype.visitDurationMillisecond=ht;st.prototype.visitDurationMicrosecond=ht;st.prototype.visitDurationNanosecond=ht;st.prototype.visitFixedSizeList=ht;st.prototype.visitMap=ht;const Ds=new st;var eu;const ru={},nu={};class Ft{constructor(t){var e,n,s;const i=t[0]instanceof Ft?t.flatMap(c=>c.data):t;if(i.length===0||i.some(c=>!(c instanceof Et)))throw new TypeError("Vector constructor expects an Array of Data instances.");const a=(e=i[0])===null||e===void 0?void 0:e.type;switch(i.length){case 0:this._offsets=[0];break;case 1:{const{get:c,set:d,indexOf:f}=ru[a.typeId],y=i[0];this.isValid=B=>ks(y,B),this.get=B=>c(y,B),this.set=(B,L)=>d(y,B,L),this.indexOf=B=>f(y,B),this._offsets=[0,y.length];break}default:Object.setPrototypeOf(this,nu[a.typeId]),this._offsets=qc(i);break}this.data=i,this.type=a,this.stride=Oe(a),this.numChildren=(s=(n=a.children)===null||n===void 0?void 0:n.length)!==null&&s!==void 0?s:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,e)=>t+e.byteLength,0)}get nullable(){return nd(this.data)}get nullCount(){return Hc(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${E[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(Ns(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return Ds.visit(this)}concat(...t){return new Ft(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new Ft(Yc(this,t,e,({data:n,_offsets:s},i,a)=>Kc(n,s,i,a)))}toJSON(){return[...this]}toArray(){const{type:t,data:e,length:n,stride:s,ArrayType:i}=this;switch(t.typeId){case E.Int:case E.Float:case E.Decimal:case E.Time:case E.Timestamp:switch(e.length){case 0:return new i;case 1:return e[0].values.subarray(0,n*s);default:return e.reduce((a,{values:c,length:d})=>(a.array.set(c.subarray(0,d*s),a.offset),a.offset+=d*s,a),{array:new i(n*s),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(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new Ft(this.data.map(({children:e})=>e[t])):null}get isMemoized(){return tt.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(tt.isDictionary(this.type)){const t=new ui(this.data[0].dictionary),e=this.data.map(n=>{const s=n.clone();return s.dictionary=t,s});return new Ft(e)}return new ui(this)}unmemoize(){if(tt.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),e=this.data.map(n=>{const s=n.clone();return s.dictionary=t,s});return new Ft(e)}return this}}eu=Symbol.toStringTag;Ft[eu]=(r=>{r.type=tt.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0;const t=Object.keys(E).map(e=>E[e]).filter(e=>typeof e=="number"&&e!==E.NONE);for(const e of t){const n=ne.getVisitFnByTypeId(e),s=fe.getVisitFnByTypeId(e),i=ci.getVisitFnByTypeId(e);ru[e]={get:n,set:s,indexOf:i},nu[e]=Object.create(r,{isValid:{value:ai(ks)},get:{value:ai(ne.getVisitFnByTypeId(e))},set:{value:Xc(fe.getVisitFnByTypeId(e))},indexOf:{value:Qc(ci.getVisitFnByTypeId(e))}})}return"Vector"})(Ft.prototype);class ui extends Ft{constructor(t){super(t.data);const e=this.get,n=this.set,s=this.slice,i=new Array(this.length);Object.defineProperty(this,"get",{value(a){const c=i[a];if(c!==void 0)return c;const d=e.call(this,a);return i[a]=d,d}}),Object.defineProperty(this,"set",{value(a,c){n.call(this,a,c),i[a]=c}}),Object.defineProperty(this,"slice",{value:(a,c)=>new ui(s.call(this,a,c))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Ft(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class os{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,n,s){return t.prep(8,24),t.writeInt64(BigInt(s??0)),t.pad(4),t.writeInt32(n),t.writeInt64(BigInt(e??0)),t.offset()}}class ie{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 ie).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+xt),(e||new ie).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):zt.V1}schema(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new Se).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new os).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}dictionariesLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,e){const n=this.bb.__offset(this.bb_pos,10);return n?(e||new os).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}recordBatchesLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,12);return n?(e||new jt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){const 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,zt.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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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)}}class vt{constructor(t=[],e,n,s=zt.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=as(this.fields)),this.dictionaries=n,this.metadataVersion=s}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){const e=new Set(t),n=this.fields.filter(s=>e.has(s.name));return new vt(n,this.metadata)}selectAt(t){const e=t.map(n=>this.fields[n]).filter(Boolean);return new vt(e,this.metadata)}assign(...t){const e=t[0]instanceof vt?t[0]:Array.isArray(t[0])?new vt(t[0]):new vt(t),n=[...this.fields],s=Bn(Bn(new Map,this.metadata),e.metadata),i=e.fields.filter(c=>{const d=n.findIndex(f=>f.name===c.name);return~d?(n[d]=c.clone({metadata:Bn(Bn(new Map,n[d].metadata),c.metadata)}))&&!1:!0}),a=as(i,new Map);return new vt([...n,...i],s,new Map([...this.dictionaries,...a]))}}vt.prototype.fields=null;vt.prototype.metadata=null;vt.prototype.dictionaries=null;class Ct{static new(...t){let[e,n,s,i]=t;return t[0]&&typeof t[0]=="object"&&({name:e}=t[0],n===void 0&&(n=t[0].type),s===void 0&&(s=t[0].nullable),i===void 0&&(i=t[0].metadata)),new Ct(`${e}`,n,s,i)}constructor(t,e,n=!1,s){this.name=t,this.type=e,this.nullable=n,this.metadata=s||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,n,s,i]=t;return!t[0]||typeof t[0]!="object"?[e=this.name,n=this.type,s=this.nullable,i=this.metadata]=t:{name:e=this.name,type:n=this.type,nullable:s=this.nullable,metadata:i=this.metadata}=t[0],Ct.new(e,n,s,i)}}Ct.prototype.type=null;Ct.prototype.name=null;Ct.prototype.nullable=null;Ct.prototype.metadata=null;function Bn(r,t){return new Map([...r||new Map,...t||new Map])}function as(r,t=new Map){for(let e=-1,n=r.length;++e<n;){const i=r[e].type;if(tt.isDictionary(i)){if(!t.has(i.id))t.set(i.id,i.dictionary);else if(t.get(i.id)!==i.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}i.children&&i.children.length>0&&as(i.children,t)}return t}var ad=Ea,cd=xr;class Us{static decode(t){t=new cd(It(t));const e=ie.getRootAsFooter(t),n=vt.decode(e.schema(),new Map,e.version());return new ud(n,e)}static encode(t){const e=new ad,n=vt.encode(e,t.schema);ie.startRecordBatchesVector(e,t.numRecordBatches);for(const a of[...t.recordBatches()].slice().reverse())Tr.encode(e,a);const s=e.endVector();ie.startDictionariesVector(e,t.numDictionaries);for(const a of[...t.dictionaryBatches()].slice().reverse())Tr.encode(e,a);const i=e.endVector();return ie.startFooter(e),ie.addSchema(e,n),ie.addVersion(e,zt.V5),ie.addRecordBatches(e,s),ie.addDictionaries(e,i),ie.finishFooterBuffer(e,ie.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=zt.V5,n,s){this.schema=t,this.version=e,n&&(this._recordBatches=n),s&&(this._dictionaryBatches=s)}*recordBatches(){for(let t,e=-1,n=this.numRecordBatches;++e<n;)(t=this.getRecordBatch(e))&&(yield t)}*dictionaryBatches(){for(let t,e=-1,n=this.numDictionaries;++e<n;)(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}}class ud extends Us{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){const e=this._footer.recordBatches(t);if(e)return Tr.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){const e=this._footer.dictionaries(t);if(e)return Tr.decode(e)}return null}}class Tr{static decode(t){return new Tr(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,e){const{metaDataLength:n}=e,s=BigInt(e.offset),i=BigInt(e.bodyLength);return os.createBlock(t,s,n,i)}constructor(t,e,n){this.metaDataLength=t,this.offset=Lt(n),this.bodyLength=Lt(e)}}const Rt=Object.freeze({done:!0,value:void 0});class Ao{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class iu{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())}}class hd extends iu{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return gt(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){const{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(Rt);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return ce.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return ce.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return gt(this,void 0,void 0,function*(){return yield this.abort(t),Rt})}return(t){return gt(this,void 0,void 0,function*(){return yield this.close(),Rt})}read(t){return gt(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return gt(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,n)=>{this.resolvers.push({resolve:e,reject:n})}):Promise.resolve(Rt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class ld extends hd{write(t){if((t=It(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Ki(this.toUint8Array(!0)):this.toUint8Array(!1).then(Ki)}toUint8Array(t=!1){return t?Ee(this._values)[0]:gt(this,void 0,void 0,function*(){var e,n,s,i;const a=[];let c=0;try{for(var d=!0,f=br(this),y;y=yield f.next(),e=y.done,!e;d=!0){i=y.value,d=!1;const B=i;a.push(B),c+=B.byteLength}}catch(B){n={error:B}}finally{try{!d&&!e&&(s=f.return)&&(yield s.call(f))}finally{if(n)throw n.error}}return Ee(a,c)[0]})}}class hi{constructor(t){t&&(this.source=new dd(ce.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)}}class Mr{constructor(t){t instanceof Mr?this.source=t.source:t instanceof ld?this.source=new Xe(ce.fromAsyncIterable(t)):va(t)?this.source=new Xe(ce.fromNodeStream(t)):vs(t)?this.source=new Xe(ce.fromDOMStream(t)):Ia(t)?this.source=new Xe(ce.fromDOMStream(t.body)):Bi(t)?this.source=new Xe(ce.fromIterable(t)):un(t)?this.source=new Xe(ce.fromAsyncIterable(t)):Bs(t)&&(this.source=new Xe(ce.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)}}class dd{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)||Rt)}return(t){return Object.create(this.source.return&&this.source.return(t)||Rt)}}class Xe{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return gt(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return gt(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return gt(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return gt(this,arguments,void 0,function*(e,n="read"){return yield this.source.next({cmd:n,size:e})})}throw(t){return gt(this,void 0,void 0,function*(){const e=this.source.throw&&(yield this.source.throw(t))||Rt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return gt(this,void 0,void 0,function*(){const e=this.source.return&&(yield this.source.return(t))||Rt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}}class Eo extends hi{constructor(t,e){super(),this.position=0,this.buffer=It(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){const{buffer:e,byteOffset:n}=this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){const{buffer:e,size:n,position:s}=this;return e&&s<n?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(n,s+Math.min(n-s,t)),e.subarray(s,this.position)):null}readAt(t,e){const n=this.buffer,s=Math.min(this.size,t+e);return n?n.subarray(t,s):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}}}class li extends Mr{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=gt(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return gt(this,void 0,void 0,function*(){const{buffer:e,byteOffset:n}=yield this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)})}seek(t){return gt(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 gt(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:e,size:n,position:s}=this;if(e&&s<n){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let i=s,a=0,c=0;const d=Math.min(n,i+Math.min(n-i,t)),f=new Uint8Array(Math.max(0,(this.position=d)-i));for(;(i+=c)<d&&(a+=c)<f.byteLength;)({bytesRead:c}=yield e.read(f,a,f.byteLength-a,i));return f}return null})}readAt(t,e){return gt(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:n,size:s}=this;if(n&&t+e<s){const i=Math.min(s,t+e),a=new Uint8Array(i-t);return(yield n.read(a,0,e,t)).buffer}return new Uint8Array(e)})}close(){return gt(this,void 0,void 0,function*(){const t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return gt(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return gt(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}}const fd=65536;function wr(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}const Nr=8,Ls=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class su{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){const e=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let s=e[3]*n[3];this.buffer[0]=s&65535;let i=s>>>16;return s=e[2]*n[3],i+=s,s=e[3]*n[2]>>>0,i+=s,this.buffer[0]+=i<<16,this.buffer[1]=i>>>0<s?fd:0,this.buffer[1]+=i>>>16,this.buffer[1]+=e[1]*n[3]+e[2]*n[2]+e[3]*n[1],this.buffer[1]+=e[0]*n[3]+e[1]*n[2]+e[2]*n[1]+e[3]*n[0]<<16,this}_plus(t){const 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`${wr(this.buffer[1])} ${wr(this.buffer[0])}`}}class Tt extends su{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,e=new Uint32Array(2)){return Tt.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return Tt.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){const n=t.length,s=new Tt(e);for(let i=0;i<n;){const a=Nr<n-i?Nr:n-i,c=new Tt(new Uint32Array([Number.parseInt(t.slice(i,i+a),10),0])),d=new Tt(new Uint32Array([Ls[a],0]));s.times(d),s.plus(c),i+=a}return s}static convertArray(t){const e=new Uint32Array(t.length*2);for(let n=-1,s=t.length;++n<s;)Tt.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new Tt(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new Tt(new Uint32Array(t.buffer)).plus(e)}}class te extends su{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){const e=this.buffer[1]<<0,n=t.buffer[1]<<0;return e<n||e===n&&this.buffer[0]<t.buffer[0]}static from(t,e=new Uint32Array(2)){return te.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return te.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){const n=t.startsWith("-"),s=t.length,i=new te(e);for(let a=n?1:0;a<s;){const c=Nr<s-a?Nr:s-a,d=new te(new Uint32Array([Number.parseInt(t.slice(a,a+c),10),0])),f=new te(new Uint32Array([Ls[c],0]));i.times(f),i.plus(d),a+=c}return n?i.negate():i}static convertArray(t){const e=new Uint32Array(t.length*2);for(let n=-1,s=t.length;++n<s;)te.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new te(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new te(new Uint32Array(t.buffer)).plus(e)}}class Ie{constructor(t){this.buffer=t}high(){return new te(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new te(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){const e=new Tt(new Uint32Array([this.buffer[3],0])),n=new Tt(new Uint32Array([this.buffer[2],0])),s=new Tt(new Uint32Array([this.buffer[1],0])),i=new Tt(new Uint32Array([this.buffer[0],0])),a=new Tt(new Uint32Array([t.buffer[3],0])),c=new Tt(new Uint32Array([t.buffer[2],0])),d=new Tt(new Uint32Array([t.buffer[1],0])),f=new Tt(new Uint32Array([t.buffer[0],0]));let y=Tt.multiply(i,f);this.buffer[0]=y.low();const B=new Tt(new Uint32Array([y.high(),0]));return y=Tt.multiply(s,f),B.plus(y),y=Tt.multiply(i,d),B.plus(y),this.buffer[1]=B.low(),this.buffer[3]=B.lessThan(y)?1:0,this.buffer[2]=B.high(),new Tt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(Tt.multiply(n,f)).plus(Tt.multiply(s,d)).plus(Tt.multiply(i,c)),this.buffer[3]+=Tt.multiply(e,f).plus(Tt.multiply(n,d)).plus(Tt.multiply(s,c)).plus(Tt.multiply(i,a)).low(),this}plus(t){const 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`${wr(this.buffer[3])} ${wr(this.buffer[2])} ${wr(this.buffer[1])} ${wr(this.buffer[0])}`}static multiply(t,e){return new Ie(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new Ie(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return Ie.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return Ie.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){const n=t.startsWith("-"),s=t.length,i=new Ie(e);for(let a=n?1:0;a<s;){const c=Nr<s-a?Nr:s-a,d=new Ie(new Uint32Array([Number.parseInt(t.slice(a,a+c),10),0,0,0])),f=new Ie(new Uint32Array([Ls[c],0,0,0]));i.times(f),i.plus(d),a+=c}return n?i.negate():i}static convertArray(t){const e=new Uint32Array(t.length*4);for(let n=-1,s=t.length;++n<s;)Ie.from(t[n],new Uint32Array(e.buffer,e.byteOffset+4*4*n,4));return e}}class ou extends St{constructor(t,e,n,s,i=zt.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=e,this.buffers=n,this.dictionaries=s,this.metadataVersion=i}visit(t){return super.visit(t instanceof Ct?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return _t({type:t,length:e})}visitBool(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitInt(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDate(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTime(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitList(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),children:this.visitMany(t.children)})}visitUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return this.metadataVersion<zt.V5&&this.readNullBitmap(t,n),t.mode===re.Sparse?this.visitSparseUnion(t,{length:e,nullCount:n}):this.visitDenseUnion(t,{length:e,nullCount:n})}visitDenseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),child:this.visit(t.children[0])})}visitMap(t,{length:e,nullCount:n}=this.nextFieldNode()){return _t({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),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,n=this.nextBufferRange()){return e>0&&this.readData(t,n)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+e)}readDictionary(t){return this.dictionaries.get(t.id)}}class pd extends ou{constructor(t,e,n,s,i){super(new Uint8Array(0),e,n,s,i),this.sources=t}readNullBitmap(t,e,{offset:n}=this.nextBufferRange()){return e<=0?new Uint8Array(0):is(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return Mt(Uint8Array,Mt(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return Mt(Uint8Array,Mt(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){const{sources:n}=this;return tt.isTimestamp(t)||(tt.isInt(t)||tt.isTime(t))&&t.bitWidth===64||tt.isDuration(t)||tt.isDate(t)&&t.unit===de.MILLISECOND?Mt(Uint8Array,te.convertArray(n[e])):tt.isDecimal(t)?Mt(Uint8Array,Ie.convertArray(n[e])):tt.isBinary(t)||tt.isLargeBinary(t)||tt.isFixedSizeBinary(t)?yd(n[e]):tt.isBool(t)?is(n[e]):tt.isUtf8(t)||tt.isLargeUtf8(t)?Is(n[e].join("")):Mt(Uint8Array,Mt(t.ArrayType,n[e].map(s=>+s)))}}function yd(r){const t=r.join(""),e=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)e[n>>1]=Number.parseInt(t.slice(n,n+2),16);return e}class ot extends St{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((n,s)=>this.compareFields(n,e[s]))}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 Xt(r,t){return t instanceof r.constructor}function ir(r,t){return r===t||Xt(r,t)}function Pe(r,t){return r===t||Xt(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function xi(r,t){return r===t||Xt(r,t)&&r.precision===t.precision}function gd(r,t){return r===t||Xt(r,t)&&r.byteWidth===t.byteWidth}function Cs(r,t){return r===t||Xt(r,t)&&r.unit===t.unit}function gn(r,t){return r===t||Xt(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function mn(r,t){return r===t||Xt(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function md(r,t){return r===t||Xt(r,t)&&r.children.length===t.children.length&&He.compareManyFields(r.children,t.children)}function wd(r,t){return r===t||Xt(r,t)&&r.children.length===t.children.length&&He.compareManyFields(r.children,t.children)}function Rs(r,t){return r===t||Xt(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&He.compareManyFields(r.children,t.children)}function bd(r,t){return r===t||Xt(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&He.visit(r.indices,t.indices)&&He.visit(r.dictionary,t.dictionary)}function Ps(r,t){return r===t||Xt(r,t)&&r.unit===t.unit}function wn(r,t){return r===t||Xt(r,t)&&r.unit===t.unit}function _d(r,t){return r===t||Xt(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&He.compareManyFields(r.children,t.children)}function Sd(r,t){return r===t||Xt(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&He.compareManyFields(r.children,t.children)}ot.prototype.visitNull=ir;ot.prototype.visitBool=ir;ot.prototype.visitInt=Pe;ot.prototype.visitInt8=Pe;ot.prototype.visitInt16=Pe;ot.prototype.visitInt32=Pe;ot.prototype.visitInt64=Pe;ot.prototype.visitUint8=Pe;ot.prototype.visitUint16=Pe;ot.prototype.visitUint32=Pe;ot.prototype.visitUint64=Pe;ot.prototype.visitFloat=xi;ot.prototype.visitFloat16=xi;ot.prototype.visitFloat32=xi;ot.prototype.visitFloat64=xi;ot.prototype.visitUtf8=ir;ot.prototype.visitLargeUtf8=ir;ot.prototype.visitBinary=ir;ot.prototype.visitLargeBinary=ir;ot.prototype.visitFixedSizeBinary=gd;ot.prototype.visitDate=Cs;ot.prototype.visitDateDay=Cs;ot.prototype.visitDateMillisecond=Cs;ot.prototype.visitTimestamp=gn;ot.prototype.visitTimestampSecond=gn;ot.prototype.visitTimestampMillisecond=gn;ot.prototype.visitTimestampMicrosecond=gn;ot.prototype.visitTimestampNanosecond=gn;ot.prototype.visitTime=mn;ot.prototype.visitTimeSecond=mn;ot.prototype.visitTimeMillisecond=mn;ot.prototype.visitTimeMicrosecond=mn;ot.prototype.visitTimeNanosecond=mn;ot.prototype.visitDecimal=ir;ot.prototype.visitList=md;ot.prototype.visitStruct=wd;ot.prototype.visitUnion=Rs;ot.prototype.visitDenseUnion=Rs;ot.prototype.visitSparseUnion=Rs;ot.prototype.visitDictionary=bd;ot.prototype.visitInterval=Ps;ot.prototype.visitIntervalDayTime=Ps;ot.prototype.visitIntervalYearMonth=Ps;ot.prototype.visitDuration=wn;ot.prototype.visitDurationSecond=wn;ot.prototype.visitDurationMillisecond=wn;ot.prototype.visitDurationMicrosecond=wn;ot.prototype.visitDurationNanosecond=wn;ot.prototype.visitFixedSizeList=_d;ot.prototype.visitMap=Sd;const He=new ot;function Id(r,t){return He.compareSchemas(r,t)}function Ci(r,t){return Bd(r,t.map(e=>e.data.concat()))}function Bd(r,t){const e=[...r.fields],n=[],s={numBatches:t.reduce((B,L)=>Math.max(B,L.length),0)};let i=0,a=0,c=-1;const d=t.length;let f,y=[];for(;s.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,c=-1;++c<d;)y[c]=f=t[c].shift(),a=Math.min(a,f?f.length:a);Number.isFinite(a)&&(y=vd(e,a,y,t,s),a>0&&(n[i++]=_t({type:new Kt(e),length:a,nullCount:0,children:y.slice()})))}return[r=r.assign(e),n.map(B=>new ye(r,B))]}function vd(r,t,e,n,s){var i;const a=(t+63&-64)>>3;for(let c=-1,d=n.length;++c<d;){const f=e[c],y=f?.length;if(y>=t)y===t?e[c]=f:(e[c]=f.slice(0,t),s.numBatches=Math.max(s.numBatches,n[c].unshift(f.slice(t,y-t))));else{const B=r[c];r[c]=B.clone({nullable:!0}),e[c]=(i=f?._changeLengthAndBackfillNullBitmap(t))!==null&&i!==void 0?i:_t({type:B.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return e}var au;class le{constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new vt([]),this._offsets=[0],this;let s,i;t[0]instanceof vt&&(s=t.shift()),t.at(-1)instanceof Uint32Array&&(i=t.pop());const a=d=>{if(d){if(d instanceof ye)return[d];if(d instanceof le)return d.batches;if(d instanceof Et){if(d.type instanceof Kt)return[new ye(new vt(d.type.children),d)]}else{if(Array.isArray(d))return d.flatMap(f=>a(f));if(typeof d[Symbol.iterator]=="function")return[...d].flatMap(f=>a(f));if(typeof d=="object"){const f=Object.keys(d),y=f.map(x=>new Ft([d[x]])),B=s??new vt(f.map((x,M)=>new Ct(String(x),y[M].type,y[M].nullable))),[,L]=Ci(B,y);return L.length===0?[new ye(d)]:L}}}return[]},c=t.flatMap(d=>a(d));if(s=(n=s??((e=c[0])===null||e===void 0?void 0:e.schema))!==null&&n!==void 0?n:new vt([]),!(s instanceof vt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const d of c){if(!(d instanceof ye))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Id(s,d.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=s,this.batches=c,this._offsets=i??qc(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=Hc(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(Ns(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?Ds.visit(new Ft(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
2
2
  ${this.toArray().join(`,
3
3
  `)}
4
- ]`}concat(...t){const e=this.schema,n=this.data.concat(t.flatMap(({data:o})=>o));return new he(e,n.map(o=>new pe(e,o)))}slice(t,e){const n=this.schema;[t,e]=Bc({length:this.numRows},t,e);const o=Ec(this.data,this._offsets,t,e);return new he(n,o.map(i=>new pe(n,i)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){const e=this.data.map(n=>n.children[t]);if(e.length===0){const{type:n}=this.schema.fields[t],o=_t({type:n,length:0,nullCount:0});e.push(o._changeLengthAndBackfillNullBitmap(this.numRows))}return new Ft(e)}return null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(o=>o.name===t),e)}setChildAt(t,e){let n=this.schema,o=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new Ft([_t({type:new Ye,length:this.numRows})]));const i=n.fields.slice(),a=i[t].clone({type:e.type}),c=this.schema.fields.map((f,p)=>this.getChildAt(p));[i[t],c[t]]=[a,e],[n,o]=xi(n,c)}return new he(n,o)}select(t){const e=this.schema.fields.reduce((n,o,i)=>n.set(o.name,i),new Map);return this.selectAt(t.map(n=>e.get(n)).filter(n=>n>-1))}selectAt(t){const e=this.schema.selectAt(t),n=this.batches.map(o=>o.selectAt(t));return new he(e,n)}assign(t){const e=this.schema.fields,[n,o]=t.schema.fields.reduce((c,f,p)=>{const[g,v]=c,C=e.findIndex(F=>F.name===f.name);return~C?v[C]=p:g.push(p),c},[[],[]]),i=this.schema.assign(t.schema),a=[...e.map((c,f)=>[f,o[f]]).map(([c,f])=>f===void 0?this.getChildAt(c):t.getChildAt(f)),...n.map(c=>t.getChildAt(c))].filter(Boolean);return new he(...xi(i,a))}}Rc=Symbol.toStringTag;he[Rc]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=Xn(ws),r.get=Xn(ne.getVisitFn(x.Struct)),r.set=Tc(fe.getVisitFn(x.Struct)),r.indexOf=Oc(Qn.getVisitFn(x.Struct)),"Table"))(he.prototype);var Cc;let pe=class rn{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof vt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=_t({nullCount:0,type:new Kt(this.schema.fields),children:this.schema.fields.map(e=>_t({type:e.type,nullCount:0}))})]=t,!(this.data instanceof Et))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=ho(this.schema,this.data.children);break}case 1:{const[e]=t,{fields:n,children:o,length:i}=Object.keys(e).reduce((f,p,g)=>(f.children[g]=e[p],f.length=Math.max(f.length,e[p].length),f.fields[g]=Rt.new({name:p,type:e[p].type,nullable:!0}),f),{length:0,fields:new Array,children:new Array}),a=new vt(n),c=_t({type:new Kt(n),length:i,children:o,nullCount:0});[this.schema,this.data]=ho(a,c.children,i);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=Pc(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 ne.visit(this.data,t)}at(t){return this.get(ys(t,this.numRows))}set(t,e){return fe.visit(this.data,t,e)}indexOf(t,e){return Qn.visit(this.data,t,e)}[Symbol.iterator](){return bs.visit(new Ft([this.data]))}toArray(){return[...this]}concat(...t){return new he(this.schema,[this,...t])}slice(t,e){const[n]=new Ft([this.data]).slice(t,e).data;return new rn(this.schema,n)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new Ft([this.data.children[t]]):null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(o=>o.name===t),e)}setChildAt(t,e){let n=this.schema,o=this.data;if(t>-1&&t<this.numCols){e||(e=new Ft([_t({type:new Ye,length:this.numRows})]));const i=n.fields.slice(),a=o.children.slice(),c=i[t].clone({type:e.type});[i[t],a[t]]=[c,e.data[0]],n=new vt(i,new Map(this.schema.metadata)),o=_t({type:new Kt(i),children:a})}return new rn(n,o)}select(t){const e=this.schema.select(t),n=new Kt(e.fields),o=[];for(const i of t){const a=this.schema.fields.findIndex(c=>c.name===i);~a&&(o[a]=this.data.children[a])}return new rn(e,_t({type:n,length:this.numRows,children:o}))}selectAt(t){const e=this.schema.selectAt(t),n=t.map(i=>this.data.children[i]).filter(Boolean),o=_t({type:new Kt(e.fields),length:this.numRows,children:n});return new rn(e,o)}};Cc=Symbol.toStringTag;pe[Cc]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(pe.prototype);function ho(r,t,e=t.reduce((n,o)=>Math.max(n,o.length),0)){var n;const o=[...r.fields],i=[...t],a=(e+63&-64)>>3;for(const[c,f]of r.fields.entries()){const p=t[c];(!p||p.length!==e)&&(o[c]=f.clone({nullable:!0}),i[c]=(n=p?._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:_t({type:f.type,length:e,nullCount:e,nullBitmap:new Uint8Array(a)}))}return[r.assign(o),_t({type:new Kt(o),length:e,children:i})]}function Pc(r,t,e=new Map){var n,o;if(((n=r?.length)!==null&&n!==void 0?n:0)>0&&r?.length===t?.length)for(let i=-1,a=r.length;++i<a;){const{type:c}=r[i],f=t[i];for(const p of[f,...((o=f?.dictionary)===null||o===void 0?void 0:o.data)||[]])Pc(c.children,p?.children,e);if(tt.isDictionary(c)){const{id:p}=c;if(!e.has(p))f?.dictionary&&e.set(p,f.dictionary);else if(e.get(p)!==f.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}class $c extends pe{constructor(t){const e=t.fields.map(o=>_t({type:o.type})),n=_t({type:new Kt(t.fields),nullCount:0,children:e});super(t,n)}}let ze=class be{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 be).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+At),(e||new be).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):zt.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):Bt.NONE}header(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,12);return n?(e||new jt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){const 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,zt.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,Bt.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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,n,o,i,a){return be.startMessage(t),be.addVersion(t,e),be.addHeaderType(t,n),be.addHeader(t,o),be.addBodyLength(t,i),be.addCustomMetadata(t,a),be.endMessage(t)}};class Kl extends St{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return to.startNull(e),to.endNull(e)}visitInt(t,e){return se.startInt(e),se.addBitWidth(e,t.bitWidth),se.addIsSigned(e,t.isSigned),se.endInt(e)}visitFloat(t,e){return Be.startFloatingPoint(e),Be.addPrecision(e,t.precision),Be.endFloatingPoint(e)}visitBinary(t,e){return Hs.startBinary(e),Hs.endBinary(e)}visitLargeBinary(t,e){return Ks.startLargeBinary(e),Ks.endLargeBinary(e)}visitBool(t,e){return qs.startBool(e),qs.endBool(e)}visitUtf8(t,e){return eo.startUtf8(e),eo.endUtf8(e)}visitLargeUtf8(t,e){return Xs.startLargeUtf8(e),Xs.endLargeUtf8(e)}visitDecimal(t,e){return cr.startDecimal(e),cr.addScale(e,t.scale),cr.addPrecision(e,t.precision),cr.addBitWidth(e,t.bitWidth),cr.endDecimal(e)}visitDate(t,e){return In.startDate(e),In.addUnit(e,t.unit),In.endDate(e)}visitTime(t,e){return ce.startTime(e),ce.addUnit(e,t.unit),ce.addBitWidth(e,t.bitWidth),ce.endTime(e)}visitTimestamp(t,e){const n=t.timezone&&e.createString(t.timezone)||void 0;return ue.startTimestamp(e),ue.addUnit(e,t.unit),n!==void 0&&ue.addTimezone(e,n),ue.endTimestamp(e)}visitInterval(t,e){return ve.startInterval(e),ve.addUnit(e,t.unit),ve.endInterval(e)}visitDuration(t,e){return Bn.startDuration(e),Bn.addUnit(e,t.unit),Bn.endDuration(e)}visitList(t,e){return Qs.startList(e),Qs.endList(e)}visitStruct(t,e){return Xe.startStruct_(e),Xe.endStruct_(e)}visitUnion(t,e){ee.startTypeIdsVector(e,t.typeIds.length);const n=ee.createTypeIdsVector(e,t.typeIds);return ee.startUnion(e),ee.addMode(e,t.mode),ee.addTypeIds(e,n),ee.endUnion(e)}visitDictionary(t,e){const n=this.visit(t.indices,e);return ke.startDictionaryEncoding(e),ke.addId(e,BigInt(t.id)),ke.addIsOrdered(e,t.isOrdered),n!==void 0&&ke.addIndexType(e,n),ke.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return vn.startFixedSizeBinary(e),vn.addByteWidth(e,t.byteWidth),vn.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return An.startFixedSizeList(e),An.addListSize(e,t.listSize),An.endFixedSizeList(e)}visitMap(t,e){return xn.startMap(e),xn.addKeysSorted(e,t.keysSorted),xn.endMap(e)}}const Ei=new Kl;function Xl(r,t=new Map){return new vt(tf(r,t),Tn(r.metadata),t)}function zc(r){return new me(r.count,jc(r.columns),Vc(r.columns))}function Ql(r){return new Le(zc(r.data),r.id,r.isDelta)}function tf(r,t){return(r.fields||[]).filter(Boolean).map(e=>Rt.fromJSON(e,t))}function lo(r,t){return(r.children||[]).filter(Boolean).map(e=>Rt.fromJSON(e,t))}function jc(r){return(r||[]).reduce((t,e)=>[...t,new Nr(e.count,ef(e.VALIDITY)),...jc(e.children)],[])}function Vc(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){const o=r[e];o.VALIDITY&&t.push(new De(t.length,o.VALIDITY.length)),o.TYPE_ID&&t.push(new De(t.length,o.TYPE_ID.length)),o.OFFSET&&t.push(new De(t.length,o.OFFSET.length)),o.DATA&&t.push(new De(t.length,o.DATA.length)),t=Vc(o.children,t)}return t}function ef(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function rf(r,t){let e,n,o,i,a,c;return!t||!(i=r.dictionary)?(a=po(r,lo(r,t)),o=new Rt(r.name,a,r.nullable,Tn(r.metadata))):t.has(e=i.id)?(n=(n=i.indexType)?fo(n):new un,c=new xr(t.get(e),n,e,i.isOrdered),o=new Rt(r.name,c,r.nullable,Tn(r.metadata))):(n=(n=i.indexType)?fo(n):new un,t.set(e,a=po(r,lo(r,t))),c=new xr(a,n,e,i.isOrdered),o=new Rt(r.name,c,r.nullable,Tn(r.metadata))),o||null}function Tn(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function fo(r){return new tr(r.isSigned,r.bitWidth)}function po(r,t){const e=r.type.name;switch(e){case"NONE":return new Ye;case"null":return new Ye;case"binary":return new Ln;case"largebinary":return new Rn;case"utf8":return new Cn;case"largeutf8":return new Pn;case"bool":return new $n;case"list":return new Yn((t||[])[0]);case"struct":return new Kt(t||[]);case"struct_":return new Kt(t||[])}switch(e){case"int":{const n=r.type;return new tr(n.isSigned,n.bitWidth)}case"floatingpoint":{const n=r.type;return new Un(Jt[n.precision])}case"decimal":{const n=r.type;return new zn(n.scale,n.precision,n.bitWidth)}case"date":{const n=r.type;return new jn(le[n.unit])}case"time":{const n=r.type;return new Vn(at[n.unit],n.bitWidth)}case"timestamp":{const n=r.type;return new Wn(at[n.unit],n.timezone)}case"interval":{const n=r.type;return new Zn(Ee[n.unit])}case"duration":{const n=r.type;return new Gn(at[n.unit])}case"union":{const n=r.type,[o,...i]=(n.mode+"").toLowerCase(),a=o.toUpperCase()+i.join("");return new Jn(re[a],n.typeIds||[],t||[])}case"fixedsizebinary":{const n=r.type;return new Hn(n.byteWidth)}case"fixedsizelist":{const n=r.type;return new qn(n.listSize,(t||[])[0])}case"map":{const n=r.type;return new Kn((t||[])[0],n.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var nf=na,sf=vr;class ye{static fromJSON(t,e){const n=new ye(0,zt.V5,e);return n._createHeader=of(t,e),n}static decode(t){t=new sf(It(t));const e=ze.getRootAsMessage(t),n=e.bodyLength(),o=e.version(),i=e.headerType(),a=new ye(n,o,i);return a._createHeader=af(e,i),a}static encode(t){const e=new nf;let n=-1;return t.isSchema()?n=vt.encode(e,t.header()):t.isRecordBatch()?n=me.encode(e,t.header()):t.isDictionaryBatch()&&(n=Le.encode(e,t.header())),ze.startMessage(e),ze.addVersion(e,zt.V5),ze.addHeader(e,n),ze.addHeaderType(e,t.headerType),ze.addBodyLength(e,BigInt(t.bodyLength)),ze.finishMessageBuffer(e,ze.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof vt)return new ye(0,zt.V5,Bt.Schema,t);if(t instanceof me)return new ye(e,zt.V5,Bt.RecordBatch,t);if(t instanceof Le)return new ye(e,zt.V5,Bt.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===Bt.Schema}isRecordBatch(){return this.headerType===Bt.RecordBatch}isDictionaryBatch(){return this.headerType===Bt.DictionaryBatch}constructor(t,e,n,o){this._version=e,this._headerType=n,this.body=new Uint8Array(0),o&&(this._createHeader=()=>o),this._bodyLength=Lt(t)}}class me{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,n){this._nodes=e,this._buffers=n,this._length=Lt(t)}}class Le{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,n=!1){this._data=t,this._isDelta=n,this._id=Lt(e)}}class De{constructor(t,e){this.offset=Lt(t),this.length=Lt(e)}}class Nr{constructor(t,e){this.length=Lt(t),this.nullCount=Lt(e)}}function of(r,t){return()=>{switch(t){case Bt.Schema:return vt.fromJSON(r);case Bt.RecordBatch:return me.fromJSON(r);case Bt.DictionaryBatch:return Le.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${Bt[t]}, type: ${t} }`)}}function af(r,t){return()=>{switch(t){case Bt.Schema:return vt.decode(r.header(new _e),new Map,r.version());case Bt.RecordBatch:return me.decode(r.header(new Oe),r.version());case Bt.DictionaryBatch:return Le.decode(r.header(new or),r.version())}throw new Error(`Unrecognized Message type: { name: ${Bt[t]}, type: ${t} }`)}}Rt.encode=wf;Rt.decode=gf;Rt.fromJSON=rf;vt.encode=mf;vt.decode=cf;vt.fromJSON=Xl;me.encode=bf;me.decode=uf;me.fromJSON=zc;Le.encode=_f;Le.decode=hf;Le.fromJSON=Ql;Nr.encode=Sf;Nr.decode=ff;De.encode=If;De.decode=lf;function cf(r,t=new Map,e=zt.V5){const n=yf(r,t);return new vt(n,On(r),t,e)}function uf(r,t=zt.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new me(r.length(),df(r),pf(r,t))}function hf(r,t=zt.V5){return new Le(me.decode(r.data(),t),r.id(),r.isDelta())}function lf(r){return new De(r.offset(),r.length())}function ff(r){return new Nr(r.length(),r.nullCount())}function df(r){const t=[];for(let e,n=-1,o=-1,i=r.nodesLength();++n<i;)(e=r.nodes(n))&&(t[++o]=Nr.decode(e));return t}function pf(r,t){const e=[];for(let n,o=-1,i=-1,a=r.buffersLength();++o<a;)(n=r.buffers(o))&&(t<zt.V4&&(n.bb_pos+=8*(o+1)),e[++i]=De.decode(n));return e}function yf(r,t){const e=[];for(let n,o=-1,i=-1,a=r.fieldsLength();++o<a;)(n=r.fields(o))&&(e[++i]=Rt.decode(n,t));return e}function yo(r,t){const e=[];for(let n,o=-1,i=-1,a=r.childrenLength();++o<a;)(n=r.children(o))&&(e[++i]=Rt.decode(n,t));return e}function gf(r,t){let e,n,o,i,a,c;return!t||!(c=r.dictionary())?(o=mo(r,yo(r,t)),n=new Rt(r.name(),o,r.nullable(),On(r))):t.has(e=Lt(c.id()))?(i=(i=c.indexType())?go(i):new un,a=new xr(t.get(e),i,e,c.isOrdered()),n=new Rt(r.name(),a,r.nullable(),On(r))):(i=(i=c.indexType())?go(i):new un,t.set(e,o=mo(r,yo(r,t))),a=new xr(o,i,e,c.isOrdered()),n=new Rt(r.name(),a,r.nullable(),On(r))),n||null}function On(r){const t=new Map;if(r)for(let e,n,o=-1,i=Math.trunc(r.customMetadataLength());++o<i;)(e=r.customMetadata(o))&&(n=e.key())!=null&&t.set(n,e.value());return t}function go(r){return new tr(r.isSigned(),r.bitWidth())}function mo(r,t){const e=r.typeType();switch(e){case Dt.NONE:return new Ye;case Dt.Null:return new Ye;case Dt.Binary:return new Ln;case Dt.LargeBinary:return new Rn;case Dt.Utf8:return new Cn;case Dt.LargeUtf8:return new Pn;case Dt.Bool:return new $n;case Dt.List:return new Yn((t||[])[0]);case Dt.Struct_:return new Kt(t||[])}switch(e){case Dt.Int:{const n=r.type(new se);return new tr(n.isSigned(),n.bitWidth())}case Dt.FloatingPoint:{const n=r.type(new Be);return new Un(n.precision())}case Dt.Decimal:{const n=r.type(new cr);return new zn(n.scale(),n.precision(),n.bitWidth())}case Dt.Date:{const n=r.type(new In);return new jn(n.unit())}case Dt.Time:{const n=r.type(new ce);return new Vn(n.unit(),n.bitWidth())}case Dt.Timestamp:{const n=r.type(new ue);return new Wn(n.unit(),n.timezone())}case Dt.Interval:{const n=r.type(new ve);return new Zn(n.unit())}case Dt.Duration:{const n=r.type(new Bn);return new Gn(n.unit())}case Dt.Union:{const n=r.type(new ee);return new Jn(n.mode(),n.typeIdsArray()||[],t||[])}case Dt.FixedSizeBinary:{const n=r.type(new vn);return new Hn(n.byteWidth())}case Dt.FixedSizeList:{const n=r.type(new An);return new qn(n.listSize(),(t||[])[0])}case Dt.Map:{const n=r.type(new xn);return new Kn((t||[])[0],n.keysSorted())}}throw new Error(`Unrecognized type: "${Dt[e]}" (${e})`)}function mf(r,t){const e=t.fields.map(i=>Rt.encode(r,i));_e.startFieldsVector(r,e.length);const n=_e.createFieldsVector(r,e),o=t.metadata&&t.metadata.size>0?_e.createCustomMetadataVector(r,[...t.metadata].map(([i,a])=>{const c=r.createString(`${i}`),f=r.createString(`${a}`);return jt.startKeyValue(r),jt.addKey(r,c),jt.addValue(r,f),jt.endKeyValue(r)})):-1;return _e.startSchema(r),_e.addFields(r,n),_e.addEndianness(r,Bf?Ar.Little:Ar.Big),o!==-1&&_e.addCustomMetadata(r,o),_e.endSchema(r)}function wf(r,t){let e=-1,n=-1,o=-1;const i=t.type;let a=t.typeId;tt.isDictionary(i)?(a=i.dictionary.typeId,o=Ei.visit(i,r),n=Ei.visit(i.dictionary,r)):n=Ei.visit(i,r);const c=(i.children||[]).map(g=>Rt.encode(r,g)),f=oe.createChildrenVector(r,c),p=t.metadata&&t.metadata.size>0?oe.createCustomMetadataVector(r,[...t.metadata].map(([g,v])=>{const C=r.createString(`${g}`),F=r.createString(`${v}`);return jt.startKeyValue(r),jt.addKey(r,C),jt.addValue(r,F),jt.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),oe.startField(r),oe.addType(r,n),oe.addTypeType(r,a),oe.addChildren(r,f),oe.addNullable(r,!!t.nullable),e!==-1&&oe.addName(r,e),o!==-1&&oe.addDictionary(r,o),p!==-1&&oe.addCustomMetadata(r,p),oe.endField(r)}function bf(r,t){const e=t.nodes||[],n=t.buffers||[];Oe.startNodesVector(r,e.length);for(const a of e.slice().reverse())Nr.encode(r,a);const o=r.endVector();Oe.startBuffersVector(r,n.length);for(const a of n.slice().reverse())De.encode(r,a);const i=r.endVector();return Oe.startRecordBatch(r),Oe.addLength(r,BigInt(t.length)),Oe.addNodes(r,o),Oe.addBuffers(r,i),Oe.endRecordBatch(r)}function _f(r,t){const e=me.encode(r,t.data);return or.startDictionaryBatch(r),or.addId(r,BigInt(t.id)),or.addIsDelta(r,t.isDelta),or.addData(r,e),or.endDictionaryBatch(r)}function Sf(r,t){return oa.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function If(r,t){return sa.createBuffer(r,BigInt(t.offset),BigInt(t.length))}const Bf=(()=>{const r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})(),As=r=>`Expected ${Bt[r]} Message in stream, but was null or length 0.`,xs=r=>`Header pointer of flatbuffer-encoded ${Bt[r]} Message is null or length 0.`,Wc=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,Zc=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`;class Gc{constructor(t){this.source=t instanceof ei?t:new ei(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done||t.value===-1&&(t=this.readMetadataLength()).done||(t=this.readMetadata(t.value)).done?Ct: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(As(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const e=It(this.source.read(t));if(e.byteLength<t)throw new Error(Zc(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){const e=Bt.Schema,n=this.readMessage(e),o=n?.header();if(t&&!o)throw new Error(xs(e));return o}readMetadataLength(){const t=this.source.read(mi),e=t&&new vr(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}}readMetadata(t){const e=this.source.read(t);if(!e)return Ct;if(e.byteLength<t)throw new Error(Wc(t,e.byteLength));return{done:!1,value:ye.decode(e)}}}class vf{constructor(t,e){this.source=t instanceof Tr?t:Ko(t)?new ri(t,e):new Tr(t)}[Symbol.asyncIterator](){return this}next(){return gt(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done||t.value===-1&&(t=yield this.readMetadataLength()).done||(t=yield this.readMetadata(t.value)).done?Ct:t})}throw(t){return gt(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return gt(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return gt(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(As(t));return e.value})}readMessageBody(t){return gt(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);const e=It(yield this.source.read(t));if(e.byteLength<t)throw new Error(Zc(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return gt(this,arguments,void 0,function*(t=!1){const e=Bt.Schema,n=yield this.readMessage(e),o=n?.header();if(t&&!o)throw new Error(xs(e));return o})}readMetadataLength(){return gt(this,void 0,void 0,function*(){const t=yield this.source.read(mi),e=t&&new vr(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}})}readMetadata(t){return gt(this,void 0,void 0,function*(){const e=yield this.source.read(t);if(!e)return Ct;if(e.byteLength<t)throw new Error(Wc(t,e.byteLength));return{done:!1,value:ye.decode(e)}})}}class Af extends Gc{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof co?t:new co(t)}next(){const{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:ye.fromJSON(t.schema,Bt.Schema)};if(this._dictionaryIndex<t.dictionaries.length){const e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:ye.fromJSON(e,Bt.DictionaryBatch)}}if(this._batchIndex<t.batches.length){const e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:ye.fromJSON(e,Bt.RecordBatch)}}return this._body=[],Ct}readMessageBody(t){return e(this._body);function e(n){return(n||[]).reduce((o,i)=>[...o,...i.VALIDITY&&[i.VALIDITY]||[],...i.TYPE_ID&&[i.TYPE_ID]||[],...i.OFFSET&&[i.OFFSET]||[],...i.DATA&&[i.DATA]||[],...e(i.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(As(t));return e.value}readSchema(){const t=Bt.Schema,e=this.readMessage(t),n=e?.header();if(!e||!n)throw new Error(xs(t));return n}}const mi=4,Ji="ARROW1",ni=new Uint8Array(Ji.length);for(let r=0;r<Ji.length;r+=1)ni[r]=Ji.codePointAt(r);function Es(r,t=0){for(let e=-1,n=ni.length;++e<n;)if(ni[e]!==r[t+e])return!1;return!0}const pn=ni.length,Yc=pn+mi,xf=pn*2+mi;class Ue extends Dc{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){const e=this._impl.open(t);return sn(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 ae.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return ae.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 Ue?t:Ci(t)?Mf(t):Ko(t)?kf(t):sn(t)?gt(this,void 0,void 0,function*(){return yield Ue.from(yield t)}):Xo(t)||us(t)||ta(t)||cs(t)?Nf(new Tr(t)):Ff(new ei(t))}static readAll(t){return t instanceof Ue?t.isSync()?wo(t):bo(t):Ci(t)||ArrayBuffer.isView(t)||pi(t)||qo(t)?wo(t):bo(t)}}class ii extends Ue{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Ae(this,arguments,function*(){yield wt(yield*Sn(wr(this[Symbol.iterator]())))})}}class si extends Ue{constructor(t){super(t),this._impl=t}readAll(){return gt(this,void 0,void 0,function*(){var t,e,n,o;const i=new Array;try{for(var a=!0,c=wr(this),f;f=yield c.next(),t=f.done,!t;a=!0){o=f.value,a=!1;const p=o;i.push(p)}}catch(p){e={error:p}}finally{try{!a&&!t&&(n=c.return)&&(yield n.call(c))}finally{if(e)throw e.error}}return i})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class Jc extends ii{constructor(t){super(t),this._impl=t}}class Ef extends si{constructor(t){super(t),this._impl=t}}class Hc{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){const n=this._loadVectors(t,e,this.schema.fields),o=_t({type:new Kt(this.schema.fields),length:t.length,children:n});return new pe(this.schema,o)}_loadDictionaryBatch(t,e){const{id:n,isDelta:o}=t,{dictionaries:i,schema:a}=this,c=i.get(n),f=a.dictionaries.get(n),p=this._loadVectors(t.data,e,[f]);return(c&&o?c.concat(new Ft(p)):new Ft(p)).memoize()}_loadVectors(t,e,n){return new Lc(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}}class oi extends Hc{constructor(t,e){super(e),this._reader=Ci(t)?new Af(this._handle=t):new Gc(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=Kc(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):Ct}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Ct}next(){if(this.closed)return Ct;let t;const{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const n=t.header(),o=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,o)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const n=t.header(),o=e.readMessageBody(t.bodyLength),i=this._loadDictionaryBatch(n,o);this.dictionaries.set(n.id,i)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new $c(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class ai extends Hc{constructor(t,e){super(e),this._reader=new vf(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return gt(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 gt(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Kc(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return gt(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):Ct})}return(t){return gt(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Ct})}next(){return gt(this,void 0,void 0,function*(){if(this.closed)return Ct;let t;const{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const n=t.header(),o=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,o)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const n=t.header(),o=yield e.readMessageBody(t.bodyLength),i=this._loadDictionaryBatch(n,o);this.dictionaries.set(n.id,i)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new $c(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return gt(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class qc extends oi{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 uo?t:new uo(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const 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();const n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){const o=this._reader.readMessage(Bt.RecordBatch);if(o?.isRecordBatch()){const i=o.header(),a=this._reader.readMessageBody(o.bodyLength);return this._loadRecordBatch(i,a)}}return null}_readDictionaryBatch(t){var e;const n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){const o=this._reader.readMessage(Bt.DictionaryBatch);if(o?.isDictionaryBatch()){const i=o.header(),a=this._reader.readMessageBody(o.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}}}_readFooter(){const{_handle:t}=this,e=t.size-Yc,n=t.readInt32(e),o=t.readAt(e-n,n);return _s.decode(o)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){const n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(n&&this._handle.seek(n.offset))return this._reader.readMessage(t)}return null}}class Tf extends ai{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){const n=typeof e[0]!="number"?e.shift():void 0,o=e[0]instanceof Map?e.shift():void 0;super(t instanceof ri?t:new ri(t,n),o)}isFile(){return!0}isAsync(){return!0}open(t){const e=Object.create(null,{open:{get:()=>super.open}});return gt(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return gt(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());const n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){const o=yield this._reader.readMessage(Bt.RecordBatch);if(o?.isRecordBatch()){const i=o.header(),a=yield this._reader.readMessageBody(o.bodyLength);return this._loadRecordBatch(i,a)}}return null})}_readDictionaryBatch(t){return gt(this,void 0,void 0,function*(){var e;const n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){const o=yield this._reader.readMessage(Bt.DictionaryBatch);if(o?.isDictionaryBatch()){const i=o.header(),a=yield this._reader.readMessageBody(o.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}}})}_readFooter(){return gt(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const e=t.size-Yc,n=yield t.readInt32(e),o=yield t.readAt(e-n,n);return _s.decode(o)})}_readNextMessageAndValidate(t){return gt(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){const e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}}class Of extends oi{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new $l(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}}function Kc(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*wo(r){const t=Ue.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function bo(r){return Ae(this,arguments,function*(){const e=yield wt(Ue.from(r));try{if(!(yield wt(e.open({autoDestroy:!1}))).closed)do yield yield wt(e);while(!(yield wt(e.reset().open())).closed)}finally{yield wt(e.cancel())}})}function Mf(r){return new ii(new Of(r))}function Ff(r){const t=r.peek(pn+7&-8);return t&&t.byteLength>=4?Es(t)?new Jc(new qc(r.read())):new ii(new oi(r)):new ii(new oi(function*(){}()))}function Nf(r){return gt(this,void 0,void 0,function*(){const t=yield r.peek(pn+7&-8);return t&&t.byteLength>=4?Es(t)?new Jc(new qc(yield r.read())):new si(new ai(r)):new si(new ai(function(){return Ae(this,arguments,function*(){})}()))})}function kf(r){return gt(this,void 0,void 0,function*(){const{size:t}=yield r.stat(),e=new ri(r,t);return t>=xf&&Es(yield e.readAt(0,pn+7&-8))?new Ef(new Tf(e)):new si(new ai(e))})}function Xc(r){const t=Ue.from(r);return sn(t)?t.then(e=>Xc(e)):t.isAsync()?t.readAll().then(e=>new he(e)):new he(t.readAll())}function Ts(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ti={},Dr={},Oi={},Ur={},_o;function Qc(){if(_o)return Ur;_o=1,Ur.byteLength=c,Ur.toByteArray=p,Ur.fromByteArray=C;for(var r=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o<i;++o)r[o]=n[o],t[n.charCodeAt(o)]=o;t[45]=62,t[95]=63;function a(F){var T=F.length;if(T%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var U=F.indexOf("=");U===-1&&(U=T);var M=U===T?0:4-U%4;return[U,M]}function c(F){var T=a(F),U=T[0],M=T[1];return(U+M)*3/4-M}function f(F,T,U){return(T+U)*3/4-U}function p(F){var T,U=a(F),M=U[0],k=U[1],P=new e(f(F,M,k)),R=0,V=k>0?M-4:M,G;for(G=0;G<V;G+=4)T=t[F.charCodeAt(G)]<<18|t[F.charCodeAt(G+1)]<<12|t[F.charCodeAt(G+2)]<<6|t[F.charCodeAt(G+3)],P[R++]=T>>16&255,P[R++]=T>>8&255,P[R++]=T&255;return k===2&&(T=t[F.charCodeAt(G)]<<2|t[F.charCodeAt(G+1)]>>4,P[R++]=T&255),k===1&&(T=t[F.charCodeAt(G)]<<10|t[F.charCodeAt(G+1)]<<4|t[F.charCodeAt(G+2)]>>2,P[R++]=T>>8&255,P[R++]=T&255),P}function g(F){return r[F>>18&63]+r[F>>12&63]+r[F>>6&63]+r[F&63]}function v(F,T,U){for(var M,k=[],P=T;P<U;P+=3)M=(F[P]<<16&16711680)+(F[P+1]<<8&65280)+(F[P+2]&255),k.push(g(M));return k.join("")}function C(F){for(var T,U=F.length,M=U%3,k=[],P=16383,R=0,V=U-M;R<V;R+=P)k.push(v(F,R,R+P>V?V:R+P));return M===1?(T=F[U-1],k.push(r[T>>2]+r[T<<4&63]+"==")):M===2&&(T=(F[U-2]<<8)+F[U-1],k.push(r[T>>10]+r[T>>4&63]+r[T<<2&63]+"=")),k.join("")}return Ur}var wn={};var So;function tu(){return So||(So=1,wn.read=function(r,t,e,n,o){var i,a,c=o*8-n-1,f=(1<<c)-1,p=f>>1,g=-7,v=e?o-1:0,C=e?-1:1,F=r[t+v];for(v+=C,i=F&(1<<-g)-1,F>>=-g,g+=c;g>0;i=i*256+r[t+v],v+=C,g-=8);for(a=i&(1<<-g)-1,i>>=-g,g+=n;g>0;a=a*256+r[t+v],v+=C,g-=8);if(i===0)i=1-p;else{if(i===f)return a?NaN:(F?-1:1)*(1/0);a=a+Math.pow(2,n),i=i-p}return(F?-1:1)*a*Math.pow(2,i-n)},wn.write=function(r,t,e,n,o,i){var a,c,f,p=i*8-o-1,g=(1<<p)-1,v=g>>1,C=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,F=n?0:i-1,T=n?1:-1,U=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,a=g):(a=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-a))<1&&(a--,f*=2),a+v>=1?t+=C/f:t+=C*Math.pow(2,1-v),t*f>=2&&(a++,f/=2),a+v>=g?(c=0,a=g):a+v>=1?(c=(t*f-1)*Math.pow(2,o),a=a+v):(c=t*Math.pow(2,v-1)*Math.pow(2,o),a=0));o>=8;r[e+F]=c&255,F+=T,c/=256,o-=8);for(a=a<<o|c,p+=o;p>0;r[e+F]=a&255,F+=T,a/=256,p-=8);r[e+F-T]|=U*128}),wn}var Io;function Os(){return Io||(Io=1,function(r){const t=Qc(),e=tu(),n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=c,r.SlowBuffer=P,r.INSPECT_MAX_BYTES=50;const o=2147483647;r.kMaxLength=o,c.TYPED_ARRAY_SUPPORT=i(),!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{const h=new Uint8Array(1),s={foo:function(){return 42}};return Object.setPrototypeOf(s,Uint8Array.prototype),Object.setPrototypeOf(h,s),h.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function a(h){if(h>o)throw new RangeError('The value "'+h+'" is invalid for option "size"');const s=new Uint8Array(h);return Object.setPrototypeOf(s,c.prototype),s}function c(h,s,u){if(typeof h=="number"){if(typeof s=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(h)}return f(h,s,u)}c.poolSize=8192;function f(h,s,u){if(typeof h=="string")return C(h,s);if(ArrayBuffer.isView(h))return T(h);if(h==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h);if(mt(h,ArrayBuffer)||h&&mt(h.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(mt(h,SharedArrayBuffer)||h&&mt(h.buffer,SharedArrayBuffer)))return U(h,s,u);if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const l=h.valueOf&&h.valueOf();if(l!=null&&l!==h)return c.from(l,s,u);const d=M(h);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof h[Symbol.toPrimitive]=="function")return c.from(h[Symbol.toPrimitive]("string"),s,u);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h)}c.from=function(h,s,u){return f(h,s,u)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array);function p(h){if(typeof h!="number")throw new TypeError('"size" argument must be of type number');if(h<0)throw new RangeError('The value "'+h+'" is invalid for option "size"')}function g(h,s,u){return p(h),h<=0?a(h):s!==void 0?typeof u=="string"?a(h).fill(s,u):a(h).fill(s):a(h)}c.alloc=function(h,s,u){return g(h,s,u)};function v(h){return p(h),a(h<0?0:k(h)|0)}c.allocUnsafe=function(h){return v(h)},c.allocUnsafeSlow=function(h){return v(h)};function C(h,s){if((typeof s!="string"||s==="")&&(s="utf8"),!c.isEncoding(s))throw new TypeError("Unknown encoding: "+s);const u=R(h,s)|0;let l=a(u);const d=l.write(h,s);return d!==u&&(l=l.slice(0,d)),l}function F(h){const s=h.length<0?0:k(h.length)|0,u=a(s);for(let l=0;l<s;l+=1)u[l]=h[l]&255;return u}function T(h){if(mt(h,Uint8Array)){const s=new Uint8Array(h);return U(s.buffer,s.byteOffset,s.byteLength)}return F(h)}function U(h,s,u){if(s<0||h.byteLength<s)throw new RangeError('"offset" is outside of buffer bounds');if(h.byteLength<s+(u||0))throw new RangeError('"length" is outside of buffer bounds');let l;return s===void 0&&u===void 0?l=new Uint8Array(h):u===void 0?l=new Uint8Array(h,s):l=new Uint8Array(h,s,u),Object.setPrototypeOf(l,c.prototype),l}function M(h){if(c.isBuffer(h)){const s=k(h.length)|0,u=a(s);return u.length===0||h.copy(u,0,0,s),u}if(h.length!==void 0)return typeof h.length!="number"||Qt(h.length)?a(0):F(h);if(h.type==="Buffer"&&Array.isArray(h.data))return F(h.data)}function k(h){if(h>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return h|0}function P(h){return+h!=h&&(h=0),c.alloc(+h)}c.isBuffer=function(s){return s!=null&&s._isBuffer===!0&&s!==c.prototype},c.compare=function(s,u){if(mt(s,Uint8Array)&&(s=c.from(s,s.offset,s.byteLength)),mt(u,Uint8Array)&&(u=c.from(u,u.offset,u.byteLength)),!c.isBuffer(s)||!c.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(s===u)return 0;let l=s.length,d=u.length;for(let b=0,I=Math.min(l,d);b<I;++b)if(s[b]!==u[b]){l=s[b],d=u[b];break}return l<d?-1:d<l?1:0},c.isEncoding=function(s){switch(String(s).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(s,u){if(!Array.isArray(s))throw new TypeError('"list" argument must be an Array of Buffers');if(s.length===0)return c.alloc(0);let l;if(u===void 0)for(u=0,l=0;l<s.length;++l)u+=s[l].length;const d=c.allocUnsafe(u);let b=0;for(l=0;l<s.length;++l){let I=s[l];if(mt(I,Uint8Array))b+I.length>d.length?(c.isBuffer(I)||(I=c.from(I)),I.copy(d,b)):Uint8Array.prototype.set.call(d,I,b);else if(c.isBuffer(I))I.copy(d,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=I.length}return d};function R(h,s){if(c.isBuffer(h))return h.length;if(ArrayBuffer.isView(h)||mt(h,ArrayBuffer))return h.byteLength;if(typeof h!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof h);const u=h.length,l=arguments.length>2&&arguments[2]===!0;if(!l&&u===0)return 0;let d=!1;for(;;)switch(s){case"ascii":case"latin1":case"binary":return u;case"utf8":case"utf-8":return kt(h).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u*2;case"hex":return u>>>1;case"base64":return $t(h).length;default:if(d)return l?-1:kt(h).length;s=(""+s).toLowerCase(),d=!0}}c.byteLength=R;function V(h,s,u){let l=!1;if((s===void 0||s<0)&&(s=0),s>this.length||((u===void 0||u>this.length)&&(u=this.length),u<=0)||(u>>>=0,s>>>=0,u<=s))return"";for(h||(h="utf8");;)switch(h){case"hex":return X(this,s,u);case"utf8":case"utf-8":return z(this,s,u);case"ascii":return Y(this,s,u);case"latin1":case"binary":return Z(this,s,u);case"base64":return Q(this,s,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return K(this,s,u);default:if(l)throw new TypeError("Unknown encoding: "+h);h=(h+"").toLowerCase(),l=!0}}c.prototype._isBuffer=!0;function G(h,s,u){const l=h[s];h[s]=h[u],h[u]=l}c.prototype.swap16=function(){const s=this.length;if(s%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let u=0;u<s;u+=2)G(this,u,u+1);return this},c.prototype.swap32=function(){const s=this.length;if(s%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let u=0;u<s;u+=4)G(this,u,u+3),G(this,u+1,u+2);return this},c.prototype.swap64=function(){const s=this.length;if(s%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let u=0;u<s;u+=8)G(this,u,u+7),G(this,u+1,u+6),G(this,u+2,u+5),G(this,u+3,u+4);return this},c.prototype.toString=function(){const s=this.length;return s===0?"":arguments.length===0?z(this,0,s):V.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(s){if(!c.isBuffer(s))throw new TypeError("Argument must be a Buffer");return this===s?!0:c.compare(this,s)===0},c.prototype.inspect=function(){let s="";const u=r.INSPECT_MAX_BYTES;return s=this.toString("hex",0,u).replace(/(.{2})/g,"$1 ").trim(),this.length>u&&(s+=" ... "),"<Buffer "+s+">"},n&&(c.prototype[n]=c.prototype.inspect),c.prototype.compare=function(s,u,l,d,b){if(mt(s,Uint8Array)&&(s=c.from(s,s.offset,s.byteLength)),!c.isBuffer(s))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof s);if(u===void 0&&(u=0),l===void 0&&(l=s?s.length:0),d===void 0&&(d=0),b===void 0&&(b=this.length),u<0||l>s.length||d<0||b>this.length)throw new RangeError("out of range index");if(d>=b&&u>=l)return 0;if(d>=b)return-1;if(u>=l)return 1;if(u>>>=0,l>>>=0,d>>>=0,b>>>=0,this===s)return 0;let I=b-d,H=l-u;const pt=Math.min(I,H),lt=this.slice(d,b),yt=s.slice(u,l);for(let et=0;et<pt;++et)if(lt[et]!==yt[et]){I=lt[et],H=yt[et];break}return I<H?-1:H<I?1:0};function A(h,s,u,l,d){if(h.length===0)return-1;if(typeof u=="string"?(l=u,u=0):u>2147483647?u=2147483647:u<-2147483648&&(u=-2147483648),u=+u,Qt(u)&&(u=d?0:h.length-1),u<0&&(u=h.length+u),u>=h.length){if(d)return-1;u=h.length-1}else if(u<0)if(d)u=0;else return-1;if(typeof s=="string"&&(s=c.from(s,l)),c.isBuffer(s))return s.length===0?-1:O(h,s,u,l,d);if(typeof s=="number")return s=s&255,typeof Uint8Array.prototype.indexOf=="function"?d?Uint8Array.prototype.indexOf.call(h,s,u):Uint8Array.prototype.lastIndexOf.call(h,s,u):O(h,[s],u,l,d);throw new TypeError("val must be string, number or Buffer")}function O(h,s,u,l,d){let b=1,I=h.length,H=s.length;if(l!==void 0&&(l=String(l).toLowerCase(),l==="ucs2"||l==="ucs-2"||l==="utf16le"||l==="utf-16le")){if(h.length<2||s.length<2)return-1;b=2,I/=2,H/=2,u/=2}function pt(yt,et){return b===1?yt[et]:yt.readUInt16BE(et*b)}let lt;if(d){let yt=-1;for(lt=u;lt<I;lt++)if(pt(h,lt)===pt(s,yt===-1?0:lt-yt)){if(yt===-1&&(yt=lt),lt-yt+1===H)return yt*b}else yt!==-1&&(lt-=lt-yt),yt=-1}else for(u+H>I&&(u=I-H),lt=u;lt>=0;lt--){let yt=!0;for(let et=0;et<H;et++)if(pt(h,lt+et)!==pt(s,et)){yt=!1;break}if(yt)return lt}return-1}c.prototype.includes=function(s,u,l){return this.indexOf(s,u,l)!==-1},c.prototype.indexOf=function(s,u,l){return A(this,s,u,l,!0)},c.prototype.lastIndexOf=function(s,u,l){return A(this,s,u,l,!1)};function m(h,s,u,l){u=Number(u)||0;const d=h.length-u;l?(l=Number(l),l>d&&(l=d)):l=d;const b=s.length;l>b/2&&(l=b/2);let I;for(I=0;I<l;++I){const H=parseInt(s.substr(I*2,2),16);if(Qt(H))return I;h[u+I]=H}return I}function S(h,s,u,l){return Mt(kt(s,h.length-u),h,u,l)}function w(h,s,u,l){return Mt(Ht(s),h,u,l)}function B(h,s,u,l){return Mt($t(s),h,u,l)}function N(h,s,u,l){return Mt(Vt(s,h.length-u),h,u,l)}c.prototype.write=function(s,u,l,d){if(u===void 0)d="utf8",l=this.length,u=0;else if(l===void 0&&typeof u=="string")d=u,l=this.length,u=0;else if(isFinite(u))u=u>>>0,isFinite(l)?(l=l>>>0,d===void 0&&(d="utf8")):(d=l,l=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const b=this.length-u;if((l===void 0||l>b)&&(l=b),s.length>0&&(l<0||u<0)||u>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");let I=!1;for(;;)switch(d){case"hex":return m(this,s,u,l);case"utf8":case"utf-8":return S(this,s,u,l);case"ascii":case"latin1":case"binary":return w(this,s,u,l);case"base64":return B(this,s,u,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,s,u,l);default:if(I)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),I=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Q(h,s,u){return s===0&&u===h.length?t.fromByteArray(h):t.fromByteArray(h.slice(s,u))}function z(h,s,u){u=Math.min(h.length,u);const l=[];let d=s;for(;d<u;){const b=h[d];let I=null,H=b>239?4:b>223?3:b>191?2:1;if(d+H<=u){let pt,lt,yt,et;switch(H){case 1:b<128&&(I=b);break;case 2:pt=h[d+1],(pt&192)===128&&(et=(b&31)<<6|pt&63,et>127&&(I=et));break;case 3:pt=h[d+1],lt=h[d+2],(pt&192)===128&&(lt&192)===128&&(et=(b&15)<<12|(pt&63)<<6|lt&63,et>2047&&(et<55296||et>57343)&&(I=et));break;case 4:pt=h[d+1],lt=h[d+2],yt=h[d+3],(pt&192)===128&&(lt&192)===128&&(yt&192)===128&&(et=(b&15)<<18|(pt&63)<<12|(lt&63)<<6|yt&63,et>65535&&et<1114112&&(I=et))}}I===null?(I=65533,H=1):I>65535&&(I-=65536,l.push(I>>>10&1023|55296),I=56320|I&1023),l.push(I),d+=H}return D(l)}const L=4096;function D(h){const s=h.length;if(s<=L)return String.fromCharCode.apply(String,h);let u="",l=0;for(;l<s;)u+=String.fromCharCode.apply(String,h.slice(l,l+=L));return u}function Y(h,s,u){let l="";u=Math.min(h.length,u);for(let d=s;d<u;++d)l+=String.fromCharCode(h[d]&127);return l}function Z(h,s,u){let l="";u=Math.min(h.length,u);for(let d=s;d<u;++d)l+=String.fromCharCode(h[d]);return l}function X(h,s,u){const l=h.length;(!s||s<0)&&(s=0),(!u||u<0||u>l)&&(u=l);let d="";for(let b=s;b<u;++b)d+=ir[h[b]];return d}function K(h,s,u){const l=h.slice(s,u);let d="";for(let b=0;b<l.length-1;b+=2)d+=String.fromCharCode(l[b]+l[b+1]*256);return d}c.prototype.slice=function(s,u){const l=this.length;s=~~s,u=u===void 0?l:~~u,s<0?(s+=l,s<0&&(s=0)):s>l&&(s=l),u<0?(u+=l,u<0&&(u=0)):u>l&&(u=l),u<s&&(u=s);const d=this.subarray(s,u);return Object.setPrototypeOf(d,c.prototype),d};function q(h,s,u){if(h%1!==0||h<0)throw new RangeError("offset is not uint");if(h+s>u)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(s,u,l){s=s>>>0,u=u>>>0,l||q(s,u,this.length);let d=this[s],b=1,I=0;for(;++I<u&&(b*=256);)d+=this[s+I]*b;return d},c.prototype.readUintBE=c.prototype.readUIntBE=function(s,u,l){s=s>>>0,u=u>>>0,l||q(s,u,this.length);let d=this[s+--u],b=1;for(;u>0&&(b*=256);)d+=this[s+--u]*b;return d},c.prototype.readUint8=c.prototype.readUInt8=function(s,u){return s=s>>>0,u||q(s,1,this.length),this[s]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(s,u){return s=s>>>0,u||q(s,2,this.length),this[s]|this[s+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(s,u){return s=s>>>0,u||q(s,2,this.length),this[s]<<8|this[s+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(s,u){return s=s>>>0,u||q(s,4,this.length),(this[s]|this[s+1]<<8|this[s+2]<<16)+this[s+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(s,u){return s=s>>>0,u||q(s,4,this.length),this[s]*16777216+(this[s+1]<<16|this[s+2]<<8|this[s+3])},c.prototype.readBigUInt64LE=Wt(function(s){s=s>>>0,$(s,"offset");const u=this[s],l=this[s+7];(u===void 0||l===void 0)&&J(s,this.length-8);const d=u+this[++s]*2**8+this[++s]*2**16+this[++s]*2**24,b=this[++s]+this[++s]*2**8+this[++s]*2**16+l*2**24;return BigInt(d)+(BigInt(b)<<BigInt(32))}),c.prototype.readBigUInt64BE=Wt(function(s){s=s>>>0,$(s,"offset");const u=this[s],l=this[s+7];(u===void 0||l===void 0)&&J(s,this.length-8);const d=u*2**24+this[++s]*2**16+this[++s]*2**8+this[++s],b=this[++s]*2**24+this[++s]*2**16+this[++s]*2**8+l;return(BigInt(d)<<BigInt(32))+BigInt(b)}),c.prototype.readIntLE=function(s,u,l){s=s>>>0,u=u>>>0,l||q(s,u,this.length);let d=this[s],b=1,I=0;for(;++I<u&&(b*=256);)d+=this[s+I]*b;return b*=128,d>=b&&(d-=Math.pow(2,8*u)),d},c.prototype.readIntBE=function(s,u,l){s=s>>>0,u=u>>>0,l||q(s,u,this.length);let d=u,b=1,I=this[s+--d];for(;d>0&&(b*=256);)I+=this[s+--d]*b;return b*=128,I>=b&&(I-=Math.pow(2,8*u)),I},c.prototype.readInt8=function(s,u){return s=s>>>0,u||q(s,1,this.length),this[s]&128?(255-this[s]+1)*-1:this[s]},c.prototype.readInt16LE=function(s,u){s=s>>>0,u||q(s,2,this.length);const l=this[s]|this[s+1]<<8;return l&32768?l|4294901760:l},c.prototype.readInt16BE=function(s,u){s=s>>>0,u||q(s,2,this.length);const l=this[s+1]|this[s]<<8;return l&32768?l|4294901760:l},c.prototype.readInt32LE=function(s,u){return s=s>>>0,u||q(s,4,this.length),this[s]|this[s+1]<<8|this[s+2]<<16|this[s+3]<<24},c.prototype.readInt32BE=function(s,u){return s=s>>>0,u||q(s,4,this.length),this[s]<<24|this[s+1]<<16|this[s+2]<<8|this[s+3]},c.prototype.readBigInt64LE=Wt(function(s){s=s>>>0,$(s,"offset");const u=this[s],l=this[s+7];(u===void 0||l===void 0)&&J(s,this.length-8);const d=this[s+4]+this[s+5]*2**8+this[s+6]*2**16+(l<<24);return(BigInt(d)<<BigInt(32))+BigInt(u+this[++s]*2**8+this[++s]*2**16+this[++s]*2**24)}),c.prototype.readBigInt64BE=Wt(function(s){s=s>>>0,$(s,"offset");const u=this[s],l=this[s+7];(u===void 0||l===void 0)&&J(s,this.length-8);const d=(u<<24)+this[++s]*2**16+this[++s]*2**8+this[++s];return(BigInt(d)<<BigInt(32))+BigInt(this[++s]*2**24+this[++s]*2**16+this[++s]*2**8+l)}),c.prototype.readFloatLE=function(s,u){return s=s>>>0,u||q(s,4,this.length),e.read(this,s,!0,23,4)},c.prototype.readFloatBE=function(s,u){return s=s>>>0,u||q(s,4,this.length),e.read(this,s,!1,23,4)},c.prototype.readDoubleLE=function(s,u){return s=s>>>0,u||q(s,8,this.length),e.read(this,s,!0,52,8)},c.prototype.readDoubleBE=function(s,u){return s=s>>>0,u||q(s,8,this.length),e.read(this,s,!1,52,8)};function rt(h,s,u,l,d,b){if(!c.isBuffer(h))throw new TypeError('"buffer" argument must be a Buffer instance');if(s>d||s<b)throw new RangeError('"value" argument is out of bounds');if(u+l>h.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(s,u,l,d){if(s=+s,u=u>>>0,l=l>>>0,!d){const H=Math.pow(2,8*l)-1;rt(this,s,u,l,H,0)}let b=1,I=0;for(this[u]=s&255;++I<l&&(b*=256);)this[u+I]=s/b&255;return u+l},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(s,u,l,d){if(s=+s,u=u>>>0,l=l>>>0,!d){const H=Math.pow(2,8*l)-1;rt(this,s,u,l,H,0)}let b=l-1,I=1;for(this[u+b]=s&255;--b>=0&&(I*=256);)this[u+b]=s/I&255;return u+l},c.prototype.writeUint8=c.prototype.writeUInt8=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,1,255,0),this[u]=s&255,u+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,2,65535,0),this[u]=s&255,this[u+1]=s>>>8,u+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,2,65535,0),this[u]=s>>>8,this[u+1]=s&255,u+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,4,4294967295,0),this[u+3]=s>>>24,this[u+2]=s>>>16,this[u+1]=s>>>8,this[u]=s&255,u+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,4,4294967295,0),this[u]=s>>>24,this[u+1]=s>>>16,this[u+2]=s>>>8,this[u+3]=s&255,u+4};function xt(h,s,u,l,d){j(s,l,d,h,u,7);let b=Number(s&BigInt(4294967295));h[u++]=b,b=b>>8,h[u++]=b,b=b>>8,h[u++]=b,b=b>>8,h[u++]=b;let I=Number(s>>BigInt(32)&BigInt(4294967295));return h[u++]=I,I=I>>8,h[u++]=I,I=I>>8,h[u++]=I,I=I>>8,h[u++]=I,u}function Ut(h,s,u,l,d){j(s,l,d,h,u,7);let b=Number(s&BigInt(4294967295));h[u+7]=b,b=b>>8,h[u+6]=b,b=b>>8,h[u+5]=b,b=b>>8,h[u+4]=b;let I=Number(s>>BigInt(32)&BigInt(4294967295));return h[u+3]=I,I=I>>8,h[u+2]=I,I=I>>8,h[u+1]=I,I=I>>8,h[u]=I,u+8}c.prototype.writeBigUInt64LE=Wt(function(s,u=0){return xt(this,s,u,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=Wt(function(s,u=0){return Ut(this,s,u,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(s,u,l,d){if(s=+s,u=u>>>0,!d){const pt=Math.pow(2,8*l-1);rt(this,s,u,l,pt-1,-pt)}let b=0,I=1,H=0;for(this[u]=s&255;++b<l&&(I*=256);)s<0&&H===0&&this[u+b-1]!==0&&(H=1),this[u+b]=(s/I>>0)-H&255;return u+l},c.prototype.writeIntBE=function(s,u,l,d){if(s=+s,u=u>>>0,!d){const pt=Math.pow(2,8*l-1);rt(this,s,u,l,pt-1,-pt)}let b=l-1,I=1,H=0;for(this[u+b]=s&255;--b>=0&&(I*=256);)s<0&&H===0&&this[u+b+1]!==0&&(H=1),this[u+b]=(s/I>>0)-H&255;return u+l},c.prototype.writeInt8=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,1,127,-128),s<0&&(s=255+s+1),this[u]=s&255,u+1},c.prototype.writeInt16LE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,2,32767,-32768),this[u]=s&255,this[u+1]=s>>>8,u+2},c.prototype.writeInt16BE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,2,32767,-32768),this[u]=s>>>8,this[u+1]=s&255,u+2},c.prototype.writeInt32LE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,4,2147483647,-2147483648),this[u]=s&255,this[u+1]=s>>>8,this[u+2]=s>>>16,this[u+3]=s>>>24,u+4},c.prototype.writeInt32BE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,4,2147483647,-2147483648),s<0&&(s=4294967295+s+1),this[u]=s>>>24,this[u+1]=s>>>16,this[u+2]=s>>>8,this[u+3]=s&255,u+4},c.prototype.writeBigInt64LE=Wt(function(s,u=0){return xt(this,s,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=Wt(function(s,u=0){return Ut(this,s,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Pt(h,s,u,l,d,b){if(u+l>h.length)throw new RangeError("Index out of range");if(u<0)throw new RangeError("Index out of range")}function Zt(h,s,u,l,d){return s=+s,u=u>>>0,d||Pt(h,s,u,4),e.write(h,s,u,l,23,4),u+4}c.prototype.writeFloatLE=function(s,u,l){return Zt(this,s,u,!0,l)},c.prototype.writeFloatBE=function(s,u,l){return Zt(this,s,u,!1,l)};function Gt(h,s,u,l,d){return s=+s,u=u>>>0,d||Pt(h,s,u,8),e.write(h,s,u,l,52,8),u+8}c.prototype.writeDoubleLE=function(s,u,l){return Gt(this,s,u,!0,l)},c.prototype.writeDoubleBE=function(s,u,l){return Gt(this,s,u,!1,l)},c.prototype.copy=function(s,u,l,d){if(!c.isBuffer(s))throw new TypeError("argument should be a Buffer");if(l||(l=0),!d&&d!==0&&(d=this.length),u>=s.length&&(u=s.length),u||(u=0),d>0&&d<l&&(d=l),d===l||s.length===0||this.length===0)return 0;if(u<0)throw new RangeError("targetStart out of bounds");if(l<0||l>=this.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),s.length-u<d-l&&(d=s.length-u+l);const b=d-l;return this===s&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(u,l,d):Uint8Array.prototype.set.call(s,this.subarray(l,d),u),b},c.prototype.fill=function(s,u,l,d){if(typeof s=="string"){if(typeof u=="string"?(d=u,u=0,l=this.length):typeof l=="string"&&(d=l,l=this.length),d!==void 0&&typeof d!="string")throw new TypeError("encoding must be a string");if(typeof d=="string"&&!c.isEncoding(d))throw new TypeError("Unknown encoding: "+d);if(s.length===1){const I=s.charCodeAt(0);(d==="utf8"&&I<128||d==="latin1")&&(s=I)}}else typeof s=="number"?s=s&255:typeof s=="boolean"&&(s=Number(s));if(u<0||this.length<u||this.length<l)throw new RangeError("Out of range index");if(l<=u)return this;u=u>>>0,l=l===void 0?this.length:l>>>0,s||(s=0);let b;if(typeof s=="number")for(b=u;b<l;++b)this[b]=s;else{const I=c.isBuffer(s)?s:c.from(s,d),H=I.length;if(H===0)throw new TypeError('The value "'+s+'" is invalid for argument "value"');for(b=0;b<l-u;++b)this[b+u]=I[b%H]}return this};const W={};function y(h,s,u){W[h]=class extends u{constructor(){super(),Object.defineProperty(this,"message",{value:s.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${h}]`,this.stack,delete this.name}get code(){return h}set code(d){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:d,writable:!0})}toString(){return`${this.name} [${h}]: ${this.message}`}}}y("ERR_BUFFER_OUT_OF_BOUNDS",function(h){return h?`${h} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),y("ERR_INVALID_ARG_TYPE",function(h,s){return`The "${h}" argument must be of type number. Received type ${typeof s}`},TypeError),y("ERR_OUT_OF_RANGE",function(h,s,u){let l=`The value of "${h}" is out of range.`,d=u;return Number.isInteger(u)&&Math.abs(u)>2**32?d=_(String(u)):typeof u=="bigint"&&(d=String(u),(u>BigInt(2)**BigInt(32)||u<-(BigInt(2)**BigInt(32)))&&(d=_(d)),d+="n"),l+=` It must be ${s}. Received ${d}`,l},RangeError);function _(h){let s="",u=h.length;const l=h[0]==="-"?1:0;for(;u>=l+4;u-=3)s=`_${h.slice(u-3,u)}${s}`;return`${h.slice(0,u)}${s}`}function E(h,s,u){$(s,"offset"),(h[s]===void 0||h[s+u]===void 0)&&J(s,h.length-(u+1))}function j(h,s,u,l,d,b){if(h>u||h<s){const I=typeof s=="bigint"?"n":"";let H;throw s===0||s===BigInt(0)?H=`>= 0${I} and < 2${I} ** ${(b+1)*8}${I}`:H=`>= -(2${I} ** ${(b+1)*8-1}${I}) and < 2 ** ${(b+1)*8-1}${I}`,new W.ERR_OUT_OF_RANGE("value",H,h)}E(l,d,b)}function $(h,s){if(typeof h!="number")throw new W.ERR_INVALID_ARG_TYPE(s,"number",h)}function J(h,s,u){throw Math.floor(h)!==h?($(h,u),new W.ERR_OUT_OF_RANGE("offset","an integer",h)):s<0?new W.ERR_BUFFER_OUT_OF_BOUNDS:new W.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${s}`,h)}const bt=/[^+/0-9A-Za-z-_]/g;function Nt(h){if(h=h.split("=")[0],h=h.trim().replace(bt,""),h.length<2)return"";for(;h.length%4!==0;)h=h+"=";return h}function kt(h,s){s=s||1/0;let u;const l=h.length;let d=null;const b=[];for(let I=0;I<l;++I){if(u=h.charCodeAt(I),u>55295&&u<57344){if(!d){if(u>56319){(s-=3)>-1&&b.push(239,191,189);continue}else if(I+1===l){(s-=3)>-1&&b.push(239,191,189);continue}d=u;continue}if(u<56320){(s-=3)>-1&&b.push(239,191,189),d=u;continue}u=(d-55296<<10|u-56320)+65536}else d&&(s-=3)>-1&&b.push(239,191,189);if(d=null,u<128){if((s-=1)<0)break;b.push(u)}else if(u<2048){if((s-=2)<0)break;b.push(u>>6|192,u&63|128)}else if(u<65536){if((s-=3)<0)break;b.push(u>>12|224,u>>6&63|128,u&63|128)}else if(u<1114112){if((s-=4)<0)break;b.push(u>>18|240,u>>12&63|128,u>>6&63|128,u&63|128)}else throw new Error("Invalid code point")}return b}function Ht(h){const s=[];for(let u=0;u<h.length;++u)s.push(h.charCodeAt(u)&255);return s}function Vt(h,s){let u,l,d;const b=[];for(let I=0;I<h.length&&!((s-=2)<0);++I)u=h.charCodeAt(I),l=u>>8,d=u%256,b.push(d),b.push(l);return b}function $t(h){return t.toByteArray(Nt(h))}function Mt(h,s,u,l){let d;for(d=0;d<l&&!(d+u>=s.length||d>=h.length);++d)s[d+u]=h[d];return d}function mt(h,s){return h instanceof s||h!=null&&h.constructor!=null&&h.constructor.name!=null&&h.constructor.name===s.name}function Qt(h){return h!==h}const ir=function(){const h="0123456789abcdef",s=new Array(256);for(let u=0;u<16;++u){const l=u*16;for(let d=0;d<16;++d)s[l+d]=h[u]+h[d]}return s}();function Wt(h){return typeof BigInt>"u"?_i:h}function _i(){throw new Error("BigInt not supported")}}(Oi)),Oi}var Bo;function Df(){if(Bo)return Dr;Bo=1,Object.defineProperty(Dr,"__esModule",{value:!0}),Dr.BinaryReader=void 0;const r=Os();class t{constructor(n,o=!1){this.readUInt8=this._read(r.Buffer.prototype.readUInt8,r.Buffer.prototype.readUInt8,1),this.readUInt16=this._read(r.Buffer.prototype.readUInt16LE,r.Buffer.prototype.readUInt16BE,2),this.readUInt32=this._read(r.Buffer.prototype.readUInt32LE,r.Buffer.prototype.readUInt32BE,4),this.readInt8=this._read(r.Buffer.prototype.readInt8,r.Buffer.prototype.readInt8,1),this.readInt16=this._read(r.Buffer.prototype.readInt16LE,r.Buffer.prototype.readInt16BE,2),this.readInt32=this._read(r.Buffer.prototype.readInt32LE,r.Buffer.prototype.readInt32BE,4),this.readFloat=this._read(r.Buffer.prototype.readFloatLE,r.Buffer.prototype.readFloatBE,4),this.readDouble=this._read(r.Buffer.prototype.readDoubleLE,r.Buffer.prototype.readDoubleBE,8),this.buffer=n,this.position=0,this.isBigEndian=o}_read(n,o,i){return()=>{let a;return this.isBigEndian?a=o.call(this.buffer,this.position):a=n.call(this.buffer,this.position),this.position+=i,a}}readVarInt(){let n,o=0,i=0;do n=this.buffer[this.position+i],o+=(n&127)<<7*i,i++;while(n>=128);return this.position+=i,o}}return Dr.BinaryReader=t,Dr}var Lr={},vo;function qe(){if(vo)return Lr;vo=1,Object.defineProperty(Lr,"__esModule",{value:!0}),Lr.BinaryWriter=void 0;const r=Os();class t{constructor(n,o=!0){this.writeUInt8=this._write(r.Buffer.prototype.writeUInt8,1),this.writeUInt16LE=this._write(r.Buffer.prototype.writeUInt16LE,2),this.writeUInt16BE=this._write(r.Buffer.prototype.writeUInt16BE,2),this.writeUInt32LE=this._write(r.Buffer.prototype.writeUInt32LE,4),this.writeUInt32BE=this._write(r.Buffer.prototype.writeUInt32BE,4),this.writeInt8=this._write(r.Buffer.prototype.writeInt8,1),this.writeInt16LE=this._write(r.Buffer.prototype.writeInt16LE,2),this.writeInt16BE=this._write(r.Buffer.prototype.writeInt16BE,2),this.writeInt32LE=this._write(r.Buffer.prototype.writeInt32LE,4),this.writeInt32BE=this._write(r.Buffer.prototype.writeInt32BE,4),this.writeFloatLE=this._write(r.Buffer.prototype.writeFloatLE,4),this.writeFloatBE=this._write(r.Buffer.prototype.writeFloatBE,4),this.writeDoubleLE=this._write(r.Buffer.prototype.writeDoubleLE,8),this.writeDoubleBE=this._write(r.Buffer.prototype.writeDoubleBE,8),this.buffer=r.Buffer.alloc(n),this.position=0,this.allowResize=o}_write(n,o){return(i,a=!1)=>{this.ensureSize(o),n.call(this.buffer,i,this.position,a),this.position+=o}}writeBuffer(n){this.ensureSize(n.length),n.copy(this.buffer,this.position,0,n.length),this.position+=n.length}writeVarInt(n){let o=1;for(;(n&4294967168)!==0;)this.writeUInt8(n&127|128),n>>>=7,o++;return this.writeUInt8(n&127),o}ensureSize(n){if(this.buffer.length<this.position+n)if(this.allowResize){const o=r.Buffer.alloc(this.position+n);this.buffer.copy(o,0,0,this.buffer.length),this.buffer=o}else throw new RangeError("index out of range")}}return Lr.BinaryWriter=t,Lr}var Rr={},Ao;function Pe(){return Ao||(Ao=1,Object.defineProperty(Rr,"__esModule",{value:!0}),Rr.CONSTANTS=void 0,Rr.CONSTANTS={wkt:{Point:"POINT",LineString:"LINESTRING",Polygon:"POLYGON",MultiPoint:"MULTIPOINT",MultiLineString:"MULTILINESTRING",MultiPolygon:"MULTIPOLYGON",GeometryCollection:"GEOMETRYCOLLECTION"},wkb:{Point:1,LineString:2,Polygon:3,MultiPoint:4,MultiLineString:5,MultiPolygon:6,GeometryCollection:7},geoJSON:{Point:"Point",LineString:"LineString",Polygon:"Polygon",MultiPoint:"MultiPoint",MultiLineString:"MultiLineString",MultiPolygon:"MultiPolygon",GeometryCollection:"GeometryCollection"}}),Rr}var Cr={},xo;function Uf(){if(xo)return Cr;xo=1,Object.defineProperty(Cr,"__esModule",{value:!0}),Cr.Geometry=void 0;const r=Os(),t=$e();class e{constructor(){this.srid=void 0,this.hasZ=!1,this.hasM=!1}static parse(o,i){if(typeof o==="string"||o instanceof t.WktParser)return e._parseWkt(o);if(r.Buffer.isBuffer(o)||o instanceof t.BinaryReader)try{return e._parseWkb(o,i)}catch{try{return e.parseTwkb(o)}catch{throw new Error("Could not parse WKB or TWKB")}}else throw new Error("First argument must be a string or Buffer")}static _parseWkt(o){let i,a;o instanceof t.WktParser?i=o:i=new t.WktParser(o);const c=i.matchRegex([/^SRID=(\d+);/]);c&&(a=parseInt(c[1],10));const f=i.matchType(),p=i.matchDimension(),g={srid:a,hasZ:p.hasZ,hasM:p.hasM};switch(f){case t.CONSTANTS.wkt.Point:return t.Point._parseWktWithOptions(i,g);case t.CONSTANTS.wkt.LineString:return t.LineString._parseWktWithOptions(i,g);case t.CONSTANTS.wkt.Polygon:return t.Polygon._parseWktWithOptions(i,g);case t.CONSTANTS.wkt.MultiPoint:return t.MultiPoint._parseWktWithOptions(i,g);case t.CONSTANTS.wkt.MultiLineString:return t.MultiLineString._parseWktWithOptions(i,g);case t.CONSTANTS.wkt.MultiPolygon:return t.MultiPolygon._parseWktWithOptions(i,g);case t.CONSTANTS.wkt.GeometryCollection:return t.GeometryCollection._parseWktWithOptions(i,g);default:throw new Error("Unsupported geometry type")}}static _parseWkb(o,i){let a,c,f;const p={};switch(o instanceof t.BinaryReader?a=o:a=new t.BinaryReader(o),a.isBigEndian=!a.readInt8(),c=a.readUInt32(),p.hasSrid=(c&536870912)===536870912,p.isEwkb=c&536870912||c&1073741824||c&2147483648,p.hasSrid&&(p.srid=a.readUInt32()),p.hasZ=!1,p.hasM=!1,!p.isEwkb&&(!i||!i.isEwkb)?c>=1e3&&c<2e3?(p.hasZ=!0,f=c-1e3):c>=2e3&&c<3e3?(p.hasM=!0,f=c-2e3):c>=3e3&&c<4e3?(p.hasZ=!0,p.hasM=!0,f=c-3e3):f=c:(c&2147483648&&(p.hasZ=!0),c&1073741824&&(p.hasM=!0),f=c&15),f){case t.CONSTANTS.wkb.Point:return t.Point._parseWkb(a,p);case t.CONSTANTS.wkb.LineString:return t.LineString._parseWkb(a,p);case t.CONSTANTS.wkb.Polygon:return t.Polygon._parseWkb(a,p);case t.CONSTANTS.wkb.MultiPoint:return t.MultiPoint._parseWkb(a,p);case t.CONSTANTS.wkb.MultiLineString:return t.MultiLineString._parseWkb(a,p);case t.CONSTANTS.wkb.MultiPolygon:return t.MultiPolygon._parseWkb(a,p);case t.CONSTANTS.wkb.GeometryCollection:return t.GeometryCollection._parseWkb(a,p);default:throw new Error(`GeometryType ${f} not supported`)}}static parseTwkb(o){let i;const a={};o instanceof t.BinaryReader?i=o:i=new t.BinaryReader(o);const c=i.readUInt8(),f=i.readUInt8(),p=c&15;if(a.precision=t.ZigZag.decode(c>>4),a.precisionFactor=Math.pow(10,a.precision),a.hasBoundingBox=f>>0&1,a.hasSizeAttribute=f>>1&1,a.hasIdList=f>>2&1,a.hasExtendedPrecision=f>>3&1,a.isEmpty=f>>4&1,a.hasExtendedPrecision){const g=i.readUInt8();a.hasZ=(g&1)===1,a.hasM=(g&2)===2,a.zPrecision=t.ZigZag.decode((g&28)>>2),a.zPrecisionFactor=Math.pow(10,a.zPrecision),a.mPrecision=t.ZigZag.decode((g&224)>>5),a.mPrecisionFactor=Math.pow(10,a.mPrecision)}else a.hasZ=!1,a.hasM=!1;if(a.hasSizeAttribute&&i.readVarInt(),a.hasBoundingBox){let g=2;a.hasZ&&g++,a.hasM&&g++;for(let v=0;v<g;v++)i.readVarInt(),i.readVarInt()}switch(p){case t.CONSTANTS.wkb.Point:return t.Point._parseTwkb(i,a);case t.CONSTANTS.wkb.LineString:return t.LineString._parseTwkb(i,a);case t.CONSTANTS.wkb.Polygon:return t.Polygon._parseTwkb(i,a);case t.CONSTANTS.wkb.MultiPoint:return t.MultiPoint._parseTwkb(i,a);case t.CONSTANTS.wkb.MultiLineString:return t.MultiLineString._parseTwkb(i,a);case t.CONSTANTS.wkb.MultiPolygon:return t.MultiPolygon._parseTwkb(i,a);case t.CONSTANTS.wkb.GeometryCollection:return t.GeometryCollection._parseTwkb(i,a);default:throw new Error("GeometryType "+p+" not supported")}}toGeoJSON(o){const i={};return this.srid&&o&&(o.shortCrs?i.crs={type:"name",properties:{name:"EPSG:"+this.srid}}:o.longCrs&&(i.crs={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+this.srid}})),i}static _parseGeoJSON(o,i){let a;switch(o.type){case t.CONSTANTS.geoJSON.Point:a=t.Point._parseGeoJSON(o);break;case t.CONSTANTS.geoJSON.LineString:a=t.LineString._parseGeoJSON(o);break;case t.CONSTANTS.geoJSON.Polygon:a=t.Polygon._parseGeoJSON(o);break;case t.CONSTANTS.geoJSON.MultiPoint:a=t.MultiPoint._parseGeoJSON(o);break;case t.CONSTANTS.geoJSON.MultiLineString:a=t.MultiLineString._parseGeoJSON(o);break;case t.CONSTANTS.geoJSON.MultiPolygon:a=t.MultiPolygon._parseGeoJSON(o);break;case t.CONSTANTS.geoJSON.GeometryCollection:a=t.GeometryCollection._parseGeoJSON(o);break;default:throw new Error("GeometryType "+o.type+" not supported")}if(o.crs&&o.crs.type&&o.crs.type==="name"&&o.crs.properties&&o.crs.properties.name){const c=o.crs.properties.name;if(c.indexOf("EPSG:")===0)a.srid=parseInt(c.substring(5));else if(c.indexOf("urn:ogc:def:crs:EPSG::")===0)a.srid=parseInt(c.substring(22));else throw new Error("Unsupported crs: "+c)}else i||(a.srid=4326);return a}toEwkt(){return`SRID=${this.srid};${this.toWkt()}`}toEwkb(){const o=new t.BinaryWriter(this._getWkbSize()+4),i=this.toWkb();return o.writeInt8(1),o.writeUInt32LE((i.slice(1,5).readUInt32LE(0)|536870912)>>>0,!0),o.writeUInt32LE(this.srid),o.writeBuffer(i.slice(5)),o.buffer}_getWktType(o,i){let a=o;return this.hasZ&&this.hasM?a+=" ZM ":this.hasZ?a+=" Z ":this.hasM&&(a+=" M "),i&&!this.hasZ&&!this.hasM&&(a+=" "),i&&(a+="EMPTY"),a}_getWktCoordinate(o){let i=`${o.x} ${o.y}`;return this.hasZ&&(i+=` ${o.z}`),this.hasM&&(i+=` ${o.m}`),i}_writeWkbType(o,i,a){let c=0;typeof this.srid>"u"&&(!a||typeof a.srid>"u")?this.hasZ&&this.hasM?c+=3e3:this.hasZ?c+=1e3:this.hasM&&(c+=2e3):(this.hasZ&&(c|=2147483648),this.hasM&&(c|=1073741824)),o.writeUInt32LE(c+i>>>0,!0)}static getTwkbPrecision(o,i,a){return{xy:o,z:i,m:a,xyFactor:Math.pow(10,o),zFactor:Math.pow(10,i),mFactor:Math.pow(10,a)}}_writeTwkbHeader(o,i,a,c){const f=(t.ZigZag.encode(a.xy)<<4)+i;let p=this.hasZ||this.hasM?1:0;if(p+=c?1:0,o.writeUInt8(f),o.writeUInt8(p),this.hasZ||this.hasM){let g=0;this.hasZ&&(g|=1),this.hasM&&(g|=2),o.writeUInt8(g)}}toWkt(){throw new Error("Method 'toWkt' not implemented.")}toWkb(){throw new Error("Method 'toWkb' not implemented.")}toTwkb(){throw new Error("Method 'toTwkb' not implemented.")}_getWkbSize(){throw new Error("Method '_getWkbSize' not implemented.")}}return Cr.Geometry=e,Cr}var Pr={},Eo;function Lf(){if(Eo)return Pr;Eo=1,Object.defineProperty(Pr,"__esModule",{value:!0}),Pr.GeometryCollection=void 0;const r=qe(),t=Pe(),e=$e();class n extends e.Geometry{constructor(i=[],a){super(),this.geometries=i,this.srid=a,this.geometries.length>0&&(this.hasZ=this.geometries[0].hasZ,this.hasM=this.geometries[0].hasM)}static Z(i,a){const c=new n(i,a);return c.hasZ=!0,c}static M(i,a){const c=new n(i,a);return c.hasM=!0,c}static ZM(i,a){const c=new n(i,a);return c.hasZ=!0,c.hasM=!0,c}static _parseWktWithOptions(i,a){const c=new n;if(c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM,i.isMatch(["EMPTY"]))return c;i.expectGroupStart();do c.geometries.push(e.Geometry.parse(i));while(i.isMatch([","]));return i.expectGroupEnd(),c}static _parseWkb(i,a){const c=new n;c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM;const f=i.readUInt32();for(let p=0;p<f;p++)c.geometries.push(e.Geometry.parse(i,a));return c}static _parseTwkb(i,a){const c=new n;if(c.hasZ=a.hasZ,c.hasM=a.hasM,a.isEmpty)return c;const f=i.readVarInt();for(let p=0;p<f;p++)c.geometries.push(e.Geometry.parseTwkb(i));return c}static _parseGeoJSON(i){const a=new n;for(let c=0;c<i.geometries.length;c++)a.geometries.push(e.Geometry._parseGeoJSON(i.geometries[c],!0));return a.geometries.length>0&&(a.hasZ=a.geometries[0].hasZ),a}toWkt(){if(this.geometries.length===0)return this._getWktType(t.CONSTANTS.wkt.GeometryCollection,!0);let i=this._getWktType(t.CONSTANTS.wkt.GeometryCollection,!1)+"(";for(let a=0;a<this.geometries.length;a++)i+=this.geometries[a].toWkt()+",";return i=i.slice(0,-1)+")",i}toWkb(){const i=new r.BinaryWriter(this._getWkbSize());i.writeInt8(1),this._writeWkbType(i,t.CONSTANTS.wkb.GeometryCollection),i.writeUInt32LE(this.geometries.length);for(let a=0;a<this.geometries.length;a++)i.writeBuffer(this.geometries[a].toWkb());return i.buffer}toTwkb(){const i=new r.BinaryWriter(0,!0),a=e.Geometry.getTwkbPrecision(5,0,0),c=this.geometries.length===0;if(this._writeTwkbHeader(i,t.CONSTANTS.wkb.GeometryCollection,a,c),!c){i.writeVarInt(this.geometries.length);for(let f=0;f<this.geometries.length;f++)i.writeBuffer(this.geometries[f].toTwkb())}return i.buffer}_getWkbSize(){let i=9;for(let a=0;a<this.geometries.length;a++)i+=this.geometries[a]._getWkbSize();return i}toGeoJSON(i){const a=super.toGeoJSON(i);return a.type=t.CONSTANTS.geoJSON.GeometryCollection,a.geometries=this.geometries.map(c=>c.toGeoJSON()),a}}return Pr.GeometryCollection=n,Pr}var $r={},To;function Rf(){if(To)return $r;To=1,Object.defineProperty($r,"__esModule",{value:!0}),$r.LineString=void 0;const r=qe(),t=Pe(),e=$e();class n extends e.Geometry{constructor(i=[],a){super(),this.hasZ=!1,this.hasM=!1,this.points=i,this.srid=a,this.points.length>0&&(this.hasZ=this.points[0].hasZ,this.hasM=this.points[0].hasM)}static Z(i,a){const c=new n(i,a);return c.hasZ=!0,c}static M(i,a){const c=new n(i,a);return c.hasM=!0,c}static ZM(i,a){const c=new n(i,a);return c.hasZ=!0,c.hasM=!0,c}static _parseWktWithOptions(i,a){const c=new n;return c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM,i.isMatch(["EMPTY"])||(i.expectGroupStart(),c.points.push(...i.matchCoordinates(a)),i.expectGroupEnd()),c}static _parseWkb(i,a){const c=new n;c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM;const f=i.readUInt32();for(let p=0;p<f;p++)c.points.push(e.Point._readWkbPoint(i,a));return c}static _parseTwkb(i,a){const c=new n;if(c.hasZ=a.hasZ,c.hasM=a.hasM,a.isEmpty)return c;const f=new e.Point(0,0,0,0),p=i.readVarInt();for(let g=0;g<p;g++)c.points.push(e.Point._readTwkbPoint(i,a,f));return c}static _parseGeoJSON(i){const a=new n;i.coordinates.length>0&&(a.hasZ=i.coordinates[0].length>2);for(const c of i.coordinates)a.points.push(e.Point._readGeoJSONPoint(c));return a}static fromGeometry(i){const a=new n;return a.srid=i.srid,a.hasZ=i.hasZ,a.hasM=i.hasM,i instanceof n?a.points=i.points:i instanceof e.Point&&(a.points=[i]),a}toWkt(){return this.points.length===0?this._getWktType(t.CONSTANTS.wkt.LineString,!0):this._getWktType(t.CONSTANTS.wkt.LineString,!1)+this._toInnerWkt()}_toInnerWkt(){let i="(";for(const a of this.points)i+=`${this._getWktCoordinate(a)},`;return i.slice(0,-1)+")"}toWkb(i){const a=new r.BinaryWriter(this._getWkbSize());a.writeInt8(1),this._writeWkbType(a,t.CONSTANTS.wkb.LineString,i),a.writeUInt32LE(this.points.length);for(const c of this.points)c._writeWkbPoint(a);return a.buffer}toTwkb(){const i=new r.BinaryWriter(0,!0),a=e.Geometry.getTwkbPrecision(5,0,0),c=this.points.length===0;if(this._writeTwkbHeader(i,t.CONSTANTS.wkb.LineString,a,c),!c){i.writeVarInt(this.points.length);const f=new e.Point(0,0,0,0);for(const p of this.points)p._writeTwkbPoint(i,a,f)}return i.buffer}_getWkbSize(){let i=16;return this.hasZ&&(i+=8),this.hasM&&(i+=8),9+this.points.length*i}toGeoJSON(i){const a=super.toGeoJSON(i);return a.type=t.CONSTANTS.geoJSON.LineString,a.coordinates=this.points.map(c=>this.hasZ?[c.x,c.y,c.z]:[c.x,c.y]),a}}return $r.LineString=n,$r}var zr={},Oo;function Cf(){if(Oo)return zr;Oo=1,Object.defineProperty(zr,"__esModule",{value:!0}),zr.MultiLineString=void 0;const r=qe(),t=Pe(),e=$e();class n extends e.Geometry{constructor(i=[],a){super(),this.lineStrings=i,this.srid=a,this.lineStrings.length>0&&(this.hasZ=this.lineStrings[0].hasZ,this.hasM=this.lineStrings[0].hasM)}static Z(i,a){const c=new n(i,a);return c.hasZ=!0,c}static M(i,a){const c=new n(i,a);return c.hasM=!0,c}static ZM(i,a){const c=new n(i,a);return c.hasZ=!0,c.hasM=!0,c}static _parseWktWithOptions(i,a){const c=new n;if(c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM,i.isMatch(["EMPTY"]))return c;i.expectGroupStart();do i.expectGroupStart(),c.lineStrings.push(new e.LineString(i.matchCoordinates(a))),i.expectGroupEnd();while(i.isMatch([","]));return i.expectGroupEnd(),c}static _parseWkb(i,a){const c=new n;c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM;const f=i.readUInt32();for(let p=0;p<f;p++){const g=e.Geometry.parse(i,a);c.lineStrings.push(e.LineString.fromGeometry(g))}return c}static _parseTwkb(i,a){const c=new n;if(c.hasZ=a.hasZ,c.hasM=a.hasM,a.isEmpty)return c;const f=new e.Point(0,0,0,0),p=i.readVarInt();for(let g=0;g<p;g++){const v=new e.LineString;v.hasZ=a.hasZ,v.hasM=a.hasM;const C=i.readVarInt();for(let F=0;F<C;F++)v.points.push(e.Point._readTwkbPoint(i,a,f));c.lineStrings.push(v)}return c}static _parseGeoJSON(i){const a=new n;i.coordinates.length>0&&i.coordinates[0].length>0&&(a.hasZ=i.coordinates[0][0].length>2);for(let c=0;c<i.coordinates.length;c++)a.lineStrings.push(e.LineString._parseGeoJSON({coordinates:i.coordinates[c]}));return a}toWkt(){if(this.lineStrings.length===0)return this._getWktType(t.CONSTANTS.wkt.MultiLineString,!0);let i=this._getWktType(t.CONSTANTS.wkt.MultiLineString,!1)+"(";for(let a=0;a<this.lineStrings.length;a++)i+=this.lineStrings[a]._toInnerWkt()+",";return i=i.slice(0,-1)+")",i}toWkb(){const i=new r.BinaryWriter(this._getWkbSize());i.writeInt8(1),this._writeWkbType(i,t.CONSTANTS.wkb.MultiLineString),i.writeUInt32LE(this.lineStrings.length);for(let a=0;a<this.lineStrings.length;a++)i.writeBuffer(this.lineStrings[a].toWkb({srid:this.srid}));return i.buffer}toTwkb(){const i=new r.BinaryWriter(0,!0),a=e.Geometry.getTwkbPrecision(5,0,0),c=this.lineStrings.length===0;if(this._writeTwkbHeader(i,t.CONSTANTS.wkb.MultiLineString,a,c),!c){i.writeVarInt(this.lineStrings.length);const f=new e.Point(0,0,0,0);for(let p=0;p<this.lineStrings.length;p++){i.writeVarInt(this.lineStrings[p].points.length);for(let g=0;g<this.lineStrings[p].points.length;g++)this.lineStrings[p].points[g]._writeTwkbPoint(i,a,f)}}return i.buffer}_getWkbSize(){let i=9;for(let a=0;a<this.lineStrings.length;a++)i+=this.lineStrings[a]._getWkbSize();return i}toGeoJSON(i){const a=super.toGeoJSON(i);a.type=t.CONSTANTS.geoJSON.MultiLineString,a.coordinates=[];for(let c=0;c<this.lineStrings.length;c++)a.coordinates.push(this.lineStrings[c].toGeoJSON().coordinates);return a}}return zr.MultiLineString=n,zr}var jr={},Mo;function Pf(){if(Mo)return jr;Mo=1,Object.defineProperty(jr,"__esModule",{value:!0}),jr.MultiPoint=void 0;const r=qe(),t=Pe(),e=$e();class n extends e.Geometry{constructor(i=[],a){super(),this.points=i,this.srid=a,this.points.length>0&&(this.hasZ=this.points[0].hasZ,this.hasM=this.points[0].hasM)}static Z(i,a){const c=new n(i,a);return c.hasZ=!0,c}static M(i,a){const c=new n(i,a);return c.hasM=!0,c}static ZM(i,a){const c=new n(i,a);return c.hasZ=!0,c.hasM=!0,c}static _parseWktWithOptions(i,a){const c=new n;return c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM,i.isMatch(["EMPTY"])||(i.expectGroupStart(),c.points.push(...i.matchCoordinates(a)),i.expectGroupEnd()),c}static _parseWkb(i,a){const c=new n;c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM;const f=i.readUInt32();for(let p=0;p<f;p++){const g=e.Geometry.parse(i,a);c.points.push(e.Point.fromGeometry(g))}return c}static _parseTwkb(i,a){const c=new n;if(c.hasZ=a.hasZ,c.hasM=a.hasM,a.isEmpty)return c;const f=new e.Point(0,0,0,0),p=i.readVarInt();for(let g=0;g<p;g++)c.points.push(e.Point._readTwkbPoint(i,a,f));return c}static _parseGeoJSON(i){const a=new n;i.coordinates.length>0&&(a.hasZ=i.coordinates[0].length>2);for(let c=0;c<i.coordinates.length;c++)a.points.push(e.Point._parseGeoJSON({coordinates:i.coordinates[c]}));return a}toWkt(){if(this.points.length===0)return this._getWktType(t.CONSTANTS.wkt.MultiPoint,!0);let i=this._getWktType(t.CONSTANTS.wkt.MultiPoint,!1)+"(";for(let a=0;a<this.points.length;a++)i+=this._getWktCoordinate(this.points[a])+",";return i=i.slice(0,-1)+")",i}toWkb(){const i=new r.BinaryWriter(this._getWkbSize());i.writeInt8(1),this._writeWkbType(i,t.CONSTANTS.wkb.MultiPoint),i.writeUInt32LE(this.points.length);for(let a=0;a<this.points.length;a++)i.writeBuffer(this.points[a].toWkb({srid:this.srid}));return i.buffer}toTwkb(){const i=new r.BinaryWriter(0,!0),a=e.Geometry.getTwkbPrecision(5,0,0),c=this.points.length===0;if(this._writeTwkbHeader(i,t.CONSTANTS.wkb.MultiPoint,a,c),!c){i.writeVarInt(this.points.length);const f=new e.Point(0,0,0,0);for(let p=0;p<this.points.length;p++)this.points[p]._writeTwkbPoint(i,a,f)}return i.buffer}_getWkbSize(){let i=16;return this.hasZ&&(i+=8),this.hasM&&(i+=8),i+=5,9+this.points.length*i}toGeoJSON(i){const a=super.toGeoJSON(i);a.type=t.CONSTANTS.geoJSON.MultiPoint,a.coordinates=[];for(let c=0;c<this.points.length;c++)a.coordinates.push(this.points[c].toGeoJSON().coordinates);return a}}return jr.MultiPoint=n,jr}var Vr={},Fo;function $f(){if(Fo)return Vr;Fo=1,Object.defineProperty(Vr,"__esModule",{value:!0}),Vr.MultiPolygon=void 0;const r=qe(),t=Pe(),e=$e();class n extends e.Geometry{constructor(i,a){super(),this.polygons=i||[],this.srid=a,this.polygons.length>0?(this.hasZ=this.polygons[0].hasZ,this.hasM=this.polygons[0].hasM):(this.hasZ=!1,this.hasM=!1)}static Z(i,a){const c=new n(i,a);return c.hasZ=!0,c}static M(i,a){const c=new n(i,a);return c.hasM=!0,c}static ZM(i,a){const c=new n(i,a);return c.hasZ=!0,c.hasM=!0,c}static _parseWktWithOptions(i,a){const c=new n;if(c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM,i.isMatch(["EMPTY"]))return c;i.expectGroupStart();do{i.expectGroupStart();const f=[],p=[];for(i.expectGroupStart(),f.push(...i.matchCoordinates(a)),i.expectGroupEnd();i.isMatch([","]);)i.expectGroupStart(),p.push(i.matchCoordinates(a)),i.expectGroupEnd();c.polygons.push(new e.Polygon(f,p)),i.expectGroupEnd()}while(i.isMatch([","]));return i.expectGroupEnd(),c}static _parseWkb(i,a){const c=new n;c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM;const f=i.readUInt32();for(let p=0;p<f;p++)c.polygons.push(e.Geometry.parse(i,a));return c}static _parseTwkb(i,a){const c=new n;if(c.hasZ=a.hasZ,c.hasM=a.hasM,a.isEmpty)return c;const f=new e.Point(0,0,0,0),p=i.readVarInt();for(let g=0;g<p;g++){const v=new e.Polygon;v.hasZ=a.hasZ,v.hasM=a.hasM;const C=i.readVarInt(),F=i.readVarInt();for(let T=0;T<F;T++)v.exteriorRing.push(e.Point._readTwkbPoint(i,a,f));for(let T=1;T<C;T++){const U=[],M=i.readVarInt();for(let k=0;k<M;k++)U.push(e.Point._readTwkbPoint(i,a,f));v.interiorRings.push(U)}c.polygons.push(v)}return c}static _parseGeoJSON(i){const a=new n;i.coordinates.length>0&&i.coordinates[0].length>0&&i.coordinates[0][0].length>0&&(a.hasZ=i.coordinates[0][0].length>2);for(let c=0;c<i.coordinates.length;c++)a.polygons.push(e.Polygon._parseGeoJSON({coordinates:i.coordinates}));return a}toWkt(){if(this.polygons.length===0)return this._getWktType(t.CONSTANTS.wkt.MultiPolygon,!0);let i=this._getWktType(t.CONSTANTS.wkt.MultiPolygon,!1)+"(";for(let a=0;a<this.polygons.length;a++)i+=this.polygons[a]._toInnerWkt()+",";return i=i.slice(0,-1),i+=")",i}toWkb(){const i=new r.BinaryWriter(this._getWkbSize());i.writeInt8(1),this._writeWkbType(i,t.CONSTANTS.wkb.MultiPolygon),i.writeUInt32LE(this.polygons.length);for(let a=0;a<this.polygons.length;a++)i.writeBuffer(this.polygons[a].toWkb({srid:this.srid}));return i.buffer}toTwkb(){const i=new r.BinaryWriter(0,!0),a=e.Geometry.getTwkbPrecision(5,0,0),c=this.polygons.length===0;if(this._writeTwkbHeader(i,t.CONSTANTS.wkb.MultiPolygon,a,c),this.polygons.length>0){i.writeVarInt(this.polygons.length);const f=new e.Point(0,0,0,0);for(let p=0;p<this.polygons.length;p++){i.writeVarInt(1+this.polygons[p].interiorRings.length),i.writeVarInt(this.polygons[p].exteriorRing.length);for(let g=0;g<this.polygons[p].exteriorRing.length;g++)this.polygons[p].exteriorRing[g]._writeTwkbPoint(i,a,f);for(let g=0;g<this.polygons[p].interiorRings.length;g++){i.writeVarInt(this.polygons[p].interiorRings[g].length);for(let v=0;v<this.polygons[p].interiorRings[g].length;v++)this.polygons[p].interiorRings[g][v]._writeTwkbPoint(i,a,f)}}}return i.buffer}_getWkbSize(){let i=9;for(let a=0;a<this.polygons.length;a++)i+=this.polygons[a]._getWkbSize();return i}toGeoJSON(i){const a=super.toGeoJSON(i);a.type=t.CONSTANTS.geoJSON.MultiPolygon,a.coordinates=[];for(let c=0;c<this.polygons.length;c++)a.coordinates.push(this.polygons[c].toGeoJSON().coordinates);return a}}return Vr.MultiPolygon=n,Vr}var Wr={},Zr={},No;function eu(){if(No)return Zr;No=1,Object.defineProperty(Zr,"__esModule",{value:!0}),Zr.ZigZag=void 0;class r{static encode(e){return e<<1^e>>31}static decode(e){return e>>1^-(e&1)}}return Zr.ZigZag=r,Zr}var ko;function ru(){if(ko)return Wr;ko=1,Object.defineProperty(Wr,"__esModule",{value:!0}),Wr.Point=void 0;const r=qe(),t=eu(),e=Pe(),n=$e();class o extends n.Geometry{constructor(a,c,f,p,g){super(),this.x=a,this.y=c,this.z=f,this.m=p,this.srid=g,this.hasZ=typeof this.z<"u",this.hasM=typeof this.m<"u"}static Z(a,c,f,p){const g=new o(a,c,f,0,p);return g.hasZ=!0,g}static M(a,c,f,p){const g=new o(a,c,0,f,p);return g.hasM=!0,g}static ZM(a,c,f,p,g){const v=new o(a,c,f,p,g);return v.hasZ=!0,v.hasM=!0,v}static _parseWktWithOptions(a,c){const f=new o(0,0,0,0);if(f.srid=c.srid,f.hasZ=c.hasZ,f.hasM=c.hasM,a.isMatch(["EMPTY"]))return f;a.expectGroupStart();const p=a.matchCoordinate(c);return f.x=p.x,f.y=p.y,f.z=p.z,f.m=p.m,a.expectGroupEnd(),f}static _parseWkb(a,c){const f=o._readWkbPoint(a,c);return f.srid=c.srid,f}static _readWkbPoint(a,c){return new o(a.readDouble(),a.readDouble(),c.hasZ?a.readDouble():!1,c.hasM?a.readDouble():!1)}static _parseTwkb(a,c){const f=new o(0,0,0,0);return f.hasZ=c.hasZ,f.hasM=c.hasM,c.isEmpty||(f.x=t.ZigZag.decode(a.readVarInt())/c.precisionFactor,f.y=t.ZigZag.decode(a.readVarInt())/c.precisionFactor,f.z=c.hasZ?t.ZigZag.decode(a.readVarInt())/c.zPrecisionFactor:0,f.m=c.hasM?t.ZigZag.decode(a.readVarInt())/c.mPrecisionFactor:0),f}static _readTwkbPoint(a,c,f){return f.x+=t.ZigZag.decode(a.readVarInt())/c.precisionFactor,f.y+=t.ZigZag.decode(a.readVarInt())/c.precisionFactor,c.hasZ&&(f.z+=t.ZigZag.decode(a.readVarInt())/c.zPrecisionFactor),c.hasM&&(f.m+=t.ZigZag.decode(a.readVarInt())/c.mPrecisionFactor),new o(f.x,f.y,f.z,f.m)}static _parseGeoJSON(a){return o._readGeoJSONPoint(a.coordinates)}static _readGeoJSONPoint(a){return a.length===0?new o(0,0,0,0):a.length>2?new o(a[0],a[1],a[2],0):new o(a[0],a[1],0,0)}static fromGeometry(a){const c=new o(0,0,0,0);return c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM,a instanceof o?(c.x=a.x,c.y=a.y,c.z=a.z,c.m=a.m):console.log("Point.fromGeometry: geom is not an instance of Point"),c}toWkt(){return this.x===void 0&&this.y===void 0&&this.z===void 0&&this.m===void 0?this._getWktType(e.CONSTANTS.wkt.Point,!0):`${this._getWktType(e.CONSTANTS.wkt.Point,!1)}(${this._getWktCoordinate(this)})`}toWkb(a){const c=new r.BinaryWriter(this._getWkbSize());return c.writeInt8(1),this._writeWkbType(c,e.CONSTANTS.wkb.Point,a),this.x===void 0&&this.y===void 0?(c.writeDoubleLE(NaN),c.writeDoubleLE(NaN),this.hasZ&&c.writeDoubleLE(NaN),this.hasM&&c.writeDoubleLE(NaN)):this._writeWkbPoint(c),c.buffer}_writeWkbPoint(a){a.writeDoubleLE(this.x),a.writeDoubleLE(this.y),this.hasZ&&a.writeDoubleLE(this.z),this.hasM&&a.writeDoubleLE(this.m)}toTwkb(){const a=new r.BinaryWriter(0,!0),c=n.Geometry.getTwkbPrecision(5,0,0),f=this.x===void 0&&this.y===void 0;return this._writeTwkbHeader(a,e.CONSTANTS.wkb.Point,c,f),f||this._writeTwkbPoint(a,c,new o(0,0,0,0)),a.buffer}_writeTwkbPoint(a,c,f){const p=this.x*c.xyFactor,g=this.y*c.xyFactor,v=this.z*c.zFactor,C=this.m*c.mFactor;a.writeVarInt(t.ZigZag.encode(p-f.x)),a.writeVarInt(t.ZigZag.encode(g-f.y)),this.hasZ&&a.writeVarInt(t.ZigZag.encode(v-f.z)),this.hasM&&a.writeVarInt(t.ZigZag.encode(C-f.m)),f.x=p,f.y=g,f.z=v,f.m=C}_getWkbSize(){let a=21;return this.hasZ&&(a+=8),this.hasM&&(a+=8),a}toGeoJSON(a){const c=super.toGeoJSON(a);return c.type=e.CONSTANTS.geoJSON.Point,this.x===void 0&&this.y===void 0?c.coordinates=[]:this.z!==void 0?c.coordinates=[this.x,this.y,this.z]:c.coordinates=[this.x,this.y],c}}return Wr.Point=o,Wr}var Gr={},Do;function zf(){if(Do)return Gr;Do=1,Object.defineProperty(Gr,"__esModule",{value:!0}),Gr.Polygon=void 0;const r=qe(),t=Pe(),e=$e();class n extends e.Geometry{constructor(i,a,c){super(),this.exteriorRing=i||[],this.interiorRings=a||[],this.srid=c,this.exteriorRing.length>0?(this.hasZ=this.exteriorRing[0].hasZ,this.hasM=this.exteriorRing[0].hasM):(this.hasZ=!1,this.hasM=!1)}static Z(i,a,c){const f=new n(i,a,c);return f.hasZ=!0,f}static M(i,a,c){const f=new n(i,a,c);return f.hasM=!0,f}static ZM(i,a,c){const f=new n(i,a,c);return f.hasZ=!0,f.hasM=!0,f}static _parseWktWithOptions(i,a){const c=new n;if(c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM,i.isMatch(["EMPTY"]))return c;for(i.expectGroupStart(),i.expectGroupStart(),c.exteriorRing.push(...i.matchCoordinates(a)),i.expectGroupEnd();i.isMatch([","]);)i.expectGroupStart(),c.interiorRings.push(i.matchCoordinates(a)),i.expectGroupEnd();return i.expectGroupEnd(),c}static _parseWkb(i,a){const c=new n;c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM;const f=i.readUInt32();if(f>0){const p=i.readUInt32();for(let g=0;g<p;g++)c.exteriorRing.push(e.Point._readWkbPoint(i,a));for(let g=1;g<f;g++){const v=[],C=i.readUInt32();for(let F=0;F<C;F++)v.push(e.Point._readWkbPoint(i,a));c.interiorRings.push(v)}}return c}static _parseTwkb(i,a){const c=new n;if(c.hasZ=a.hasZ,c.hasM=a.hasM,a.isEmpty)return c;const f=new e.Point(0,0,0,0),p=i.readVarInt(),g=i.readVarInt();for(let v=0;v<g;v++)c.exteriorRing.push(e.Point._readTwkbPoint(i,a,f));for(let v=1;v<p;v++){const C=[],F=i.readVarInt();for(let T=0;T<F;T++)C.push(e.Point._readTwkbPoint(i,a,f));c.interiorRings.push(C)}return c}static _parseGeoJSON(i){const a=new n;i.coordinates.length>0&&i.coordinates[0].length>0&&(a.hasZ=i.coordinates[0][0].length>2);for(let c=0;c<i.coordinates.length;c++){c>0&&a.interiorRings.push([]);for(let f=0;f<i.coordinates[c].length;f++)c===0?a.exteriorRing.push(e.Point._readGeoJSONPoint(i.coordinates[c][f])):a.interiorRings[c-1].push(e.Point._readGeoJSONPoint(i.coordinates[c][f]))}return a}toWkt(){return this.exteriorRing.length===0?this._getWktType(t.CONSTANTS.wkt.Polygon,!0):this._getWktType(t.CONSTANTS.wkt.Polygon,!1)+this._toInnerWkt()}_toInnerWkt(){let i="((";for(let a=0;a<this.exteriorRing.length;a++)i+=this._getWktCoordinate(this.exteriorRing[a])+",";i=i.slice(0,-1),i+=")";for(let a=0;a<this.interiorRings.length;a++){i+=",(";for(let c=0;c<this.interiorRings[a].length;c++)i+=this._getWktCoordinate(this.interiorRings[a][c])+",";i=i.slice(0,-1),i+=")"}return i+=")",i}toWkb(i){const a=new r.BinaryWriter(this._getWkbSize());a.writeInt8(1),this._writeWkbType(a,t.CONSTANTS.wkb.Polygon,i),this.exteriorRing.length>0?(a.writeUInt32LE(1+this.interiorRings.length),a.writeUInt32LE(this.exteriorRing.length)):a.writeUInt32LE(0);for(let c=0;c<this.exteriorRing.length;c++)this.exteriorRing[c]._writeWkbPoint(a);for(let c=0;c<this.interiorRings.length;c++){a.writeUInt32LE(this.interiorRings[c].length);for(let f=0;f<this.interiorRings[c].length;f++)this.interiorRings[c][f]._writeWkbPoint(a)}return a.buffer}toTwkb(){const i=new r.BinaryWriter(0,!0),a=e.Geometry.getTwkbPrecision(5,0,0),c=this.exteriorRing.length===0;if(this._writeTwkbHeader(i,t.CONSTANTS.wkb.Polygon,a,c),this.exteriorRing.length>0){i.writeVarInt(1+this.interiorRings.length),i.writeVarInt(this.exteriorRing.length);const f=new e.Point(0,0,0,0);for(let p=0;p<this.exteriorRing.length;p++)this.exteriorRing[p]._writeTwkbPoint(i,a,f);for(let p=0;p<this.interiorRings.length;p++){i.writeVarInt(this.interiorRings[p].length);for(let g=0;g<this.interiorRings[p].length;g++)this.interiorRings[p][g]._writeTwkbPoint(i,a,f)}}return i.buffer}_getWkbSize(){let i=16;this.hasZ&&(i+=8),this.hasM&&(i+=8);let a=9;this.exteriorRing.length>0&&(a+=4+this.exteriorRing.length*i);for(let c=0;c<this.interiorRings.length;c++)a+=4+this.interiorRings[c].length*i;return a}toGeoJSON(i){const a=super.toGeoJSON(i);if(a.type=t.CONSTANTS.geoJSON.Polygon,a.coordinates=[],this.exteriorRing.length>0){const c=[];for(let f=0;f<this.exteriorRing.length;f++)this.hasZ?c.push([this.exteriorRing[f].x,this.exteriorRing[f].y,this.exteriorRing[f].z]):c.push([this.exteriorRing[f].x,this.exteriorRing[f].y]);a.coordinates.push(c)}for(let c=0;c<this.interiorRings.length;c++){const f=[];for(let p=0;p<this.interiorRings[c].length;p++)this.hasZ?f.push([this.interiorRings[c][p].x,this.interiorRings[c][p].y,this.interiorRings[c][p].z]):f.push([this.interiorRings[c][p].x,this.interiorRings[c][p].y]);a.coordinates.push(f)}return a}}return Gr.Polygon=n,Gr}var Yr={},Uo;function jf(){if(Uo)return Yr;Uo=1,Object.defineProperty(Yr,"__esModule",{value:!0}),Yr.WktParser=void 0;const r=Pe(),t=ru();class e{constructor(o){this.value=o,this.position=0}match(o){this.skipWhitespaces();for(let i=0;i<o.length;i++)if(this.value.substring(this.position).indexOf(o[i])===0)return this.position+=o[i].length,o[i];return null}matchRegex(o){this.skipWhitespaces();for(let i=0;i<o.length;i++){const a=this.value.substring(this.position).match(o[i]);if(a)return this.position+=a[0].length,a}return null}isMatch(o){this.skipWhitespaces();for(let i=0;i<o.length;i++)if(this.value.substring(this.position).indexOf(o[i])===0)return this.position+=o[i].length,!0;return!1}matchType(){const o=this.match([r.CONSTANTS.wkt.Point,r.CONSTANTS.wkt.LineString,r.CONSTANTS.wkt.Polygon,r.CONSTANTS.wkt.MultiPoint,r.CONSTANTS.wkt.MultiLineString,r.CONSTANTS.wkt.MultiPolygon,r.CONSTANTS.wkt.GeometryCollection]);if(!o)throw new Error("Expected geometry type");return o}matchDimension(){switch(this.match(["ZM","Z","M"])){case"ZM":return{hasZ:!0,hasM:!0};case"Z":return{hasZ:!0,hasM:!1};case"M":return{hasZ:!1,hasM:!0};default:return{hasZ:!1,hasM:!1}}}expectGroupStart(){if(!this.isMatch(["("]))throw new Error("Expected group start")}expectGroupEnd(){if(!this.isMatch([")"]))throw new Error("Expected group end")}matchCoordinate(o){let i;if(o.hasZ&&o.hasM?i=this.matchRegex([/^(\S*)\s+(\S*)\s+(\S*)\s+([^\s,)]*)/]):o.hasZ||o.hasM?i=this.matchRegex([/^(\S*)\s+(\S*)\s+([^\s,)]*)/]):i=this.matchRegex([/^(\S*)\s+([^\s,)]*)/]),!i)throw new Error("Expected coordinates");return o.hasZ&&o.hasM?new t.Point(parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3]),parseFloat(i[4])):o.hasZ?new t.Point(parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3]),0):o.hasM?new t.Point(parseFloat(i[1]),parseFloat(i[2]),0,parseFloat(i[3])):new t.Point(parseFloat(i[1]),parseFloat(i[2]),0,0)}matchCoordinates(o){const i=[];do{const a=this.isMatch(["("]);i.push(this.matchCoordinate(o)),a&&this.expectGroupEnd()}while(this.isMatch([","]));return i}skipWhitespaces(){for(;this.position<this.value.length&&this.value[this.position]===" ";)this.position++}}return Yr.WktParser=e,Yr}var Lo;function $e(){return Lo||(Lo=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.ZigZag=r.WktParser=r.Polygon=r.Point=r.MultiPolygon=r.MultiPoint=r.MultiLineString=r.LineString=r.GeometryCollection=r.Geometry=r.CONSTANTS=r.BinaryWriter=r.BinaryReader=void 0;const t=Df();Object.defineProperty(r,"BinaryReader",{enumerable:!0,get:function(){return t.BinaryReader}});const e=qe();Object.defineProperty(r,"BinaryWriter",{enumerable:!0,get:function(){return e.BinaryWriter}});const n=Pe();Object.defineProperty(r,"CONSTANTS",{enumerable:!0,get:function(){return n.CONSTANTS}});const o=Uf();Object.defineProperty(r,"Geometry",{enumerable:!0,get:function(){return o.Geometry}});const i=Lf();Object.defineProperty(r,"GeometryCollection",{enumerable:!0,get:function(){return i.GeometryCollection}});const a=Rf();Object.defineProperty(r,"LineString",{enumerable:!0,get:function(){return a.LineString}});const c=Cf();Object.defineProperty(r,"MultiLineString",{enumerable:!0,get:function(){return c.MultiLineString}});const f=Pf();Object.defineProperty(r,"MultiPoint",{enumerable:!0,get:function(){return f.MultiPoint}});const p=$f();Object.defineProperty(r,"MultiPolygon",{enumerable:!0,get:function(){return p.MultiPolygon}});const g=ru();Object.defineProperty(r,"Point",{enumerable:!0,get:function(){return g.Point}});const v=zf();Object.defineProperty(r,"Polygon",{enumerable:!0,get:function(){return v.Polygon}});const C=jf();Object.defineProperty(r,"WktParser",{enumerable:!0,get:function(){return C.WktParser}});const F=eu();Object.defineProperty(r,"ZigZag",{enumerable:!0,get:function(){return F.ZigZag}})}(Ti)),Ti}var Vf=$e(),Mi={};var Ro;function Wf(){return Ro||(Ro=1,function(r){const t=Qc(),e=tu(),n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=c,r.SlowBuffer=P,r.INSPECT_MAX_BYTES=50;const o=2147483647;r.kMaxLength=o,c.TYPED_ARRAY_SUPPORT=i(),!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{const h=new Uint8Array(1),s={foo:function(){return 42}};return Object.setPrototypeOf(s,Uint8Array.prototype),Object.setPrototypeOf(h,s),h.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function a(h){if(h>o)throw new RangeError('The value "'+h+'" is invalid for option "size"');const s=new Uint8Array(h);return Object.setPrototypeOf(s,c.prototype),s}function c(h,s,u){if(typeof h=="number"){if(typeof s=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(h)}return f(h,s,u)}c.poolSize=8192;function f(h,s,u){if(typeof h=="string")return C(h,s);if(ArrayBuffer.isView(h))return T(h);if(h==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h);if(mt(h,ArrayBuffer)||h&&mt(h.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(mt(h,SharedArrayBuffer)||h&&mt(h.buffer,SharedArrayBuffer)))return U(h,s,u);if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const l=h.valueOf&&h.valueOf();if(l!=null&&l!==h)return c.from(l,s,u);const d=M(h);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof h[Symbol.toPrimitive]=="function")return c.from(h[Symbol.toPrimitive]("string"),s,u);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h)}c.from=function(h,s,u){return f(h,s,u)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array);function p(h){if(typeof h!="number")throw new TypeError('"size" argument must be of type number');if(h<0)throw new RangeError('The value "'+h+'" is invalid for option "size"')}function g(h,s,u){return p(h),h<=0?a(h):s!==void 0?typeof u=="string"?a(h).fill(s,u):a(h).fill(s):a(h)}c.alloc=function(h,s,u){return g(h,s,u)};function v(h){return p(h),a(h<0?0:k(h)|0)}c.allocUnsafe=function(h){return v(h)},c.allocUnsafeSlow=function(h){return v(h)};function C(h,s){if((typeof s!="string"||s==="")&&(s="utf8"),!c.isEncoding(s))throw new TypeError("Unknown encoding: "+s);const u=R(h,s)|0;let l=a(u);const d=l.write(h,s);return d!==u&&(l=l.slice(0,d)),l}function F(h){const s=h.length<0?0:k(h.length)|0,u=a(s);for(let l=0;l<s;l+=1)u[l]=h[l]&255;return u}function T(h){if(mt(h,Uint8Array)){const s=new Uint8Array(h);return U(s.buffer,s.byteOffset,s.byteLength)}return F(h)}function U(h,s,u){if(s<0||h.byteLength<s)throw new RangeError('"offset" is outside of buffer bounds');if(h.byteLength<s+(u||0))throw new RangeError('"length" is outside of buffer bounds');let l;return s===void 0&&u===void 0?l=new Uint8Array(h):u===void 0?l=new Uint8Array(h,s):l=new Uint8Array(h,s,u),Object.setPrototypeOf(l,c.prototype),l}function M(h){if(c.isBuffer(h)){const s=k(h.length)|0,u=a(s);return u.length===0||h.copy(u,0,0,s),u}if(h.length!==void 0)return typeof h.length!="number"||Qt(h.length)?a(0):F(h);if(h.type==="Buffer"&&Array.isArray(h.data))return F(h.data)}function k(h){if(h>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return h|0}function P(h){return+h!=h&&(h=0),c.alloc(+h)}c.isBuffer=function(s){return s!=null&&s._isBuffer===!0&&s!==c.prototype},c.compare=function(s,u){if(mt(s,Uint8Array)&&(s=c.from(s,s.offset,s.byteLength)),mt(u,Uint8Array)&&(u=c.from(u,u.offset,u.byteLength)),!c.isBuffer(s)||!c.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(s===u)return 0;let l=s.length,d=u.length;for(let b=0,I=Math.min(l,d);b<I;++b)if(s[b]!==u[b]){l=s[b],d=u[b];break}return l<d?-1:d<l?1:0},c.isEncoding=function(s){switch(String(s).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(s,u){if(!Array.isArray(s))throw new TypeError('"list" argument must be an Array of Buffers');if(s.length===0)return c.alloc(0);let l;if(u===void 0)for(u=0,l=0;l<s.length;++l)u+=s[l].length;const d=c.allocUnsafe(u);let b=0;for(l=0;l<s.length;++l){let I=s[l];if(mt(I,Uint8Array))b+I.length>d.length?(c.isBuffer(I)||(I=c.from(I)),I.copy(d,b)):Uint8Array.prototype.set.call(d,I,b);else if(c.isBuffer(I))I.copy(d,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=I.length}return d};function R(h,s){if(c.isBuffer(h))return h.length;if(ArrayBuffer.isView(h)||mt(h,ArrayBuffer))return h.byteLength;if(typeof h!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof h);const u=h.length,l=arguments.length>2&&arguments[2]===!0;if(!l&&u===0)return 0;let d=!1;for(;;)switch(s){case"ascii":case"latin1":case"binary":return u;case"utf8":case"utf-8":return kt(h).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u*2;case"hex":return u>>>1;case"base64":return $t(h).length;default:if(d)return l?-1:kt(h).length;s=(""+s).toLowerCase(),d=!0}}c.byteLength=R;function V(h,s,u){let l=!1;if((s===void 0||s<0)&&(s=0),s>this.length||((u===void 0||u>this.length)&&(u=this.length),u<=0)||(u>>>=0,s>>>=0,u<=s))return"";for(h||(h="utf8");;)switch(h){case"hex":return X(this,s,u);case"utf8":case"utf-8":return z(this,s,u);case"ascii":return Y(this,s,u);case"latin1":case"binary":return Z(this,s,u);case"base64":return Q(this,s,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return K(this,s,u);default:if(l)throw new TypeError("Unknown encoding: "+h);h=(h+"").toLowerCase(),l=!0}}c.prototype._isBuffer=!0;function G(h,s,u){const l=h[s];h[s]=h[u],h[u]=l}c.prototype.swap16=function(){const s=this.length;if(s%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let u=0;u<s;u+=2)G(this,u,u+1);return this},c.prototype.swap32=function(){const s=this.length;if(s%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let u=0;u<s;u+=4)G(this,u,u+3),G(this,u+1,u+2);return this},c.prototype.swap64=function(){const s=this.length;if(s%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let u=0;u<s;u+=8)G(this,u,u+7),G(this,u+1,u+6),G(this,u+2,u+5),G(this,u+3,u+4);return this},c.prototype.toString=function(){const s=this.length;return s===0?"":arguments.length===0?z(this,0,s):V.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(s){if(!c.isBuffer(s))throw new TypeError("Argument must be a Buffer");return this===s?!0:c.compare(this,s)===0},c.prototype.inspect=function(){let s="";const u=r.INSPECT_MAX_BYTES;return s=this.toString("hex",0,u).replace(/(.{2})/g,"$1 ").trim(),this.length>u&&(s+=" ... "),"<Buffer "+s+">"},n&&(c.prototype[n]=c.prototype.inspect),c.prototype.compare=function(s,u,l,d,b){if(mt(s,Uint8Array)&&(s=c.from(s,s.offset,s.byteLength)),!c.isBuffer(s))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof s);if(u===void 0&&(u=0),l===void 0&&(l=s?s.length:0),d===void 0&&(d=0),b===void 0&&(b=this.length),u<0||l>s.length||d<0||b>this.length)throw new RangeError("out of range index");if(d>=b&&u>=l)return 0;if(d>=b)return-1;if(u>=l)return 1;if(u>>>=0,l>>>=0,d>>>=0,b>>>=0,this===s)return 0;let I=b-d,H=l-u;const pt=Math.min(I,H),lt=this.slice(d,b),yt=s.slice(u,l);for(let et=0;et<pt;++et)if(lt[et]!==yt[et]){I=lt[et],H=yt[et];break}return I<H?-1:H<I?1:0};function A(h,s,u,l,d){if(h.length===0)return-1;if(typeof u=="string"?(l=u,u=0):u>2147483647?u=2147483647:u<-2147483648&&(u=-2147483648),u=+u,Qt(u)&&(u=d?0:h.length-1),u<0&&(u=h.length+u),u>=h.length){if(d)return-1;u=h.length-1}else if(u<0)if(d)u=0;else return-1;if(typeof s=="string"&&(s=c.from(s,l)),c.isBuffer(s))return s.length===0?-1:O(h,s,u,l,d);if(typeof s=="number")return s=s&255,typeof Uint8Array.prototype.indexOf=="function"?d?Uint8Array.prototype.indexOf.call(h,s,u):Uint8Array.prototype.lastIndexOf.call(h,s,u):O(h,[s],u,l,d);throw new TypeError("val must be string, number or Buffer")}function O(h,s,u,l,d){let b=1,I=h.length,H=s.length;if(l!==void 0&&(l=String(l).toLowerCase(),l==="ucs2"||l==="ucs-2"||l==="utf16le"||l==="utf-16le")){if(h.length<2||s.length<2)return-1;b=2,I/=2,H/=2,u/=2}function pt(yt,et){return b===1?yt[et]:yt.readUInt16BE(et*b)}let lt;if(d){let yt=-1;for(lt=u;lt<I;lt++)if(pt(h,lt)===pt(s,yt===-1?0:lt-yt)){if(yt===-1&&(yt=lt),lt-yt+1===H)return yt*b}else yt!==-1&&(lt-=lt-yt),yt=-1}else for(u+H>I&&(u=I-H),lt=u;lt>=0;lt--){let yt=!0;for(let et=0;et<H;et++)if(pt(h,lt+et)!==pt(s,et)){yt=!1;break}if(yt)return lt}return-1}c.prototype.includes=function(s,u,l){return this.indexOf(s,u,l)!==-1},c.prototype.indexOf=function(s,u,l){return A(this,s,u,l,!0)},c.prototype.lastIndexOf=function(s,u,l){return A(this,s,u,l,!1)};function m(h,s,u,l){u=Number(u)||0;const d=h.length-u;l?(l=Number(l),l>d&&(l=d)):l=d;const b=s.length;l>b/2&&(l=b/2);let I;for(I=0;I<l;++I){const H=parseInt(s.substr(I*2,2),16);if(Qt(H))return I;h[u+I]=H}return I}function S(h,s,u,l){return Mt(kt(s,h.length-u),h,u,l)}function w(h,s,u,l){return Mt(Ht(s),h,u,l)}function B(h,s,u,l){return Mt($t(s),h,u,l)}function N(h,s,u,l){return Mt(Vt(s,h.length-u),h,u,l)}c.prototype.write=function(s,u,l,d){if(u===void 0)d="utf8",l=this.length,u=0;else if(l===void 0&&typeof u=="string")d=u,l=this.length,u=0;else if(isFinite(u))u=u>>>0,isFinite(l)?(l=l>>>0,d===void 0&&(d="utf8")):(d=l,l=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const b=this.length-u;if((l===void 0||l>b)&&(l=b),s.length>0&&(l<0||u<0)||u>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");let I=!1;for(;;)switch(d){case"hex":return m(this,s,u,l);case"utf8":case"utf-8":return S(this,s,u,l);case"ascii":case"latin1":case"binary":return w(this,s,u,l);case"base64":return B(this,s,u,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,s,u,l);default:if(I)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),I=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Q(h,s,u){return s===0&&u===h.length?t.fromByteArray(h):t.fromByteArray(h.slice(s,u))}function z(h,s,u){u=Math.min(h.length,u);const l=[];let d=s;for(;d<u;){const b=h[d];let I=null,H=b>239?4:b>223?3:b>191?2:1;if(d+H<=u){let pt,lt,yt,et;switch(H){case 1:b<128&&(I=b);break;case 2:pt=h[d+1],(pt&192)===128&&(et=(b&31)<<6|pt&63,et>127&&(I=et));break;case 3:pt=h[d+1],lt=h[d+2],(pt&192)===128&&(lt&192)===128&&(et=(b&15)<<12|(pt&63)<<6|lt&63,et>2047&&(et<55296||et>57343)&&(I=et));break;case 4:pt=h[d+1],lt=h[d+2],yt=h[d+3],(pt&192)===128&&(lt&192)===128&&(yt&192)===128&&(et=(b&15)<<18|(pt&63)<<12|(lt&63)<<6|yt&63,et>65535&&et<1114112&&(I=et))}}I===null?(I=65533,H=1):I>65535&&(I-=65536,l.push(I>>>10&1023|55296),I=56320|I&1023),l.push(I),d+=H}return D(l)}const L=4096;function D(h){const s=h.length;if(s<=L)return String.fromCharCode.apply(String,h);let u="",l=0;for(;l<s;)u+=String.fromCharCode.apply(String,h.slice(l,l+=L));return u}function Y(h,s,u){let l="";u=Math.min(h.length,u);for(let d=s;d<u;++d)l+=String.fromCharCode(h[d]&127);return l}function Z(h,s,u){let l="";u=Math.min(h.length,u);for(let d=s;d<u;++d)l+=String.fromCharCode(h[d]);return l}function X(h,s,u){const l=h.length;(!s||s<0)&&(s=0),(!u||u<0||u>l)&&(u=l);let d="";for(let b=s;b<u;++b)d+=ir[h[b]];return d}function K(h,s,u){const l=h.slice(s,u);let d="";for(let b=0;b<l.length-1;b+=2)d+=String.fromCharCode(l[b]+l[b+1]*256);return d}c.prototype.slice=function(s,u){const l=this.length;s=~~s,u=u===void 0?l:~~u,s<0?(s+=l,s<0&&(s=0)):s>l&&(s=l),u<0?(u+=l,u<0&&(u=0)):u>l&&(u=l),u<s&&(u=s);const d=this.subarray(s,u);return Object.setPrototypeOf(d,c.prototype),d};function q(h,s,u){if(h%1!==0||h<0)throw new RangeError("offset is not uint");if(h+s>u)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(s,u,l){s=s>>>0,u=u>>>0,l||q(s,u,this.length);let d=this[s],b=1,I=0;for(;++I<u&&(b*=256);)d+=this[s+I]*b;return d},c.prototype.readUintBE=c.prototype.readUIntBE=function(s,u,l){s=s>>>0,u=u>>>0,l||q(s,u,this.length);let d=this[s+--u],b=1;for(;u>0&&(b*=256);)d+=this[s+--u]*b;return d},c.prototype.readUint8=c.prototype.readUInt8=function(s,u){return s=s>>>0,u||q(s,1,this.length),this[s]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(s,u){return s=s>>>0,u||q(s,2,this.length),this[s]|this[s+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(s,u){return s=s>>>0,u||q(s,2,this.length),this[s]<<8|this[s+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(s,u){return s=s>>>0,u||q(s,4,this.length),(this[s]|this[s+1]<<8|this[s+2]<<16)+this[s+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(s,u){return s=s>>>0,u||q(s,4,this.length),this[s]*16777216+(this[s+1]<<16|this[s+2]<<8|this[s+3])},c.prototype.readBigUInt64LE=Wt(function(s){s=s>>>0,$(s,"offset");const u=this[s],l=this[s+7];(u===void 0||l===void 0)&&J(s,this.length-8);const d=u+this[++s]*2**8+this[++s]*2**16+this[++s]*2**24,b=this[++s]+this[++s]*2**8+this[++s]*2**16+l*2**24;return BigInt(d)+(BigInt(b)<<BigInt(32))}),c.prototype.readBigUInt64BE=Wt(function(s){s=s>>>0,$(s,"offset");const u=this[s],l=this[s+7];(u===void 0||l===void 0)&&J(s,this.length-8);const d=u*2**24+this[++s]*2**16+this[++s]*2**8+this[++s],b=this[++s]*2**24+this[++s]*2**16+this[++s]*2**8+l;return(BigInt(d)<<BigInt(32))+BigInt(b)}),c.prototype.readIntLE=function(s,u,l){s=s>>>0,u=u>>>0,l||q(s,u,this.length);let d=this[s],b=1,I=0;for(;++I<u&&(b*=256);)d+=this[s+I]*b;return b*=128,d>=b&&(d-=Math.pow(2,8*u)),d},c.prototype.readIntBE=function(s,u,l){s=s>>>0,u=u>>>0,l||q(s,u,this.length);let d=u,b=1,I=this[s+--d];for(;d>0&&(b*=256);)I+=this[s+--d]*b;return b*=128,I>=b&&(I-=Math.pow(2,8*u)),I},c.prototype.readInt8=function(s,u){return s=s>>>0,u||q(s,1,this.length),this[s]&128?(255-this[s]+1)*-1:this[s]},c.prototype.readInt16LE=function(s,u){s=s>>>0,u||q(s,2,this.length);const l=this[s]|this[s+1]<<8;return l&32768?l|4294901760:l},c.prototype.readInt16BE=function(s,u){s=s>>>0,u||q(s,2,this.length);const l=this[s+1]|this[s]<<8;return l&32768?l|4294901760:l},c.prototype.readInt32LE=function(s,u){return s=s>>>0,u||q(s,4,this.length),this[s]|this[s+1]<<8|this[s+2]<<16|this[s+3]<<24},c.prototype.readInt32BE=function(s,u){return s=s>>>0,u||q(s,4,this.length),this[s]<<24|this[s+1]<<16|this[s+2]<<8|this[s+3]},c.prototype.readBigInt64LE=Wt(function(s){s=s>>>0,$(s,"offset");const u=this[s],l=this[s+7];(u===void 0||l===void 0)&&J(s,this.length-8);const d=this[s+4]+this[s+5]*2**8+this[s+6]*2**16+(l<<24);return(BigInt(d)<<BigInt(32))+BigInt(u+this[++s]*2**8+this[++s]*2**16+this[++s]*2**24)}),c.prototype.readBigInt64BE=Wt(function(s){s=s>>>0,$(s,"offset");const u=this[s],l=this[s+7];(u===void 0||l===void 0)&&J(s,this.length-8);const d=(u<<24)+this[++s]*2**16+this[++s]*2**8+this[++s];return(BigInt(d)<<BigInt(32))+BigInt(this[++s]*2**24+this[++s]*2**16+this[++s]*2**8+l)}),c.prototype.readFloatLE=function(s,u){return s=s>>>0,u||q(s,4,this.length),e.read(this,s,!0,23,4)},c.prototype.readFloatBE=function(s,u){return s=s>>>0,u||q(s,4,this.length),e.read(this,s,!1,23,4)},c.prototype.readDoubleLE=function(s,u){return s=s>>>0,u||q(s,8,this.length),e.read(this,s,!0,52,8)},c.prototype.readDoubleBE=function(s,u){return s=s>>>0,u||q(s,8,this.length),e.read(this,s,!1,52,8)};function rt(h,s,u,l,d,b){if(!c.isBuffer(h))throw new TypeError('"buffer" argument must be a Buffer instance');if(s>d||s<b)throw new RangeError('"value" argument is out of bounds');if(u+l>h.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(s,u,l,d){if(s=+s,u=u>>>0,l=l>>>0,!d){const H=Math.pow(2,8*l)-1;rt(this,s,u,l,H,0)}let b=1,I=0;for(this[u]=s&255;++I<l&&(b*=256);)this[u+I]=s/b&255;return u+l},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(s,u,l,d){if(s=+s,u=u>>>0,l=l>>>0,!d){const H=Math.pow(2,8*l)-1;rt(this,s,u,l,H,0)}let b=l-1,I=1;for(this[u+b]=s&255;--b>=0&&(I*=256);)this[u+b]=s/I&255;return u+l},c.prototype.writeUint8=c.prototype.writeUInt8=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,1,255,0),this[u]=s&255,u+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,2,65535,0),this[u]=s&255,this[u+1]=s>>>8,u+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,2,65535,0),this[u]=s>>>8,this[u+1]=s&255,u+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,4,4294967295,0),this[u+3]=s>>>24,this[u+2]=s>>>16,this[u+1]=s>>>8,this[u]=s&255,u+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,4,4294967295,0),this[u]=s>>>24,this[u+1]=s>>>16,this[u+2]=s>>>8,this[u+3]=s&255,u+4};function xt(h,s,u,l,d){j(s,l,d,h,u,7);let b=Number(s&BigInt(4294967295));h[u++]=b,b=b>>8,h[u++]=b,b=b>>8,h[u++]=b,b=b>>8,h[u++]=b;let I=Number(s>>BigInt(32)&BigInt(4294967295));return h[u++]=I,I=I>>8,h[u++]=I,I=I>>8,h[u++]=I,I=I>>8,h[u++]=I,u}function Ut(h,s,u,l,d){j(s,l,d,h,u,7);let b=Number(s&BigInt(4294967295));h[u+7]=b,b=b>>8,h[u+6]=b,b=b>>8,h[u+5]=b,b=b>>8,h[u+4]=b;let I=Number(s>>BigInt(32)&BigInt(4294967295));return h[u+3]=I,I=I>>8,h[u+2]=I,I=I>>8,h[u+1]=I,I=I>>8,h[u]=I,u+8}c.prototype.writeBigUInt64LE=Wt(function(s,u=0){return xt(this,s,u,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=Wt(function(s,u=0){return Ut(this,s,u,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(s,u,l,d){if(s=+s,u=u>>>0,!d){const pt=Math.pow(2,8*l-1);rt(this,s,u,l,pt-1,-pt)}let b=0,I=1,H=0;for(this[u]=s&255;++b<l&&(I*=256);)s<0&&H===0&&this[u+b-1]!==0&&(H=1),this[u+b]=(s/I>>0)-H&255;return u+l},c.prototype.writeIntBE=function(s,u,l,d){if(s=+s,u=u>>>0,!d){const pt=Math.pow(2,8*l-1);rt(this,s,u,l,pt-1,-pt)}let b=l-1,I=1,H=0;for(this[u+b]=s&255;--b>=0&&(I*=256);)s<0&&H===0&&this[u+b+1]!==0&&(H=1),this[u+b]=(s/I>>0)-H&255;return u+l},c.prototype.writeInt8=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,1,127,-128),s<0&&(s=255+s+1),this[u]=s&255,u+1},c.prototype.writeInt16LE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,2,32767,-32768),this[u]=s&255,this[u+1]=s>>>8,u+2},c.prototype.writeInt16BE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,2,32767,-32768),this[u]=s>>>8,this[u+1]=s&255,u+2},c.prototype.writeInt32LE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,4,2147483647,-2147483648),this[u]=s&255,this[u+1]=s>>>8,this[u+2]=s>>>16,this[u+3]=s>>>24,u+4},c.prototype.writeInt32BE=function(s,u,l){return s=+s,u=u>>>0,l||rt(this,s,u,4,2147483647,-2147483648),s<0&&(s=4294967295+s+1),this[u]=s>>>24,this[u+1]=s>>>16,this[u+2]=s>>>8,this[u+3]=s&255,u+4},c.prototype.writeBigInt64LE=Wt(function(s,u=0){return xt(this,s,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=Wt(function(s,u=0){return Ut(this,s,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Pt(h,s,u,l,d,b){if(u+l>h.length)throw new RangeError("Index out of range");if(u<0)throw new RangeError("Index out of range")}function Zt(h,s,u,l,d){return s=+s,u=u>>>0,d||Pt(h,s,u,4),e.write(h,s,u,l,23,4),u+4}c.prototype.writeFloatLE=function(s,u,l){return Zt(this,s,u,!0,l)},c.prototype.writeFloatBE=function(s,u,l){return Zt(this,s,u,!1,l)};function Gt(h,s,u,l,d){return s=+s,u=u>>>0,d||Pt(h,s,u,8),e.write(h,s,u,l,52,8),u+8}c.prototype.writeDoubleLE=function(s,u,l){return Gt(this,s,u,!0,l)},c.prototype.writeDoubleBE=function(s,u,l){return Gt(this,s,u,!1,l)},c.prototype.copy=function(s,u,l,d){if(!c.isBuffer(s))throw new TypeError("argument should be a Buffer");if(l||(l=0),!d&&d!==0&&(d=this.length),u>=s.length&&(u=s.length),u||(u=0),d>0&&d<l&&(d=l),d===l||s.length===0||this.length===0)return 0;if(u<0)throw new RangeError("targetStart out of bounds");if(l<0||l>=this.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),s.length-u<d-l&&(d=s.length-u+l);const b=d-l;return this===s&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(u,l,d):Uint8Array.prototype.set.call(s,this.subarray(l,d),u),b},c.prototype.fill=function(s,u,l,d){if(typeof s=="string"){if(typeof u=="string"?(d=u,u=0,l=this.length):typeof l=="string"&&(d=l,l=this.length),d!==void 0&&typeof d!="string")throw new TypeError("encoding must be a string");if(typeof d=="string"&&!c.isEncoding(d))throw new TypeError("Unknown encoding: "+d);if(s.length===1){const I=s.charCodeAt(0);(d==="utf8"&&I<128||d==="latin1")&&(s=I)}}else typeof s=="number"?s=s&255:typeof s=="boolean"&&(s=Number(s));if(u<0||this.length<u||this.length<l)throw new RangeError("Out of range index");if(l<=u)return this;u=u>>>0,l=l===void 0?this.length:l>>>0,s||(s=0);let b;if(typeof s=="number")for(b=u;b<l;++b)this[b]=s;else{const I=c.isBuffer(s)?s:c.from(s,d),H=I.length;if(H===0)throw new TypeError('The value "'+s+'" is invalid for argument "value"');for(b=0;b<l-u;++b)this[b+u]=I[b%H]}return this};const W={};function y(h,s,u){W[h]=class extends u{constructor(){super(),Object.defineProperty(this,"message",{value:s.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${h}]`,this.stack,delete this.name}get code(){return h}set code(d){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:d,writable:!0})}toString(){return`${this.name} [${h}]: ${this.message}`}}}y("ERR_BUFFER_OUT_OF_BOUNDS",function(h){return h?`${h} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),y("ERR_INVALID_ARG_TYPE",function(h,s){return`The "${h}" argument must be of type number. Received type ${typeof s}`},TypeError),y("ERR_OUT_OF_RANGE",function(h,s,u){let l=`The value of "${h}" is out of range.`,d=u;return Number.isInteger(u)&&Math.abs(u)>2**32?d=_(String(u)):typeof u=="bigint"&&(d=String(u),(u>BigInt(2)**BigInt(32)||u<-(BigInt(2)**BigInt(32)))&&(d=_(d)),d+="n"),l+=` It must be ${s}. Received ${d}`,l},RangeError);function _(h){let s="",u=h.length;const l=h[0]==="-"?1:0;for(;u>=l+4;u-=3)s=`_${h.slice(u-3,u)}${s}`;return`${h.slice(0,u)}${s}`}function E(h,s,u){$(s,"offset"),(h[s]===void 0||h[s+u]===void 0)&&J(s,h.length-(u+1))}function j(h,s,u,l,d,b){if(h>u||h<s){const I=typeof s=="bigint"?"n":"";let H;throw s===0||s===BigInt(0)?H=`>= 0${I} and < 2${I} ** ${(b+1)*8}${I}`:H=`>= -(2${I} ** ${(b+1)*8-1}${I}) and < 2 ** ${(b+1)*8-1}${I}`,new W.ERR_OUT_OF_RANGE("value",H,h)}E(l,d,b)}function $(h,s){if(typeof h!="number")throw new W.ERR_INVALID_ARG_TYPE(s,"number",h)}function J(h,s,u){throw Math.floor(h)!==h?($(h,u),new W.ERR_OUT_OF_RANGE("offset","an integer",h)):s<0?new W.ERR_BUFFER_OUT_OF_BOUNDS:new W.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${s}`,h)}const bt=/[^+/0-9A-Za-z-_]/g;function Nt(h){if(h=h.split("=")[0],h=h.trim().replace(bt,""),h.length<2)return"";for(;h.length%4!==0;)h=h+"=";return h}function kt(h,s){s=s||1/0;let u;const l=h.length;let d=null;const b=[];for(let I=0;I<l;++I){if(u=h.charCodeAt(I),u>55295&&u<57344){if(!d){if(u>56319){(s-=3)>-1&&b.push(239,191,189);continue}else if(I+1===l){(s-=3)>-1&&b.push(239,191,189);continue}d=u;continue}if(u<56320){(s-=3)>-1&&b.push(239,191,189),d=u;continue}u=(d-55296<<10|u-56320)+65536}else d&&(s-=3)>-1&&b.push(239,191,189);if(d=null,u<128){if((s-=1)<0)break;b.push(u)}else if(u<2048){if((s-=2)<0)break;b.push(u>>6|192,u&63|128)}else if(u<65536){if((s-=3)<0)break;b.push(u>>12|224,u>>6&63|128,u&63|128)}else if(u<1114112){if((s-=4)<0)break;b.push(u>>18|240,u>>12&63|128,u>>6&63|128,u&63|128)}else throw new Error("Invalid code point")}return b}function Ht(h){const s=[];for(let u=0;u<h.length;++u)s.push(h.charCodeAt(u)&255);return s}function Vt(h,s){let u,l,d;const b=[];for(let I=0;I<h.length&&!((s-=2)<0);++I)u=h.charCodeAt(I),l=u>>8,d=u%256,b.push(d),b.push(l);return b}function $t(h){return t.toByteArray(Nt(h))}function Mt(h,s,u,l){let d;for(d=0;d<l&&!(d+u>=s.length||d>=h.length);++d)s[d+u]=h[d];return d}function mt(h,s){return h instanceof s||h!=null&&h.constructor!=null&&h.constructor.name!=null&&h.constructor.name===s.name}function Qt(h){return h!==h}const ir=function(){const h="0123456789abcdef",s=new Array(256);for(let u=0;u<16;++u){const l=u*16;for(let d=0;d<16;++d)s[l+d]=h[u]+h[d]}return s}();function Wt(h){return typeof BigInt>"u"?_i:h}function _i(){throw new Error("BigInt not supported")}}(Mi)),Mi}var nu=Wf();function wi(r){return new Promise((t,e)=>{r.oncomplete=r.onsuccess=()=>t(r.result),r.onabort=r.onerror=()=>e(r.error)})}function iu(r,t){const e=indexedDB.open(r);e.onupgradeneeded=()=>e.result.createObjectStore(t);const n=wi(e);return(o,i)=>n.then(a=>i(a.transaction(t,o).objectStore(t)))}let Fi;function Ms(){return Fi||(Fi=iu("keyval-store","keyval")),Fi}function Zf(r,t=Ms()){return t("readonly",e=>wi(e.get(r)))}function Gf(r,t,e=Ms()){return e("readwrite",n=>(n.put(t,r),wi(n.transaction)))}function Ni(r,t=Ms()){return t("readwrite",e=>(e.delete(r),wi(e.transaction)))}function bn(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ki={exports:{}},Co;function Yf(){return Co||(Co=1,function(r,t){(function(e){r.exports=e()})(function(){return function e(n,o,i){function a(p,g){if(!o[p]){if(!n[p]){var v=typeof bn=="function"&&bn;if(!g&&v)return v(p,!0);if(c)return c(p,!0);throw new Error("Cannot find module '"+p+"'")}g=o[p]={exports:{}},n[p][0].call(g.exports,function(C){var F=n[p][1][C];return a(F||C)},g,g.exports,e,n,o,i)}return o[p].exports}for(var c=typeof bn=="function"&&bn,f=0;f<i.length;f++)a(i[f]);return a}({1:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){var T=e("crypto");function U(A,O){O=P(A,O);var m;return(m=O.algorithm!=="passthrough"?T.createHash(O.algorithm):new G).write===void 0&&(m.write=m.update,m.end=m.update),V(O,m).dispatch(A),m.update||m.end(""),m.digest?m.digest(O.encoding==="buffer"?void 0:O.encoding):(A=m.read(),O.encoding!=="buffer"?A.toString(O.encoding):A)}(o=n.exports=U).sha1=function(A){return U(A)},o.keys=function(A){return U(A,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},o.MD5=function(A){return U(A,{algorithm:"md5",encoding:"hex"})},o.keysMD5=function(A){return U(A,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var M=T.getHashes?T.getHashes().slice():["sha1","md5"],k=(M.push("passthrough"),["buffer","hex","binary","base64"]);function P(A,O){var m={};if(m.algorithm=(O=O||{}).algorithm||"sha1",m.encoding=O.encoding||"hex",m.excludeValues=!!O.excludeValues,m.algorithm=m.algorithm.toLowerCase(),m.encoding=m.encoding.toLowerCase(),m.ignoreUnknown=O.ignoreUnknown===!0,m.respectType=O.respectType!==!1,m.respectFunctionNames=O.respectFunctionNames!==!1,m.respectFunctionProperties=O.respectFunctionProperties!==!1,m.unorderedArrays=O.unorderedArrays===!0,m.unorderedSets=O.unorderedSets!==!1,m.unorderedObjects=O.unorderedObjects!==!1,m.replacer=O.replacer||void 0,m.excludeKeys=O.excludeKeys||void 0,A===void 0)throw new Error("Object argument required.");for(var S=0;S<M.length;++S)M[S].toLowerCase()===m.algorithm.toLowerCase()&&(m.algorithm=M[S]);if(M.indexOf(m.algorithm)===-1)throw new Error('Algorithm "'+m.algorithm+'" not supported. supported values: '+M.join(", "));if(k.indexOf(m.encoding)===-1&&m.algorithm!=="passthrough")throw new Error('Encoding "'+m.encoding+'" not supported. supported values: '+k.join(", "));return m}function R(A){if(typeof A=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(A))!=null}function V(A,O,m){m=m||[];function S(w){return O.update?O.update(w,"utf8"):O.write(w,"utf8")}return{dispatch:function(w){return this["_"+((w=A.replacer?A.replacer(w):w)===null?"null":typeof w)](w)},_object:function(w){var B,N=Object.prototype.toString.call(w),Q=/\[object (.*)\]/i.exec(N);if(Q=(Q=Q?Q[1]:"unknown:["+N+"]").toLowerCase(),0<=(N=m.indexOf(w)))return this.dispatch("[CIRCULAR:"+N+"]");if(m.push(w),c!==void 0&&c.isBuffer&&c.isBuffer(w))return S("buffer:"),S(w);if(Q==="object"||Q==="function"||Q==="asyncfunction")return N=Object.keys(w),A.unorderedObjects&&(N=N.sort()),A.respectType===!1||R(w)||N.splice(0,0,"prototype","__proto__","constructor"),A.excludeKeys&&(N=N.filter(function(z){return!A.excludeKeys(z)})),S("object:"+N.length+":"),B=this,N.forEach(function(z){B.dispatch(z),S(":"),A.excludeValues||B.dispatch(w[z]),S(",")});if(!this["_"+Q]){if(A.ignoreUnknown)return S("["+Q+"]");throw new Error('Unknown object type "'+Q+'"')}this["_"+Q](w)},_array:function(w,z){z=z!==void 0?z:A.unorderedArrays!==!1;var N=this;if(S("array:"+w.length+":"),!z||w.length<=1)return w.forEach(function(L){return N.dispatch(L)});var Q=[],z=w.map(function(L){var D=new G,Y=m.slice();return V(A,D,Y).dispatch(L),Q=Q.concat(Y.slice(m.length)),D.read().toString()});return m=m.concat(Q),z.sort(),this._array(z,!1)},_date:function(w){return S("date:"+w.toJSON())},_symbol:function(w){return S("symbol:"+w.toString())},_error:function(w){return S("error:"+w.toString())},_boolean:function(w){return S("bool:"+w.toString())},_string:function(w){S("string:"+w.length+":"),S(w.toString())},_function:function(w){S("fn:"),R(w)?this.dispatch("[native]"):this.dispatch(w.toString()),A.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(w.name)),A.respectFunctionProperties&&this._object(w)},_number:function(w){return S("number:"+w.toString())},_xml:function(w){return S("xml:"+w.toString())},_null:function(){return S("Null")},_undefined:function(){return S("Undefined")},_regexp:function(w){return S("regex:"+w.toString())},_uint8array:function(w){return S("uint8array:"),this.dispatch(Array.prototype.slice.call(w))},_uint8clampedarray:function(w){return S("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(w))},_int8array:function(w){return S("int8array:"),this.dispatch(Array.prototype.slice.call(w))},_uint16array:function(w){return S("uint16array:"),this.dispatch(Array.prototype.slice.call(w))},_int16array:function(w){return S("int16array:"),this.dispatch(Array.prototype.slice.call(w))},_uint32array:function(w){return S("uint32array:"),this.dispatch(Array.prototype.slice.call(w))},_int32array:function(w){return S("int32array:"),this.dispatch(Array.prototype.slice.call(w))},_float32array:function(w){return S("float32array:"),this.dispatch(Array.prototype.slice.call(w))},_float64array:function(w){return S("float64array:"),this.dispatch(Array.prototype.slice.call(w))},_arraybuffer:function(w){return S("arraybuffer:"),this.dispatch(new Uint8Array(w))},_url:function(w){return S("url:"+w.toString())},_map:function(w){return S("map:"),w=Array.from(w),this._array(w,A.unorderedSets!==!1)},_set:function(w){return S("set:"),w=Array.from(w),this._array(w,A.unorderedSets!==!1)},_file:function(w){return S("file:"),this.dispatch([w.name,w.size,w.type,w.lastModfied])},_blob:function(){if(A.ignoreUnknown)return S("[blob]");throw Error(`Hashing Blob objects is currently not supported
4
+ ]`}concat(...t){const e=this.schema,n=this.data.concat(t.flatMap(({data:s})=>s));return new le(e,n.map(s=>new ye(e,s)))}slice(t,e){const n=this.schema;[t,e]=Yc({length:this.numRows},t,e);const s=Kc(this.data,this._offsets,t,e);return new le(n,s.map(i=>new ye(n,i)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){const e=this.data.map(n=>n.children[t]);if(e.length===0){const{type:n}=this.schema.fields[t],s=_t({type:n,length:0,nullCount:0});e.push(s._changeLengthAndBackfillNullBitmap(this.numRows))}return new Ft(e)}return null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(s=>s.name===t),e)}setChildAt(t,e){let n=this.schema,s=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new Ft([_t({type:new Je,length:this.numRows})]));const i=n.fields.slice(),a=i[t].clone({type:e.type}),c=this.schema.fields.map((d,f)=>this.getChildAt(f));[i[t],c[t]]=[a,e],[n,s]=Ci(n,c)}return new le(n,s)}select(t){const e=this.schema.fields.reduce((n,s,i)=>n.set(s.name,i),new Map);return this.selectAt(t.map(n=>e.get(n)).filter(n=>n>-1))}selectAt(t){const e=this.schema.selectAt(t),n=this.batches.map(s=>s.selectAt(t));return new le(e,n)}assign(t){const e=this.schema.fields,[n,s]=t.schema.fields.reduce((c,d,f)=>{const[y,B]=c,L=e.findIndex(x=>x.name===d.name);return~L?B[L]=f:y.push(f),c},[[],[]]),i=this.schema.assign(t.schema),a=[...e.map((c,d)=>[d,s[d]]).map(([c,d])=>d===void 0?this.getChildAt(c):t.getChildAt(d)),...n.map(c=>t.getChildAt(c))].filter(Boolean);return new le(...Ci(i,a))}}au=Symbol.toStringTag;le[au]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=ai(ks),r.get=ai(ne.getVisitFn(E.Struct)),r.set=Xc(fe.getVisitFn(E.Struct)),r.indexOf=Qc(ci.getVisitFn(E.Struct)),"Table"))(le.prototype);var cu;let ye=class on{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof vt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=_t({nullCount:0,type:new Kt(this.schema.fields),children:this.schema.fields.map(e=>_t({type:e.type,nullCount:0}))})]=t,!(this.data instanceof Et))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=To(this.schema,this.data.children);break}case 1:{const[e]=t,{fields:n,children:s,length:i}=Object.keys(e).reduce((d,f,y)=>(d.children[y]=e[f],d.length=Math.max(d.length,e[f].length),d.fields[y]=Ct.new({name:f,type:e[f].type,nullable:!0}),d),{length:0,fields:new Array,children:new Array}),a=new vt(n),c=_t({type:new Kt(n),length:i,children:s,nullCount:0});[this.schema,this.data]=To(a,c.children,i);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=uu(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 ne.visit(this.data,t)}at(t){return this.get(Ns(t,this.numRows))}set(t,e){return fe.visit(this.data,t,e)}indexOf(t,e){return ci.visit(this.data,t,e)}[Symbol.iterator](){return Ds.visit(new Ft([this.data]))}toArray(){return[...this]}concat(...t){return new le(this.schema,[this,...t])}slice(t,e){const[n]=new Ft([this.data]).slice(t,e).data;return new on(this.schema,n)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new Ft([this.data.children[t]]):null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(s=>s.name===t),e)}setChildAt(t,e){let n=this.schema,s=this.data;if(t>-1&&t<this.numCols){e||(e=new Ft([_t({type:new Je,length:this.numRows})]));const i=n.fields.slice(),a=s.children.slice(),c=i[t].clone({type:e.type});[i[t],a[t]]=[c,e.data[0]],n=new vt(i,new Map(this.schema.metadata)),s=_t({type:new Kt(i),children:a})}return new on(n,s)}select(t){const e=this.schema.select(t),n=new Kt(e.fields),s=[];for(const i of t){const a=this.schema.fields.findIndex(c=>c.name===i);~a&&(s[a]=this.data.children[a])}return new on(e,_t({type:n,length:this.numRows,children:s}))}selectAt(t){const e=this.schema.selectAt(t),n=t.map(i=>this.data.children[i]).filter(Boolean),s=_t({type:new Kt(e.fields),length:this.numRows,children:n});return new on(e,s)}};cu=Symbol.toStringTag;ye[cu]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(ye.prototype);function To(r,t,e=t.reduce((n,s)=>Math.max(n,s.length),0)){var n;const s=[...r.fields],i=[...t],a=(e+63&-64)>>3;for(const[c,d]of r.fields.entries()){const f=t[c];(!f||f.length!==e)&&(s[c]=d.clone({nullable:!0}),i[c]=(n=f?._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:_t({type:d.type,length:e,nullCount:e,nullBitmap:new Uint8Array(a)}))}return[r.assign(s),_t({type:new Kt(s),length:e,children:i})]}function uu(r,t,e=new Map){var n,s;if(((n=r?.length)!==null&&n!==void 0?n:0)>0&&r?.length===t?.length)for(let i=-1,a=r.length;++i<a;){const{type:c}=r[i],d=t[i];for(const f of[d,...((s=d?.dictionary)===null||s===void 0?void 0:s.data)||[]])uu(c.children,f?.children,e);if(tt.isDictionary(c)){const{id:f}=c;if(!e.has(f))d?.dictionary&&e.set(f,d.dictionary);else if(e.get(f)!==d.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}class hu extends ye{constructor(t){const e=t.fields.map(s=>_t({type:s.type})),n=_t({type:new Kt(t.fields),nullCount:0,children:e});super(t,n)}}let je=class _e{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 _e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+xt),(e||new _e).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):zt.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):Bt.NONE}header(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,12);return n?(e||new jt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){const 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,zt.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,Bt.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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,n,s,i,a){return _e.startMessage(t),_e.addVersion(t,e),_e.addHeaderType(t,n),_e.addHeader(t,s),_e.addBodyLength(t,i),_e.addCustomMetadata(t,a),_e.endMessage(t)}};class xd extends St{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return wo.startNull(e),wo.endNull(e)}visitInt(t,e){return oe.startInt(e),oe.addBitWidth(e,t.bitWidth),oe.addIsSigned(e,t.isSigned),oe.endInt(e)}visitFloat(t,e){return ve.startFloatingPoint(e),ve.addPrecision(e,t.precision),ve.endFloatingPoint(e)}visitBinary(t,e){return fo.startBinary(e),fo.endBinary(e)}visitLargeBinary(t,e){return yo.startLargeBinary(e),yo.endLargeBinary(e)}visitBool(t,e){return po.startBool(e),po.endBool(e)}visitUtf8(t,e){return bo.startUtf8(e),bo.endUtf8(e)}visitLargeUtf8(t,e){return go.startLargeUtf8(e),go.endLargeUtf8(e)}visitDecimal(t,e){return ur.startDecimal(e),ur.addScale(e,t.scale),ur.addPrecision(e,t.precision),ur.addBitWidth(e,t.bitWidth),ur.endDecimal(e)}visitDate(t,e){return Nn.startDate(e),Nn.addUnit(e,t.unit),Nn.endDate(e)}visitTime(t,e){return ue.startTime(e),ue.addUnit(e,t.unit),ue.addBitWidth(e,t.bitWidth),ue.endTime(e)}visitTimestamp(t,e){const n=t.timezone&&e.createString(t.timezone)||void 0;return he.startTimestamp(e),he.addUnit(e,t.unit),n!==void 0&&he.addTimezone(e,n),he.endTimestamp(e)}visitInterval(t,e){return xe.startInterval(e),xe.addUnit(e,t.unit),xe.endInterval(e)}visitDuration(t,e){return Fn.startDuration(e),Fn.addUnit(e,t.unit),Fn.endDuration(e)}visitList(t,e){return mo.startList(e),mo.endList(e)}visitStruct(t,e){return Qe.startStruct_(e),Qe.endStruct_(e)}visitUnion(t,e){ee.startTypeIdsVector(e,t.typeIds.length);const n=ee.createTypeIdsVector(e,t.typeIds);return ee.startUnion(e),ee.addMode(e,t.mode),ee.addTypeIds(e,n),ee.endUnion(e)}visitDictionary(t,e){const n=this.visit(t.indices,e);return De.startDictionaryEncoding(e),De.addId(e,BigInt(t.id)),De.addIsOrdered(e,t.isOrdered),n!==void 0&&De.addIndexType(e,n),De.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return On.startFixedSizeBinary(e),On.addByteWidth(e,t.byteWidth),On.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return kn.startFixedSizeList(e),kn.addListSize(e,t.listSize),kn.endFixedSizeList(e)}visitMap(t,e){return Dn.startMap(e),Dn.addKeysSorted(e,t.keysSorted),Dn.endMap(e)}}const Ri=new xd;function Ad(r,t=new Map){return new vt(Td(r,t),Ln(r.metadata),t)}function lu(r){return new we(r.count,du(r.columns),fu(r.columns))}function Ed(r){return new Ce(lu(r.data),r.id,r.isDelta)}function Td(r,t){return(r.fields||[]).filter(Boolean).map(e=>Ct.fromJSON(e,t))}function Mo(r,t){return(r.children||[]).filter(Boolean).map(e=>Ct.fromJSON(e,t))}function du(r){return(r||[]).reduce((t,e)=>[...t,new kr(e.count,Md(e.VALIDITY)),...du(e.children)],[])}function fu(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){const s=r[e];s.VALIDITY&&t.push(new Ue(t.length,s.VALIDITY.length)),s.TYPE_ID&&t.push(new Ue(t.length,s.TYPE_ID.length)),s.OFFSET&&t.push(new Ue(t.length,s.OFFSET.length)),s.DATA&&t.push(new Ue(t.length,s.DATA.length)),t=fu(s.children,t)}return t}function Md(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function Nd(r,t){let e,n,s,i,a,c;return!t||!(i=r.dictionary)?(a=Fo(r,Mo(r,t)),s=new Ct(r.name,a,r.nullable,Ln(r.metadata))):t.has(e=i.id)?(n=(n=i.indexType)?No(n):new fn,c=new Er(t.get(e),n,e,i.isOrdered),s=new Ct(r.name,c,r.nullable,Ln(r.metadata))):(n=(n=i.indexType)?No(n):new fn,t.set(e,a=Fo(r,Mo(r,t))),c=new Er(a,n,e,i.isOrdered),s=new Ct(r.name,c,r.nullable,Ln(r.metadata))),s||null}function Ln(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function No(r){return new er(r.isSigned,r.bitWidth)}function Fo(r,t){const e=r.type.name;switch(e){case"NONE":return new Je;case"null":return new Je;case"binary":return new Zn;case"largebinary":return new Gn;case"utf8":return new Yn;case"largeutf8":return new Jn;case"bool":return new Hn;case"list":return new ri((t||[])[0]);case"struct":return new Kt(t||[]);case"struct_":return new Kt(t||[])}switch(e){case"int":{const n=r.type;return new er(n.isSigned,n.bitWidth)}case"floatingpoint":{const n=r.type;return new Wn(Jt[n.precision])}case"decimal":{const n=r.type;return new qn(n.scale,n.precision,n.bitWidth)}case"date":{const n=r.type;return new Kn(de[n.unit])}case"time":{const n=r.type;return new Xn(at[n.unit],n.bitWidth)}case"timestamp":{const n=r.type;return new Qn(at[n.unit],n.timezone)}case"interval":{const n=r.type;return new ti(Te[n.unit])}case"duration":{const n=r.type;return new ei(at[n.unit])}case"union":{const n=r.type,[s,...i]=(n.mode+"").toLowerCase(),a=s.toUpperCase()+i.join("");return new ni(re[a],n.typeIds||[],t||[])}case"fixedsizebinary":{const n=r.type;return new ii(n.byteWidth)}case"fixedsizelist":{const n=r.type;return new si(n.listSize,(t||[])[0])}case"map":{const n=r.type;return new oi((t||[])[0],n.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var Fd=Ea,Od=xr;class ge{static fromJSON(t,e){const n=new ge(0,zt.V5,e);return n._createHeader=kd(t,e),n}static decode(t){t=new Od(It(t));const e=je.getRootAsMessage(t),n=e.bodyLength(),s=e.version(),i=e.headerType(),a=new ge(n,s,i);return a._createHeader=Dd(e,i),a}static encode(t){const e=new Fd;let n=-1;return t.isSchema()?n=vt.encode(e,t.header()):t.isRecordBatch()?n=we.encode(e,t.header()):t.isDictionaryBatch()&&(n=Ce.encode(e,t.header())),je.startMessage(e),je.addVersion(e,zt.V5),je.addHeader(e,n),je.addHeaderType(e,t.headerType),je.addBodyLength(e,BigInt(t.bodyLength)),je.finishMessageBuffer(e,je.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof vt)return new ge(0,zt.V5,Bt.Schema,t);if(t instanceof we)return new ge(e,zt.V5,Bt.RecordBatch,t);if(t instanceof Ce)return new ge(e,zt.V5,Bt.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===Bt.Schema}isRecordBatch(){return this.headerType===Bt.RecordBatch}isDictionaryBatch(){return this.headerType===Bt.DictionaryBatch}constructor(t,e,n,s){this._version=e,this._headerType=n,this.body=new Uint8Array(0),s&&(this._createHeader=()=>s),this._bodyLength=Lt(t)}}class we{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,n){this._nodes=e,this._buffers=n,this._length=Lt(t)}}class Ce{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,n=!1){this._data=t,this._isDelta=n,this._id=Lt(e)}}class Ue{constructor(t,e){this.offset=Lt(t),this.length=Lt(e)}}class kr{constructor(t,e){this.length=Lt(t),this.nullCount=Lt(e)}}function kd(r,t){return()=>{switch(t){case Bt.Schema:return vt.fromJSON(r);case Bt.RecordBatch:return we.fromJSON(r);case Bt.DictionaryBatch:return Ce.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${Bt[t]}, type: ${t} }`)}}function Dd(r,t){return()=>{switch(t){case Bt.Schema:return vt.decode(r.header(new Se),new Map,r.version());case Bt.RecordBatch:return we.decode(r.header(new Ne),r.version());case Bt.DictionaryBatch:return Ce.decode(r.header(new ar),r.version())}throw new Error(`Unrecognized Message type: { name: ${Bt[t]}, type: ${t} }`)}}Ct.encode=Zd;Ct.decode=Vd;Ct.fromJSON=Nd;vt.encode=Wd;vt.decode=Ud;vt.fromJSON=Ad;we.encode=Gd;we.decode=Ld;we.fromJSON=lu;Ce.encode=Yd;Ce.decode=Cd;Ce.fromJSON=Ed;kr.encode=Jd;kr.decode=Pd;Ue.encode=Hd;Ue.decode=Rd;function Ud(r,t=new Map,e=zt.V5){const n=jd(r,t);return new vt(n,Cn(r),t,e)}function Ld(r,t=zt.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new we(r.length(),$d(r),zd(r,t))}function Cd(r,t=zt.V5){return new Ce(we.decode(r.data(),t),r.id(),r.isDelta())}function Rd(r){return new Ue(r.offset(),r.length())}function Pd(r){return new kr(r.length(),r.nullCount())}function $d(r){const t=[];for(let e,n=-1,s=-1,i=r.nodesLength();++n<i;)(e=r.nodes(n))&&(t[++s]=kr.decode(e));return t}function zd(r,t){const e=[];for(let n,s=-1,i=-1,a=r.buffersLength();++s<a;)(n=r.buffers(s))&&(t<zt.V4&&(n.bb_pos+=8*(s+1)),e[++i]=Ue.decode(n));return e}function jd(r,t){const e=[];for(let n,s=-1,i=-1,a=r.fieldsLength();++s<a;)(n=r.fields(s))&&(e[++i]=Ct.decode(n,t));return e}function Oo(r,t){const e=[];for(let n,s=-1,i=-1,a=r.childrenLength();++s<a;)(n=r.children(s))&&(e[++i]=Ct.decode(n,t));return e}function Vd(r,t){let e,n,s,i,a,c;return!t||!(c=r.dictionary())?(s=Do(r,Oo(r,t)),n=new Ct(r.name(),s,r.nullable(),Cn(r))):t.has(e=Lt(c.id()))?(i=(i=c.indexType())?ko(i):new fn,a=new Er(t.get(e),i,e,c.isOrdered()),n=new Ct(r.name(),a,r.nullable(),Cn(r))):(i=(i=c.indexType())?ko(i):new fn,t.set(e,s=Do(r,Oo(r,t))),a=new Er(s,i,e,c.isOrdered()),n=new Ct(r.name(),a,r.nullable(),Cn(r))),n||null}function Cn(r){const t=new Map;if(r)for(let e,n,s=-1,i=Math.trunc(r.customMetadataLength());++s<i;)(e=r.customMetadata(s))&&(n=e.key())!=null&&t.set(n,e.value());return t}function ko(r){return new er(r.isSigned(),r.bitWidth())}function Do(r,t){const e=r.typeType();switch(e){case Dt.NONE:return new Je;case Dt.Null:return new Je;case Dt.Binary:return new Zn;case Dt.LargeBinary:return new Gn;case Dt.Utf8:return new Yn;case Dt.LargeUtf8:return new Jn;case Dt.Bool:return new Hn;case Dt.List:return new ri((t||[])[0]);case Dt.Struct_:return new Kt(t||[])}switch(e){case Dt.Int:{const n=r.type(new oe);return new er(n.isSigned(),n.bitWidth())}case Dt.FloatingPoint:{const n=r.type(new ve);return new Wn(n.precision())}case Dt.Decimal:{const n=r.type(new ur);return new qn(n.scale(),n.precision(),n.bitWidth())}case Dt.Date:{const n=r.type(new Nn);return new Kn(n.unit())}case Dt.Time:{const n=r.type(new ue);return new Xn(n.unit(),n.bitWidth())}case Dt.Timestamp:{const n=r.type(new he);return new Qn(n.unit(),n.timezone())}case Dt.Interval:{const n=r.type(new xe);return new ti(n.unit())}case Dt.Duration:{const n=r.type(new Fn);return new ei(n.unit())}case Dt.Union:{const n=r.type(new ee);return new ni(n.mode(),n.typeIdsArray()||[],t||[])}case Dt.FixedSizeBinary:{const n=r.type(new On);return new ii(n.byteWidth())}case Dt.FixedSizeList:{const n=r.type(new kn);return new si(n.listSize(),(t||[])[0])}case Dt.Map:{const n=r.type(new Dn);return new oi((t||[])[0],n.keysSorted())}}throw new Error(`Unrecognized type: "${Dt[e]}" (${e})`)}function Wd(r,t){const e=t.fields.map(i=>Ct.encode(r,i));Se.startFieldsVector(r,e.length);const n=Se.createFieldsVector(r,e),s=t.metadata&&t.metadata.size>0?Se.createCustomMetadataVector(r,[...t.metadata].map(([i,a])=>{const c=r.createString(`${i}`),d=r.createString(`${a}`);return jt.startKeyValue(r),jt.addKey(r,c),jt.addValue(r,d),jt.endKeyValue(r)})):-1;return Se.startSchema(r),Se.addFields(r,n),Se.addEndianness(r,qd?Ar.Little:Ar.Big),s!==-1&&Se.addCustomMetadata(r,s),Se.endSchema(r)}function Zd(r,t){let e=-1,n=-1,s=-1;const i=t.type;let a=t.typeId;tt.isDictionary(i)?(a=i.dictionary.typeId,s=Ri.visit(i,r),n=Ri.visit(i.dictionary,r)):n=Ri.visit(i,r);const c=(i.children||[]).map(y=>Ct.encode(r,y)),d=ae.createChildrenVector(r,c),f=t.metadata&&t.metadata.size>0?ae.createCustomMetadataVector(r,[...t.metadata].map(([y,B])=>{const L=r.createString(`${y}`),x=r.createString(`${B}`);return jt.startKeyValue(r),jt.addKey(r,L),jt.addValue(r,x),jt.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),ae.startField(r),ae.addType(r,n),ae.addTypeType(r,a),ae.addChildren(r,d),ae.addNullable(r,!!t.nullable),e!==-1&&ae.addName(r,e),s!==-1&&ae.addDictionary(r,s),f!==-1&&ae.addCustomMetadata(r,f),ae.endField(r)}function Gd(r,t){const e=t.nodes||[],n=t.buffers||[];Ne.startNodesVector(r,e.length);for(const a of e.slice().reverse())kr.encode(r,a);const s=r.endVector();Ne.startBuffersVector(r,n.length);for(const a of n.slice().reverse())Ue.encode(r,a);const i=r.endVector();return Ne.startRecordBatch(r),Ne.addLength(r,BigInt(t.length)),Ne.addNodes(r,s),Ne.addBuffers(r,i),Ne.endRecordBatch(r)}function Yd(r,t){const e=we.encode(r,t.data);return ar.startDictionaryBatch(r),ar.addId(r,BigInt(t.id)),ar.addIsDelta(r,t.isDelta),ar.addData(r,e),ar.endDictionaryBatch(r)}function Jd(r,t){return Na.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function Hd(r,t){return Ma.createBuffer(r,BigInt(t.offset),BigInt(t.length))}const qd=(()=>{const r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})(),$s=r=>`Expected ${Bt[r]} Message in stream, but was null or length 0.`,zs=r=>`Header pointer of flatbuffer-encoded ${Bt[r]} Message is null or length 0.`,pu=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,yu=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`;class gu{constructor(t){this.source=t instanceof hi?t:new hi(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done||t.value===-1&&(t=this.readMetadataLength()).done||(t=this.readMetadata(t.value)).done?Rt: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($s(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const e=It(this.source.read(t));if(e.byteLength<t)throw new Error(yu(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){const e=Bt.Schema,n=this.readMessage(e),s=n?.header();if(t&&!s)throw new Error(zs(e));return s}readMetadataLength(){const t=this.source.read(Ai),e=t&&new xr(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}}readMetadata(t){const e=this.source.read(t);if(!e)return Rt;if(e.byteLength<t)throw new Error(pu(t,e.byteLength));return{done:!1,value:ge.decode(e)}}}class Kd{constructor(t,e){this.source=t instanceof Mr?t:Sa(t)?new li(t,e):new Mr(t)}[Symbol.asyncIterator](){return this}next(){return gt(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done||t.value===-1&&(t=yield this.readMetadataLength()).done||(t=yield this.readMetadata(t.value)).done?Rt:t})}throw(t){return gt(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return gt(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return gt(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($s(t));return e.value})}readMessageBody(t){return gt(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);const e=It(yield this.source.read(t));if(e.byteLength<t)throw new Error(yu(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return gt(this,arguments,void 0,function*(t=!1){const e=Bt.Schema,n=yield this.readMessage(e),s=n?.header();if(t&&!s)throw new Error(zs(e));return s})}readMetadataLength(){return gt(this,void 0,void 0,function*(){const t=yield this.source.read(Ai),e=t&&new xr(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}})}readMetadata(t){return gt(this,void 0,void 0,function*(){const e=yield this.source.read(t);if(!e)return Rt;if(e.byteLength<t)throw new Error(pu(t,e.byteLength));return{done:!1,value:ge.decode(e)}})}}class Xd extends gu{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Ao?t:new Ao(t)}next(){const{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:ge.fromJSON(t.schema,Bt.Schema)};if(this._dictionaryIndex<t.dictionaries.length){const e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:ge.fromJSON(e,Bt.DictionaryBatch)}}if(this._batchIndex<t.batches.length){const e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:ge.fromJSON(e,Bt.RecordBatch)}}return this._body=[],Rt}readMessageBody(t){return e(this._body);function e(n){return(n||[]).reduce((s,i)=>[...s,...i.VALIDITY&&[i.VALIDITY]||[],...i.TYPE_ID&&[i.TYPE_ID]||[],...i.OFFSET&&[i.OFFSET]||[],...i.DATA&&[i.DATA]||[],...e(i.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error($s(t));return e.value}readSchema(){const t=Bt.Schema,e=this.readMessage(t),n=e?.header();if(!e||!n)throw new Error(zs(t));return n}}const Ai=4,cs="ARROW1",di=new Uint8Array(cs.length);for(let r=0;r<cs.length;r+=1)di[r]=cs.codePointAt(r);function js(r,t=0){for(let e=-1,n=di.length;++e<n;)if(di[e]!==r[t+e])return!1;return!0}const bn=di.length,mu=bn+Ai,Qd=bn*2+Ai;class Le extends iu{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){const e=this._impl.open(t);return un(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 ce.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return ce.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 Le?t:Xi(t)?nf(t):Sa(t)?af(t):un(t)?gt(this,void 0,void 0,function*(){return yield Le.from(yield t)}):Ia(t)||vs(t)||va(t)||Bs(t)?of(new Mr(t)):sf(new hi(t))}static readAll(t){return t instanceof Le?t.isSync()?Uo(t):Lo(t):Xi(t)||ArrayBuffer.isView(t)||Bi(t)||_a(t)?Uo(t):Lo(t)}}class fi extends Le{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Ae(this,arguments,function*(){yield wt(yield*Mn(br(this[Symbol.iterator]())))})}}class pi extends Le{constructor(t){super(t),this._impl=t}readAll(){return gt(this,void 0,void 0,function*(){var t,e,n,s;const i=new Array;try{for(var a=!0,c=br(this),d;d=yield c.next(),t=d.done,!t;a=!0){s=d.value,a=!1;const f=s;i.push(f)}}catch(f){e={error:f}}finally{try{!a&&!t&&(n=c.return)&&(yield n.call(c))}finally{if(e)throw e.error}}return i})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class wu extends fi{constructor(t){super(t),this._impl=t}}class tf extends pi{constructor(t){super(t),this._impl=t}}class bu{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){const n=this._loadVectors(t,e,this.schema.fields),s=_t({type:new Kt(this.schema.fields),length:t.length,children:n});return new ye(this.schema,s)}_loadDictionaryBatch(t,e){const{id:n,isDelta:s}=t,{dictionaries:i,schema:a}=this,c=i.get(n),d=a.dictionaries.get(n),f=this._loadVectors(t.data,e,[d]);return(c&&s?c.concat(new Ft(f)):new Ft(f)).memoize()}_loadVectors(t,e,n){return new ou(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}}class yi extends bu{constructor(t,e){super(e),this._reader=Xi(t)?new Xd(this._handle=t):new gu(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=Su(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):Rt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Rt}next(){if(this.closed)return Rt;let t;const{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const n=t.header(),s=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,s)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const n=t.header(),s=e.readMessageBody(t.bodyLength),i=this._loadDictionaryBatch(n,s);this.dictionaries.set(n.id,i)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new hu(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class gi extends bu{constructor(t,e){super(e),this._reader=new Kd(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return gt(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 gt(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Su(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return gt(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):Rt})}return(t){return gt(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Rt})}next(){return gt(this,void 0,void 0,function*(){if(this.closed)return Rt;let t;const{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const n=t.header(),s=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,s)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const n=t.header(),s=yield e.readMessageBody(t.bodyLength),i=this._loadDictionaryBatch(n,s);this.dictionaries.set(n.id,i)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new hu(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return gt(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class _u extends yi{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 Eo?t:new Eo(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const 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();const n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){const s=this._reader.readMessage(Bt.RecordBatch);if(s?.isRecordBatch()){const i=s.header(),a=this._reader.readMessageBody(s.bodyLength);return this._loadRecordBatch(i,a)}}return null}_readDictionaryBatch(t){var e;const n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){const s=this._reader.readMessage(Bt.DictionaryBatch);if(s?.isDictionaryBatch()){const i=s.header(),a=this._reader.readMessageBody(s.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}}}_readFooter(){const{_handle:t}=this,e=t.size-mu,n=t.readInt32(e),s=t.readAt(e-n,n);return Us.decode(s)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){const n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(n&&this._handle.seek(n.offset))return this._reader.readMessage(t)}return null}}class ef extends gi{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){const n=typeof e[0]!="number"?e.shift():void 0,s=e[0]instanceof Map?e.shift():void 0;super(t instanceof li?t:new li(t,n),s)}isFile(){return!0}isAsync(){return!0}open(t){const e=Object.create(null,{open:{get:()=>super.open}});return gt(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return gt(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());const n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){const s=yield this._reader.readMessage(Bt.RecordBatch);if(s?.isRecordBatch()){const i=s.header(),a=yield this._reader.readMessageBody(s.bodyLength);return this._loadRecordBatch(i,a)}}return null})}_readDictionaryBatch(t){return gt(this,void 0,void 0,function*(){var e;const n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){const s=yield this._reader.readMessage(Bt.DictionaryBatch);if(s?.isDictionaryBatch()){const i=s.header(),a=yield this._reader.readMessageBody(s.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}}})}_readFooter(){return gt(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const e=t.size-mu,n=yield t.readInt32(e),s=yield t.readAt(e-n,n);return Us.decode(s)})}_readNextMessageAndValidate(t){return gt(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){const e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}}class rf extends yi{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new pd(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}}function Su(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Uo(r){const t=Le.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Lo(r){return Ae(this,arguments,function*(){const e=yield wt(Le.from(r));try{if(!(yield wt(e.open({autoDestroy:!1}))).closed)do yield yield wt(e);while(!(yield wt(e.reset().open())).closed)}finally{yield wt(e.cancel())}})}function nf(r){return new fi(new rf(r))}function sf(r){const t=r.peek(bn+7&-8);return t&&t.byteLength>=4?js(t)?new wu(new _u(r.read())):new fi(new yi(r)):new fi(new yi(function*(){}()))}function of(r){return gt(this,void 0,void 0,function*(){const t=yield r.peek(bn+7&-8);return t&&t.byteLength>=4?js(t)?new wu(new _u(yield r.read())):new pi(new gi(r)):new pi(new gi(function(){return Ae(this,arguments,function*(){})}()))})}function af(r){return gt(this,void 0,void 0,function*(){const{size:t}=yield r.stat(),e=new li(r,t);return t>=Qd&&js(yield e.readAt(0,bn+7&-8))?new tf(new ef(e)):new pi(new gi(e))})}function Iu(r){const t=Le.from(r);return un(t)?t.then(e=>Iu(e)):t.isAsync()?t.readAll().then(e=>new le(e)):new le(t.readAll())}function Vs(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Pi={},Ur={},$i={},Lr={},Co;function Bu(){if(Co)return Lr;Co=1,Lr.byteLength=c,Lr.toByteArray=f,Lr.fromByteArray=L;for(var r=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,i=n.length;s<i;++s)r[s]=n[s],t[n.charCodeAt(s)]=s;t[45]=62,t[95]=63;function a(x){var M=x.length;if(M%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var U=x.indexOf("=");U===-1&&(U=M);var F=U===M?0:4-U%4;return[U,F]}function c(x){var M=a(x),U=M[0],F=M[1];return(U+F)*3/4-F}function d(x,M,U){return(M+U)*3/4-U}function f(x){var M,U=a(x),F=U[0],O=U[1],C=new e(d(x,F,O)),P=0,V=O>0?F-4:F,G;for(G=0;G<V;G+=4)M=t[x.charCodeAt(G)]<<18|t[x.charCodeAt(G+1)]<<12|t[x.charCodeAt(G+2)]<<6|t[x.charCodeAt(G+3)],C[P++]=M>>16&255,C[P++]=M>>8&255,C[P++]=M&255;return O===2&&(M=t[x.charCodeAt(G)]<<2|t[x.charCodeAt(G+1)]>>4,C[P++]=M&255),O===1&&(M=t[x.charCodeAt(G)]<<10|t[x.charCodeAt(G+1)]<<4|t[x.charCodeAt(G+2)]>>2,C[P++]=M>>8&255,C[P++]=M&255),C}function y(x){return r[x>>18&63]+r[x>>12&63]+r[x>>6&63]+r[x&63]}function B(x,M,U){for(var F,O=[],C=M;C<U;C+=3)F=(x[C]<<16&16711680)+(x[C+1]<<8&65280)+(x[C+2]&255),O.push(y(F));return O.join("")}function L(x){for(var M,U=x.length,F=U%3,O=[],C=16383,P=0,V=U-F;P<V;P+=C)O.push(B(x,P,P+C>V?V:P+C));return F===1?(M=x[U-1],O.push(r[M>>2]+r[M<<4&63]+"==")):F===2&&(M=(x[U-2]<<8)+x[U-1],O.push(r[M>>10]+r[M>>4&63]+r[M<<2&63]+"=")),O.join("")}return Lr}var vn={};var Ro;function vu(){return Ro||(Ro=1,vn.read=function(r,t,e,n,s){var i,a,c=s*8-n-1,d=(1<<c)-1,f=d>>1,y=-7,B=e?s-1:0,L=e?-1:1,x=r[t+B];for(B+=L,i=x&(1<<-y)-1,x>>=-y,y+=c;y>0;i=i*256+r[t+B],B+=L,y-=8);for(a=i&(1<<-y)-1,i>>=-y,y+=n;y>0;a=a*256+r[t+B],B+=L,y-=8);if(i===0)i=1-f;else{if(i===d)return a?NaN:(x?-1:1)*(1/0);a=a+Math.pow(2,n),i=i-f}return(x?-1:1)*a*Math.pow(2,i-n)},vn.write=function(r,t,e,n,s,i){var a,c,d,f=i*8-s-1,y=(1<<f)-1,B=y>>1,L=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:i-1,M=n?1:-1,U=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,a=y):(a=Math.floor(Math.log(t)/Math.LN2),t*(d=Math.pow(2,-a))<1&&(a--,d*=2),a+B>=1?t+=L/d:t+=L*Math.pow(2,1-B),t*d>=2&&(a++,d/=2),a+B>=y?(c=0,a=y):a+B>=1?(c=(t*d-1)*Math.pow(2,s),a=a+B):(c=t*Math.pow(2,B-1)*Math.pow(2,s),a=0));s>=8;r[e+x]=c&255,x+=M,c/=256,s-=8);for(a=a<<s|c,f+=s;f>0;r[e+x]=a&255,x+=M,a/=256,f-=8);r[e+x-M]|=U*128}),vn}var Po;function Ws(){return Po||(Po=1,function(r){const t=Bu(),e=vu(),n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=c,r.SlowBuffer=C,r.INSPECT_MAX_BYTES=50;const s=2147483647;r.kMaxLength=s,c.TYPED_ARRAY_SUPPORT=i(),!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{const h=new Uint8Array(1),o={foo:function(){return 42}};return Object.setPrototypeOf(o,Uint8Array.prototype),Object.setPrototypeOf(h,o),h.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function a(h){if(h>s)throw new RangeError('The value "'+h+'" is invalid for option "size"');const o=new Uint8Array(h);return Object.setPrototypeOf(o,c.prototype),o}function c(h,o,u){if(typeof h=="number"){if(typeof o=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(h)}return d(h,o,u)}c.poolSize=8192;function d(h,o,u){if(typeof h=="string")return L(h,o);if(ArrayBuffer.isView(h))return M(h);if(h==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h);if(mt(h,ArrayBuffer)||h&&mt(h.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(mt(h,SharedArrayBuffer)||h&&mt(h.buffer,SharedArrayBuffer)))return U(h,o,u);if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const l=h.valueOf&&h.valueOf();if(l!=null&&l!==h)return c.from(l,o,u);const p=F(h);if(p)return p;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof h[Symbol.toPrimitive]=="function")return c.from(h[Symbol.toPrimitive]("string"),o,u);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h)}c.from=function(h,o,u){return d(h,o,u)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array);function f(h){if(typeof h!="number")throw new TypeError('"size" argument must be of type number');if(h<0)throw new RangeError('The value "'+h+'" is invalid for option "size"')}function y(h,o,u){return f(h),h<=0?a(h):o!==void 0?typeof u=="string"?a(h).fill(o,u):a(h).fill(o):a(h)}c.alloc=function(h,o,u){return y(h,o,u)};function B(h){return f(h),a(h<0?0:O(h)|0)}c.allocUnsafe=function(h){return B(h)},c.allocUnsafeSlow=function(h){return B(h)};function L(h,o){if((typeof o!="string"||o==="")&&(o="utf8"),!c.isEncoding(o))throw new TypeError("Unknown encoding: "+o);const u=P(h,o)|0;let l=a(u);const p=l.write(h,o);return p!==u&&(l=l.slice(0,p)),l}function x(h){const o=h.length<0?0:O(h.length)|0,u=a(o);for(let l=0;l<o;l+=1)u[l]=h[l]&255;return u}function M(h){if(mt(h,Uint8Array)){const o=new Uint8Array(h);return U(o.buffer,o.byteOffset,o.byteLength)}return x(h)}function U(h,o,u){if(o<0||h.byteLength<o)throw new RangeError('"offset" is outside of buffer bounds');if(h.byteLength<o+(u||0))throw new RangeError('"length" is outside of buffer bounds');let l;return o===void 0&&u===void 0?l=new Uint8Array(h):u===void 0?l=new Uint8Array(h,o):l=new Uint8Array(h,o,u),Object.setPrototypeOf(l,c.prototype),l}function F(h){if(c.isBuffer(h)){const o=O(h.length)|0,u=a(o);return u.length===0||h.copy(u,0,0,o),u}if(h.length!==void 0)return typeof h.length!="number"||Qt(h.length)?a(0):x(h);if(h.type==="Buffer"&&Array.isArray(h.data))return x(h.data)}function O(h){if(h>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return h|0}function C(h){return+h!=h&&(h=0),c.alloc(+h)}c.isBuffer=function(o){return o!=null&&o._isBuffer===!0&&o!==c.prototype},c.compare=function(o,u){if(mt(o,Uint8Array)&&(o=c.from(o,o.offset,o.byteLength)),mt(u,Uint8Array)&&(u=c.from(u,u.offset,u.byteLength)),!c.isBuffer(o)||!c.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(o===u)return 0;let l=o.length,p=u.length;for(let b=0,I=Math.min(l,p);b<I;++b)if(o[b]!==u[b]){l=o[b],p=u[b];break}return l<p?-1:p<l?1:0},c.isEncoding=function(o){switch(String(o).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(o,u){if(!Array.isArray(o))throw new TypeError('"list" argument must be an Array of Buffers');if(o.length===0)return c.alloc(0);let l;if(u===void 0)for(u=0,l=0;l<o.length;++l)u+=o[l].length;const p=c.allocUnsafe(u);let b=0;for(l=0;l<o.length;++l){let I=o[l];if(mt(I,Uint8Array))b+I.length>p.length?(c.isBuffer(I)||(I=c.from(I)),I.copy(p,b)):Uint8Array.prototype.set.call(p,I,b);else if(c.isBuffer(I))I.copy(p,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=I.length}return p};function P(h,o){if(c.isBuffer(h))return h.length;if(ArrayBuffer.isView(h)||mt(h,ArrayBuffer))return h.byteLength;if(typeof h!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof h);const u=h.length,l=arguments.length>2&&arguments[2]===!0;if(!l&&u===0)return 0;let p=!1;for(;;)switch(o){case"ascii":case"latin1":case"binary":return u;case"utf8":case"utf-8":return kt(h).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u*2;case"hex":return u>>>1;case"base64":return $t(h).length;default:if(p)return l?-1:kt(h).length;o=(""+o).toLowerCase(),p=!0}}c.byteLength=P;function V(h,o,u){let l=!1;if((o===void 0||o<0)&&(o=0),o>this.length||((u===void 0||u>this.length)&&(u=this.length),u<=0)||(u>>>=0,o>>>=0,u<=o))return"";for(h||(h="utf8");;)switch(h){case"hex":return X(this,o,u);case"utf8":case"utf-8":return z(this,o,u);case"ascii":return Y(this,o,u);case"latin1":case"binary":return Z(this,o,u);case"base64":return Q(this,o,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return K(this,o,u);default:if(l)throw new TypeError("Unknown encoding: "+h);h=(h+"").toLowerCase(),l=!0}}c.prototype._isBuffer=!0;function G(h,o,u){const l=h[o];h[o]=h[u],h[u]=l}c.prototype.swap16=function(){const o=this.length;if(o%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let u=0;u<o;u+=2)G(this,u,u+1);return this},c.prototype.swap32=function(){const o=this.length;if(o%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let u=0;u<o;u+=4)G(this,u,u+3),G(this,u+1,u+2);return this},c.prototype.swap64=function(){const o=this.length;if(o%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let u=0;u<o;u+=8)G(this,u,u+7),G(this,u+1,u+6),G(this,u+2,u+5),G(this,u+3,u+4);return this},c.prototype.toString=function(){const o=this.length;return o===0?"":arguments.length===0?z(this,0,o):V.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(o){if(!c.isBuffer(o))throw new TypeError("Argument must be a Buffer");return this===o?!0:c.compare(this,o)===0},c.prototype.inspect=function(){let o="";const u=r.INSPECT_MAX_BYTES;return o=this.toString("hex",0,u).replace(/(.{2})/g,"$1 ").trim(),this.length>u&&(o+=" ... "),"<Buffer "+o+">"},n&&(c.prototype[n]=c.prototype.inspect),c.prototype.compare=function(o,u,l,p,b){if(mt(o,Uint8Array)&&(o=c.from(o,o.offset,o.byteLength)),!c.isBuffer(o))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof o);if(u===void 0&&(u=0),l===void 0&&(l=o?o.length:0),p===void 0&&(p=0),b===void 0&&(b=this.length),u<0||l>o.length||p<0||b>this.length)throw new RangeError("out of range index");if(p>=b&&u>=l)return 0;if(p>=b)return-1;if(u>=l)return 1;if(u>>>=0,l>>>=0,p>>>=0,b>>>=0,this===o)return 0;let I=b-p,H=l-u;const pt=Math.min(I,H),lt=this.slice(p,b),yt=o.slice(u,l);for(let et=0;et<pt;++et)if(lt[et]!==yt[et]){I=lt[et],H=yt[et];break}return I<H?-1:H<I?1:0};function A(h,o,u,l,p){if(h.length===0)return-1;if(typeof u=="string"?(l=u,u=0):u>2147483647?u=2147483647:u<-2147483648&&(u=-2147483648),u=+u,Qt(u)&&(u=p?0:h.length-1),u<0&&(u=h.length+u),u>=h.length){if(p)return-1;u=h.length-1}else if(u<0)if(p)u=0;else return-1;if(typeof o=="string"&&(o=c.from(o,l)),c.isBuffer(o))return o.length===0?-1:N(h,o,u,l,p);if(typeof o=="number")return o=o&255,typeof Uint8Array.prototype.indexOf=="function"?p?Uint8Array.prototype.indexOf.call(h,o,u):Uint8Array.prototype.lastIndexOf.call(h,o,u):N(h,[o],u,l,p);throw new TypeError("val must be string, number or Buffer")}function N(h,o,u,l,p){let b=1,I=h.length,H=o.length;if(l!==void 0&&(l=String(l).toLowerCase(),l==="ucs2"||l==="ucs-2"||l==="utf16le"||l==="utf-16le")){if(h.length<2||o.length<2)return-1;b=2,I/=2,H/=2,u/=2}function pt(yt,et){return b===1?yt[et]:yt.readUInt16BE(et*b)}let lt;if(p){let yt=-1;for(lt=u;lt<I;lt++)if(pt(h,lt)===pt(o,yt===-1?0:lt-yt)){if(yt===-1&&(yt=lt),lt-yt+1===H)return yt*b}else yt!==-1&&(lt-=lt-yt),yt=-1}else for(u+H>I&&(u=I-H),lt=u;lt>=0;lt--){let yt=!0;for(let et=0;et<H;et++)if(pt(h,lt+et)!==pt(o,et)){yt=!1;break}if(yt)return lt}return-1}c.prototype.includes=function(o,u,l){return this.indexOf(o,u,l)!==-1},c.prototype.indexOf=function(o,u,l){return A(this,o,u,l,!0)},c.prototype.lastIndexOf=function(o,u,l){return A(this,o,u,l,!1)};function m(h,o,u,l){u=Number(u)||0;const p=h.length-u;l?(l=Number(l),l>p&&(l=p)):l=p;const b=o.length;l>b/2&&(l=b/2);let I;for(I=0;I<l;++I){const H=parseInt(o.substr(I*2,2),16);if(Qt(H))return I;h[u+I]=H}return I}function S(h,o,u,l){return Nt(kt(o,h.length-u),h,u,l)}function w(h,o,u,l){return Nt(Ht(o),h,u,l)}function v(h,o,u,l){return Nt($t(o),h,u,l)}function k(h,o,u,l){return Nt(Vt(o,h.length-u),h,u,l)}c.prototype.write=function(o,u,l,p){if(u===void 0)p="utf8",l=this.length,u=0;else if(l===void 0&&typeof u=="string")p=u,l=this.length,u=0;else if(isFinite(u))u=u>>>0,isFinite(l)?(l=l>>>0,p===void 0&&(p="utf8")):(p=l,l=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const b=this.length-u;if((l===void 0||l>b)&&(l=b),o.length>0&&(l<0||u<0)||u>this.length)throw new RangeError("Attempt to write outside buffer bounds");p||(p="utf8");let I=!1;for(;;)switch(p){case"hex":return m(this,o,u,l);case"utf8":case"utf-8":return S(this,o,u,l);case"ascii":case"latin1":case"binary":return w(this,o,u,l);case"base64":return v(this,o,u,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,o,u,l);default:if(I)throw new TypeError("Unknown encoding: "+p);p=(""+p).toLowerCase(),I=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Q(h,o,u){return o===0&&u===h.length?t.fromByteArray(h):t.fromByteArray(h.slice(o,u))}function z(h,o,u){u=Math.min(h.length,u);const l=[];let p=o;for(;p<u;){const b=h[p];let I=null,H=b>239?4:b>223?3:b>191?2:1;if(p+H<=u){let pt,lt,yt,et;switch(H){case 1:b<128&&(I=b);break;case 2:pt=h[p+1],(pt&192)===128&&(et=(b&31)<<6|pt&63,et>127&&(I=et));break;case 3:pt=h[p+1],lt=h[p+2],(pt&192)===128&&(lt&192)===128&&(et=(b&15)<<12|(pt&63)<<6|lt&63,et>2047&&(et<55296||et>57343)&&(I=et));break;case 4:pt=h[p+1],lt=h[p+2],yt=h[p+3],(pt&192)===128&&(lt&192)===128&&(yt&192)===128&&(et=(b&15)<<18|(pt&63)<<12|(lt&63)<<6|yt&63,et>65535&&et<1114112&&(I=et))}}I===null?(I=65533,H=1):I>65535&&(I-=65536,l.push(I>>>10&1023|55296),I=56320|I&1023),l.push(I),p+=H}return D(l)}const R=4096;function D(h){const o=h.length;if(o<=R)return String.fromCharCode.apply(String,h);let u="",l=0;for(;l<o;)u+=String.fromCharCode.apply(String,h.slice(l,l+=R));return u}function Y(h,o,u){let l="";u=Math.min(h.length,u);for(let p=o;p<u;++p)l+=String.fromCharCode(h[p]&127);return l}function Z(h,o,u){let l="";u=Math.min(h.length,u);for(let p=o;p<u;++p)l+=String.fromCharCode(h[p]);return l}function X(h,o,u){const l=h.length;(!o||o<0)&&(o=0),(!u||u<0||u>l)&&(u=l);let p="";for(let b=o;b<u;++b)p+=sr[h[b]];return p}function K(h,o,u){const l=h.slice(o,u);let p="";for(let b=0;b<l.length-1;b+=2)p+=String.fromCharCode(l[b]+l[b+1]*256);return p}c.prototype.slice=function(o,u){const l=this.length;o=~~o,u=u===void 0?l:~~u,o<0?(o+=l,o<0&&(o=0)):o>l&&(o=l),u<0?(u+=l,u<0&&(u=0)):u>l&&(u=l),u<o&&(u=o);const p=this.subarray(o,u);return Object.setPrototypeOf(p,c.prototype),p};function q(h,o,u){if(h%1!==0||h<0)throw new RangeError("offset is not uint");if(h+o>u)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(o,u,l){o=o>>>0,u=u>>>0,l||q(o,u,this.length);let p=this[o],b=1,I=0;for(;++I<u&&(b*=256);)p+=this[o+I]*b;return p},c.prototype.readUintBE=c.prototype.readUIntBE=function(o,u,l){o=o>>>0,u=u>>>0,l||q(o,u,this.length);let p=this[o+--u],b=1;for(;u>0&&(b*=256);)p+=this[o+--u]*b;return p},c.prototype.readUint8=c.prototype.readUInt8=function(o,u){return o=o>>>0,u||q(o,1,this.length),this[o]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(o,u){return o=o>>>0,u||q(o,2,this.length),this[o]|this[o+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(o,u){return o=o>>>0,u||q(o,2,this.length),this[o]<<8|this[o+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(o,u){return o=o>>>0,u||q(o,4,this.length),(this[o]|this[o+1]<<8|this[o+2]<<16)+this[o+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(o,u){return o=o>>>0,u||q(o,4,this.length),this[o]*16777216+(this[o+1]<<16|this[o+2]<<8|this[o+3])},c.prototype.readBigUInt64LE=Wt(function(o){o=o>>>0,$(o,"offset");const u=this[o],l=this[o+7];(u===void 0||l===void 0)&&J(o,this.length-8);const p=u+this[++o]*2**8+this[++o]*2**16+this[++o]*2**24,b=this[++o]+this[++o]*2**8+this[++o]*2**16+l*2**24;return BigInt(p)+(BigInt(b)<<BigInt(32))}),c.prototype.readBigUInt64BE=Wt(function(o){o=o>>>0,$(o,"offset");const u=this[o],l=this[o+7];(u===void 0||l===void 0)&&J(o,this.length-8);const p=u*2**24+this[++o]*2**16+this[++o]*2**8+this[++o],b=this[++o]*2**24+this[++o]*2**16+this[++o]*2**8+l;return(BigInt(p)<<BigInt(32))+BigInt(b)}),c.prototype.readIntLE=function(o,u,l){o=o>>>0,u=u>>>0,l||q(o,u,this.length);let p=this[o],b=1,I=0;for(;++I<u&&(b*=256);)p+=this[o+I]*b;return b*=128,p>=b&&(p-=Math.pow(2,8*u)),p},c.prototype.readIntBE=function(o,u,l){o=o>>>0,u=u>>>0,l||q(o,u,this.length);let p=u,b=1,I=this[o+--p];for(;p>0&&(b*=256);)I+=this[o+--p]*b;return b*=128,I>=b&&(I-=Math.pow(2,8*u)),I},c.prototype.readInt8=function(o,u){return o=o>>>0,u||q(o,1,this.length),this[o]&128?(255-this[o]+1)*-1:this[o]},c.prototype.readInt16LE=function(o,u){o=o>>>0,u||q(o,2,this.length);const l=this[o]|this[o+1]<<8;return l&32768?l|4294901760:l},c.prototype.readInt16BE=function(o,u){o=o>>>0,u||q(o,2,this.length);const l=this[o+1]|this[o]<<8;return l&32768?l|4294901760:l},c.prototype.readInt32LE=function(o,u){return o=o>>>0,u||q(o,4,this.length),this[o]|this[o+1]<<8|this[o+2]<<16|this[o+3]<<24},c.prototype.readInt32BE=function(o,u){return o=o>>>0,u||q(o,4,this.length),this[o]<<24|this[o+1]<<16|this[o+2]<<8|this[o+3]},c.prototype.readBigInt64LE=Wt(function(o){o=o>>>0,$(o,"offset");const u=this[o],l=this[o+7];(u===void 0||l===void 0)&&J(o,this.length-8);const p=this[o+4]+this[o+5]*2**8+this[o+6]*2**16+(l<<24);return(BigInt(p)<<BigInt(32))+BigInt(u+this[++o]*2**8+this[++o]*2**16+this[++o]*2**24)}),c.prototype.readBigInt64BE=Wt(function(o){o=o>>>0,$(o,"offset");const u=this[o],l=this[o+7];(u===void 0||l===void 0)&&J(o,this.length-8);const p=(u<<24)+this[++o]*2**16+this[++o]*2**8+this[++o];return(BigInt(p)<<BigInt(32))+BigInt(this[++o]*2**24+this[++o]*2**16+this[++o]*2**8+l)}),c.prototype.readFloatLE=function(o,u){return o=o>>>0,u||q(o,4,this.length),e.read(this,o,!0,23,4)},c.prototype.readFloatBE=function(o,u){return o=o>>>0,u||q(o,4,this.length),e.read(this,o,!1,23,4)},c.prototype.readDoubleLE=function(o,u){return o=o>>>0,u||q(o,8,this.length),e.read(this,o,!0,52,8)},c.prototype.readDoubleBE=function(o,u){return o=o>>>0,u||q(o,8,this.length),e.read(this,o,!1,52,8)};function rt(h,o,u,l,p,b){if(!c.isBuffer(h))throw new TypeError('"buffer" argument must be a Buffer instance');if(o>p||o<b)throw new RangeError('"value" argument is out of bounds');if(u+l>h.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(o,u,l,p){if(o=+o,u=u>>>0,l=l>>>0,!p){const H=Math.pow(2,8*l)-1;rt(this,o,u,l,H,0)}let b=1,I=0;for(this[u]=o&255;++I<l&&(b*=256);)this[u+I]=o/b&255;return u+l},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(o,u,l,p){if(o=+o,u=u>>>0,l=l>>>0,!p){const H=Math.pow(2,8*l)-1;rt(this,o,u,l,H,0)}let b=l-1,I=1;for(this[u+b]=o&255;--b>=0&&(I*=256);)this[u+b]=o/I&255;return u+l},c.prototype.writeUint8=c.prototype.writeUInt8=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,1,255,0),this[u]=o&255,u+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,2,65535,0),this[u]=o&255,this[u+1]=o>>>8,u+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,2,65535,0),this[u]=o>>>8,this[u+1]=o&255,u+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,4,4294967295,0),this[u+3]=o>>>24,this[u+2]=o>>>16,this[u+1]=o>>>8,this[u]=o&255,u+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,4,4294967295,0),this[u]=o>>>24,this[u+1]=o>>>16,this[u+2]=o>>>8,this[u+3]=o&255,u+4};function At(h,o,u,l,p){j(o,l,p,h,u,7);let b=Number(o&BigInt(4294967295));h[u++]=b,b=b>>8,h[u++]=b,b=b>>8,h[u++]=b,b=b>>8,h[u++]=b;let I=Number(o>>BigInt(32)&BigInt(4294967295));return h[u++]=I,I=I>>8,h[u++]=I,I=I>>8,h[u++]=I,I=I>>8,h[u++]=I,u}function Ut(h,o,u,l,p){j(o,l,p,h,u,7);let b=Number(o&BigInt(4294967295));h[u+7]=b,b=b>>8,h[u+6]=b,b=b>>8,h[u+5]=b,b=b>>8,h[u+4]=b;let I=Number(o>>BigInt(32)&BigInt(4294967295));return h[u+3]=I,I=I>>8,h[u+2]=I,I=I>>8,h[u+1]=I,I=I>>8,h[u]=I,u+8}c.prototype.writeBigUInt64LE=Wt(function(o,u=0){return At(this,o,u,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=Wt(function(o,u=0){return Ut(this,o,u,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(o,u,l,p){if(o=+o,u=u>>>0,!p){const pt=Math.pow(2,8*l-1);rt(this,o,u,l,pt-1,-pt)}let b=0,I=1,H=0;for(this[u]=o&255;++b<l&&(I*=256);)o<0&&H===0&&this[u+b-1]!==0&&(H=1),this[u+b]=(o/I>>0)-H&255;return u+l},c.prototype.writeIntBE=function(o,u,l,p){if(o=+o,u=u>>>0,!p){const pt=Math.pow(2,8*l-1);rt(this,o,u,l,pt-1,-pt)}let b=l-1,I=1,H=0;for(this[u+b]=o&255;--b>=0&&(I*=256);)o<0&&H===0&&this[u+b+1]!==0&&(H=1),this[u+b]=(o/I>>0)-H&255;return u+l},c.prototype.writeInt8=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,1,127,-128),o<0&&(o=255+o+1),this[u]=o&255,u+1},c.prototype.writeInt16LE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,2,32767,-32768),this[u]=o&255,this[u+1]=o>>>8,u+2},c.prototype.writeInt16BE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,2,32767,-32768),this[u]=o>>>8,this[u+1]=o&255,u+2},c.prototype.writeInt32LE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,4,2147483647,-2147483648),this[u]=o&255,this[u+1]=o>>>8,this[u+2]=o>>>16,this[u+3]=o>>>24,u+4},c.prototype.writeInt32BE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,4,2147483647,-2147483648),o<0&&(o=4294967295+o+1),this[u]=o>>>24,this[u+1]=o>>>16,this[u+2]=o>>>8,this[u+3]=o&255,u+4},c.prototype.writeBigInt64LE=Wt(function(o,u=0){return At(this,o,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=Wt(function(o,u=0){return Ut(this,o,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Pt(h,o,u,l,p,b){if(u+l>h.length)throw new RangeError("Index out of range");if(u<0)throw new RangeError("Index out of range")}function Zt(h,o,u,l,p){return o=+o,u=u>>>0,p||Pt(h,o,u,4),e.write(h,o,u,l,23,4),u+4}c.prototype.writeFloatLE=function(o,u,l){return Zt(this,o,u,!0,l)},c.prototype.writeFloatBE=function(o,u,l){return Zt(this,o,u,!1,l)};function Gt(h,o,u,l,p){return o=+o,u=u>>>0,p||Pt(h,o,u,8),e.write(h,o,u,l,52,8),u+8}c.prototype.writeDoubleLE=function(o,u,l){return Gt(this,o,u,!0,l)},c.prototype.writeDoubleBE=function(o,u,l){return Gt(this,o,u,!1,l)},c.prototype.copy=function(o,u,l,p){if(!c.isBuffer(o))throw new TypeError("argument should be a Buffer");if(l||(l=0),!p&&p!==0&&(p=this.length),u>=o.length&&(u=o.length),u||(u=0),p>0&&p<l&&(p=l),p===l||o.length===0||this.length===0)return 0;if(u<0)throw new RangeError("targetStart out of bounds");if(l<0||l>=this.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("sourceEnd out of bounds");p>this.length&&(p=this.length),o.length-u<p-l&&(p=o.length-u+l);const b=p-l;return this===o&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(u,l,p):Uint8Array.prototype.set.call(o,this.subarray(l,p),u),b},c.prototype.fill=function(o,u,l,p){if(typeof o=="string"){if(typeof u=="string"?(p=u,u=0,l=this.length):typeof l=="string"&&(p=l,l=this.length),p!==void 0&&typeof p!="string")throw new TypeError("encoding must be a string");if(typeof p=="string"&&!c.isEncoding(p))throw new TypeError("Unknown encoding: "+p);if(o.length===1){const I=o.charCodeAt(0);(p==="utf8"&&I<128||p==="latin1")&&(o=I)}}else typeof o=="number"?o=o&255:typeof o=="boolean"&&(o=Number(o));if(u<0||this.length<u||this.length<l)throw new RangeError("Out of range index");if(l<=u)return this;u=u>>>0,l=l===void 0?this.length:l>>>0,o||(o=0);let b;if(typeof o=="number")for(b=u;b<l;++b)this[b]=o;else{const I=c.isBuffer(o)?o:c.from(o,p),H=I.length;if(H===0)throw new TypeError('The value "'+o+'" is invalid for argument "value"');for(b=0;b<l-u;++b)this[b+u]=I[b%H]}return this};const W={};function g(h,o,u){W[h]=class extends u{constructor(){super(),Object.defineProperty(this,"message",{value:o.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${h}]`,this.stack,delete this.name}get code(){return h}set code(p){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:p,writable:!0})}toString(){return`${this.name} [${h}]: ${this.message}`}}}g("ERR_BUFFER_OUT_OF_BOUNDS",function(h){return h?`${h} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),g("ERR_INVALID_ARG_TYPE",function(h,o){return`The "${h}" argument must be of type number. Received type ${typeof o}`},TypeError),g("ERR_OUT_OF_RANGE",function(h,o,u){let l=`The value of "${h}" is out of range.`,p=u;return Number.isInteger(u)&&Math.abs(u)>2**32?p=_(String(u)):typeof u=="bigint"&&(p=String(u),(u>BigInt(2)**BigInt(32)||u<-(BigInt(2)**BigInt(32)))&&(p=_(p)),p+="n"),l+=` It must be ${o}. Received ${p}`,l},RangeError);function _(h){let o="",u=h.length;const l=h[0]==="-"?1:0;for(;u>=l+4;u-=3)o=`_${h.slice(u-3,u)}${o}`;return`${h.slice(0,u)}${o}`}function T(h,o,u){$(o,"offset"),(h[o]===void 0||h[o+u]===void 0)&&J(o,h.length-(u+1))}function j(h,o,u,l,p,b){if(h>u||h<o){const I=typeof o=="bigint"?"n":"";let H;throw o===0||o===BigInt(0)?H=`>= 0${I} and < 2${I} ** ${(b+1)*8}${I}`:H=`>= -(2${I} ** ${(b+1)*8-1}${I}) and < 2 ** ${(b+1)*8-1}${I}`,new W.ERR_OUT_OF_RANGE("value",H,h)}T(l,p,b)}function $(h,o){if(typeof h!="number")throw new W.ERR_INVALID_ARG_TYPE(o,"number",h)}function J(h,o,u){throw Math.floor(h)!==h?($(h,u),new W.ERR_OUT_OF_RANGE("offset","an integer",h)):o<0?new W.ERR_BUFFER_OUT_OF_BOUNDS:new W.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${o}`,h)}const bt=/[^+/0-9A-Za-z-_]/g;function Ot(h){if(h=h.split("=")[0],h=h.trim().replace(bt,""),h.length<2)return"";for(;h.length%4!==0;)h=h+"=";return h}function kt(h,o){o=o||1/0;let u;const l=h.length;let p=null;const b=[];for(let I=0;I<l;++I){if(u=h.charCodeAt(I),u>55295&&u<57344){if(!p){if(u>56319){(o-=3)>-1&&b.push(239,191,189);continue}else if(I+1===l){(o-=3)>-1&&b.push(239,191,189);continue}p=u;continue}if(u<56320){(o-=3)>-1&&b.push(239,191,189),p=u;continue}u=(p-55296<<10|u-56320)+65536}else p&&(o-=3)>-1&&b.push(239,191,189);if(p=null,u<128){if((o-=1)<0)break;b.push(u)}else if(u<2048){if((o-=2)<0)break;b.push(u>>6|192,u&63|128)}else if(u<65536){if((o-=3)<0)break;b.push(u>>12|224,u>>6&63|128,u&63|128)}else if(u<1114112){if((o-=4)<0)break;b.push(u>>18|240,u>>12&63|128,u>>6&63|128,u&63|128)}else throw new Error("Invalid code point")}return b}function Ht(h){const o=[];for(let u=0;u<h.length;++u)o.push(h.charCodeAt(u)&255);return o}function Vt(h,o){let u,l,p;const b=[];for(let I=0;I<h.length&&!((o-=2)<0);++I)u=h.charCodeAt(I),l=u>>8,p=u%256,b.push(p),b.push(l);return b}function $t(h){return t.toByteArray(Ot(h))}function Nt(h,o,u,l){let p;for(p=0;p<l&&!(p+u>=o.length||p>=h.length);++p)o[p+u]=h[p];return p}function mt(h,o){return h instanceof o||h!=null&&h.constructor!=null&&h.constructor.name!=null&&h.constructor.name===o.name}function Qt(h){return h!==h}const sr=function(){const h="0123456789abcdef",o=new Array(256);for(let u=0;u<16;++u){const l=u*16;for(let p=0;p<16;++p)o[l+p]=h[u]+h[p]}return o}();function Wt(h){return typeof BigInt>"u"?Fi:h}function Fi(){throw new Error("BigInt not supported")}}($i)),$i}var $o;function cf(){if($o)return Ur;$o=1,Object.defineProperty(Ur,"__esModule",{value:!0}),Ur.BinaryReader=void 0;const r=Ws();class t{constructor(n,s=!1){this.readUInt8=this._read(r.Buffer.prototype.readUInt8,r.Buffer.prototype.readUInt8,1),this.readUInt16=this._read(r.Buffer.prototype.readUInt16LE,r.Buffer.prototype.readUInt16BE,2),this.readUInt32=this._read(r.Buffer.prototype.readUInt32LE,r.Buffer.prototype.readUInt32BE,4),this.readInt8=this._read(r.Buffer.prototype.readInt8,r.Buffer.prototype.readInt8,1),this.readInt16=this._read(r.Buffer.prototype.readInt16LE,r.Buffer.prototype.readInt16BE,2),this.readInt32=this._read(r.Buffer.prototype.readInt32LE,r.Buffer.prototype.readInt32BE,4),this.readFloat=this._read(r.Buffer.prototype.readFloatLE,r.Buffer.prototype.readFloatBE,4),this.readDouble=this._read(r.Buffer.prototype.readDoubleLE,r.Buffer.prototype.readDoubleBE,8),this.buffer=n,this.position=0,this.isBigEndian=s}_read(n,s,i){return()=>{let a;return this.isBigEndian?a=s.call(this.buffer,this.position):a=n.call(this.buffer,this.position),this.position+=i,a}}readVarInt(){let n,s=0,i=0;do n=this.buffer[this.position+i],s+=(n&127)<<7*i,i++;while(n>=128);return this.position+=i,s}}return Ur.BinaryReader=t,Ur}var Cr={},zo;function Ke(){if(zo)return Cr;zo=1,Object.defineProperty(Cr,"__esModule",{value:!0}),Cr.BinaryWriter=void 0;const r=Ws();class t{constructor(n,s=!0){this.writeUInt8=this._write(r.Buffer.prototype.writeUInt8,1),this.writeUInt16LE=this._write(r.Buffer.prototype.writeUInt16LE,2),this.writeUInt16BE=this._write(r.Buffer.prototype.writeUInt16BE,2),this.writeUInt32LE=this._write(r.Buffer.prototype.writeUInt32LE,4),this.writeUInt32BE=this._write(r.Buffer.prototype.writeUInt32BE,4),this.writeInt8=this._write(r.Buffer.prototype.writeInt8,1),this.writeInt16LE=this._write(r.Buffer.prototype.writeInt16LE,2),this.writeInt16BE=this._write(r.Buffer.prototype.writeInt16BE,2),this.writeInt32LE=this._write(r.Buffer.prototype.writeInt32LE,4),this.writeInt32BE=this._write(r.Buffer.prototype.writeInt32BE,4),this.writeFloatLE=this._write(r.Buffer.prototype.writeFloatLE,4),this.writeFloatBE=this._write(r.Buffer.prototype.writeFloatBE,4),this.writeDoubleLE=this._write(r.Buffer.prototype.writeDoubleLE,8),this.writeDoubleBE=this._write(r.Buffer.prototype.writeDoubleBE,8),this.buffer=r.Buffer.alloc(n),this.position=0,this.allowResize=s}_write(n,s){return(i,a=!1)=>{this.ensureSize(s),n.call(this.buffer,i,this.position,a),this.position+=s}}writeBuffer(n){this.ensureSize(n.length),n.copy(this.buffer,this.position,0,n.length),this.position+=n.length}writeVarInt(n){let s=1;for(;(n&4294967168)!==0;)this.writeUInt8(n&127|128),n>>>=7,s++;return this.writeUInt8(n&127),s}ensureSize(n){if(this.buffer.length<this.position+n)if(this.allowResize){const s=r.Buffer.alloc(this.position+n);this.buffer.copy(s,0,0,this.buffer.length),this.buffer=s}else throw new RangeError("index out of range")}}return Cr.BinaryWriter=t,Cr}var Rr={},jo;function $e(){return jo||(jo=1,Object.defineProperty(Rr,"__esModule",{value:!0}),Rr.CONSTANTS=void 0,Rr.CONSTANTS={wkt:{Point:"POINT",LineString:"LINESTRING",Polygon:"POLYGON",MultiPoint:"MULTIPOINT",MultiLineString:"MULTILINESTRING",MultiPolygon:"MULTIPOLYGON",GeometryCollection:"GEOMETRYCOLLECTION"},wkb:{Point:1,LineString:2,Polygon:3,MultiPoint:4,MultiLineString:5,MultiPolygon:6,GeometryCollection:7},geoJSON:{Point:"Point",LineString:"LineString",Polygon:"Polygon",MultiPoint:"MultiPoint",MultiLineString:"MultiLineString",MultiPolygon:"MultiPolygon",GeometryCollection:"GeometryCollection"}}),Rr}var Pr={},Vo;function uf(){if(Vo)return Pr;Vo=1,Object.defineProperty(Pr,"__esModule",{value:!0}),Pr.Geometry=void 0;const r=Ws(),t=ze();class e{constructor(){this.srid=void 0,this.hasZ=!1,this.hasM=!1}static parse(s,i){if(typeof s==="string"||s instanceof t.WktParser)return e._parseWkt(s);if(r.Buffer.isBuffer(s)||s instanceof t.BinaryReader)try{return e._parseWkb(s,i)}catch{try{return e.parseTwkb(s)}catch{throw new Error("Could not parse WKB or TWKB")}}else throw new Error("First argument must be a string or Buffer")}static _parseWkt(s){let i,a;s instanceof t.WktParser?i=s:i=new t.WktParser(s);const c=i.matchRegex([/^SRID=(\d+);/]);c&&(a=parseInt(c[1],10));const d=i.matchType(),f=i.matchDimension(),y={srid:a,hasZ:f.hasZ,hasM:f.hasM};switch(d){case t.CONSTANTS.wkt.Point:return t.Point._parseWktWithOptions(i,y);case t.CONSTANTS.wkt.LineString:return t.LineString._parseWktWithOptions(i,y);case t.CONSTANTS.wkt.Polygon:return t.Polygon._parseWktWithOptions(i,y);case t.CONSTANTS.wkt.MultiPoint:return t.MultiPoint._parseWktWithOptions(i,y);case t.CONSTANTS.wkt.MultiLineString:return t.MultiLineString._parseWktWithOptions(i,y);case t.CONSTANTS.wkt.MultiPolygon:return t.MultiPolygon._parseWktWithOptions(i,y);case t.CONSTANTS.wkt.GeometryCollection:return t.GeometryCollection._parseWktWithOptions(i,y);default:throw new Error("Unsupported geometry type")}}static _parseWkb(s,i){let a,c,d;const f={};switch(s instanceof t.BinaryReader?a=s:a=new t.BinaryReader(s),a.isBigEndian=!a.readInt8(),c=a.readUInt32(),f.hasSrid=(c&536870912)===536870912,f.isEwkb=c&536870912||c&1073741824||c&2147483648,f.hasSrid&&(f.srid=a.readUInt32()),f.hasZ=!1,f.hasM=!1,!f.isEwkb&&(!i||!i.isEwkb)?c>=1e3&&c<2e3?(f.hasZ=!0,d=c-1e3):c>=2e3&&c<3e3?(f.hasM=!0,d=c-2e3):c>=3e3&&c<4e3?(f.hasZ=!0,f.hasM=!0,d=c-3e3):d=c:(c&2147483648&&(f.hasZ=!0),c&1073741824&&(f.hasM=!0),d=c&15),d){case t.CONSTANTS.wkb.Point:return t.Point._parseWkb(a,f);case t.CONSTANTS.wkb.LineString:return t.LineString._parseWkb(a,f);case t.CONSTANTS.wkb.Polygon:return t.Polygon._parseWkb(a,f);case t.CONSTANTS.wkb.MultiPoint:return t.MultiPoint._parseWkb(a,f);case t.CONSTANTS.wkb.MultiLineString:return t.MultiLineString._parseWkb(a,f);case t.CONSTANTS.wkb.MultiPolygon:return t.MultiPolygon._parseWkb(a,f);case t.CONSTANTS.wkb.GeometryCollection:return t.GeometryCollection._parseWkb(a,f);default:throw new Error(`GeometryType ${d} not supported`)}}static parseTwkb(s){let i;const a={};s instanceof t.BinaryReader?i=s:i=new t.BinaryReader(s);const c=i.readUInt8(),d=i.readUInt8(),f=c&15;if(a.precision=t.ZigZag.decode(c>>4),a.precisionFactor=Math.pow(10,a.precision),a.hasBoundingBox=d>>0&1,a.hasSizeAttribute=d>>1&1,a.hasIdList=d>>2&1,a.hasExtendedPrecision=d>>3&1,a.isEmpty=d>>4&1,a.hasExtendedPrecision){const y=i.readUInt8();a.hasZ=(y&1)===1,a.hasM=(y&2)===2,a.zPrecision=t.ZigZag.decode((y&28)>>2),a.zPrecisionFactor=Math.pow(10,a.zPrecision),a.mPrecision=t.ZigZag.decode((y&224)>>5),a.mPrecisionFactor=Math.pow(10,a.mPrecision)}else a.hasZ=!1,a.hasM=!1;if(a.hasSizeAttribute&&i.readVarInt(),a.hasBoundingBox){let y=2;a.hasZ&&y++,a.hasM&&y++;for(let B=0;B<y;B++)i.readVarInt(),i.readVarInt()}switch(f){case t.CONSTANTS.wkb.Point:return t.Point._parseTwkb(i,a);case t.CONSTANTS.wkb.LineString:return t.LineString._parseTwkb(i,a);case t.CONSTANTS.wkb.Polygon:return t.Polygon._parseTwkb(i,a);case t.CONSTANTS.wkb.MultiPoint:return t.MultiPoint._parseTwkb(i,a);case t.CONSTANTS.wkb.MultiLineString:return t.MultiLineString._parseTwkb(i,a);case t.CONSTANTS.wkb.MultiPolygon:return t.MultiPolygon._parseTwkb(i,a);case t.CONSTANTS.wkb.GeometryCollection:return t.GeometryCollection._parseTwkb(i,a);default:throw new Error("GeometryType "+f+" not supported")}}toGeoJSON(s){const i={};return this.srid&&s&&(s.shortCrs?i.crs={type:"name",properties:{name:"EPSG:"+this.srid}}:s.longCrs&&(i.crs={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+this.srid}})),i}static _parseGeoJSON(s,i){let a;switch(s.type){case t.CONSTANTS.geoJSON.Point:a=t.Point._parseGeoJSON(s);break;case t.CONSTANTS.geoJSON.LineString:a=t.LineString._parseGeoJSON(s);break;case t.CONSTANTS.geoJSON.Polygon:a=t.Polygon._parseGeoJSON(s);break;case t.CONSTANTS.geoJSON.MultiPoint:a=t.MultiPoint._parseGeoJSON(s);break;case t.CONSTANTS.geoJSON.MultiLineString:a=t.MultiLineString._parseGeoJSON(s);break;case t.CONSTANTS.geoJSON.MultiPolygon:a=t.MultiPolygon._parseGeoJSON(s);break;case t.CONSTANTS.geoJSON.GeometryCollection:a=t.GeometryCollection._parseGeoJSON(s);break;default:throw new Error("GeometryType "+s.type+" not supported")}if(s.crs&&s.crs.type&&s.crs.type==="name"&&s.crs.properties&&s.crs.properties.name){const c=s.crs.properties.name;if(c.indexOf("EPSG:")===0)a.srid=parseInt(c.substring(5));else if(c.indexOf("urn:ogc:def:crs:EPSG::")===0)a.srid=parseInt(c.substring(22));else throw new Error("Unsupported crs: "+c)}else i||(a.srid=4326);return a}toEwkt(){return`SRID=${this.srid};${this.toWkt()}`}toEwkb(){const s=new t.BinaryWriter(this._getWkbSize()+4),i=this.toWkb();return s.writeInt8(1),s.writeUInt32LE((i.slice(1,5).readUInt32LE(0)|536870912)>>>0,!0),s.writeUInt32LE(this.srid),s.writeBuffer(i.slice(5)),s.buffer}_getWktType(s,i){let a=s;return this.hasZ&&this.hasM?a+=" ZM ":this.hasZ?a+=" Z ":this.hasM&&(a+=" M "),i&&!this.hasZ&&!this.hasM&&(a+=" "),i&&(a+="EMPTY"),a}_getWktCoordinate(s){let i=`${s.x} ${s.y}`;return this.hasZ&&(i+=` ${s.z}`),this.hasM&&(i+=` ${s.m}`),i}_writeWkbType(s,i,a){let c=0;typeof this.srid>"u"&&(!a||typeof a.srid>"u")?this.hasZ&&this.hasM?c+=3e3:this.hasZ?c+=1e3:this.hasM&&(c+=2e3):(this.hasZ&&(c|=2147483648),this.hasM&&(c|=1073741824)),s.writeUInt32LE(c+i>>>0,!0)}static getTwkbPrecision(s,i,a){return{xy:s,z:i,m:a,xyFactor:Math.pow(10,s),zFactor:Math.pow(10,i),mFactor:Math.pow(10,a)}}_writeTwkbHeader(s,i,a,c){const d=(t.ZigZag.encode(a.xy)<<4)+i;let f=this.hasZ||this.hasM?1:0;if(f+=c?1:0,s.writeUInt8(d),s.writeUInt8(f),this.hasZ||this.hasM){let y=0;this.hasZ&&(y|=1),this.hasM&&(y|=2),s.writeUInt8(y)}}toWkt(){throw new Error("Method 'toWkt' not implemented.")}toWkb(){throw new Error("Method 'toWkb' not implemented.")}toTwkb(){throw new Error("Method 'toTwkb' not implemented.")}_getWkbSize(){throw new Error("Method '_getWkbSize' not implemented.")}}return Pr.Geometry=e,Pr}var $r={},Wo;function hf(){if(Wo)return $r;Wo=1,Object.defineProperty($r,"__esModule",{value:!0}),$r.GeometryCollection=void 0;const r=Ke(),t=$e(),e=ze();class n extends e.Geometry{constructor(i=[],a){super(),this.geometries=i,this.srid=a,this.geometries.length>0&&(this.hasZ=this.geometries[0].hasZ,this.hasM=this.geometries[0].hasM)}static Z(i,a){const c=new n(i,a);return c.hasZ=!0,c}static M(i,a){const c=new n(i,a);return c.hasM=!0,c}static ZM(i,a){const c=new n(i,a);return c.hasZ=!0,c.hasM=!0,c}static _parseWktWithOptions(i,a){const c=new n;if(c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM,i.isMatch(["EMPTY"]))return c;i.expectGroupStart();do c.geometries.push(e.Geometry.parse(i));while(i.isMatch([","]));return i.expectGroupEnd(),c}static _parseWkb(i,a){const c=new n;c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM;const d=i.readUInt32();for(let f=0;f<d;f++)c.geometries.push(e.Geometry.parse(i,a));return c}static _parseTwkb(i,a){const c=new n;if(c.hasZ=a.hasZ,c.hasM=a.hasM,a.isEmpty)return c;const d=i.readVarInt();for(let f=0;f<d;f++)c.geometries.push(e.Geometry.parseTwkb(i));return c}static _parseGeoJSON(i){const a=new n;for(let c=0;c<i.geometries.length;c++)a.geometries.push(e.Geometry._parseGeoJSON(i.geometries[c],!0));return a.geometries.length>0&&(a.hasZ=a.geometries[0].hasZ),a}toWkt(){if(this.geometries.length===0)return this._getWktType(t.CONSTANTS.wkt.GeometryCollection,!0);let i=this._getWktType(t.CONSTANTS.wkt.GeometryCollection,!1)+"(";for(let a=0;a<this.geometries.length;a++)i+=this.geometries[a].toWkt()+",";return i=i.slice(0,-1)+")",i}toWkb(){const i=new r.BinaryWriter(this._getWkbSize());i.writeInt8(1),this._writeWkbType(i,t.CONSTANTS.wkb.GeometryCollection),i.writeUInt32LE(this.geometries.length);for(let a=0;a<this.geometries.length;a++)i.writeBuffer(this.geometries[a].toWkb());return i.buffer}toTwkb(){const i=new r.BinaryWriter(0,!0),a=e.Geometry.getTwkbPrecision(5,0,0),c=this.geometries.length===0;if(this._writeTwkbHeader(i,t.CONSTANTS.wkb.GeometryCollection,a,c),!c){i.writeVarInt(this.geometries.length);for(let d=0;d<this.geometries.length;d++)i.writeBuffer(this.geometries[d].toTwkb())}return i.buffer}_getWkbSize(){let i=9;for(let a=0;a<this.geometries.length;a++)i+=this.geometries[a]._getWkbSize();return i}toGeoJSON(i){const a=super.toGeoJSON(i);return a.type=t.CONSTANTS.geoJSON.GeometryCollection,a.geometries=this.geometries.map(c=>c.toGeoJSON()),a}}return $r.GeometryCollection=n,$r}var zr={},Zo;function lf(){if(Zo)return zr;Zo=1,Object.defineProperty(zr,"__esModule",{value:!0}),zr.LineString=void 0;const r=Ke(),t=$e(),e=ze();class n extends e.Geometry{constructor(i=[],a){super(),this.hasZ=!1,this.hasM=!1,this.points=i,this.srid=a,this.points.length>0&&(this.hasZ=this.points[0].hasZ,this.hasM=this.points[0].hasM)}static Z(i,a){const c=new n(i,a);return c.hasZ=!0,c}static M(i,a){const c=new n(i,a);return c.hasM=!0,c}static ZM(i,a){const c=new n(i,a);return c.hasZ=!0,c.hasM=!0,c}static _parseWktWithOptions(i,a){const c=new n;return c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM,i.isMatch(["EMPTY"])||(i.expectGroupStart(),c.points.push(...i.matchCoordinates(a)),i.expectGroupEnd()),c}static _parseWkb(i,a){const c=new n;c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM;const d=i.readUInt32();for(let f=0;f<d;f++)c.points.push(e.Point._readWkbPoint(i,a));return c}static _parseTwkb(i,a){const c=new n;if(c.hasZ=a.hasZ,c.hasM=a.hasM,a.isEmpty)return c;const d=new e.Point(0,0,0,0),f=i.readVarInt();for(let y=0;y<f;y++)c.points.push(e.Point._readTwkbPoint(i,a,d));return c}static _parseGeoJSON(i){const a=new n;i.coordinates.length>0&&(a.hasZ=i.coordinates[0].length>2);for(const c of i.coordinates)a.points.push(e.Point._readGeoJSONPoint(c));return a}static fromGeometry(i){const a=new n;return a.srid=i.srid,a.hasZ=i.hasZ,a.hasM=i.hasM,i instanceof n?a.points=i.points:i instanceof e.Point&&(a.points=[i]),a}toWkt(){return this.points.length===0?this._getWktType(t.CONSTANTS.wkt.LineString,!0):this._getWktType(t.CONSTANTS.wkt.LineString,!1)+this._toInnerWkt()}_toInnerWkt(){let i="(";for(const a of this.points)i+=`${this._getWktCoordinate(a)},`;return i.slice(0,-1)+")"}toWkb(i){const a=new r.BinaryWriter(this._getWkbSize());a.writeInt8(1),this._writeWkbType(a,t.CONSTANTS.wkb.LineString,i),a.writeUInt32LE(this.points.length);for(const c of this.points)c._writeWkbPoint(a);return a.buffer}toTwkb(){const i=new r.BinaryWriter(0,!0),a=e.Geometry.getTwkbPrecision(5,0,0),c=this.points.length===0;if(this._writeTwkbHeader(i,t.CONSTANTS.wkb.LineString,a,c),!c){i.writeVarInt(this.points.length);const d=new e.Point(0,0,0,0);for(const f of this.points)f._writeTwkbPoint(i,a,d)}return i.buffer}_getWkbSize(){let i=16;return this.hasZ&&(i+=8),this.hasM&&(i+=8),9+this.points.length*i}toGeoJSON(i){const a=super.toGeoJSON(i);return a.type=t.CONSTANTS.geoJSON.LineString,a.coordinates=this.points.map(c=>this.hasZ?[c.x,c.y,c.z]:[c.x,c.y]),a}}return zr.LineString=n,zr}var jr={},Go;function df(){if(Go)return jr;Go=1,Object.defineProperty(jr,"__esModule",{value:!0}),jr.MultiLineString=void 0;const r=Ke(),t=$e(),e=ze();class n extends e.Geometry{constructor(i=[],a){super(),this.lineStrings=i,this.srid=a,this.lineStrings.length>0&&(this.hasZ=this.lineStrings[0].hasZ,this.hasM=this.lineStrings[0].hasM)}static Z(i,a){const c=new n(i,a);return c.hasZ=!0,c}static M(i,a){const c=new n(i,a);return c.hasM=!0,c}static ZM(i,a){const c=new n(i,a);return c.hasZ=!0,c.hasM=!0,c}static _parseWktWithOptions(i,a){const c=new n;if(c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM,i.isMatch(["EMPTY"]))return c;i.expectGroupStart();do i.expectGroupStart(),c.lineStrings.push(new e.LineString(i.matchCoordinates(a))),i.expectGroupEnd();while(i.isMatch([","]));return i.expectGroupEnd(),c}static _parseWkb(i,a){const c=new n;c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM;const d=i.readUInt32();for(let f=0;f<d;f++){const y=e.Geometry.parse(i,a);c.lineStrings.push(e.LineString.fromGeometry(y))}return c}static _parseTwkb(i,a){const c=new n;if(c.hasZ=a.hasZ,c.hasM=a.hasM,a.isEmpty)return c;const d=new e.Point(0,0,0,0),f=i.readVarInt();for(let y=0;y<f;y++){const B=new e.LineString;B.hasZ=a.hasZ,B.hasM=a.hasM;const L=i.readVarInt();for(let x=0;x<L;x++)B.points.push(e.Point._readTwkbPoint(i,a,d));c.lineStrings.push(B)}return c}static _parseGeoJSON(i){const a=new n;i.coordinates.length>0&&i.coordinates[0].length>0&&(a.hasZ=i.coordinates[0][0].length>2);for(let c=0;c<i.coordinates.length;c++)a.lineStrings.push(e.LineString._parseGeoJSON({coordinates:i.coordinates[c]}));return a}toWkt(){if(this.lineStrings.length===0)return this._getWktType(t.CONSTANTS.wkt.MultiLineString,!0);let i=this._getWktType(t.CONSTANTS.wkt.MultiLineString,!1)+"(";for(let a=0;a<this.lineStrings.length;a++)i+=this.lineStrings[a]._toInnerWkt()+",";return i=i.slice(0,-1)+")",i}toWkb(){const i=new r.BinaryWriter(this._getWkbSize());i.writeInt8(1),this._writeWkbType(i,t.CONSTANTS.wkb.MultiLineString),i.writeUInt32LE(this.lineStrings.length);for(let a=0;a<this.lineStrings.length;a++)i.writeBuffer(this.lineStrings[a].toWkb({srid:this.srid}));return i.buffer}toTwkb(){const i=new r.BinaryWriter(0,!0),a=e.Geometry.getTwkbPrecision(5,0,0),c=this.lineStrings.length===0;if(this._writeTwkbHeader(i,t.CONSTANTS.wkb.MultiLineString,a,c),!c){i.writeVarInt(this.lineStrings.length);const d=new e.Point(0,0,0,0);for(let f=0;f<this.lineStrings.length;f++){i.writeVarInt(this.lineStrings[f].points.length);for(let y=0;y<this.lineStrings[f].points.length;y++)this.lineStrings[f].points[y]._writeTwkbPoint(i,a,d)}}return i.buffer}_getWkbSize(){let i=9;for(let a=0;a<this.lineStrings.length;a++)i+=this.lineStrings[a]._getWkbSize();return i}toGeoJSON(i){const a=super.toGeoJSON(i);a.type=t.CONSTANTS.geoJSON.MultiLineString,a.coordinates=[];for(let c=0;c<this.lineStrings.length;c++)a.coordinates.push(this.lineStrings[c].toGeoJSON().coordinates);return a}}return jr.MultiLineString=n,jr}var Vr={},Yo;function ff(){if(Yo)return Vr;Yo=1,Object.defineProperty(Vr,"__esModule",{value:!0}),Vr.MultiPoint=void 0;const r=Ke(),t=$e(),e=ze();class n extends e.Geometry{constructor(i=[],a){super(),this.points=i,this.srid=a,this.points.length>0&&(this.hasZ=this.points[0].hasZ,this.hasM=this.points[0].hasM)}static Z(i,a){const c=new n(i,a);return c.hasZ=!0,c}static M(i,a){const c=new n(i,a);return c.hasM=!0,c}static ZM(i,a){const c=new n(i,a);return c.hasZ=!0,c.hasM=!0,c}static _parseWktWithOptions(i,a){const c=new n;return c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM,i.isMatch(["EMPTY"])||(i.expectGroupStart(),c.points.push(...i.matchCoordinates(a)),i.expectGroupEnd()),c}static _parseWkb(i,a){const c=new n;c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM;const d=i.readUInt32();for(let f=0;f<d;f++){const y=e.Geometry.parse(i,a);c.points.push(e.Point.fromGeometry(y))}return c}static _parseTwkb(i,a){const c=new n;if(c.hasZ=a.hasZ,c.hasM=a.hasM,a.isEmpty)return c;const d=new e.Point(0,0,0,0),f=i.readVarInt();for(let y=0;y<f;y++)c.points.push(e.Point._readTwkbPoint(i,a,d));return c}static _parseGeoJSON(i){const a=new n;i.coordinates.length>0&&(a.hasZ=i.coordinates[0].length>2);for(let c=0;c<i.coordinates.length;c++)a.points.push(e.Point._parseGeoJSON({coordinates:i.coordinates[c]}));return a}toWkt(){if(this.points.length===0)return this._getWktType(t.CONSTANTS.wkt.MultiPoint,!0);let i=this._getWktType(t.CONSTANTS.wkt.MultiPoint,!1)+"(";for(let a=0;a<this.points.length;a++)i+=this._getWktCoordinate(this.points[a])+",";return i=i.slice(0,-1)+")",i}toWkb(){const i=new r.BinaryWriter(this._getWkbSize());i.writeInt8(1),this._writeWkbType(i,t.CONSTANTS.wkb.MultiPoint),i.writeUInt32LE(this.points.length);for(let a=0;a<this.points.length;a++)i.writeBuffer(this.points[a].toWkb({srid:this.srid}));return i.buffer}toTwkb(){const i=new r.BinaryWriter(0,!0),a=e.Geometry.getTwkbPrecision(5,0,0),c=this.points.length===0;if(this._writeTwkbHeader(i,t.CONSTANTS.wkb.MultiPoint,a,c),!c){i.writeVarInt(this.points.length);const d=new e.Point(0,0,0,0);for(let f=0;f<this.points.length;f++)this.points[f]._writeTwkbPoint(i,a,d)}return i.buffer}_getWkbSize(){let i=16;return this.hasZ&&(i+=8),this.hasM&&(i+=8),i+=5,9+this.points.length*i}toGeoJSON(i){const a=super.toGeoJSON(i);a.type=t.CONSTANTS.geoJSON.MultiPoint,a.coordinates=[];for(let c=0;c<this.points.length;c++)a.coordinates.push(this.points[c].toGeoJSON().coordinates);return a}}return Vr.MultiPoint=n,Vr}var Wr={},Jo;function pf(){if(Jo)return Wr;Jo=1,Object.defineProperty(Wr,"__esModule",{value:!0}),Wr.MultiPolygon=void 0;const r=Ke(),t=$e(),e=ze();class n extends e.Geometry{constructor(i,a){super(),this.polygons=i||[],this.srid=a,this.polygons.length>0?(this.hasZ=this.polygons[0].hasZ,this.hasM=this.polygons[0].hasM):(this.hasZ=!1,this.hasM=!1)}static Z(i,a){const c=new n(i,a);return c.hasZ=!0,c}static M(i,a){const c=new n(i,a);return c.hasM=!0,c}static ZM(i,a){const c=new n(i,a);return c.hasZ=!0,c.hasM=!0,c}static _parseWktWithOptions(i,a){const c=new n;if(c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM,i.isMatch(["EMPTY"]))return c;i.expectGroupStart();do{i.expectGroupStart();const d=[],f=[];for(i.expectGroupStart(),d.push(...i.matchCoordinates(a)),i.expectGroupEnd();i.isMatch([","]);)i.expectGroupStart(),f.push(i.matchCoordinates(a)),i.expectGroupEnd();c.polygons.push(new e.Polygon(d,f)),i.expectGroupEnd()}while(i.isMatch([","]));return i.expectGroupEnd(),c}static _parseWkb(i,a){const c=new n;c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM;const d=i.readUInt32();for(let f=0;f<d;f++)c.polygons.push(e.Geometry.parse(i,a));return c}static _parseTwkb(i,a){const c=new n;if(c.hasZ=a.hasZ,c.hasM=a.hasM,a.isEmpty)return c;const d=new e.Point(0,0,0,0),f=i.readVarInt();for(let y=0;y<f;y++){const B=new e.Polygon;B.hasZ=a.hasZ,B.hasM=a.hasM;const L=i.readVarInt(),x=i.readVarInt();for(let M=0;M<x;M++)B.exteriorRing.push(e.Point._readTwkbPoint(i,a,d));for(let M=1;M<L;M++){const U=[],F=i.readVarInt();for(let O=0;O<F;O++)U.push(e.Point._readTwkbPoint(i,a,d));B.interiorRings.push(U)}c.polygons.push(B)}return c}static _parseGeoJSON(i){const a=new n;i.coordinates.length>0&&i.coordinates[0].length>0&&i.coordinates[0][0].length>0&&(a.hasZ=i.coordinates[0][0].length>2);for(let c=0;c<i.coordinates.length;c++)a.polygons.push(e.Polygon._parseGeoJSON({coordinates:i.coordinates}));return a}toWkt(){if(this.polygons.length===0)return this._getWktType(t.CONSTANTS.wkt.MultiPolygon,!0);let i=this._getWktType(t.CONSTANTS.wkt.MultiPolygon,!1)+"(";for(let a=0;a<this.polygons.length;a++)i+=this.polygons[a]._toInnerWkt()+",";return i=i.slice(0,-1),i+=")",i}toWkb(){const i=new r.BinaryWriter(this._getWkbSize());i.writeInt8(1),this._writeWkbType(i,t.CONSTANTS.wkb.MultiPolygon),i.writeUInt32LE(this.polygons.length);for(let a=0;a<this.polygons.length;a++)i.writeBuffer(this.polygons[a].toWkb({srid:this.srid}));return i.buffer}toTwkb(){const i=new r.BinaryWriter(0,!0),a=e.Geometry.getTwkbPrecision(5,0,0),c=this.polygons.length===0;if(this._writeTwkbHeader(i,t.CONSTANTS.wkb.MultiPolygon,a,c),this.polygons.length>0){i.writeVarInt(this.polygons.length);const d=new e.Point(0,0,0,0);for(let f=0;f<this.polygons.length;f++){i.writeVarInt(1+this.polygons[f].interiorRings.length),i.writeVarInt(this.polygons[f].exteriorRing.length);for(let y=0;y<this.polygons[f].exteriorRing.length;y++)this.polygons[f].exteriorRing[y]._writeTwkbPoint(i,a,d);for(let y=0;y<this.polygons[f].interiorRings.length;y++){i.writeVarInt(this.polygons[f].interiorRings[y].length);for(let B=0;B<this.polygons[f].interiorRings[y].length;B++)this.polygons[f].interiorRings[y][B]._writeTwkbPoint(i,a,d)}}}return i.buffer}_getWkbSize(){let i=9;for(let a=0;a<this.polygons.length;a++)i+=this.polygons[a]._getWkbSize();return i}toGeoJSON(i){const a=super.toGeoJSON(i);a.type=t.CONSTANTS.geoJSON.MultiPolygon,a.coordinates=[];for(let c=0;c<this.polygons.length;c++)a.coordinates.push(this.polygons[c].toGeoJSON().coordinates);return a}}return Wr.MultiPolygon=n,Wr}var Zr={},Gr={},Ho;function xu(){if(Ho)return Gr;Ho=1,Object.defineProperty(Gr,"__esModule",{value:!0}),Gr.ZigZag=void 0;class r{static encode(e){return e<<1^e>>31}static decode(e){return e>>1^-(e&1)}}return Gr.ZigZag=r,Gr}var qo;function Au(){if(qo)return Zr;qo=1,Object.defineProperty(Zr,"__esModule",{value:!0}),Zr.Point=void 0;const r=Ke(),t=xu(),e=$e(),n=ze();class s extends n.Geometry{constructor(a,c,d,f,y){super(),this.x=a,this.y=c,this.z=d,this.m=f,this.srid=y,this.hasZ=typeof this.z<"u",this.hasM=typeof this.m<"u"}static Z(a,c,d,f){const y=new s(a,c,d,0,f);return y.hasZ=!0,y}static M(a,c,d,f){const y=new s(a,c,0,d,f);return y.hasM=!0,y}static ZM(a,c,d,f,y){const B=new s(a,c,d,f,y);return B.hasZ=!0,B.hasM=!0,B}static _parseWktWithOptions(a,c){const d=new s(0,0,0,0);if(d.srid=c.srid,d.hasZ=c.hasZ,d.hasM=c.hasM,a.isMatch(["EMPTY"]))return d;a.expectGroupStart();const f=a.matchCoordinate(c);return d.x=f.x,d.y=f.y,d.z=f.z,d.m=f.m,a.expectGroupEnd(),d}static _parseWkb(a,c){const d=s._readWkbPoint(a,c);return d.srid=c.srid,d}static _readWkbPoint(a,c){return new s(a.readDouble(),a.readDouble(),c.hasZ?a.readDouble():!1,c.hasM?a.readDouble():!1)}static _parseTwkb(a,c){const d=new s(0,0,0,0);return d.hasZ=c.hasZ,d.hasM=c.hasM,c.isEmpty||(d.x=t.ZigZag.decode(a.readVarInt())/c.precisionFactor,d.y=t.ZigZag.decode(a.readVarInt())/c.precisionFactor,d.z=c.hasZ?t.ZigZag.decode(a.readVarInt())/c.zPrecisionFactor:0,d.m=c.hasM?t.ZigZag.decode(a.readVarInt())/c.mPrecisionFactor:0),d}static _readTwkbPoint(a,c,d){return d.x+=t.ZigZag.decode(a.readVarInt())/c.precisionFactor,d.y+=t.ZigZag.decode(a.readVarInt())/c.precisionFactor,c.hasZ&&(d.z+=t.ZigZag.decode(a.readVarInt())/c.zPrecisionFactor),c.hasM&&(d.m+=t.ZigZag.decode(a.readVarInt())/c.mPrecisionFactor),new s(d.x,d.y,d.z,d.m)}static _parseGeoJSON(a){return s._readGeoJSONPoint(a.coordinates)}static _readGeoJSONPoint(a){return a.length===0?new s(0,0,0,0):a.length>2?new s(a[0],a[1],a[2],0):new s(a[0],a[1],0,0)}static fromGeometry(a){const c=new s(0,0,0,0);return c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM,a instanceof s?(c.x=a.x,c.y=a.y,c.z=a.z,c.m=a.m):console.log("Point.fromGeometry: geom is not an instance of Point"),c}toWkt(){return this.x===void 0&&this.y===void 0&&this.z===void 0&&this.m===void 0?this._getWktType(e.CONSTANTS.wkt.Point,!0):`${this._getWktType(e.CONSTANTS.wkt.Point,!1)}(${this._getWktCoordinate(this)})`}toWkb(a){const c=new r.BinaryWriter(this._getWkbSize());return c.writeInt8(1),this._writeWkbType(c,e.CONSTANTS.wkb.Point,a),this.x===void 0&&this.y===void 0?(c.writeDoubleLE(NaN),c.writeDoubleLE(NaN),this.hasZ&&c.writeDoubleLE(NaN),this.hasM&&c.writeDoubleLE(NaN)):this._writeWkbPoint(c),c.buffer}_writeWkbPoint(a){a.writeDoubleLE(this.x),a.writeDoubleLE(this.y),this.hasZ&&a.writeDoubleLE(this.z),this.hasM&&a.writeDoubleLE(this.m)}toTwkb(){const a=new r.BinaryWriter(0,!0),c=n.Geometry.getTwkbPrecision(5,0,0),d=this.x===void 0&&this.y===void 0;return this._writeTwkbHeader(a,e.CONSTANTS.wkb.Point,c,d),d||this._writeTwkbPoint(a,c,new s(0,0,0,0)),a.buffer}_writeTwkbPoint(a,c,d){const f=this.x*c.xyFactor,y=this.y*c.xyFactor,B=this.z*c.zFactor,L=this.m*c.mFactor;a.writeVarInt(t.ZigZag.encode(f-d.x)),a.writeVarInt(t.ZigZag.encode(y-d.y)),this.hasZ&&a.writeVarInt(t.ZigZag.encode(B-d.z)),this.hasM&&a.writeVarInt(t.ZigZag.encode(L-d.m)),d.x=f,d.y=y,d.z=B,d.m=L}_getWkbSize(){let a=21;return this.hasZ&&(a+=8),this.hasM&&(a+=8),a}toGeoJSON(a){const c=super.toGeoJSON(a);return c.type=e.CONSTANTS.geoJSON.Point,this.x===void 0&&this.y===void 0?c.coordinates=[]:this.z!==void 0?c.coordinates=[this.x,this.y,this.z]:c.coordinates=[this.x,this.y],c}}return Zr.Point=s,Zr}var Yr={},Ko;function yf(){if(Ko)return Yr;Ko=1,Object.defineProperty(Yr,"__esModule",{value:!0}),Yr.Polygon=void 0;const r=Ke(),t=$e(),e=ze();class n extends e.Geometry{constructor(i,a,c){super(),this.exteriorRing=i||[],this.interiorRings=a||[],this.srid=c,this.exteriorRing.length>0?(this.hasZ=this.exteriorRing[0].hasZ,this.hasM=this.exteriorRing[0].hasM):(this.hasZ=!1,this.hasM=!1)}static Z(i,a,c){const d=new n(i,a,c);return d.hasZ=!0,d}static M(i,a,c){const d=new n(i,a,c);return d.hasM=!0,d}static ZM(i,a,c){const d=new n(i,a,c);return d.hasZ=!0,d.hasM=!0,d}static _parseWktWithOptions(i,a){const c=new n;if(c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM,i.isMatch(["EMPTY"]))return c;for(i.expectGroupStart(),i.expectGroupStart(),c.exteriorRing.push(...i.matchCoordinates(a)),i.expectGroupEnd();i.isMatch([","]);)i.expectGroupStart(),c.interiorRings.push(i.matchCoordinates(a)),i.expectGroupEnd();return i.expectGroupEnd(),c}static _parseWkb(i,a){const c=new n;c.srid=a.srid,c.hasZ=a.hasZ,c.hasM=a.hasM;const d=i.readUInt32();if(d>0){const f=i.readUInt32();for(let y=0;y<f;y++)c.exteriorRing.push(e.Point._readWkbPoint(i,a));for(let y=1;y<d;y++){const B=[],L=i.readUInt32();for(let x=0;x<L;x++)B.push(e.Point._readWkbPoint(i,a));c.interiorRings.push(B)}}return c}static _parseTwkb(i,a){const c=new n;if(c.hasZ=a.hasZ,c.hasM=a.hasM,a.isEmpty)return c;const d=new e.Point(0,0,0,0),f=i.readVarInt(),y=i.readVarInt();for(let B=0;B<y;B++)c.exteriorRing.push(e.Point._readTwkbPoint(i,a,d));for(let B=1;B<f;B++){const L=[],x=i.readVarInt();for(let M=0;M<x;M++)L.push(e.Point._readTwkbPoint(i,a,d));c.interiorRings.push(L)}return c}static _parseGeoJSON(i){const a=new n;i.coordinates.length>0&&i.coordinates[0].length>0&&(a.hasZ=i.coordinates[0][0].length>2);for(let c=0;c<i.coordinates.length;c++){c>0&&a.interiorRings.push([]);for(let d=0;d<i.coordinates[c].length;d++)c===0?a.exteriorRing.push(e.Point._readGeoJSONPoint(i.coordinates[c][d])):a.interiorRings[c-1].push(e.Point._readGeoJSONPoint(i.coordinates[c][d]))}return a}toWkt(){return this.exteriorRing.length===0?this._getWktType(t.CONSTANTS.wkt.Polygon,!0):this._getWktType(t.CONSTANTS.wkt.Polygon,!1)+this._toInnerWkt()}_toInnerWkt(){let i="((";for(let a=0;a<this.exteriorRing.length;a++)i+=this._getWktCoordinate(this.exteriorRing[a])+",";i=i.slice(0,-1),i+=")";for(let a=0;a<this.interiorRings.length;a++){i+=",(";for(let c=0;c<this.interiorRings[a].length;c++)i+=this._getWktCoordinate(this.interiorRings[a][c])+",";i=i.slice(0,-1),i+=")"}return i+=")",i}toWkb(i){const a=new r.BinaryWriter(this._getWkbSize());a.writeInt8(1),this._writeWkbType(a,t.CONSTANTS.wkb.Polygon,i),this.exteriorRing.length>0?(a.writeUInt32LE(1+this.interiorRings.length),a.writeUInt32LE(this.exteriorRing.length)):a.writeUInt32LE(0);for(let c=0;c<this.exteriorRing.length;c++)this.exteriorRing[c]._writeWkbPoint(a);for(let c=0;c<this.interiorRings.length;c++){a.writeUInt32LE(this.interiorRings[c].length);for(let d=0;d<this.interiorRings[c].length;d++)this.interiorRings[c][d]._writeWkbPoint(a)}return a.buffer}toTwkb(){const i=new r.BinaryWriter(0,!0),a=e.Geometry.getTwkbPrecision(5,0,0),c=this.exteriorRing.length===0;if(this._writeTwkbHeader(i,t.CONSTANTS.wkb.Polygon,a,c),this.exteriorRing.length>0){i.writeVarInt(1+this.interiorRings.length),i.writeVarInt(this.exteriorRing.length);const d=new e.Point(0,0,0,0);for(let f=0;f<this.exteriorRing.length;f++)this.exteriorRing[f]._writeTwkbPoint(i,a,d);for(let f=0;f<this.interiorRings.length;f++){i.writeVarInt(this.interiorRings[f].length);for(let y=0;y<this.interiorRings[f].length;y++)this.interiorRings[f][y]._writeTwkbPoint(i,a,d)}}return i.buffer}_getWkbSize(){let i=16;this.hasZ&&(i+=8),this.hasM&&(i+=8);let a=9;this.exteriorRing.length>0&&(a+=4+this.exteriorRing.length*i);for(let c=0;c<this.interiorRings.length;c++)a+=4+this.interiorRings[c].length*i;return a}toGeoJSON(i){const a=super.toGeoJSON(i);if(a.type=t.CONSTANTS.geoJSON.Polygon,a.coordinates=[],this.exteriorRing.length>0){const c=[];for(let d=0;d<this.exteriorRing.length;d++)this.hasZ?c.push([this.exteriorRing[d].x,this.exteriorRing[d].y,this.exteriorRing[d].z]):c.push([this.exteriorRing[d].x,this.exteriorRing[d].y]);a.coordinates.push(c)}for(let c=0;c<this.interiorRings.length;c++){const d=[];for(let f=0;f<this.interiorRings[c].length;f++)this.hasZ?d.push([this.interiorRings[c][f].x,this.interiorRings[c][f].y,this.interiorRings[c][f].z]):d.push([this.interiorRings[c][f].x,this.interiorRings[c][f].y]);a.coordinates.push(d)}return a}}return Yr.Polygon=n,Yr}var Jr={},Xo;function gf(){if(Xo)return Jr;Xo=1,Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.WktParser=void 0;const r=$e(),t=Au();class e{constructor(s){this.value=s,this.position=0}match(s){this.skipWhitespaces();for(let i=0;i<s.length;i++)if(this.value.substring(this.position).indexOf(s[i])===0)return this.position+=s[i].length,s[i];return null}matchRegex(s){this.skipWhitespaces();for(let i=0;i<s.length;i++){const a=this.value.substring(this.position).match(s[i]);if(a)return this.position+=a[0].length,a}return null}isMatch(s){this.skipWhitespaces();for(let i=0;i<s.length;i++)if(this.value.substring(this.position).indexOf(s[i])===0)return this.position+=s[i].length,!0;return!1}matchType(){const s=this.match([r.CONSTANTS.wkt.Point,r.CONSTANTS.wkt.LineString,r.CONSTANTS.wkt.Polygon,r.CONSTANTS.wkt.MultiPoint,r.CONSTANTS.wkt.MultiLineString,r.CONSTANTS.wkt.MultiPolygon,r.CONSTANTS.wkt.GeometryCollection]);if(!s)throw new Error("Expected geometry type");return s}matchDimension(){switch(this.match(["ZM","Z","M"])){case"ZM":return{hasZ:!0,hasM:!0};case"Z":return{hasZ:!0,hasM:!1};case"M":return{hasZ:!1,hasM:!0};default:return{hasZ:!1,hasM:!1}}}expectGroupStart(){if(!this.isMatch(["("]))throw new Error("Expected group start")}expectGroupEnd(){if(!this.isMatch([")"]))throw new Error("Expected group end")}matchCoordinate(s){let i;if(s.hasZ&&s.hasM?i=this.matchRegex([/^(\S*)\s+(\S*)\s+(\S*)\s+([^\s,)]*)/]):s.hasZ||s.hasM?i=this.matchRegex([/^(\S*)\s+(\S*)\s+([^\s,)]*)/]):i=this.matchRegex([/^(\S*)\s+([^\s,)]*)/]),!i)throw new Error("Expected coordinates");return s.hasZ&&s.hasM?new t.Point(parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3]),parseFloat(i[4])):s.hasZ?new t.Point(parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3]),0):s.hasM?new t.Point(parseFloat(i[1]),parseFloat(i[2]),0,parseFloat(i[3])):new t.Point(parseFloat(i[1]),parseFloat(i[2]),0,0)}matchCoordinates(s){const i=[];do{const a=this.isMatch(["("]);i.push(this.matchCoordinate(s)),a&&this.expectGroupEnd()}while(this.isMatch([","]));return i}skipWhitespaces(){for(;this.position<this.value.length&&this.value[this.position]===" ";)this.position++}}return Jr.WktParser=e,Jr}var Qo;function ze(){return Qo||(Qo=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.ZigZag=r.WktParser=r.Polygon=r.Point=r.MultiPolygon=r.MultiPoint=r.MultiLineString=r.LineString=r.GeometryCollection=r.Geometry=r.CONSTANTS=r.BinaryWriter=r.BinaryReader=void 0;const t=cf();Object.defineProperty(r,"BinaryReader",{enumerable:!0,get:function(){return t.BinaryReader}});const e=Ke();Object.defineProperty(r,"BinaryWriter",{enumerable:!0,get:function(){return e.BinaryWriter}});const n=$e();Object.defineProperty(r,"CONSTANTS",{enumerable:!0,get:function(){return n.CONSTANTS}});const s=uf();Object.defineProperty(r,"Geometry",{enumerable:!0,get:function(){return s.Geometry}});const i=hf();Object.defineProperty(r,"GeometryCollection",{enumerable:!0,get:function(){return i.GeometryCollection}});const a=lf();Object.defineProperty(r,"LineString",{enumerable:!0,get:function(){return a.LineString}});const c=df();Object.defineProperty(r,"MultiLineString",{enumerable:!0,get:function(){return c.MultiLineString}});const d=ff();Object.defineProperty(r,"MultiPoint",{enumerable:!0,get:function(){return d.MultiPoint}});const f=pf();Object.defineProperty(r,"MultiPolygon",{enumerable:!0,get:function(){return f.MultiPolygon}});const y=Au();Object.defineProperty(r,"Point",{enumerable:!0,get:function(){return y.Point}});const B=yf();Object.defineProperty(r,"Polygon",{enumerable:!0,get:function(){return B.Polygon}});const L=gf();Object.defineProperty(r,"WktParser",{enumerable:!0,get:function(){return L.WktParser}});const x=xu();Object.defineProperty(r,"ZigZag",{enumerable:!0,get:function(){return x.ZigZag}})}(Pi)),Pi}var mf=ze(),zi={};var ta;function wf(){return ta||(ta=1,function(r){const t=Bu(),e=vu(),n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=c,r.SlowBuffer=C,r.INSPECT_MAX_BYTES=50;const s=2147483647;r.kMaxLength=s,c.TYPED_ARRAY_SUPPORT=i(),!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{const h=new Uint8Array(1),o={foo:function(){return 42}};return Object.setPrototypeOf(o,Uint8Array.prototype),Object.setPrototypeOf(h,o),h.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function a(h){if(h>s)throw new RangeError('The value "'+h+'" is invalid for option "size"');const o=new Uint8Array(h);return Object.setPrototypeOf(o,c.prototype),o}function c(h,o,u){if(typeof h=="number"){if(typeof o=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(h)}return d(h,o,u)}c.poolSize=8192;function d(h,o,u){if(typeof h=="string")return L(h,o);if(ArrayBuffer.isView(h))return M(h);if(h==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h);if(mt(h,ArrayBuffer)||h&&mt(h.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(mt(h,SharedArrayBuffer)||h&&mt(h.buffer,SharedArrayBuffer)))return U(h,o,u);if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const l=h.valueOf&&h.valueOf();if(l!=null&&l!==h)return c.from(l,o,u);const p=F(h);if(p)return p;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof h[Symbol.toPrimitive]=="function")return c.from(h[Symbol.toPrimitive]("string"),o,u);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h)}c.from=function(h,o,u){return d(h,o,u)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array);function f(h){if(typeof h!="number")throw new TypeError('"size" argument must be of type number');if(h<0)throw new RangeError('The value "'+h+'" is invalid for option "size"')}function y(h,o,u){return f(h),h<=0?a(h):o!==void 0?typeof u=="string"?a(h).fill(o,u):a(h).fill(o):a(h)}c.alloc=function(h,o,u){return y(h,o,u)};function B(h){return f(h),a(h<0?0:O(h)|0)}c.allocUnsafe=function(h){return B(h)},c.allocUnsafeSlow=function(h){return B(h)};function L(h,o){if((typeof o!="string"||o==="")&&(o="utf8"),!c.isEncoding(o))throw new TypeError("Unknown encoding: "+o);const u=P(h,o)|0;let l=a(u);const p=l.write(h,o);return p!==u&&(l=l.slice(0,p)),l}function x(h){const o=h.length<0?0:O(h.length)|0,u=a(o);for(let l=0;l<o;l+=1)u[l]=h[l]&255;return u}function M(h){if(mt(h,Uint8Array)){const o=new Uint8Array(h);return U(o.buffer,o.byteOffset,o.byteLength)}return x(h)}function U(h,o,u){if(o<0||h.byteLength<o)throw new RangeError('"offset" is outside of buffer bounds');if(h.byteLength<o+(u||0))throw new RangeError('"length" is outside of buffer bounds');let l;return o===void 0&&u===void 0?l=new Uint8Array(h):u===void 0?l=new Uint8Array(h,o):l=new Uint8Array(h,o,u),Object.setPrototypeOf(l,c.prototype),l}function F(h){if(c.isBuffer(h)){const o=O(h.length)|0,u=a(o);return u.length===0||h.copy(u,0,0,o),u}if(h.length!==void 0)return typeof h.length!="number"||Qt(h.length)?a(0):x(h);if(h.type==="Buffer"&&Array.isArray(h.data))return x(h.data)}function O(h){if(h>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return h|0}function C(h){return+h!=h&&(h=0),c.alloc(+h)}c.isBuffer=function(o){return o!=null&&o._isBuffer===!0&&o!==c.prototype},c.compare=function(o,u){if(mt(o,Uint8Array)&&(o=c.from(o,o.offset,o.byteLength)),mt(u,Uint8Array)&&(u=c.from(u,u.offset,u.byteLength)),!c.isBuffer(o)||!c.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(o===u)return 0;let l=o.length,p=u.length;for(let b=0,I=Math.min(l,p);b<I;++b)if(o[b]!==u[b]){l=o[b],p=u[b];break}return l<p?-1:p<l?1:0},c.isEncoding=function(o){switch(String(o).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(o,u){if(!Array.isArray(o))throw new TypeError('"list" argument must be an Array of Buffers');if(o.length===0)return c.alloc(0);let l;if(u===void 0)for(u=0,l=0;l<o.length;++l)u+=o[l].length;const p=c.allocUnsafe(u);let b=0;for(l=0;l<o.length;++l){let I=o[l];if(mt(I,Uint8Array))b+I.length>p.length?(c.isBuffer(I)||(I=c.from(I)),I.copy(p,b)):Uint8Array.prototype.set.call(p,I,b);else if(c.isBuffer(I))I.copy(p,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=I.length}return p};function P(h,o){if(c.isBuffer(h))return h.length;if(ArrayBuffer.isView(h)||mt(h,ArrayBuffer))return h.byteLength;if(typeof h!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof h);const u=h.length,l=arguments.length>2&&arguments[2]===!0;if(!l&&u===0)return 0;let p=!1;for(;;)switch(o){case"ascii":case"latin1":case"binary":return u;case"utf8":case"utf-8":return kt(h).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u*2;case"hex":return u>>>1;case"base64":return $t(h).length;default:if(p)return l?-1:kt(h).length;o=(""+o).toLowerCase(),p=!0}}c.byteLength=P;function V(h,o,u){let l=!1;if((o===void 0||o<0)&&(o=0),o>this.length||((u===void 0||u>this.length)&&(u=this.length),u<=0)||(u>>>=0,o>>>=0,u<=o))return"";for(h||(h="utf8");;)switch(h){case"hex":return X(this,o,u);case"utf8":case"utf-8":return z(this,o,u);case"ascii":return Y(this,o,u);case"latin1":case"binary":return Z(this,o,u);case"base64":return Q(this,o,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return K(this,o,u);default:if(l)throw new TypeError("Unknown encoding: "+h);h=(h+"").toLowerCase(),l=!0}}c.prototype._isBuffer=!0;function G(h,o,u){const l=h[o];h[o]=h[u],h[u]=l}c.prototype.swap16=function(){const o=this.length;if(o%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let u=0;u<o;u+=2)G(this,u,u+1);return this},c.prototype.swap32=function(){const o=this.length;if(o%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let u=0;u<o;u+=4)G(this,u,u+3),G(this,u+1,u+2);return this},c.prototype.swap64=function(){const o=this.length;if(o%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let u=0;u<o;u+=8)G(this,u,u+7),G(this,u+1,u+6),G(this,u+2,u+5),G(this,u+3,u+4);return this},c.prototype.toString=function(){const o=this.length;return o===0?"":arguments.length===0?z(this,0,o):V.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(o){if(!c.isBuffer(o))throw new TypeError("Argument must be a Buffer");return this===o?!0:c.compare(this,o)===0},c.prototype.inspect=function(){let o="";const u=r.INSPECT_MAX_BYTES;return o=this.toString("hex",0,u).replace(/(.{2})/g,"$1 ").trim(),this.length>u&&(o+=" ... "),"<Buffer "+o+">"},n&&(c.prototype[n]=c.prototype.inspect),c.prototype.compare=function(o,u,l,p,b){if(mt(o,Uint8Array)&&(o=c.from(o,o.offset,o.byteLength)),!c.isBuffer(o))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof o);if(u===void 0&&(u=0),l===void 0&&(l=o?o.length:0),p===void 0&&(p=0),b===void 0&&(b=this.length),u<0||l>o.length||p<0||b>this.length)throw new RangeError("out of range index");if(p>=b&&u>=l)return 0;if(p>=b)return-1;if(u>=l)return 1;if(u>>>=0,l>>>=0,p>>>=0,b>>>=0,this===o)return 0;let I=b-p,H=l-u;const pt=Math.min(I,H),lt=this.slice(p,b),yt=o.slice(u,l);for(let et=0;et<pt;++et)if(lt[et]!==yt[et]){I=lt[et],H=yt[et];break}return I<H?-1:H<I?1:0};function A(h,o,u,l,p){if(h.length===0)return-1;if(typeof u=="string"?(l=u,u=0):u>2147483647?u=2147483647:u<-2147483648&&(u=-2147483648),u=+u,Qt(u)&&(u=p?0:h.length-1),u<0&&(u=h.length+u),u>=h.length){if(p)return-1;u=h.length-1}else if(u<0)if(p)u=0;else return-1;if(typeof o=="string"&&(o=c.from(o,l)),c.isBuffer(o))return o.length===0?-1:N(h,o,u,l,p);if(typeof o=="number")return o=o&255,typeof Uint8Array.prototype.indexOf=="function"?p?Uint8Array.prototype.indexOf.call(h,o,u):Uint8Array.prototype.lastIndexOf.call(h,o,u):N(h,[o],u,l,p);throw new TypeError("val must be string, number or Buffer")}function N(h,o,u,l,p){let b=1,I=h.length,H=o.length;if(l!==void 0&&(l=String(l).toLowerCase(),l==="ucs2"||l==="ucs-2"||l==="utf16le"||l==="utf-16le")){if(h.length<2||o.length<2)return-1;b=2,I/=2,H/=2,u/=2}function pt(yt,et){return b===1?yt[et]:yt.readUInt16BE(et*b)}let lt;if(p){let yt=-1;for(lt=u;lt<I;lt++)if(pt(h,lt)===pt(o,yt===-1?0:lt-yt)){if(yt===-1&&(yt=lt),lt-yt+1===H)return yt*b}else yt!==-1&&(lt-=lt-yt),yt=-1}else for(u+H>I&&(u=I-H),lt=u;lt>=0;lt--){let yt=!0;for(let et=0;et<H;et++)if(pt(h,lt+et)!==pt(o,et)){yt=!1;break}if(yt)return lt}return-1}c.prototype.includes=function(o,u,l){return this.indexOf(o,u,l)!==-1},c.prototype.indexOf=function(o,u,l){return A(this,o,u,l,!0)},c.prototype.lastIndexOf=function(o,u,l){return A(this,o,u,l,!1)};function m(h,o,u,l){u=Number(u)||0;const p=h.length-u;l?(l=Number(l),l>p&&(l=p)):l=p;const b=o.length;l>b/2&&(l=b/2);let I;for(I=0;I<l;++I){const H=parseInt(o.substr(I*2,2),16);if(Qt(H))return I;h[u+I]=H}return I}function S(h,o,u,l){return Nt(kt(o,h.length-u),h,u,l)}function w(h,o,u,l){return Nt(Ht(o),h,u,l)}function v(h,o,u,l){return Nt($t(o),h,u,l)}function k(h,o,u,l){return Nt(Vt(o,h.length-u),h,u,l)}c.prototype.write=function(o,u,l,p){if(u===void 0)p="utf8",l=this.length,u=0;else if(l===void 0&&typeof u=="string")p=u,l=this.length,u=0;else if(isFinite(u))u=u>>>0,isFinite(l)?(l=l>>>0,p===void 0&&(p="utf8")):(p=l,l=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const b=this.length-u;if((l===void 0||l>b)&&(l=b),o.length>0&&(l<0||u<0)||u>this.length)throw new RangeError("Attempt to write outside buffer bounds");p||(p="utf8");let I=!1;for(;;)switch(p){case"hex":return m(this,o,u,l);case"utf8":case"utf-8":return S(this,o,u,l);case"ascii":case"latin1":case"binary":return w(this,o,u,l);case"base64":return v(this,o,u,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,o,u,l);default:if(I)throw new TypeError("Unknown encoding: "+p);p=(""+p).toLowerCase(),I=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Q(h,o,u){return o===0&&u===h.length?t.fromByteArray(h):t.fromByteArray(h.slice(o,u))}function z(h,o,u){u=Math.min(h.length,u);const l=[];let p=o;for(;p<u;){const b=h[p];let I=null,H=b>239?4:b>223?3:b>191?2:1;if(p+H<=u){let pt,lt,yt,et;switch(H){case 1:b<128&&(I=b);break;case 2:pt=h[p+1],(pt&192)===128&&(et=(b&31)<<6|pt&63,et>127&&(I=et));break;case 3:pt=h[p+1],lt=h[p+2],(pt&192)===128&&(lt&192)===128&&(et=(b&15)<<12|(pt&63)<<6|lt&63,et>2047&&(et<55296||et>57343)&&(I=et));break;case 4:pt=h[p+1],lt=h[p+2],yt=h[p+3],(pt&192)===128&&(lt&192)===128&&(yt&192)===128&&(et=(b&15)<<18|(pt&63)<<12|(lt&63)<<6|yt&63,et>65535&&et<1114112&&(I=et))}}I===null?(I=65533,H=1):I>65535&&(I-=65536,l.push(I>>>10&1023|55296),I=56320|I&1023),l.push(I),p+=H}return D(l)}const R=4096;function D(h){const o=h.length;if(o<=R)return String.fromCharCode.apply(String,h);let u="",l=0;for(;l<o;)u+=String.fromCharCode.apply(String,h.slice(l,l+=R));return u}function Y(h,o,u){let l="";u=Math.min(h.length,u);for(let p=o;p<u;++p)l+=String.fromCharCode(h[p]&127);return l}function Z(h,o,u){let l="";u=Math.min(h.length,u);for(let p=o;p<u;++p)l+=String.fromCharCode(h[p]);return l}function X(h,o,u){const l=h.length;(!o||o<0)&&(o=0),(!u||u<0||u>l)&&(u=l);let p="";for(let b=o;b<u;++b)p+=sr[h[b]];return p}function K(h,o,u){const l=h.slice(o,u);let p="";for(let b=0;b<l.length-1;b+=2)p+=String.fromCharCode(l[b]+l[b+1]*256);return p}c.prototype.slice=function(o,u){const l=this.length;o=~~o,u=u===void 0?l:~~u,o<0?(o+=l,o<0&&(o=0)):o>l&&(o=l),u<0?(u+=l,u<0&&(u=0)):u>l&&(u=l),u<o&&(u=o);const p=this.subarray(o,u);return Object.setPrototypeOf(p,c.prototype),p};function q(h,o,u){if(h%1!==0||h<0)throw new RangeError("offset is not uint");if(h+o>u)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(o,u,l){o=o>>>0,u=u>>>0,l||q(o,u,this.length);let p=this[o],b=1,I=0;for(;++I<u&&(b*=256);)p+=this[o+I]*b;return p},c.prototype.readUintBE=c.prototype.readUIntBE=function(o,u,l){o=o>>>0,u=u>>>0,l||q(o,u,this.length);let p=this[o+--u],b=1;for(;u>0&&(b*=256);)p+=this[o+--u]*b;return p},c.prototype.readUint8=c.prototype.readUInt8=function(o,u){return o=o>>>0,u||q(o,1,this.length),this[o]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(o,u){return o=o>>>0,u||q(o,2,this.length),this[o]|this[o+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(o,u){return o=o>>>0,u||q(o,2,this.length),this[o]<<8|this[o+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(o,u){return o=o>>>0,u||q(o,4,this.length),(this[o]|this[o+1]<<8|this[o+2]<<16)+this[o+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(o,u){return o=o>>>0,u||q(o,4,this.length),this[o]*16777216+(this[o+1]<<16|this[o+2]<<8|this[o+3])},c.prototype.readBigUInt64LE=Wt(function(o){o=o>>>0,$(o,"offset");const u=this[o],l=this[o+7];(u===void 0||l===void 0)&&J(o,this.length-8);const p=u+this[++o]*2**8+this[++o]*2**16+this[++o]*2**24,b=this[++o]+this[++o]*2**8+this[++o]*2**16+l*2**24;return BigInt(p)+(BigInt(b)<<BigInt(32))}),c.prototype.readBigUInt64BE=Wt(function(o){o=o>>>0,$(o,"offset");const u=this[o],l=this[o+7];(u===void 0||l===void 0)&&J(o,this.length-8);const p=u*2**24+this[++o]*2**16+this[++o]*2**8+this[++o],b=this[++o]*2**24+this[++o]*2**16+this[++o]*2**8+l;return(BigInt(p)<<BigInt(32))+BigInt(b)}),c.prototype.readIntLE=function(o,u,l){o=o>>>0,u=u>>>0,l||q(o,u,this.length);let p=this[o],b=1,I=0;for(;++I<u&&(b*=256);)p+=this[o+I]*b;return b*=128,p>=b&&(p-=Math.pow(2,8*u)),p},c.prototype.readIntBE=function(o,u,l){o=o>>>0,u=u>>>0,l||q(o,u,this.length);let p=u,b=1,I=this[o+--p];for(;p>0&&(b*=256);)I+=this[o+--p]*b;return b*=128,I>=b&&(I-=Math.pow(2,8*u)),I},c.prototype.readInt8=function(o,u){return o=o>>>0,u||q(o,1,this.length),this[o]&128?(255-this[o]+1)*-1:this[o]},c.prototype.readInt16LE=function(o,u){o=o>>>0,u||q(o,2,this.length);const l=this[o]|this[o+1]<<8;return l&32768?l|4294901760:l},c.prototype.readInt16BE=function(o,u){o=o>>>0,u||q(o,2,this.length);const l=this[o+1]|this[o]<<8;return l&32768?l|4294901760:l},c.prototype.readInt32LE=function(o,u){return o=o>>>0,u||q(o,4,this.length),this[o]|this[o+1]<<8|this[o+2]<<16|this[o+3]<<24},c.prototype.readInt32BE=function(o,u){return o=o>>>0,u||q(o,4,this.length),this[o]<<24|this[o+1]<<16|this[o+2]<<8|this[o+3]},c.prototype.readBigInt64LE=Wt(function(o){o=o>>>0,$(o,"offset");const u=this[o],l=this[o+7];(u===void 0||l===void 0)&&J(o,this.length-8);const p=this[o+4]+this[o+5]*2**8+this[o+6]*2**16+(l<<24);return(BigInt(p)<<BigInt(32))+BigInt(u+this[++o]*2**8+this[++o]*2**16+this[++o]*2**24)}),c.prototype.readBigInt64BE=Wt(function(o){o=o>>>0,$(o,"offset");const u=this[o],l=this[o+7];(u===void 0||l===void 0)&&J(o,this.length-8);const p=(u<<24)+this[++o]*2**16+this[++o]*2**8+this[++o];return(BigInt(p)<<BigInt(32))+BigInt(this[++o]*2**24+this[++o]*2**16+this[++o]*2**8+l)}),c.prototype.readFloatLE=function(o,u){return o=o>>>0,u||q(o,4,this.length),e.read(this,o,!0,23,4)},c.prototype.readFloatBE=function(o,u){return o=o>>>0,u||q(o,4,this.length),e.read(this,o,!1,23,4)},c.prototype.readDoubleLE=function(o,u){return o=o>>>0,u||q(o,8,this.length),e.read(this,o,!0,52,8)},c.prototype.readDoubleBE=function(o,u){return o=o>>>0,u||q(o,8,this.length),e.read(this,o,!1,52,8)};function rt(h,o,u,l,p,b){if(!c.isBuffer(h))throw new TypeError('"buffer" argument must be a Buffer instance');if(o>p||o<b)throw new RangeError('"value" argument is out of bounds');if(u+l>h.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(o,u,l,p){if(o=+o,u=u>>>0,l=l>>>0,!p){const H=Math.pow(2,8*l)-1;rt(this,o,u,l,H,0)}let b=1,I=0;for(this[u]=o&255;++I<l&&(b*=256);)this[u+I]=o/b&255;return u+l},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(o,u,l,p){if(o=+o,u=u>>>0,l=l>>>0,!p){const H=Math.pow(2,8*l)-1;rt(this,o,u,l,H,0)}let b=l-1,I=1;for(this[u+b]=o&255;--b>=0&&(I*=256);)this[u+b]=o/I&255;return u+l},c.prototype.writeUint8=c.prototype.writeUInt8=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,1,255,0),this[u]=o&255,u+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,2,65535,0),this[u]=o&255,this[u+1]=o>>>8,u+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,2,65535,0),this[u]=o>>>8,this[u+1]=o&255,u+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,4,4294967295,0),this[u+3]=o>>>24,this[u+2]=o>>>16,this[u+1]=o>>>8,this[u]=o&255,u+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,4,4294967295,0),this[u]=o>>>24,this[u+1]=o>>>16,this[u+2]=o>>>8,this[u+3]=o&255,u+4};function At(h,o,u,l,p){j(o,l,p,h,u,7);let b=Number(o&BigInt(4294967295));h[u++]=b,b=b>>8,h[u++]=b,b=b>>8,h[u++]=b,b=b>>8,h[u++]=b;let I=Number(o>>BigInt(32)&BigInt(4294967295));return h[u++]=I,I=I>>8,h[u++]=I,I=I>>8,h[u++]=I,I=I>>8,h[u++]=I,u}function Ut(h,o,u,l,p){j(o,l,p,h,u,7);let b=Number(o&BigInt(4294967295));h[u+7]=b,b=b>>8,h[u+6]=b,b=b>>8,h[u+5]=b,b=b>>8,h[u+4]=b;let I=Number(o>>BigInt(32)&BigInt(4294967295));return h[u+3]=I,I=I>>8,h[u+2]=I,I=I>>8,h[u+1]=I,I=I>>8,h[u]=I,u+8}c.prototype.writeBigUInt64LE=Wt(function(o,u=0){return At(this,o,u,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=Wt(function(o,u=0){return Ut(this,o,u,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(o,u,l,p){if(o=+o,u=u>>>0,!p){const pt=Math.pow(2,8*l-1);rt(this,o,u,l,pt-1,-pt)}let b=0,I=1,H=0;for(this[u]=o&255;++b<l&&(I*=256);)o<0&&H===0&&this[u+b-1]!==0&&(H=1),this[u+b]=(o/I>>0)-H&255;return u+l},c.prototype.writeIntBE=function(o,u,l,p){if(o=+o,u=u>>>0,!p){const pt=Math.pow(2,8*l-1);rt(this,o,u,l,pt-1,-pt)}let b=l-1,I=1,H=0;for(this[u+b]=o&255;--b>=0&&(I*=256);)o<0&&H===0&&this[u+b+1]!==0&&(H=1),this[u+b]=(o/I>>0)-H&255;return u+l},c.prototype.writeInt8=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,1,127,-128),o<0&&(o=255+o+1),this[u]=o&255,u+1},c.prototype.writeInt16LE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,2,32767,-32768),this[u]=o&255,this[u+1]=o>>>8,u+2},c.prototype.writeInt16BE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,2,32767,-32768),this[u]=o>>>8,this[u+1]=o&255,u+2},c.prototype.writeInt32LE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,4,2147483647,-2147483648),this[u]=o&255,this[u+1]=o>>>8,this[u+2]=o>>>16,this[u+3]=o>>>24,u+4},c.prototype.writeInt32BE=function(o,u,l){return o=+o,u=u>>>0,l||rt(this,o,u,4,2147483647,-2147483648),o<0&&(o=4294967295+o+1),this[u]=o>>>24,this[u+1]=o>>>16,this[u+2]=o>>>8,this[u+3]=o&255,u+4},c.prototype.writeBigInt64LE=Wt(function(o,u=0){return At(this,o,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=Wt(function(o,u=0){return Ut(this,o,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Pt(h,o,u,l,p,b){if(u+l>h.length)throw new RangeError("Index out of range");if(u<0)throw new RangeError("Index out of range")}function Zt(h,o,u,l,p){return o=+o,u=u>>>0,p||Pt(h,o,u,4),e.write(h,o,u,l,23,4),u+4}c.prototype.writeFloatLE=function(o,u,l){return Zt(this,o,u,!0,l)},c.prototype.writeFloatBE=function(o,u,l){return Zt(this,o,u,!1,l)};function Gt(h,o,u,l,p){return o=+o,u=u>>>0,p||Pt(h,o,u,8),e.write(h,o,u,l,52,8),u+8}c.prototype.writeDoubleLE=function(o,u,l){return Gt(this,o,u,!0,l)},c.prototype.writeDoubleBE=function(o,u,l){return Gt(this,o,u,!1,l)},c.prototype.copy=function(o,u,l,p){if(!c.isBuffer(o))throw new TypeError("argument should be a Buffer");if(l||(l=0),!p&&p!==0&&(p=this.length),u>=o.length&&(u=o.length),u||(u=0),p>0&&p<l&&(p=l),p===l||o.length===0||this.length===0)return 0;if(u<0)throw new RangeError("targetStart out of bounds");if(l<0||l>=this.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("sourceEnd out of bounds");p>this.length&&(p=this.length),o.length-u<p-l&&(p=o.length-u+l);const b=p-l;return this===o&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(u,l,p):Uint8Array.prototype.set.call(o,this.subarray(l,p),u),b},c.prototype.fill=function(o,u,l,p){if(typeof o=="string"){if(typeof u=="string"?(p=u,u=0,l=this.length):typeof l=="string"&&(p=l,l=this.length),p!==void 0&&typeof p!="string")throw new TypeError("encoding must be a string");if(typeof p=="string"&&!c.isEncoding(p))throw new TypeError("Unknown encoding: "+p);if(o.length===1){const I=o.charCodeAt(0);(p==="utf8"&&I<128||p==="latin1")&&(o=I)}}else typeof o=="number"?o=o&255:typeof o=="boolean"&&(o=Number(o));if(u<0||this.length<u||this.length<l)throw new RangeError("Out of range index");if(l<=u)return this;u=u>>>0,l=l===void 0?this.length:l>>>0,o||(o=0);let b;if(typeof o=="number")for(b=u;b<l;++b)this[b]=o;else{const I=c.isBuffer(o)?o:c.from(o,p),H=I.length;if(H===0)throw new TypeError('The value "'+o+'" is invalid for argument "value"');for(b=0;b<l-u;++b)this[b+u]=I[b%H]}return this};const W={};function g(h,o,u){W[h]=class extends u{constructor(){super(),Object.defineProperty(this,"message",{value:o.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${h}]`,this.stack,delete this.name}get code(){return h}set code(p){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:p,writable:!0})}toString(){return`${this.name} [${h}]: ${this.message}`}}}g("ERR_BUFFER_OUT_OF_BOUNDS",function(h){return h?`${h} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),g("ERR_INVALID_ARG_TYPE",function(h,o){return`The "${h}" argument must be of type number. Received type ${typeof o}`},TypeError),g("ERR_OUT_OF_RANGE",function(h,o,u){let l=`The value of "${h}" is out of range.`,p=u;return Number.isInteger(u)&&Math.abs(u)>2**32?p=_(String(u)):typeof u=="bigint"&&(p=String(u),(u>BigInt(2)**BigInt(32)||u<-(BigInt(2)**BigInt(32)))&&(p=_(p)),p+="n"),l+=` It must be ${o}. Received ${p}`,l},RangeError);function _(h){let o="",u=h.length;const l=h[0]==="-"?1:0;for(;u>=l+4;u-=3)o=`_${h.slice(u-3,u)}${o}`;return`${h.slice(0,u)}${o}`}function T(h,o,u){$(o,"offset"),(h[o]===void 0||h[o+u]===void 0)&&J(o,h.length-(u+1))}function j(h,o,u,l,p,b){if(h>u||h<o){const I=typeof o=="bigint"?"n":"";let H;throw o===0||o===BigInt(0)?H=`>= 0${I} and < 2${I} ** ${(b+1)*8}${I}`:H=`>= -(2${I} ** ${(b+1)*8-1}${I}) and < 2 ** ${(b+1)*8-1}${I}`,new W.ERR_OUT_OF_RANGE("value",H,h)}T(l,p,b)}function $(h,o){if(typeof h!="number")throw new W.ERR_INVALID_ARG_TYPE(o,"number",h)}function J(h,o,u){throw Math.floor(h)!==h?($(h,u),new W.ERR_OUT_OF_RANGE("offset","an integer",h)):o<0?new W.ERR_BUFFER_OUT_OF_BOUNDS:new W.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${o}`,h)}const bt=/[^+/0-9A-Za-z-_]/g;function Ot(h){if(h=h.split("=")[0],h=h.trim().replace(bt,""),h.length<2)return"";for(;h.length%4!==0;)h=h+"=";return h}function kt(h,o){o=o||1/0;let u;const l=h.length;let p=null;const b=[];for(let I=0;I<l;++I){if(u=h.charCodeAt(I),u>55295&&u<57344){if(!p){if(u>56319){(o-=3)>-1&&b.push(239,191,189);continue}else if(I+1===l){(o-=3)>-1&&b.push(239,191,189);continue}p=u;continue}if(u<56320){(o-=3)>-1&&b.push(239,191,189),p=u;continue}u=(p-55296<<10|u-56320)+65536}else p&&(o-=3)>-1&&b.push(239,191,189);if(p=null,u<128){if((o-=1)<0)break;b.push(u)}else if(u<2048){if((o-=2)<0)break;b.push(u>>6|192,u&63|128)}else if(u<65536){if((o-=3)<0)break;b.push(u>>12|224,u>>6&63|128,u&63|128)}else if(u<1114112){if((o-=4)<0)break;b.push(u>>18|240,u>>12&63|128,u>>6&63|128,u&63|128)}else throw new Error("Invalid code point")}return b}function Ht(h){const o=[];for(let u=0;u<h.length;++u)o.push(h.charCodeAt(u)&255);return o}function Vt(h,o){let u,l,p;const b=[];for(let I=0;I<h.length&&!((o-=2)<0);++I)u=h.charCodeAt(I),l=u>>8,p=u%256,b.push(p),b.push(l);return b}function $t(h){return t.toByteArray(Ot(h))}function Nt(h,o,u,l){let p;for(p=0;p<l&&!(p+u>=o.length||p>=h.length);++p)o[p+u]=h[p];return p}function mt(h,o){return h instanceof o||h!=null&&h.constructor!=null&&h.constructor.name!=null&&h.constructor.name===o.name}function Qt(h){return h!==h}const sr=function(){const h="0123456789abcdef",o=new Array(256);for(let u=0;u<16;++u){const l=u*16;for(let p=0;p<16;++p)o[l+p]=h[u]+h[p]}return o}();function Wt(h){return typeof BigInt>"u"?Fi:h}function Fi(){throw new Error("BigInt not supported")}}(zi)),zi}var Eu=wf();function Ei(r){return new Promise((t,e)=>{r.oncomplete=r.onsuccess=()=>t(r.result),r.onabort=r.onerror=()=>e(r.error)})}function Tu(r,t){const e=indexedDB.open(r);e.onupgradeneeded=()=>e.result.createObjectStore(t);const n=Ei(e);return(s,i)=>n.then(a=>i(a.transaction(t,s).objectStore(t)))}let ji;function Zs(){return ji||(ji=Tu("keyval-store","keyval")),ji}function Vi(r,t=Zs()){return t("readonly",e=>Ei(e.get(r)))}function ea(r,t,e=Zs()){return e("readwrite",n=>(n.put(t,r),Ei(n.transaction)))}function xn(r,t=Zs()){return t("readwrite",e=>(e.delete(r),Ei(e.transaction)))}function An(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Wi={exports:{}},ra;function bf(){return ra||(ra=1,function(r,t){(function(e){r.exports=e()})(function(){return function e(n,s,i){function a(f,y){if(!s[f]){if(!n[f]){var B=typeof An=="function"&&An;if(!y&&B)return B(f,!0);if(c)return c(f,!0);throw new Error("Cannot find module '"+f+"'")}y=s[f]={exports:{}},n[f][0].call(y.exports,function(L){var x=n[f][1][L];return a(x||L)},y,y.exports,e,n,s,i)}return s[f].exports}for(var c=typeof An=="function"&&An,d=0;d<i.length;d++)a(i[d]);return a}({1:[function(e,n,s){(function(i,a,c,d,f,y,B,L,x){var M=e("crypto");function U(A,N){N=C(A,N);var m;return(m=N.algorithm!=="passthrough"?M.createHash(N.algorithm):new G).write===void 0&&(m.write=m.update,m.end=m.update),V(N,m).dispatch(A),m.update||m.end(""),m.digest?m.digest(N.encoding==="buffer"?void 0:N.encoding):(A=m.read(),N.encoding!=="buffer"?A.toString(N.encoding):A)}(s=n.exports=U).sha1=function(A){return U(A)},s.keys=function(A){return U(A,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},s.MD5=function(A){return U(A,{algorithm:"md5",encoding:"hex"})},s.keysMD5=function(A){return U(A,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var F=M.getHashes?M.getHashes().slice():["sha1","md5"],O=(F.push("passthrough"),["buffer","hex","binary","base64"]);function C(A,N){var m={};if(m.algorithm=(N=N||{}).algorithm||"sha1",m.encoding=N.encoding||"hex",m.excludeValues=!!N.excludeValues,m.algorithm=m.algorithm.toLowerCase(),m.encoding=m.encoding.toLowerCase(),m.ignoreUnknown=N.ignoreUnknown===!0,m.respectType=N.respectType!==!1,m.respectFunctionNames=N.respectFunctionNames!==!1,m.respectFunctionProperties=N.respectFunctionProperties!==!1,m.unorderedArrays=N.unorderedArrays===!0,m.unorderedSets=N.unorderedSets!==!1,m.unorderedObjects=N.unorderedObjects!==!1,m.replacer=N.replacer||void 0,m.excludeKeys=N.excludeKeys||void 0,A===void 0)throw new Error("Object argument required.");for(var S=0;S<F.length;++S)F[S].toLowerCase()===m.algorithm.toLowerCase()&&(m.algorithm=F[S]);if(F.indexOf(m.algorithm)===-1)throw new Error('Algorithm "'+m.algorithm+'" not supported. supported values: '+F.join(", "));if(O.indexOf(m.encoding)===-1&&m.algorithm!=="passthrough")throw new Error('Encoding "'+m.encoding+'" not supported. supported values: '+O.join(", "));return m}function P(A){if(typeof A=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(A))!=null}function V(A,N,m){m=m||[];function S(w){return N.update?N.update(w,"utf8"):N.write(w,"utf8")}return{dispatch:function(w){return this["_"+((w=A.replacer?A.replacer(w):w)===null?"null":typeof w)](w)},_object:function(w){var v,k=Object.prototype.toString.call(w),Q=/\[object (.*)\]/i.exec(k);if(Q=(Q=Q?Q[1]:"unknown:["+k+"]").toLowerCase(),0<=(k=m.indexOf(w)))return this.dispatch("[CIRCULAR:"+k+"]");if(m.push(w),c!==void 0&&c.isBuffer&&c.isBuffer(w))return S("buffer:"),S(w);if(Q==="object"||Q==="function"||Q==="asyncfunction")return k=Object.keys(w),A.unorderedObjects&&(k=k.sort()),A.respectType===!1||P(w)||k.splice(0,0,"prototype","__proto__","constructor"),A.excludeKeys&&(k=k.filter(function(z){return!A.excludeKeys(z)})),S("object:"+k.length+":"),v=this,k.forEach(function(z){v.dispatch(z),S(":"),A.excludeValues||v.dispatch(w[z]),S(",")});if(!this["_"+Q]){if(A.ignoreUnknown)return S("["+Q+"]");throw new Error('Unknown object type "'+Q+'"')}this["_"+Q](w)},_array:function(w,z){z=z!==void 0?z:A.unorderedArrays!==!1;var k=this;if(S("array:"+w.length+":"),!z||w.length<=1)return w.forEach(function(R){return k.dispatch(R)});var Q=[],z=w.map(function(R){var D=new G,Y=m.slice();return V(A,D,Y).dispatch(R),Q=Q.concat(Y.slice(m.length)),D.read().toString()});return m=m.concat(Q),z.sort(),this._array(z,!1)},_date:function(w){return S("date:"+w.toJSON())},_symbol:function(w){return S("symbol:"+w.toString())},_error:function(w){return S("error:"+w.toString())},_boolean:function(w){return S("bool:"+w.toString())},_string:function(w){S("string:"+w.length+":"),S(w.toString())},_function:function(w){S("fn:"),P(w)?this.dispatch("[native]"):this.dispatch(w.toString()),A.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(w.name)),A.respectFunctionProperties&&this._object(w)},_number:function(w){return S("number:"+w.toString())},_xml:function(w){return S("xml:"+w.toString())},_null:function(){return S("Null")},_undefined:function(){return S("Undefined")},_regexp:function(w){return S("regex:"+w.toString())},_uint8array:function(w){return S("uint8array:"),this.dispatch(Array.prototype.slice.call(w))},_uint8clampedarray:function(w){return S("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(w))},_int8array:function(w){return S("int8array:"),this.dispatch(Array.prototype.slice.call(w))},_uint16array:function(w){return S("uint16array:"),this.dispatch(Array.prototype.slice.call(w))},_int16array:function(w){return S("int16array:"),this.dispatch(Array.prototype.slice.call(w))},_uint32array:function(w){return S("uint32array:"),this.dispatch(Array.prototype.slice.call(w))},_int32array:function(w){return S("int32array:"),this.dispatch(Array.prototype.slice.call(w))},_float32array:function(w){return S("float32array:"),this.dispatch(Array.prototype.slice.call(w))},_float64array:function(w){return S("float64array:"),this.dispatch(Array.prototype.slice.call(w))},_arraybuffer:function(w){return S("arraybuffer:"),this.dispatch(new Uint8Array(w))},_url:function(w){return S("url:"+w.toString())},_map:function(w){return S("map:"),w=Array.from(w),this._array(w,A.unorderedSets!==!1)},_set:function(w){return S("set:"),w=Array.from(w),this._array(w,A.unorderedSets!==!1)},_file:function(w){return S("file:"),this.dispatch([w.name,w.size,w.type,w.lastModfied])},_blob:function(){if(A.ignoreUnknown)return S("[blob]");throw Error(`Hashing Blob objects is currently not supported
5
5
  (see https://github.com/puleos/object-hash/issues/26)
6
6
  Use "options.replacer" or "options.ignoreUnknown"
7
- `)},_domwindow:function(){return S("domwindow")},_bigint:function(w){return S("bigint:"+w.toString())},_process:function(){return S("process")},_timer:function(){return S("timer")},_pipe:function(){return S("pipe")},_tcp:function(){return S("tcp")},_udp:function(){return S("udp")},_tty:function(){return S("tty")},_statwatcher:function(){return S("statwatcher")},_securecontext:function(){return S("securecontext")},_connection:function(){return S("connection")},_zlib:function(){return S("zlib")},_context:function(){return S("context")},_nodescript:function(){return S("nodescript")},_httpparser:function(){return S("httpparser")},_dataview:function(){return S("dataview")},_signal:function(){return S("signal")},_fsevent:function(){return S("fsevent")},_tlswrap:function(){return S("tlswrap")}}}function G(){return{buf:"",write:function(A){this.buf+=A},end:function(A){this.buf+=A},read:function(){return this.buf}}}o.writeToStream=function(A,O,m){return m===void 0&&(m=O,O={}),V(O=P(A,O),m).dispatch(A)}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){(function(T){var U=typeof Uint8Array<"u"?Uint8Array:Array,M=43,k=47,P=48,R=97,V=65,G=45,A=95;function O(m){return m=m.charCodeAt(0),m===M||m===G?62:m===k||m===A?63:m<P?-1:m<P+10?m-P+26+26:m<V+26?m-V:m<R+26?m-R+26:void 0}T.toByteArray=function(m){var S,w;if(0<m.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var B=m.length,B=m.charAt(B-2)==="="?2:m.charAt(B-1)==="="?1:0,N=new U(3*m.length/4-B),Q=0<B?m.length-4:m.length,z=0;function L(D){N[z++]=D}for(S=0;S<Q;S+=4,0)L((16711680&(w=O(m.charAt(S))<<18|O(m.charAt(S+1))<<12|O(m.charAt(S+2))<<6|O(m.charAt(S+3))))>>16),L((65280&w)>>8),L(255&w);return B==2?L(255&(w=O(m.charAt(S))<<2|O(m.charAt(S+1))>>4)):B==1&&(L((w=O(m.charAt(S))<<10|O(m.charAt(S+1))<<4|O(m.charAt(S+2))>>2)>>8&255),L(255&w)),N},T.fromByteArray=function(m){var S,w,B,N,Q=m.length%3,z="";function L(D){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(D)}for(S=0,B=m.length-Q;S<B;S+=3)w=(m[S]<<16)+(m[S+1]<<8)+m[S+2],z+=L((N=w)>>18&63)+L(N>>12&63)+L(N>>6&63)+L(63&N);switch(Q){case 1:z=(z+=L((w=m[m.length-1])>>2))+L(w<<4&63)+"==";break;case 2:z=(z=(z+=L((w=(m[m.length-2]<<8)+m[m.length-1])>>10))+L(w>>4&63))+L(w<<2&63)+"="}return z}})(o===void 0?this.base64js={}:o)}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(e,n,o){(function(i,a,M,f,p,g,v,C,F){var T=e("base64-js"),U=e("ieee754");function M(y,_,E){if(!(this instanceof M))return new M(y,_,E);var j,$,J,bt,Nt=typeof y;if(_==="base64"&&Nt=="string")for(y=(bt=y).trim?bt.trim():bt.replace(/^\s+|\s+$/g,"");y.length%4!=0;)y+="=";if(Nt=="number")j=Z(y);else if(Nt=="string")j=M.byteLength(y,_);else{if(Nt!="object")throw new Error("First argument needs to be a number, array or string.");j=Z(y.length)}if(M._useTypedArrays?$=M._augment(new Uint8Array(j)):(($=this).length=j,$._isBuffer=!0),M._useTypedArrays&&typeof y.byteLength=="number")$._set(y);else if(X(bt=y)||M.isBuffer(bt)||bt&&typeof bt=="object"&&typeof bt.length=="number")for(J=0;J<j;J++)M.isBuffer(y)?$[J]=y.readUInt8(J):$[J]=y[J];else if(Nt=="string")$.write(y,0,_);else if(Nt=="number"&&!M._useTypedArrays&&!E)for(J=0;J<j;J++)$[J]=0;return $}function k(y,_,E,j){return M._charsWritten=xt(function($){for(var J=[],bt=0;bt<$.length;bt++)J.push(255&$.charCodeAt(bt));return J}(_),y,E,j)}function P(y,_,E,j){return M._charsWritten=xt(function($){for(var J,bt,Nt=[],kt=0;kt<$.length;kt++)bt=$.charCodeAt(kt),J=bt>>8,bt=bt%256,Nt.push(bt),Nt.push(J);return Nt}(_),y,E,j)}function R(y,_,E){var j="";E=Math.min(y.length,E);for(var $=_;$<E;$++)j+=String.fromCharCode(y[$]);return j}function V(y,_,E,J){J||(W(typeof E=="boolean","missing or invalid endian"),W(_!=null,"missing offset"),W(_+1<y.length,"Trying to read beyond buffer length"));var $,J=y.length;if(!(J<=_))return E?($=y[_],_+1<J&&($|=y[_+1]<<8)):($=y[_]<<8,_+1<J&&($|=y[_+1])),$}function G(y,_,E,J){J||(W(typeof E=="boolean","missing or invalid endian"),W(_!=null,"missing offset"),W(_+3<y.length,"Trying to read beyond buffer length"));var $,J=y.length;if(!(J<=_))return E?(_+2<J&&($=y[_+2]<<16),_+1<J&&($|=y[_+1]<<8),$|=y[_],_+3<J&&($+=y[_+3]<<24>>>0)):(_+1<J&&($=y[_+1]<<16),_+2<J&&($|=y[_+2]<<8),_+3<J&&($|=y[_+3]),$+=y[_]<<24>>>0),$}function A(y,_,E,j){if(j||(W(typeof E=="boolean","missing or invalid endian"),W(_!=null,"missing offset"),W(_+1<y.length,"Trying to read beyond buffer length")),!(y.length<=_))return j=V(y,_,E,!0),32768&j?-1*(65535-j+1):j}function O(y,_,E,j){if(j||(W(typeof E=="boolean","missing or invalid endian"),W(_!=null,"missing offset"),W(_+3<y.length,"Trying to read beyond buffer length")),!(y.length<=_))return j=G(y,_,E,!0),2147483648&j?-1*(4294967295-j+1):j}function m(y,_,E,j){return j||(W(typeof E=="boolean","missing or invalid endian"),W(_+3<y.length,"Trying to read beyond buffer length")),U.read(y,_,E,23,4)}function S(y,_,E,j){return j||(W(typeof E=="boolean","missing or invalid endian"),W(_+7<y.length,"Trying to read beyond buffer length")),U.read(y,_,E,52,8)}function w(y,_,E,j,$){if($||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(E!=null,"missing offset"),W(E+1<y.length,"trying to write beyond buffer length"),Pt(_,65535)),$=y.length,!($<=E))for(var J=0,bt=Math.min($-E,2);J<bt;J++)y[E+J]=(_&255<<8*(j?J:1-J))>>>8*(j?J:1-J)}function B(y,_,E,j,$){if($||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(E!=null,"missing offset"),W(E+3<y.length,"trying to write beyond buffer length"),Pt(_,4294967295)),$=y.length,!($<=E))for(var J=0,bt=Math.min($-E,4);J<bt;J++)y[E+J]=_>>>8*(j?J:3-J)&255}function N(y,_,E,j,$){$||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(E!=null,"missing offset"),W(E+1<y.length,"Trying to write beyond buffer length"),Zt(_,32767,-32768)),y.length<=E||w(y,0<=_?_:65535+_+1,E,j,$)}function Q(y,_,E,j,$){$||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(E!=null,"missing offset"),W(E+3<y.length,"Trying to write beyond buffer length"),Zt(_,2147483647,-2147483648)),y.length<=E||B(y,0<=_?_:4294967295+_+1,E,j,$)}function z(y,_,E,j,$){$||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(E!=null,"missing offset"),W(E+3<y.length,"Trying to write beyond buffer length"),Gt(_,34028234663852886e22,-34028234663852886e22)),y.length<=E||U.write(y,_,E,j,23,4)}function L(y,_,E,j,$){$||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(E!=null,"missing offset"),W(E+7<y.length,"Trying to write beyond buffer length"),Gt(_,17976931348623157e292,-17976931348623157e292)),y.length<=E||U.write(y,_,E,j,52,8)}o.Buffer=M,o.SlowBuffer=M,o.INSPECT_MAX_BYTES=50,M.poolSize=8192,M._useTypedArrays=function(){try{var y=new ArrayBuffer(0),_=new Uint8Array(y);return _.foo=function(){return 42},_.foo()===42&&typeof _.subarray=="function"}catch{return!1}}(),M.isEncoding=function(y){switch(String(y).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},M.isBuffer=function(y){return!(y==null||!y._isBuffer)},M.byteLength=function(y,_){var E;switch(y+="",_||"utf8"){case"hex":E=y.length/2;break;case"utf8":case"utf-8":E=q(y).length;break;case"ascii":case"binary":case"raw":E=y.length;break;case"base64":E=rt(y).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":E=2*y.length;break;default:throw new Error("Unknown encoding")}return E},M.concat=function(y,_){if(W(X(y),`Usage: Buffer.concat(list, [totalLength])
8
- list should be an Array.`),y.length===0)return new M(0);if(y.length===1)return y[0];if(typeof _!="number")for($=_=0;$<y.length;$++)_+=y[$].length;for(var E=new M(_),j=0,$=0;$<y.length;$++){var J=y[$];J.copy(E,j),j+=J.length}return E},M.prototype.write=function(y,_,E,j){isFinite(_)?isFinite(E)||(j=E,E=void 0):(kt=j,j=_,_=E,E=kt),_=Number(_)||0;var $,J,bt,Nt,kt=this.length-_;switch((!E||kt<(E=Number(E)))&&(E=kt),j=String(j||"utf8").toLowerCase()){case"hex":$=function(Ht,Vt,$t,Mt){$t=Number($t)||0;var mt=Ht.length-$t;(!Mt||mt<(Mt=Number(Mt)))&&(Mt=mt),W((mt=Vt.length)%2==0,"Invalid hex string"),mt/2<Mt&&(Mt=mt/2);for(var Qt=0;Qt<Mt;Qt++){var ir=parseInt(Vt.substr(2*Qt,2),16);W(!isNaN(ir),"Invalid hex string"),Ht[$t+Qt]=ir}return M._charsWritten=2*Qt,Qt}(this,y,_,E);break;case"utf8":case"utf-8":J=this,bt=_,Nt=E,$=M._charsWritten=xt(q(y),J,bt,Nt);break;case"ascii":case"binary":$=k(this,y,_,E);break;case"base64":J=this,bt=_,Nt=E,$=M._charsWritten=xt(rt(y),J,bt,Nt);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":$=P(this,y,_,E);break;default:throw new Error("Unknown encoding")}return $},M.prototype.toString=function(y,_,E){var j,$,J,bt,Nt=this;if(y=String(y||"utf8").toLowerCase(),_=Number(_)||0,(E=E!==void 0?Number(E):Nt.length)===_)return"";switch(y){case"hex":j=function(kt,Ht,Vt){var $t=kt.length;(!Ht||Ht<0)&&(Ht=0),(!Vt||Vt<0||$t<Vt)&&(Vt=$t);for(var Mt="",mt=Ht;mt<Vt;mt++)Mt+=K(kt[mt]);return Mt}(Nt,_,E);break;case"utf8":case"utf-8":j=function(kt,Ht,Vt){var $t="",Mt="";Vt=Math.min(kt.length,Vt);for(var mt=Ht;mt<Vt;mt++)kt[mt]<=127?($t+=Ut(Mt)+String.fromCharCode(kt[mt]),Mt=""):Mt+="%"+kt[mt].toString(16);return $t+Ut(Mt)}(Nt,_,E);break;case"ascii":case"binary":j=R(Nt,_,E);break;case"base64":$=Nt,bt=E,j=(J=_)===0&&bt===$.length?T.fromByteArray($):T.fromByteArray($.slice(J,bt));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":j=function(kt,Ht,Vt){for(var $t=kt.slice(Ht,Vt),Mt="",mt=0;mt<$t.length;mt+=2)Mt+=String.fromCharCode($t[mt]+256*$t[mt+1]);return Mt}(Nt,_,E);break;default:throw new Error("Unknown encoding")}return j},M.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},M.prototype.copy=function(y,_,E,j){if(_=_||0,(j=j||j===0?j:this.length)!==(E=E||0)&&y.length!==0&&this.length!==0){W(E<=j,"sourceEnd < sourceStart"),W(0<=_&&_<y.length,"targetStart out of bounds"),W(0<=E&&E<this.length,"sourceStart out of bounds"),W(0<=j&&j<=this.length,"sourceEnd out of bounds"),j>this.length&&(j=this.length);var $=(j=y.length-_<j-E?y.length-_+E:j)-E;if($<100||!M._useTypedArrays)for(var J=0;J<$;J++)y[J+_]=this[J+E];else y._set(this.subarray(E,E+$),_)}},M.prototype.slice=function(y,_){var E=this.length;if(y=Y(y,E,0),_=Y(_,E,E),M._useTypedArrays)return M._augment(this.subarray(y,_));for(var j=_-y,$=new M(j,void 0,!0),J=0;J<j;J++)$[J]=this[J+y];return $},M.prototype.get=function(y){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(y)},M.prototype.set=function(y,_){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(y,_)},M.prototype.readUInt8=function(y,_){if(_||(W(y!=null,"missing offset"),W(y<this.length,"Trying to read beyond buffer length")),!(y>=this.length))return this[y]},M.prototype.readUInt16LE=function(y,_){return V(this,y,!0,_)},M.prototype.readUInt16BE=function(y,_){return V(this,y,!1,_)},M.prototype.readUInt32LE=function(y,_){return G(this,y,!0,_)},M.prototype.readUInt32BE=function(y,_){return G(this,y,!1,_)},M.prototype.readInt8=function(y,_){if(_||(W(y!=null,"missing offset"),W(y<this.length,"Trying to read beyond buffer length")),!(y>=this.length))return 128&this[y]?-1*(255-this[y]+1):this[y]},M.prototype.readInt16LE=function(y,_){return A(this,y,!0,_)},M.prototype.readInt16BE=function(y,_){return A(this,y,!1,_)},M.prototype.readInt32LE=function(y,_){return O(this,y,!0,_)},M.prototype.readInt32BE=function(y,_){return O(this,y,!1,_)},M.prototype.readFloatLE=function(y,_){return m(this,y,!0,_)},M.prototype.readFloatBE=function(y,_){return m(this,y,!1,_)},M.prototype.readDoubleLE=function(y,_){return S(this,y,!0,_)},M.prototype.readDoubleBE=function(y,_){return S(this,y,!1,_)},M.prototype.writeUInt8=function(y,_,E){E||(W(y!=null,"missing value"),W(_!=null,"missing offset"),W(_<this.length,"trying to write beyond buffer length"),Pt(y,255)),_>=this.length||(this[_]=y)},M.prototype.writeUInt16LE=function(y,_,E){w(this,y,_,!0,E)},M.prototype.writeUInt16BE=function(y,_,E){w(this,y,_,!1,E)},M.prototype.writeUInt32LE=function(y,_,E){B(this,y,_,!0,E)},M.prototype.writeUInt32BE=function(y,_,E){B(this,y,_,!1,E)},M.prototype.writeInt8=function(y,_,E){E||(W(y!=null,"missing value"),W(_!=null,"missing offset"),W(_<this.length,"Trying to write beyond buffer length"),Zt(y,127,-128)),_>=this.length||(0<=y?this.writeUInt8(y,_,E):this.writeUInt8(255+y+1,_,E))},M.prototype.writeInt16LE=function(y,_,E){N(this,y,_,!0,E)},M.prototype.writeInt16BE=function(y,_,E){N(this,y,_,!1,E)},M.prototype.writeInt32LE=function(y,_,E){Q(this,y,_,!0,E)},M.prototype.writeInt32BE=function(y,_,E){Q(this,y,_,!1,E)},M.prototype.writeFloatLE=function(y,_,E){z(this,y,_,!0,E)},M.prototype.writeFloatBE=function(y,_,E){z(this,y,_,!1,E)},M.prototype.writeDoubleLE=function(y,_,E){L(this,y,_,!0,E)},M.prototype.writeDoubleBE=function(y,_,E){L(this,y,_,!1,E)},M.prototype.fill=function(y,_,E){if(_=_||0,E=E||this.length,W(typeof(y=typeof(y=y||0)=="string"?y.charCodeAt(0):y)=="number"&&!isNaN(y),"value is not a number"),W(_<=E,"end < start"),E!==_&&this.length!==0){W(0<=_&&_<this.length,"start out of bounds"),W(0<=E&&E<=this.length,"end out of bounds");for(var j=_;j<E;j++)this[j]=y}},M.prototype.inspect=function(){for(var y=[],_=this.length,E=0;E<_;E++)if(y[E]=K(this[E]),E===o.INSPECT_MAX_BYTES){y[E+1]="...";break}return"<Buffer "+y.join(" ")+">"},M.prototype.toArrayBuffer=function(){if(typeof Uint8Array>"u")throw new Error("Buffer.toArrayBuffer not supported in this browser");if(M._useTypedArrays)return new M(this).buffer;for(var y=new Uint8Array(this.length),_=0,E=y.length;_<E;_+=1)y[_]=this[_];return y.buffer};var D=M.prototype;function Y(y,_,E){return typeof y!="number"?E:_<=(y=~~y)?_:0<=y||0<=(y+=_)?y:0}function Z(y){return(y=~~Math.ceil(+y))<0?0:y}function X(y){return(Array.isArray||function(_){return Object.prototype.toString.call(_)==="[object Array]"})(y)}function K(y){return y<16?"0"+y.toString(16):y.toString(16)}function q(y){for(var _=[],E=0;E<y.length;E++){var j=y.charCodeAt(E);if(j<=127)_.push(y.charCodeAt(E));else for(var $=E,J=(55296<=j&&j<=57343&&E++,encodeURIComponent(y.slice($,E+1)).substr(1).split("%")),bt=0;bt<J.length;bt++)_.push(parseInt(J[bt],16))}return _}function rt(y){return T.toByteArray(y)}function xt(y,_,E,j){for(var $=0;$<j&&!($+E>=_.length||$>=y.length);$++)_[$+E]=y[$];return $}function Ut(y){try{return decodeURIComponent(y)}catch{return"�"}}function Pt(y,_){W(typeof y=="number","cannot write a non-number as a number"),W(0<=y,"specified a negative value for writing an unsigned value"),W(y<=_,"value is larger than maximum value for type"),W(Math.floor(y)===y,"value has a fractional component")}function Zt(y,_,E){W(typeof y=="number","cannot write a non-number as a number"),W(y<=_,"value larger than maximum allowed value"),W(E<=y,"value smaller than minimum allowed value"),W(Math.floor(y)===y,"value has a fractional component")}function Gt(y,_,E){W(typeof y=="number","cannot write a non-number as a number"),W(y<=_,"value larger than maximum allowed value"),W(E<=y,"value smaller than minimum allowed value")}function W(y,_){if(!y)throw new Error(_||"Failed assertion")}M._augment=function(y){return y._isBuffer=!0,y._get=y.get,y._set=y.set,y.get=D.get,y.set=D.set,y.write=D.write,y.toString=D.toString,y.toLocaleString=D.toString,y.toJSON=D.toJSON,y.copy=D.copy,y.slice=D.slice,y.readUInt8=D.readUInt8,y.readUInt16LE=D.readUInt16LE,y.readUInt16BE=D.readUInt16BE,y.readUInt32LE=D.readUInt32LE,y.readUInt32BE=D.readUInt32BE,y.readInt8=D.readInt8,y.readInt16LE=D.readInt16LE,y.readInt16BE=D.readInt16BE,y.readInt32LE=D.readInt32LE,y.readInt32BE=D.readInt32BE,y.readFloatLE=D.readFloatLE,y.readFloatBE=D.readFloatBE,y.readDoubleLE=D.readDoubleLE,y.readDoubleBE=D.readDoubleBE,y.writeUInt8=D.writeUInt8,y.writeUInt16LE=D.writeUInt16LE,y.writeUInt16BE=D.writeUInt16BE,y.writeUInt32LE=D.writeUInt32LE,y.writeUInt32BE=D.writeUInt32BE,y.writeInt8=D.writeInt8,y.writeInt16LE=D.writeInt16LE,y.writeInt16BE=D.writeInt16BE,y.writeInt32LE=D.writeInt32LE,y.writeInt32BE=D.writeInt32BE,y.writeFloatLE=D.writeFloatLE,y.writeFloatBE=D.writeFloatBE,y.writeDoubleLE=D.writeDoubleLE,y.writeDoubleBE=D.writeDoubleBE,y.fill=D.fill,y.inspect=D.inspect,y.toArrayBuffer=D.toArrayBuffer,y}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(e,n,o){(function(i,a,T,f,p,g,v,C,F){var T=e("buffer").Buffer,U=4,M=new T(U);M.fill(0),n.exports={hash:function(k,P,R,V){for(var G=P(function(w,B){w.length%U!=0&&(N=w.length+(U-w.length%U),w=T.concat([w,M],N));for(var N,Q=[],z=B?w.readInt32BE:w.readInt32LE,L=0;L<w.length;L+=U)Q.push(z.call(w,L));return Q}(k=T.isBuffer(k)?k:new T(k),V),8*k.length),P=V,A=new T(R),O=P?A.writeInt32BE:A.writeInt32LE,m=0;m<G.length;m++)O.call(A,G[m],4*m,!0);return A}}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(e,n,o){(function(i,a,T,f,p,g,v,C,F){var T=e("buffer").Buffer,U=e("./sha"),M=e("./sha256"),k=e("./rng"),P={sha1:U,sha256:M,md5:e("./md5")},R=64,V=new T(R);function G(w,B){var N=P[w=w||"sha1"],Q=[];return N||A("algorithm:",w,"is not yet supported"),{update:function(z){return T.isBuffer(z)||(z=new T(z)),Q.push(z),z.length,this},digest:function(z){var L=T.concat(Q),L=B?function(D,Y,Z){T.isBuffer(Y)||(Y=new T(Y)),T.isBuffer(Z)||(Z=new T(Z)),Y.length>R?Y=D(Y):Y.length<R&&(Y=T.concat([Y,V],R));for(var X=new T(R),K=new T(R),q=0;q<R;q++)X[q]=54^Y[q],K[q]=92^Y[q];return Z=D(T.concat([X,Z])),D(T.concat([K,Z]))}(N,B,L):N(L);return Q=null,z?L.toString(z):L}}}function A(){var w=[].slice.call(arguments).join(" ");throw new Error([w,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join(`
9
- `))}V.fill(0),o.createHash=function(w){return G(w)},o.createHmac=G,o.randomBytes=function(w,B){if(!B||!B.call)return new T(k(w));try{B.call(this,void 0,new T(k(w)))}catch(N){B(N)}};var O,m=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],S=function(w){o[w]=function(){A("sorry,",w,"is not implemented yet")}};for(O in m)S(m[O])}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){var T=e("./helpers");function U(A,O){A[O>>5]|=128<<O%32,A[14+(O+64>>>9<<4)]=O;for(var m=1732584193,S=-271733879,w=-1732584194,B=271733878,N=0;N<A.length;N+=16){var Q=m,z=S,L=w,D=B,m=k(m,S,w,B,A[N+0],7,-680876936),B=k(B,m,S,w,A[N+1],12,-389564586),w=k(w,B,m,S,A[N+2],17,606105819),S=k(S,w,B,m,A[N+3],22,-1044525330);m=k(m,S,w,B,A[N+4],7,-176418897),B=k(B,m,S,w,A[N+5],12,1200080426),w=k(w,B,m,S,A[N+6],17,-1473231341),S=k(S,w,B,m,A[N+7],22,-45705983),m=k(m,S,w,B,A[N+8],7,1770035416),B=k(B,m,S,w,A[N+9],12,-1958414417),w=k(w,B,m,S,A[N+10],17,-42063),S=k(S,w,B,m,A[N+11],22,-1990404162),m=k(m,S,w,B,A[N+12],7,1804603682),B=k(B,m,S,w,A[N+13],12,-40341101),w=k(w,B,m,S,A[N+14],17,-1502002290),m=P(m,S=k(S,w,B,m,A[N+15],22,1236535329),w,B,A[N+1],5,-165796510),B=P(B,m,S,w,A[N+6],9,-1069501632),w=P(w,B,m,S,A[N+11],14,643717713),S=P(S,w,B,m,A[N+0],20,-373897302),m=P(m,S,w,B,A[N+5],5,-701558691),B=P(B,m,S,w,A[N+10],9,38016083),w=P(w,B,m,S,A[N+15],14,-660478335),S=P(S,w,B,m,A[N+4],20,-405537848),m=P(m,S,w,B,A[N+9],5,568446438),B=P(B,m,S,w,A[N+14],9,-1019803690),w=P(w,B,m,S,A[N+3],14,-187363961),S=P(S,w,B,m,A[N+8],20,1163531501),m=P(m,S,w,B,A[N+13],5,-1444681467),B=P(B,m,S,w,A[N+2],9,-51403784),w=P(w,B,m,S,A[N+7],14,1735328473),m=R(m,S=P(S,w,B,m,A[N+12],20,-1926607734),w,B,A[N+5],4,-378558),B=R(B,m,S,w,A[N+8],11,-2022574463),w=R(w,B,m,S,A[N+11],16,1839030562),S=R(S,w,B,m,A[N+14],23,-35309556),m=R(m,S,w,B,A[N+1],4,-1530992060),B=R(B,m,S,w,A[N+4],11,1272893353),w=R(w,B,m,S,A[N+7],16,-155497632),S=R(S,w,B,m,A[N+10],23,-1094730640),m=R(m,S,w,B,A[N+13],4,681279174),B=R(B,m,S,w,A[N+0],11,-358537222),w=R(w,B,m,S,A[N+3],16,-722521979),S=R(S,w,B,m,A[N+6],23,76029189),m=R(m,S,w,B,A[N+9],4,-640364487),B=R(B,m,S,w,A[N+12],11,-421815835),w=R(w,B,m,S,A[N+15],16,530742520),m=V(m,S=R(S,w,B,m,A[N+2],23,-995338651),w,B,A[N+0],6,-198630844),B=V(B,m,S,w,A[N+7],10,1126891415),w=V(w,B,m,S,A[N+14],15,-1416354905),S=V(S,w,B,m,A[N+5],21,-57434055),m=V(m,S,w,B,A[N+12],6,1700485571),B=V(B,m,S,w,A[N+3],10,-1894986606),w=V(w,B,m,S,A[N+10],15,-1051523),S=V(S,w,B,m,A[N+1],21,-2054922799),m=V(m,S,w,B,A[N+8],6,1873313359),B=V(B,m,S,w,A[N+15],10,-30611744),w=V(w,B,m,S,A[N+6],15,-1560198380),S=V(S,w,B,m,A[N+13],21,1309151649),m=V(m,S,w,B,A[N+4],6,-145523070),B=V(B,m,S,w,A[N+11],10,-1120210379),w=V(w,B,m,S,A[N+2],15,718787259),S=V(S,w,B,m,A[N+9],21,-343485551),m=G(m,Q),S=G(S,z),w=G(w,L),B=G(B,D)}return Array(m,S,w,B)}function M(A,O,m,S,w,B){return G((O=G(G(O,A),G(S,B)))<<w|O>>>32-w,m)}function k(A,O,m,S,w,B,N){return M(O&m|~O&S,A,O,w,B,N)}function P(A,O,m,S,w,B,N){return M(O&S|m&~S,A,O,w,B,N)}function R(A,O,m,S,w,B,N){return M(O^m^S,A,O,w,B,N)}function V(A,O,m,S,w,B,N){return M(m^(O|~S),A,O,w,B,N)}function G(A,O){var m=(65535&A)+(65535&O);return(A>>16)+(O>>16)+(m>>16)<<16|65535&m}n.exports=function(A){return T.hash(A,U,16)}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){n.exports=function(T){for(var U,M=new Array(T),k=0;k<T;k++)(3&k)==0&&(U=4294967296*Math.random()),M[k]=U>>>((3&k)<<3)&255;return M}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){var T=e("./helpers");function U(P,R){P[R>>5]|=128<<24-R%32,P[15+(R+64>>9<<4)]=R;for(var V,G,A,O=Array(80),m=1732584193,S=-271733879,w=-1732584194,B=271733878,N=-1009589776,Q=0;Q<P.length;Q+=16){for(var z=m,L=S,D=w,Y=B,Z=N,X=0;X<80;X++){O[X]=X<16?P[Q+X]:k(O[X-3]^O[X-8]^O[X-14]^O[X-16],1);var K=M(M(k(m,5),(K=S,G=w,A=B,(V=X)<20?K&G|~K&A:!(V<40)&&V<60?K&G|K&A|G&A:K^G^A)),M(M(N,O[X]),(V=X)<20?1518500249:V<40?1859775393:V<60?-1894007588:-899497514)),N=B,B=w,w=k(S,30),S=m,m=K}m=M(m,z),S=M(S,L),w=M(w,D),B=M(B,Y),N=M(N,Z)}return Array(m,S,w,B,N)}function M(P,R){var V=(65535&P)+(65535&R);return(P>>16)+(R>>16)+(V>>16)<<16|65535&V}function k(P,R){return P<<R|P>>>32-R}n.exports=function(P){return T.hash(P,U,20,!0)}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){function T(R,V){var G=(65535&R)+(65535&V);return(R>>16)+(V>>16)+(G>>16)<<16|65535&G}function U(R,V){var G,A=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),O=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),m=new Array(64);R[V>>5]|=128<<24-V%32,R[15+(V+64>>9<<4)]=V;for(var S,w,B=0;B<R.length;B+=16){for(var N=O[0],Q=O[1],z=O[2],L=O[3],D=O[4],Y=O[5],Z=O[6],X=O[7],K=0;K<64;K++)m[K]=K<16?R[K+B]:T(T(T((w=m[K-2],k(w,17)^k(w,19)^P(w,10)),m[K-7]),(w=m[K-15],k(w,7)^k(w,18)^P(w,3))),m[K-16]),G=T(T(T(T(X,k(w=D,6)^k(w,11)^k(w,25)),D&Y^~D&Z),A[K]),m[K]),S=T(k(S=N,2)^k(S,13)^k(S,22),N&Q^N&z^Q&z),X=Z,Z=Y,Y=D,D=T(L,G),L=z,z=Q,Q=N,N=T(G,S);O[0]=T(N,O[0]),O[1]=T(Q,O[1]),O[2]=T(z,O[2]),O[3]=T(L,O[3]),O[4]=T(D,O[4]),O[5]=T(Y,O[5]),O[6]=T(Z,O[6]),O[7]=T(X,O[7])}return O}var M=e("./helpers"),k=function(R,V){return R>>>V|R<<32-V},P=function(R,V){return R>>>V};n.exports=function(R){return M.hash(R,U,32,!0)}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){o.read=function(T,U,M,k,B){var R,V,G=8*B-k-1,A=(1<<G)-1,O=A>>1,m=-7,S=M?B-1:0,w=M?-1:1,B=T[U+S];for(S+=w,R=B&(1<<-m)-1,B>>=-m,m+=G;0<m;R=256*R+T[U+S],S+=w,m-=8);for(V=R&(1<<-m)-1,R>>=-m,m+=k;0<m;V=256*V+T[U+S],S+=w,m-=8);if(R===0)R=1-O;else{if(R===A)return V?NaN:1/0*(B?-1:1);V+=Math.pow(2,k),R-=O}return(B?-1:1)*V*Math.pow(2,R-k)},o.write=function(T,U,M,k,P,N){var V,G,A=8*N-P-1,O=(1<<A)-1,m=O>>1,S=P===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=k?0:N-1,B=k?1:-1,N=U<0||U===0&&1/U<0?1:0;for(U=Math.abs(U),isNaN(U)||U===1/0?(G=isNaN(U)?1:0,V=O):(V=Math.floor(Math.log(U)/Math.LN2),U*(k=Math.pow(2,-V))<1&&(V--,k*=2),2<=(U+=1<=V+m?S/k:S*Math.pow(2,1-m))*k&&(V++,k/=2),O<=V+m?(G=0,V=O):1<=V+m?(G=(U*k-1)*Math.pow(2,P),V+=m):(G=U*Math.pow(2,m-1)*Math.pow(2,P),V=0));8<=P;T[M+w]=255&G,w+=B,G/=256,P-=8);for(V=V<<P|G,A+=P;0<A;T[M+w]=255&V,w+=B,V/=256,A-=8);T[M+w-B]|=128*N}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(e,n,o){(function(i,a,c,f,p,g,v,C,F){var T,U,M;function k(){}(i=n.exports={}).nextTick=(U=typeof window<"u"&&window.setImmediate,M=typeof window<"u"&&window.postMessage&&window.addEventListener,U?function(P){return window.setImmediate(P)}:M?(T=[],window.addEventListener("message",function(P){var R=P.source;R!==window&&R!==null||P.data!=="process-tick"||(P.stopPropagation(),0<T.length&&T.shift()())},!0),function(P){T.push(P),window.postMessage("process-tick","*")}):function(P){setTimeout(P,0)}),i.title="browser",i.browser=!0,i.env={},i.argv=[],i.on=k,i.addListener=k,i.once=k,i.off=k,i.removeListener=k,i.removeAllListeners=k,i.emit=k,i.binding=function(P){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(P){throw new Error("process.chdir is not supported")}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)})}(ki)),ki.exports}var Jf=Yf();const Hf=Ts(Jf);function qf(r){return new Promise(t=>setTimeout(t,r))}class Kf{cache;url;params;cache_prefix;fetchOptions;timeout;_pending={};constructor(t,e,n={}){const o={...e};n.parameters&&(o["x-parameters"]=JSON.stringify(n.parameters)),n.chunks&&(o["x-chunks"]=n.chunks),n.downsample&&(o["x-downsample"]=JSON.stringify(n.downsample)),o["x-filtered"]="True",this.params={},e["x-datamesh-auth"]&&(this.params.auth=e["x-datamesh-auth"]),e["x-datamesh-sig"]&&(this.params.sig=e["x-datamesh-sig"]),this.fetchOptions={headers:o},this.url=t;const i=t.split("/").pop();n.nocache||typeof window>"u"?this.cache=void 0:this.cache=iu("zarr","cache"),this.cache_prefix=Hf({datasource:i,...n.parameters,chunks:n.chunks,downsample:n.downsample}),this.timeout=n.timeout||6e4}async get(t,e,n=0){const o=`${this.cache_prefix}${t}`;let i=null;if(this.cache&&(i=await Zf(o,this.cache),i&&delete this._pending[o],this._pending[o]))if(await qf(200),n>this.timeout){await Ni(o,this.cache),delete this._pending[o],console.error("Zarr timeout");return}else return await this.get(t,e,n+200);if(!i){this._pending[o]=!0;try{const a={...this.fetchOptions,...e,headers:{...this.fetchOptions.headers||{},...e?.headers||{}},signal:AbortSignal.timeout(this.timeout)},c=new URLSearchParams(this.params).toString(),f=await fetch(`${this.url}${t}?${c}`,a);if(f.status===404){this.cache&&await Ni(o,this.cache);return}if(f.status>=400)throw new Error(`HTTP error: ${f.status}`);i=new Uint8Array(await f.arrayBuffer()),this.cache&&await Gf(o,i,this.cache)}catch(a){if(console.debug("Zarr retry:"+o),n<this.timeout/200)return delete this._pending[o],await this.get(t,e,n+200);this.cache&&await Ni(o,this.cache),console.error(a);return}finally{delete this._pending[o]}}return i}}const Po=async(r,t=".zarray")=>{const{path:e}=r.resolve(t),n=await r.store.get(e);return n?JSON.parse(new TextDecoder().decode(n)):{}};async function Xf(r){const t=await Po(r,".zattrs"),e=await Po(r);e.dtype.startsWith("<M8")&&(t._dtype=e.dtype);const n=[];e.order==="F"&&n.push({name:"transpose",configuration:{order:"F"}}),typeof e.dtype=="string"&&e.dtype.startsWith(">")&&n.push({name:"bytes",configuration:{endian:"big"}});for(const{id:i,...a}of e.filters??[])n.push({name:i,configuration:a});if(e.compressor){const{id:i,...a}=e.compressor;n.push({name:i,configuration:a})}const o={zarr_format:3,node_type:"array",shape:e.shape,data_type:"int64",chunk_grid:{name:"regular",configuration:{chunk_shape:e.chunks}},chunk_key_encoding:{name:"v2",configuration:{separator:e.dimension_separator??"."}},codecs:n,fill_value:e.fill_value,attributes:t};return new Br(r.store,r.path,o)}function bi(r,t,e){const n=e.value;return e.value=async function(...o){const i=Date.now(),a=await n.apply(this,o),f=Date.now()-i;return console.debug(`${t} took ${f}ms`),a},e}var Qf=Object.defineProperty,td=Object.getOwnPropertyDescriptor,ed=(r,t,e,n)=>{for(var o=td(t,e),i=r.length-1,a;i>=0;i--)(a=r[i])&&(o=a(t,e,o)||o);return o&&Qf(t,e,o),o};const su=r=>{const t=new nu.Buffer(r,"base64");return Vf.Geometry.parse(t).toGeoJSON()},ci=r=>r&&(Array.isArray(r)||ArrayBuffer.isView(r)),rd=r=>{const t=[];if(!ci(r))return t;for(;t.push(r.length),ci(r[0]);)r=r[0];return t},nd=r=>{for(;Array.isArray(r);)r=r[0];if(r==null)return"uint8";switch(r.constructor.name){case"Boolean":return"bool";case"Number":return"float32";case"Int8Array":return"int8";case"Int16Array":return"int16";case"Int32Array":return"int32";case"BigInt64Array":return"int64";case"Uint8Array":return"uint8";case"Uint16Array":return"uint16";case"Uint32Array":return"uint32";case"Float32Array":return"float32";case"Float64Array":return"float64";case"String":return"v2:object";case"Object":return"v2:object"}throw new Error("Unsupported data type: "+r.constructor.name)},id=r=>{let t=r.toString().toLowerCase();return r.typeId==5?t="v2:object":r.typeId==1&&(t="uint8"),t},sd=r=>{if(!Array.isArray(r))return r;const t=r.flat(1/0);if(ci(t[0])){const e=t[0].length,n=new t[0].constructor(t.length*e);for(let o=0;o<t.length;o++)n.set(t[o],o*e);return n}else return t},od=r=>{const t=r.length,e=Array(t);for(let n=t-1,o=1;n>=0;n--)e[n]=o,o*=r[n];return e},Fs=(r,t,e,n=0)=>{if(t.length===0)return r[0];if(t.length===1){const i=new r.constructor(t[0]);return i.set(r.slice(n,n+t[0])),i}const o=new Array(t[0]);for(let i=0;i<t[0];i++)o[i]=Fs(r,t.slice(1),e.slice(1),n+i*e[0]);return o},ad=(r,t)=>{const[e,n]=t.split("<M8"),o=new Float64Array(r.data.length);let i=1n;switch(n){case"[ms]":i=1000n;break;case"[us]":i=1000000n;break;case"[ns]":i=1000000000n;break;default:i=1n;break}for(let a=0;a<r.data.length;a++){const c=r.data[a];o[a]=Number(c/i)}return Fs(o,r.shape,r.stride)},ou=(r,t,e)=>{const n=Object.keys(t),o={};for(const i in r)ci(r[i].data)&&(o[i]=!0);if(n.length==1)for(let i=0;i<t[n[0]];i++){const a={};for(const c in r)o[c]?r[c].data.length>1&&(a[c]=r[c].data[i]):a[c]=r[c].data;e.push(a)}else for(let i=0;i<t[n[0]];i++){const a={};for(const f in r)r[f].dimensions.includes(n[0])?a[f]={attributes:r[f].attributes,data:r[f].data[i],dimensions:r[f].dimensions.slice(1)}:a[f]=r[f];const c={...t};delete c[n[0]],ou(a,c,e)}return e};class ui{id;dimensions;attributes;arr;constructor(t,e,n,o){this.id=t,this.dimensions=e,this.attributes=n,this.arr=o}async get(t){if(this.arr.shape.length==0||this.arr.shape[0]==0)return[];const e=t&&t.map(o=>{if(typeof o=="string"){const[i,a,c]=o.split(":");return Ui(parseInt(i),parseInt(a),parseInt(c))}else return o}),n=await ih(this.arr,e);if(this.arr.dtype=="v2:object"||!n.shape)return n.data;if(this.arr.dtype=="bool")return[...n.data];{const o=this.arr.attrs._dtype;return o?.startsWith("<M8")?ad(n,o):Fs(n.data,n.shape,n.stride)}}}ed([bi],ui.prototype,"get");class Ge{dimensions;variables;attributes;coordkeys;root;constructor(t,e,n,o,i){this.dimensions=t,this.variables=e,this.attributes=n,this.coordkeys=o,this.root=i}static async zarr(t,e,n={}){const o=new Kf(t,e,{chunks:n.chunks,downsample:n.downsample,parameters:n.parameters,timeout:n.timeout,nocache:n.nocache}),i=await $u(o),a=await Ze(i,{kind:"group"}),c={},f={};for(const g of i.contents())if(g.kind=="array"){let v;try{v=await Ze(a.resolve(g.path),{kind:"array"})}catch(T){const U=typeof T=="object"&&T&&"message"in T?String(T.message):void 0;if(U&&U.includes("<M8"))v=await Xf(a.resolve(g.path));else throw T}const C=v.attrs._ARRAY_DIMENSIONS,F=g.path.split("/").pop();c[F]=new ui(F,C||[],v.attrs,v),C&&C.map((T,U)=>{const M=v.shape[U];if(f[T]&&f[T]!=M)throw new Error(`Inconsistent dimension size for ${T}: ${f[T]} != ${M}`);f[T]=M})}const p=JSON.parse(a.attrs._coordinates)||{};return new Ge(f,c,a.attrs,n.coordkeys||p,a)}static async fromArrow(t,e){const n={},o={record:t.numRows},i={};return t.schema.fields.forEach(a=>{const c=t.getChild(a.name);let f={},p=c?.toArray(),g=id(a.type);if(tt.isTimestamp(a.type)){const v=new Float64Array(p.length),C=BigInt(1e3**(a.type.unit-0));for(let F=0;F<p.length;F++)v[F]=Number(p[F]/C);p=v,g="float64",f={unit:"Unix timestamp (s)"}}else if(tt.isBinary(a.type)){const v=[];for(let C=0;C<p.length;C++)v.push(new nu.Buffer(p[C]).toString("base64"));p=v,g="v2:object"}i[a.name]={dimensions:["record"],attributes:f,data:p,dtype:g}}),await Ge.init({dimensions:o,variables:i,attributes:n},e)}static async fromGeojson(t,e){if(!("features"in t&&Array.isArray(t.features))&&!("geometry"in t))throw new Error("Invalid GeoJSON");const n="features"in t&&t.features?t.features:[t];if(n.length===0)throw new Error("FeatureCollection contains no features");const o=new Set;n.forEach(f=>{f.properties&&Object.keys(f.properties).forEach(p=>o.add(p))});const i=n.map(f=>{const p={geometry:f.geometry};return f.properties&&Object.assign(p,f.properties),p}),a={dimensions:{index:i.length},variables:{},attributes:{}},c=await Ge.init(a,{...e,g:"geometry"});await c.assign("geometry",["index"],i.map(f=>f.geometry),{description:"GeoJSON geometry"});for(const f of o){const p=i.map(g=>g[f]);await c.assign(f,["index"],p,{description:`Property: ${f}`})}return c}static async init(t,e){const n=await js(new Map,{attributes:{created:new Date}}),o=new Ge(t.dimensions,{},t.attributes||{},e||{},n);for(const i in t.variables){const{dimensions:a,attributes:c,data:f,dtype:p}=t.variables[i];await o.assign(i,a,f,c,p&&p==="string"?"v2:object":p)}return o}async asDataframe(){const t={},e=[];for(const o in this.variables)t[o]={attributes:this.variables[o].attributes,dimensions:this.variables[o].dimensions},t[o].data=await this.variables[o].get(),this.variables[o].arr.dtype=="int64"&&e.push(o);const n=ou(t,{...this.dimensions},[]);if(this.coordkeys.t)for(let o=0;o<n.length;o++)n[o][this.coordkeys.t]=new Date(1e3*n[o][this.coordkeys.t]).toISOString();if(e.length>0)for(const o of e)for(let i=0;i<n.length;i++)n[i][o]=Number(n[i][o]);return n}async asGeojson(t){if(!this.coordkeys.g&&!t)throw new Error("No geometry found");const e=[],n=await this.asDataframe();for(let o=0;o<n.length;o++){const{...i}=n[o];let a=t;if(!a&&this.coordkeys.g){delete i[this.coordkeys.g];const c=n[o][this.coordkeys.g];c.slice(0,7)=='{"type:'?a=JSON.parse(c):a=su(c)}e.push({type:"Feature",geometry:a,properties:i})}return{type:"FeatureCollection",features:e}}async assign(t,e,n,o,i,a){const c=rd(n);if(c.length!=e.length)throw new Error("Data shape does not match dimensions");e.map((v,C)=>{if(this.dimensions[v]){if(this.dimensions[v]!=c[C])throw new Error(`Existing size of dimension ${v} does not match new data`)}else this.dimensions[v]=c[C]});const f=i||nd(n),p=await js(this.root.resolve(t),{shape:c,data_type:f,chunk_shape:a||c,codecs:f=="v2:object"?[{name:"json2"}]:[]});let g=sd(n);g.length==0?g=null:f=="bool"?g=new qi(g):Array.isArray(g)&&f=="float32"?g=Float32Array.from(g,v=>v??NaN):Array.isArray(g)&&f=="float64"?g=Float64Array.from(g,v=>v??NaN):Array.isArray(g)&&f=="int8"?g=Int8Array.from(g):Array.isArray(g)&&f=="int16"?g=Int16Array.from(g):Array.isArray(g)&&f=="int32"?g=Int32Array.from(g):Array.isArray(g)&&f=="int64"?g=BigInt64Array.from(g.map(v=>BigInt(v))):Array.isArray(g)&&f=="uint8"?g=Uint8Array.from(g):Array.isArray(g)&&f=="uint16"?g=Uint16Array.from(g):Array.isArray(g)&&f=="uint32"?g=Uint32Array.from(g):Array.isArray(g)&&f=="uint64"&&(g=BigUint64Array.from(g.map(v=>BigInt(v)))),g&&await sh(p,c.map(()=>null),{data:g,shape:c,stride:od(c)}),this.variables[t]=new ui(t,e,o||{},p)}}var cd=Object.defineProperty,ud=Object.getOwnPropertyDescriptor,hd=(r,t,e,n)=>{for(var o=ud(t,e),i=r.length-1,a;i>=0;i--)(a=r[i])&&(o=a(t,e,o)||o);return o&&cd(t,e,o),o};const au=class Hi{id;user;creationTime;endTime;write;verified=!1;_connection;static async acquire(t,e={}){if(!t._isV1){const n=new Hi;return n.id="dummy_session",n.user="dummy_user",n.creationTime=new Date,n.endTime=new Date(Date.now()+(e.duration||3600)*1e3),n.write=!1,n.verified=!1,n._connection=t,typeof process<"u"&&process.on&&process.on("beforeExit",()=>{n.close()}),n}try{const n={...t._authHeaders};n["Cache-Control"]="no-store";const o=new URLSearchParams({duration:String(e.duration??3600)}),i=await fetch(`${t._gateway}/session/?${o.toString()}`,{headers:n});if(i.status!==200)throw new Error(`Failed to create session: ${await i.text()}`);const a=await i.json(),c=new Hi;return c.id=a.id,c.user=a.user,c.creationTime=new Date(a.creation_time),c.endTime=new Date(a.end_time),c.write=a.write,c.verified=a.verified||!1,c._connection=t,typeof process<"u"&&process.on&&process.on("beforeExit",()=>{c.close()}),c}catch(n){throw new Error(`Error when acquiring datamesh session: ${n}`)}}get header(){return{"X-DATAMESH-SESSIONID":this.id}}addHeader(t){return{...t,...this.header}}async close(t=!1){if(this._connection._isV1)try{typeof process<"u"&&process.off&&process.off("beforeExit",this.close);const e=await fetch(`${this._connection._gateway}/session/${this.id}`,{method:"DELETE",headers:this.header,body:JSON.stringify({finalise_write:t})});if(e.status!==204){if(t)throw new Error(`Failed to finalise write: ${await e.text()}`);console.warn(`Failed to close session: ${await e.text()}`)}}catch(e){if(t)throw new Error(`Error when closing datamesh session: ${e}`);console.warn(`Error when closing datamesh session: ${e}`)}}async enter(){return this}async exit(t){await this.close(t===void 0)}};hd([bi],au,"acquire");let ld=au;var fd=Object.defineProperty,dd=Object.getOwnPropertyDescriptor,cu=(r,t,e,n)=>{for(var o=dd(t,e),i=r.length-1,a;i>=0;i--)(a=r[i])&&(o=a(t,e,o)||o);return o&&fd(t,e,o),o};const pd=typeof process<"u"&&process.env?.DATAMESH_SERVICE?process.env.DATAMESH_SERVICE:"https://datamesh.oceanum.io",Ns=class uu{static LAZY_LOAD_SIZE=1e8;_token;_host;_authHeaders;_gateway;_nocache=!1;_isV1=!1;_sessionParams={};_currentSession=null;service;gateway;constructor(t=typeof process<"u"&&process.env?.DATAMESH_TOKEN?process.env.DATAMESH_TOKEN:"$DATAMESH_TOKEN",e){if(!t&&!e?.jwtAuth)throw new Error("A valid datamesh token must be supplied as a connector constructor argument or defined in environment variables as DATAMESH_TOKEN");this._token=t,this._nocache=e?.nocache??!1;const n=new URL(e?.service||pd);this._host=`${n.protocol}//${n.hostname}`,this._authHeaders=e?.jwtAuth?{Authorization:`Bearer ${e.jwtAuth}`}:{Authorization:`Token ${this._token}`,"X-DATAMESH-TOKEN":this._token},this._gateway=e?.gateway||this._host,this._host.split(".").slice(-1)[0]!==this._gateway.split(".").slice(-1)[0]&&console.warn("Datamesh gateway and service domains do not match"),e?.sessionDuration&&typeof e.sessionDuration=="number"&&(this._sessionParams={duration:e.sessionDuration}),this._checkApiVersion()}async _checkApiVersion(){try{(await fetch(`${this._gateway}/session`,{headers:this._authHeaders})).status===200?(this._isV1=!0,console.info("Using datamesh API version 1")):(this._isV1=!1,console.info("Using datamesh API version 0"))}catch{this._isV1=!1,console.info("Using datamesh API version 0")}}get host(){return this._host}async status(){return(await fetch(this._host,{headers:this._authHeaders})).status===200}async validateResponse(t){if(t.status>=400){let e;try{e=(await t.json()).detail}catch{e=`Datamesh server error: ${await t.text()}`}throw new Error(e)}}async createSession(t={}){const e={duration:t.duration||this._sessionParams.duration||3600};return this._currentSession=await ld.acquire(this,e),this._currentSession}async getSession(){return this._currentSession?this._currentSession:this.createSession()}async getSessionHeaders(t={}){return this._isV1&&!this._currentSession&&await this.createSession(),this._currentSession?this._currentSession.addHeader({...this._authHeaders,...t}):{...this._authHeaders,...t}}async metadataRequest(t="",e={}){const n=new URL(`${this._host}/datasource/${t}`);Object.keys(e).forEach(a=>n.searchParams.append(a,e[a]));const o=await this.getSessionHeaders(),i=await fetch(n.toString(),{headers:o});if(i.status===403)throw new Error(`Datasource ${t} not authorized`);return await this.validateResponse(i),i}async dataRequest(t,e="application/vnd.apache.arrow.file"){const n=await this.getSessionHeaders({Accept:e}),o=await fetch(`${this._gateway}/oceanql/${t}?f=arrow`,{headers:n});return await this.validateResponse(o),Xc(await o.arrayBuffer())}async stageRequest(t){const e=JSON.stringify(t),n=await this.getSessionHeaders({"Content-Type":"application/json"}),o=await fetch(`${this._gateway}/oceanql/stage/`,{method:"POST",headers:n,body:e});if(o.status>=400){const i=await o.json();throw new Error(i.detail)}else return o.status===204?null:o.json()}async query(t,e={}){const n=await this.stageRequest(t);if(!n)return console.warn("No data found for query"),null;if(n.size<uu.LAZY_LOAD_SIZE&&n.container!="dataset"){const f=await this.dataRequest(n.qhash);return await Ge.fromArrow(f,n.coordkeys)}const o=`${this._gateway}/zarr/${this._isV1?"query/":""}${n.qhash}`,i=t.parameters,a=await this.getSessionHeaders(),c=await Ge.zarr(o,a,{parameters:i,timeout:e.timeout||6e4,nocache:this._nocache});if(t.variables)for(const f of Object.keys(c.variables))!t.variables.includes(f)&&!Object.values(c.coordkeys).includes(f)&&delete c.variables[f];return c}async getDatasource(t){const n=await(await this.metadataRequest(t)).json();return{id:t,geom:n.geometry,...n.properties}}async loadDatasource(t,e={}){const n={datasource:t,parameters:e};return await this.query(n)}async closeSession(t=!1){this._currentSession&&(await this._currentSession.close(t),this._currentSession=null)}};cu([bi],Ns.prototype,"stageRequest");cu([bi],Ns.prototype,"query");let yd=Ns;var Mn={exports:{}},gd=Mn.exports,$o;function md(){return $o||($o=1,function(r,t){(function(e,n){r.exports=n()})(gd,function(){var e=1e3,n=6e4,o=36e5,i="millisecond",a="second",c="minute",f="hour",p="day",g="week",v="month",C="quarter",F="year",T="date",U="Invalid Date",M=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,k=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,P={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(z){var L=["th","st","nd","rd"],D=z%100;return"["+z+(L[(D-20)%10]||L[D]||L[0])+"]"}},R=function(z,L,D){var Y=String(z);return!Y||Y.length>=L?z:""+Array(L+1-Y.length).join(D)+z},V={s:R,z:function(z){var L=-z.utcOffset(),D=Math.abs(L),Y=Math.floor(D/60),Z=D%60;return(L<=0?"+":"-")+R(Y,2,"0")+":"+R(Z,2,"0")},m:function z(L,D){if(L.date()<D.date())return-z(D,L);var Y=12*(D.year()-L.year())+(D.month()-L.month()),Z=L.clone().add(Y,v),X=D-Z<0,K=L.clone().add(Y+(X?-1:1),v);return+(-(Y+(D-Z)/(X?Z-K:K-Z))||0)},a:function(z){return z<0?Math.ceil(z)||0:Math.floor(z)},p:function(z){return{M:v,y:F,w:g,d:p,D:T,h:f,m:c,s:a,ms:i,Q:C}[z]||String(z||"").toLowerCase().replace(/s$/,"")},u:function(z){return z===void 0}},G="en",A={};A[G]=P;var O="$isDayjsObject",m=function(z){return z instanceof N||!(!z||!z[O])},S=function z(L,D,Y){var Z;if(!L)return G;if(typeof L=="string"){var X=L.toLowerCase();A[X]&&(Z=X),D&&(A[X]=D,Z=X);var K=L.split("-");if(!Z&&K.length>1)return z(K[0])}else{var q=L.name;A[q]=L,Z=q}return!Y&&Z&&(G=Z),Z||!Y&&G},w=function(z,L){if(m(z))return z.clone();var D=typeof L=="object"?L:{};return D.date=z,D.args=arguments,new N(D)},B=V;B.l=S,B.i=m,B.w=function(z,L){return w(z,{locale:L.$L,utc:L.$u,x:L.$x,$offset:L.$offset})};var N=function(){function z(D){this.$L=S(D.locale,null,!0),this.parse(D),this.$x=this.$x||D.x||{},this[O]=!0}var L=z.prototype;return L.parse=function(D){this.$d=function(Y){var Z=Y.date,X=Y.utc;if(Z===null)return new Date(NaN);if(B.u(Z))return new Date;if(Z instanceof Date)return new Date(Z);if(typeof Z=="string"&&!/Z$/i.test(Z)){var K=Z.match(M);if(K){var q=K[2]-1||0,rt=(K[7]||"0").substring(0,3);return X?new Date(Date.UTC(K[1],q,K[3]||1,K[4]||0,K[5]||0,K[6]||0,rt)):new Date(K[1],q,K[3]||1,K[4]||0,K[5]||0,K[6]||0,rt)}}return new Date(Z)}(D),this.init()},L.init=function(){var D=this.$d;this.$y=D.getFullYear(),this.$M=D.getMonth(),this.$D=D.getDate(),this.$W=D.getDay(),this.$H=D.getHours(),this.$m=D.getMinutes(),this.$s=D.getSeconds(),this.$ms=D.getMilliseconds()},L.$utils=function(){return B},L.isValid=function(){return this.$d.toString()!==U},L.isSame=function(D,Y){var Z=w(D);return this.startOf(Y)<=Z&&Z<=this.endOf(Y)},L.isAfter=function(D,Y){return w(D)<this.startOf(Y)},L.isBefore=function(D,Y){return this.endOf(Y)<w(D)},L.$g=function(D,Y,Z){return B.u(D)?this[Y]:this.set(Z,D)},L.unix=function(){return Math.floor(this.valueOf()/1e3)},L.valueOf=function(){return this.$d.getTime()},L.startOf=function(D,Y){var Z=this,X=!!B.u(Y)||Y,K=B.p(D),q=function(y,_){var E=B.w(Z.$u?Date.UTC(Z.$y,_,y):new Date(Z.$y,_,y),Z);return X?E:E.endOf(p)},rt=function(y,_){return B.w(Z.toDate()[y].apply(Z.toDate("s"),(X?[0,0,0,0]:[23,59,59,999]).slice(_)),Z)},xt=this.$W,Ut=this.$M,Pt=this.$D,Zt="set"+(this.$u?"UTC":"");switch(K){case F:return X?q(1,0):q(31,11);case v:return X?q(1,Ut):q(0,Ut+1);case g:var Gt=this.$locale().weekStart||0,W=(xt<Gt?xt+7:xt)-Gt;return q(X?Pt-W:Pt+(6-W),Ut);case p:case T:return rt(Zt+"Hours",0);case f:return rt(Zt+"Minutes",1);case c:return rt(Zt+"Seconds",2);case a:return rt(Zt+"Milliseconds",3);default:return this.clone()}},L.endOf=function(D){return this.startOf(D,!1)},L.$set=function(D,Y){var Z,X=B.p(D),K="set"+(this.$u?"UTC":""),q=(Z={},Z[p]=K+"Date",Z[T]=K+"Date",Z[v]=K+"Month",Z[F]=K+"FullYear",Z[f]=K+"Hours",Z[c]=K+"Minutes",Z[a]=K+"Seconds",Z[i]=K+"Milliseconds",Z)[X],rt=X===p?this.$D+(Y-this.$W):Y;if(X===v||X===F){var xt=this.clone().set(T,1);xt.$d[q](rt),xt.init(),this.$d=xt.set(T,Math.min(this.$D,xt.daysInMonth())).$d}else q&&this.$d[q](rt);return this.init(),this},L.set=function(D,Y){return this.clone().$set(D,Y)},L.get=function(D){return this[B.p(D)]()},L.add=function(D,Y){var Z,X=this;D=Number(D);var K=B.p(Y),q=function(Ut){var Pt=w(X);return B.w(Pt.date(Pt.date()+Math.round(Ut*D)),X)};if(K===v)return this.set(v,this.$M+D);if(K===F)return this.set(F,this.$y+D);if(K===p)return q(1);if(K===g)return q(7);var rt=(Z={},Z[c]=n,Z[f]=o,Z[a]=e,Z)[K]||1,xt=this.$d.getTime()+D*rt;return B.w(xt,this)},L.subtract=function(D,Y){return this.add(-1*D,Y)},L.format=function(D){var Y=this,Z=this.$locale();if(!this.isValid())return Z.invalidDate||U;var X=D||"YYYY-MM-DDTHH:mm:ssZ",K=B.z(this),q=this.$H,rt=this.$m,xt=this.$M,Ut=Z.weekdays,Pt=Z.months,Zt=Z.meridiem,Gt=function(_,E,j,$){return _&&(_[E]||_(Y,X))||j[E].slice(0,$)},W=function(_){return B.s(q%12||12,_,"0")},y=Zt||function(_,E,j){var $=_<12?"AM":"PM";return j?$.toLowerCase():$};return X.replace(k,function(_,E){return E||function(j){switch(j){case"YY":return String(Y.$y).slice(-2);case"YYYY":return B.s(Y.$y,4,"0");case"M":return xt+1;case"MM":return B.s(xt+1,2,"0");case"MMM":return Gt(Z.monthsShort,xt,Pt,3);case"MMMM":return Gt(Pt,xt);case"D":return Y.$D;case"DD":return B.s(Y.$D,2,"0");case"d":return String(Y.$W);case"dd":return Gt(Z.weekdaysMin,Y.$W,Ut,2);case"ddd":return Gt(Z.weekdaysShort,Y.$W,Ut,3);case"dddd":return Ut[Y.$W];case"H":return String(q);case"HH":return B.s(q,2,"0");case"h":return W(1);case"hh":return W(2);case"a":return y(q,rt,!0);case"A":return y(q,rt,!1);case"m":return String(rt);case"mm":return B.s(rt,2,"0");case"s":return String(Y.$s);case"ss":return B.s(Y.$s,2,"0");case"SSS":return B.s(Y.$ms,3,"0");case"Z":return K}return null}(_)||K.replace(":","")})},L.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},L.diff=function(D,Y,Z){var X,K=this,q=B.p(Y),rt=w(D),xt=(rt.utcOffset()-this.utcOffset())*n,Ut=this-rt,Pt=function(){return B.m(K,rt)};switch(q){case F:X=Pt()/12;break;case v:X=Pt();break;case C:X=Pt()/3;break;case g:X=(Ut-xt)/6048e5;break;case p:X=(Ut-xt)/864e5;break;case f:X=Ut/o;break;case c:X=Ut/n;break;case a:X=Ut/e;break;default:X=Ut}return Z?X:B.a(X)},L.daysInMonth=function(){return this.endOf(v).$D},L.$locale=function(){return A[this.$L]},L.locale=function(D,Y){if(!D)return this.$L;var Z=this.clone(),X=S(D,Y,!0);return X&&(Z.$L=X),Z},L.clone=function(){return B.w(this.$d,this)},L.toDate=function(){return new Date(this.valueOf())},L.toJSON=function(){return this.isValid()?this.toISOString():null},L.toISOString=function(){return this.$d.toISOString()},L.toString=function(){return this.$d.toUTCString()},z}(),Q=N.prototype;return w.prototype=Q,[["$ms",i],["$s",a],["$m",c],["$H",f],["$W",p],["$M",v],["$y",F],["$D",T]].forEach(function(z){Q[z[1]]=function(L){return this.$g(L,z[0],z[1])}}),w.extend=function(z,L){return z.$i||(z(L,N,w),z.$i=!0),w},w.locale=S,w.isDayjs=m,w.unix=function(z){return w(1e3*z)},w.en=A[G],w.Ls=A,w.p={},w})}(Mn)),Mn.exports}var wd=md();const gr=Ts(wd);var Fn={exports:{}},bd=Fn.exports,zo;function _d(){return zo||(zo=1,function(r,t){(function(e,n){r.exports=n()})(bd,function(){var e,n,o=1e3,i=6e4,a=36e5,c=864e5,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,p=31536e6,g=2628e6,v=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,C={years:p,months:g,days:c,hours:a,minutes:i,seconds:o,milliseconds:1,weeks:6048e5},F=function(A){return A instanceof V},T=function(A,O,m){return new V(A,m,O.$l)},U=function(A){return n.p(A)+"s"},M=function(A){return A<0},k=function(A){return M(A)?Math.ceil(A):Math.floor(A)},P=function(A){return Math.abs(A)},R=function(A,O){return A?M(A)?{negative:!0,format:""+P(A)+O}:{negative:!1,format:""+A+O}:{negative:!1,format:""}},V=function(){function A(m,S,w){var B=this;if(this.$d={},this.$l=w,m===void 0&&(this.$ms=0,this.parseFromMilliseconds()),S)return T(m*C[U(S)],this);if(typeof m=="number")return this.$ms=m,this.parseFromMilliseconds(),this;if(typeof m=="object")return Object.keys(m).forEach(function(z){B.$d[U(z)]=m[z]}),this.calMilliseconds(),this;if(typeof m=="string"){var N=m.match(v);if(N){var Q=N.slice(2).map(function(z){return z!=null?Number(z):0});return this.$d.years=Q[0],this.$d.months=Q[1],this.$d.weeks=Q[2],this.$d.days=Q[3],this.$d.hours=Q[4],this.$d.minutes=Q[5],this.$d.seconds=Q[6],this.calMilliseconds(),this}}return this}var O=A.prototype;return O.calMilliseconds=function(){var m=this;this.$ms=Object.keys(this.$d).reduce(function(S,w){return S+(m.$d[w]||0)*C[w]},0)},O.parseFromMilliseconds=function(){var m=this.$ms;this.$d.years=k(m/p),m%=p,this.$d.months=k(m/g),m%=g,this.$d.days=k(m/c),m%=c,this.$d.hours=k(m/a),m%=a,this.$d.minutes=k(m/i),m%=i,this.$d.seconds=k(m/o),m%=o,this.$d.milliseconds=m},O.toISOString=function(){var m=R(this.$d.years,"Y"),S=R(this.$d.months,"M"),w=+this.$d.days||0;this.$d.weeks&&(w+=7*this.$d.weeks);var B=R(w,"D"),N=R(this.$d.hours,"H"),Q=R(this.$d.minutes,"M"),z=this.$d.seconds||0;this.$d.milliseconds&&(z+=this.$d.milliseconds/1e3,z=Math.round(1e3*z)/1e3);var L=R(z,"S"),D=m.negative||S.negative||B.negative||N.negative||Q.negative||L.negative,Y=N.format||Q.format||L.format?"T":"",Z=(D?"-":"")+"P"+m.format+S.format+B.format+Y+N.format+Q.format+L.format;return Z==="P"||Z==="-P"?"P0D":Z},O.toJSON=function(){return this.toISOString()},O.format=function(m){var S=m||"YYYY-MM-DDTHH:mm:ss",w={Y:this.$d.years,YY:n.s(this.$d.years,2,"0"),YYYY:n.s(this.$d.years,4,"0"),M:this.$d.months,MM:n.s(this.$d.months,2,"0"),D:this.$d.days,DD:n.s(this.$d.days,2,"0"),H:this.$d.hours,HH:n.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:n.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:n.s(this.$d.seconds,2,"0"),SSS:n.s(this.$d.milliseconds,3,"0")};return S.replace(f,function(B,N){return N||String(w[B])})},O.as=function(m){return this.$ms/C[U(m)]},O.get=function(m){var S=this.$ms,w=U(m);return w==="milliseconds"?S%=1e3:S=w==="weeks"?k(S/C[w]):this.$d[w],S||0},O.add=function(m,S,w){var B;return B=S?m*C[U(S)]:F(m)?m.$ms:T(m,this).$ms,T(this.$ms+B*(w?-1:1),this)},O.subtract=function(m,S){return this.add(m,S,!0)},O.locale=function(m){var S=this.clone();return S.$l=m,S},O.clone=function(){return T(this.$ms,this)},O.humanize=function(m){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!m)},O.valueOf=function(){return this.asMilliseconds()},O.milliseconds=function(){return this.get("milliseconds")},O.asMilliseconds=function(){return this.as("milliseconds")},O.seconds=function(){return this.get("seconds")},O.asSeconds=function(){return this.as("seconds")},O.minutes=function(){return this.get("minutes")},O.asMinutes=function(){return this.as("minutes")},O.hours=function(){return this.get("hours")},O.asHours=function(){return this.as("hours")},O.days=function(){return this.get("days")},O.asDays=function(){return this.as("days")},O.weeks=function(){return this.get("weeks")},O.asWeeks=function(){return this.as("weeks")},O.months=function(){return this.get("months")},O.asMonths=function(){return this.as("months")},O.years=function(){return this.get("years")},O.asYears=function(){return this.as("years")},A}(),G=function(A,O,m){return A.add(O.years()*m,"y").add(O.months()*m,"M").add(O.days()*m,"d").add(O.hours()*m,"h").add(O.minutes()*m,"m").add(O.seconds()*m,"s").add(O.milliseconds()*m,"ms")};return function(A,O,m){e=m,n=m().$utils(),m.duration=function(B,N){var Q=m.locale();return T(B,{$l:Q},N)},m.isDuration=F;var S=O.prototype.add,w=O.prototype.subtract;O.prototype.add=function(B,N){return F(B)?G(this,B,1):S.bind(this)(B,N)},O.prototype.subtract=function(B,N){return F(B)?G(this,B,-1):w.bind(this)(B,N)}}})}(Fn)),Fn.exports}var Sd=_d();const Id=Ts(Sd);gr.extend(Id);const Bd=r=>{if(r instanceof Date)return gr(r).toISOString();if(r instanceof gr)return r.toISOString();if(r instanceof gr.duration)return r.toISOString();try{return gr.duration(r).toISOString()}catch{return gr(r).toISOString()}},vd=r=>{const t=r.times.map(e=>Bd(e));return{type:r.type||"range",times:t,resolution:r.resolution,resample:r.resample}};class Ad{datasource;parameters;description;variables;timefilter;geofilter;levelfilter;coordfilter;crs;aggregate;limit;id;constructor(t){this.datasource=t.datasource,this.parameters=t.parameters,this.description=t.description,this.variables=t.variables,this.timefilter=t.timefilter&&vd(t.timefilter),this.geofilter=t.geofilter,this.levelfilter=t.levelfilter,this.coordfilter=t.coordfilter,this.crs=t.crs,this.aggregate=t.aggregate,this.limit=t.limit,this.id=t.id}toJSON(){return{datasource:this.datasource,parameters:this.parameters,description:this.description,variables:this.variables,timefilter:this.timefilter,geofilter:this.geofilter,levelfilter:this.levelfilter,coordfilter:this.coordfilter,crs:this.crs,aggregate:this.aggregate,limit:this.limit,id:this.id}}}exports.Connector=yd;exports.DataVar=ui;exports.Dataset=Ge;exports.Query=Ad;exports.wkb_to_geojson=su;
7
+ `)},_domwindow:function(){return S("domwindow")},_bigint:function(w){return S("bigint:"+w.toString())},_process:function(){return S("process")},_timer:function(){return S("timer")},_pipe:function(){return S("pipe")},_tcp:function(){return S("tcp")},_udp:function(){return S("udp")},_tty:function(){return S("tty")},_statwatcher:function(){return S("statwatcher")},_securecontext:function(){return S("securecontext")},_connection:function(){return S("connection")},_zlib:function(){return S("zlib")},_context:function(){return S("context")},_nodescript:function(){return S("nodescript")},_httpparser:function(){return S("httpparser")},_dataview:function(){return S("dataview")},_signal:function(){return S("signal")},_fsevent:function(){return S("fsevent")},_tlswrap:function(){return S("tlswrap")}}}function G(){return{buf:"",write:function(A){this.buf+=A},end:function(A){this.buf+=A},read:function(){return this.buf}}}s.writeToStream=function(A,N,m){return m===void 0&&(m=N,N={}),V(N=C(A,N),m).dispatch(A)}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(e,n,s){(function(i,a,c,d,f,y,B,L,x){(function(M){var U=typeof Uint8Array<"u"?Uint8Array:Array,F=43,O=47,C=48,P=97,V=65,G=45,A=95;function N(m){return m=m.charCodeAt(0),m===F||m===G?62:m===O||m===A?63:m<C?-1:m<C+10?m-C+26+26:m<V+26?m-V:m<P+26?m-P+26:void 0}M.toByteArray=function(m){var S,w;if(0<m.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var v=m.length,v=m.charAt(v-2)==="="?2:m.charAt(v-1)==="="?1:0,k=new U(3*m.length/4-v),Q=0<v?m.length-4:m.length,z=0;function R(D){k[z++]=D}for(S=0;S<Q;S+=4,0)R((16711680&(w=N(m.charAt(S))<<18|N(m.charAt(S+1))<<12|N(m.charAt(S+2))<<6|N(m.charAt(S+3))))>>16),R((65280&w)>>8),R(255&w);return v==2?R(255&(w=N(m.charAt(S))<<2|N(m.charAt(S+1))>>4)):v==1&&(R((w=N(m.charAt(S))<<10|N(m.charAt(S+1))<<4|N(m.charAt(S+2))>>2)>>8&255),R(255&w)),k},M.fromByteArray=function(m){var S,w,v,k,Q=m.length%3,z="";function R(D){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(D)}for(S=0,v=m.length-Q;S<v;S+=3)w=(m[S]<<16)+(m[S+1]<<8)+m[S+2],z+=R((k=w)>>18&63)+R(k>>12&63)+R(k>>6&63)+R(63&k);switch(Q){case 1:z=(z+=R((w=m[m.length-1])>>2))+R(w<<4&63)+"==";break;case 2:z=(z=(z+=R((w=(m[m.length-2]<<8)+m[m.length-1])>>10))+R(w>>4&63))+R(w<<2&63)+"="}return z}})(s===void 0?this.base64js={}:s)}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(e,n,s){(function(i,a,F,d,f,y,B,L,x){var M=e("base64-js"),U=e("ieee754");function F(g,_,T){if(!(this instanceof F))return new F(g,_,T);var j,$,J,bt,Ot=typeof g;if(_==="base64"&&Ot=="string")for(g=(bt=g).trim?bt.trim():bt.replace(/^\s+|\s+$/g,"");g.length%4!=0;)g+="=";if(Ot=="number")j=Z(g);else if(Ot=="string")j=F.byteLength(g,_);else{if(Ot!="object")throw new Error("First argument needs to be a number, array or string.");j=Z(g.length)}if(F._useTypedArrays?$=F._augment(new Uint8Array(j)):(($=this).length=j,$._isBuffer=!0),F._useTypedArrays&&typeof g.byteLength=="number")$._set(g);else if(X(bt=g)||F.isBuffer(bt)||bt&&typeof bt=="object"&&typeof bt.length=="number")for(J=0;J<j;J++)F.isBuffer(g)?$[J]=g.readUInt8(J):$[J]=g[J];else if(Ot=="string")$.write(g,0,_);else if(Ot=="number"&&!F._useTypedArrays&&!T)for(J=0;J<j;J++)$[J]=0;return $}function O(g,_,T,j){return F._charsWritten=At(function($){for(var J=[],bt=0;bt<$.length;bt++)J.push(255&$.charCodeAt(bt));return J}(_),g,T,j)}function C(g,_,T,j){return F._charsWritten=At(function($){for(var J,bt,Ot=[],kt=0;kt<$.length;kt++)bt=$.charCodeAt(kt),J=bt>>8,bt=bt%256,Ot.push(bt),Ot.push(J);return Ot}(_),g,T,j)}function P(g,_,T){var j="";T=Math.min(g.length,T);for(var $=_;$<T;$++)j+=String.fromCharCode(g[$]);return j}function V(g,_,T,J){J||(W(typeof T=="boolean","missing or invalid endian"),W(_!=null,"missing offset"),W(_+1<g.length,"Trying to read beyond buffer length"));var $,J=g.length;if(!(J<=_))return T?($=g[_],_+1<J&&($|=g[_+1]<<8)):($=g[_]<<8,_+1<J&&($|=g[_+1])),$}function G(g,_,T,J){J||(W(typeof T=="boolean","missing or invalid endian"),W(_!=null,"missing offset"),W(_+3<g.length,"Trying to read beyond buffer length"));var $,J=g.length;if(!(J<=_))return T?(_+2<J&&($=g[_+2]<<16),_+1<J&&($|=g[_+1]<<8),$|=g[_],_+3<J&&($+=g[_+3]<<24>>>0)):(_+1<J&&($=g[_+1]<<16),_+2<J&&($|=g[_+2]<<8),_+3<J&&($|=g[_+3]),$+=g[_]<<24>>>0),$}function A(g,_,T,j){if(j||(W(typeof T=="boolean","missing or invalid endian"),W(_!=null,"missing offset"),W(_+1<g.length,"Trying to read beyond buffer length")),!(g.length<=_))return j=V(g,_,T,!0),32768&j?-1*(65535-j+1):j}function N(g,_,T,j){if(j||(W(typeof T=="boolean","missing or invalid endian"),W(_!=null,"missing offset"),W(_+3<g.length,"Trying to read beyond buffer length")),!(g.length<=_))return j=G(g,_,T,!0),2147483648&j?-1*(4294967295-j+1):j}function m(g,_,T,j){return j||(W(typeof T=="boolean","missing or invalid endian"),W(_+3<g.length,"Trying to read beyond buffer length")),U.read(g,_,T,23,4)}function S(g,_,T,j){return j||(W(typeof T=="boolean","missing or invalid endian"),W(_+7<g.length,"Trying to read beyond buffer length")),U.read(g,_,T,52,8)}function w(g,_,T,j,$){if($||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(T!=null,"missing offset"),W(T+1<g.length,"trying to write beyond buffer length"),Pt(_,65535)),$=g.length,!($<=T))for(var J=0,bt=Math.min($-T,2);J<bt;J++)g[T+J]=(_&255<<8*(j?J:1-J))>>>8*(j?J:1-J)}function v(g,_,T,j,$){if($||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(T!=null,"missing offset"),W(T+3<g.length,"trying to write beyond buffer length"),Pt(_,4294967295)),$=g.length,!($<=T))for(var J=0,bt=Math.min($-T,4);J<bt;J++)g[T+J]=_>>>8*(j?J:3-J)&255}function k(g,_,T,j,$){$||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(T!=null,"missing offset"),W(T+1<g.length,"Trying to write beyond buffer length"),Zt(_,32767,-32768)),g.length<=T||w(g,0<=_?_:65535+_+1,T,j,$)}function Q(g,_,T,j,$){$||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(T!=null,"missing offset"),W(T+3<g.length,"Trying to write beyond buffer length"),Zt(_,2147483647,-2147483648)),g.length<=T||v(g,0<=_?_:4294967295+_+1,T,j,$)}function z(g,_,T,j,$){$||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(T!=null,"missing offset"),W(T+3<g.length,"Trying to write beyond buffer length"),Gt(_,34028234663852886e22,-34028234663852886e22)),g.length<=T||U.write(g,_,T,j,23,4)}function R(g,_,T,j,$){$||(W(_!=null,"missing value"),W(typeof j=="boolean","missing or invalid endian"),W(T!=null,"missing offset"),W(T+7<g.length,"Trying to write beyond buffer length"),Gt(_,17976931348623157e292,-17976931348623157e292)),g.length<=T||U.write(g,_,T,j,52,8)}s.Buffer=F,s.SlowBuffer=F,s.INSPECT_MAX_BYTES=50,F.poolSize=8192,F._useTypedArrays=function(){try{var g=new ArrayBuffer(0),_=new Uint8Array(g);return _.foo=function(){return 42},_.foo()===42&&typeof _.subarray=="function"}catch{return!1}}(),F.isEncoding=function(g){switch(String(g).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},F.isBuffer=function(g){return!(g==null||!g._isBuffer)},F.byteLength=function(g,_){var T;switch(g+="",_||"utf8"){case"hex":T=g.length/2;break;case"utf8":case"utf-8":T=q(g).length;break;case"ascii":case"binary":case"raw":T=g.length;break;case"base64":T=rt(g).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":T=2*g.length;break;default:throw new Error("Unknown encoding")}return T},F.concat=function(g,_){if(W(X(g),`Usage: Buffer.concat(list, [totalLength])
8
+ list should be an Array.`),g.length===0)return new F(0);if(g.length===1)return g[0];if(typeof _!="number")for($=_=0;$<g.length;$++)_+=g[$].length;for(var T=new F(_),j=0,$=0;$<g.length;$++){var J=g[$];J.copy(T,j),j+=J.length}return T},F.prototype.write=function(g,_,T,j){isFinite(_)?isFinite(T)||(j=T,T=void 0):(kt=j,j=_,_=T,T=kt),_=Number(_)||0;var $,J,bt,Ot,kt=this.length-_;switch((!T||kt<(T=Number(T)))&&(T=kt),j=String(j||"utf8").toLowerCase()){case"hex":$=function(Ht,Vt,$t,Nt){$t=Number($t)||0;var mt=Ht.length-$t;(!Nt||mt<(Nt=Number(Nt)))&&(Nt=mt),W((mt=Vt.length)%2==0,"Invalid hex string"),mt/2<Nt&&(Nt=mt/2);for(var Qt=0;Qt<Nt;Qt++){var sr=parseInt(Vt.substr(2*Qt,2),16);W(!isNaN(sr),"Invalid hex string"),Ht[$t+Qt]=sr}return F._charsWritten=2*Qt,Qt}(this,g,_,T);break;case"utf8":case"utf-8":J=this,bt=_,Ot=T,$=F._charsWritten=At(q(g),J,bt,Ot);break;case"ascii":case"binary":$=O(this,g,_,T);break;case"base64":J=this,bt=_,Ot=T,$=F._charsWritten=At(rt(g),J,bt,Ot);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":$=C(this,g,_,T);break;default:throw new Error("Unknown encoding")}return $},F.prototype.toString=function(g,_,T){var j,$,J,bt,Ot=this;if(g=String(g||"utf8").toLowerCase(),_=Number(_)||0,(T=T!==void 0?Number(T):Ot.length)===_)return"";switch(g){case"hex":j=function(kt,Ht,Vt){var $t=kt.length;(!Ht||Ht<0)&&(Ht=0),(!Vt||Vt<0||$t<Vt)&&(Vt=$t);for(var Nt="",mt=Ht;mt<Vt;mt++)Nt+=K(kt[mt]);return Nt}(Ot,_,T);break;case"utf8":case"utf-8":j=function(kt,Ht,Vt){var $t="",Nt="";Vt=Math.min(kt.length,Vt);for(var mt=Ht;mt<Vt;mt++)kt[mt]<=127?($t+=Ut(Nt)+String.fromCharCode(kt[mt]),Nt=""):Nt+="%"+kt[mt].toString(16);return $t+Ut(Nt)}(Ot,_,T);break;case"ascii":case"binary":j=P(Ot,_,T);break;case"base64":$=Ot,bt=T,j=(J=_)===0&&bt===$.length?M.fromByteArray($):M.fromByteArray($.slice(J,bt));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":j=function(kt,Ht,Vt){for(var $t=kt.slice(Ht,Vt),Nt="",mt=0;mt<$t.length;mt+=2)Nt+=String.fromCharCode($t[mt]+256*$t[mt+1]);return Nt}(Ot,_,T);break;default:throw new Error("Unknown encoding")}return j},F.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},F.prototype.copy=function(g,_,T,j){if(_=_||0,(j=j||j===0?j:this.length)!==(T=T||0)&&g.length!==0&&this.length!==0){W(T<=j,"sourceEnd < sourceStart"),W(0<=_&&_<g.length,"targetStart out of bounds"),W(0<=T&&T<this.length,"sourceStart out of bounds"),W(0<=j&&j<=this.length,"sourceEnd out of bounds"),j>this.length&&(j=this.length);var $=(j=g.length-_<j-T?g.length-_+T:j)-T;if($<100||!F._useTypedArrays)for(var J=0;J<$;J++)g[J+_]=this[J+T];else g._set(this.subarray(T,T+$),_)}},F.prototype.slice=function(g,_){var T=this.length;if(g=Y(g,T,0),_=Y(_,T,T),F._useTypedArrays)return F._augment(this.subarray(g,_));for(var j=_-g,$=new F(j,void 0,!0),J=0;J<j;J++)$[J]=this[J+g];return $},F.prototype.get=function(g){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(g)},F.prototype.set=function(g,_){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(g,_)},F.prototype.readUInt8=function(g,_){if(_||(W(g!=null,"missing offset"),W(g<this.length,"Trying to read beyond buffer length")),!(g>=this.length))return this[g]},F.prototype.readUInt16LE=function(g,_){return V(this,g,!0,_)},F.prototype.readUInt16BE=function(g,_){return V(this,g,!1,_)},F.prototype.readUInt32LE=function(g,_){return G(this,g,!0,_)},F.prototype.readUInt32BE=function(g,_){return G(this,g,!1,_)},F.prototype.readInt8=function(g,_){if(_||(W(g!=null,"missing offset"),W(g<this.length,"Trying to read beyond buffer length")),!(g>=this.length))return 128&this[g]?-1*(255-this[g]+1):this[g]},F.prototype.readInt16LE=function(g,_){return A(this,g,!0,_)},F.prototype.readInt16BE=function(g,_){return A(this,g,!1,_)},F.prototype.readInt32LE=function(g,_){return N(this,g,!0,_)},F.prototype.readInt32BE=function(g,_){return N(this,g,!1,_)},F.prototype.readFloatLE=function(g,_){return m(this,g,!0,_)},F.prototype.readFloatBE=function(g,_){return m(this,g,!1,_)},F.prototype.readDoubleLE=function(g,_){return S(this,g,!0,_)},F.prototype.readDoubleBE=function(g,_){return S(this,g,!1,_)},F.prototype.writeUInt8=function(g,_,T){T||(W(g!=null,"missing value"),W(_!=null,"missing offset"),W(_<this.length,"trying to write beyond buffer length"),Pt(g,255)),_>=this.length||(this[_]=g)},F.prototype.writeUInt16LE=function(g,_,T){w(this,g,_,!0,T)},F.prototype.writeUInt16BE=function(g,_,T){w(this,g,_,!1,T)},F.prototype.writeUInt32LE=function(g,_,T){v(this,g,_,!0,T)},F.prototype.writeUInt32BE=function(g,_,T){v(this,g,_,!1,T)},F.prototype.writeInt8=function(g,_,T){T||(W(g!=null,"missing value"),W(_!=null,"missing offset"),W(_<this.length,"Trying to write beyond buffer length"),Zt(g,127,-128)),_>=this.length||(0<=g?this.writeUInt8(g,_,T):this.writeUInt8(255+g+1,_,T))},F.prototype.writeInt16LE=function(g,_,T){k(this,g,_,!0,T)},F.prototype.writeInt16BE=function(g,_,T){k(this,g,_,!1,T)},F.prototype.writeInt32LE=function(g,_,T){Q(this,g,_,!0,T)},F.prototype.writeInt32BE=function(g,_,T){Q(this,g,_,!1,T)},F.prototype.writeFloatLE=function(g,_,T){z(this,g,_,!0,T)},F.prototype.writeFloatBE=function(g,_,T){z(this,g,_,!1,T)},F.prototype.writeDoubleLE=function(g,_,T){R(this,g,_,!0,T)},F.prototype.writeDoubleBE=function(g,_,T){R(this,g,_,!1,T)},F.prototype.fill=function(g,_,T){if(_=_||0,T=T||this.length,W(typeof(g=typeof(g=g||0)=="string"?g.charCodeAt(0):g)=="number"&&!isNaN(g),"value is not a number"),W(_<=T,"end < start"),T!==_&&this.length!==0){W(0<=_&&_<this.length,"start out of bounds"),W(0<=T&&T<=this.length,"end out of bounds");for(var j=_;j<T;j++)this[j]=g}},F.prototype.inspect=function(){for(var g=[],_=this.length,T=0;T<_;T++)if(g[T]=K(this[T]),T===s.INSPECT_MAX_BYTES){g[T+1]="...";break}return"<Buffer "+g.join(" ")+">"},F.prototype.toArrayBuffer=function(){if(typeof Uint8Array>"u")throw new Error("Buffer.toArrayBuffer not supported in this browser");if(F._useTypedArrays)return new F(this).buffer;for(var g=new Uint8Array(this.length),_=0,T=g.length;_<T;_+=1)g[_]=this[_];return g.buffer};var D=F.prototype;function Y(g,_,T){return typeof g!="number"?T:_<=(g=~~g)?_:0<=g||0<=(g+=_)?g:0}function Z(g){return(g=~~Math.ceil(+g))<0?0:g}function X(g){return(Array.isArray||function(_){return Object.prototype.toString.call(_)==="[object Array]"})(g)}function K(g){return g<16?"0"+g.toString(16):g.toString(16)}function q(g){for(var _=[],T=0;T<g.length;T++){var j=g.charCodeAt(T);if(j<=127)_.push(g.charCodeAt(T));else for(var $=T,J=(55296<=j&&j<=57343&&T++,encodeURIComponent(g.slice($,T+1)).substr(1).split("%")),bt=0;bt<J.length;bt++)_.push(parseInt(J[bt],16))}return _}function rt(g){return M.toByteArray(g)}function At(g,_,T,j){for(var $=0;$<j&&!($+T>=_.length||$>=g.length);$++)_[$+T]=g[$];return $}function Ut(g){try{return decodeURIComponent(g)}catch{return"�"}}function Pt(g,_){W(typeof g=="number","cannot write a non-number as a number"),W(0<=g,"specified a negative value for writing an unsigned value"),W(g<=_,"value is larger than maximum value for type"),W(Math.floor(g)===g,"value has a fractional component")}function Zt(g,_,T){W(typeof g=="number","cannot write a non-number as a number"),W(g<=_,"value larger than maximum allowed value"),W(T<=g,"value smaller than minimum allowed value"),W(Math.floor(g)===g,"value has a fractional component")}function Gt(g,_,T){W(typeof g=="number","cannot write a non-number as a number"),W(g<=_,"value larger than maximum allowed value"),W(T<=g,"value smaller than minimum allowed value")}function W(g,_){if(!g)throw new Error(_||"Failed assertion")}F._augment=function(g){return g._isBuffer=!0,g._get=g.get,g._set=g.set,g.get=D.get,g.set=D.set,g.write=D.write,g.toString=D.toString,g.toLocaleString=D.toString,g.toJSON=D.toJSON,g.copy=D.copy,g.slice=D.slice,g.readUInt8=D.readUInt8,g.readUInt16LE=D.readUInt16LE,g.readUInt16BE=D.readUInt16BE,g.readUInt32LE=D.readUInt32LE,g.readUInt32BE=D.readUInt32BE,g.readInt8=D.readInt8,g.readInt16LE=D.readInt16LE,g.readInt16BE=D.readInt16BE,g.readInt32LE=D.readInt32LE,g.readInt32BE=D.readInt32BE,g.readFloatLE=D.readFloatLE,g.readFloatBE=D.readFloatBE,g.readDoubleLE=D.readDoubleLE,g.readDoubleBE=D.readDoubleBE,g.writeUInt8=D.writeUInt8,g.writeUInt16LE=D.writeUInt16LE,g.writeUInt16BE=D.writeUInt16BE,g.writeUInt32LE=D.writeUInt32LE,g.writeUInt32BE=D.writeUInt32BE,g.writeInt8=D.writeInt8,g.writeInt16LE=D.writeInt16LE,g.writeInt16BE=D.writeInt16BE,g.writeInt32LE=D.writeInt32LE,g.writeInt32BE=D.writeInt32BE,g.writeFloatLE=D.writeFloatLE,g.writeFloatBE=D.writeFloatBE,g.writeDoubleLE=D.writeDoubleLE,g.writeDoubleBE=D.writeDoubleBE,g.fill=D.fill,g.inspect=D.inspect,g.toArrayBuffer=D.toArrayBuffer,g}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(e,n,s){(function(i,a,M,d,f,y,B,L,x){var M=e("buffer").Buffer,U=4,F=new M(U);F.fill(0),n.exports={hash:function(O,C,P,V){for(var G=C(function(w,v){w.length%U!=0&&(k=w.length+(U-w.length%U),w=M.concat([w,F],k));for(var k,Q=[],z=v?w.readInt32BE:w.readInt32LE,R=0;R<w.length;R+=U)Q.push(z.call(w,R));return Q}(O=M.isBuffer(O)?O:new M(O),V),8*O.length),C=V,A=new M(P),N=C?A.writeInt32BE:A.writeInt32LE,m=0;m<G.length;m++)N.call(A,G[m],4*m,!0);return A}}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(e,n,s){(function(i,a,M,d,f,y,B,L,x){var M=e("buffer").Buffer,U=e("./sha"),F=e("./sha256"),O=e("./rng"),C={sha1:U,sha256:F,md5:e("./md5")},P=64,V=new M(P);function G(w,v){var k=C[w=w||"sha1"],Q=[];return k||A("algorithm:",w,"is not yet supported"),{update:function(z){return M.isBuffer(z)||(z=new M(z)),Q.push(z),z.length,this},digest:function(z){var R=M.concat(Q),R=v?function(D,Y,Z){M.isBuffer(Y)||(Y=new M(Y)),M.isBuffer(Z)||(Z=new M(Z)),Y.length>P?Y=D(Y):Y.length<P&&(Y=M.concat([Y,V],P));for(var X=new M(P),K=new M(P),q=0;q<P;q++)X[q]=54^Y[q],K[q]=92^Y[q];return Z=D(M.concat([X,Z])),D(M.concat([K,Z]))}(k,v,R):k(R);return Q=null,z?R.toString(z):R}}}function A(){var w=[].slice.call(arguments).join(" ");throw new Error([w,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join(`
9
+ `))}V.fill(0),s.createHash=function(w){return G(w)},s.createHmac=G,s.randomBytes=function(w,v){if(!v||!v.call)return new M(O(w));try{v.call(this,void 0,new M(O(w)))}catch(k){v(k)}};var N,m=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],S=function(w){s[w]=function(){A("sorry,",w,"is not implemented yet")}};for(N in m)S(m[N])}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(e,n,s){(function(i,a,c,d,f,y,B,L,x){var M=e("./helpers");function U(A,N){A[N>>5]|=128<<N%32,A[14+(N+64>>>9<<4)]=N;for(var m=1732584193,S=-271733879,w=-1732584194,v=271733878,k=0;k<A.length;k+=16){var Q=m,z=S,R=w,D=v,m=O(m,S,w,v,A[k+0],7,-680876936),v=O(v,m,S,w,A[k+1],12,-389564586),w=O(w,v,m,S,A[k+2],17,606105819),S=O(S,w,v,m,A[k+3],22,-1044525330);m=O(m,S,w,v,A[k+4],7,-176418897),v=O(v,m,S,w,A[k+5],12,1200080426),w=O(w,v,m,S,A[k+6],17,-1473231341),S=O(S,w,v,m,A[k+7],22,-45705983),m=O(m,S,w,v,A[k+8],7,1770035416),v=O(v,m,S,w,A[k+9],12,-1958414417),w=O(w,v,m,S,A[k+10],17,-42063),S=O(S,w,v,m,A[k+11],22,-1990404162),m=O(m,S,w,v,A[k+12],7,1804603682),v=O(v,m,S,w,A[k+13],12,-40341101),w=O(w,v,m,S,A[k+14],17,-1502002290),m=C(m,S=O(S,w,v,m,A[k+15],22,1236535329),w,v,A[k+1],5,-165796510),v=C(v,m,S,w,A[k+6],9,-1069501632),w=C(w,v,m,S,A[k+11],14,643717713),S=C(S,w,v,m,A[k+0],20,-373897302),m=C(m,S,w,v,A[k+5],5,-701558691),v=C(v,m,S,w,A[k+10],9,38016083),w=C(w,v,m,S,A[k+15],14,-660478335),S=C(S,w,v,m,A[k+4],20,-405537848),m=C(m,S,w,v,A[k+9],5,568446438),v=C(v,m,S,w,A[k+14],9,-1019803690),w=C(w,v,m,S,A[k+3],14,-187363961),S=C(S,w,v,m,A[k+8],20,1163531501),m=C(m,S,w,v,A[k+13],5,-1444681467),v=C(v,m,S,w,A[k+2],9,-51403784),w=C(w,v,m,S,A[k+7],14,1735328473),m=P(m,S=C(S,w,v,m,A[k+12],20,-1926607734),w,v,A[k+5],4,-378558),v=P(v,m,S,w,A[k+8],11,-2022574463),w=P(w,v,m,S,A[k+11],16,1839030562),S=P(S,w,v,m,A[k+14],23,-35309556),m=P(m,S,w,v,A[k+1],4,-1530992060),v=P(v,m,S,w,A[k+4],11,1272893353),w=P(w,v,m,S,A[k+7],16,-155497632),S=P(S,w,v,m,A[k+10],23,-1094730640),m=P(m,S,w,v,A[k+13],4,681279174),v=P(v,m,S,w,A[k+0],11,-358537222),w=P(w,v,m,S,A[k+3],16,-722521979),S=P(S,w,v,m,A[k+6],23,76029189),m=P(m,S,w,v,A[k+9],4,-640364487),v=P(v,m,S,w,A[k+12],11,-421815835),w=P(w,v,m,S,A[k+15],16,530742520),m=V(m,S=P(S,w,v,m,A[k+2],23,-995338651),w,v,A[k+0],6,-198630844),v=V(v,m,S,w,A[k+7],10,1126891415),w=V(w,v,m,S,A[k+14],15,-1416354905),S=V(S,w,v,m,A[k+5],21,-57434055),m=V(m,S,w,v,A[k+12],6,1700485571),v=V(v,m,S,w,A[k+3],10,-1894986606),w=V(w,v,m,S,A[k+10],15,-1051523),S=V(S,w,v,m,A[k+1],21,-2054922799),m=V(m,S,w,v,A[k+8],6,1873313359),v=V(v,m,S,w,A[k+15],10,-30611744),w=V(w,v,m,S,A[k+6],15,-1560198380),S=V(S,w,v,m,A[k+13],21,1309151649),m=V(m,S,w,v,A[k+4],6,-145523070),v=V(v,m,S,w,A[k+11],10,-1120210379),w=V(w,v,m,S,A[k+2],15,718787259),S=V(S,w,v,m,A[k+9],21,-343485551),m=G(m,Q),S=G(S,z),w=G(w,R),v=G(v,D)}return Array(m,S,w,v)}function F(A,N,m,S,w,v){return G((N=G(G(N,A),G(S,v)))<<w|N>>>32-w,m)}function O(A,N,m,S,w,v,k){return F(N&m|~N&S,A,N,w,v,k)}function C(A,N,m,S,w,v,k){return F(N&S|m&~S,A,N,w,v,k)}function P(A,N,m,S,w,v,k){return F(N^m^S,A,N,w,v,k)}function V(A,N,m,S,w,v,k){return F(m^(N|~S),A,N,w,v,k)}function G(A,N){var m=(65535&A)+(65535&N);return(A>>16)+(N>>16)+(m>>16)<<16|65535&m}n.exports=function(A){return M.hash(A,U,16)}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(e,n,s){(function(i,a,c,d,f,y,B,L,x){n.exports=function(M){for(var U,F=new Array(M),O=0;O<M;O++)(3&O)==0&&(U=4294967296*Math.random()),F[O]=U>>>((3&O)<<3)&255;return F}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(e,n,s){(function(i,a,c,d,f,y,B,L,x){var M=e("./helpers");function U(C,P){C[P>>5]|=128<<24-P%32,C[15+(P+64>>9<<4)]=P;for(var V,G,A,N=Array(80),m=1732584193,S=-271733879,w=-1732584194,v=271733878,k=-1009589776,Q=0;Q<C.length;Q+=16){for(var z=m,R=S,D=w,Y=v,Z=k,X=0;X<80;X++){N[X]=X<16?C[Q+X]:O(N[X-3]^N[X-8]^N[X-14]^N[X-16],1);var K=F(F(O(m,5),(K=S,G=w,A=v,(V=X)<20?K&G|~K&A:!(V<40)&&V<60?K&G|K&A|G&A:K^G^A)),F(F(k,N[X]),(V=X)<20?1518500249:V<40?1859775393:V<60?-1894007588:-899497514)),k=v,v=w,w=O(S,30),S=m,m=K}m=F(m,z),S=F(S,R),w=F(w,D),v=F(v,Y),k=F(k,Z)}return Array(m,S,w,v,k)}function F(C,P){var V=(65535&C)+(65535&P);return(C>>16)+(P>>16)+(V>>16)<<16|65535&V}function O(C,P){return C<<P|C>>>32-P}n.exports=function(C){return M.hash(C,U,20,!0)}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(e,n,s){(function(i,a,c,d,f,y,B,L,x){function M(P,V){var G=(65535&P)+(65535&V);return(P>>16)+(V>>16)+(G>>16)<<16|65535&G}function U(P,V){var G,A=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),N=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),m=new Array(64);P[V>>5]|=128<<24-V%32,P[15+(V+64>>9<<4)]=V;for(var S,w,v=0;v<P.length;v+=16){for(var k=N[0],Q=N[1],z=N[2],R=N[3],D=N[4],Y=N[5],Z=N[6],X=N[7],K=0;K<64;K++)m[K]=K<16?P[K+v]:M(M(M((w=m[K-2],O(w,17)^O(w,19)^C(w,10)),m[K-7]),(w=m[K-15],O(w,7)^O(w,18)^C(w,3))),m[K-16]),G=M(M(M(M(X,O(w=D,6)^O(w,11)^O(w,25)),D&Y^~D&Z),A[K]),m[K]),S=M(O(S=k,2)^O(S,13)^O(S,22),k&Q^k&z^Q&z),X=Z,Z=Y,Y=D,D=M(R,G),R=z,z=Q,Q=k,k=M(G,S);N[0]=M(k,N[0]),N[1]=M(Q,N[1]),N[2]=M(z,N[2]),N[3]=M(R,N[3]),N[4]=M(D,N[4]),N[5]=M(Y,N[5]),N[6]=M(Z,N[6]),N[7]=M(X,N[7])}return N}var F=e("./helpers"),O=function(P,V){return P>>>V|P<<32-V},C=function(P,V){return P>>>V};n.exports=function(P){return F.hash(P,U,32,!0)}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(e,n,s){(function(i,a,c,d,f,y,B,L,x){s.read=function(M,U,F,O,v){var P,V,G=8*v-O-1,A=(1<<G)-1,N=A>>1,m=-7,S=F?v-1:0,w=F?-1:1,v=M[U+S];for(S+=w,P=v&(1<<-m)-1,v>>=-m,m+=G;0<m;P=256*P+M[U+S],S+=w,m-=8);for(V=P&(1<<-m)-1,P>>=-m,m+=O;0<m;V=256*V+M[U+S],S+=w,m-=8);if(P===0)P=1-N;else{if(P===A)return V?NaN:1/0*(v?-1:1);V+=Math.pow(2,O),P-=N}return(v?-1:1)*V*Math.pow(2,P-O)},s.write=function(M,U,F,O,C,k){var V,G,A=8*k-C-1,N=(1<<A)-1,m=N>>1,S=C===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=O?0:k-1,v=O?1:-1,k=U<0||U===0&&1/U<0?1:0;for(U=Math.abs(U),isNaN(U)||U===1/0?(G=isNaN(U)?1:0,V=N):(V=Math.floor(Math.log(U)/Math.LN2),U*(O=Math.pow(2,-V))<1&&(V--,O*=2),2<=(U+=1<=V+m?S/O:S*Math.pow(2,1-m))*O&&(V++,O/=2),N<=V+m?(G=0,V=N):1<=V+m?(G=(U*O-1)*Math.pow(2,C),V+=m):(G=U*Math.pow(2,m-1)*Math.pow(2,C),V=0));8<=C;M[F+w]=255&G,w+=v,G/=256,C-=8);for(V=V<<C|G,A+=C;0<A;M[F+w]=255&V,w+=v,V/=256,A-=8);M[F+w-v]|=128*k}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(e,n,s){(function(i,a,c,d,f,y,B,L,x){var M,U,F;function O(){}(i=n.exports={}).nextTick=(U=typeof window<"u"&&window.setImmediate,F=typeof window<"u"&&window.postMessage&&window.addEventListener,U?function(C){return window.setImmediate(C)}:F?(M=[],window.addEventListener("message",function(C){var P=C.source;P!==window&&P!==null||C.data!=="process-tick"||(C.stopPropagation(),0<M.length&&M.shift()())},!0),function(C){M.push(C),window.postMessage("process-tick","*")}):function(C){setTimeout(C,0)}),i.title="browser",i.browser=!0,i.env={},i.argv=[],i.on=O,i.addListener=O,i.once=O,i.off=O,i.removeListener=O,i.removeAllListeners=O,i.emit=O,i.binding=function(C){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(C){throw new Error("process.chdir is not supported")}}).call(this,e("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)})}(Wi)),Wi.exports}var _f=bf();const Sf=Vs(_f);new TextEncoder;const If=4096;function Mu(r,t,e){let n=t;const s=n+e,i=[];let a="";for(;n<s;){const c=r[n++];if((c&128)===0)i.push(c);else if((c&224)===192){const d=r[n++]&63;i.push((c&31)<<6|d)}else if((c&240)===224){const d=r[n++]&63,f=r[n++]&63;i.push((c&31)<<12|d<<6|f)}else if((c&248)===240){const d=r[n++]&63,f=r[n++]&63,y=r[n++]&63;let B=(c&7)<<18|d<<12|f<<6|y;B>65535&&(B-=65536,i.push(B>>>10&1023|55296),B=56320|B&1023),i.push(B)}else i.push(c);i.length>=If&&(a+=String.fromCharCode(...i),i.length=0)}return i.length>0&&(a+=String.fromCharCode(...i)),a}const Bf=new TextDecoder,vf=200;function xf(r,t,e){const n=r.subarray(t,t+e);return Bf.decode(n)}function Af(r,t,e){return e>vf?xf(r,t,e):Mu(r,t,e)}class En{constructor(t,e){this.type=t,this.data=e}}class se extends Error{constructor(t){super(t);const e=Object.create(se.prototype);Object.setPrototypeOf(this,e),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:se.name})}}const Hr=4294967295;function Ef(r,t,e){const n=Math.floor(e/4294967296),s=e;r.setUint32(t,n),r.setUint32(t+4,s)}function Nu(r,t){const e=r.getInt32(t),n=r.getUint32(t+4);return e*4294967296+n}function Tf(r,t){const e=r.getUint32(t),n=r.getUint32(t+4);return e*4294967296+n}const Mf=-1,Nf=4294967296-1,Ff=17179869184-1;function Of({sec:r,nsec:t}){if(r>=0&&t>=0&&r<=Ff)if(t===0&&r<=Nf){const e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,r),e}else{const e=r/4294967296,n=r&4294967295,s=new Uint8Array(8),i=new DataView(s.buffer);return i.setUint32(0,t<<2|e&3),i.setUint32(4,n),s}else{const e=new Uint8Array(12),n=new DataView(e.buffer);return n.setUint32(0,t),Ef(n,4,r),e}}function kf(r){const t=r.getTime(),e=Math.floor(t/1e3),n=(t-e*1e3)*1e6,s=Math.floor(n/1e9);return{sec:e+s,nsec:n-s*1e9}}function Df(r){if(r instanceof Date){const t=kf(r);return Of(t)}else return null}function Uf(r){const t=new DataView(r.buffer,r.byteOffset,r.byteLength);switch(r.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:{const e=t.getUint32(0),n=t.getUint32(4),s=(e&3)*4294967296+n,i=e>>>2;return{sec:s,nsec:i}}case 12:{const e=Nu(t,4),n=t.getUint32(0);return{sec:e,nsec:n}}default:throw new se(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${r.length}`)}}function Lf(r){const t=Uf(r);return new Date(t.sec*1e3+t.nsec/1e6)}const Cf={type:Mf,encode:Df,decode:Lf};class us{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(Cf)}register({type:t,encode:e,decode:n}){if(t>=0)this.encoders[t]=e,this.decoders[t]=n;else{const s=-1-t;this.builtInEncoders[s]=e,this.builtInDecoders[s]=n}}tryToEncode(t,e){for(let n=0;n<this.builtInEncoders.length;n++){const s=this.builtInEncoders[n];if(s!=null){const i=s(t,e);if(i!=null){const a=-1-n;return new En(a,i)}}}for(let n=0;n<this.encoders.length;n++){const s=this.encoders[n];if(s!=null){const i=s(t,e);if(i!=null){const a=n;return new En(a,i)}}}return t instanceof En?t:null}decode(t,e,n){const s=e<0?this.builtInDecoders[-1-e]:this.decoders[e];return s?s(t,e,n):new En(e,t)}}us.defaultCodec=new us;function Rf(r){return r instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer}function na(r){return r instanceof Uint8Array?r:ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):Rf(r)?new Uint8Array(r):Uint8Array.from(r)}function Zi(r){return`${r<0?"-":""}0x${Math.abs(r).toString(16).padStart(2,"0")}`}const Pf=16,$f=16;class zf{constructor(t=Pf,e=$f){this.hit=0,this.miss=0,this.maxKeyLength=t,this.maxLengthPerKey=e,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(t){return t>0&&t<=this.maxKeyLength}find(t,e,n){const s=this.caches[n-1];t:for(const i of s){const a=i.bytes;for(let c=0;c<n;c++)if(a[c]!==t[e+c])continue t;return i.str}return null}store(t,e){const n=this.caches[t.length-1],s={bytes:t,str:e};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=s:n.push(s)}decode(t,e,n){const s=this.find(t,e,n);if(s!=null)return this.hit++,s;this.miss++;const i=Mu(t,e,n),a=Uint8Array.prototype.slice.call(t,e,e+n);return this.store(a,i),i}}const hs="array",cn="map_key",Fu="map_value",jf=r=>{if(typeof r=="string"||typeof r=="number")return r;throw new se("The type of key must be string or number but "+typeof r)};class Vf{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(t){const e=this.getUninitializedStateFromPool();e.type=hs,e.position=0,e.size=t,e.array=new Array(t)}pushMapState(t){const e=this.getUninitializedStateFromPool();e.type=cn,e.readCount=0,e.size=t,e.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const t={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(t)}return this.stack[this.stackHeadPosition]}release(t){if(this.stack[this.stackHeadPosition]!==t)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(t.type===hs){const n=t;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(t.type===cn||t.type===Fu){const n=t;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}const qr=-1,Gs=new DataView(new ArrayBuffer(0)),Wf=new Uint8Array(Gs.buffer);try{Gs.getInt8(0)}catch(r){if(!(r instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}const ia=new RangeError("Insufficient data"),Zf=new zf;class Ys{constructor(t){this.totalPos=0,this.pos=0,this.view=Gs,this.bytes=Wf,this.headByte=qr,this.stack=new Vf,this.entered=!1,this.extensionCodec=t?.extensionCodec??us.defaultCodec,this.context=t?.context,this.useBigInt64=t?.useBigInt64??!1,this.rawStrings=t?.rawStrings??!1,this.maxStrLength=t?.maxStrLength??Hr,this.maxBinLength=t?.maxBinLength??Hr,this.maxArrayLength=t?.maxArrayLength??Hr,this.maxMapLength=t?.maxMapLength??Hr,this.maxExtLength=t?.maxExtLength??Hr,this.keyDecoder=t?.keyDecoder!==void 0?t.keyDecoder:Zf,this.mapKeyConverter=t?.mapKeyConverter??jf}clone(){return new Ys({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=qr,this.stack.reset()}setBuffer(t){const e=na(t);this.bytes=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.pos=0}appendBuffer(t){if(this.headByte===qr&&!this.hasRemaining(1))this.setBuffer(t);else{const e=this.bytes.subarray(this.pos),n=na(t),s=new Uint8Array(e.length+n.length);s.set(e),s.set(n,e.length),this.setBuffer(s)}}hasRemaining(t){return this.view.byteLength-this.pos>=t}createExtraByteError(t){const{view:e,pos:n}=this;return new RangeError(`Extra ${e.byteLength-n} of ${e.byteLength} byte(s) found at buffer[${t}]`)}decode(t){if(this.entered)return this.clone().decode(t);try{this.entered=!0,this.reinitializeState(),this.setBuffer(t);const e=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return e}finally{this.entered=!1}}*decodeMulti(t){if(this.entered){yield*this.clone().decodeMulti(t);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(t);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(t){if(this.entered)return this.clone().decodeAsync(t);try{this.entered=!0;let e=!1,n;for await(const c of t){if(e)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(c);try{n=this.doDecodeSync(),e=!0}catch(d){if(!(d instanceof RangeError))throw d}this.totalPos+=this.pos}if(e){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}const{headByte:s,pos:i,totalPos:a}=this;throw new RangeError(`Insufficient data in parsing ${Zi(s)} at ${a} (${i} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(t){return this.decodeMultiAsync(t,!0)}decodeStream(t){return this.decodeMultiAsync(t,!1)}async*decodeMultiAsync(t,e){if(this.entered){yield*this.clone().decodeMultiAsync(t,e);return}try{this.entered=!0;let n=e,s=-1;for await(const i of t){if(e&&s===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i),n&&(s=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--s!==0;);}catch(a){if(!(a instanceof RangeError))throw a}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){t:for(;;){const t=this.readHeadByte();let e;if(t>=224)e=t-256;else if(t<192)if(t<128)e=t;else if(t<144){const s=t-128;if(s!==0){this.pushMapState(s),this.complete();continue t}else e={}}else if(t<160){const s=t-144;if(s!==0){this.pushArrayState(s),this.complete();continue t}else e=[]}else{const s=t-160;e=this.decodeString(s,0)}else if(t===192)e=null;else if(t===194)e=!1;else if(t===195)e=!0;else if(t===202)e=this.readF32();else if(t===203)e=this.readF64();else if(t===204)e=this.readU8();else if(t===205)e=this.readU16();else if(t===206)e=this.readU32();else if(t===207)this.useBigInt64?e=this.readU64AsBigInt():e=this.readU64();else if(t===208)e=this.readI8();else if(t===209)e=this.readI16();else if(t===210)e=this.readI32();else if(t===211)this.useBigInt64?e=this.readI64AsBigInt():e=this.readI64();else if(t===217){const s=this.lookU8();e=this.decodeString(s,1)}else if(t===218){const s=this.lookU16();e=this.decodeString(s,2)}else if(t===219){const s=this.lookU32();e=this.decodeString(s,4)}else if(t===220){const s=this.readU16();if(s!==0){this.pushArrayState(s),this.complete();continue t}else e=[]}else if(t===221){const s=this.readU32();if(s!==0){this.pushArrayState(s),this.complete();continue t}else e=[]}else if(t===222){const s=this.readU16();if(s!==0){this.pushMapState(s),this.complete();continue t}else e={}}else if(t===223){const s=this.readU32();if(s!==0){this.pushMapState(s),this.complete();continue t}else e={}}else if(t===196){const s=this.lookU8();e=this.decodeBinary(s,1)}else if(t===197){const s=this.lookU16();e=this.decodeBinary(s,2)}else if(t===198){const s=this.lookU32();e=this.decodeBinary(s,4)}else if(t===212)e=this.decodeExtension(1,0);else if(t===213)e=this.decodeExtension(2,0);else if(t===214)e=this.decodeExtension(4,0);else if(t===215)e=this.decodeExtension(8,0);else if(t===216)e=this.decodeExtension(16,0);else if(t===199){const s=this.lookU8();e=this.decodeExtension(s,1)}else if(t===200){const s=this.lookU16();e=this.decodeExtension(s,2)}else if(t===201){const s=this.lookU32();e=this.decodeExtension(s,4)}else throw new se(`Unrecognized type byte: ${Zi(t)}`);this.complete();const n=this.stack;for(;n.length>0;){const s=n.top();if(s.type===hs)if(s.array[s.position]=e,s.position++,s.position===s.size)e=s.array,n.release(s);else continue t;else if(s.type===cn){if(e==="__proto__")throw new se("The key __proto__ is not allowed");s.key=this.mapKeyConverter(e),s.type=Fu;continue t}else if(s.map[s.key]=e,s.readCount++,s.readCount===s.size)e=s.map,n.release(s);else{s.key=null,s.type=cn;continue t}}return e}}readHeadByte(){return this.headByte===qr&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=qr}readArraySize(){const t=this.readHeadByte();switch(t){case 220:return this.readU16();case 221:return this.readU32();default:{if(t<160)return t-144;throw new se(`Unrecognized array type byte: ${Zi(t)}`)}}}pushMapState(t){if(t>this.maxMapLength)throw new se(`Max length exceeded: map length (${t}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(t)}pushArrayState(t){if(t>this.maxArrayLength)throw new se(`Max length exceeded: array length (${t}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(t)}decodeString(t,e){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(t,e):this.decodeBinary(t,e)}decodeUtf8String(t,e){if(t>this.maxStrLength)throw new se(`Max length exceeded: UTF-8 byte length (${t}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+e+t)throw ia;const n=this.pos+e;let s;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(t)?s=this.keyDecoder.decode(this.bytes,n,t):s=Af(this.bytes,n,t),this.pos+=e+t,s}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===cn:!1}decodeBinary(t,e){if(t>this.maxBinLength)throw new se(`Max length exceeded: bin length (${t}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(t+e))throw ia;const n=this.pos+e,s=this.bytes.subarray(n,n+t);return this.pos+=e+t,s}decodeExtension(t,e){if(t>this.maxExtLength)throw new se(`Max length exceeded: ext length (${t}) > maxExtLength (${this.maxExtLength})`);const n=this.view.getInt8(this.pos+e),s=this.decodeBinary(t,e+1);return this.extensionCodec.decode(s,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const t=this.view.getUint8(this.pos);return this.pos++,t}readI8(){const t=this.view.getInt8(this.pos);return this.pos++,t}readU16(){const t=this.view.getUint16(this.pos);return this.pos+=2,t}readI16(){const t=this.view.getInt16(this.pos);return this.pos+=2,t}readU32(){const t=this.view.getUint32(this.pos);return this.pos+=4,t}readI32(){const t=this.view.getInt32(this.pos);return this.pos+=4,t}readU64(){const t=Tf(this.view,this.pos);return this.pos+=8,t}readI64(){const t=Nu(this.view,this.pos);return this.pos+=8,t}readU64AsBigInt(){const t=this.view.getBigUint64(this.pos);return this.pos+=8,t}readI64AsBigInt(){const t=this.view.getBigInt64(this.pos);return this.pos+=8,t}readF32(){const t=this.view.getFloat32(this.pos);return this.pos+=4,t}readF64(){const t=this.view.getFloat64(this.pos);return this.pos+=8,t}}function Gf(r,t){return new Ys(t).decode(r)}pa.set("msgpack2",async()=>({kind:"array_to_bytes",fromConfig:(r,t)=>({kind:"array_to_bytes",async encode(e){throw new Error("msgpack2 encode not implemented")},async decode(e){const n=Gf(e),{shape:s}=t,i=new Array(s.length);let a=1;for(let c=s.length-1;c>=0;c--)i[c]=a,a*=s[c];return{data:n,shape:s,stride:i}}})}));function Yf(r){return new Promise(t=>setTimeout(t,r))}const Gi="__cache_created_at";class Jf{cache;url;params;cache_prefix;fetchOptions;timeout;ttl;_pending={};_cacheValid;constructor(t,e,n={}){const s={...e};n.parameters&&(s["x-parameters"]=JSON.stringify(n.parameters)),n.chunks&&(s["x-chunks"]=n.chunks),n.downsample&&(s["x-downsample"]=JSON.stringify(n.downsample)),s["x-filtered"]="True",this.params={},e["x-datamesh-auth"]&&(this.params.auth=e["x-datamesh-auth"]),e["x-datamesh-sig"]&&(this.params.sig=e["x-datamesh-sig"]),this.fetchOptions={headers:s},this.url=t,n.nocache&&console.warn("CachedHTTPStore: 'nocache' option is deprecated, use 'ttl: 0' instead"),n.ttl===0||n.nocache||typeof window>"u"?this.cache=void 0:this.cache=Tu("zarr","cache"),this.cache_prefix=Sf({root:t,...n.parameters,chunks:n.chunks,downsample:n.downsample}),this.timeout=n.timeout||6e4,this.ttl=n.ttl}async checkCacheTTL(){if(!this.ttl||!this.cache)return!0;if(this._cacheValid!==void 0)return this._cacheValid;const t=`${this.cache_prefix}${Gi}`,e=await Vi(t,this.cache);return e?(Date.now()-e)/1e3>this.ttl?(this._cacheValid=!1,!1):(this._cacheValid=!0,!0):(this._cacheValid=!0,!0)}async setCacheTimestamp(){if(!this.cache||!this.ttl)return;const t=`${this.cache_prefix}${Gi}`;await Vi(t,this.cache)||await ea(t,Date.now(),this.cache)}async invalidateCache(){if(!this.cache)return;const t=`${this.cache_prefix}${Gi}`;await xn(t,this.cache),this._cacheValid=void 0}async get(t,e,n=0){const s=`${this.cache_prefix}${t}`;let i=null;if(this.cache&&(await this.checkCacheTTL()?i=await Vi(s,this.cache):await this.invalidateCache(),i&&delete this._pending[s],this._pending[s]))if(await Yf(200),n>this.timeout){await xn(s,this.cache),delete this._pending[s],console.error("Zarr timeout");return}else return await this.get(t,e,n+200);if(!i){this._pending[s]=!0;try{const a={...this.fetchOptions,...e,headers:{...this.fetchOptions.headers||{},...e?.headers||{}},signal:AbortSignal.timeout(this.timeout)},c=new URLSearchParams(this.params).toString(),d=await fetch(`${this.url}${t}?${c}`,a);if(d.status===404){this.cache&&await xn(s,this.cache);return}if(d.status>=400)throw new Error(`HTTP error: ${d.status}`);i=new Uint8Array(await d.arrayBuffer()),this.cache&&(await ea(s,i,this.cache),await this.setCacheTimestamp())}catch(a){if(console.debug("Zarr retry:"+s),n<this.timeout/200)return delete this._pending[s],await this.get(t,e,n+200);this.cache&&await xn(s,this.cache),console.error(a);return}finally{delete this._pending[s]}}return i}}const sa=async(r,t=".zarray")=>{const{path:e}=r.resolve(t),n=await r.store.get(e);return n?JSON.parse(new TextDecoder().decode(n)):{}};async function Hf(r){const t=await sa(r,".zattrs"),e=await sa(r);e.dtype.startsWith("<M8")&&(t._dtype=e.dtype),e.fill_value!==void 0&&(t._fill_value=e.fill_value);const n=[];e.order==="F"&&n.push({name:"transpose",configuration:{order:"F"}}),typeof e.dtype=="string"&&e.dtype.startsWith(">")&&n.push({name:"bytes",configuration:{endian:"big"}});for(const{id:i,...a}of e.filters??[])n.push({name:i,configuration:a});if(e.compressor){const{id:i,...a}=e.compressor;n.push({name:i,configuration:a})}const s={zarr_format:3,node_type:"array",shape:e.shape,data_type:"int64",chunk_grid:{name:"regular",configuration:{chunk_shape:e.chunks}},chunk_key_encoding:{name:"v2",configuration:{separator:e.dimension_separator??"."}},codecs:n,fill_value:e.fill_value,attributes:t};return new vr(r.store,r.path,s)}function Ti(r,t,e){const n=e.value;return e.value=async function(...s){const i=Date.now(),a=await n.apply(this,s),d=Date.now()-i;return console.debug(`${t} took ${d}ms`),a},e}const Js={microseconds:.001,milliseconds:1,seconds:1e3,minutes:60*1e3,hours:60*60*1e3,days:24*60*60*1e3},qf={day:"days",days:"days",d:"days",hour:"hours",hours:"hours",hr:"hours",hrs:"hours",h:"hours",minute:"minutes",minutes:"minutes",min:"minutes",mins:"minutes",second:"seconds",seconds:"seconds",sec:"seconds",secs:"seconds",s:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds",msec:"milliseconds",msecs:"milliseconds",ms:"milliseconds",microsecond:"microseconds",microseconds:"microseconds",usec:"microseconds",usecs:"microseconds",us:"microseconds"},Mi=new Set(["standard","gregorian","proleptic_gregorian"]);function Ni(r){const t=/^\s*(\w+)\s+since\s+(.+?)\s*$/i,e=r.match(t);if(!e)throw new Error(`Invalid CF time units: "${r}". Expected format: "<unit> since <reference_time>"`);const[,n,s]=e,i=n.toLowerCase(),a=qf[i];if(!a)throw new Error(`Unsupported time unit: "${n}". Supported units: days, hours, minutes, seconds, milliseconds, microseconds`);const c=Kf(s),d=c.getTime();return{unit:a,referenceDate:c,referenceMs:d,original:r}}function Kf(r){const t=r.trim().replace("T"," ").replace(/Z$/i,""),e=/^(-?\d+)-(\d{1,2})-(\d{1,2})(?:\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2})(?:\.(\d+))?)?)?$/,n=t.match(e);if(!n){const C=new Date(r);if(isNaN(C.getTime()))throw new Error(`Cannot parse reference time: "${r}"`);return C}const[,s,i,a,c,d,f,y]=n,B=parseInt(s,10),L=parseInt(i,10)-1,x=parseInt(a,10),M=c?parseInt(c,10):0,U=d?parseInt(d,10):0,F=f?parseInt(f,10):0;let O=0;if(y){const C=y.padEnd(3,"0").slice(0,3);O=parseInt(C,10)}return new Date(Date.UTC(B,L,x,M,U,F,O))}function Xf(r,t,e="standard"){if(!Mi.has(e))throw new Error(`Unsupported calendar: "${e}". Currently only Gregorian calendars are supported: standard, gregorian, proleptic_gregorian`);const n=Ni(t),s=Js[n.unit];if(typeof r=="number")return new Date(n.referenceMs+r*s);const i=[];for(let a=0;a<r.length;a++){const c=r[a];c==null||Number.isNaN(c)?i.push(new Date(NaN)):i.push(new Date(n.referenceMs+c*s))}return i}function Qf(r,t,e="standard"){if(!Mi.has(e))throw new Error(`Unsupported calendar: "${e}". Currently only Gregorian calendars are supported: standard, gregorian, proleptic_gregorian`);const n=Ni(t),s=Js[n.unit];return r instanceof Date?(r.getTime()-n.referenceMs)/s:r.map(i=>!i||isNaN(i.getTime())?NaN:(i.getTime()-n.referenceMs)/s)}function Ou(r){return Mi.has(r.toLowerCase())}function tp(){return Array.from(Mi)}function ku(r){const t=r.units;return typeof t=="string"&&/^\s*\w+\s+since\s+.+$/i.test(t)}function Du(r,t,e="standard"){if(!Ou(e))return null;const n=Ni(t),s=Js[n.unit],i=n.referenceMs,a=new Float64Array(r.length);for(let c=0;c<r.length;c++){const d=Number(r[c]);Number.isNaN(d)?a[c]=NaN:a[c]=(i+d*s)/1e3}return a}var ep=Object.defineProperty,rp=Object.getOwnPropertyDescriptor,np=(r,t,e,n)=>{for(var s=rp(t,e),i=r.length-1,a;i>=0;i--)(a=r[i])&&(s=a(t,e,s)||s);return s&&ep(t,e,s),s};const oa=(r,t,e,n,s)=>n?.variables?.[r]?n.variables[r]:s||(n?.dimensions?t.map((i,a)=>n.dimensions?.[i]??e[a]):e),Uu=r=>{const t=new Eu.Buffer(r,"base64");return mf.Geometry.parse(t).toGeoJSON()},mi=r=>r&&(Array.isArray(r)||ArrayBuffer.isView(r)),Yi=r=>{const t=[];if(!mi(r))return t;for(;t.push(r.length),mi(r[0]);)r=r[0];return t},ip=r=>{for(;Array.isArray(r);)r=r[0];if(r==null)return"uint8";switch(r.constructor.name){case"Boolean":return"bool";case"Number":return"float32";case"Int8Array":return"int8";case"Int16Array":return"int16";case"Int32Array":return"int32";case"BigInt64Array":return"int64";case"Uint8Array":return"uint8";case"Uint16Array":return"uint16";case"Uint32Array":return"uint32";case"Float32Array":return"float32";case"Float64Array":return"float64";case"String":return"v2:object";case"Object":return"v2:object"}throw new Error("Unsupported data type: "+r.constructor.name)},sp=r=>{let t=r.toString().toLowerCase();return r.typeId==5?t="v2:object":r.typeId==1&&(t="uint8"),t},aa=r=>{if(!Array.isArray(r))return r;const t=r.flat(1/0);if(mi(t[0])){const e=t[0].length,n=new t[0].constructor(t.length*e);for(let s=0;s<t.length;s++)n.set(t[s],s*e);return n}else return t},ca=r=>{const t=r.length,e=Array(t);for(let n=t-1,s=1;n>=0;n--)e[n]=s,s*=r[n];return e},pn=(r,t,e,n=0)=>{if(t.length===0)return r[0];if(t.length===1){const i=new r.constructor(t[0]);return i.set(r.slice(n,n+t[0])),i}const s=new Array(t[0]);for(let i=0;i<t[0];i++)s[i]=pn(r,t.slice(1),e.slice(1),n+i*e[0]);return s},op=(r,t)=>{const[e,n]=t.split("<M8"),s=new Float64Array(r.data.length);let i=1n;switch(n){case"[ms]":i=1000n;break;case"[us]":i=1000000n;break;case"[ns]":i=1000000000n;break;default:i=1n;break}for(let a=0;a<r.data.length;a++){const c=r.data[a];s[a]=Number(c/i)}return pn(s,r.shape,r.stride)},ap=(r,t,e="standard")=>{const n=Du(r.data,t,e);return n===null?(console.warn(`Unsupported calendar "${e}" for cftime conversion. Returning raw values. Supported: standard, gregorian, proleptic_gregorian`),pn(r.data,r.shape,r.stride)):pn(n,r.shape,r.stride)},cp=r=>{if(r==null)return!0;if(typeof r=="string"){const t=r.toLowerCase();return t==="nan"||t==="-nan"||t==="+nan"}return typeof r=="number"?Number.isNaN(r):!1},up=(r,t,e)=>{if(!e.startsWith("float")||cp(t))return r;if(typeof t=="number"&&!Number.isNaN(t)){const n=e==="float64"?new Float64Array(r.length):new Float32Array(r.length);for(let s=0;s<r.length;s++){const i=r[s];n[s]=Math.abs(i-t)<Math.abs(t*1e-6)?NaN:i}return n}return r},Lu=(r,t,e)=>{const n=Object.keys(t),s={};for(const i in r)mi(r[i].data)&&(s[i]=!0);if(n.length==1)for(let i=0;i<t[n[0]];i++){const a={};for(const c in r)s[c]?r[c].data.length>1&&(a[c]=r[c].data[i]):a[c]=r[c].data;e.push(a)}else for(let i=0;i<t[n[0]];i++){const a={};for(const d in r)r[d].dimensions.includes(n[0])?a[d]={attributes:r[d].attributes,data:r[d].data[i],dimensions:r[d].dimensions.slice(1)}:a[d]=r[d];const c={...t};delete c[n[0]],Lu(a,c,e)}return e};class wi{id;dimensions;attributes;arr;constructor(t,e,n,s){this.id=t,this.dimensions=e,this.attributes=n,this.arr=s}async get(t){if(this.arr.shape.length==0||this.arr.shape[0]==0)return[];const e=t&&t.map(s=>{if(typeof s=="string"){const[i,a,c]=s.split(":");return Hi(parseInt(i),parseInt(a),parseInt(c))}else return s}),n=await kh(this.arr,e);if(this.arr.dtype=="v2:object"||!n.shape)return n.data;if(this.arr.dtype=="bool")return[...n.data];{const s=this.arr.attrs,i=this.arr.dtype,a=s._dtype;if(a?.startsWith("<M8"))return op(n,a);if(ku(s)){const f=s.units,y=s.calendar||"standard";return ap(n,f,y)}const c=this.attributes._fill_value,d=c?up(n.data,c,i):n.data;return pn(d,n.shape,n.stride)}}}np([Ti],wi.prototype,"get");class Ye{dimensions;variables;attributes;coordkeys;root;constructor(t,e,n,s,i){this.dimensions=t,this.variables=e,this.attributes=n,this.coordkeys=s,this.root=i}static async zarr(t,e,n={}){const s=new Jf(t,e,{chunks:n.chunks,downsample:n.downsample,parameters:n.parameters,timeout:n.timeout,nocache:n.nocache,ttl:n.ttl}),i=await yh(s),a=await Ge(i,{kind:"group"}),c={},d={};for(const y of i.contents())if(y.kind=="array"){let B;try{B=await Ge(a.resolve(y.path),{kind:"array"})}catch(U){const F=typeof U=="object"&&U&&"message"in U?String(U.message):void 0;if(F&&F.includes("<M8"))B=await Hf(a.resolve(y.path));else throw U}const L={...B.attrs};if(L._fill_value===void 0){const U=`${y.path}/.zarray`.replace(/^\//,""),F=await i.get(`/${U}`);if(F){const O=JSON.parse(new TextDecoder().decode(F));O.fill_value!==void 0&&(L._fill_value=O.fill_value)}}const x=L._ARRAY_DIMENSIONS,M=y.path.split("/").pop();c[M]=new wi(M,x||[],L,B),x&&x.map((U,F)=>{const O=B.shape[F];if(d[U]&&d[U]!=O)throw new Error(`Inconsistent dimension size for ${U}: ${d[U]} != ${O}`);d[U]=O})}const f=JSON.parse(a.attrs._coordinates||"{}")||{};return new Ye(d,c,a.attrs,n.coordkeys||f,a)}static async fromArrow(t,e){const n={},s={record:t.numRows},i={};return t.schema.fields.forEach(a=>{const c=t.getChild(a.name);let d={},f=c?.toArray(),y=sp(a.type);if(tt.isTimestamp(a.type)){const B=new Float64Array(f.length),L=BigInt(1e3**(a.type.unit-0));for(let x=0;x<f.length;x++)B[x]=Number(f[x]/L);f=B,y="float64",d={unit:"Unix timestamp (s)"}}else if(tt.isBinary(a.type)){const B=[];for(let L=0;L<f.length;L++)B.push(new Eu.Buffer(f[L]).toString("base64"));f=B,y="v2:object"}i[a.name]={dimensions:["record"],attributes:d,data:f,dtype:y}}),await Ye.init({dimensions:s,variables:i,attributes:n},e)}static async fromGeojson(t,e){if(!("features"in t&&Array.isArray(t.features))&&!("geometry"in t))throw new Error("Invalid GeoJSON");const n="features"in t&&t.features?t.features:[t];if(n.length===0)throw new Error("FeatureCollection contains no features");const s=new Set;n.forEach(d=>{d.properties&&Object.keys(d.properties).forEach(f=>s.add(f))});const i=n.map(d=>{const f={geometry:d.geometry};return d.properties&&Object.assign(f,d.properties),f}),a={dimensions:{index:i.length},variables:{},attributes:{}},c=await Ye.init(a,{...e,g:"geometry"});await c.assign("geometry",["index"],i.map(d=>d.geometry),{description:"GeoJSON geometry"});for(const d of s){const f=i.map(y=>y[d]);await c.assign(d,["index"],f,{description:`Property: ${d}`})}return c}static async init(t,e,n){const s=await _n(new Map,{attributes:{created:new Date}}),i=new Ye(t.dimensions,{},t.attributes||{},e||{},s);for(const a in t.variables){const{dimensions:c,attributes:d,data:f,dtype:y,chunks:B}=t.variables[a],L=Yi(f),x=oa(a,c,L,n,B);await i.assign(a,c,f,d,y&&y==="string"?"v2:object":y,x)}return i}async asDataframe(){const t={},e=[];for(const s in this.variables)t[s]={attributes:this.variables[s].attributes,dimensions:this.variables[s].dimensions},t[s].data=await this.variables[s].get(),this.variables[s].arr.dtype=="int64"&&s!=this.coordkeys.t&&e.push(s);const n=Lu(t,{...this.dimensions},[]);if(this.coordkeys.t)for(let s=0;s<n.length;s++)n[s][this.coordkeys.t]=new Date(1e3*n[s][this.coordkeys.t]).toISOString();if(e.length>0)for(const s of e)for(let i=0;i<n.length;i++)n[i][s]=Number(n[i][s]);return n}async asGeojson(t){if(!this.coordkeys.g&&!t)throw new Error("No geometry found");const e=[],n=await this.asDataframe();for(let s=0;s<n.length;s++){const{...i}=n[s];let a=t;if(!a&&this.coordkeys.g){delete i[this.coordkeys.g];const c=n[s][this.coordkeys.g];c.slice(0,7)=='{"type:'?a=JSON.parse(c):a=Uu(c)}e.push({type:"Feature",geometry:a,properties:i})}return{type:"FeatureCollection",features:e}}async assign(t,e,n,s,i,a){const c=Yi(n);if(c.length!=e.length)throw new Error("Data shape does not match dimensions");e.map((B,L)=>{if(this.dimensions[B]){if(this.dimensions[B]!=c[L])throw new Error(`Existing size of dimension ${B} does not match new data`)}else this.dimensions[B]=c[L]});const d=i||ip(n),f=await _n(this.root.resolve(t),{shape:c,data_type:d,chunk_shape:a||c,codecs:d=="v2:object"?[{name:"json2"}]:[]});let y=aa(n);y.length==0?y=null:d=="bool"?y=new $n(y):Array.isArray(y)&&d=="float32"?y=Float32Array.from(y,B=>B??NaN):Array.isArray(y)&&d=="float64"?y=Float64Array.from(y,B=>B??NaN):Array.isArray(y)&&d=="int8"?y=Int8Array.from(y):Array.isArray(y)&&d=="int16"?y=Int16Array.from(y):Array.isArray(y)&&d=="int32"?y=Int32Array.from(y):Array.isArray(y)&&d=="int64"?y=BigInt64Array.from(y.map(B=>BigInt(B))):Array.isArray(y)&&d=="uint8"?y=Uint8Array.from(y):Array.isArray(y)&&d=="uint16"?y=Uint16Array.from(y):Array.isArray(y)&&d=="uint32"?y=Uint32Array.from(y):Array.isArray(y)&&d=="uint64"&&(y=BigUint64Array.from(y.map(B=>BigInt(B)))),y&&await oo(f,c.map(()=>null),{data:y,shape:c,stride:ca(c)}),this.variables[t]=new wi(t,e,s||{},f)}async toZarr(t){const e=t?.chunks,n=new Map,s=await _n(n,{attributes:{...this.attributes,_coordinates:JSON.stringify(this.coordkeys)}});for(const i in this.variables){const a=this.variables[i],c=await a.get(),d=Yi(c),f=a.dimensions,y=oa(i,f,d,e,e?void 0:a.arr.chunks),B=a.arr.dtype,L=await _n(s.resolve(i),{shape:d,data_type:B,chunk_shape:y,codecs:B==="v2:object"?[{name:"json2"}]:void 0,attributes:{...a.attributes,_ARRAY_DIMENSIONS:f}});let x=aa(c);x&&x.length>0&&(B==="bool"?x=new $n(x):Array.isArray(x)&&B==="float32"?x=Float32Array.from(x,M=>M??NaN):Array.isArray(x)&&B==="float64"?x=Float64Array.from(x,M=>M??NaN):Array.isArray(x)&&B==="int8"?x=Int8Array.from(x):Array.isArray(x)&&B==="int16"?x=Int16Array.from(x):Array.isArray(x)&&B==="int32"?x=Int32Array.from(x):Array.isArray(x)&&B==="int64"?x=BigInt64Array.from(x.map(M=>BigInt(M))):Array.isArray(x)&&B==="uint8"?x=Uint8Array.from(x):Array.isArray(x)&&B==="uint16"?x=Uint16Array.from(x):Array.isArray(x)&&B==="uint32"?x=Uint32Array.from(x):Array.isArray(x)&&B==="uint64"&&(x=BigUint64Array.from(x.map(M=>BigInt(M)))),await oo(L,d.map(()=>null),{data:x,shape:d,stride:ca(d)}))}return n}}var hp=Object.defineProperty,lp=Object.getOwnPropertyDescriptor,dp=(r,t,e,n)=>{for(var s=lp(t,e),i=r.length-1,a;i>=0;i--)(a=r[i])&&(s=a(t,e,s)||s);return s&&hp(t,e,s),s};const Cu=class ls{id;user;creationTime;endTime;write;verified=!1;_connection;static async acquire(t,e={}){if(!t._isV1){const n=new ls;return n.id="dummy_session",n.user="dummy_user",n.creationTime=new Date,n.endTime=new Date(Date.now()+(e.duration||3600)*1e3),n.write=!1,n.verified=!1,n._connection=t,typeof process<"u"&&process.on&&process.on("beforeExit",()=>{n.close()}),n}try{const n={...t._authHeaders};n["Cache-Control"]="no-store";const s=new URLSearchParams({duration:String(e.duration??3600)}),i=await fetch(`${t._gateway}/session/?${s.toString()}`,{headers:n});if(i.status!==200)throw new Error(`Failed to create session: ${await i.text()}`);const a=await i.json(),c=new ls;return c.id=a.id,c.user=a.user,c.creationTime=new Date(a.creation_time),c.endTime=new Date(a.end_time),c.write=a.write,c.verified=a.verified||!1,c._connection=t,typeof process<"u"&&process.on&&process.on("beforeExit",()=>{c.close()}),c}catch(n){throw new Error(`Error when acquiring datamesh session: ${n}`)}}get header(){return{"X-DATAMESH-SESSIONID":this.id}}addHeader(t){return{...t,...this.header}}async close(t=!1){if(this._connection._isV1)try{typeof process<"u"&&process.off&&process.off("beforeExit",this.close);const e=await fetch(`${this._connection._gateway}/session/${this.id}`,{method:"DELETE",headers:this.header,body:JSON.stringify({finalise_write:t})});if(e.status!==204){if(t)throw new Error(`Failed to finalise write: ${await e.text()}`);console.warn(`Failed to close session: ${await e.text()}`)}}catch(e){if(t)throw new Error(`Error when closing datamesh session: ${e}`);console.warn(`Error when closing datamesh session: ${e}`)}}async enter(){return this}async exit(t){await this.close(t===void 0)}};dp([Ti],Cu,"acquire");let fp=Cu;var pp=Object.defineProperty,yp=Object.getOwnPropertyDescriptor,Ru=(r,t,e,n)=>{for(var s=yp(t,e),i=r.length-1,a;i>=0;i--)(a=r[i])&&(s=a(t,e,s)||s);return s&&pp(t,e,s),s};const gp=typeof process<"u"&&process.env?.DATAMESH_SERVICE?process.env.DATAMESH_SERVICE:"https://datamesh.oceanum.io",Hs=class Pu{static LAZY_LOAD_SIZE=1e8;_token;_host;_authHeaders;_gateway;_nocache=!1;_isV1=!1;_sessionParams={};_currentSession=null;service;gateway;constructor(t=typeof process<"u"&&process.env?.DATAMESH_TOKEN?process.env.DATAMESH_TOKEN:"$DATAMESH_TOKEN",e){if(!t&&!e?.jwtAuth)throw new Error("A valid datamesh token must be supplied as a connector constructor argument or defined in environment variables as DATAMESH_TOKEN");this._token=t,this._nocache=e?.nocache??!1;const n=new URL(e?.service||gp);this._host=`${n.protocol}//${n.hostname}`,this._authHeaders=e?.jwtAuth?{Authorization:`Bearer ${e.jwtAuth}`}:{Authorization:`Token ${this._token}`,"X-DATAMESH-TOKEN":this._token},this._gateway=e?.gateway||this._host,this._host.split(".").slice(-1)[0]!==this._gateway.split(".").slice(-1)[0]&&console.warn("Datamesh gateway and service domains do not match"),e?.sessionDuration&&typeof e.sessionDuration=="number"&&(this._sessionParams={duration:e.sessionDuration}),this._checkApiVersion()}async _checkApiVersion(){try{(await fetch(`${this._gateway}/session`,{headers:this._authHeaders})).status===200?(this._isV1=!0,console.info("Using datamesh API version 1")):(this._isV1=!1,console.info("Using datamesh API version 0"))}catch{this._isV1=!1,console.info("Using datamesh API version 0")}}get host(){return this._host}async status(){return(await fetch(this._host,{headers:this._authHeaders})).status===200}async validateResponse(t){if(t.status>=400){let e;try{e=(await t.json()).detail}catch{e=`Datamesh server error: ${await t.text()}`}throw new Error(e)}}async createSession(t={}){const e={duration:t.duration||this._sessionParams.duration||3600};return this._currentSession=await fp.acquire(this,e),this._currentSession}async getSession(){return this._currentSession?this._currentSession:this.createSession()}async getSessionHeaders(t={}){return this._isV1&&!this._currentSession&&await this.createSession(),this._currentSession?this._currentSession.addHeader({...this._authHeaders,...t}):{...this._authHeaders,...t}}async metadataRequest(t="",e={}){const n=new URL(`${this._host}/datasource/${t}`);Object.keys(e).forEach(a=>n.searchParams.append(a,e[a]));const s=await this.getSessionHeaders(),i=await fetch(n.toString(),{headers:s});if(i.status===403)throw new Error(`Datasource ${t} not authorized`);return await this.validateResponse(i),i}async dataRequest(t,e="application/vnd.apache.arrow.file"){const n=await this.getSessionHeaders({Accept:e}),s=await fetch(`${this._gateway}/oceanql/${t}?f=arrow`,{headers:n});return await this.validateResponse(s),Iu(await s.arrayBuffer())}async stageRequest(t){const e=JSON.stringify(t),n=await this.getSessionHeaders({"Content-Type":"application/json"}),s=await fetch(`${this._gateway}/oceanql/stage/`,{method:"POST",headers:n,body:e});if(s.status>=400){const i=await s.json();throw new Error(i.detail)}else return s.status===204?null:s.json()}async query(t,e={}){const n=await this.stageRequest(t);if(!n)return console.warn("No data found for query"),null;if(n.size<Pu.LAZY_LOAD_SIZE&&n.container!="dataset"){const d=await this.dataRequest(n.qhash);return await Ye.fromArrow(d,n.coordkeys)}const s=`${this._gateway}/zarr/${this._isV1?"query/":""}${n.qhash}`,i=t.parameters,a=await this.getSessionHeaders(),c=await Ye.zarr(s,a,{parameters:i,timeout:e.timeout||6e4,nocache:this._nocache});if(t.variables)for(const d of Object.keys(c.variables))!t.variables.includes(d)&&!Object.values(c.coordkeys).includes(d)&&delete c.variables[d];return c}async getDatasource(t){const n=await(await this.metadataRequest(t)).json();return{id:t,geom:n.geometry,...n.properties}}async loadDatasource(t,e={}){const n={datasource:t,parameters:e};return await this.query(n)}async closeSession(t=!1){this._currentSession&&(await this._currentSession.close(t),this._currentSession=null)}};Ru([Ti],Hs.prototype,"stageRequest");Ru([Ti],Hs.prototype,"query");let mp=Hs;var Rn={exports:{}},wp=Rn.exports,ua;function bp(){return ua||(ua=1,function(r,t){(function(e,n){r.exports=n()})(wp,function(){var e=1e3,n=6e4,s=36e5,i="millisecond",a="second",c="minute",d="hour",f="day",y="week",B="month",L="quarter",x="year",M="date",U="Invalid Date",F=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,O=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,C={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(z){var R=["th","st","nd","rd"],D=z%100;return"["+z+(R[(D-20)%10]||R[D]||R[0])+"]"}},P=function(z,R,D){var Y=String(z);return!Y||Y.length>=R?z:""+Array(R+1-Y.length).join(D)+z},V={s:P,z:function(z){var R=-z.utcOffset(),D=Math.abs(R),Y=Math.floor(D/60),Z=D%60;return(R<=0?"+":"-")+P(Y,2,"0")+":"+P(Z,2,"0")},m:function z(R,D){if(R.date()<D.date())return-z(D,R);var Y=12*(D.year()-R.year())+(D.month()-R.month()),Z=R.clone().add(Y,B),X=D-Z<0,K=R.clone().add(Y+(X?-1:1),B);return+(-(Y+(D-Z)/(X?Z-K:K-Z))||0)},a:function(z){return z<0?Math.ceil(z)||0:Math.floor(z)},p:function(z){return{M:B,y:x,w:y,d:f,D:M,h:d,m:c,s:a,ms:i,Q:L}[z]||String(z||"").toLowerCase().replace(/s$/,"")},u:function(z){return z===void 0}},G="en",A={};A[G]=C;var N="$isDayjsObject",m=function(z){return z instanceof k||!(!z||!z[N])},S=function z(R,D,Y){var Z;if(!R)return G;if(typeof R=="string"){var X=R.toLowerCase();A[X]&&(Z=X),D&&(A[X]=D,Z=X);var K=R.split("-");if(!Z&&K.length>1)return z(K[0])}else{var q=R.name;A[q]=R,Z=q}return!Y&&Z&&(G=Z),Z||!Y&&G},w=function(z,R){if(m(z))return z.clone();var D=typeof R=="object"?R:{};return D.date=z,D.args=arguments,new k(D)},v=V;v.l=S,v.i=m,v.w=function(z,R){return w(z,{locale:R.$L,utc:R.$u,x:R.$x,$offset:R.$offset})};var k=function(){function z(D){this.$L=S(D.locale,null,!0),this.parse(D),this.$x=this.$x||D.x||{},this[N]=!0}var R=z.prototype;return R.parse=function(D){this.$d=function(Y){var Z=Y.date,X=Y.utc;if(Z===null)return new Date(NaN);if(v.u(Z))return new Date;if(Z instanceof Date)return new Date(Z);if(typeof Z=="string"&&!/Z$/i.test(Z)){var K=Z.match(F);if(K){var q=K[2]-1||0,rt=(K[7]||"0").substring(0,3);return X?new Date(Date.UTC(K[1],q,K[3]||1,K[4]||0,K[5]||0,K[6]||0,rt)):new Date(K[1],q,K[3]||1,K[4]||0,K[5]||0,K[6]||0,rt)}}return new Date(Z)}(D),this.init()},R.init=function(){var D=this.$d;this.$y=D.getFullYear(),this.$M=D.getMonth(),this.$D=D.getDate(),this.$W=D.getDay(),this.$H=D.getHours(),this.$m=D.getMinutes(),this.$s=D.getSeconds(),this.$ms=D.getMilliseconds()},R.$utils=function(){return v},R.isValid=function(){return this.$d.toString()!==U},R.isSame=function(D,Y){var Z=w(D);return this.startOf(Y)<=Z&&Z<=this.endOf(Y)},R.isAfter=function(D,Y){return w(D)<this.startOf(Y)},R.isBefore=function(D,Y){return this.endOf(Y)<w(D)},R.$g=function(D,Y,Z){return v.u(D)?this[Y]:this.set(Z,D)},R.unix=function(){return Math.floor(this.valueOf()/1e3)},R.valueOf=function(){return this.$d.getTime()},R.startOf=function(D,Y){var Z=this,X=!!v.u(Y)||Y,K=v.p(D),q=function(g,_){var T=v.w(Z.$u?Date.UTC(Z.$y,_,g):new Date(Z.$y,_,g),Z);return X?T:T.endOf(f)},rt=function(g,_){return v.w(Z.toDate()[g].apply(Z.toDate("s"),(X?[0,0,0,0]:[23,59,59,999]).slice(_)),Z)},At=this.$W,Ut=this.$M,Pt=this.$D,Zt="set"+(this.$u?"UTC":"");switch(K){case x:return X?q(1,0):q(31,11);case B:return X?q(1,Ut):q(0,Ut+1);case y:var Gt=this.$locale().weekStart||0,W=(At<Gt?At+7:At)-Gt;return q(X?Pt-W:Pt+(6-W),Ut);case f:case M:return rt(Zt+"Hours",0);case d:return rt(Zt+"Minutes",1);case c:return rt(Zt+"Seconds",2);case a:return rt(Zt+"Milliseconds",3);default:return this.clone()}},R.endOf=function(D){return this.startOf(D,!1)},R.$set=function(D,Y){var Z,X=v.p(D),K="set"+(this.$u?"UTC":""),q=(Z={},Z[f]=K+"Date",Z[M]=K+"Date",Z[B]=K+"Month",Z[x]=K+"FullYear",Z[d]=K+"Hours",Z[c]=K+"Minutes",Z[a]=K+"Seconds",Z[i]=K+"Milliseconds",Z)[X],rt=X===f?this.$D+(Y-this.$W):Y;if(X===B||X===x){var At=this.clone().set(M,1);At.$d[q](rt),At.init(),this.$d=At.set(M,Math.min(this.$D,At.daysInMonth())).$d}else q&&this.$d[q](rt);return this.init(),this},R.set=function(D,Y){return this.clone().$set(D,Y)},R.get=function(D){return this[v.p(D)]()},R.add=function(D,Y){var Z,X=this;D=Number(D);var K=v.p(Y),q=function(Ut){var Pt=w(X);return v.w(Pt.date(Pt.date()+Math.round(Ut*D)),X)};if(K===B)return this.set(B,this.$M+D);if(K===x)return this.set(x,this.$y+D);if(K===f)return q(1);if(K===y)return q(7);var rt=(Z={},Z[c]=n,Z[d]=s,Z[a]=e,Z)[K]||1,At=this.$d.getTime()+D*rt;return v.w(At,this)},R.subtract=function(D,Y){return this.add(-1*D,Y)},R.format=function(D){var Y=this,Z=this.$locale();if(!this.isValid())return Z.invalidDate||U;var X=D||"YYYY-MM-DDTHH:mm:ssZ",K=v.z(this),q=this.$H,rt=this.$m,At=this.$M,Ut=Z.weekdays,Pt=Z.months,Zt=Z.meridiem,Gt=function(_,T,j,$){return _&&(_[T]||_(Y,X))||j[T].slice(0,$)},W=function(_){return v.s(q%12||12,_,"0")},g=Zt||function(_,T,j){var $=_<12?"AM":"PM";return j?$.toLowerCase():$};return X.replace(O,function(_,T){return T||function(j){switch(j){case"YY":return String(Y.$y).slice(-2);case"YYYY":return v.s(Y.$y,4,"0");case"M":return At+1;case"MM":return v.s(At+1,2,"0");case"MMM":return Gt(Z.monthsShort,At,Pt,3);case"MMMM":return Gt(Pt,At);case"D":return Y.$D;case"DD":return v.s(Y.$D,2,"0");case"d":return String(Y.$W);case"dd":return Gt(Z.weekdaysMin,Y.$W,Ut,2);case"ddd":return Gt(Z.weekdaysShort,Y.$W,Ut,3);case"dddd":return Ut[Y.$W];case"H":return String(q);case"HH":return v.s(q,2,"0");case"h":return W(1);case"hh":return W(2);case"a":return g(q,rt,!0);case"A":return g(q,rt,!1);case"m":return String(rt);case"mm":return v.s(rt,2,"0");case"s":return String(Y.$s);case"ss":return v.s(Y.$s,2,"0");case"SSS":return v.s(Y.$ms,3,"0");case"Z":return K}return null}(_)||K.replace(":","")})},R.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},R.diff=function(D,Y,Z){var X,K=this,q=v.p(Y),rt=w(D),At=(rt.utcOffset()-this.utcOffset())*n,Ut=this-rt,Pt=function(){return v.m(K,rt)};switch(q){case x:X=Pt()/12;break;case B:X=Pt();break;case L:X=Pt()/3;break;case y:X=(Ut-At)/6048e5;break;case f:X=(Ut-At)/864e5;break;case d:X=Ut/s;break;case c:X=Ut/n;break;case a:X=Ut/e;break;default:X=Ut}return Z?X:v.a(X)},R.daysInMonth=function(){return this.endOf(B).$D},R.$locale=function(){return A[this.$L]},R.locale=function(D,Y){if(!D)return this.$L;var Z=this.clone(),X=S(D,Y,!0);return X&&(Z.$L=X),Z},R.clone=function(){return v.w(this.$d,this)},R.toDate=function(){return new Date(this.valueOf())},R.toJSON=function(){return this.isValid()?this.toISOString():null},R.toISOString=function(){return this.$d.toISOString()},R.toString=function(){return this.$d.toUTCString()},z}(),Q=k.prototype;return w.prototype=Q,[["$ms",i],["$s",a],["$m",c],["$H",d],["$W",f],["$M",B],["$y",x],["$D",M]].forEach(function(z){Q[z[1]]=function(R){return this.$g(R,z[0],z[1])}}),w.extend=function(z,R){return z.$i||(z(R,k,w),z.$i=!0),w},w.locale=S,w.isDayjs=m,w.unix=function(z){return w(1e3*z)},w.en=A[G],w.Ls=A,w.p={},w})}(Rn)),Rn.exports}var _p=bp();const mr=Vs(_p);var Pn={exports:{}},Sp=Pn.exports,ha;function Ip(){return ha||(ha=1,function(r,t){(function(e,n){r.exports=n()})(Sp,function(){var e,n,s=1e3,i=6e4,a=36e5,c=864e5,d=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,f=31536e6,y=2628e6,B=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,L={years:f,months:y,days:c,hours:a,minutes:i,seconds:s,milliseconds:1,weeks:6048e5},x=function(A){return A instanceof V},M=function(A,N,m){return new V(A,m,N.$l)},U=function(A){return n.p(A)+"s"},F=function(A){return A<0},O=function(A){return F(A)?Math.ceil(A):Math.floor(A)},C=function(A){return Math.abs(A)},P=function(A,N){return A?F(A)?{negative:!0,format:""+C(A)+N}:{negative:!1,format:""+A+N}:{negative:!1,format:""}},V=function(){function A(m,S,w){var v=this;if(this.$d={},this.$l=w,m===void 0&&(this.$ms=0,this.parseFromMilliseconds()),S)return M(m*L[U(S)],this);if(typeof m=="number")return this.$ms=m,this.parseFromMilliseconds(),this;if(typeof m=="object")return Object.keys(m).forEach(function(z){v.$d[U(z)]=m[z]}),this.calMilliseconds(),this;if(typeof m=="string"){var k=m.match(B);if(k){var Q=k.slice(2).map(function(z){return z!=null?Number(z):0});return this.$d.years=Q[0],this.$d.months=Q[1],this.$d.weeks=Q[2],this.$d.days=Q[3],this.$d.hours=Q[4],this.$d.minutes=Q[5],this.$d.seconds=Q[6],this.calMilliseconds(),this}}return this}var N=A.prototype;return N.calMilliseconds=function(){var m=this;this.$ms=Object.keys(this.$d).reduce(function(S,w){return S+(m.$d[w]||0)*L[w]},0)},N.parseFromMilliseconds=function(){var m=this.$ms;this.$d.years=O(m/f),m%=f,this.$d.months=O(m/y),m%=y,this.$d.days=O(m/c),m%=c,this.$d.hours=O(m/a),m%=a,this.$d.minutes=O(m/i),m%=i,this.$d.seconds=O(m/s),m%=s,this.$d.milliseconds=m},N.toISOString=function(){var m=P(this.$d.years,"Y"),S=P(this.$d.months,"M"),w=+this.$d.days||0;this.$d.weeks&&(w+=7*this.$d.weeks);var v=P(w,"D"),k=P(this.$d.hours,"H"),Q=P(this.$d.minutes,"M"),z=this.$d.seconds||0;this.$d.milliseconds&&(z+=this.$d.milliseconds/1e3,z=Math.round(1e3*z)/1e3);var R=P(z,"S"),D=m.negative||S.negative||v.negative||k.negative||Q.negative||R.negative,Y=k.format||Q.format||R.format?"T":"",Z=(D?"-":"")+"P"+m.format+S.format+v.format+Y+k.format+Q.format+R.format;return Z==="P"||Z==="-P"?"P0D":Z},N.toJSON=function(){return this.toISOString()},N.format=function(m){var S=m||"YYYY-MM-DDTHH:mm:ss",w={Y:this.$d.years,YY:n.s(this.$d.years,2,"0"),YYYY:n.s(this.$d.years,4,"0"),M:this.$d.months,MM:n.s(this.$d.months,2,"0"),D:this.$d.days,DD:n.s(this.$d.days,2,"0"),H:this.$d.hours,HH:n.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:n.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:n.s(this.$d.seconds,2,"0"),SSS:n.s(this.$d.milliseconds,3,"0")};return S.replace(d,function(v,k){return k||String(w[v])})},N.as=function(m){return this.$ms/L[U(m)]},N.get=function(m){var S=this.$ms,w=U(m);return w==="milliseconds"?S%=1e3:S=w==="weeks"?O(S/L[w]):this.$d[w],S||0},N.add=function(m,S,w){var v;return v=S?m*L[U(S)]:x(m)?m.$ms:M(m,this).$ms,M(this.$ms+v*(w?-1:1),this)},N.subtract=function(m,S){return this.add(m,S,!0)},N.locale=function(m){var S=this.clone();return S.$l=m,S},N.clone=function(){return M(this.$ms,this)},N.humanize=function(m){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!m)},N.valueOf=function(){return this.asMilliseconds()},N.milliseconds=function(){return this.get("milliseconds")},N.asMilliseconds=function(){return this.as("milliseconds")},N.seconds=function(){return this.get("seconds")},N.asSeconds=function(){return this.as("seconds")},N.minutes=function(){return this.get("minutes")},N.asMinutes=function(){return this.as("minutes")},N.hours=function(){return this.get("hours")},N.asHours=function(){return this.as("hours")},N.days=function(){return this.get("days")},N.asDays=function(){return this.as("days")},N.weeks=function(){return this.get("weeks")},N.asWeeks=function(){return this.as("weeks")},N.months=function(){return this.get("months")},N.asMonths=function(){return this.as("months")},N.years=function(){return this.get("years")},N.asYears=function(){return this.as("years")},A}(),G=function(A,N,m){return A.add(N.years()*m,"y").add(N.months()*m,"M").add(N.days()*m,"d").add(N.hours()*m,"h").add(N.minutes()*m,"m").add(N.seconds()*m,"s").add(N.milliseconds()*m,"ms")};return function(A,N,m){e=m,n=m().$utils(),m.duration=function(v,k){var Q=m.locale();return M(v,{$l:Q},k)},m.isDuration=x;var S=N.prototype.add,w=N.prototype.subtract;N.prototype.add=function(v,k){return x(v)?G(this,v,1):S.bind(this)(v,k)},N.prototype.subtract=function(v,k){return x(v)?G(this,v,-1):w.bind(this)(v,k)}}})}(Pn)),Pn.exports}var Bp=Ip();const vp=Vs(Bp);mr.extend(vp);const xp=r=>{if(r instanceof Date)return mr(r).toISOString();if(r instanceof mr)return r.toISOString();if(r instanceof mr.duration)return r.toISOString();try{return mr.duration(r).toISOString()}catch{return mr(r).toISOString()}},Ap=r=>{const t=r.times.map(e=>xp(e));return{type:r.type||"range",times:t,resolution:r.resolution,resample:r.resample}};class Ep{datasource;parameters;description;variables;timefilter;geofilter;levelfilter;coordfilter;crs;aggregate;limit;id;constructor(t){this.datasource=t.datasource,this.parameters=t.parameters,this.description=t.description,this.variables=t.variables,this.timefilter=t.timefilter&&Ap(t.timefilter),this.geofilter=t.geofilter,this.levelfilter=t.levelfilter,this.coordfilter=t.coordfilter,this.crs=t.crs,this.aggregate=t.aggregate,this.limit=t.limit,this.id=t.id}toJSON(){return{datasource:this.datasource,parameters:this.parameters,description:this.description,variables:this.variables,timefilter:this.timefilter,geofilter:this.geofilter,levelfilter:this.levelfilter,coordfilter:this.coordfilter,crs:this.crs,aggregate:this.aggregate,limit:this.limit,id:this.id}}}exports.Connector=mp;exports.DataVar=wi;exports.Dataset=Ye;exports.Query=Ep;exports.cftimeToUnixSeconds=Du;exports.date2num=Qf;exports.getSupportedCalendars=tp;exports.hasCFTimeUnits=ku;exports.isCalendarSupported=Ou;exports.num2date=Xf;exports.parseCFUnits=Ni;exports.wkb_to_geojson=Uu;