@loaders.gl/pointclouds 5.0.0-beta.7 → 5.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +837 -71
- package/dist/dist.min.js +20 -20
- package/dist/las/las-loader-shared.cjs +1 -1
- package/dist/las/las-loader-shared.js +1 -1
- package/dist/las/las-writer.cjs +1 -1
- package/dist/las/las-writer.js +1 -1
- package/dist/las/lib/laz-perf/parse-las.cjs +8 -7
- package/dist/las/lib/laz-perf/parse-las.cjs.map +3 -3
- package/dist/las/lib/laz-perf/parse-las.js +8 -7
- package/dist/las/lib/laz-perf/parse-las.js.map +1 -1
- package/dist/las/lib/laz-rs-wasm/parse-las.cjs +8 -7
- package/dist/las/lib/laz-rs-wasm/parse-las.cjs.map +3 -3
- package/dist/las/lib/laz-rs-wasm/parse-las.js +8 -7
- package/dist/las/lib/laz-rs-wasm/parse-las.js.map +1 -1
- package/dist/las-worker.js +1 -1
- package/dist/las-writer.cjs +1 -1
- package/dist/pcd/pcd-loader-types.cjs +1 -1
- package/dist/pcd/pcd-loader-types.js +1 -1
- package/dist/pcd/pcd-writer.cjs +1 -1
- package/dist/pcd/pcd-writer.js +1 -1
- package/dist/pcd-loader-types.cjs +1 -1
- package/dist/pcd-worker.js +37 -1
- package/dist/pcd-writer.cjs +1 -1
- package/dist/ply/lib/parse-ply-in-batches.cjs +7 -6
- package/dist/ply/lib/parse-ply-in-batches.cjs.map +3 -3
- package/dist/ply/lib/parse-ply-in-batches.d.ts.map +1 -1
- package/dist/ply/lib/parse-ply-in-batches.js +2 -2
- package/dist/ply/lib/parse-ply-in-batches.js.map +1 -1
- package/dist/ply/ply-loader-types.cjs +1 -1
- package/dist/ply/ply-loader-types.js +1 -1
- package/dist/ply/ply-writer.cjs +1 -1
- package/dist/ply/ply-writer.js +1 -1
- package/dist/ply-loader-types.cjs +1 -1
- package/dist/ply-worker.js +790 -24
- package/dist/ply-writer.cjs +1 -1
- package/package.json +3 -3
- package/src/las/lib/laz-perf/parse-las.ts +7 -8
- package/src/las/lib/laz-rs-wasm/parse-las.ts +7 -8
- package/src/ply/lib/parse-ply-in-batches.ts +2 -2
package/dist/dist.min.js
CHANGED
|
@@ -4,45 +4,45 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['loaders'] = factory();
|
|
6
6
|
else root['loaders'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var Zu=Object.defineProperty;var L1=Object.getOwnPropertyDescriptor;var T1=Object.getOwnPropertyNames;var M1=Object.prototype.hasOwnProperty;var p=(r,t,e)=>()=>{if(e)throw e[0];try{return r&&(t=r(r=0)),t}catch(n){throw e=[n],n}};var Re=(r,t)=>{for(var e in t)Zu(r,e,{get:t[e],enumerable:!0})},D1=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of T1(t))!M1.call(r,s)&&s!==e&&Zu(r,s,{get:()=>t[s],enumerable:!(n=L1(t,s))||n.enumerable});return r};var C1=r=>D1(Zu({},"__esModule",{value:!0}),r);var F_,O_,E_,U_,om=p(()=>{F_=Math.PI/2,O_=Math.PI/4,E_=Math.PI/6,U_=Math.PI*2});var am=p(()=>{});var cm=p(()=>{});var lm=p(()=>{});var um=p(()=>{});var fm=p(()=>{});var hm=p(()=>{});function uc(){return no??Uint16Array}var no,dm=p(()=>{no=globalThis.Float16Array});var pm=p(()=>{dm()});var mm=p(()=>{pm()});var ym=p(()=>{lm()});var gm=p(()=>{um()});var bm=p(()=>{hm()});var wm=p(()=>{am()});var xm=p(()=>{cm()});var vm=p(()=>{fm()});var Am=p(()=>{om();mm();ym();gm();bm();wm();xm();vm()});function fc(r){let t=uc();return new t(r)}function jn(r){return!!(no&&r instanceof no)}function hc(r,t,e){jn(r)?r[t]=e:r[t]=Sm(e)}function Hu(r,t){return jn(r)?r[t]:V1(r[t])}function ra(r){return jn(r)?new Uint16Array(r.buffer,r.byteOffset,r.length):r}function ti(r,t){let e=fc(r.length);for(let n=0;n<r.length;n++)hc(e,n,r[n]/t);return e}function na(r,t){return Float32Array.from(r,e=>e/t)}function Sm(r){if(!Number.isFinite(r))return r===1/0?31744:r===-1/0?64512:32256;let t=r<0||Object.is(r,-0)?32768:0,e=Math.abs(r);if(e===0)return t;if(e>=65520)return t|31744;if(e>=65504)return t|31743;let n=Math.floor(Math.log2(e));if(n<-14)return t|Math.round(e/2**-24);let s=n+15,i=Math.round((e/2**n-1)*1024);return i===1024?t|s+1<<10:t|s<<10|i}function V1(r){let t=r&32768?-1:1,e=r>>10&31,n=r&1023;return e===0?t*n*2**-24:e===31?n?NaN:t*(1/0):t*(1+n/1024)*2**(e-15)}var Im=p(()=>{"use strict";Am()});function _m(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(e[n[s]]=r[n[s]]);return e}function B(r,t,e,n){function s(i){return i instanceof e?i:new e(function(o){o(i)})}return new(e||(e=Promise))(function(i,o){function a(u){try{l(n.next(u))}catch(f){o(f)}}function c(u){try{l(n.throw(u))}catch(f){o(f)}}function l(u){u.done?i(u.value):s(u.value).then(a,c)}l((n=n.apply(r,t||[])).next())})}function Bm(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 Y(r){return this instanceof Y?(this.v=r,this):new Y(r)}function xe(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),a("next"),a("throw"),a("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(m){return function(y){return Promise.resolve(y).then(m,f)}}function a(m,y){n[m]&&(s[m]=function(g){return new Promise(function(x,I){i.push([m,g,x,I])>1||c(m,g)})},y&&(s[m]=y(s[m])))}function c(m,y){try{l(n[m](y))}catch(g){h(i[0][3],g)}}function l(m){m.value instanceof Y?Promise.resolve(m.value.v).then(u,f):h(i[0][2],m)}function u(m){c("next",m)}function f(m){c("throw",m)}function h(m,y){m(y),i.shift(),i.length&&c(i[0][0],i[0][1])}}function so(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(o){return(e=!e)?{value:Y(r[s](o)),done:!1}:i?i(o):o}:i}}function He(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 Bm=="function"?Bm(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(o){return new Promise(function(a,c){o=r[i](o),s(a,c,o.done,o.value)})}}function s(i,o,a,c){Promise.resolve(c).then(function(l){i({value:l,done:a})},o)}}var Pe=p(()=>{});var Lm,io,G1,Xe,hn=p(()=>{Lm=new TextDecoder("utf-8"),io=Lm.decode.bind(Lm),G1=new TextEncoder,Xe=r=>G1.encode(r)});var j1,Tm,Vt,ve,Ke,Ir,lr,dc,pc,mc,yc,gc,Mm,sa,Dm,bc,Cm,qn=p(()=>{j1=r=>typeof r=="number",Tm=r=>typeof r=="boolean",Vt=r=>typeof r=="function",ve=r=>r!=null&&Object(r)===r,Ke=r=>ve(r)&&Vt(r.then),Ir=r=>ve(r)&&Vt(r[Symbol.iterator]),lr=r=>ve(r)&&Vt(r[Symbol.asyncIterator]),dc=r=>ve(r)&&ve(r.schema),pc=r=>ve(r)&&"done"in r&&"value"in r,mc=r=>ve(r)&&Vt(r.stat)&&j1(r.fd),yc=r=>ve(r)&&sa(r.body),gc=r=>"_getDOMStream"in r&&"_getNodeStream"in r,Mm=r=>ve(r)&&Vt(r.abort)&&Vt(r.getWriter)&&!gc(r),sa=r=>ve(r)&&Vt(r.cancel)&&Vt(r.getReader)&&!gc(r),Dm=r=>ve(r)&&Vt(r.end)&&Vt(r.write)&&Tm(r.writable)&&!gc(r),bc=r=>ve(r)&&Vt(r.read)&&Vt(r.pipe)&&Tm(r.readable)&&!gc(r),Cm=r=>ve(r)&&Vt(r.clear)&&Vt(r.bytes)&&Vt(r.position)&&Vt(r.setPosition)&&Vt(r.capacity)&&Vt(r.getBufferIdentifier)&&Vt(r.createLong)});var ef={};Re(ef,{compareArrayLike:()=>tf,joinUint8Arrays:()=>Je,memcpy:()=>ia,rebaseValueOffsets:()=>wc,toArrayBufferView:()=>K,toArrayBufferViewAsyncIterator:()=>Br,toArrayBufferViewIterator:()=>Wr,toBigInt64Array:()=>oa,toBigUint64Array:()=>H1,toFloat32Array:()=>X1,toFloat32ArrayAsyncIterator:()=>hx,toFloat32ArrayIterator:()=>sx,toFloat64Array:()=>K1,toFloat64ArrayAsyncIterator:()=>dx,toFloat64ArrayIterator:()=>ix,toInt16Array:()=>W1,toInt16ArrayAsyncIterator:()=>cx,toInt16ArrayIterator:()=>tx,toInt32Array:()=>ei,toInt32ArrayAsyncIterator:()=>lx,toInt32ArrayIterator:()=>ex,toInt8Array:()=>$1,toInt8ArrayAsyncIterator:()=>ax,toInt8ArrayIterator:()=>Q1,toUint16Array:()=>Y1,toUint16ArrayAsyncIterator:()=>ux,toUint16ArrayIterator:()=>rx,toUint32Array:()=>Z1,toUint32ArrayAsyncIterator:()=>fx,toUint32ArrayIterator:()=>nx,toUint8Array:()=>O,toUint8ArrayAsyncIterator:()=>Qu,toUint8ArrayIterator:()=>Ju,toUint8ClampedArray:()=>J1,toUint8ClampedArrayAsyncIterator:()=>px,toUint8ClampedArrayIterator:()=>ox});function q1(r){let t=r[0]?[r[0]]:[],e,n,s,i;for(let o,a,c=0,l=0,u=r.length;++c<u;){if(o=t[l],a=r[c],!o||!a||o.buffer!==a.buffer||a.byteOffset<o.byteOffset){a&&(t[++l]=a);continue}if({byteOffset:e,byteLength:s}=o,{byteOffset:n,byteLength:i}=a,e+s<n||n+i<e){a&&(t[++l]=a);continue}t[l]=new Uint8Array(o.buffer,e,n-e+i)}return t}function ia(r,t,e=0,n=t.byteLength){let s=r.byteLength,i=new Uint8Array(r.buffer,r.byteOffset,s),o=new Uint8Array(t.buffer,t.byteOffset,Math.min(n,s));return i.set(o,e),r}function Je(r,t){let e=q1(r),n=e.reduce((u,f)=>u+f.byteLength,0),s,i,o,a=0,c=-1,l=Math.min(t||Number.POSITIVE_INFINITY,n);for(let u=e.length;++c<u;){if(s=e[c],i=s.subarray(0,Math.min(s.length,l-a)),l<=a+i.length){i.length<s.length?e[c]=s.subarray(i.length):i.length===s.length&&c++,o?ia(o,i,a):o=i;break}ia(o||(o=new Uint8Array(l)),i,a),a+=i.length}return[o||new Uint8Array(0),e.slice(c),n-(o?o.byteLength:0)]}function K(r,t){let e=pc(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=Xe(e)),e instanceof ArrayBuffer?new r(e):e instanceof Ku?new r(e):Cm(e)?K(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)}function*Wr(r,t){let e=function*(s){yield s},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Ku?e(t):Ir(t)?t:e(t);return yield*Xu((function*(s){let i=null;do i=s.next(yield K(r,i));while(!i.done)})(n[Symbol.iterator]())),new r}function Br(r,t){return xe(this,arguments,function*(){if(Ke(t))return yield Y(yield Y(yield*so(He(Br(r,yield Y(t))))));let n=function(o){return xe(this,arguments,function*(){yield yield Y(yield Y(o))})},s=function(o){return xe(this,arguments,function*(){yield Y(yield*so(He(Xu((function*(a){let c=null;do c=a.next(yield c?.value);while(!c.done)})(o[Symbol.iterator]())))))})},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Ku?n(t):Ir(t)?s(t):lr(t)?t:n(t);return yield Y(yield*so(He(Xu((function(o){return xe(this,arguments,function*(){let a=null;do a=yield Y(o.next(yield yield Y(K(r,a))));while(!a.done)})})(i[Symbol.asyncIterator]()))))),yield Y(new r)})}function wc(r,t,e){if(r!==0){e=e.slice(0,t);let n=typeof e[0]=="bigint"?BigInt(r):r;for(let s=-1,i=e.length;++s<i;)e[s]+=n}return e.subarray(0,t)}function tf(r,t){let e=0,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}var Ku,$1,W1,ei,oa,O,Y1,Z1,H1,X1,K1,J1,Xu,Q1,tx,ex,Ju,rx,nx,sx,ix,ox,ax,cx,lx,Qu,ux,fx,hx,dx,px,Gt=p(()=>{Pe();hn();qn();Ku=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;$1=r=>K(Int8Array,r),W1=r=>K(Int16Array,r),ei=r=>K(Int32Array,r),oa=r=>K(BigInt64Array,r),O=r=>K(Uint8Array,r),Y1=r=>K(Uint16Array,r),Z1=r=>K(Uint32Array,r),H1=r=>K(BigUint64Array,r),X1=r=>K(Float32Array,r),K1=r=>K(Float64Array,r),J1=r=>K(Uint8ClampedArray,r),Xu=r=>(r.next(),r);Q1=r=>Wr(Int8Array,r),tx=r=>Wr(Int16Array,r),ex=r=>Wr(Int32Array,r),Ju=r=>Wr(Uint8Array,r),rx=r=>Wr(Uint16Array,r),nx=r=>Wr(Uint32Array,r),sx=r=>Wr(Float32Array,r),ix=r=>Wr(Float64Array,r),ox=r=>Wr(Uint8ClampedArray,r);ax=r=>Br(Int8Array,r),cx=r=>Br(Int16Array,r),lx=r=>Br(Int32Array,r),Qu=r=>Br(Uint8Array,r),ux=r=>Br(Uint16Array,r),fx=r=>Br(Uint32Array,r),hx=r=>Br(Float32Array,r),dx=r=>Br(Float64Array,r),px=r=>Br(Uint8ClampedArray,r)});function*mx(r){let t,e=!1,n=[],s,i,o,a=0;function c(){return i==="peek"?Je(n,o)[0]:([s,n,a]=Je(n,o),s)}({cmd:i,size:o}=(yield null)||{cmd:"read",size:0});let l=Ju(r)[Symbol.iterator]();try{do if({done:t,value:s}=Number.isNaN(o-a)?l.next():l.next(o-a),!t&&s.byteLength>0&&(n.push(s),a+=s.byteLength),t||o<=a)do({cmd:i,size:o}=yield c());while(o<a);while(!t)}catch(u){e=!0,typeof l.throw=="function"&&l.throw(u)}finally{e===!1&&typeof l.return=="function"&&l.return(null)}return null}function yx(r){return xe(this,arguments,function*(){let e,n=!1,s=[],i,o,a,c=0;function l(){return o==="peek"?Je(s,a)[0]:([i,s,c]=Je(s,a),i)}({cmd:o,size:a}=(yield yield Y(null))||{cmd:"read",size:0});let u=Qu(r)[Symbol.asyncIterator]();try{do if({done:e,value:i}=Number.isNaN(a-c)?yield Y(u.next()):yield Y(u.next(a-c)),!e&&i.byteLength>0&&(s.push(i),c+=i.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield Y(l()));while(a<c);while(!e)}catch(f){n=!0,typeof u.throw=="function"&&(yield Y(u.throw(f)))}finally{n===!1&&typeof u.return=="function"&&(yield Y(u.return(new Uint8Array(0))))}return yield Y(null)})}function gx(r){return xe(this,arguments,function*(){let e=!1,n=!1,s=[],i,o,a,c=0;function l(){return o==="peek"?Je(s,a)[0]:([i,s,c]=Je(s,a),i)}({cmd:o,size:a}=(yield yield Y(null))||{cmd:"read",size:0});let u=new nf(r);try{do if({done:e,value:i}=Number.isNaN(a-c)?yield Y(u.read()):yield Y(u.read(a-c)),!e&&i.byteLength>0&&(s.push(O(i)),c+=i.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield Y(l()));while(a<c);while(!e)}catch(f){n=!0,yield Y(u.cancel(f))}finally{n===!1?yield Y(u.cancel()):r.locked&&u.releaseLock()}return yield Y(null)})}function bx(r){return xe(this,arguments,function*(){let e=[],n="error",s=!1,i=null,o,a,c=0,l=[],u;function f(){return o==="peek"?Je(l,a)[0]:([u,l,c]=Je(l,a),u)}if({cmd:o,size:a}=(yield yield Y(null))||{cmd:"read",size:0},r.isTTY)return yield yield Y(new Uint8Array(0)),yield Y(null);try{e[0]=rf(r,"end"),e[1]=rf(r,"error");do{if(e[2]=rf(r,"readable"),[n,i]=yield Y(Promise.race(e.map(m=>m[2]))),n==="error")break;if((s=n==="end")||(Number.isFinite(a-c)?(u=O(r.read(a-c)),u.byteLength<a-c&&(u=O(r.read()))):u=O(r.read()),u.byteLength>0&&(l.push(u),c+=u.byteLength)),s||a<=c)do({cmd:o,size:a}=yield yield Y(f()));while(a<c)}while(!s)}finally{yield Y(h(e,n==="error"?i:null))}return yield Y(null);function h(m,y){return u=l=null,new Promise((g,x)=>{for(let[I,q]of m)r.off(I,q);try{let I=r.destroy;I&&I.call(r,y),y=void 0}catch(I){y=I||y}finally{y!=null?x(y):g()}})}})}var Yt,xc,nf,rf,aa=p(()=>{Pe();Gt();Yt={fromIterable(r){return xc(mx(r))},fromAsyncIterable(r){return xc(yx(r))},fromDOMStream(r){return xc(gx(r))},fromNodeStream(r){return xc(bx(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')}},xc=r=>(r.next(),r);nf=class{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return B(this,void 0,void 0,function*(){let{reader:e,source:n}=this;e&&(yield e.cancel(t).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(t){return B(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};let e=yield this.reader.read();return!e.done&&(e.value=O(e)),e})}},rf=(r,t)=>{let e=s=>n([t,s]),n;return[t,e,new Promise(s=>(n=s)&&r.once(t,e))]}});var ht,vc=p(()=>{(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"})(ht||(ht={}))});var lt,sf=p(()=>{(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(lt||(lt={}))});var ot,of=p(()=>{(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(ot||(ot={}))});var mt,af=p(()=>{(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(mt||(mt={}))});var v,ca=p(()=>{(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(v||(v={}))});var et,cf=p(()=>{(function(r){r[r.YEAR_MONTH=0]="YEAR_MONTH",r[r.DAY_TIME=1]="DAY_TIME",r[r.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(et||(et={}))});var Ac=p(()=>{});var Yr,Sc,Ic,oo,lf=p(()=>{Yr=new Int32Array(2),Sc=new Float32Array(Yr.buffer),Ic=new Float64Array(Yr.buffer),oo=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1});var la,uf=p(()=>{(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(la||(la={}))});var Zt,ff=p(()=>{Ac();uf();lf();Zt=class r{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new r(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return Yr[0]=this.readInt32(t),Sc[0]}readFloat64(t){return Yr[oo?0:1]=this.readInt32(t),Yr[oo?1:0]=this.readInt32(t+4),Ic[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){Sc[0]=e,this.writeInt32(t,Yr[0])}writeFloat64(t,e){Ic[0]=e,this.writeInt32(t,Yr[oo?0:1]),this.writeInt32(t+4,Yr[oo?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){let 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);let n=this.readInt32(t);t+=4;let s=this.bytes_.subarray(t,t+n);return e===la.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)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=4)throw new Error("FlatBuffers: file identifier must be length "+4);for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createScalarList(t,e){let n=[];for(let s=0;s<e;++s){let i=t(s);i!==null&&n.push(i)}return n}createObjList(t,e){let n=[];for(let s=0;s<e;++s){let i=t(s);i!==null&&n.push(i.unpack())}return n}}});var ri,Fm=p(()=>{ff();Ac();ri=class r{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let e;t?e=t:e=1024,this.bb=Zt.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);let n=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<n+t+e;){let s=this.bb.capacity();this.bb=r.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){let e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");let n=e<<1,s=Zt.allocate(n);return s.setPosition(n-e),s.bytes().set(t.bytes(),n-e),s}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);let t=this.offset(),e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);let n=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);let s=2;this.addInt16(t-this.object_start);let i=(n+s)*2;this.addInt16(i);let o=0,a=this.space;t:for(e=0;e<this.vtables.length;e++){let c=this.bb.capacity()-this.vtables[e];if(i==this.bb.readInt16(c)){for(let l=2;l<i;l+=2)if(this.bb.readInt16(a+l)!=this.bb.readInt16(c+l))continue t;o=this.vtables[e];break}}return o?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,o-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,n){let s=n?4:0;if(e){let i=e;if(this.prep(this.minalign,8+s),i.length!=4)throw new TypeError("FlatBuffers: file identifier must be length "+4);for(let o=3;o>=0;o--)this.writeInt8(i.charCodeAt(o))}this.prep(this.minalign,4+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){let 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(4,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);let e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(t==null)return 0;let e;return t instanceof Uint8Array?e=t:e=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){let e=[];for(let n=0;n<t.length;++n){let 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 nt=p(()=>{Ac();lf();Fm();ff();uf()});var ni,hf=p(()=>{(function(r){r[r.BUFFER=0]="BUFFER"})(ni||(ni={}))});var Ht,ao=p(()=>{(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(Ht||(Ht={}))});var dn,df=p(()=>{nt();hf();ao();dn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBodyCompression(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}codec(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):Ht.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):ni.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,Ht.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,ni.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return r.startBodyCompression(t),r.addCodec(t,e),r.addMethod(t,n),r.endBodyCompression(t)}}});var co,pf=p(()=>{co=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n??0)),t.writeInt64(BigInt(e??0)),t.offset()}}});var lo,mf=p(()=>{lo=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()}}});var ie,yf=p(()=>{nt();df();pf();mf();ie=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsRecordBatch(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}length(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new lo).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}nodesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new co).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}buffersLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){let e=this.bb.__offset(this.bb_pos,10);return e?(t||new dn).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}variadicBufferCounts(t){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+t*8):BigInt(0)}variadicBufferCountsLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startRecordBatch(t){t.startObject(5)}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 addVariadicBufferCounts(t,e){t.addFieldOffset(4,e,0)}static createVariadicBufferCountsVector(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 startVariadicBufferCountsVector(t,e){t.startVector(8,e,8)}static endRecordBatch(t){return t.endObject()}}});var pn,Om=p(()=>{nt();yf();pn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryBatch(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new ie).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isDelta(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}}});var $n,gf=p(()=>{(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})($n||($n={}))});var ua,Em=p(()=>{(function(r){r[r.DenseArray=0]="DenseArray"})(ua||(ua={}))});var Lr,_c=p(()=>{nt();Lr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInt(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,e){t.addFieldInt32(0,e,0)}static addIsSigned(t,e){t.addFieldInt8(1,+e,0)}static endInt(t){return t.endObject()}static createInt(t,e,n){return r.startInt(t),r.addBitWidth(t,e),r.addIsSigned(t,n),r.endInt(t)}}});var Zr,bf=p(()=>{nt();Em();_c();Zr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryEncoding(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new Lr).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isOrdered(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):ua.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,ua.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}}});var Tt,uo=p(()=>{nt();Tt=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsKeyValue(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}key(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}value(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,e){t.addFieldOffset(0,e,0)}static addValue(t,e){t.addFieldOffset(1,e,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,e,n){return r.startKeyValue(t),r.addKey(t,e),r.addValue(t,n),r.endKeyValue(t)}}});var fa,Um=p(()=>{nt();fa=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return r.startBinary(t),r.endBinary(t)}}});var ha,Nm=p(()=>{nt();ha=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBinaryView(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinaryView(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBinaryView(t){t.startObject(0)}static endBinaryView(t){return t.endObject()}static createBinaryView(t){return r.startBinaryView(t),r.endBinaryView(t)}}});var da,Rm=p(()=>{nt();da=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBool(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return r.startBool(t),r.endBool(t)}}});var Wn,wf=p(()=>{nt();af();Wn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDate(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):mt.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,mt.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return r.startDate(t),r.addUnit(t,e),r.endDate(t)}}});var Hr,xf=p(()=>{nt();Hr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDecimal(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,e){t.addFieldInt32(0,e,0)}static addScale(t,e){t.addFieldInt32(1,e,0)}static addBitWidth(t,e){t.addFieldInt32(2,e,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,e,n,s){return r.startDecimal(t),r.addPrecision(t,e),r.addScale(t,n),r.addBitWidth(t,s),r.endDecimal(t)}}});var Yn,vf=p(()=>{nt();ca();Yn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDuration(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):v.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,v.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,e){return r.startDuration(t),r.addUnit(t,e),r.endDuration(t)}}});var Zn,Af=p(()=>{nt();Zn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,e){return r.startFixedSizeBinary(t),r.addByteWidth(t,e),r.endFixedSizeBinary(t)}}});var Hn,Sf=p(()=>{nt();Hn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}listSize(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,e){return r.startFixedSizeList(t),r.addListSize(t,e),r.endFixedSizeList(t)}}});var Xn,If=p(()=>{nt();of();Xn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFloatingPoint(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):ot.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,ot.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return r.startFloatingPoint(t),r.addPrecision(t,e),r.endFloatingPoint(t)}}});var Kn,Bf=p(()=>{nt();cf();Kn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInterval(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):et.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,et.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return r.startInterval(t),r.addUnit(t,e),r.endInterval(t)}}});var pa,Pm=p(()=>{nt();pa=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return r.startLargeBinary(t),r.endLargeBinary(t)}}});var ma,km=p(()=>{nt();ma=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeList(t){t.startObject(0)}static endLargeList(t){return t.endObject()}static createLargeList(t){return r.startLargeList(t),r.endLargeList(t)}}});var ya,zm=p(()=>{nt();ya=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeUtf8(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return r.startLargeUtf8(t),r.endLargeUtf8(t)}}});var ga,Vm=p(()=>{nt();ga=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return r.startList(t),r.endList(t)}}});var Jn,_f=p(()=>{nt();Jn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMap(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){let t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,e){t.addFieldInt8(0,+e,0)}static endMap(t){return t.endObject()}static createMap(t,e){return r.startMap(t),r.addKeysSorted(t,e),r.endMap(t)}}});var ba,Gm=p(()=>{nt();ba=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNull(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return r.startNull(t),r.endNull(t)}}});var wa,jm=p(()=>{nt();wa=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsStruct_(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return r.startStruct_(t),r.endStruct_(t)}}});var mn,Lf=p(()=>{nt();ca();mn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTime(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):v.MILLISECOND}bitWidth(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,v.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,n){return r.startTime(t),r.addUnit(t,e),r.addBitWidth(t,n),r.endTime(t)}}});var yn,Tf=p(()=>{nt();ca();yn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTimestamp(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):v.SECOND}timezone(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,v.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,n){return r.startTimestamp(t),r.addUnit(t,e),r.addTimezone(t,n),r.endTimestamp(t)}}});var Tr,Mf=p(()=>{nt();sf();Tr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUnion(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}mode(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):lt.Sparse}typeIds(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+t*4):0}typeIdsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,e){t.addFieldInt16(0,e,lt.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 r.startUnion(t),r.addMode(t,e),r.addTypeIds(t,n),r.endUnion(t)}}});var xa,qm=p(()=>{nt();xa=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return r.startUtf8(t),r.endUtf8(t)}}});var va,$m=p(()=>{nt();va=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8View(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8View(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8View(t){t.startObject(0)}static endUtf8View(t){return t.endObject()}static createUtf8View(t){return r.startUtf8View(t),r.endUtf8View(t)}}});var k,Lc=p(()=>{(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",r[r.BinaryView=23]="BinaryView",r[r.Utf8View=24]="Utf8View",r[r.ListView=25]="ListView",r[r.LargeListView=26]="LargeListView"})(k||(k={}))});var oe,Df=p(()=>{nt();bf();uo();Lc();oe=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsField(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}nullable(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):k.NONE}type(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){let e=this.bb.__offset(this.bb_pos,12);return e?(t||new Zr).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){let n=this.bb.__offset(this.bb_pos,14);return n?(e||new r).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}childrenLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,16);return n?(e||new Tt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,e){t.addFieldOffset(0,e,0)}static addNullable(t,e){t.addFieldInt8(1,+e,0)}static addTypeType(t,e){t.addFieldInt8(2,e,k.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()}}});var ke,Cf=p(()=>{nt();gf();Df();uo();ke=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}endianness(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):$n.Little}fields(t,e){let 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(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new Tt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+t*8):BigInt(0)}featuresLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,e){t.addFieldInt16(0,e,$n.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 createSchema(t,e,n,s,i){return r.startSchema(t),r.addEndianness(t,e),r.addFields(t,n),r.addCustomMetadata(t,s),r.addFeatures(t,i),r.endSchema(t)}}});var Q,Tc=p(()=>{(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"})(Q||(Q={}))});var d,Z,Mt=p(()=>{vc();sf();of();af();ca();cf();Tc();(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.LargeList=21]="LargeList",r[r.BinaryView=23]="BinaryView",r[r.Utf8View=24]="Utf8View",r[r.Dictionary=-1]="Dictionary",r[r.Int8=-2]="Int8",r[r.Int16=-3]="Int16",r[r.Int32=-4]="Int32",r[r.Int64=-5]="Int64",r[r.Uint8=-6]="Uint8",r[r.Uint16=-7]="Uint16",r[r.Uint32=-8]="Uint32",r[r.Uint64=-9]="Uint64",r[r.Float16=-10]="Float16",r[r.Float32=-11]="Float32",r[r.Float64=-12]="Float64",r[r.DateDay=-13]="DateDay",r[r.DateMillisecond=-14]="DateMillisecond",r[r.TimestampSecond=-15]="TimestampSecond",r[r.TimestampMillisecond=-16]="TimestampMillisecond",r[r.TimestampMicrosecond=-17]="TimestampMicrosecond",r[r.TimestampNanosecond=-18]="TimestampNanosecond",r[r.TimeSecond=-19]="TimeSecond",r[r.TimeMillisecond=-20]="TimeMillisecond",r[r.TimeMicrosecond=-21]="TimeMicrosecond",r[r.TimeNanosecond=-22]="TimeNanosecond",r[r.DenseUnion=-23]="DenseUnion",r[r.SparseUnion=-24]="SparseUnion",r[r.IntervalDayTime=-25]="IntervalDayTime",r[r.IntervalYearMonth=-26]="IntervalYearMonth",r[r.DurationSecond=-27]="DurationSecond",r[r.DurationMillisecond=-28]="DurationMillisecond",r[r.DurationMicrosecond=-29]="DurationMicrosecond",r[r.DurationNanosecond=-30]="DurationNanosecond",r[r.IntervalMonthDayNano=-31]="IntervalMonthDayNano"})(d||(d={}));(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(Z||(Z={}))});var Ff={};Re(Ff,{valueToString:()=>Mr});function Mr(r){if(r===null)return"null";if(r===void 0)return"undefined";switch(typeof r){case"number":return`${r}`;case"bigint":return`${r}`;case"string":return`"${r}"`}return typeof r[Symbol.toPrimitive]=="function"?r[Symbol.toPrimitive]("string"):ArrayBuffer.isView(r)?r instanceof BigInt64Array||r instanceof BigUint64Array?`[${[...r].map(t=>Mr(t))}]`:`[${r}]`:ArrayBuffer.isView(r)?`[${r}]`:JSON.stringify(r,(t,e)=>typeof e=="bigint"?`${e}`:e)}var Aa=p(()=>{});function J(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 Of(r,t){return J(r/t)+J(r%t)/J(t)}var Xr=p(()=>{});var Nf={};Re(Nf,{BN:()=>si,bigNumToBigInt:()=>Ym,bigNumToNumber:()=>Uf,bigNumToString:()=>po,isArrowBigNumSymbol:()=>Wm});function Dr(r,...t){return t.length===0?Object.setPrototypeOf(K(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}function fo(...r){return Dr.apply(this,r)}function ho(...r){return Dr.apply(this,r)}function Sa(...r){return Dr.apply(this,r)}function Uf(r,t){let{buffer:e,byteOffset:n,byteLength:s,signed:i}=r,o=new BigUint64Array(e,n,s/8),a=i&&o.at(-1)&BigInt(1)<<BigInt(63),c=BigInt(0),l=0;if(a){for(let u of o)c|=(u^xx)*(BigInt(1)<<BigInt(64*l++));c*=BigInt(-1),c-=BigInt(1)}else for(let u of o)c|=u*(BigInt(1)<<BigInt(64*l++));if(typeof t=="number"&&t>0){let u=BigInt("1".padEnd(t+1,"0")),f=c/u,h=a?-(c%u):c%u,m=J(f),y=`${h}`.padStart(t,"0");return+`${a&&m===0?"-":""}${m}.${y}`}return J(c)}function po(r){if(r.byteLength===8)return`${new r.BigIntArray(r.buffer,r.byteOffset,1)[0]}`;if(!r.signed)return Ef(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Ef(r);t=t.slice();let n=1;for(let i=0;i<t.length;i++){let o=t[i],a=~o+n;t[i]=a,n&=o===0?1:0}return`-${Ef(t)}`}function Ym(r){return r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:po(r)}function Ef(r){let t="",e=new Uint32Array(2),n=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),s=new Uint32Array((n=new Uint16Array(n).reverse()).buffer),i=-1,o=n.length-1;do{for(e[0]=n[i=0];i<o;)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"}var Wm,wx,xx,si,Mc=p(()=>{Gt();Xr();Wm=Symbol.for("isArrowBigNum");Dr.prototype[Wm]=!0;Dr.prototype.toJSON=function(){return`"${po(this)}"`};Dr.prototype.valueOf=function(r){return Uf(this,r)};Dr.prototype.toString=function(){return po(this)};Dr.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return Uf(this);case"string":return po(this);case"default":return Ym(this)}return po(this)};Object.setPrototypeOf(fo.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(ho.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Sa.prototype,Object.create(Uint32Array.prototype));Object.assign(fo.prototype,Dr.prototype,{constructor:fo,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(ho.prototype,Dr.prototype,{constructor:ho,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Sa.prototype,Dr.prototype,{constructor:Sa,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});wx=BigInt(4294967296)*BigInt(4294967296),xx=wx-BigInt(1);si=class r{static new(t,e){switch(e){case!0:return new fo(t);case!1:return new ho(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new fo(t)}return t.byteLength===16?new Sa(t):new ho(t)}static signed(t){return new fo(t)}static unsigned(t){return new ho(t)}static decimal(t){return new Sa(t)}constructor(t,e){return r.new(t,e)}}});function er(r){let t=r;switch(r.typeId){case d.Decimal:return r.bitWidth/32;case d.Interval:return t.unit===et.MONTH_DAY_NANO?4:1+t.unit;case d.BinaryView:case d.Utf8View:return 16;case d.FixedSizeList:return t.listSize;case d.FixedSizeBinary:return t.byteWidth;default:return 1}}var Zm,Hm,Xm,Km,Jm,Qm,ty,ey,ry,ny,sy,iy,oy,ay,cy,ly,uy,fy,hy,dy,py,my,yy,gy,by,wy,w,Et,Lt,Ae,Se,Dt,Qe,Ie,Be,qt,Cr,ae,Fr,Xt,_e,ze,H,Or,ce,Le,Er,le,Ve,Te,Qn,ts,Kt,es,rs,ns,ss,Jt,is,Kr,os,as,ue,cs,ls,Ia,Me,Ba,_a,La,Ta,Ct,tr,ut,De,gn,us,Ge,gt,fe,vx,Rt,yt=p(()=>{Xr();Mt();wy=Symbol.for("apache-arrow/DataType"),w=class r{static isDataType(t){return t?.[wy]===!0}static isNull(t){return t?.typeId===d.Null}static isInt(t){return t?.typeId===d.Int}static isFloat(t){return t?.typeId===d.Float}static isBinary(t){return t?.typeId===d.Binary}static isBinaryView(t){return t?.typeId===d.BinaryView}static isLargeBinary(t){return t?.typeId===d.LargeBinary}static isUtf8(t){return t?.typeId===d.Utf8}static isUtf8View(t){return t?.typeId===d.Utf8View}static isLargeUtf8(t){return t?.typeId===d.LargeUtf8}static isBool(t){return t?.typeId===d.Bool}static isDecimal(t){return t?.typeId===d.Decimal}static isDate(t){return t?.typeId===d.Date}static isTime(t){return t?.typeId===d.Time}static isTimestamp(t){return t?.typeId===d.Timestamp}static isInterval(t){return t?.typeId===d.Interval}static isDuration(t){return t?.typeId===d.Duration}static isList(t){return t?.typeId===d.List}static isLargeList(t){return t?.typeId===d.LargeList}static isStruct(t){return t?.typeId===d.Struct}static isUnion(t){return t?.typeId===d.Union}static isFixedSizeBinary(t){return t?.typeId===d.FixedSizeBinary}static isFixedSizeList(t){return t?.typeId===d.FixedSizeList}static isMap(t){return t?.typeId===d.Map}static isDictionary(t){return t?.typeId===d.Dictionary}static isDenseUnion(t){return r.isUnion(t)&&t.mode===lt.Dense}static isSparseUnion(t){return r.isUnion(t)&&t.mode===lt.Sparse}constructor(t){this.typeId=t}};Zm=Symbol.toStringTag;w[Zm]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[wy]=!0,r[Symbol.toStringTag]="DataType"))(w.prototype);Et=class extends w{constructor(){super(d.Null)}toString(){return"Null"}};Hm=Symbol.toStringTag;Et[Hm]=(r=>r[Symbol.toStringTag]="Null")(Et.prototype);Lt=class extends w{constructor(t,e){super(d.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}`}};Xm=Symbol.toStringTag;Lt[Xm]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(Lt.prototype);Ae=class extends Lt{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},Se=class extends Lt{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},Dt=class extends Lt{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Qe=class extends Lt{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},Ie=class extends Lt{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},Be=class extends Lt{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},qt=class extends Lt{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},Cr=class extends Lt{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(Ae.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(Se.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(Dt.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(Qe.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(Ie.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(Be.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(qt.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(Cr.prototype,"ArrayType",{value:BigUint64Array});ae=class extends w{constructor(t){super(d.Float),this.precision=t}get ArrayType(){switch(this.precision){case ot.HALF:return Uint16Array;case ot.SINGLE:return Float32Array;case ot.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};Km=Symbol.toStringTag;ae[Km]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(ae.prototype);Fr=class extends ae{constructor(){super(ot.HALF)}},Xt=class extends ae{constructor(){super(ot.SINGLE)}},_e=class extends ae{constructor(){super(ot.DOUBLE)}};Object.defineProperty(Fr.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Xt.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(_e.prototype,"ArrayType",{value:Float64Array});ze=class extends w{constructor(){super(d.Binary)}toString(){return"Binary"}};Jm=Symbol.toStringTag;ze[Jm]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(ze.prototype);H=class extends w{constructor(){super(d.BinaryView)}toString(){return"BinaryView"}};Qm=Symbol.toStringTag;H.ELEMENT_WIDTH=16;H.INLINE_CAPACITY=12;H.LENGTH_OFFSET=0;H.INLINE_OFFSET=4;H.BUFFER_INDEX_OFFSET=8;H.BUFFER_OFFSET_OFFSET=12;H[Qm]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="BinaryView"))(H.prototype);Or=class extends w{constructor(){super(d.LargeBinary)}toString(){return"LargeBinary"}};ty=Symbol.toStringTag;Or[ty]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(Or.prototype);ce=class extends w{constructor(){super(d.Utf8)}toString(){return"Utf8"}};ey=Symbol.toStringTag;ce[ey]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(ce.prototype);Le=class extends w{constructor(){super(d.Utf8View)}toString(){return"Utf8View"}};ry=Symbol.toStringTag;Le.ELEMENT_WIDTH=H.ELEMENT_WIDTH;Le.INLINE_CAPACITY=H.INLINE_CAPACITY;Le[ry]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8View"))(Le.prototype);Er=class extends w{constructor(){super(d.LargeUtf8)}toString(){return"LargeUtf8"}};ny=Symbol.toStringTag;Er[ny]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(Er.prototype);le=class extends w{constructor(){super(d.Bool)}toString(){return"Bool"}};sy=Symbol.toStringTag;le[sy]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(le.prototype);Ve=class extends w{constructor(t,e,n=128){super(d.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};iy=Symbol.toStringTag;Ve[iy]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(Ve.prototype);Te=class extends w{constructor(t){super(d.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${mt[this.unit]}>`}get ArrayType(){return this.unit===mt.DAY?Int32Array:BigInt64Array}};oy=Symbol.toStringTag;Te[oy]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(Te.prototype);Qn=class extends Te{constructor(){super(mt.DAY)}},ts=class extends Te{constructor(){super(mt.MILLISECOND)}},Kt=class extends w{constructor(t,e){super(d.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${v[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};ay=Symbol.toStringTag;Kt[ay]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(Kt.prototype);es=class extends Kt{constructor(){super(v.SECOND,32)}},rs=class extends Kt{constructor(){super(v.MILLISECOND,32)}},ns=class extends Kt{constructor(){super(v.MICROSECOND,64)}},ss=class extends Kt{constructor(){super(v.NANOSECOND,64)}},Jt=class extends w{constructor(t,e){super(d.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${v[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};cy=Symbol.toStringTag;Jt[cy]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(Jt.prototype);is=class extends Jt{constructor(t){super(v.SECOND,t)}},Kr=class extends Jt{constructor(t){super(v.MILLISECOND,t)}},os=class extends Jt{constructor(t){super(v.MICROSECOND,t)}},as=class extends Jt{constructor(t){super(v.NANOSECOND,t)}},ue=class extends w{constructor(t){super(d.Interval),this.unit=t}toString(){return`Interval<${et[this.unit]}>`}};ly=Symbol.toStringTag;ue[ly]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(ue.prototype);cs=class extends ue{constructor(){super(et.DAY_TIME)}},ls=class extends ue{constructor(){super(et.YEAR_MONTH)}},Ia=class extends ue{constructor(){super(et.MONTH_DAY_NANO)}},Me=class extends w{constructor(t){super(d.Duration),this.unit=t}toString(){return`Duration<${v[this.unit]}>`}};uy=Symbol.toStringTag;Me[uy]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(Me.prototype);Ba=class extends Me{constructor(){super(v.SECOND)}},_a=class extends Me{constructor(){super(v.MILLISECOND)}},La=class extends Me{constructor(){super(v.MICROSECOND)}},Ta=class extends Me{constructor(){super(v.NANOSECOND)}},Ct=class extends w{constructor(t){super(d.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}};fy=Symbol.toStringTag;Ct[fy]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(Ct.prototype);tr=class extends w{constructor(t){super(d.LargeList),this.children=[t]}toString(){return`LargeList<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};hy=Symbol.toStringTag;tr[hy]=(r=>(r.children=null,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeList"))(tr.prototype);ut=class extends w{constructor(t){super(d.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};dy=Symbol.toStringTag;ut[dy]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(ut.prototype);De=class extends w{constructor(t,e,n){super(d.Union),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((s,i,o)=>(s[i]=o)&&s||s,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}};py=Symbol.toStringTag;De[py]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(De.prototype);gn=class extends De{constructor(t,e){super(lt.Dense,t,e)}},us=class extends De{constructor(t,e){super(lt.Sparse,t,e)}},Ge=class extends w{constructor(t){super(d.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};my=Symbol.toStringTag;Ge[my]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(Ge.prototype);gt=class extends w{constructor(t,e){super(d.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}>`}};yy=Symbol.toStringTag;gt[yy]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(gt.prototype);fe=class extends w{constructor(t,e=!1){var n,s,i;if(super(d.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((n=t?.type)===null||n===void 0)&&n.children)){let o=(s=t?.type)===null||s===void 0?void 0:s.children[0];o&&(o.name="key");let a=(i=t?.type)===null||i===void 0?void 0:i.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};gy=Symbol.toStringTag;fe[gy]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(fe.prototype);vx=(r=>()=>++r)(-1),Rt=class extends w{constructor(t,e,n,s){super(d.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=s||!1,this.id=n==null?vx():J(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}>`}};by=Symbol.toStringTag;Rt[by]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(Rt.prototype)});function Ax(r,t,e=!0){return typeof t=="number"?mo(r,t,e):typeof t=="string"&&t in d?mo(r,d[t],e):t&&t instanceof w?mo(r,vy(t),e):t?.type&&t.type instanceof w?mo(r,vy(t.type),e):mo(r,d.NONE,e)}function mo(r,t,e=!0){let n=null;switch(t){case d.Null:n=r.visitNull;break;case d.Bool:n=r.visitBool;break;case d.Int:n=r.visitInt;break;case d.Int8:n=r.visitInt8||r.visitInt;break;case d.Int16:n=r.visitInt16||r.visitInt;break;case d.Int32:n=r.visitInt32||r.visitInt;break;case d.Int64:n=r.visitInt64||r.visitInt;break;case d.Uint8:n=r.visitUint8||r.visitInt;break;case d.Uint16:n=r.visitUint16||r.visitInt;break;case d.Uint32:n=r.visitUint32||r.visitInt;break;case d.Uint64:n=r.visitUint64||r.visitInt;break;case d.Float:n=r.visitFloat;break;case d.Float16:n=r.visitFloat16||r.visitFloat;break;case d.Float32:n=r.visitFloat32||r.visitFloat;break;case d.Float64:n=r.visitFloat64||r.visitFloat;break;case d.Utf8:n=r.visitUtf8;break;case d.LargeUtf8:n=r.visitLargeUtf8;break;case d.Utf8View:n=r.visitUtf8View||r.visitUtf8;break;case d.Binary:n=r.visitBinary;break;case d.LargeBinary:n=r.visitLargeBinary;break;case d.BinaryView:n=r.visitBinaryView||r.visitBinary;break;case d.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case d.Date:n=r.visitDate;break;case d.DateDay:n=r.visitDateDay||r.visitDate;break;case d.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case d.Timestamp:n=r.visitTimestamp;break;case d.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case d.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case d.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case d.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case d.Time:n=r.visitTime;break;case d.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case d.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case d.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case d.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case d.Decimal:n=r.visitDecimal;break;case d.List:n=r.visitList;break;case d.LargeList:n=r.visitLargeList;break;case d.Struct:n=r.visitStruct;break;case d.Union:n=r.visitUnion;break;case d.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case d.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case d.Dictionary:n=r.visitDictionary;break;case d.Interval:n=r.visitInterval;break;case d.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case d.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case d.IntervalMonthDayNano:n=r.visitIntervalMonthDayNano||r.visitInterval;break;case d.Duration:n=r.visitDuration;break;case d.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case d.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case d.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case d.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case d.FixedSizeList:n=r.visitFixedSizeList;break;case d.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error(`Unrecognized type '${d[t]}'`)}function vy(r){switch(r.typeId){case d.Null:return d.Null;case d.Int:{let{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?d.Int8:d.Uint8;case 16:return e?d.Int16:d.Uint16;case 32:return e?d.Int32:d.Uint32;case 64:return e?d.Int64:d.Uint64}return d.Int}case d.Float:switch(r.precision){case ot.HALF:return d.Float16;case ot.SINGLE:return d.Float32;case ot.DOUBLE:return d.Float64}return d.Float;case d.Binary:return d.Binary;case d.LargeBinary:return d.LargeBinary;case d.BinaryView:return d.BinaryView;case d.Utf8:return d.Utf8;case d.LargeUtf8:return d.LargeUtf8;case d.Utf8View:return d.Utf8View;case d.Bool:return d.Bool;case d.Decimal:return d.Decimal;case d.Time:switch(r.unit){case v.SECOND:return d.TimeSecond;case v.MILLISECOND:return d.TimeMillisecond;case v.MICROSECOND:return d.TimeMicrosecond;case v.NANOSECOND:return d.TimeNanosecond}return d.Time;case d.Timestamp:switch(r.unit){case v.SECOND:return d.TimestampSecond;case v.MILLISECOND:return d.TimestampMillisecond;case v.MICROSECOND:return d.TimestampMicrosecond;case v.NANOSECOND:return d.TimestampNanosecond}return d.Timestamp;case d.Date:switch(r.unit){case mt.DAY:return d.DateDay;case mt.MILLISECOND:return d.DateMillisecond}return d.Date;case d.Interval:switch(r.unit){case et.DAY_TIME:return d.IntervalDayTime;case et.YEAR_MONTH:return d.IntervalYearMonth;case et.MONTH_DAY_NANO:return d.IntervalMonthDayNano}return d.Interval;case d.Duration:switch(r.unit){case v.SECOND:return d.DurationSecond;case v.MILLISECOND:return d.DurationMillisecond;case v.MICROSECOND:return d.DurationMicrosecond;case v.NANOSECOND:return d.DurationNanosecond}return d.Duration;case d.Map:return d.Map;case d.List:return d.List;case d.LargeList:return d.LargeList;case d.Struct:return d.Struct;case d.Union:switch(r.mode){case lt.Dense:return d.DenseUnion;case lt.Sparse:return d.SparseUnion}return d.Union;case d.FixedSizeBinary:return d.FixedSizeBinary;case d.FixedSizeList:return d.FixedSizeList;case d.Dictionary:return d.Dictionary}throw new Error(`Unrecognized type '${d[r.typeId]}'`)}var F,je=p(()=>{Mt();yt();F=class{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 Ax(this,t,e)}getVisitFnByTypeId(t,e=!0){return mo(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}visitUtf8View(t,...e){return null}visitBinary(t,...e){return null}visitLargeBinary(t,...e){return null}visitBinaryView(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}visitLargeList(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}};F.prototype.visitInt8=null;F.prototype.visitInt16=null;F.prototype.visitInt32=null;F.prototype.visitInt64=null;F.prototype.visitUint8=null;F.prototype.visitUint16=null;F.prototype.visitUint32=null;F.prototype.visitUint64=null;F.prototype.visitFloat16=null;F.prototype.visitFloat32=null;F.prototype.visitFloat64=null;F.prototype.visitDateDay=null;F.prototype.visitDateMillisecond=null;F.prototype.visitTimestampSecond=null;F.prototype.visitTimestampMillisecond=null;F.prototype.visitTimestampMicrosecond=null;F.prototype.visitTimestampNanosecond=null;F.prototype.visitTimeSecond=null;F.prototype.visitTimeMillisecond=null;F.prototype.visitTimeMicrosecond=null;F.prototype.visitTimeNanosecond=null;F.prototype.visitDenseUnion=null;F.prototype.visitSparseUnion=null;F.prototype.visitIntervalDayTime=null;F.prototype.visitIntervalYearMonth=null;F.prototype.visitIntervalMonthDayNano=null;F.prototype.visitDuration=null;F.prototype.visitDurationSecond=null;F.prototype.visitDurationMillisecond=null;F.prototype.visitDurationMicrosecond=null;F.prototype.visitDurationNanosecond=null});var Rf={};Re(Rf,{float64ToUint16:()=>Ma,uint16ToFloat64:()=>Dc});function Dc(r){let 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 Ma(r){if(r!==r)return 32256;Ay[0]=r;let t=(yo[1]&2147483648)>>16&65535,e=yo[1]&2146435072,n=0;return e>=1089470464?yo[0]>0?e=31744:(e=(e&2080374784)>>16,n=(yo[1]&1048575)>>10):e<=1056964608?(n=1048576+(yo[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(yo[1]&1048575)+512>>10),t|e|n&65535}var Ay,yo,Da=p(()=>{Ay=new Float64Array(1),yo=new Uint32Array(Ay.buffer)});function j(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}var P,Sx,Sy,Ix,bn,Pf,Iy,Bx,Cc,Fc,kf,By,_x,_y,Lx,Ly,Tx,zf,Oc,Ec,Uc,Nc,Vf,Rc,Pc,kc,zc,Gf,jf,Ty,Mx,Dx,Cx,Fx,Ox,Ex,Ux,My,Dy,Nx,qf,Vc,Gc,jc,qc,$c,Wc,Yc,$f,Rx,Qt,rr=p(()=>{he();je();Xr();hn();Da();Mt();yt();P=class extends F{};Sx=(r,t,e)=>{r[t]=Math.floor(e/864e5)},Sy=(r,t,e,n)=>{if(e+1<t.length){let s=J(t[e]),i=J(t[e+1]);r.set(n.subarray(0,i-s),s)}},Ix=({offset:r,values:t},e,n)=>{let s=r+e;n?t[s>>3]|=1<<s%8:t[s>>3]&=~(1<<s%8)},bn=({values:r},t,e)=>{r[t]=e},Pf=({values:r},t,e)=>{r[t]=e},Iy=({values:r},t,e)=>{r[t]=Ma(e)},Bx=(r,t,e)=>{switch(r.type.precision){case ot.HALF:return Iy(r,t,e);case ot.SINGLE:case ot.DOUBLE:return Pf(r,t,e)}},Cc=({values:r},t,e)=>{Sx(r,t,e.valueOf())},Fc=({values:r},t,e)=>{r[t]=BigInt(e)},kf=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},By=({values:r,valueOffsets:t},e,n)=>Sy(r,t,e,n),_x=r=>{let t=r.variadicBuffers;return(!Array.isArray(t)||Object.isFrozen(t))&&(t=Array.from(t),r.variadicBuffers=t),t},_y=(r,t,e)=>{var n,s,i,o;let a=r.values;if(!a)throw new Error("BinaryView data is missing view buffer");let c=H.ELEMENT_WIDTH,l=t*c,u=l+c;if(l<0||u>a.length)throw new RangeError(`BinaryView index ${t} out of bounds`);a.fill(0,l,u);let f=new DataView(a.buffer,a.byteOffset+l,c),h=e.length;if(f.setInt32(H.LENGTH_OFFSET,h,!0),h<=H.INLINE_CAPACITY){a.set(e,l+H.INLINE_OFFSET);return}let m=((n=e[0])!==null&&n!==void 0?n:0)|((s=e[1])!==null&&s!==void 0?s:0)<<8|((i=e[2])!==null&&i!==void 0?i:0)<<16|((o=e[3])!==null&&o!==void 0?o:0)<<24;f.setUint32(H.INLINE_OFFSET,m>>>0,!0);let y=_x(r),g=e.slice(),x=y.push(g)-1;f.setInt32(H.BUFFER_INDEX_OFFSET,x,!0),f.setInt32(H.BUFFER_OFFSET_OFFSET,0,!0)},Lx=(r,t,e)=>{let n=e instanceof Uint8Array?e:new Uint8Array(e);_y(r,t,n)},Ly=({values:r,valueOffsets:t},e,n)=>Sy(r,t,e,Xe(n)),Tx=(r,t,e)=>{let n=Xe(e);_y(r,t,n)},zf=(r,t,e)=>{r.type.unit===mt.DAY?Cc(r,t,e):Fc(r,t,e)},Oc=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},Ec=({values:r},t,e)=>{r[t]=BigInt(e)},Uc=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},Nc=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},Vf=(r,t,e)=>{switch(r.type.unit){case v.SECOND:return Oc(r,t,e);case v.MILLISECOND:return Ec(r,t,e);case v.MICROSECOND:return Uc(r,t,e);case v.NANOSECOND:return Nc(r,t,e)}},Rc=({values:r},t,e)=>{r[t]=e},Pc=({values:r},t,e)=>{r[t]=e},kc=({values:r},t,e)=>{r[t]=e},zc=({values:r},t,e)=>{r[t]=e},Gf=(r,t,e)=>{switch(r.type.unit){case v.SECOND:return Rc(r,t,e);case v.MILLISECOND:return Pc(r,t,e);case v.MICROSECOND:return kc(r,t,e);case v.NANOSECOND:return zc(r,t,e)}},jf=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},Ty=(r,t,e)=>{let n=r.children[0],s=r.valueOffsets,i=Qt.getVisitFn(n),o=J(s[t]),a=J(s[t+1]);if(Array.isArray(e))for(let c=-1,l=o;l<a;)i(n,l++,e[++c]);else for(let c=-1,l=o;l<a;)i(n,l++,e.get(++c))},Mx=(r,t,e)=>{let n=r.children[0],{valueOffsets:s}=r,i=Qt.getVisitFn(n),{[t]:o,[t+1]:a}=s,c=e instanceof Map?e.entries():Object.entries(e);for(let l of c)if(i(n,o,l),++o>=a)break},Dx=(r,t)=>(e,n,s,i)=>n&&e(n,r,t[i]),Cx=(r,t)=>(e,n,s,i)=>n&&e(n,r,t.get(i)),Fx=(r,t)=>(e,n,s,i)=>n&&e(n,r,t.get(s.name)),Ox=(r,t)=>(e,n,s,i)=>n&&e(n,r,t[s.name]),Ex=(r,t,e)=>{let n=r.type.children.map(i=>Qt.getVisitFn(i.type)),s=e instanceof Map?Fx(t,e):e instanceof A?Cx(t,e):Array.isArray(e)?Dx(t,e):Ox(t,e);r.type.children.forEach((i,o)=>s(n[o],r.children[o],i,o))},Ux=(r,t,e)=>{r.type.mode===lt.Dense?My(r,t,e):Dy(r,t,e)},My=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],s=r.children[n];Qt.visit(s,r.valueOffsets[t],e)},Dy=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],s=r.children[n];Qt.visit(s,t,e)},Nx=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},qf=(r,t,e)=>{switch(r.type.unit){case et.YEAR_MONTH:return Gc(r,t,e);case et.DAY_TIME:return Vc(r,t,e);case et.MONTH_DAY_NANO:return jc(r,t,e)}},Vc=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},Gc=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},jc=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},qc=({values:r},t,e)=>{r[t]=e},$c=({values:r},t,e)=>{r[t]=e},Wc=({values:r},t,e)=>{r[t]=e},Yc=({values:r},t,e)=>{r[t]=e},$f=(r,t,e)=>{switch(r.type.unit){case v.SECOND:return qc(r,t,e);case v.MILLISECOND:return $c(r,t,e);case v.MICROSECOND:return Wc(r,t,e);case v.NANOSECOND:return Yc(r,t,e)}},Rx=(r,t,e)=>{let{stride:n}=r,s=r.children[0],i=Qt.getVisitFn(s);if(Array.isArray(e))for(let o=-1,a=t*n;++o<n;)i(s,a+o,e[o]);else for(let o=-1,a=t*n;++o<n;)i(s,a+o,e.get(o))};P.prototype.visitBool=j(Ix);P.prototype.visitInt=j(bn);P.prototype.visitInt8=j(bn);P.prototype.visitInt16=j(bn);P.prototype.visitInt32=j(bn);P.prototype.visitInt64=j(bn);P.prototype.visitUint8=j(bn);P.prototype.visitUint16=j(bn);P.prototype.visitUint32=j(bn);P.prototype.visitUint64=j(bn);P.prototype.visitFloat=j(Bx);P.prototype.visitFloat16=j(Iy);P.prototype.visitFloat32=j(Pf);P.prototype.visitFloat64=j(Pf);P.prototype.visitUtf8=j(Ly);P.prototype.visitLargeUtf8=j(Ly);P.prototype.visitUtf8View=j(Tx);P.prototype.visitBinary=j(By);P.prototype.visitLargeBinary=j(By);P.prototype.visitBinaryView=j(Lx);P.prototype.visitFixedSizeBinary=j(kf);P.prototype.visitDate=j(zf);P.prototype.visitDateDay=j(Cc);P.prototype.visitDateMillisecond=j(Fc);P.prototype.visitTimestamp=j(Vf);P.prototype.visitTimestampSecond=j(Oc);P.prototype.visitTimestampMillisecond=j(Ec);P.prototype.visitTimestampMicrosecond=j(Uc);P.prototype.visitTimestampNanosecond=j(Nc);P.prototype.visitTime=j(Gf);P.prototype.visitTimeSecond=j(Rc);P.prototype.visitTimeMillisecond=j(Pc);P.prototype.visitTimeMicrosecond=j(kc);P.prototype.visitTimeNanosecond=j(zc);P.prototype.visitDecimal=j(jf);P.prototype.visitList=j(Ty);P.prototype.visitLargeList=j(Ty);P.prototype.visitStruct=j(Ex);P.prototype.visitUnion=j(Ux);P.prototype.visitDenseUnion=j(My);P.prototype.visitSparseUnion=j(Dy);P.prototype.visitDictionary=j(Nx);P.prototype.visitInterval=j(qf);P.prototype.visitIntervalDayTime=j(Vc);P.prototype.visitIntervalYearMonth=j(Gc);P.prototype.visitIntervalMonthDayNano=j(jc);P.prototype.visitDuration=j($f);P.prototype.visitDurationSecond=j(qc);P.prototype.visitDurationMillisecond=j($c);P.prototype.visitDurationMicrosecond=j(Wc);P.prototype.visitDurationNanosecond=j(Yc);P.prototype.visitFixedSizeList=j(Rx);P.prototype.visitMap=j(Mx);Qt=new P});var Ur,go,Jr,Wf,Yf,Px,Zc=p(()=>{Aa();ii();rr();Ur=Symbol.for("parent"),go=Symbol.for("rowIndex"),Jr=class{constructor(t,e){return this[Ur]=t,this[go]=e,new Proxy(this,Px)}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[go],e=this[Ur],n=e.type.children,s={};for(let i=-1,o=n.length;++i<o;)s[n[i].name]=Pt.visit(e.children[i],t);return s}toString(){return`{${[...this].map(([t,e])=>`${Mr(t)}: ${Mr(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new Wf(this[Ur],this[go])}},Wf=class{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,Pt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(Jr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Ur]:{writable:!0,enumerable:!1,configurable:!1,value:null},[go]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});Yf=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Ur].type.children.map(e=>e.name)}has(t,e){return t[Ur].type.children.some(n=>n.name===e)}getOwnPropertyDescriptor(t,e){if(t[Ur].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];let n=t[Ur].type.children.findIndex(s=>s.name===e);if(n!==-1){let s=Pt.visit(t[Ur].children[n],t[go]);return Reflect.set(t,e,s),s}}set(t,e,n){let s=t[Ur].type.children.findIndex(i=>i.name===e);return s!==-1?(Qt.visit(t[Ur].children[s],t[go],n),Reflect.set(t,e,n)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,n):!1}},Px=new Yf});function z(r){return(t,e)=>t.getValid(e)?r(t,e):null}var E,kx,bo,zx,Vx,Cy,Gx,Fy,Oy,fs,jx,Ey,qx,Uy,Ny,$x,Ry,Wx,Yx,Zx,Hx,Py,ky,zy,Vy,Xx,Gy,jy,qy,$y,Kx,Jx,Wy,Qx,tv,ev,Yy,Zy,rv,nv,Hy,Xy,Ky,Jy,Qy,t0,e0,sv,iv,Pt,ii=p(()=>{Mc();he();je();Ca();Zc();Xr();hn();Da();Mt();E=class extends F{};kx=(r,t)=>864e5*r[t],bo=16,zx=12,Vx=(r,t)=>null,Cy=(r,t,e)=>{if(e+1>=t.length)return null;let n=J(t[e]),s=J(t[e+1]);return r.subarray(n,s)},Gx=({offset:r,values:t},e)=>{let n=r+e;return(t[n>>3]&1<<n%8)!==0},Fy=({values:r},t)=>kx(r,t),Oy=({values:r},t)=>J(r[t]),fs=({stride:r,values:t},e)=>t[r*e],jx=({stride:r,values:t},e)=>Dc(t[r*e]),Ey=({values:r},t)=>r[t],qx=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),Uy=({values:r,valueOffsets:t},e)=>Cy(r,t,e),Ny=(r,t)=>{var e;let n=r.values;if(!n)throw new Error("BinaryView data is missing view buffer");let s=t*bo,i=s+bo;if(s<0||i>n.length)throw new Error(`BinaryView data buffer is too short: expected ${bo} bytes, got ${Math.max(0,n.length-s)}`);let o=n.subarray(s,i);if(o.length<bo)throw new Error(`BinaryView data buffer is too short: expected ${bo} bytes, got ${o.length}`);let a=new DataView(n.buffer,o.byteOffset,bo),c=a.getInt32(0,!0);if(c<=0)return new Uint8Array(0);if(c<=zx)return o.subarray(4,4+c);let l=a.getInt32(8,!0),u=a.getInt32(12,!0),f=(e=r.variadicBuffers)===null||e===void 0?void 0:e[l];if(!f)throw new Error(`BinaryView variadic buffer ${l} is missing`);return f.subarray(u,u+c)},$x=(r,t)=>Ny(r,t),Ry=({values:r,valueOffsets:t},e)=>{let n=Cy(r,t,e);return n!==null?io(n):null},Wx=(r,t)=>{let e=Ny(r,t);return io(e)},Yx=({values:r},t)=>r[t],Zx=({type:r,values:t},e)=>r.precision!==ot.HALF?t[e]:Dc(t[e]),Hx=(r,t)=>r.type.unit===mt.DAY?Fy(r,t):Oy(r,t),Py=({values:r},t)=>1e3*J(r[t]),ky=({values:r},t)=>J(r[t]),zy=({values:r},t)=>Of(r[t],BigInt(1e3)),Vy=({values:r},t)=>Of(r[t],BigInt(1e6)),Xx=(r,t)=>{switch(r.type.unit){case v.SECOND:return Py(r,t);case v.MILLISECOND:return ky(r,t);case v.MICROSECOND:return zy(r,t);case v.NANOSECOND:return Vy(r,t)}},Gy=({values:r},t)=>r[t],jy=({values:r},t)=>r[t],qy=({values:r},t)=>r[t],$y=({values:r},t)=>r[t],Kx=(r,t)=>{switch(r.type.unit){case v.SECOND:return Gy(r,t);case v.MILLISECOND:return jy(r,t);case v.MICROSECOND:return qy(r,t);case v.NANOSECOND:return $y(r,t)}},Jx=({values:r,stride:t},e)=>si.decimal(r.subarray(t*e,t*(e+1))),Wy=(r,t)=>{let{valueOffsets:e,stride:n,children:s}=r,i=J(e[t*n]),o=J(e[t*n+1]),c=s[0].slice(i,o-i);return new A([c])},Qx=(r,t)=>{let{valueOffsets:e,children:n}=r,{[t]:s,[t+1]:i}=e,o=n[0];return new fr(o.slice(s,i-s))},tv=(r,t)=>new Jr(r,t),ev=(r,t)=>r.type.mode===lt.Dense?Yy(r,t):Zy(r,t),Yy=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return Pt.visit(n,r.valueOffsets[t])},Zy=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return Pt.visit(n,t)},rv=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},nv=(r,t)=>r.type.unit===et.MONTH_DAY_NANO?Ky(r,t):r.type.unit===et.DAY_TIME?Hy(r,t):Xy(r,t),Hy=({values:r},t)=>r.subarray(2*t,2*(t+1)),Xy=({values:r},t)=>{let e=r[t],n=new Int32Array(2);return n[0]=Math.trunc(e/12),n[1]=Math.trunc(e%12),n},Ky=({values:r},t)=>r.subarray(4*t,4*(t+1)),Jy=({values:r},t)=>r[t],Qy=({values:r},t)=>r[t],t0=({values:r},t)=>r[t],e0=({values:r},t)=>r[t],sv=(r,t)=>{switch(r.type.unit){case v.SECOND:return Jy(r,t);case v.MILLISECOND:return Qy(r,t);case v.MICROSECOND:return t0(r,t);case v.NANOSECOND:return e0(r,t)}},iv=(r,t)=>{let{stride:e,children:n}=r,i=n[0].slice(t*e,e);return new A([i])};E.prototype.visitNull=z(Vx);E.prototype.visitBool=z(Gx);E.prototype.visitInt=z(Yx);E.prototype.visitInt8=z(fs);E.prototype.visitInt16=z(fs);E.prototype.visitInt32=z(fs);E.prototype.visitInt64=z(Ey);E.prototype.visitUint8=z(fs);E.prototype.visitUint16=z(fs);E.prototype.visitUint32=z(fs);E.prototype.visitUint64=z(Ey);E.prototype.visitFloat=z(Zx);E.prototype.visitFloat16=z(jx);E.prototype.visitFloat32=z(fs);E.prototype.visitFloat64=z(fs);E.prototype.visitUtf8=z(Ry);E.prototype.visitLargeUtf8=z(Ry);E.prototype.visitUtf8View=z(Wx);E.prototype.visitBinary=z(Uy);E.prototype.visitLargeBinary=z(Uy);E.prototype.visitBinaryView=z($x);E.prototype.visitFixedSizeBinary=z(qx);E.prototype.visitDate=z(Hx);E.prototype.visitDateDay=z(Fy);E.prototype.visitDateMillisecond=z(Oy);E.prototype.visitTimestamp=z(Xx);E.prototype.visitTimestampSecond=z(Py);E.prototype.visitTimestampMillisecond=z(ky);E.prototype.visitTimestampMicrosecond=z(zy);E.prototype.visitTimestampNanosecond=z(Vy);E.prototype.visitTime=z(Kx);E.prototype.visitTimeSecond=z(Gy);E.prototype.visitTimeMillisecond=z(jy);E.prototype.visitTimeMicrosecond=z(qy);E.prototype.visitTimeNanosecond=z($y);E.prototype.visitDecimal=z(Jx);E.prototype.visitList=z(Wy);E.prototype.visitLargeList=z(Wy);E.prototype.visitStruct=z(tv);E.prototype.visitUnion=z(ev);E.prototype.visitDenseUnion=z(Yy);E.prototype.visitSparseUnion=z(Zy);E.prototype.visitDictionary=z(rv);E.prototype.visitInterval=z(nv);E.prototype.visitIntervalDayTime=z(Hy);E.prototype.visitIntervalYearMonth=z(Xy);E.prototype.visitIntervalMonthDayNano=z(Ky);E.prototype.visitDuration=z(sv);E.prototype.visitDurationSecond=z(Jy);E.prototype.visitDurationMillisecond=z(Qy);E.prototype.visitDurationMicrosecond=z(t0);E.prototype.visitDurationNanosecond=z(e0);E.prototype.visitFixedSizeList=z(iv);E.prototype.visitMap=z(Qx);Pt=new E});var hs,xo,wo,Zf,fr,Hf,Xf,Ca=p(()=>{he();Aa();ii();rr();hs=Symbol.for("keys"),xo=Symbol.for("vals"),wo=Symbol.for("kKeysAsStrings"),Zf=Symbol.for("_kKeysAsStrings"),fr=class{constructor(t){return this[hs]=new A([t.children[0]]).memoize(),this[xo]=t.children[1],new Proxy(this,new Xf)}get[wo](){return this[Zf]||(this[Zf]=Array.from(this[hs].toArray(),String))}[Symbol.iterator](){return new Hf(this[hs],this[xo])}get size(){return this[hs].length}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[hs],e=this[xo],n={};for(let s=-1,i=t.length;++s<i;)n[t.get(s)]=Pt.visit(e,s);return n}toString(){return`{${[...this].map(([t,e])=>`${Mr(t)}: ${Mr(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},Hf=class{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){let t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),Pt.visit(this.vals,t)]})}},Xf=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[wo]}has(t,e){return t[wo].includes(e)}getOwnPropertyDescriptor(t,e){if(t[wo].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[wo].indexOf(e);if(n!==-1){let s=Pt.visit(Reflect.get(t,xo),n);return Reflect.set(t,e,s),s}}set(t,e,n){let s=t[wo].indexOf(e);return s!==-1?(Qt.visit(Reflect.get(t,xo),s,n),Reflect.set(t,e,n)):Reflect.has(t,e)?Reflect.set(t,e,n):!1}};Object.defineProperties(fr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[hs]:{writable:!0,enumerable:!1,configurable:!1,value:null},[xo]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Zf]:{writable:!0,enumerable:!1,configurable:!1,value:null}})});var Kf={};Re(Kf,{clampRange:()=>Fa,createElementComparator:()=>ds,wrapIndex:()=>oi});function Fa(r,t,e,n){let{length:s=0}=r,i=typeof t!="number"?0:t,o=typeof e!="number"?s:e;return i<0&&(i=(i%s+s)%s),o<0&&(o=(o%s+s)%s),o<i&&(r0=i,i=o,o=r0),o>s&&(o=s),n?n(r,i,o):[i,o]}function ds(r){if(typeof r!=="object"||r===null)return n0(r)?n0:e=>e===r;if(r instanceof Date){let e=r.valueOf();return n=>n instanceof Date?n.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?tf(r,e):!1:r instanceof Map?av(r):Array.isArray(r)?ov(r):r instanceof A?cv(r):lv(r,!0)}function ov(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=ds(r[e]);return Hc(t)}function av(r){let t=-1,e=[];for(let n of r.values())e[++t]=ds(n);return Hc(e)}function cv(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=ds(r.get(e));return Hc(t)}function lv(r,t=!1){let e=Object.keys(r);if(!t&&e.length===0)return()=>!1;let n=[];for(let s=-1,i=e.length;++s<i;)n[s]=ds(r[e[s]]);return Hc(n,e)}function Hc(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return uv(r,e);case Map:return s0(r,e,e.keys());case fr:case Jr:case Object:case void 0:return s0(r,e,t||Object.keys(e))}return e instanceof A?fv(r,e):!1}}function uv(r,t){let 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 fv(r,t){let 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 s0(r,t,e){let 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](),o=0,a=r.length,c=i.next(),l=n.next(),u=s.next();for(;o<a&&!l.done&&!u.done&&!c.done&&!(l.value!==u.value||!r[o](c.value));++o,l=n.next(),u=s.next(),c=i.next());return o===a&&l.done&&u.done&&c.done?!0:(n.return&&n.return(),s.return&&s.return(),i.return&&i.return(),!1)}var r0,oi,n0,vo=p(()=>{he();Ca();Zc();Gt();oi=(r,t)=>r<0?t+r:r,n0=r=>r!==r});var Jf={};Re(Jf,{BitIterator:()=>Qr,getBit:()=>Kc,getBool:()=>Ao,packBools:()=>ci,popcnt_array:()=>i0,popcnt_bit_range:()=>Oa,popcnt_uint32:()=>Xc,setBool:()=>hv,truncateBitmap:()=>ai});function Ao(r,t,e,n){return(e&1<<n)!==0}function Kc(r,t,e,n){return(e&1<<n)>>n}function hv(r,t,e){return e?!!(r[t>>3]|=1<<t%8)||!0:!(r[t>>3]&=~(1<<t%8))&&!1}function ai(r,t,e){let n=e.byteLength+7&-8;if(r>0||e.byteLength<n){let s=new Uint8Array(n);return s.set(r%8===0?e.subarray(r>>3):ci(new Qr(e,r,t,null,Ao)).subarray(0,n)),s}return e}function ci(r){let t=[],e=0,n=0,s=0;for(let o of r)o&&(s|=1<<n),++n===8&&(t[e++]=s,s=n=0);(e===0||n>0)&&(t[e++]=s);let i=new Uint8Array(t.length+7&-8);return i.set(t),i}function Oa(r,t,e){if(e-t<=0)return 0;if(e-t<8){let i=0;for(let o of new Qr(r,t,e-t,r,Kc))i+=o;return i}let n=e>>3<<3,s=t+(t%8===0?0:8-t%8);return Oa(r,t,s)+Oa(r,n,e)+i0(r,s>>3,n-s>>3)}function i0(r,t,e){let n=0,s=Math.trunc(t),i=new DataView(r.buffer,r.byteOffset,r.byteLength),o=e===void 0?r.byteLength:s+e;for(;o-s>=4;)n+=Xc(i.getUint32(s)),s+=4;for(;o-s>=2;)n+=Xc(i.getUint16(s)),s+=2;for(;o-s>=1;)n+=Xc(i.getUint8(s)),s+=1;return n}function Xc(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var Qr,li=p(()=>{Qr=class{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 M(r){return pv.visit(r)}var dv,o0,D,Qf,pv,hr=p(()=>{he();Mt();yt();li();yt();je();Gt();dv=-1,o0=Symbol.for("apache-arrow/Data"),D=class r{static isData(t){return t?.[o0]===!0}get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:t}=this;return w.isSparseUnion(t)?this.children.some(e=>e.nullable):w.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0,{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),t+=this.variadicBuffers.reduce((o,a)=>{var c;return o+((c=a?.byteLength)!==null&&c!==void 0?c:0)},0),this.children.reduce((o,a)=>o+a.byteLength,t)}get nullCount(){if(w.isUnion(this.type))return this.children.reduce((n,s)=>n+s.nullCount,0);let t=this._nullCount,e;return t<=dv&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-Oa(e,this.offset,this.offset+this.length)),t}constructor(t,e,n,s,i,o=[],a,c=[]){var l;this.type=t,this.children=o,this.dictionary=a,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 u;i instanceof r?(this.stride=i.stride,this.values=i.values,this.typeIds=i.typeIds,this.nullBitmap=i.nullBitmap,this.valueOffsets=i.valueOffsets,this.variadicBuffers=i.variadicBuffers):(this.stride=er(t),i&&((u=i[0])&&(this.valueOffsets=u),(u=i[1])&&(this.values=u),(u=i[2])&&(this.nullBitmap=u),(u=i[3])&&(this.typeIds=u)),this.variadicBuffers=c),(l=this.variadicBuffers)!==null&&l!==void 0||(this.variadicBuffers=[])}getValid(t){let{type:e}=this;if(w.isUnion(e)){let n=e,s=this.typeIds[t],i=n.typeIdToChildIndex[s],o=this.children[i],a=this.valueOffsets,c=n.mode===lt.Dense&&a?Number(a[t]):t;return o.getValid(c)}if(this.nullable&&this.nullCount>0){let n=this.offset+t;return(this.nullBitmap[n>>3]&1<<n%8)!==0}return!0}setValid(t,e){let n,{type:s}=this;if(w.isUnion(s)){let i=s,o=this.typeIds[t],a=i.typeIdToChildIndex[o],c=this.children[a],l=this.valueOffsets,u=i.mode===lt.Dense&&l?Number(l[t]):t;n=c.getValid(u),c.setValid(u,e)}else{let{nullBitmap:i}=this,{offset:o,length:a}=this,c=o+t,l=1<<c%8,u=c>>3;(!i||i.byteLength<=u)&&(i=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(i.set(ai(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:i})):Object.assign(this,{nullBitmap:i,_nullCount:0}));let f=i[u];n=(f&l)!==0,i[u]=e?f|l:f&~l}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,o=this.children,a=this.variadicBuffers){return new r(t,e,n,s,i,o,this.dictionary,a)}slice(t,e){let{stride:n,typeId:s,children:i}=this,o=+(this._nullCount===0)-1,a=s===16?n:1,c=this._sliceBuffers(t,e,n,s);return this.clone(this.type,this.offset+t,e,o,c,i.length===0||this.valueOffsets?i:this._sliceChildren(i,a*t,a*e),this.variadicBuffers)}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===d.Null)return this.clone(this.type,0,t,0,this.buffers,this.children,this.variadicBuffers);let{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(ai(this.offset,e,this.nullBitmap),0);let i=this.buffers;return i[Z.VALIDITY]=s,this.clone(this.type,0,t,n+(t-e),i,this.children,this.variadicBuffers)}_sliceBuffers(t,e,n,s){let i,{buffers:o}=this;if((i=o[Z.TYPE])&&(o[Z.TYPE]=i.subarray(t,t+e)),w.isBinaryView(this.type)||w.isUtf8View(this.type)){let a=H.ELEMENT_WIDTH;(i=o[Z.DATA])&&(o[Z.DATA]=i.subarray(t*a,(t+e)*a))}else(i=o[Z.OFFSET])&&(o[Z.OFFSET]=i.subarray(t,t+e+1))||(i=o[Z.DATA])&&(o[Z.DATA]=s===6?i:i.subarray(n*t,n*(t+e)));return o}_sliceChildren(t,e,n){return t.map(s=>s.slice(e,n))}};D.prototype.children=Object.freeze([]);D.prototype[o0]=!0;Object.defineProperty(D,Symbol.hasInstance,{value:function(t){return Function.prototype[Symbol.hasInstance].call(this,t)||this===D&&D.isData(t)}});Qf=class r extends F{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){let{["type"]:e,["offset"]:n=0,["length"]:s=0}=t;return new D(e,n,s,s)}visitBool(t){let{["type"]:e,["offset"]:n=0}=t,s=O(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length>>3,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitInt(t){let{["type"]:e,["offset"]:n=0}=t,s=O(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitFloat(t){let{["type"]:e,["offset"]:n=0}=t,s=O(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitUtf8(t){let{["type"]:e,["offset"]:n=0}=t,s=O(t.data),i=O(t.nullBitmap),o=ei(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[o,s,i])}visitUtf8View(t){var e;let{["type"]:n,["offset"]:s=0}=t,i=K(n.ArrayType,t.views),o=O(t.nullBitmap),a=(t.variadicBuffers||[]).map(u=>O(u)),c=(e=t.length)!==null&&e!==void 0?e:Math.trunc(i.length/Le.ELEMENT_WIDTH),l=t.nullBitmap?-1:0;return new D(n,s,c,l,[void 0,i,o],[],void 0,a)}visitLargeUtf8(t){let{["type"]:e,["offset"]:n=0}=t,s=O(t.data),i=O(t.nullBitmap),o=oa(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[o,s,i])}visitBinary(t){let{["type"]:e,["offset"]:n=0}=t,s=O(t.data),i=O(t.nullBitmap),o=ei(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[o,s,i])}visitBinaryView(t){var e;let{["type"]:n,["offset"]:s=0}=t,i=K(n.ArrayType,t.views),o=O(t.nullBitmap),a=(t.variadicBuffers||[]).map(u=>O(u)),c=(e=t.length)!==null&&e!==void 0?e:Math.trunc(i.length/H.ELEMENT_WIDTH),l=t.nullBitmap?-1:0;return new D(n,s,c,l,[void 0,i,o],[],void 0,a)}visitLargeBinary(t){let{["type"]:e,["offset"]:n=0}=t,s=O(t.data),i=O(t.nullBitmap),o=oa(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[o,s,i])}visitFixedSizeBinary(t){let{["type"]:e,["offset"]:n=0}=t,s=O(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length/er(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitDate(t){let{["type"]:e,["offset"]:n=0}=t,s=O(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length/er(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitTimestamp(t){let{["type"]:e,["offset"]:n=0}=t,s=O(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length/er(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitTime(t){let{["type"]:e,["offset"]:n=0}=t,s=O(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length/er(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitDecimal(t){let{["type"]:e,["offset"]:n=0}=t,s=O(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length/er(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitList(t){let{["type"]:e,["offset"]:n=0,["child"]:s}=t,i=O(t.nullBitmap),o=ei(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[o,void 0,i],[s])}visitLargeList(t){let{["type"]:e,["offset"]:n=0,["child"]:s}=t,i=O(t.nullBitmap),o=oa(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[o,void 0,i],[s])}visitStruct(t){let{["type"]:e,["offset"]:n=0,["children"]:s=[]}=t,i=O(t.nullBitmap),{length:o=s.reduce((c,{length:l})=>Math.max(c,l),0),nullCount:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,void 0,i],s)}visitUnion(t){let{["type"]:e,["offset"]:n=0,["children"]:s=[]}=t,i=K(e.ArrayType,t.typeIds),{["length"]:o=i.length,["nullCount"]:a=-1}=t;if(w.isSparseUnion(e))return new D(e,n,o,a,[void 0,void 0,void 0,i],s);let c=ei(t.valueOffsets);return new D(e,n,o,a,[c,void 0,void 0,i],s)}visitDictionary(t){let{["type"]:e,["offset"]:n=0}=t,s=O(t.nullBitmap),i=K(e.indices.ArrayType,t.data),{["dictionary"]:o=new A([new r().visit({type:e.dictionary})])}=t,{["length"]:a=i.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[void 0,i,s],[],o)}visitInterval(t){let{["type"]:e,["offset"]:n=0}=t,s=O(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length/er(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitDuration(t){let{["type"]:e,["offset"]:n=0}=t,s=O(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitFixedSizeList(t){let{["type"]:e,["offset"]:n=0,["child"]:s=new r().visit({type:e.valueType})}=t,i=O(t.nullBitmap),{["length"]:o=s.length/er(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,void 0,i],[s])}visitMap(t){let{["type"]:e,["offset"]:n=0,["child"]:s=new r().visit({type:e.childType})}=t,i=O(t.nullBitmap),o=ei(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[o,void 0,i],[s])}},pv=new Qf});function a0(r){return r.some(t=>t.nullable)}function Jc(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 tl(r,t,e,n){let s=[];for(let i=-1,o=r.length;++i<o;){let a=r[i],c=t[i],{length:l}=a;if(c>=n)break;if(e>=c+l)continue;if(c>=e&&c+l<=n){s.push(a);continue}let u=Math.max(0,e-c),f=Math.min(n-c,l);s.push(a.slice(u,f-u))}return s.length===0&&s.push(r[0].slice(0,0)),s}function th(r,t,e,n){let s=0,i=0,o=t.length-1;do{if(s>=o-1)return e<t[o]?n(r,s,e-t[s]):null;i=s+Math.trunc((o-s)*.5),e<t[i]?o=i:s=i}while(s<o)}function Ua(r,t){return r.getValid(t)}function So(r){function t(e,n,s){return r(e[n],s)}return function(e){let n=this.data;return th(n,this._offsets,e,t)}}function el(r){let t;function e(n,s,i){return r(n[s],i,t)}return function(n,s){let i=this.data;t=s;let o=th(i,this._offsets,n,e);return t=void 0,o}}function rl(r){let t;function e(n,s,i){let o=i,a=0,c=0;for(let l=s-1,u=n.length;++l<u;){let f=n[l];if(~(a=r(f,t,o)))return c+a;o=0,c+=f.length}return-1}return function(n,s){t=n;let i=this.data,o=typeof s!="number"?e(i,0,0):th(i,this._offsets,s,e);return t=void 0,o}}var Ea,nl=p(()=>{Ea=class{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){let t=this.chunkIterator.next();if(!t.done)return t;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}}});function mv(r,t){return t===null&&r.length>0?0:-1}function yv(r,t){let{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(let s of new Qr(e,r.offset+(t||0),r.length,e,Ao)){if(!s)return n;++n}return-1}function W(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case d.Union:break;case d.Dictionary:break;default:return yv(r,e)}let n=Pt.getVisitFn(r),s=ds(t);for(let i=(e||0)-1,o=r.length;++i<o;)if(s(n(r,i)))return i;return-1}function c0(r,t,e){let n=Pt.getVisitFn(r),s=ds(t);for(let i=(e||0)-1,o=r.length;++i<o;)if(s(n(r,i)))return i;return-1}var U,ui,sl=p(()=>{Mt();je();ii();li();vo();U=class extends F{};U.prototype.visitNull=mv;U.prototype.visitBool=W;U.prototype.visitInt=W;U.prototype.visitInt8=W;U.prototype.visitInt16=W;U.prototype.visitInt32=W;U.prototype.visitInt64=W;U.prototype.visitUint8=W;U.prototype.visitUint16=W;U.prototype.visitUint32=W;U.prototype.visitUint64=W;U.prototype.visitFloat=W;U.prototype.visitFloat16=W;U.prototype.visitFloat32=W;U.prototype.visitFloat64=W;U.prototype.visitUtf8=W;U.prototype.visitLargeUtf8=W;U.prototype.visitUtf8View=W;U.prototype.visitBinary=W;U.prototype.visitLargeBinary=W;U.prototype.visitBinaryView=W;U.prototype.visitFixedSizeBinary=W;U.prototype.visitDate=W;U.prototype.visitDateDay=W;U.prototype.visitDateMillisecond=W;U.prototype.visitTimestamp=W;U.prototype.visitTimestampSecond=W;U.prototype.visitTimestampMillisecond=W;U.prototype.visitTimestampMicrosecond=W;U.prototype.visitTimestampNanosecond=W;U.prototype.visitTime=W;U.prototype.visitTimeSecond=W;U.prototype.visitTimeMillisecond=W;U.prototype.visitTimeMicrosecond=W;U.prototype.visitTimeNanosecond=W;U.prototype.visitDecimal=W;U.prototype.visitList=W;U.prototype.visitLargeList=W;U.prototype.visitStruct=W;U.prototype.visitUnion=W;U.prototype.visitDenseUnion=c0;U.prototype.visitSparseUnion=c0;U.prototype.visitDictionary=W;U.prototype.visitInterval=W;U.prototype.visitIntervalDayTime=W;U.prototype.visitIntervalYearMonth=W;U.prototype.visitIntervalMonthDayNano=W;U.prototype.visitDuration=W;U.prototype.visitDurationSecond=W;U.prototype.visitDurationMillisecond=W;U.prototype.visitDurationMicrosecond=W;U.prototype.visitDurationNanosecond=W;U.prototype.visitFixedSizeList=W;U.prototype.visitMap=W;ui=new U});function V(r){let{type:t}=r;if(r.nullCount===0&&r.stride===1&&(w.isInt(t)&&t.bitWidth!==64||w.isTime(t)&&t.bitWidth!==64||w.isFloat(t)&&t.precision!==ot.HALF))return new Ea(r.data.length,n=>{let s=r.data[n];return s.values.subarray(0,s.length)[Symbol.iterator]()});let e=0;return new Ea(r.data.length,n=>{let i=r.data[n].length,o=r.slice(e,e+i);return e+=i,new eh(o)})}var N,eh,Io,il=p(()=>{je();Mt();yt();nl();N=class extends F{};eh=class{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}};N.prototype.visitNull=V;N.prototype.visitBool=V;N.prototype.visitInt=V;N.prototype.visitInt8=V;N.prototype.visitInt16=V;N.prototype.visitInt32=V;N.prototype.visitInt64=V;N.prototype.visitUint8=V;N.prototype.visitUint16=V;N.prototype.visitUint32=V;N.prototype.visitUint64=V;N.prototype.visitFloat=V;N.prototype.visitFloat16=V;N.prototype.visitFloat32=V;N.prototype.visitFloat64=V;N.prototype.visitUtf8=V;N.prototype.visitLargeUtf8=V;N.prototype.visitUtf8View=V;N.prototype.visitBinary=V;N.prototype.visitLargeBinary=V;N.prototype.visitBinaryView=V;N.prototype.visitFixedSizeBinary=V;N.prototype.visitDate=V;N.prototype.visitDateDay=V;N.prototype.visitDateMillisecond=V;N.prototype.visitTimestamp=V;N.prototype.visitTimestampSecond=V;N.prototype.visitTimestampMillisecond=V;N.prototype.visitTimestampMicrosecond=V;N.prototype.visitTimestampNanosecond=V;N.prototype.visitTime=V;N.prototype.visitTimeSecond=V;N.prototype.visitTimeMillisecond=V;N.prototype.visitTimeMicrosecond=V;N.prototype.visitTimeNanosecond=V;N.prototype.visitDecimal=V;N.prototype.visitList=V;N.prototype.visitLargeList=V;N.prototype.visitStruct=V;N.prototype.visitUnion=V;N.prototype.visitDenseUnion=V;N.prototype.visitSparseUnion=V;N.prototype.visitDictionary=V;N.prototype.visitInterval=V;N.prototype.visitIntervalDayTime=V;N.prototype.visitIntervalYearMonth=V;N.prototype.visitIntervalMonthDayNano=V;N.prototype.visitDuration=V;N.prototype.visitDurationSecond=V;N.prototype.visitDurationMillisecond=V;N.prototype.visitDurationMicrosecond=V;N.prototype.visitDurationNanosecond=V;N.prototype.visitFixedSizeList=V;N.prototype.visitMap=V;Io=new N});function te(r){if(r){if(r instanceof D)return new A([r]);if(r instanceof A)return new A(r.data);if(r.type instanceof w)return new A([M(r)]);if(Array.isArray(r))return new A(r.flatMap(t=>gv(t)));if(ArrayBuffer.isView(r)){r instanceof DataView&&(r=new Uint8Array(r.buffer));let t={offset:0,length:r.length,nullCount:-1,data:r};if(r instanceof Int8Array)return new A([M(Object.assign(Object.assign({},t),{type:new Ae}))]);if(r instanceof Int16Array)return new A([M(Object.assign(Object.assign({},t),{type:new Se}))]);if(r instanceof Int32Array)return new A([M(Object.assign(Object.assign({},t),{type:new Dt}))]);if(r instanceof BigInt64Array)return new A([M(Object.assign(Object.assign({},t),{type:new Qe}))]);if(r instanceof Uint8Array||r instanceof Uint8ClampedArray)return new A([M(Object.assign(Object.assign({},t),{type:new Ie}))]);if(r instanceof Uint16Array)return new A([M(Object.assign(Object.assign({},t),{type:new Be}))]);if(r instanceof Uint32Array)return new A([M(Object.assign(Object.assign({},t),{type:new qt}))]);if(r instanceof BigUint64Array)return new A([M(Object.assign(Object.assign({},t),{type:new Cr}))]);if(r instanceof Float32Array)return new A([M(Object.assign(Object.assign({},t),{type:new Xt}))]);if(r instanceof Float64Array)return new A([M(Object.assign(Object.assign({},t),{type:new _e}))]);throw new Error("Unrecognized input")}}throw new Error("Unrecognized input")}function gv(r){return r instanceof D?[r]:r instanceof A?r.data:te(r).data}var l0,u0,f0,h0,A,ol,he=p(()=>{Mt();vo();yt();hr();nl();ii();rr();sl();il();yt();u0=Symbol.for("apache-arrow/Vector"),f0={},h0={},A=class r{static isVector(t){return t?.[u0]===!0}constructor(t){var e,n,s;let i=t[0]instanceof r?t.flatMap(a=>a.data):t;if(i.length===0||i.some(a=>!(a instanceof D)))throw new TypeError("Vector constructor expects an Array of Data instances.");let o=(e=i[0])===null||e===void 0?void 0:e.type;switch(i.length){case 0:this._offsets=[0];break;case 1:{let{get:a,set:c,indexOf:l}=f0[o.typeId],u=i[0];this.isValid=f=>Ua(u,f),this.get=f=>a(u,f),this.set=(f,h)=>c(u,f,h),this.indexOf=f=>l(u,f),this._offsets=[0,u.length];break}default:Object.setPrototypeOf(this,h0[o.typeId]),this._offsets=Qc(i);break}this.data=i,this.type=o,this.stride=er(o),this.numChildren=(s=(n=o.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 a0(this.data)}get nullCount(){return Jc(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${d[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(oi(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return Io.visit(this)}concat(...t){return new r(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new r(Fa(this,t,e,({data:n,_offsets:s},i,o)=>tl(n,s,i,o)))}toJSON(){return[...this]}toArray(){let{type:t,data:e,length:n,stride:s,ArrayType:i}=this;switch(t.typeId){case d.Int:case d.Float:case d.Decimal:case d.Time:case d.Timestamp:switch(e.length){case 0:return new i;case 1:return e[0].values.subarray(0,n*s);default:return e.reduce((o,{values:a,length:c})=>(o.array.set(a.subarray(0,c*s),o.offset),o.offset+=c*s,o),{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 r(this.data.map(({children:e})=>e[t])):null}get isMemoized(){return w.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(w.isDictionary(this.type)){let t=new ol(this.data[0].dictionary),e=this.data.map(n=>{let s=n.clone();return s.dictionary=t,s});return new r(e)}return new ol(this)}unmemoize(){if(w.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),e=this.data.map(n=>{let s=n.clone();return s.dictionary=t,s});return new r(e)}return this}};l0=Symbol.toStringTag;A[l0]=(r=>{r.type=w.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0,r[u0]=!0;let t=Object.keys(d).map(e=>d[e]).filter(e=>typeof e=="number"&&e!==d.NONE);for(let e of t){let n=Pt.getVisitFnByTypeId(e),s=Qt.getVisitFnByTypeId(e),i=ui.getVisitFnByTypeId(e);f0[e]={get:n,set:s,indexOf:i},h0[e]=Object.create(r,{isValid:{value:So(Ua)},get:{value:So(Pt.getVisitFnByTypeId(e))},set:{value:el(Qt.getVisitFnByTypeId(e))},indexOf:{value:rl(ui.getVisitFnByTypeId(e))}})}return"Vector"})(A.prototype);Object.defineProperty(A,Symbol.hasInstance,{value:function(t){return Function.prototype[Symbol.hasInstance].call(this,t)||this===A&&A.isVector(t)}});ol=class r extends A{constructor(t){super(t.data);let e=this.get,n=this.set,s=this.slice,i=new Array(this.length);Object.defineProperty(this,"get",{value(o){let a=i[o];if(a!==void 0)return a;let c=e.call(this,o);return i[o]=c,c}}),Object.defineProperty(this,"set",{value(o,a){n.call(this,o,a),i[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new r(s.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new A(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}});function d0(r){if(!r||r.length<=0)return function(s){return!0};let t="",e=r.filter(n=>n===n);return e.length>0&&(t=`
|
|
7
|
+
"use strict";var __exports__=(()=>{var xf=Object.defineProperty;var _x=Object.getOwnPropertyDescriptor;var Lx=Object.getOwnPropertyNames;var Tx=Object.prototype.hasOwnProperty;var d=(r,t,e)=>()=>{if(e)throw e[0];try{return r&&(t=r(r=0)),t}catch(n){throw e=[n],n}};var Re=(r,t)=>{for(var e in t)xf(r,e,{get:t[e],enumerable:!0})},Mx=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Lx(t))!Tx.call(r,s)&&s!==e&&xf(r,s,{get:()=>t[s],enumerable:!(n=_x(t,s))||n.enumerable});return r};var Dx=r=>Mx(xf({},"__esModule",{value:!0}),r);var jL,qL,WL,YL,Zm=d(()=>{jL=Math.PI/2,qL=Math.PI/4,WL=Math.PI/6,YL=Math.PI*2});var Hm=d(()=>{});var Xm=d(()=>{});var Km=d(()=>{});var Jm=d(()=>{});var Qm=d(()=>{});var ty=d(()=>{});function Bc(){return lo??Uint16Array}var lo,ey=d(()=>{lo=globalThis.Float16Array});var ry=d(()=>{ey()});var ny=d(()=>{ry()});var sy=d(()=>{Km()});var iy=d(()=>{Jm()});var oy=d(()=>{ty()});var ay=d(()=>{Hm()});var cy=d(()=>{Xm()});var ly=d(()=>{Qm()});var uy=d(()=>{Zm();ny();sy();iy();oy();ay();cy();ly()});function _c(r){let t=Bc();return new t(r)}function qn(r){return!!(lo&&r instanceof lo)}function Lc(r,t,e){qn(r)?r[t]=e:r[t]=fy(e)}function Af(r,t){return qn(r)?r[t]:zx(r[t])}function la(r){return qn(r)?new Uint16Array(r.buffer,r.byteOffset,r.length):r}function si(r,t){let e=_c(r.length);for(let n=0;n<r.length;n++)Lc(e,n,r[n]/t);return e}function ua(r,t){return Float32Array.from(r,e=>e/t)}function fy(r){if(!Number.isFinite(r))return r===1/0?31744:r===-1/0?64512:32256;let t=r<0||Object.is(r,-0)?32768:0,e=Math.abs(r);if(e===0)return t;if(e>=65520)return t|31744;if(e>=65504)return t|31743;let n=Math.floor(Math.log2(e));if(n<-14)return t|Math.round(e/2**-24);let s=n+15,i=Math.round((e/2**n-1)*1024);return i===1024?t|s+1<<10:t|s<<10|i}function zx(r){let t=r&32768?-1:1,e=r>>10&31,n=r&1023;return e===0?t*n*2**-24:e===31?n?NaN:t*(1/0):t*(1+n/1024)*2**(e-15)}var hy=d(()=>{"use strict";uy()});function py(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(e[n[s]]=r[n[s]]);return e}function B(r,t,e,n){function s(i){return i instanceof e?i:new e(function(o){o(i)})}return new(e||(e=Promise))(function(i,o){function a(u){try{l(n.next(u))}catch(f){o(f)}}function c(u){try{l(n.throw(u))}catch(f){o(f)}}function l(u){u.done?i(u.value):s(u.value).then(a,c)}l((n=n.apply(r,t||[])).next())})}function dy(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 Y(r){return this instanceof Y?(this.v=r,this):new Y(r)}function xe(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),a("next"),a("throw"),a("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(m){return function(y){return Promise.resolve(y).then(m,f)}}function a(m,y){n[m]&&(s[m]=function(g){return new Promise(function(x,I){i.push([m,g,x,I])>1||c(m,g)})},y&&(s[m]=y(s[m])))}function c(m,y){try{l(n[m](y))}catch(g){h(i[0][3],g)}}function l(m){m.value instanceof Y?Promise.resolve(m.value.v).then(u,f):h(i[0][2],m)}function u(m){c("next",m)}function f(m){c("throw",m)}function h(m,y){m(y),i.shift(),i.length&&c(i[0][0],i[0][1])}}function uo(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(o){return(e=!e)?{value:Y(r[s](o)),done:!1}:i?i(o):o}:i}}function He(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 dy=="function"?dy(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(o){return new Promise(function(a,c){o=r[i](o),s(a,c,o.done,o.value)})}}function s(i,o,a,c){Promise.resolve(c).then(function(l){i({value:l,done:a})},o)}}var Pe=d(()=>{});var my,fo,Vx,Xe,dn=d(()=>{my=new TextDecoder("utf-8"),fo=my.decode.bind(my),Vx=new TextEncoder,Xe=r=>Vx.encode(r)});var Gx,yy,Vt,Ae,Ke,Br,lr,Tc,Mc,Dc,Cc,Fc,gy,fa,by,Ec,wy,Wn=d(()=>{Gx=r=>typeof r=="number",yy=r=>typeof r=="boolean",Vt=r=>typeof r=="function",Ae=r=>r!=null&&Object(r)===r,Ke=r=>Ae(r)&&Vt(r.then),Br=r=>Ae(r)&&Vt(r[Symbol.iterator]),lr=r=>Ae(r)&&Vt(r[Symbol.asyncIterator]),Tc=r=>Ae(r)&&Ae(r.schema),Mc=r=>Ae(r)&&"done"in r&&"value"in r,Dc=r=>Ae(r)&&Vt(r.stat)&&Gx(r.fd),Cc=r=>Ae(r)&&fa(r.body),Fc=r=>"_getDOMStream"in r&&"_getNodeStream"in r,gy=r=>Ae(r)&&Vt(r.abort)&&Vt(r.getWriter)&&!Fc(r),fa=r=>Ae(r)&&Vt(r.cancel)&&Vt(r.getReader)&&!Fc(r),by=r=>Ae(r)&&Vt(r.end)&&Vt(r.write)&&yy(r.writable)&&!Fc(r),Ec=r=>Ae(r)&&Vt(r.read)&&Vt(r.pipe)&&yy(r.readable)&&!Fc(r),wy=r=>Ae(r)&&Vt(r.clear)&&Vt(r.bytes)&&Vt(r.position)&&Vt(r.setPosition)&&Vt(r.capacity)&&Vt(r.getBufferIdentifier)&&Vt(r.createLong)});var Lf={};Re(Lf,{compareArrayLike:()=>_f,joinUint8Arrays:()=>Je,memcpy:()=>ha,rebaseValueOffsets:()=>Oc,toArrayBufferView:()=>K,toArrayBufferViewAsyncIterator:()=>_r,toArrayBufferViewIterator:()=>Yr,toBigInt64Array:()=>da,toBigUint64Array:()=>Zx,toFloat32Array:()=>Hx,toFloat32ArrayAsyncIterator:()=>fA,toFloat32ArrayIterator:()=>nA,toFloat64Array:()=>Xx,toFloat64ArrayAsyncIterator:()=>hA,toFloat64ArrayIterator:()=>sA,toInt16Array:()=>qx,toInt16ArrayAsyncIterator:()=>aA,toInt16ArrayIterator:()=>Qx,toInt32Array:()=>ii,toInt32ArrayAsyncIterator:()=>cA,toInt32ArrayIterator:()=>tA,toInt8Array:()=>jx,toInt8ArrayAsyncIterator:()=>oA,toInt8ArrayIterator:()=>Jx,toUint16Array:()=>Wx,toUint16ArrayAsyncIterator:()=>lA,toUint16ArrayIterator:()=>eA,toUint32Array:()=>Yx,toUint32ArrayAsyncIterator:()=>uA,toUint32ArrayIterator:()=>rA,toUint8Array:()=>E,toUint8ArrayAsyncIterator:()=>Bf,toUint8ArrayIterator:()=>If,toUint8ClampedArray:()=>Kx,toUint8ClampedArrayAsyncIterator:()=>dA,toUint8ClampedArrayIterator:()=>iA});function $x(r){let t=r[0]?[r[0]]:[],e,n,s,i;for(let o,a,c=0,l=0,u=r.length;++c<u;){if(o=t[l],a=r[c],!o||!a||o.buffer!==a.buffer||a.byteOffset<o.byteOffset){a&&(t[++l]=a);continue}if({byteOffset:e,byteLength:s}=o,{byteOffset:n,byteLength:i}=a,e+s<n||n+i<e){a&&(t[++l]=a);continue}t[l]=new Uint8Array(o.buffer,e,n-e+i)}return t}function ha(r,t,e=0,n=t.byteLength){let s=r.byteLength,i=new Uint8Array(r.buffer,r.byteOffset,s),o=new Uint8Array(t.buffer,t.byteOffset,Math.min(n,s));return i.set(o,e),r}function Je(r,t){let e=$x(r),n=e.reduce((u,f)=>u+f.byteLength,0),s,i,o,a=0,c=-1,l=Math.min(t||Number.POSITIVE_INFINITY,n);for(let u=e.length;++c<u;){if(s=e[c],i=s.subarray(0,Math.min(s.length,l-a)),l<=a+i.length){i.length<s.length?e[c]=s.subarray(i.length):i.length===s.length&&c++,o?ha(o,i,a):o=i;break}ha(o||(o=new Uint8Array(l)),i,a),a+=i.length}return[o||new Uint8Array(0),e.slice(c),n-(o?o.byteLength:0)]}function K(r,t){let e=Mc(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=Xe(e)),e instanceof ArrayBuffer?new r(e):e instanceof Sf?new r(e):wy(e)?K(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)}function*Yr(r,t){let e=function*(s){yield s},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Sf?e(t):Br(t)?t:e(t);return yield*vf((function*(s){let i=null;do i=s.next(yield K(r,i));while(!i.done)})(n[Symbol.iterator]())),new r}function _r(r,t){return xe(this,arguments,function*(){if(Ke(t))return yield Y(yield Y(yield*uo(He(_r(r,yield Y(t))))));let n=function(o){return xe(this,arguments,function*(){yield yield Y(yield Y(o))})},s=function(o){return xe(this,arguments,function*(){yield Y(yield*uo(He(vf((function*(a){let c=null;do c=a.next(yield c?.value);while(!c.done)})(o[Symbol.iterator]())))))})},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Sf?n(t):Br(t)?s(t):lr(t)?t:n(t);return yield Y(yield*uo(He(vf((function(o){return xe(this,arguments,function*(){let a=null;do a=yield Y(o.next(yield yield Y(K(r,a))));while(!a.done)})})(i[Symbol.asyncIterator]()))))),yield Y(new r)})}function Oc(r,t,e){if(r!==0){e=e.slice(0,t);let n=typeof e[0]=="bigint"?BigInt(r):r;for(let s=-1,i=e.length;++s<i;)e[s]+=n}return e.subarray(0,t)}function _f(r,t){let e=0,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}var Sf,jx,qx,ii,da,E,Wx,Yx,Zx,Hx,Xx,Kx,vf,Jx,Qx,tA,If,eA,rA,nA,sA,iA,oA,aA,cA,Bf,lA,uA,fA,hA,dA,Gt=d(()=>{Pe();dn();Wn();Sf=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;jx=r=>K(Int8Array,r),qx=r=>K(Int16Array,r),ii=r=>K(Int32Array,r),da=r=>K(BigInt64Array,r),E=r=>K(Uint8Array,r),Wx=r=>K(Uint16Array,r),Yx=r=>K(Uint32Array,r),Zx=r=>K(BigUint64Array,r),Hx=r=>K(Float32Array,r),Xx=r=>K(Float64Array,r),Kx=r=>K(Uint8ClampedArray,r),vf=r=>(r.next(),r);Jx=r=>Yr(Int8Array,r),Qx=r=>Yr(Int16Array,r),tA=r=>Yr(Int32Array,r),If=r=>Yr(Uint8Array,r),eA=r=>Yr(Uint16Array,r),rA=r=>Yr(Uint32Array,r),nA=r=>Yr(Float32Array,r),sA=r=>Yr(Float64Array,r),iA=r=>Yr(Uint8ClampedArray,r);oA=r=>_r(Int8Array,r),aA=r=>_r(Int16Array,r),cA=r=>_r(Int32Array,r),Bf=r=>_r(Uint8Array,r),lA=r=>_r(Uint16Array,r),uA=r=>_r(Uint32Array,r),fA=r=>_r(Float32Array,r),hA=r=>_r(Float64Array,r),dA=r=>_r(Uint8ClampedArray,r)});function*pA(r){let t,e=!1,n=[],s,i,o,a=0;function c(){return i==="peek"?Je(n,o)[0]:([s,n,a]=Je(n,o),s)}({cmd:i,size:o}=(yield null)||{cmd:"read",size:0});let l=If(r)[Symbol.iterator]();try{do if({done:t,value:s}=Number.isNaN(o-a)?l.next():l.next(o-a),!t&&s.byteLength>0&&(n.push(s),a+=s.byteLength),t||o<=a)do({cmd:i,size:o}=yield c());while(o<a);while(!t)}catch(u){e=!0,typeof l.throw=="function"&&l.throw(u)}finally{e===!1&&typeof l.return=="function"&&l.return(null)}return null}function mA(r){return xe(this,arguments,function*(){let e,n=!1,s=[],i,o,a,c=0;function l(){return o==="peek"?Je(s,a)[0]:([i,s,c]=Je(s,a),i)}({cmd:o,size:a}=(yield yield Y(null))||{cmd:"read",size:0});let u=Bf(r)[Symbol.asyncIterator]();try{do if({done:e,value:i}=Number.isNaN(a-c)?yield Y(u.next()):yield Y(u.next(a-c)),!e&&i.byteLength>0&&(s.push(i),c+=i.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield Y(l()));while(a<c);while(!e)}catch(f){n=!0,typeof u.throw=="function"&&(yield Y(u.throw(f)))}finally{n===!1&&typeof u.return=="function"&&(yield Y(u.return(new Uint8Array(0))))}return yield Y(null)})}function yA(r){return xe(this,arguments,function*(){let e=!1,n=!1,s=[],i,o,a,c=0;function l(){return o==="peek"?Je(s,a)[0]:([i,s,c]=Je(s,a),i)}({cmd:o,size:a}=(yield yield Y(null))||{cmd:"read",size:0});let u=new Mf(r);try{do if({done:e,value:i}=Number.isNaN(a-c)?yield Y(u.read()):yield Y(u.read(a-c)),!e&&i.byteLength>0&&(s.push(E(i)),c+=i.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield Y(l()));while(a<c);while(!e)}catch(f){n=!0,yield Y(u.cancel(f))}finally{n===!1?yield Y(u.cancel()):r.locked&&u.releaseLock()}return yield Y(null)})}function gA(r){return xe(this,arguments,function*(){let e=[],n="error",s=!1,i=null,o,a,c=0,l=[],u;function f(){return o==="peek"?Je(l,a)[0]:([u,l,c]=Je(l,a),u)}if({cmd:o,size:a}=(yield yield Y(null))||{cmd:"read",size:0},r.isTTY)return yield yield Y(new Uint8Array(0)),yield Y(null);try{e[0]=Tf(r,"end"),e[1]=Tf(r,"error");do{if(e[2]=Tf(r,"readable"),[n,i]=yield Y(Promise.race(e.map(m=>m[2]))),n==="error")break;if((s=n==="end")||(Number.isFinite(a-c)?(u=E(r.read(a-c)),u.byteLength<a-c&&(u=E(r.read()))):u=E(r.read()),u.byteLength>0&&(l.push(u),c+=u.byteLength)),s||a<=c)do({cmd:o,size:a}=yield yield Y(f()));while(a<c)}while(!s)}finally{yield Y(h(e,n==="error"?i:null))}return yield Y(null);function h(m,y){return u=l=null,new Promise((g,x)=>{for(let[I,j]of m)r.off(I,j);try{let I=r.destroy;I&&I.call(r,y),y=void 0}catch(I){y=I||y}finally{y!=null?x(y):g()}})}})}var Yt,Nc,Mf,Tf,pa=d(()=>{Pe();Gt();Yt={fromIterable(r){return Nc(pA(r))},fromAsyncIterable(r){return Nc(mA(r))},fromDOMStream(r){return Nc(yA(r))},fromNodeStream(r){return Nc(gA(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')}},Nc=r=>(r.next(),r);Mf=class{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return B(this,void 0,void 0,function*(){let{reader:e,source:n}=this;e&&(yield e.cancel(t).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(t){return B(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};let e=yield this.reader.read();return!e.done&&(e.value=E(e)),e})}},Tf=(r,t)=>{let e=s=>n([t,s]),n;return[t,e,new Promise(s=>(n=s)&&r.once(t,e))]}});var ht,Uc=d(()=>{(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"})(ht||(ht={}))});var lt,Df=d(()=>{(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(lt||(lt={}))});var ot,Cf=d(()=>{(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(ot||(ot={}))});var mt,Ff=d(()=>{(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(mt||(mt={}))});var A,ma=d(()=>{(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(A||(A={}))});var et,Ef=d(()=>{(function(r){r[r.YEAR_MONTH=0]="YEAR_MONTH",r[r.DAY_TIME=1]="DAY_TIME",r[r.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(et||(et={}))});var Rc=d(()=>{});var Zr,Pc,kc,ho,Of=d(()=>{Zr=new Int32Array(2),Pc=new Float32Array(Zr.buffer),kc=new Float64Array(Zr.buffer),ho=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1});var ya,Nf=d(()=>{(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(ya||(ya={}))});var Zt,Uf=d(()=>{Rc();Nf();Of();Zt=class r{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new r(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return Zr[0]=this.readInt32(t),Pc[0]}readFloat64(t){return Zr[ho?0:1]=this.readInt32(t),Zr[ho?1:0]=this.readInt32(t+4),kc[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){Pc[0]=e,this.writeInt32(t,Zr[0])}writeFloat64(t,e){kc[0]=e,this.writeInt32(t,Zr[ho?0:1]),this.writeInt32(t+4,Zr[ho?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){let 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);let n=this.readInt32(t);t+=4;let s=this.bytes_.subarray(t,t+n);return e===ya.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)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=4)throw new Error("FlatBuffers: file identifier must be length "+4);for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createScalarList(t,e){let n=[];for(let s=0;s<e;++s){let i=t(s);i!==null&&n.push(i)}return n}createObjList(t,e){let n=[];for(let s=0;s<e;++s){let i=t(s);i!==null&&n.push(i.unpack())}return n}}});var oi,xy=d(()=>{Uf();Rc();oi=class r{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let e;t?e=t:e=1024,this.bb=Zt.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);let n=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<n+t+e;){let s=this.bb.capacity();this.bb=r.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){let e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");let n=e<<1,s=Zt.allocate(n);return s.setPosition(n-e),s.bytes().set(t.bytes(),n-e),s}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);let t=this.offset(),e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);let n=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);let s=2;this.addInt16(t-this.object_start);let i=(n+s)*2;this.addInt16(i);let o=0,a=this.space;t:for(e=0;e<this.vtables.length;e++){let c=this.bb.capacity()-this.vtables[e];if(i==this.bb.readInt16(c)){for(let l=2;l<i;l+=2)if(this.bb.readInt16(a+l)!=this.bb.readInt16(c+l))continue t;o=this.vtables[e];break}}return o?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,o-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,n){let s=n?4:0;if(e){let i=e;if(this.prep(this.minalign,8+s),i.length!=4)throw new TypeError("FlatBuffers: file identifier must be length "+4);for(let o=3;o>=0;o--)this.writeInt8(i.charCodeAt(o))}this.prep(this.minalign,4+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){let 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(4,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);let e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(t==null)return 0;let e;return t instanceof Uint8Array?e=t:e=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){let e=[];for(let n=0;n<t.length;++n){let 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 nt=d(()=>{Rc();Of();xy();Uf();Nf()});var ai,Rf=d(()=>{(function(r){r[r.BUFFER=0]="BUFFER"})(ai||(ai={}))});var Ht,po=d(()=>{(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(Ht||(Ht={}))});var pn,Pf=d(()=>{nt();Rf();po();pn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBodyCompression(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}codec(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):Ht.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):ai.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,Ht.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,ai.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return r.startBodyCompression(t),r.addCodec(t,e),r.addMethod(t,n),r.endBodyCompression(t)}}});var mo,kf=d(()=>{mo=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n??0)),t.writeInt64(BigInt(e??0)),t.offset()}}});var yo,zf=d(()=>{yo=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()}}});var ie,Vf=d(()=>{nt();Pf();kf();zf();ie=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsRecordBatch(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}length(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new yo).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}nodesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new mo).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}buffersLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){let e=this.bb.__offset(this.bb_pos,10);return e?(t||new pn).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}variadicBufferCounts(t){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+t*8):BigInt(0)}variadicBufferCountsLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startRecordBatch(t){t.startObject(5)}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 addVariadicBufferCounts(t,e){t.addFieldOffset(4,e,0)}static createVariadicBufferCountsVector(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 startVariadicBufferCountsVector(t,e){t.startVector(8,e,8)}static endRecordBatch(t){return t.endObject()}}});var mn,Ay=d(()=>{nt();Vf();mn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryBatch(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new ie).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isDelta(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}}});var Yn,Gf=d(()=>{(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})(Yn||(Yn={}))});var ga,vy=d(()=>{(function(r){r[r.DenseArray=0]="DenseArray"})(ga||(ga={}))});var Tr,Vc=d(()=>{nt();Tr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInt(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,e){t.addFieldInt32(0,e,0)}static addIsSigned(t,e){t.addFieldInt8(1,+e,0)}static endInt(t){return t.endObject()}static createInt(t,e,n){return r.startInt(t),r.addBitWidth(t,e),r.addIsSigned(t,n),r.endInt(t)}}});var Hr,$f=d(()=>{nt();vy();Vc();Hr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryEncoding(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new Tr).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isOrdered(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):ga.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,ga.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}}});var Tt,go=d(()=>{nt();Tt=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsKeyValue(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}key(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}value(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,e){t.addFieldOffset(0,e,0)}static addValue(t,e){t.addFieldOffset(1,e,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,e,n){return r.startKeyValue(t),r.addKey(t,e),r.addValue(t,n),r.endKeyValue(t)}}});var ba,Sy=d(()=>{nt();ba=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return r.startBinary(t),r.endBinary(t)}}});var wa,Iy=d(()=>{nt();wa=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBinaryView(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinaryView(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBinaryView(t){t.startObject(0)}static endBinaryView(t){return t.endObject()}static createBinaryView(t){return r.startBinaryView(t),r.endBinaryView(t)}}});var xa,By=d(()=>{nt();xa=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBool(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return r.startBool(t),r.endBool(t)}}});var Zn,jf=d(()=>{nt();Ff();Zn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDate(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):mt.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,mt.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return r.startDate(t),r.addUnit(t,e),r.endDate(t)}}});var Xr,qf=d(()=>{nt();Xr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDecimal(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,e){t.addFieldInt32(0,e,0)}static addScale(t,e){t.addFieldInt32(1,e,0)}static addBitWidth(t,e){t.addFieldInt32(2,e,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,e,n,s){return r.startDecimal(t),r.addPrecision(t,e),r.addScale(t,n),r.addBitWidth(t,s),r.endDecimal(t)}}});var Hn,Wf=d(()=>{nt();ma();Hn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDuration(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):A.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,A.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,e){return r.startDuration(t),r.addUnit(t,e),r.endDuration(t)}}});var Xn,Yf=d(()=>{nt();Xn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,e){return r.startFixedSizeBinary(t),r.addByteWidth(t,e),r.endFixedSizeBinary(t)}}});var Kn,Zf=d(()=>{nt();Kn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}listSize(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,e){return r.startFixedSizeList(t),r.addListSize(t,e),r.endFixedSizeList(t)}}});var Jn,Hf=d(()=>{nt();Cf();Jn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFloatingPoint(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):ot.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,ot.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return r.startFloatingPoint(t),r.addPrecision(t,e),r.endFloatingPoint(t)}}});var Qn,Xf=d(()=>{nt();Ef();Qn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInterval(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):et.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,et.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return r.startInterval(t),r.addUnit(t,e),r.endInterval(t)}}});var Aa,_y=d(()=>{nt();Aa=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return r.startLargeBinary(t),r.endLargeBinary(t)}}});var va,Ly=d(()=>{nt();va=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeList(t){t.startObject(0)}static endLargeList(t){return t.endObject()}static createLargeList(t){return r.startLargeList(t),r.endLargeList(t)}}});var Sa,Ty=d(()=>{nt();Sa=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeUtf8(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return r.startLargeUtf8(t),r.endLargeUtf8(t)}}});var Ia,My=d(()=>{nt();Ia=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return r.startList(t),r.endList(t)}}});var ts,Kf=d(()=>{nt();ts=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMap(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){let t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,e){t.addFieldInt8(0,+e,0)}static endMap(t){return t.endObject()}static createMap(t,e){return r.startMap(t),r.addKeysSorted(t,e),r.endMap(t)}}});var Ba,Dy=d(()=>{nt();Ba=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNull(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return r.startNull(t),r.endNull(t)}}});var _a,Cy=d(()=>{nt();_a=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsStruct_(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return r.startStruct_(t),r.endStruct_(t)}}});var yn,Jf=d(()=>{nt();ma();yn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTime(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):A.MILLISECOND}bitWidth(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,A.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,n){return r.startTime(t),r.addUnit(t,e),r.addBitWidth(t,n),r.endTime(t)}}});var gn,Qf=d(()=>{nt();ma();gn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTimestamp(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):A.SECOND}timezone(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,A.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,n){return r.startTimestamp(t),r.addUnit(t,e),r.addTimezone(t,n),r.endTimestamp(t)}}});var Mr,th=d(()=>{nt();Df();Mr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUnion(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}mode(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):lt.Sparse}typeIds(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+t*4):0}typeIdsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,e){t.addFieldInt16(0,e,lt.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 r.startUnion(t),r.addMode(t,e),r.addTypeIds(t,n),r.endUnion(t)}}});var La,Fy=d(()=>{nt();La=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return r.startUtf8(t),r.endUtf8(t)}}});var Ta,Ey=d(()=>{nt();Ta=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8View(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8View(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8View(t){t.startObject(0)}static endUtf8View(t){return t.endObject()}static createUtf8View(t){return r.startUtf8View(t),r.endUtf8View(t)}}});var k,Gc=d(()=>{(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",r[r.BinaryView=23]="BinaryView",r[r.Utf8View=24]="Utf8View",r[r.ListView=25]="ListView",r[r.LargeListView=26]="LargeListView"})(k||(k={}))});var oe,eh=d(()=>{nt();$f();go();Gc();oe=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsField(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}nullable(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):k.NONE}type(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){let e=this.bb.__offset(this.bb_pos,12);return e?(t||new Hr).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){let n=this.bb.__offset(this.bb_pos,14);return n?(e||new r).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}childrenLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,16);return n?(e||new Tt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,e){t.addFieldOffset(0,e,0)}static addNullable(t,e){t.addFieldInt8(1,+e,0)}static addTypeType(t,e){t.addFieldInt8(2,e,k.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()}}});var ke,rh=d(()=>{nt();Gf();eh();go();ke=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}endianness(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Yn.Little}fields(t,e){let 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(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new Tt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+t*8):BigInt(0)}featuresLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,e){t.addFieldInt16(0,e,Yn.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 createSchema(t,e,n,s,i){return r.startSchema(t),r.addEndianness(t,e),r.addFields(t,n),r.addCustomMetadata(t,s),r.addFeatures(t,i),r.endSchema(t)}}});var Q,$c=d(()=>{(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"})(Q||(Q={}))});var p,Z,Mt=d(()=>{Uc();Df();Cf();Ff();ma();Ef();$c();(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.LargeList=21]="LargeList",r[r.BinaryView=23]="BinaryView",r[r.Utf8View=24]="Utf8View",r[r.Dictionary=-1]="Dictionary",r[r.Int8=-2]="Int8",r[r.Int16=-3]="Int16",r[r.Int32=-4]="Int32",r[r.Int64=-5]="Int64",r[r.Uint8=-6]="Uint8",r[r.Uint16=-7]="Uint16",r[r.Uint32=-8]="Uint32",r[r.Uint64=-9]="Uint64",r[r.Float16=-10]="Float16",r[r.Float32=-11]="Float32",r[r.Float64=-12]="Float64",r[r.DateDay=-13]="DateDay",r[r.DateMillisecond=-14]="DateMillisecond",r[r.TimestampSecond=-15]="TimestampSecond",r[r.TimestampMillisecond=-16]="TimestampMillisecond",r[r.TimestampMicrosecond=-17]="TimestampMicrosecond",r[r.TimestampNanosecond=-18]="TimestampNanosecond",r[r.TimeSecond=-19]="TimeSecond",r[r.TimeMillisecond=-20]="TimeMillisecond",r[r.TimeMicrosecond=-21]="TimeMicrosecond",r[r.TimeNanosecond=-22]="TimeNanosecond",r[r.DenseUnion=-23]="DenseUnion",r[r.SparseUnion=-24]="SparseUnion",r[r.IntervalDayTime=-25]="IntervalDayTime",r[r.IntervalYearMonth=-26]="IntervalYearMonth",r[r.DurationSecond=-27]="DurationSecond",r[r.DurationMillisecond=-28]="DurationMillisecond",r[r.DurationMicrosecond=-29]="DurationMicrosecond",r[r.DurationNanosecond=-30]="DurationNanosecond",r[r.IntervalMonthDayNano=-31]="IntervalMonthDayNano"})(p||(p={}));(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(Z||(Z={}))});var nh={};Re(nh,{valueToString:()=>Dr});function Dr(r){if(r===null)return"null";if(r===void 0)return"undefined";switch(typeof r){case"number":return`${r}`;case"bigint":return`${r}`;case"string":return`"${r}"`}return typeof r[Symbol.toPrimitive]=="function"?r[Symbol.toPrimitive]("string"):ArrayBuffer.isView(r)?r instanceof BigInt64Array||r instanceof BigUint64Array?`[${[...r].map(t=>Dr(t))}]`:`[${r}]`:ArrayBuffer.isView(r)?`[${r}]`:JSON.stringify(r,(t,e)=>typeof e=="bigint"?`${e}`:e)}var Ma=d(()=>{});function J(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 sh(r,t){return J(r/t)+J(r%t)/J(t)}var Kr=d(()=>{});var ah={};Re(ah,{BN:()=>ci,bigNumToBigInt:()=>Ny,bigNumToNumber:()=>oh,bigNumToString:()=>xo,isArrowBigNumSymbol:()=>Oy});function Cr(r,...t){return t.length===0?Object.setPrototypeOf(K(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}function bo(...r){return Cr.apply(this,r)}function wo(...r){return Cr.apply(this,r)}function Da(...r){return Cr.apply(this,r)}function oh(r,t){let{buffer:e,byteOffset:n,byteLength:s,signed:i}=r,o=new BigUint64Array(e,n,s/8),a=i&&o.at(-1)&BigInt(1)<<BigInt(63),c=BigInt(0),l=0;if(a){for(let u of o)c|=(u^wA)*(BigInt(1)<<BigInt(64*l++));c*=BigInt(-1),c-=BigInt(1)}else for(let u of o)c|=u*(BigInt(1)<<BigInt(64*l++));if(typeof t=="number"&&t>0){let u=BigInt("1".padEnd(t+1,"0")),f=c/u,h=a?-(c%u):c%u,m=J(f),y=`${h}`.padStart(t,"0");return+`${a&&m===0?"-":""}${m}.${y}`}return J(c)}function xo(r){if(r.byteLength===8)return`${new r.BigIntArray(r.buffer,r.byteOffset,1)[0]}`;if(!r.signed)return ih(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return ih(r);t=t.slice();let n=1;for(let i=0;i<t.length;i++){let o=t[i],a=~o+n;t[i]=a,n&=o===0?1:0}return`-${ih(t)}`}function Ny(r){return r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:xo(r)}function ih(r){let t="",e=new Uint32Array(2),n=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),s=new Uint32Array((n=new Uint16Array(n).reverse()).buffer),i=-1,o=n.length-1;do{for(e[0]=n[i=0];i<o;)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"}var Oy,bA,wA,ci,jc=d(()=>{Gt();Kr();Oy=Symbol.for("isArrowBigNum");Cr.prototype[Oy]=!0;Cr.prototype.toJSON=function(){return`"${xo(this)}"`};Cr.prototype.valueOf=function(r){return oh(this,r)};Cr.prototype.toString=function(){return xo(this)};Cr.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return oh(this);case"string":return xo(this);case"default":return Ny(this)}return xo(this)};Object.setPrototypeOf(bo.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(wo.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Da.prototype,Object.create(Uint32Array.prototype));Object.assign(bo.prototype,Cr.prototype,{constructor:bo,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(wo.prototype,Cr.prototype,{constructor:wo,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Da.prototype,Cr.prototype,{constructor:Da,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});bA=BigInt(4294967296)*BigInt(4294967296),wA=bA-BigInt(1);ci=class r{static new(t,e){switch(e){case!0:return new bo(t);case!1:return new wo(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new bo(t)}return t.byteLength===16?new Da(t):new wo(t)}static signed(t){return new bo(t)}static unsigned(t){return new wo(t)}static decimal(t){return new Da(t)}constructor(t,e){return r.new(t,e)}}});function er(r){let t=r;switch(r.typeId){case p.Decimal:return r.bitWidth/32;case p.Interval:return t.unit===et.MONTH_DAY_NANO?4:1+t.unit;case p.BinaryView:case p.Utf8View:return 16;case p.FixedSizeList:return t.listSize;case p.FixedSizeBinary:return t.byteWidth;default:return 1}}var Uy,Ry,Py,ky,zy,Vy,Gy,$y,jy,qy,Wy,Yy,Zy,Hy,Xy,Ky,Jy,Qy,tg,eg,rg,ng,sg,ig,og,ag,w,Ot,Lt,ve,Se,Dt,Qe,Ie,Be,jt,Fr,ae,Er,Xt,_e,ze,H,Or,ce,Le,Nr,le,Ve,Te,es,rs,Kt,ns,ss,is,os,Jt,as,Jr,cs,ls,ue,us,fs,Ca,Me,Fa,Ea,Oa,Na,Ct,tr,ut,De,bn,hs,Ge,gt,fe,xA,Rt,yt=d(()=>{Kr();Mt();ag=Symbol.for("apache-arrow/DataType"),w=class r{static isDataType(t){return t?.[ag]===!0}static isNull(t){return t?.typeId===p.Null}static isInt(t){return t?.typeId===p.Int}static isFloat(t){return t?.typeId===p.Float}static isBinary(t){return t?.typeId===p.Binary}static isBinaryView(t){return t?.typeId===p.BinaryView}static isLargeBinary(t){return t?.typeId===p.LargeBinary}static isUtf8(t){return t?.typeId===p.Utf8}static isUtf8View(t){return t?.typeId===p.Utf8View}static isLargeUtf8(t){return t?.typeId===p.LargeUtf8}static isBool(t){return t?.typeId===p.Bool}static isDecimal(t){return t?.typeId===p.Decimal}static isDate(t){return t?.typeId===p.Date}static isTime(t){return t?.typeId===p.Time}static isTimestamp(t){return t?.typeId===p.Timestamp}static isInterval(t){return t?.typeId===p.Interval}static isDuration(t){return t?.typeId===p.Duration}static isList(t){return t?.typeId===p.List}static isLargeList(t){return t?.typeId===p.LargeList}static isStruct(t){return t?.typeId===p.Struct}static isUnion(t){return t?.typeId===p.Union}static isFixedSizeBinary(t){return t?.typeId===p.FixedSizeBinary}static isFixedSizeList(t){return t?.typeId===p.FixedSizeList}static isMap(t){return t?.typeId===p.Map}static isDictionary(t){return t?.typeId===p.Dictionary}static isDenseUnion(t){return r.isUnion(t)&&t.mode===lt.Dense}static isSparseUnion(t){return r.isUnion(t)&&t.mode===lt.Sparse}constructor(t){this.typeId=t}};Uy=Symbol.toStringTag;w[Uy]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[ag]=!0,r[Symbol.toStringTag]="DataType"))(w.prototype);Ot=class extends w{constructor(){super(p.Null)}toString(){return"Null"}};Ry=Symbol.toStringTag;Ot[Ry]=(r=>r[Symbol.toStringTag]="Null")(Ot.prototype);Lt=class extends w{constructor(t,e){super(p.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}`}};Py=Symbol.toStringTag;Lt[Py]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(Lt.prototype);ve=class extends Lt{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},Se=class extends Lt{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},Dt=class extends Lt{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Qe=class extends Lt{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},Ie=class extends Lt{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},Be=class extends Lt{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},jt=class extends Lt{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},Fr=class extends Lt{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(ve.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(Se.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(Dt.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(Qe.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(Ie.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(Be.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(jt.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(Fr.prototype,"ArrayType",{value:BigUint64Array});ae=class extends w{constructor(t){super(p.Float),this.precision=t}get ArrayType(){switch(this.precision){case ot.HALF:return Uint16Array;case ot.SINGLE:return Float32Array;case ot.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};ky=Symbol.toStringTag;ae[ky]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(ae.prototype);Er=class extends ae{constructor(){super(ot.HALF)}},Xt=class extends ae{constructor(){super(ot.SINGLE)}},_e=class extends ae{constructor(){super(ot.DOUBLE)}};Object.defineProperty(Er.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Xt.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(_e.prototype,"ArrayType",{value:Float64Array});ze=class extends w{constructor(){super(p.Binary)}toString(){return"Binary"}};zy=Symbol.toStringTag;ze[zy]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(ze.prototype);H=class extends w{constructor(){super(p.BinaryView)}toString(){return"BinaryView"}};Vy=Symbol.toStringTag;H.ELEMENT_WIDTH=16;H.INLINE_CAPACITY=12;H.LENGTH_OFFSET=0;H.INLINE_OFFSET=4;H.BUFFER_INDEX_OFFSET=8;H.BUFFER_OFFSET_OFFSET=12;H[Vy]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="BinaryView"))(H.prototype);Or=class extends w{constructor(){super(p.LargeBinary)}toString(){return"LargeBinary"}};Gy=Symbol.toStringTag;Or[Gy]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(Or.prototype);ce=class extends w{constructor(){super(p.Utf8)}toString(){return"Utf8"}};$y=Symbol.toStringTag;ce[$y]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(ce.prototype);Le=class extends w{constructor(){super(p.Utf8View)}toString(){return"Utf8View"}};jy=Symbol.toStringTag;Le.ELEMENT_WIDTH=H.ELEMENT_WIDTH;Le.INLINE_CAPACITY=H.INLINE_CAPACITY;Le[jy]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8View"))(Le.prototype);Nr=class extends w{constructor(){super(p.LargeUtf8)}toString(){return"LargeUtf8"}};qy=Symbol.toStringTag;Nr[qy]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(Nr.prototype);le=class extends w{constructor(){super(p.Bool)}toString(){return"Bool"}};Wy=Symbol.toStringTag;le[Wy]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(le.prototype);Ve=class extends w{constructor(t,e,n=128){super(p.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};Yy=Symbol.toStringTag;Ve[Yy]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(Ve.prototype);Te=class extends w{constructor(t){super(p.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${mt[this.unit]}>`}get ArrayType(){return this.unit===mt.DAY?Int32Array:BigInt64Array}};Zy=Symbol.toStringTag;Te[Zy]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(Te.prototype);es=class extends Te{constructor(){super(mt.DAY)}},rs=class extends Te{constructor(){super(mt.MILLISECOND)}},Kt=class extends w{constructor(t,e){super(p.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${A[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};Hy=Symbol.toStringTag;Kt[Hy]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(Kt.prototype);ns=class extends Kt{constructor(){super(A.SECOND,32)}},ss=class extends Kt{constructor(){super(A.MILLISECOND,32)}},is=class extends Kt{constructor(){super(A.MICROSECOND,64)}},os=class extends Kt{constructor(){super(A.NANOSECOND,64)}},Jt=class extends w{constructor(t,e){super(p.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${A[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};Xy=Symbol.toStringTag;Jt[Xy]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(Jt.prototype);as=class extends Jt{constructor(t){super(A.SECOND,t)}},Jr=class extends Jt{constructor(t){super(A.MILLISECOND,t)}},cs=class extends Jt{constructor(t){super(A.MICROSECOND,t)}},ls=class extends Jt{constructor(t){super(A.NANOSECOND,t)}},ue=class extends w{constructor(t){super(p.Interval),this.unit=t}toString(){return`Interval<${et[this.unit]}>`}};Ky=Symbol.toStringTag;ue[Ky]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(ue.prototype);us=class extends ue{constructor(){super(et.DAY_TIME)}},fs=class extends ue{constructor(){super(et.YEAR_MONTH)}},Ca=class extends ue{constructor(){super(et.MONTH_DAY_NANO)}},Me=class extends w{constructor(t){super(p.Duration),this.unit=t}toString(){return`Duration<${A[this.unit]}>`}};Jy=Symbol.toStringTag;Me[Jy]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(Me.prototype);Fa=class extends Me{constructor(){super(A.SECOND)}},Ea=class extends Me{constructor(){super(A.MILLISECOND)}},Oa=class extends Me{constructor(){super(A.MICROSECOND)}},Na=class extends Me{constructor(){super(A.NANOSECOND)}},Ct=class extends w{constructor(t){super(p.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}};Qy=Symbol.toStringTag;Ct[Qy]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(Ct.prototype);tr=class extends w{constructor(t){super(p.LargeList),this.children=[t]}toString(){return`LargeList<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};tg=Symbol.toStringTag;tr[tg]=(r=>(r.children=null,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeList"))(tr.prototype);ut=class extends w{constructor(t){super(p.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};eg=Symbol.toStringTag;ut[eg]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(ut.prototype);De=class extends w{constructor(t,e,n){super(p.Union),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((s,i,o)=>(s[i]=o)&&s||s,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}};rg=Symbol.toStringTag;De[rg]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(De.prototype);bn=class extends De{constructor(t,e){super(lt.Dense,t,e)}},hs=class extends De{constructor(t,e){super(lt.Sparse,t,e)}},Ge=class extends w{constructor(t){super(p.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};ng=Symbol.toStringTag;Ge[ng]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(Ge.prototype);gt=class extends w{constructor(t,e){super(p.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}>`}};sg=Symbol.toStringTag;gt[sg]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(gt.prototype);fe=class extends w{constructor(t,e=!1){var n,s,i;if(super(p.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((n=t?.type)===null||n===void 0)&&n.children)){let o=(s=t?.type)===null||s===void 0?void 0:s.children[0];o&&(o.name="key");let a=(i=t?.type)===null||i===void 0?void 0:i.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};ig=Symbol.toStringTag;fe[ig]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(fe.prototype);xA=(r=>()=>++r)(-1),Rt=class extends w{constructor(t,e,n,s){super(p.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=s||!1,this.id=n==null?xA():J(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}>`}};og=Symbol.toStringTag;Rt[og]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(Rt.prototype)});function AA(r,t,e=!0){return typeof t=="number"?Ao(r,t,e):typeof t=="string"&&t in p?Ao(r,p[t],e):t&&t instanceof w?Ao(r,lg(t),e):t?.type&&t.type instanceof w?Ao(r,lg(t.type),e):Ao(r,p.NONE,e)}function Ao(r,t,e=!0){let n=null;switch(t){case p.Null:n=r.visitNull;break;case p.Bool:n=r.visitBool;break;case p.Int:n=r.visitInt;break;case p.Int8:n=r.visitInt8||r.visitInt;break;case p.Int16:n=r.visitInt16||r.visitInt;break;case p.Int32:n=r.visitInt32||r.visitInt;break;case p.Int64:n=r.visitInt64||r.visitInt;break;case p.Uint8:n=r.visitUint8||r.visitInt;break;case p.Uint16:n=r.visitUint16||r.visitInt;break;case p.Uint32:n=r.visitUint32||r.visitInt;break;case p.Uint64:n=r.visitUint64||r.visitInt;break;case p.Float:n=r.visitFloat;break;case p.Float16:n=r.visitFloat16||r.visitFloat;break;case p.Float32:n=r.visitFloat32||r.visitFloat;break;case p.Float64:n=r.visitFloat64||r.visitFloat;break;case p.Utf8:n=r.visitUtf8;break;case p.LargeUtf8:n=r.visitLargeUtf8;break;case p.Utf8View:n=r.visitUtf8View||r.visitUtf8;break;case p.Binary:n=r.visitBinary;break;case p.LargeBinary:n=r.visitLargeBinary;break;case p.BinaryView:n=r.visitBinaryView||r.visitBinary;break;case p.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case p.Date:n=r.visitDate;break;case p.DateDay:n=r.visitDateDay||r.visitDate;break;case p.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case p.Timestamp:n=r.visitTimestamp;break;case p.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case p.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case p.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case p.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case p.Time:n=r.visitTime;break;case p.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case p.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case p.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case p.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case p.Decimal:n=r.visitDecimal;break;case p.List:n=r.visitList;break;case p.LargeList:n=r.visitLargeList;break;case p.Struct:n=r.visitStruct;break;case p.Union:n=r.visitUnion;break;case p.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case p.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case p.Dictionary:n=r.visitDictionary;break;case p.Interval:n=r.visitInterval;break;case p.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case p.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case p.IntervalMonthDayNano:n=r.visitIntervalMonthDayNano||r.visitInterval;break;case p.Duration:n=r.visitDuration;break;case p.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case p.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case p.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case p.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case p.FixedSizeList:n=r.visitFixedSizeList;break;case p.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error(`Unrecognized type '${p[t]}'`)}function lg(r){switch(r.typeId){case p.Null:return p.Null;case p.Int:{let{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?p.Int8:p.Uint8;case 16:return e?p.Int16:p.Uint16;case 32:return e?p.Int32:p.Uint32;case 64:return e?p.Int64:p.Uint64}return p.Int}case p.Float:switch(r.precision){case ot.HALF:return p.Float16;case ot.SINGLE:return p.Float32;case ot.DOUBLE:return p.Float64}return p.Float;case p.Binary:return p.Binary;case p.LargeBinary:return p.LargeBinary;case p.BinaryView:return p.BinaryView;case p.Utf8:return p.Utf8;case p.LargeUtf8:return p.LargeUtf8;case p.Utf8View:return p.Utf8View;case p.Bool:return p.Bool;case p.Decimal:return p.Decimal;case p.Time:switch(r.unit){case A.SECOND:return p.TimeSecond;case A.MILLISECOND:return p.TimeMillisecond;case A.MICROSECOND:return p.TimeMicrosecond;case A.NANOSECOND:return p.TimeNanosecond}return p.Time;case p.Timestamp:switch(r.unit){case A.SECOND:return p.TimestampSecond;case A.MILLISECOND:return p.TimestampMillisecond;case A.MICROSECOND:return p.TimestampMicrosecond;case A.NANOSECOND:return p.TimestampNanosecond}return p.Timestamp;case p.Date:switch(r.unit){case mt.DAY:return p.DateDay;case mt.MILLISECOND:return p.DateMillisecond}return p.Date;case p.Interval:switch(r.unit){case et.DAY_TIME:return p.IntervalDayTime;case et.YEAR_MONTH:return p.IntervalYearMonth;case et.MONTH_DAY_NANO:return p.IntervalMonthDayNano}return p.Interval;case p.Duration:switch(r.unit){case A.SECOND:return p.DurationSecond;case A.MILLISECOND:return p.DurationMillisecond;case A.MICROSECOND:return p.DurationMicrosecond;case A.NANOSECOND:return p.DurationNanosecond}return p.Duration;case p.Map:return p.Map;case p.List:return p.List;case p.LargeList:return p.LargeList;case p.Struct:return p.Struct;case p.Union:switch(r.mode){case lt.Dense:return p.DenseUnion;case lt.Sparse:return p.SparseUnion}return p.Union;case p.FixedSizeBinary:return p.FixedSizeBinary;case p.FixedSizeList:return p.FixedSizeList;case p.Dictionary:return p.Dictionary}throw new Error(`Unrecognized type '${p[r.typeId]}'`)}var F,$e=d(()=>{Mt();yt();F=class{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 AA(this,t,e)}getVisitFnByTypeId(t,e=!0){return Ao(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}visitUtf8View(t,...e){return null}visitBinary(t,...e){return null}visitLargeBinary(t,...e){return null}visitBinaryView(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}visitLargeList(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}};F.prototype.visitInt8=null;F.prototype.visitInt16=null;F.prototype.visitInt32=null;F.prototype.visitInt64=null;F.prototype.visitUint8=null;F.prototype.visitUint16=null;F.prototype.visitUint32=null;F.prototype.visitUint64=null;F.prototype.visitFloat16=null;F.prototype.visitFloat32=null;F.prototype.visitFloat64=null;F.prototype.visitDateDay=null;F.prototype.visitDateMillisecond=null;F.prototype.visitTimestampSecond=null;F.prototype.visitTimestampMillisecond=null;F.prototype.visitTimestampMicrosecond=null;F.prototype.visitTimestampNanosecond=null;F.prototype.visitTimeSecond=null;F.prototype.visitTimeMillisecond=null;F.prototype.visitTimeMicrosecond=null;F.prototype.visitTimeNanosecond=null;F.prototype.visitDenseUnion=null;F.prototype.visitSparseUnion=null;F.prototype.visitIntervalDayTime=null;F.prototype.visitIntervalYearMonth=null;F.prototype.visitIntervalMonthDayNano=null;F.prototype.visitDuration=null;F.prototype.visitDurationSecond=null;F.prototype.visitDurationMillisecond=null;F.prototype.visitDurationMicrosecond=null;F.prototype.visitDurationNanosecond=null});var ch={};Re(ch,{float64ToUint16:()=>Ua,uint16ToFloat64:()=>qc});function qc(r){let 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 Ua(r){if(r!==r)return 32256;ug[0]=r;let t=(vo[1]&2147483648)>>16&65535,e=vo[1]&2146435072,n=0;return e>=1089470464?vo[0]>0?e=31744:(e=(e&2080374784)>>16,n=(vo[1]&1048575)>>10):e<=1056964608?(n=1048576+(vo[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(vo[1]&1048575)+512>>10),t|e|n&65535}var ug,vo,Ra=d(()=>{ug=new Float64Array(1),vo=new Uint32Array(ug.buffer)});function $(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}var P,vA,fg,SA,wn,lh,hg,IA,Wc,Yc,uh,dg,BA,pg,_A,mg,LA,fh,Zc,Hc,Xc,Kc,hh,Jc,Qc,tl,el,dh,ph,yg,TA,MA,DA,CA,FA,EA,OA,gg,bg,NA,mh,rl,nl,sl,il,ol,al,cl,yh,UA,Qt,rr=d(()=>{he();$e();Kr();dn();Ra();Mt();yt();P=class extends F{};vA=(r,t,e)=>{r[t]=Math.floor(e/864e5)},fg=(r,t,e,n)=>{if(e+1<t.length){let s=J(t[e]),i=J(t[e+1]);r.set(n.subarray(0,i-s),s)}},SA=({offset:r,values:t},e,n)=>{let s=r+e;n?t[s>>3]|=1<<s%8:t[s>>3]&=~(1<<s%8)},wn=({values:r},t,e)=>{r[t]=e},lh=({values:r},t,e)=>{r[t]=e},hg=({values:r},t,e)=>{r[t]=Ua(e)},IA=(r,t,e)=>{switch(r.type.precision){case ot.HALF:return hg(r,t,e);case ot.SINGLE:case ot.DOUBLE:return lh(r,t,e)}},Wc=({values:r},t,e)=>{vA(r,t,e.valueOf())},Yc=({values:r},t,e)=>{r[t]=BigInt(e)},uh=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},dg=({values:r,valueOffsets:t},e,n)=>fg(r,t,e,n),BA=r=>{let t=r.variadicBuffers;return(!Array.isArray(t)||Object.isFrozen(t))&&(t=Array.from(t),r.variadicBuffers=t),t},pg=(r,t,e)=>{var n,s,i,o;let a=r.values;if(!a)throw new Error("BinaryView data is missing view buffer");let c=H.ELEMENT_WIDTH,l=t*c,u=l+c;if(l<0||u>a.length)throw new RangeError(`BinaryView index ${t} out of bounds`);a.fill(0,l,u);let f=new DataView(a.buffer,a.byteOffset+l,c),h=e.length;if(f.setInt32(H.LENGTH_OFFSET,h,!0),h<=H.INLINE_CAPACITY){a.set(e,l+H.INLINE_OFFSET);return}let m=((n=e[0])!==null&&n!==void 0?n:0)|((s=e[1])!==null&&s!==void 0?s:0)<<8|((i=e[2])!==null&&i!==void 0?i:0)<<16|((o=e[3])!==null&&o!==void 0?o:0)<<24;f.setUint32(H.INLINE_OFFSET,m>>>0,!0);let y=BA(r),g=e.slice(),x=y.push(g)-1;f.setInt32(H.BUFFER_INDEX_OFFSET,x,!0),f.setInt32(H.BUFFER_OFFSET_OFFSET,0,!0)},_A=(r,t,e)=>{let n=e instanceof Uint8Array?e:new Uint8Array(e);pg(r,t,n)},mg=({values:r,valueOffsets:t},e,n)=>fg(r,t,e,Xe(n)),LA=(r,t,e)=>{let n=Xe(e);pg(r,t,n)},fh=(r,t,e)=>{r.type.unit===mt.DAY?Wc(r,t,e):Yc(r,t,e)},Zc=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},Hc=({values:r},t,e)=>{r[t]=BigInt(e)},Xc=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},Kc=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},hh=(r,t,e)=>{switch(r.type.unit){case A.SECOND:return Zc(r,t,e);case A.MILLISECOND:return Hc(r,t,e);case A.MICROSECOND:return Xc(r,t,e);case A.NANOSECOND:return Kc(r,t,e)}},Jc=({values:r},t,e)=>{r[t]=e},Qc=({values:r},t,e)=>{r[t]=e},tl=({values:r},t,e)=>{r[t]=e},el=({values:r},t,e)=>{r[t]=e},dh=(r,t,e)=>{switch(r.type.unit){case A.SECOND:return Jc(r,t,e);case A.MILLISECOND:return Qc(r,t,e);case A.MICROSECOND:return tl(r,t,e);case A.NANOSECOND:return el(r,t,e)}},ph=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},yg=(r,t,e)=>{let n=r.children[0],s=r.valueOffsets,i=Qt.getVisitFn(n),o=J(s[t]),a=J(s[t+1]);if(Array.isArray(e))for(let c=-1,l=o;l<a;)i(n,l++,e[++c]);else for(let c=-1,l=o;l<a;)i(n,l++,e.get(++c))},TA=(r,t,e)=>{let n=r.children[0],{valueOffsets:s}=r,i=Qt.getVisitFn(n),{[t]:o,[t+1]:a}=s,c=e instanceof Map?e.entries():Object.entries(e);for(let l of c)if(i(n,o,l),++o>=a)break},MA=(r,t)=>(e,n,s,i)=>n&&e(n,r,t[i]),DA=(r,t)=>(e,n,s,i)=>n&&e(n,r,t.get(i)),CA=(r,t)=>(e,n,s,i)=>n&&e(n,r,t.get(s.name)),FA=(r,t)=>(e,n,s,i)=>n&&e(n,r,t[s.name]),EA=(r,t,e)=>{let n=r.type.children.map(i=>Qt.getVisitFn(i.type)),s=e instanceof Map?CA(t,e):e instanceof v?DA(t,e):Array.isArray(e)?MA(t,e):FA(t,e);r.type.children.forEach((i,o)=>s(n[o],r.children[o],i,o))},OA=(r,t,e)=>{r.type.mode===lt.Dense?gg(r,t,e):bg(r,t,e)},gg=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],s=r.children[n];Qt.visit(s,r.valueOffsets[t],e)},bg=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],s=r.children[n];Qt.visit(s,t,e)},NA=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},mh=(r,t,e)=>{switch(r.type.unit){case et.YEAR_MONTH:return nl(r,t,e);case et.DAY_TIME:return rl(r,t,e);case et.MONTH_DAY_NANO:return sl(r,t,e)}},rl=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},nl=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},sl=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},il=({values:r},t,e)=>{r[t]=e},ol=({values:r},t,e)=>{r[t]=e},al=({values:r},t,e)=>{r[t]=e},cl=({values:r},t,e)=>{r[t]=e},yh=(r,t,e)=>{switch(r.type.unit){case A.SECOND:return il(r,t,e);case A.MILLISECOND:return ol(r,t,e);case A.MICROSECOND:return al(r,t,e);case A.NANOSECOND:return cl(r,t,e)}},UA=(r,t,e)=>{let{stride:n}=r,s=r.children[0],i=Qt.getVisitFn(s);if(Array.isArray(e))for(let o=-1,a=t*n;++o<n;)i(s,a+o,e[o]);else for(let o=-1,a=t*n;++o<n;)i(s,a+o,e.get(o))};P.prototype.visitBool=$(SA);P.prototype.visitInt=$(wn);P.prototype.visitInt8=$(wn);P.prototype.visitInt16=$(wn);P.prototype.visitInt32=$(wn);P.prototype.visitInt64=$(wn);P.prototype.visitUint8=$(wn);P.prototype.visitUint16=$(wn);P.prototype.visitUint32=$(wn);P.prototype.visitUint64=$(wn);P.prototype.visitFloat=$(IA);P.prototype.visitFloat16=$(hg);P.prototype.visitFloat32=$(lh);P.prototype.visitFloat64=$(lh);P.prototype.visitUtf8=$(mg);P.prototype.visitLargeUtf8=$(mg);P.prototype.visitUtf8View=$(LA);P.prototype.visitBinary=$(dg);P.prototype.visitLargeBinary=$(dg);P.prototype.visitBinaryView=$(_A);P.prototype.visitFixedSizeBinary=$(uh);P.prototype.visitDate=$(fh);P.prototype.visitDateDay=$(Wc);P.prototype.visitDateMillisecond=$(Yc);P.prototype.visitTimestamp=$(hh);P.prototype.visitTimestampSecond=$(Zc);P.prototype.visitTimestampMillisecond=$(Hc);P.prototype.visitTimestampMicrosecond=$(Xc);P.prototype.visitTimestampNanosecond=$(Kc);P.prototype.visitTime=$(dh);P.prototype.visitTimeSecond=$(Jc);P.prototype.visitTimeMillisecond=$(Qc);P.prototype.visitTimeMicrosecond=$(tl);P.prototype.visitTimeNanosecond=$(el);P.prototype.visitDecimal=$(ph);P.prototype.visitList=$(yg);P.prototype.visitLargeList=$(yg);P.prototype.visitStruct=$(EA);P.prototype.visitUnion=$(OA);P.prototype.visitDenseUnion=$(gg);P.prototype.visitSparseUnion=$(bg);P.prototype.visitDictionary=$(NA);P.prototype.visitInterval=$(mh);P.prototype.visitIntervalDayTime=$(rl);P.prototype.visitIntervalYearMonth=$(nl);P.prototype.visitIntervalMonthDayNano=$(sl);P.prototype.visitDuration=$(yh);P.prototype.visitDurationSecond=$(il);P.prototype.visitDurationMillisecond=$(ol);P.prototype.visitDurationMicrosecond=$(al);P.prototype.visitDurationNanosecond=$(cl);P.prototype.visitFixedSizeList=$(UA);P.prototype.visitMap=$(TA);Qt=new P});var Ur,So,Qr,gh,bh,RA,ll=d(()=>{Ma();li();rr();Ur=Symbol.for("parent"),So=Symbol.for("rowIndex"),Qr=class{constructor(t,e){return this[Ur]=t,this[So]=e,new Proxy(this,RA)}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[So],e=this[Ur],n=e.type.children,s={};for(let i=-1,o=n.length;++i<o;)s[n[i].name]=Pt.visit(e.children[i],t);return s}toString(){return`{${[...this].map(([t,e])=>`${Dr(t)}: ${Dr(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new gh(this[Ur],this[So])}},gh=class{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,Pt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(Qr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Ur]:{writable:!0,enumerable:!1,configurable:!1,value:null},[So]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});bh=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Ur].type.children.map(e=>e.name)}has(t,e){return t[Ur].type.children.some(n=>n.name===e)}getOwnPropertyDescriptor(t,e){if(t[Ur].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];let n=t[Ur].type.children.findIndex(s=>s.name===e);if(n!==-1){let s=Pt.visit(t[Ur].children[n],t[So]);return Reflect.set(t,e,s),s}}set(t,e,n){let s=t[Ur].type.children.findIndex(i=>i.name===e);return s!==-1?(Qt.visit(t[Ur].children[s],t[So],n),Reflect.set(t,e,n)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,n):!1}},RA=new bh});function z(r){return(t,e)=>t.getValid(e)?r(t,e):null}var O,PA,Io,kA,zA,wg,VA,xg,Ag,ds,GA,vg,$A,Sg,Ig,jA,Bg,qA,WA,YA,ZA,_g,Lg,Tg,Mg,HA,Dg,Cg,Fg,Eg,XA,KA,Og,JA,QA,tv,Ng,Ug,ev,rv,Rg,Pg,kg,zg,Vg,Gg,$g,nv,sv,Pt,li=d(()=>{jc();he();$e();Pa();ll();Kr();dn();Ra();Mt();O=class extends F{};PA=(r,t)=>864e5*r[t],Io=16,kA=12,zA=(r,t)=>null,wg=(r,t,e)=>{if(e+1>=t.length)return null;let n=J(t[e]),s=J(t[e+1]);return r.subarray(n,s)},VA=({offset:r,values:t},e)=>{let n=r+e;return(t[n>>3]&1<<n%8)!==0},xg=({values:r},t)=>PA(r,t),Ag=({values:r},t)=>J(r[t]),ds=({stride:r,values:t},e)=>t[r*e],GA=({stride:r,values:t},e)=>qc(t[r*e]),vg=({values:r},t)=>r[t],$A=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),Sg=({values:r,valueOffsets:t},e)=>wg(r,t,e),Ig=(r,t)=>{var e;let n=r.values;if(!n)throw new Error("BinaryView data is missing view buffer");let s=t*Io,i=s+Io;if(s<0||i>n.length)throw new Error(`BinaryView data buffer is too short: expected ${Io} bytes, got ${Math.max(0,n.length-s)}`);let o=n.subarray(s,i);if(o.length<Io)throw new Error(`BinaryView data buffer is too short: expected ${Io} bytes, got ${o.length}`);let a=new DataView(n.buffer,o.byteOffset,Io),c=a.getInt32(0,!0);if(c<=0)return new Uint8Array(0);if(c<=kA)return o.subarray(4,4+c);let l=a.getInt32(8,!0),u=a.getInt32(12,!0),f=(e=r.variadicBuffers)===null||e===void 0?void 0:e[l];if(!f)throw new Error(`BinaryView variadic buffer ${l} is missing`);return f.subarray(u,u+c)},jA=(r,t)=>Ig(r,t),Bg=({values:r,valueOffsets:t},e)=>{let n=wg(r,t,e);return n!==null?fo(n):null},qA=(r,t)=>{let e=Ig(r,t);return fo(e)},WA=({values:r},t)=>r[t],YA=({type:r,values:t},e)=>r.precision!==ot.HALF?t[e]:qc(t[e]),ZA=(r,t)=>r.type.unit===mt.DAY?xg(r,t):Ag(r,t),_g=({values:r},t)=>1e3*J(r[t]),Lg=({values:r},t)=>J(r[t]),Tg=({values:r},t)=>sh(r[t],BigInt(1e3)),Mg=({values:r},t)=>sh(r[t],BigInt(1e6)),HA=(r,t)=>{switch(r.type.unit){case A.SECOND:return _g(r,t);case A.MILLISECOND:return Lg(r,t);case A.MICROSECOND:return Tg(r,t);case A.NANOSECOND:return Mg(r,t)}},Dg=({values:r},t)=>r[t],Cg=({values:r},t)=>r[t],Fg=({values:r},t)=>r[t],Eg=({values:r},t)=>r[t],XA=(r,t)=>{switch(r.type.unit){case A.SECOND:return Dg(r,t);case A.MILLISECOND:return Cg(r,t);case A.MICROSECOND:return Fg(r,t);case A.NANOSECOND:return Eg(r,t)}},KA=({values:r,stride:t},e)=>ci.decimal(r.subarray(t*e,t*(e+1))),Og=(r,t)=>{let{valueOffsets:e,stride:n,children:s}=r,i=J(e[t*n]),o=J(e[t*n+1]),c=s[0].slice(i,o-i);return new v([c])},JA=(r,t)=>{let{valueOffsets:e,children:n}=r,{[t]:s,[t+1]:i}=e,o=n[0];return new fr(o.slice(s,i-s))},QA=(r,t)=>new Qr(r,t),tv=(r,t)=>r.type.mode===lt.Dense?Ng(r,t):Ug(r,t),Ng=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return Pt.visit(n,r.valueOffsets[t])},Ug=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return Pt.visit(n,t)},ev=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},rv=(r,t)=>r.type.unit===et.MONTH_DAY_NANO?kg(r,t):r.type.unit===et.DAY_TIME?Rg(r,t):Pg(r,t),Rg=({values:r},t)=>r.subarray(2*t,2*(t+1)),Pg=({values:r},t)=>{let e=r[t],n=new Int32Array(2);return n[0]=Math.trunc(e/12),n[1]=Math.trunc(e%12),n},kg=({values:r},t)=>r.subarray(4*t,4*(t+1)),zg=({values:r},t)=>r[t],Vg=({values:r},t)=>r[t],Gg=({values:r},t)=>r[t],$g=({values:r},t)=>r[t],nv=(r,t)=>{switch(r.type.unit){case A.SECOND:return zg(r,t);case A.MILLISECOND:return Vg(r,t);case A.MICROSECOND:return Gg(r,t);case A.NANOSECOND:return $g(r,t)}},sv=(r,t)=>{let{stride:e,children:n}=r,i=n[0].slice(t*e,e);return new v([i])};O.prototype.visitNull=z(zA);O.prototype.visitBool=z(VA);O.prototype.visitInt=z(WA);O.prototype.visitInt8=z(ds);O.prototype.visitInt16=z(ds);O.prototype.visitInt32=z(ds);O.prototype.visitInt64=z(vg);O.prototype.visitUint8=z(ds);O.prototype.visitUint16=z(ds);O.prototype.visitUint32=z(ds);O.prototype.visitUint64=z(vg);O.prototype.visitFloat=z(YA);O.prototype.visitFloat16=z(GA);O.prototype.visitFloat32=z(ds);O.prototype.visitFloat64=z(ds);O.prototype.visitUtf8=z(Bg);O.prototype.visitLargeUtf8=z(Bg);O.prototype.visitUtf8View=z(qA);O.prototype.visitBinary=z(Sg);O.prototype.visitLargeBinary=z(Sg);O.prototype.visitBinaryView=z(jA);O.prototype.visitFixedSizeBinary=z($A);O.prototype.visitDate=z(ZA);O.prototype.visitDateDay=z(xg);O.prototype.visitDateMillisecond=z(Ag);O.prototype.visitTimestamp=z(HA);O.prototype.visitTimestampSecond=z(_g);O.prototype.visitTimestampMillisecond=z(Lg);O.prototype.visitTimestampMicrosecond=z(Tg);O.prototype.visitTimestampNanosecond=z(Mg);O.prototype.visitTime=z(XA);O.prototype.visitTimeSecond=z(Dg);O.prototype.visitTimeMillisecond=z(Cg);O.prototype.visitTimeMicrosecond=z(Fg);O.prototype.visitTimeNanosecond=z(Eg);O.prototype.visitDecimal=z(KA);O.prototype.visitList=z(Og);O.prototype.visitLargeList=z(Og);O.prototype.visitStruct=z(QA);O.prototype.visitUnion=z(tv);O.prototype.visitDenseUnion=z(Ng);O.prototype.visitSparseUnion=z(Ug);O.prototype.visitDictionary=z(ev);O.prototype.visitInterval=z(rv);O.prototype.visitIntervalDayTime=z(Rg);O.prototype.visitIntervalYearMonth=z(Pg);O.prototype.visitIntervalMonthDayNano=z(kg);O.prototype.visitDuration=z(nv);O.prototype.visitDurationSecond=z(zg);O.prototype.visitDurationMillisecond=z(Vg);O.prototype.visitDurationMicrosecond=z(Gg);O.prototype.visitDurationNanosecond=z($g);O.prototype.visitFixedSizeList=z(sv);O.prototype.visitMap=z(JA);Pt=new O});var ps,_o,Bo,wh,fr,xh,Ah,Pa=d(()=>{he();Ma();li();rr();ps=Symbol.for("keys"),_o=Symbol.for("vals"),Bo=Symbol.for("kKeysAsStrings"),wh=Symbol.for("_kKeysAsStrings"),fr=class{constructor(t){return this[ps]=new v([t.children[0]]).memoize(),this[_o]=t.children[1],new Proxy(this,new Ah)}get[Bo](){return this[wh]||(this[wh]=Array.from(this[ps].toArray(),String))}[Symbol.iterator](){return new xh(this[ps],this[_o])}get size(){return this[ps].length}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[ps],e=this[_o],n={};for(let s=-1,i=t.length;++s<i;)n[t.get(s)]=Pt.visit(e,s);return n}toString(){return`{${[...this].map(([t,e])=>`${Dr(t)}: ${Dr(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},xh=class{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){let t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),Pt.visit(this.vals,t)]})}},Ah=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Bo]}has(t,e){return t[Bo].includes(e)}getOwnPropertyDescriptor(t,e){if(t[Bo].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[Bo].indexOf(e);if(n!==-1){let s=Pt.visit(Reflect.get(t,_o),n);return Reflect.set(t,e,s),s}}set(t,e,n){let s=t[Bo].indexOf(e);return s!==-1?(Qt.visit(Reflect.get(t,_o),s,n),Reflect.set(t,e,n)):Reflect.has(t,e)?Reflect.set(t,e,n):!1}};Object.defineProperties(fr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[ps]:{writable:!0,enumerable:!1,configurable:!1,value:null},[_o]:{writable:!0,enumerable:!1,configurable:!1,value:null},[wh]:{writable:!0,enumerable:!1,configurable:!1,value:null}})});var vh={};Re(vh,{clampRange:()=>ka,createElementComparator:()=>ms,wrapIndex:()=>ui});function ka(r,t,e,n){let{length:s=0}=r,i=typeof t!="number"?0:t,o=typeof e!="number"?s:e;return i<0&&(i=(i%s+s)%s),o<0&&(o=(o%s+s)%s),o<i&&(jg=i,i=o,o=jg),o>s&&(o=s),n?n(r,i,o):[i,o]}function ms(r){if(typeof r!=="object"||r===null)return qg(r)?qg:e=>e===r;if(r instanceof Date){let e=r.valueOf();return n=>n instanceof Date?n.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?_f(r,e):!1:r instanceof Map?ov(r):Array.isArray(r)?iv(r):r instanceof v?av(r):cv(r,!0)}function iv(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=ms(r[e]);return ul(t)}function ov(r){let t=-1,e=[];for(let n of r.values())e[++t]=ms(n);return ul(e)}function av(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=ms(r.get(e));return ul(t)}function cv(r,t=!1){let e=Object.keys(r);if(!t&&e.length===0)return()=>!1;let n=[];for(let s=-1,i=e.length;++s<i;)n[s]=ms(r[e[s]]);return ul(n,e)}function ul(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return lv(r,e);case Map:return Wg(r,e,e.keys());case fr:case Qr:case Object:case void 0:return Wg(r,e,t||Object.keys(e))}return e instanceof v?uv(r,e):!1}}function lv(r,t){let 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 uv(r,t){let 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 Wg(r,t,e){let 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](),o=0,a=r.length,c=i.next(),l=n.next(),u=s.next();for(;o<a&&!l.done&&!u.done&&!c.done&&!(l.value!==u.value||!r[o](c.value));++o,l=n.next(),u=s.next(),c=i.next());return o===a&&l.done&&u.done&&c.done?!0:(n.return&&n.return(),s.return&&s.return(),i.return&&i.return(),!1)}var jg,ui,qg,Lo=d(()=>{he();Pa();ll();Gt();ui=(r,t)=>r<0?t+r:r,qg=r=>r!==r});var Sh={};Re(Sh,{BitIterator:()=>tn,getBit:()=>hl,getBool:()=>To,packBools:()=>hi,popcnt_array:()=>Yg,popcnt_bit_range:()=>za,popcnt_uint32:()=>fl,setBool:()=>fv,truncateBitmap:()=>fi});function To(r,t,e,n){return(e&1<<n)!==0}function hl(r,t,e,n){return(e&1<<n)>>n}function fv(r,t,e){return e?!!(r[t>>3]|=1<<t%8)||!0:!(r[t>>3]&=~(1<<t%8))&&!1}function fi(r,t,e){let n=e.byteLength+7&-8;if(r>0||e.byteLength<n){let s=new Uint8Array(n);return s.set(r%8===0?e.subarray(r>>3):hi(new tn(e,r,t,null,To)).subarray(0,n)),s}return e}function hi(r){let t=[],e=0,n=0,s=0;for(let o of r)o&&(s|=1<<n),++n===8&&(t[e++]=s,s=n=0);(e===0||n>0)&&(t[e++]=s);let i=new Uint8Array(t.length+7&-8);return i.set(t),i}function za(r,t,e){if(e-t<=0)return 0;if(e-t<8){let i=0;for(let o of new tn(r,t,e-t,r,hl))i+=o;return i}let n=e>>3<<3,s=t+(t%8===0?0:8-t%8);return za(r,t,s)+za(r,n,e)+Yg(r,s>>3,n-s>>3)}function Yg(r,t,e){let n=0,s=Math.trunc(t),i=new DataView(r.buffer,r.byteOffset,r.byteLength),o=e===void 0?r.byteLength:s+e;for(;o-s>=4;)n+=fl(i.getUint32(s)),s+=4;for(;o-s>=2;)n+=fl(i.getUint16(s)),s+=2;for(;o-s>=1;)n+=fl(i.getUint8(s)),s+=1;return n}function fl(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var tn,di=d(()=>{tn=class{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 M(r){return dv.visit(r)}var hv,Zg,D,Ih,dv,hr=d(()=>{he();Mt();yt();di();yt();$e();Gt();hv=-1,Zg=Symbol.for("apache-arrow/Data"),D=class r{static isData(t){return t?.[Zg]===!0}get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:t}=this;return w.isSparseUnion(t)?this.children.some(e=>e.nullable):w.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0,{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),t+=this.variadicBuffers.reduce((o,a)=>{var c;return o+((c=a?.byteLength)!==null&&c!==void 0?c:0)},0),this.children.reduce((o,a)=>o+a.byteLength,t)}get nullCount(){if(w.isUnion(this.type))return this.children.reduce((n,s)=>n+s.nullCount,0);let t=this._nullCount,e;return t<=hv&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-za(e,this.offset,this.offset+this.length)),t}constructor(t,e,n,s,i,o=[],a,c=[]){var l;this.type=t,this.children=o,this.dictionary=a,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 u;i instanceof r?(this.stride=i.stride,this.values=i.values,this.typeIds=i.typeIds,this.nullBitmap=i.nullBitmap,this.valueOffsets=i.valueOffsets,this.variadicBuffers=i.variadicBuffers):(this.stride=er(t),i&&((u=i[0])&&(this.valueOffsets=u),(u=i[1])&&(this.values=u),(u=i[2])&&(this.nullBitmap=u),(u=i[3])&&(this.typeIds=u)),this.variadicBuffers=c),(l=this.variadicBuffers)!==null&&l!==void 0||(this.variadicBuffers=[])}getValid(t){let{type:e}=this;if(w.isUnion(e)){let n=e,s=this.typeIds[t],i=n.typeIdToChildIndex[s],o=this.children[i],a=this.valueOffsets,c=n.mode===lt.Dense&&a?Number(a[t]):t;return o.getValid(c)}if(this.nullable&&this.nullCount>0){let n=this.offset+t;return(this.nullBitmap[n>>3]&1<<n%8)!==0}return!0}setValid(t,e){let n,{type:s}=this;if(w.isUnion(s)){let i=s,o=this.typeIds[t],a=i.typeIdToChildIndex[o],c=this.children[a],l=this.valueOffsets,u=i.mode===lt.Dense&&l?Number(l[t]):t;n=c.getValid(u),c.setValid(u,e)}else{let{nullBitmap:i}=this,{offset:o,length:a}=this,c=o+t,l=1<<c%8,u=c>>3;(!i||i.byteLength<=u)&&(i=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(i.set(fi(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:i})):Object.assign(this,{nullBitmap:i,_nullCount:0}));let f=i[u];n=(f&l)!==0,i[u]=e?f|l:f&~l}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,o=this.children,a=this.variadicBuffers){return new r(t,e,n,s,i,o,this.dictionary,a)}slice(t,e){let{stride:n,typeId:s,children:i}=this,o=+(this._nullCount===0)-1,a=s===16?n:1,c=this._sliceBuffers(t,e,n,s);return this.clone(this.type,this.offset+t,e,o,c,i.length===0||this.valueOffsets?i:this._sliceChildren(i,a*t,a*e),this.variadicBuffers)}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===p.Null)return this.clone(this.type,0,t,0,this.buffers,this.children,this.variadicBuffers);let{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(fi(this.offset,e,this.nullBitmap),0);let i=this.buffers;return i[Z.VALIDITY]=s,this.clone(this.type,0,t,n+(t-e),i,this.children,this.variadicBuffers)}_sliceBuffers(t,e,n,s){let i,{buffers:o}=this;if((i=o[Z.TYPE])&&(o[Z.TYPE]=i.subarray(t,t+e)),w.isBinaryView(this.type)||w.isUtf8View(this.type)){let a=H.ELEMENT_WIDTH;(i=o[Z.DATA])&&(o[Z.DATA]=i.subarray(t*a,(t+e)*a))}else(i=o[Z.OFFSET])&&(o[Z.OFFSET]=i.subarray(t,t+e+1))||(i=o[Z.DATA])&&(o[Z.DATA]=s===6?i:i.subarray(n*t,n*(t+e)));return o}_sliceChildren(t,e,n){return t.map(s=>s.slice(e,n))}};D.prototype.children=Object.freeze([]);D.prototype[Zg]=!0;Object.defineProperty(D,Symbol.hasInstance,{value:function(t){return Function.prototype[Symbol.hasInstance].call(this,t)||this===D&&D.isData(t)}});Ih=class r extends F{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){let{["type"]:e,["offset"]:n=0,["length"]:s=0}=t;return new D(e,n,s,s)}visitBool(t){let{["type"]:e,["offset"]:n=0}=t,s=E(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length>>3,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitInt(t){let{["type"]:e,["offset"]:n=0}=t,s=E(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitFloat(t){let{["type"]:e,["offset"]:n=0}=t,s=E(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitUtf8(t){let{["type"]:e,["offset"]:n=0}=t,s=E(t.data),i=E(t.nullBitmap),o=ii(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[o,s,i])}visitUtf8View(t){var e;let{["type"]:n,["offset"]:s=0}=t,i=K(n.ArrayType,t.views),o=E(t.nullBitmap),a=(t.variadicBuffers||[]).map(u=>E(u)),c=(e=t.length)!==null&&e!==void 0?e:Math.trunc(i.length/Le.ELEMENT_WIDTH),l=t.nullBitmap?-1:0;return new D(n,s,c,l,[void 0,i,o],[],void 0,a)}visitLargeUtf8(t){let{["type"]:e,["offset"]:n=0}=t,s=E(t.data),i=E(t.nullBitmap),o=da(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[o,s,i])}visitBinary(t){let{["type"]:e,["offset"]:n=0}=t,s=E(t.data),i=E(t.nullBitmap),o=ii(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[o,s,i])}visitBinaryView(t){var e;let{["type"]:n,["offset"]:s=0}=t,i=K(n.ArrayType,t.views),o=E(t.nullBitmap),a=(t.variadicBuffers||[]).map(u=>E(u)),c=(e=t.length)!==null&&e!==void 0?e:Math.trunc(i.length/H.ELEMENT_WIDTH),l=t.nullBitmap?-1:0;return new D(n,s,c,l,[void 0,i,o],[],void 0,a)}visitLargeBinary(t){let{["type"]:e,["offset"]:n=0}=t,s=E(t.data),i=E(t.nullBitmap),o=da(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[o,s,i])}visitFixedSizeBinary(t){let{["type"]:e,["offset"]:n=0}=t,s=E(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length/er(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitDate(t){let{["type"]:e,["offset"]:n=0}=t,s=E(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length/er(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitTimestamp(t){let{["type"]:e,["offset"]:n=0}=t,s=E(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length/er(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitTime(t){let{["type"]:e,["offset"]:n=0}=t,s=E(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length/er(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitDecimal(t){let{["type"]:e,["offset"]:n=0}=t,s=E(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length/er(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitList(t){let{["type"]:e,["offset"]:n=0,["child"]:s}=t,i=E(t.nullBitmap),o=ii(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[o,void 0,i],[s])}visitLargeList(t){let{["type"]:e,["offset"]:n=0,["child"]:s}=t,i=E(t.nullBitmap),o=da(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[o,void 0,i],[s])}visitStruct(t){let{["type"]:e,["offset"]:n=0,["children"]:s=[]}=t,i=E(t.nullBitmap),{length:o=s.reduce((c,{length:l})=>Math.max(c,l),0),nullCount:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,void 0,i],s)}visitUnion(t){let{["type"]:e,["offset"]:n=0,["children"]:s=[]}=t,i=K(e.ArrayType,t.typeIds),{["length"]:o=i.length,["nullCount"]:a=-1}=t;if(w.isSparseUnion(e))return new D(e,n,o,a,[void 0,void 0,void 0,i],s);let c=ii(t.valueOffsets);return new D(e,n,o,a,[c,void 0,void 0,i],s)}visitDictionary(t){let{["type"]:e,["offset"]:n=0}=t,s=E(t.nullBitmap),i=K(e.indices.ArrayType,t.data),{["dictionary"]:o=new v([new r().visit({type:e.dictionary})])}=t,{["length"]:a=i.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[void 0,i,s],[],o)}visitInterval(t){let{["type"]:e,["offset"]:n=0}=t,s=E(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length/er(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitDuration(t){let{["type"]:e,["offset"]:n=0}=t,s=E(t.nullBitmap),i=K(e.ArrayType,t.data),{["length"]:o=i.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,i,s])}visitFixedSizeList(t){let{["type"]:e,["offset"]:n=0,["child"]:s=new r().visit({type:e.valueType})}=t,i=E(t.nullBitmap),{["length"]:o=s.length/er(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new D(e,n,o,a,[void 0,void 0,i],[s])}visitMap(t){let{["type"]:e,["offset"]:n=0,["child"]:s=new r().visit({type:e.childType})}=t,i=E(t.nullBitmap),o=ii(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new D(e,n,a,c,[o,void 0,i],[s])}},dv=new Ih});function Hg(r){return r.some(t=>t.nullable)}function dl(r){return r.reduce((t,e)=>t+e.nullCount,0)}function pl(r){return r.reduce((t,e,n)=>(t[n+1]=t[n]+e.length,t),new Uint32Array(r.length+1))}function ml(r,t,e,n){let s=[];for(let i=-1,o=r.length;++i<o;){let a=r[i],c=t[i],{length:l}=a;if(c>=n)break;if(e>=c+l)continue;if(c>=e&&c+l<=n){s.push(a);continue}let u=Math.max(0,e-c),f=Math.min(n-c,l);s.push(a.slice(u,f-u))}return s.length===0&&s.push(r[0].slice(0,0)),s}function Bh(r,t,e,n){let s=0,i=0,o=t.length-1;do{if(s>=o-1)return e<t[o]?n(r,s,e-t[s]):null;i=s+Math.trunc((o-s)*.5),e<t[i]?o=i:s=i}while(s<o)}function Ga(r,t){return r.getValid(t)}function Mo(r){function t(e,n,s){return r(e[n],s)}return function(e){let n=this.data;return Bh(n,this._offsets,e,t)}}function yl(r){let t;function e(n,s,i){return r(n[s],i,t)}return function(n,s){let i=this.data;t=s;let o=Bh(i,this._offsets,n,e);return t=void 0,o}}function gl(r){let t;function e(n,s,i){let o=i,a=0,c=0;for(let l=s-1,u=n.length;++l<u;){let f=n[l];if(~(a=r(f,t,o)))return c+a;o=0,c+=f.length}return-1}return function(n,s){t=n;let i=this.data,o=typeof s!="number"?e(i,0,0):Bh(i,this._offsets,s,e);return t=void 0,o}}var Va,bl=d(()=>{Va=class{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){let t=this.chunkIterator.next();if(!t.done)return t;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}}});function pv(r,t){return t===null&&r.length>0?0:-1}function mv(r,t){let{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(let s of new tn(e,r.offset+(t||0),r.length,e,To)){if(!s)return n;++n}return-1}function W(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case p.Union:break;case p.Dictionary:break;default:return mv(r,e)}let n=Pt.getVisitFn(r),s=ms(t);for(let i=(e||0)-1,o=r.length;++i<o;)if(s(n(r,i)))return i;return-1}function Xg(r,t,e){let n=Pt.getVisitFn(r),s=ms(t);for(let i=(e||0)-1,o=r.length;++i<o;)if(s(n(r,i)))return i;return-1}var N,pi,wl=d(()=>{Mt();$e();li();di();Lo();N=class extends F{};N.prototype.visitNull=pv;N.prototype.visitBool=W;N.prototype.visitInt=W;N.prototype.visitInt8=W;N.prototype.visitInt16=W;N.prototype.visitInt32=W;N.prototype.visitInt64=W;N.prototype.visitUint8=W;N.prototype.visitUint16=W;N.prototype.visitUint32=W;N.prototype.visitUint64=W;N.prototype.visitFloat=W;N.prototype.visitFloat16=W;N.prototype.visitFloat32=W;N.prototype.visitFloat64=W;N.prototype.visitUtf8=W;N.prototype.visitLargeUtf8=W;N.prototype.visitUtf8View=W;N.prototype.visitBinary=W;N.prototype.visitLargeBinary=W;N.prototype.visitBinaryView=W;N.prototype.visitFixedSizeBinary=W;N.prototype.visitDate=W;N.prototype.visitDateDay=W;N.prototype.visitDateMillisecond=W;N.prototype.visitTimestamp=W;N.prototype.visitTimestampSecond=W;N.prototype.visitTimestampMillisecond=W;N.prototype.visitTimestampMicrosecond=W;N.prototype.visitTimestampNanosecond=W;N.prototype.visitTime=W;N.prototype.visitTimeSecond=W;N.prototype.visitTimeMillisecond=W;N.prototype.visitTimeMicrosecond=W;N.prototype.visitTimeNanosecond=W;N.prototype.visitDecimal=W;N.prototype.visitList=W;N.prototype.visitLargeList=W;N.prototype.visitStruct=W;N.prototype.visitUnion=W;N.prototype.visitDenseUnion=Xg;N.prototype.visitSparseUnion=Xg;N.prototype.visitDictionary=W;N.prototype.visitInterval=W;N.prototype.visitIntervalDayTime=W;N.prototype.visitIntervalYearMonth=W;N.prototype.visitIntervalMonthDayNano=W;N.prototype.visitDuration=W;N.prototype.visitDurationSecond=W;N.prototype.visitDurationMillisecond=W;N.prototype.visitDurationMicrosecond=W;N.prototype.visitDurationNanosecond=W;N.prototype.visitFixedSizeList=W;N.prototype.visitMap=W;pi=new N});function V(r){let{type:t}=r;if(r.nullCount===0&&r.stride===1&&(w.isInt(t)&&t.bitWidth!==64||w.isTime(t)&&t.bitWidth!==64||w.isFloat(t)&&t.precision!==ot.HALF))return new Va(r.data.length,n=>{let s=r.data[n];return s.values.subarray(0,s.length)[Symbol.iterator]()});let e=0;return new Va(r.data.length,n=>{let i=r.data[n].length,o=r.slice(e,e+i);return e+=i,new _h(o)})}var U,_h,Do,xl=d(()=>{$e();Mt();yt();bl();U=class extends F{};_h=class{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}};U.prototype.visitNull=V;U.prototype.visitBool=V;U.prototype.visitInt=V;U.prototype.visitInt8=V;U.prototype.visitInt16=V;U.prototype.visitInt32=V;U.prototype.visitInt64=V;U.prototype.visitUint8=V;U.prototype.visitUint16=V;U.prototype.visitUint32=V;U.prototype.visitUint64=V;U.prototype.visitFloat=V;U.prototype.visitFloat16=V;U.prototype.visitFloat32=V;U.prototype.visitFloat64=V;U.prototype.visitUtf8=V;U.prototype.visitLargeUtf8=V;U.prototype.visitUtf8View=V;U.prototype.visitBinary=V;U.prototype.visitLargeBinary=V;U.prototype.visitBinaryView=V;U.prototype.visitFixedSizeBinary=V;U.prototype.visitDate=V;U.prototype.visitDateDay=V;U.prototype.visitDateMillisecond=V;U.prototype.visitTimestamp=V;U.prototype.visitTimestampSecond=V;U.prototype.visitTimestampMillisecond=V;U.prototype.visitTimestampMicrosecond=V;U.prototype.visitTimestampNanosecond=V;U.prototype.visitTime=V;U.prototype.visitTimeSecond=V;U.prototype.visitTimeMillisecond=V;U.prototype.visitTimeMicrosecond=V;U.prototype.visitTimeNanosecond=V;U.prototype.visitDecimal=V;U.prototype.visitList=V;U.prototype.visitLargeList=V;U.prototype.visitStruct=V;U.prototype.visitUnion=V;U.prototype.visitDenseUnion=V;U.prototype.visitSparseUnion=V;U.prototype.visitDictionary=V;U.prototype.visitInterval=V;U.prototype.visitIntervalDayTime=V;U.prototype.visitIntervalYearMonth=V;U.prototype.visitIntervalMonthDayNano=V;U.prototype.visitDuration=V;U.prototype.visitDurationSecond=V;U.prototype.visitDurationMillisecond=V;U.prototype.visitDurationMicrosecond=V;U.prototype.visitDurationNanosecond=V;U.prototype.visitFixedSizeList=V;U.prototype.visitMap=V;Do=new U});function te(r){if(r){if(r instanceof D)return new v([r]);if(r instanceof v)return new v(r.data);if(r.type instanceof w)return new v([M(r)]);if(Array.isArray(r))return new v(r.flatMap(t=>yv(t)));if(ArrayBuffer.isView(r)){r instanceof DataView&&(r=new Uint8Array(r.buffer));let t={offset:0,length:r.length,nullCount:-1,data:r};if(r instanceof Int8Array)return new v([M(Object.assign(Object.assign({},t),{type:new ve}))]);if(r instanceof Int16Array)return new v([M(Object.assign(Object.assign({},t),{type:new Se}))]);if(r instanceof Int32Array)return new v([M(Object.assign(Object.assign({},t),{type:new Dt}))]);if(r instanceof BigInt64Array)return new v([M(Object.assign(Object.assign({},t),{type:new Qe}))]);if(r instanceof Uint8Array||r instanceof Uint8ClampedArray)return new v([M(Object.assign(Object.assign({},t),{type:new Ie}))]);if(r instanceof Uint16Array)return new v([M(Object.assign(Object.assign({},t),{type:new Be}))]);if(r instanceof Uint32Array)return new v([M(Object.assign(Object.assign({},t),{type:new jt}))]);if(r instanceof BigUint64Array)return new v([M(Object.assign(Object.assign({},t),{type:new Fr}))]);if(r instanceof Float32Array)return new v([M(Object.assign(Object.assign({},t),{type:new Xt}))]);if(r instanceof Float64Array)return new v([M(Object.assign(Object.assign({},t),{type:new _e}))]);throw new Error("Unrecognized input")}}throw new Error("Unrecognized input")}function yv(r){return r instanceof D?[r]:r instanceof v?r.data:te(r).data}var Kg,Jg,Qg,t0,v,Al,he=d(()=>{Mt();Lo();yt();hr();bl();li();rr();wl();xl();yt();Jg=Symbol.for("apache-arrow/Vector"),Qg={},t0={},v=class r{static isVector(t){return t?.[Jg]===!0}constructor(t){var e,n,s;let i=t[0]instanceof r?t.flatMap(a=>a.data):t;if(i.length===0||i.some(a=>!(a instanceof D)))throw new TypeError("Vector constructor expects an Array of Data instances.");let o=(e=i[0])===null||e===void 0?void 0:e.type;switch(i.length){case 0:this._offsets=[0];break;case 1:{let{get:a,set:c,indexOf:l}=Qg[o.typeId],u=i[0];this.isValid=f=>Ga(u,f),this.get=f=>a(u,f),this.set=(f,h)=>c(u,f,h),this.indexOf=f=>l(u,f),this._offsets=[0,u.length];break}default:Object.setPrototypeOf(this,t0[o.typeId]),this._offsets=pl(i);break}this.data=i,this.type=o,this.stride=er(o),this.numChildren=(s=(n=o.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 Hg(this.data)}get nullCount(){return dl(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${p[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(ui(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return Do.visit(this)}concat(...t){return new r(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new r(ka(this,t,e,({data:n,_offsets:s},i,o)=>ml(n,s,i,o)))}toJSON(){return[...this]}toArray(){let{type:t,data:e,length:n,stride:s,ArrayType:i}=this;switch(t.typeId){case p.Int:case p.Float:case p.Decimal:case p.Time:case p.Timestamp:switch(e.length){case 0:return new i;case 1:return e[0].values.subarray(0,n*s);default:return e.reduce((o,{values:a,length:c})=>(o.array.set(a.subarray(0,c*s),o.offset),o.offset+=c*s,o),{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 r(this.data.map(({children:e})=>e[t])):null}get isMemoized(){return w.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(w.isDictionary(this.type)){let t=new Al(this.data[0].dictionary),e=this.data.map(n=>{let s=n.clone();return s.dictionary=t,s});return new r(e)}return new Al(this)}unmemoize(){if(w.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),e=this.data.map(n=>{let s=n.clone();return s.dictionary=t,s});return new r(e)}return this}};Kg=Symbol.toStringTag;v[Kg]=(r=>{r.type=w.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0,r[Jg]=!0;let t=Object.keys(p).map(e=>p[e]).filter(e=>typeof e=="number"&&e!==p.NONE);for(let e of t){let n=Pt.getVisitFnByTypeId(e),s=Qt.getVisitFnByTypeId(e),i=pi.getVisitFnByTypeId(e);Qg[e]={get:n,set:s,indexOf:i},t0[e]=Object.create(r,{isValid:{value:Mo(Ga)},get:{value:Mo(Pt.getVisitFnByTypeId(e))},set:{value:yl(Qt.getVisitFnByTypeId(e))},indexOf:{value:gl(pi.getVisitFnByTypeId(e))}})}return"Vector"})(v.prototype);Object.defineProperty(v,Symbol.hasInstance,{value:function(t){return Function.prototype[Symbol.hasInstance].call(this,t)||this===v&&v.isVector(t)}});Al=class r extends v{constructor(t){super(t.data);let e=this.get,n=this.set,s=this.slice,i=new Array(this.length);Object.defineProperty(this,"get",{value(o){let a=i[o];if(a!==void 0)return a;let c=e.call(this,o);return i[o]=c,c}}),Object.defineProperty(this,"set",{value(o,a){n.call(this,o,a),i[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new r(s.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new v(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}});function e0(r){if(!r||r.length<=0)return function(s){return!0};let t="",e=r.filter(n=>n===n);return e.length>0&&(t=`
|
|
8
8
|
switch (x) {${e.map(n=>`
|
|
9
|
-
case ${
|
|
9
|
+
case ${gv(n)}:`).join("")}
|
|
10
10
|
return false;
|
|
11
11
|
}`),r.length!==e.length&&(t=`if (x !== x) return false;
|
|
12
12
|
${t}`),new Function("x",`${t}
|
|
13
|
-
return true;`)}function bv(r){return typeof r!="bigint"?Mr(r):`${Mr(r)}n`}var p0=p(()=>{Aa()});function rh(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function m0(r,t=0){return r.length>=t?r.subarray(0,t):ia(new r.constructor(t),r,0)}var qe,wn,Bo,ps,Nr=p(()=>{Gt();qe=class{constructor(t,e=0,n=1){this.length=Math.ceil(e/n),this.buffer=new t(this.length),this.stride=n,this.BYTES_PER_ELEMENT=t.BYTES_PER_ELEMENT,this.ArrayType=t}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(t,e){return this}append(t){return this.set(this.length,t)}reserve(t){if(t>0){this.length+=t;let e=this.stride,n=this.length*e,s=this.buffer.length;n>=s&&this._resize(s===0?rh(n*1,this.BYTES_PER_ELEMENT):rh(n*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=rh(t*this.stride,this.BYTES_PER_ELEMENT);let e=m0(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=m0(this.buffer,t)}},wn=class extends qe{last(){return this.get(this.length-1)}get(t){return this.buffer[t]}set(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this}},Bo=class extends wn{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(t){return this.buffer[t>>3]>>t%8&1}set(t,e){let{buffer:n}=this.reserve(t-this.length+1),s=t>>3,i=t%8,o=n[s]>>i&1;return e?o===0&&(n[s]|=1<<i,++this.numValid):o===1&&(n[s]&=~(1<<i),--this.numValid),this}clear(){return this.numValid=0,super.clear()}},ps=class extends wn{constructor(t){super(t.OffsetArrayType,1,1)}append(t){return this.set(this.length-1,t)}set(t,e){let n=this.length-1,s=this.reserve(t-n+1).buffer;return n<t++&&n>=0&&s.fill(s[n],n,t),s[t]=s[t-1]+e,this}flush(t=this.length-1){return t>this.length&&this.set(t-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(t+1)}}});var bt,kt,de,vt=p(()=>{he();hr();Ca();yt();p0();Nr();bt=class{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t){throw new Error('"throughDOM" not available in this environment')}constructor({type:t,nullValues:e}){this.length=0,this.finished=!1,this.type=t,this.children=[],this.nullValues=e,this.stride=er(t),this._nulls=new Bo,e&&e.length>0&&(this._isValid=d0(e))}toVector(){return new A([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0,{_offsets:e,_values:n,_nulls:s,_typeIds:i,children:o}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),s&&(t+=s.byteLength),i&&(t+=i.byteLength),o.reduce((a,c)=>a+c.byteLength,t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce((e,n)=>e+n.reservedByteLength,t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(t){return this.children[t]||null}flush(){let t,e,n,s,{type:i,length:o,nullCount:a,_typeIds:c,_offsets:l,_values:u,_nulls:f}=this;(e=c?.flush(o))?s=l?.flush(o):(s=l?.flush(o))?t=u?.flush(l.last()):t=u?.flush(o),a>0&&(n=f?.flush(o));let h=this.children.map(m=>m.flush());return this.clear(),M({type:i,length:o,nullCount:a,children:h,child:h[0],data:t,typeIds:e,nullBitmap:n,valueOffsets:s})}finish(){this.finished=!0;for(let t of this.children)t.finish();return this}clear(){var t,e,n,s;this.length=0,(t=this._nulls)===null||t===void 0||t.clear(),(e=this._values)===null||e===void 0||e.clear(),(n=this._offsets)===null||n===void 0||n.clear(),(s=this._typeIds)===null||s===void 0||s.clear();for(let i of this.children)i.clear();return this}};bt.prototype.length=1;bt.prototype.stride=1;bt.prototype.children=null;bt.prototype.finished=!1;bt.prototype.nullValues=null;bt.prototype._isValid=()=>!0;kt=class extends bt{constructor(t){super(t),this._values=new wn(this.ArrayType,0,this.stride)}setValue(t,e){let n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}},de=class extends bt{constructor(t){super(t),this._pendingLength=0,this._offsets=new ps(t.type)}setValue(t,e){let n=this._pending||(this._pending=new Map),s=n.get(t);s&&(this._pendingLength-=s.length),this._pendingLength+=e instanceof fr?e[hs].length:e.length,n.set(t,e)}setValid(t,e){return super.setValid(t,e)?!0:((this._pending||(this._pending=new Map)).set(t,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this}}});var fi,nh=p(()=>{fi=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,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()}}});var nr,y0=p(()=>{nt();nh();uo();vc();Cf();nr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):ht.V1}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new ke).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new fi).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}dictionariesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,e){let n=this.bb.__offset(this.bb_pos,10);return n?(e||new fi).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}recordBatchesLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Tt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,ht.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)}}});function al(r,t){return new Map([...r||new Map,...t||new Map])}function sh(r,t=new Map){for(let e=-1,n=r.length;++e<n;){let i=r[e].type;if(w.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&&sh(i.children,t)}return t}var g0,b0,G,S,pe=p(()=>{Mt();yt();g0=Symbol.for("apache-arrow/Schema"),b0=Symbol.for("apache-arrow/Field"),G=class r{static isSchema(t){return t?.[g0]===!0}constructor(t=[],e,n,s=ht.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=sh(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){let e=new Set(t),n=this.fields.filter(s=>e.has(s.name));return new r(n,this.metadata)}selectAt(t){let e=t.map(n=>this.fields[n]).filter(Boolean);return new r(e,this.metadata)}assign(...t){let e=t[0]instanceof r?t[0]:Array.isArray(t[0])?new r(t[0]):new r(t),n=[...this.fields],s=al(al(new Map,this.metadata),e.metadata),i=e.fields.filter(a=>{let c=n.findIndex(l=>l.name===a.name);return~c?(n[c]=a.clone({metadata:al(al(new Map,n[c].metadata),a.metadata)}))&&!1:!0}),o=sh(i,new Map);return new r([...n,...i],s,new Map([...this.dictionaries,...o]))}};G.prototype.fields=null;G.prototype.metadata=null;G.prototype.dictionaries=null;G.prototype[g0]=!0;Object.defineProperty(G,Symbol.hasInstance,{value:function(t){return Function.prototype[Symbol.hasInstance].call(this,t)||this===G&&G.isSchema(t)}});S=class r{static isField(t){return t?.[b0]===!0}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 r(`${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],r.new(e,n,s,i)}};S.prototype.type=null;S.prototype.name=null;S.prototype.nullable=null;S.prototype.metadata=null;S.prototype[b0]=!0;Object.defineProperty(S,Symbol.hasInstance,{value:function(t){return Function.prototype[Symbol.hasInstance].call(this,t)||this===S&&S.isField(t)}})});var wv,xv,xn,ih,Rr,oh=p(()=>{nh();y0();nt();pe();Mt();Gt();Xr();wv=ri,xv=Zt,xn=class{static decode(t){t=new xv(O(t));let e=nr.getRootAsFooter(t),n=G.decode(e.schema(),new Map,e.version());return new ih(n,e)}static encode(t){let e=new wv,n=G.encode(e,t.schema);nr.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())Rr.encode(e,o);let s=e.endVector();nr.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())Rr.encode(e,o);let i=e.endVector();return nr.startFooter(e),nr.addSchema(e,n),nr.addVersion(e,ht.V5),nr.addRecordBatches(e,s),nr.addDictionaries(e,i),nr.finishFooterBuffer(e,nr.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=ht.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}},ih=class extends xn{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,e){super(t,e.version()),this._footer=e}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){let e=this._footer.recordBatches(t);if(e)return Rr.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return Rr.decode(e)}return null}},Rr=class r{static decode(t){return new r(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,e){let{metaDataLength:n}=e,s=BigInt(e.offset),i=BigInt(e.bodyLength);return fi.createBlock(t,s,n,i)}constructor(t,e,n){this.metaDataLength=t,this.offset=J(n),this.bodyLength=J(e)}}});var sr,w0=p(()=>{nt();uo();Tc();vc();sr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):ht.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):Q.NONE}header(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Tt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,ht.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,Q.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,o){return r.startMessage(t),r.addVersion(t,e),r.addHeaderType(t,n),r.addHeader(t,s),r.addBodyLength(t,i),r.addCustomMetadata(t,o),r.endMessage(t)}}});var ah,cl,x0=p(()=>{je();Gm();_c();If();Um();Nm();Pm();Rm();qm();$m();zm();xf();wf();Lf();Tf();Bf();vf();Vm();km();jm();Mf();bf();Af();Sf();_f();ah=class extends F{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return ba.startNull(e),ba.endNull(e)}visitInt(t,e){return Lr.startInt(e),Lr.addBitWidth(e,t.bitWidth),Lr.addIsSigned(e,t.isSigned),Lr.endInt(e)}visitFloat(t,e){return Xn.startFloatingPoint(e),Xn.addPrecision(e,t.precision),Xn.endFloatingPoint(e)}visitBinary(t,e){return fa.startBinary(e),fa.endBinary(e)}visitBinaryView(t,e){return ha.startBinaryView(e),ha.endBinaryView(e)}visitLargeBinary(t,e){return pa.startLargeBinary(e),pa.endLargeBinary(e)}visitBool(t,e){return da.startBool(e),da.endBool(e)}visitUtf8(t,e){return xa.startUtf8(e),xa.endUtf8(e)}visitUtf8View(t,e){return va.startUtf8View(e),va.endUtf8View(e)}visitLargeUtf8(t,e){return ya.startLargeUtf8(e),ya.endLargeUtf8(e)}visitDecimal(t,e){return Hr.startDecimal(e),Hr.addScale(e,t.scale),Hr.addPrecision(e,t.precision),Hr.addBitWidth(e,t.bitWidth),Hr.endDecimal(e)}visitDate(t,e){return Wn.startDate(e),Wn.addUnit(e,t.unit),Wn.endDate(e)}visitTime(t,e){return mn.startTime(e),mn.addUnit(e,t.unit),mn.addBitWidth(e,t.bitWidth),mn.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return yn.startTimestamp(e),yn.addUnit(e,t.unit),n!==void 0&&yn.addTimezone(e,n),yn.endTimestamp(e)}visitInterval(t,e){return Kn.startInterval(e),Kn.addUnit(e,t.unit),Kn.endInterval(e)}visitDuration(t,e){return Yn.startDuration(e),Yn.addUnit(e,t.unit),Yn.endDuration(e)}visitList(t,e){return ga.startList(e),ga.endList(e)}visitLargeList(t,e){return ma.startLargeList(e),ma.endLargeList(e)}visitStruct(t,e){return wa.startStruct_(e),wa.endStruct_(e)}visitUnion(t,e){Tr.startTypeIdsVector(e,t.typeIds.length);let n=Tr.createTypeIdsVector(e,t.typeIds);return Tr.startUnion(e),Tr.addMode(e,t.mode),Tr.addTypeIds(e,n),Tr.endUnion(e)}visitDictionary(t,e){let n=this.visit(t.indices,e);return Zr.startDictionaryEncoding(e),Zr.addId(e,BigInt(t.id)),Zr.addIsOrdered(e,t.isOrdered),n!==void 0&&Zr.addIndexType(e,n),Zr.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Zn.startFixedSizeBinary(e),Zn.addByteWidth(e,t.byteWidth),Zn.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Hn.startFixedSizeList(e),Hn.addListSize(e,t.listSize),Hn.endFixedSizeList(e)}visitMap(t,e){return Jn.startMap(e),Jn.addKeysSorted(e,t.keysSorted),Jn.endMap(e)}},cl=new ah});function I0(r,t=new Map){return new G(vv(r,t),ll(r.metadata),t)}function ch(r){return new zt(r.count,_0(r.columns),L0(r.columns),null,T0(r.columns))}function B0(r){return new me(ch(r.data),r.id,r.isDelta)}function vv(r,t){return(r.fields||[]).filter(Boolean).map(e=>S.fromJSON(e,t))}function v0(r,t){return(r.children||[]).filter(Boolean).map(e=>S.fromJSON(e,t))}function _0(r){return(r||[]).reduce((t,e)=>[...t,new dr(e.count,Av(e.VALIDITY)),..._0(e.children)],[])}function L0(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let s=r[e];if(s.VALIDITY&&t.push(new Ut(t.length,s.VALIDITY.length)),s.TYPE_ID&&t.push(new Ut(t.length,s.TYPE_ID.length)),s.OFFSET&&t.push(new Ut(t.length,s.OFFSET.length)),s.DATA&&t.push(new Ut(t.length,s.DATA.length)),s.VIEWS&&t.push(new Ut(t.length,s.VIEWS.length)),s.VARIADIC_DATA_BUFFERS)for(let i of s.VARIADIC_DATA_BUFFERS)t.push(new Ut(t.length,i.length));t=L0(s.children,t)}return t}function Av(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function T0(r){return(r||[]).reduce((t,e)=>[...t,...e.VARIADIC_DATA_BUFFERS?[e.VARIADIC_DATA_BUFFERS.length]:[],...T0(e.children)],[])}function M0(r,t){let e,n,s,i,o,a;return!t||!(i=r.dictionary)?(o=S0(r,v0(r,t)),s=new S(r.name,o,r.nullable,ll(r.metadata))):t.has(e=i.id)?(n=(n=i.indexType)?A0(n):new Dt,a=new Rt(t.get(e),n,e,i.isOrdered),s=new S(r.name,a,r.nullable,ll(r.metadata))):(n=(n=i.indexType)?A0(n):new Dt,t.set(e,o=S0(r,v0(r,t))),a=new Rt(o,n,e,i.isOrdered),s=new S(r.name,a,r.nullable,ll(r.metadata))),s||null}function ll(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function A0(r){return new Lt(r.isSigned,r.bitWidth)}function S0(r,t){let e=r.type.name;switch(e){case"NONE":return new Et;case"null":return new Et;case"binary":return new ze;case"largebinary":return new Or;case"binaryview":return new H;case"utf8":return new ce;case"largeutf8":return new Er;case"utf8view":return new Le;case"bool":return new le;case"list":return new Ct((t||[])[0]);case"largelist":return new tr((t||[])[0]);case"struct":return new ut(t||[]);case"struct_":return new ut(t||[])}switch(e){case"int":{let n=r.type;return new Lt(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new ae(ot[n.precision])}case"decimal":{let n=r.type;return new Ve(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new Te(mt[n.unit])}case"time":{let n=r.type;return new Kt(v[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new Jt(v[n.unit],n.timezone)}case"interval":{let n=r.type;return new ue(et[n.unit])}case"duration":{let n=r.type;return new Me(v[n.unit])}case"union":{let n=r.type,[s,...i]=(n.mode+"").toLowerCase(),o=s.toUpperCase()+i.join("");return new De(lt[o],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new Ge(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new gt(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new fe((t||[])[0],n.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var D0=p(()=>{pe();yt();ms();Mt()});function Bv(r,t){return(()=>{switch(t){case Q.Schema:return G.fromJSON(r);case Q.RecordBatch:return zt.fromJSON(r);case Q.DictionaryBatch:return me.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${Q[t]}, type: ${t} }`)})}function _v(r,t){return(()=>{switch(t){case Q.Schema:return G.decode(r.header(new ke),new Map,r.version());case Q.RecordBatch:return zt.decode(r.header(new ie),r.version());case Q.DictionaryBatch:return me.decode(r.header(new pn),r.version())}throw new Error(`Unrecognized Message type: { name: ${Q[t]}, type: ${t} }`)})}function Lv(r,t=new Map,e=ht.V5){let n=Uv(r,t);return new G(n,ul(r),t,e)}function Tv(r,t=ht.V5){return new zt(r.length(),Fv(r),Ov(r,t),E0(r.compression()),Ev(r))}function Mv(r,t=ht.V5){return new me(zt.decode(r.data(),t),r.id(),r.isDelta())}function Dv(r){return new Ut(r.offset(),r.length())}function Cv(r){return new dr(r.length(),r.nullCount())}function Fv(r){let t=[];for(let e,n=-1,s=-1,i=r.nodesLength();++n<i;)(e=r.nodes(n))&&(t[++s]=dr.decode(e));return t}function Ov(r,t){let e=[];for(let n,s=-1,i=-1,o=r.buffersLength();++s<o;)(n=r.buffers(s))&&(t<ht.V4&&(n.bb_pos+=8*(s+1)),e[++i]=Ut.decode(n));return e}function Ev(r){let t=[],e=Math.trunc(r.variadicBufferCountsLength());for(let n=0;n<e;++n)t.push(J(r.variadicBufferCounts(n)));return t}function Uv(r,t){let e=[];for(let n,s=-1,i=-1,o=r.fieldsLength();++s<o;)(n=r.fields(s))&&(e[++i]=S.decode(n,t));return e}function C0(r,t){let e=[];for(let n,s=-1,i=-1,o=r.childrenLength();++s<o;)(n=r.children(s))&&(e[++i]=S.decode(n,t));return e}function Nv(r,t){let e,n,s,i,o,a;return!t||!(a=r.dictionary())?(s=O0(r,C0(r,t)),n=new S(r.name(),s,r.nullable(),ul(r))):t.has(e=J(a.id()))?(i=(i=a.indexType())?F0(i):new Dt,o=new Rt(t.get(e),i,e,a.isOrdered()),n=new S(r.name(),o,r.nullable(),ul(r))):(i=(i=a.indexType())?F0(i):new Dt,t.set(e,s=O0(r,C0(r,t))),o=new Rt(s,i,e,a.isOrdered()),n=new S(r.name(),o,r.nullable(),ul(r))),n||null}function ul(r){let 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 Rv(r){let t=new Map;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 F0(r){return new Lt(r.isSigned(),r.bitWidth())}function O0(r,t){let e=r.typeType();switch(e){case k.NONE:return new Et;case k.Null:return new Et;case k.Binary:return new ze;case k.LargeBinary:return new Or;case k.BinaryView:return new H;case k.Utf8:return new ce;case k.LargeUtf8:return new Er;case k.Utf8View:return new Le;case k.Bool:return new le;case k.List:return new Ct((t||[])[0]);case k.LargeList:return new tr((t||[])[0]);case k.Struct_:return new ut(t||[])}switch(e){case k.Int:{let n=r.type(new Lr);return new Lt(n.isSigned(),n.bitWidth())}case k.FloatingPoint:{let n=r.type(new Xn);return new ae(n.precision())}case k.Decimal:{let n=r.type(new Hr);return new Ve(n.scale(),n.precision(),n.bitWidth())}case k.Date:{let n=r.type(new Wn);return new Te(n.unit())}case k.Time:{let n=r.type(new mn);return new Kt(n.unit(),n.bitWidth())}case k.Timestamp:{let n=r.type(new yn);return new Jt(n.unit(),n.timezone())}case k.Interval:{let n=r.type(new Kn);return new ue(n.unit())}case k.Duration:{let n=r.type(new Yn);return new Me(n.unit())}case k.Union:{let n=r.type(new Tr);return new De(n.mode(),n.typeIdsArray()||[],t||[])}case k.FixedSizeBinary:{let n=r.type(new Zn);return new Ge(n.byteWidth())}case k.FixedSizeList:{let n=r.type(new Hn);return new gt(n.listSize(),(t||[])[0])}case k.Map:{let n=r.type(new Jn);return new fe((t||[])[0],n.keysSorted())}}throw new Error(`Unrecognized type: "${k[e]}" (${e})`)}function E0(r){return r?new hi(r.codec(),r.method()):null}function Pv(r,t){let e=t.fields.map(i=>S.encode(r,i));ke.startFieldsVector(r,e.length);let n=ke.createFieldsVector(r,e),s=t.metadata&&t.metadata.size>0?ke.createCustomMetadataVector(r,[...t.metadata].map(([i,o])=>{let a=r.createString(`${i}`),c=r.createString(`${o}`);return Tt.startKeyValue(r),Tt.addKey(r,a),Tt.addValue(r,c),Tt.endKeyValue(r)})):-1;return ke.startSchema(r),ke.addFields(r,n),ke.addEndianness(r,qv?$n.Little:$n.Big),s!==-1&&ke.addCustomMetadata(r,s),ke.endSchema(r)}function kv(r,t){let e=-1,n=-1,s=-1,i=t.type,o=t.typeId;w.isDictionary(i)?(o=i.dictionary.typeId,s=cl.visit(i,r),n=cl.visit(i.dictionary,r)):n=cl.visit(i,r);let a=(i.children||[]).map(u=>S.encode(r,u)),c=oe.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?oe.createCustomMetadataVector(r,[...t.metadata].map(([u,f])=>{let h=r.createString(`${u}`),m=r.createString(`${f}`);return Tt.startKeyValue(r),Tt.addKey(r,h),Tt.addValue(r,m),Tt.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),oe.startField(r),oe.addType(r,n),oe.addTypeType(r,o),oe.addChildren(r,c),oe.addNullable(r,!!t.nullable),e!==-1&&oe.addName(r,e),s!==-1&&oe.addDictionary(r,s),l!==-1&&oe.addCustomMetadata(r,l),oe.endField(r)}function zv(r,t){let e=t.nodes||[],n=t.buffers||[],s=t.variadicBufferCounts||[];ie.startNodesVector(r,e.length);for(let l of e.slice().reverse())dr.encode(r,l);let i=r.endVector();ie.startBuffersVector(r,n.length);for(let l of n.slice().reverse())Ut.encode(r,l);let o=r.endVector(),a=null;t.compression!==null&&(a=U0(r,t.compression));let c=-1;return s.length>0&&(c=ie.createVariadicBufferCountsVector(r,s.map(BigInt))),ie.startRecordBatch(r),ie.addLength(r,BigInt(t.length)),ie.addNodes(r,i),ie.addBuffers(r,o),t.compression!==null&&a&&ie.addCompression(r,a),c!==-1&&ie.addVariadicBufferCounts(r,c),ie.endRecordBatch(r)}function U0(r,t){return dn.startBodyCompression(r),dn.addCodec(r,t.type),dn.addMethod(r,t.method),dn.endBodyCompression(r)}function Vv(r,t){let e=zt.encode(r,t.data);return pn.startDictionaryBatch(r),pn.addId(r,BigInt(t.id)),pn.addIsDelta(r,t.isDelta),pn.addData(r,e),pn.endDictionaryBatch(r)}function Gv(r,t){return lo.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function jv(r,t){return co.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var Sv,Iv,ye,zt,me,Ut,dr,hi,qv,ms=p(()=>{nt();Cf();_c();yf();Om();pf();Df();mf();Lc();uo();gf();If();xf();wf();Lf();Tf();Bf();vf();Mf();Af();Sf();_f();w0();df();hf();pe();Gt();Xr();Mt();x0();D0();yt();Sv=ri,Iv=Zt,ye=class r{static fromJSON(t,e){let n=new r(0,ht.V5,e);return n._createHeader=Bv(t,e),n}static decode(t){t=new Iv(O(t));let e=sr.getRootAsMessage(t),n=e.bodyLength(),s=e.version(),i=e.headerType(),o=Rv(e),a=new r(n,s,i,void 0,o);return a._createHeader=_v(e,i),a}static encode(t){let e=new Sv,n=-1;t.isSchema()?n=G.encode(e,t.header()):t.isRecordBatch()?n=zt.encode(e,t.header()):t.isDictionaryBatch()&&(n=me.encode(e,t.header()));let s=t.metadata&&t.metadata.size>0?sr.createCustomMetadataVector(e,[...t.metadata].map(([i,o])=>{let a=e.createString(`${i}`),c=e.createString(`${o}`);return Tt.startKeyValue(e),Tt.addKey(e,a),Tt.addValue(e,c),Tt.endKeyValue(e)})):-1;return sr.startMessage(e),sr.addVersion(e,ht.V5),sr.addHeader(e,n),sr.addHeaderType(e,t.headerType),sr.addBodyLength(e,BigInt(t.bodyLength)),s!==-1&&sr.addCustomMetadata(e,s),sr.finishMessageBuffer(e,sr.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof G)return new r(0,ht.V5,Q.Schema,t);if(t instanceof zt)return new r(e,ht.V5,Q.RecordBatch,t,t.metadata);if(t instanceof me)return new r(e,ht.V5,Q.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get compression(){return this._compression}get bodyLength(){return this._bodyLength}get metadata(){return this._metadata}header(){return this._createHeader()}isSchema(){return this.headerType===Q.Schema}isRecordBatch(){return this.headerType===Q.RecordBatch}isDictionaryBatch(){return this.headerType===Q.DictionaryBatch}constructor(t,e,n,s,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),this._compression=s?.compression,s&&(this._createHeader=()=>s),this._bodyLength=J(t),this._metadata=i||new Map}},zt=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}get compression(){return this._compression}get variadicBufferCounts(){return this._variadicBufferCounts}get metadata(){return this._metadata}constructor(t,e,n,s,i=[],o){this._nodes=e,this._buffers=n,this._length=J(t),this._compression=s,this._variadicBufferCounts=i,this._metadata=o||new Map}},me=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,e,n=!1){this._data=t,this._isDelta=n,this._id=J(e)}},Ut=class{constructor(t,e){this.offset=J(t),this.length=J(e)}},dr=class{constructor(t,e){this.length=J(t),this.nullCount=J(e)}},hi=class{constructor(t,e=ni.BUFFER){this.type=t,this.method=e}};S.encode=kv;S.decode=Nv;S.fromJSON=M0;G.encode=Pv;G.decode=Lv;G.fromJSON=I0;zt.encode=zv;zt.decode=Tv;zt.fromJSON=ch;me.encode=Vv;me.decode=Mv;me.fromJSON=B0;dr.encode=Gv;dr.decode=Cv;Ut.encode=jv;Ut.decode=Dv;hi.encode=U0;hi.decode=E0;qv=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})()});var At,Na,di,fl,Ra=p(()=>{Pe();aa();At=Object.freeze({done:!0,value:void 0}),Na=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},di=class{tee(){return this._getDOMStream().tee()}pipe(t,e){return this._getNodeStream().pipe(t,e)}pipeTo(t,e){return this._getDOMStream().pipeTo(t,e)}pipeThrough(t,e){return this._getDOMStream().pipeThrough(t,e)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}},fl=class extends di{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return B(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){let{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(At);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Yt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Yt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return B(this,void 0,void 0,function*(){return yield this.abort(t),At})}return(t){return B(this,void 0,void 0,function*(){return yield this.close(),At})}read(t){return B(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return B(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(At)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}});var pr,mr,$e,lh,vn,ys=p(()=>{Pe();aa();hn();Ra();Gt();qn();pr=class extends fl{write(t){if((t=O(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?io(this.toUint8Array(!0)):this.toUint8Array(!1).then(io)}toUint8Array(t=!1){return t?Je(this._values)[0]:B(this,void 0,void 0,function*(){var e,n,s,i;let o=[],a=0;try{for(var c=!0,l=He(this),u;u=yield l.next(),e=u.done,!e;c=!0){i=u.value,c=!1;let f=i;o.push(f),a+=f.byteLength}}catch(f){n={error:f}}finally{try{!c&&!e&&(s=l.return)&&(yield s.call(l))}finally{if(n)throw n.error}}return Je(o,a)[0]})}},mr=class{constructor(t){t&&(this.source=new lh(Yt.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)}},$e=class r{constructor(t){t instanceof r?this.source=t.source:t instanceof pr?this.source=new vn(Yt.fromAsyncIterable(t)):bc(t)?this.source=new vn(Yt.fromNodeStream(t)):sa(t)?this.source=new vn(Yt.fromDOMStream(t)):yc(t)?this.source=new vn(Yt.fromDOMStream(t.body)):Ir(t)?this.source=new vn(Yt.fromIterable(t)):Ke(t)?this.source=new vn(Yt.fromAsyncIterable(t)):lr(t)&&(this.source=new vn(Yt.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)}},lh=class{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,e="read"){return this.source.next({cmd:e,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||At)}return(t){return Object.create(this.source.return&&this.source.return(t)||At)}},vn=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return B(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return B(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return B(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return B(this,arguments,void 0,function*(e,n="read"){return yield this.source.next({cmd:n,size:e})})}throw(t){return B(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||At;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return B(this,void 0,void 0,function*(){let e=this.source.return&&(yield this.source.return(t))||At;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}}});var Pa,gs,uh=p(()=>{Pe();ys();Gt();Pa=class extends mr{constructor(t,e){super(),this.position=0,this.buffer=O(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){let{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){let{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){let 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}}},gs=class extends $e{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=B(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return B(this,void 0,void 0,function*(){let{buffer:e,byteOffset:n}=yield this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)})}seek(t){return B(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 B(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size:n,position:s}=this;if(e&&s<n){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let i=s,o=0,a=0,c=Math.min(n,i+Math.min(n-i,t)),l=new Uint8Array(Math.max(0,(this.position=c)-i));for(;(i+=a)<c&&(o+=a)<l.byteLength;)({bytesRead:a}=yield e.read(l,o,l.byteLength-o,i));return l}return null})}readAt(t,e){return B(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:n,size:s}=this;if(n&&t+e<s){let i=Math.min(s,t+e),o=new Uint8Array(i-t);return(yield n.read(o,0,e,t)).buffer}return new Uint8Array(e)})}close(){return B(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return B(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return B(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}}});var hh={};Re(hh,{BaseInt64:()=>ka,Int128:()=>za,Int64:()=>An,Uint64:()=>Ft});function _o(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}var Lo,fh,ka,Ft,An,za,dh=p(()=>{Lo=8,fh=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],ka=class{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){let e=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]),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?65536: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){let e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return`${_o(this.buffer[1])} ${_o(this.buffer[0])}`}},Ft=class r extends ka{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,e=new Uint32Array(2)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.length,s=new r(e);for(let i=0;i<n;){let o=Lo<n-i?Lo:n-i,a=new r(new Uint32Array([Number.parseInt(t.slice(i,i+o),10),0])),c=new r(new Uint32Array([fh[o],0]));s.times(c),s.plus(a),i+=o}return s}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,s=t.length;++n<s;)r.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}},An=class r extends ka{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(t){return this._times(t),this}plus(t){return this._plus(t),this}lessThan(t){let e=this.buffer[1]<<0,n=t.buffer[1]<<0;return e<n||e===n&&this.buffer[0]<t.buffer[0]}static from(t,e=new Uint32Array(2)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.startsWith("-"),s=t.length,i=new r(e);for(let o=n?1:0;o<s;){let a=Lo<s-o?Lo:s-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new r(new Uint32Array([fh[a],0]));i.times(l),i.plus(c),o+=a}return n?i.negate():i}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,s=t.length;++n<s;)r.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}},za=class r{constructor(t){this.buffer=t}high(){return new An(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new An(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){let e=new Ft(new Uint32Array([this.buffer[3],0])),n=new Ft(new Uint32Array([this.buffer[2],0])),s=new Ft(new Uint32Array([this.buffer[1],0])),i=new Ft(new Uint32Array([this.buffer[0],0])),o=new Ft(new Uint32Array([t.buffer[3],0])),a=new Ft(new Uint32Array([t.buffer[2],0])),c=new Ft(new Uint32Array([t.buffer[1],0])),l=new Ft(new Uint32Array([t.buffer[0],0])),u=Ft.multiply(i,l);this.buffer[0]=u.low();let f=new Ft(new Uint32Array([u.high(),0]));return u=Ft.multiply(s,l),f.plus(u),u=Ft.multiply(i,c),f.plus(u),this.buffer[1]=f.low(),this.buffer[3]=f.lessThan(u)?1:0,this.buffer[2]=f.high(),new Ft(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(Ft.multiply(n,l)).plus(Ft.multiply(s,c)).plus(Ft.multiply(i,a)),this.buffer[3]+=Ft.multiply(e,l).plus(Ft.multiply(n,c)).plus(Ft.multiply(s,a)).plus(Ft.multiply(i,o)).low(),this}plus(t){let e=new Uint32Array(4);return e[3]=this.buffer[3]+t.buffer[3]>>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]<this.buffer[0]>>>0&&++e[1],e[1]<this.buffer[1]>>>0&&++e[2],e[2]<this.buffer[2]>>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return`${_o(this.buffer[3])} ${_o(this.buffer[2])} ${_o(this.buffer[1])} ${_o(this.buffer[0])}`}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){let n=t.startsWith("-"),s=t.length,i=new r(e);for(let o=n?1:0;o<s;){let a=Lo<s-o?Lo:s-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new r(new Uint32Array([fh[a],0,0,0]));i.times(l),i.plus(c),o+=a}return n?i.negate():i}static convertArray(t){let e=new Uint32Array(t.length*4);for(let n=-1,s=t.length;++n<s;)r.from(t[n],new Uint32Array(e.buffer,e.byteOffset+16*n,4));return e}}});var bh={};Re(bh,{toIntervalDayTimeInt32Array:()=>ph,toIntervalDayTimeObjects:()=>yh,toIntervalMonthDayNanoInt32Array:()=>mh,toIntervalMonthDayNanoObjects:()=>gh});function ph(r){var t,e;let n=r.length,s=new Int32Array(n*2);for(let i=0,o=0;i<n;i++){let a=r[i];s[o++]=(t=a.days)!==null&&t!==void 0?t:0,s[o++]=(e=a.milliseconds)!==null&&e!==void 0?e:0}return s}function mh(r){var t,e;let n=r.length,s=new Int32Array(n*4);for(let i=0,o=0;i<n;i++){let a=r[i];s[o++]=(t=a.months)!==null&&t!==void 0?t:0,s[o++]=(e=a.days)!==null&&e!==void 0?e:0;let c=a.nanoseconds;if(c){let l=BigInt(c);s[o++]=Number(l&BigInt(4294967295))>>>0,s[o++]=Number(l>>BigInt(32))>>>0}else o+=2}return s}function yh(r){let t=r.length,e=new Array(t/2);for(let n=0,s=0;n<t;n+=2)e[s++]={days:r[n],milliseconds:r[n+1]};return e}function gh(r,t){let e=r.length,n=new Array(e/4);for(let s=0,i=0;s<e;s+=4){let o=BigInt(r[s+3])<<BigInt(32)|BigInt(r[s+2]>>>0);n[i++]={months:r[s],days:r[s+1],nanoseconds:t?`${o}`:o}}return n}var hl=p(()=>{});function R0(r){let t=new Uint8Array(r.length/2);for(let e=0;e<r.length;e+=2)t[e>>1]=Number.parseInt(r.slice(e,e+2),16);return t}function $v(r){return R0(r.join(""))}function P0(r,t){let e=new Uint8Array(r.length*16),n=new DataView(e.buffer);for(let[s,i]of r.entries()){let o=s*16,a=i.SIZE;if(n.setInt32(o,a,!0),i.INLINED!==void 0){let c=t(i.INLINED);for(let l=0;l<c.length&&l<12;l++)e[o+4+l]=c[l]}else{let c=i.PREFIX_HEX;for(let l=0;l<8&&l<c.length;l+=2)e[o+4+(l>>1)]=Number.parseInt(c.slice(l,l+2),16);n.setInt32(o+8,i.BUFFER_INDEX,!0),n.setInt32(o+12,i.OFFSET,!0)}}return e}function Wv(r){return P0(r,t=>{let 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})}function Yv(r){return P0(r,t=>new TextEncoder().encode(t))}var To,dl,pl,k0=p(()=>{hr();pe();yt();je();li();hn();dh();Mt();Gt();hl();To=class extends F{constructor(t,e,n,s,i=ht.V5,o=[]){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.variadicBufferIndex=-1,this.bytes=t,this.nodes=e,this.buffers=n,this.dictionaries=s,this.metadataVersion=i,this.variadicBufferCounts=o}visit(t){return super.visit(t instanceof S?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return M({type:t,length:e})}visitBool(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitInt(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({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 M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitUtf8View(t,{length:e,nullCount:n}=this.nextFieldNode()){let s=this.readNullBitmap(t,n),i=this.readData(t),o=this.readVariadicBuffers(this.nextVariadicBufferCount());return M({type:t,length:e,nullCount:n,nullBitmap:s,views:i,variadicBuffers:o})}visitBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({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 M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinaryView(t,{length:e,nullCount:n}=this.nextFieldNode()){let s=this.readNullBitmap(t,n),i=this.readData(t),o=this.readVariadicBuffers(this.nextVariadicBufferCount());return M({type:t,length:e,nullCount:n,nullBitmap:s,views:i,variadicBuffers:o})}visitFixedSizeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDate(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTime(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitList(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitLargeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({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 M({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<ht.V5&&this.readNullBitmap(t,n),t.mode===lt.Sparse?this.visitSparseUnion(t,{length:e,nullCount:n}):this.visitDenseUnion(t,{length:e,nullCount:n})}visitDenseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({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 M({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({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 M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({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 M({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)}readVariadicBuffers(t){return Array.from({length:t},()=>this.readData(null))}nextVariadicBufferCount(){var t;return(t=this.variadicBufferCounts[++this.variadicBufferIndex])!==null&&t!==void 0?t:0}readDictionary(t){return this.dictionaries.get(t.id)}},dl=class extends To{constructor(t,e,n,s,i,o=[]){super(new Uint8Array(0),e,n,s,i,o),this.sources=t}readNullBitmap(t,e,{offset:n}=this.nextBufferRange()){return e<=0?new Uint8Array(0):ci(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return K(Uint8Array,K(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return K(Uint8Array,K(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:n}=this;if(w.isTimestamp(t))return K(Uint8Array,An.convertArray(n[e]));if((w.isInt(t)||w.isTime(t))&&t.bitWidth===64||w.isDuration(t))return K(Uint8Array,An.convertArray(n[e]));if(w.isDate(t)&&t.unit===mt.MILLISECOND)return K(Uint8Array,An.convertArray(n[e]));if(w.isDecimal(t))return K(Uint8Array,za.convertArray(n[e]));if(w.isBinary(t)||w.isLargeBinary(t)||w.isFixedSizeBinary(t))return $v(n[e]);if(w.isBinaryView(t))return Wv(n[e]);if(w.isUtf8View(t))return Yv(n[e]);if(w.isBool(t))return ci(n[e]);if(w.isUtf8(t)||w.isLargeUtf8(t))return Xe(n[e].join(""));if(w.isInterval(t))switch(t.unit){case et.DAY_TIME:return ph(n[e]);case et.MONTH_DAY_NANO:return mh(n[e]);default:break}return K(Uint8Array,K(t.ArrayType,n[e].map(s=>+s)))}readVariadicBuffers(t){let e=[];for(let n=0;n<t;n++){let{offset:s}=this.nextBufferRange(),i=this.sources[s];e.push(R0(i))}return e}};pl=class extends To{constructor(t,e,n,s,i,o=[]){super(new Uint8Array(0),e,n,s,i,o),this.bodyChunks=t}readData(t,e=this.nextBufferRange()){return this.bodyChunks[this.buffersIndex]}}});var Sn,ml=p(()=>{Nr();vt();Gt();Sn=class extends de{constructor(t){super(t),this._values=new qe(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,O(e))}_flushPending(t,e){let n=this._offsets,s=this._values.reserve(e).buffer,i=0;for(let[o,a]of t)if(a===void 0)n.set(o,0);else{let c=a.length;s.set(a,i),n.set(o,c),i+=c}}}});var In,yl=p(()=>{Gt();Nr();vt();In=class extends de{constructor(t){super(t),this._values=new qe(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,O(e))}_flushPending(t,e){let n=this._offsets,s=this._values.reserve(e).buffer,i=0;for(let[o,a]of t)if(a===void 0)n.set(o,BigInt(0));else{let c=a.length;s.set(a,i),n.set(o,BigInt(c)),i+=c}}}});var pi,wh=p(()=>{Nr();vt();pi=class extends bt{constructor(t){super(t),this._values=new Bo}setValue(t,e){this._values.set(t,+e)}}});var tn,bs,ws,xh=p(()=>{vt();rr();tn=class extends kt{};tn.prototype._setValue=zf;bs=class extends tn{};bs.prototype._setValue=Cc;ws=class extends tn{};ws.prototype._setValue=Fc});var xs,vh=p(()=>{vt();rr();xs=class extends kt{};xs.prototype._setValue=jf});var mi,Ah=p(()=>{yt();vt();Va();mi=class extends bt{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new Rt(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=Pr({type:this.type.indices,nullValues:e}),this.dictionary=Pr({type:this.type.dictionary,nullValues:null}),typeof n=="function"&&(this.valueToKey=n)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(t){return this.indices.isValid(t)}setValid(t,e){let n=this.indices;return e=n.setValid(t,e),this.length=n.length,e}setValue(t,e){let n=this._keysToIndices,s=this.valueToKey(e),i=n[s];return i===void 0&&(n[s]=i=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,i)}flush(){let t=this.type,e=this._dictionary,n=this.dictionary.toVector(),s=this.indices.flush().clone(t);return s.dictionary=e?e.concat(n):n,this.finished||(this._dictionaryOffset+=n.length),this._dictionary=s.dictionary,this.clear(),s}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(t){return typeof t=="string"?t:`${t}`}}});var vs,Sh=p(()=>{vt();rr();vs=class extends kt{};vs.prototype._setValue=kf});var yi,Ih=p(()=>{pe();vt();yt();yi=class extends bt{setValue(t,e){let[n]=this.children,s=t*this.stride;for(let i=-1,o=this.stride;++i<o;)n.set(s+i,e[i])}setValid(t,e){return super.setValid(t,e)||this.children[0].setValid((t+1)*this.stride-1,!1),e}addChild(t,e="0"){if(this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");let n=this.children.push(t);return this.type=new gt(this.type.listSize,new S(e,t.type,!0)),n}}});var en,gi,bi,wi,Bh=p(()=>{Da();vt();en=class extends kt{setValue(t,e){this._values.set(t,e)}},gi=class extends en{setValue(t,e){super.setValue(t,Ma(e))}},bi=class extends en{},wi=class extends en{}});var kr,As,Ss,Is,_h=p(()=>{vt();rr();kr=class extends kt{};kr.prototype._setValue=qf;As=class extends kr{};As.prototype._setValue=Vc;Ss=class extends kr{};Ss.prototype._setValue=Gc;Is=class extends kr{};Is.prototype._setValue=jc});var yr,Bs,_s,Ls,Ts,Lh=p(()=>{vt();rr();yr=class extends kt{};yr.prototype._setValue=$f;Bs=class extends yr{};Bs.prototype._setValue=qc;_s=class extends yr{};_s.prototype._setValue=$c;Ls=class extends yr{};Ls.prototype._setValue=Wc;Ts=class extends yr{};Ts.prototype._setValue=Yc});var Ce,xi,vi,Ai,Si,Ii,Bi,_i,Li,Th=p(()=>{vt();Ce=class extends kt{setValue(t,e){this._values.set(t,e)}},xi=class extends Ce{},vi=class extends Ce{},Ai=class extends Ce{},Si=class extends Ce{},Ii=class extends Ce{},Bi=class extends Ce{},_i=class extends Ce{},Li=class extends Ce{}});var Ti,Mh=p(()=>{pe();yt();Nr();vt();Ti=class extends de{constructor(t){super(t),this._offsets=new ps(t.type)}addChild(t,e="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new Ct(new S(e,t.type,!0)),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[s,i]of t)if(typeof i>"u")e.set(s,0);else{let o=i,a=o.length,c=e.set(s,a).buffer[s];for(let l=-1;++l<a;)n.set(c+l,o[l])}}}});var Mi,Dh=p(()=>{pe();yt();Nr();Xr();vt();Mi=class extends de{constructor(t){super(t),this._offsets=new ps(t.type)}addChild(t,e="0"){if(this.numChildren>0)throw new Error("LargeListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new tr(new S(e,t.type,!0)),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[s,i]of t)if(typeof i>"u")e.set(s,BigInt(0));else{let o=i,a=o.length,c=J(e.set(s,BigInt(a)).buffer[s]);for(let l=-1;++l<a;)n.set(c+l,o[l])}}}});var Di,Ch=p(()=>{pe();yt();vt();Di=class extends de{set(t,e){return super.set(t,e)}setValue(t,e){let n=e instanceof Map?e:new Map(Object.entries(e)),s=this._pending||(this._pending=new Map),i=s.get(t);i&&(this._pendingLength-=i.size),this._pendingLength+=n.size,s.set(t,n)}addChild(t,e=`${this.numChildren}`){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new fe(new S(e,t.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[s,i]of t)if(i===void 0)e.set(s,0);else{let{[s]:o,[s+1]:a}=e.set(s,i.size).buffer;for(let c of i.entries())if(n.set(o,c),++o>=a)break}}}});var Ci,Fh=p(()=>{vt();Ci=class extends bt{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}}});var Fi,Oh=p(()=>{pe();vt();yt();Fi=class extends bt{setValue(t,e){let{children:n,type:s}=this;switch(Array.isArray(e)||e.constructor){case!0:return s.children.forEach((i,o)=>n[o].set(t,e[o]));case Map:return s.children.forEach((i,o)=>n[o].set(t,e.get(i.name)));default:return s.children.forEach((i,o)=>n[o].set(t,e[i.name]))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach(n=>n.setValid(t,e)),e}addChild(t,e=`${this.numChildren}`){let n=this.children.push(t);return this.type=new ut([...this.type.children,new S(e,t.type,!0)]),n}}});var gr,Ms,Ds,Cs,Fs,Eh=p(()=>{vt();rr();gr=class extends kt{};gr.prototype._setValue=Vf;Ms=class extends gr{};Ms.prototype._setValue=Oc;Ds=class extends gr{};Ds.prototype._setValue=Ec;Cs=class extends gr{};Cs.prototype._setValue=Uc;Fs=class extends gr{};Fs.prototype._setValue=Nc});var br,Os,Es,Us,Ns,Uh=p(()=>{vt();rr();br=class extends kt{};br.prototype._setValue=Gf;Os=class extends br{};Os.prototype._setValue=Rc;Es=class extends br{};Es.prototype._setValue=Pc;Us=class extends br{};Us.prototype._setValue=kc;Ns=class extends br{};Ns.prototype._setValue=zc});var Bn,Oi,Ei,Nh=p(()=>{pe();Nr();vt();yt();Bn=class extends bt{constructor(t){super(t),this._typeIds=new wn(Int8Array,0,1),typeof t.valueToChildTypeId=="function"&&(this._valueToChildTypeId=t.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(t,e){return this.set(this.length,t,e)}set(t,e,n){return n===void 0&&(n=this._valueToChildTypeId(this,e,t)),this.setValue(t,e,n),this}setValue(t,e,n){this._typeIds.set(t,n);let s=this.type.typeIdToChildIndex[n],i=this.children[s];i?.set(t,e),this.length=Math.max(t+1,this.length)}addChild(t,e=`${this.children.length}`){let n=this.children.push(t),{type:{children:s,mode:i,typeIds:o}}=this,a=[...s,new S(e,t.type)];return this.type=new De(i,[...o,n],a),n}_valueToChildTypeId(t,e,n){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},Oi=class extends Bn{},Ei=class extends Bn{constructor(t){super(t),this._offsets=new wn(Int32Array)}setValue(t,e,n){let s=this._typeIds.set(t,n).buffer[t],i=this.getChildAt(this.type.typeIdToChildIndex[s]),o=this._offsets.set(t,i.length).buffer[t];i?.set(o,e),this.length=Math.max(t+1,this.length)}}});var Rs,Rh=p(()=>{hn();ml();Nr();vt();Rs=class extends de{constructor(t){super(t),this._values=new qe(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Xe(e))}_flushPending(t,e){}};Rs.prototype._flushPending=Sn.prototype._flushPending});var Ps,Ph=p(()=>{hn();Nr();vt();yl();Ps=class extends de{constructor(t){super(t),this._values=new qe(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Xe(e))}_flushPending(t,e){}};Ps.prototype._flushPending=In.prototype._flushPending});var _n,gl=p(()=>{yt();vt();Nr();Gt();hr();_n=class extends bt{constructor(t){super(t),this._variadicBuffers=[],this._currentBuffer=null,this._currentBufferIndex=0,this._currentBufferOffset=0,this._bufferSize=32*1024*1024,this._views=new qe(Uint8Array)}get byteLength(){let t=0;this._views&&(t+=this._views.byteLength),this._nulls&&(t+=this._nulls.byteLength);for(let e of this._variadicBuffers)t+=e.byteLength;return this._currentBuffer&&(t+=this._currentBuffer.byteLength),t}setValue(t,e){return this.writeBinaryValue(t,this.encodeValue(e))}writeBinaryValue(t,e){let n=e.length,s=(t+1)*H.ELEMENT_WIDTH,i=this._views.length;s>i&&this._views.reserve(s-i);let o=this._views.buffer,a=t*H.ELEMENT_WIDTH,c=new DataView(o.buffer,o.byteOffset+a,H.ELEMENT_WIDTH);if(c.setInt32(H.LENGTH_OFFSET,n,!0),n<=H.INLINE_CAPACITY){o.set(e,a+H.INLINE_OFFSET);for(let l=n;l<H.INLINE_CAPACITY;l++)o[a+H.INLINE_OFFSET+l]=0}else{let l=new DataView(e.buffer,e.byteOffset,Math.min(4,n));c.setUint32(H.INLINE_OFFSET,l.getUint32(0,!0),!0),(!this._currentBuffer||this._currentBufferOffset+n>this._bufferSize)&&(this._currentBuffer&&this._variadicBuffers.push(this._currentBuffer.buffer.slice(0,this._currentBufferOffset)),this._currentBuffer=new qe(Uint8Array),this._currentBufferIndex=this._variadicBuffers.length,this._currentBufferOffset=0),this._currentBuffer.reserve(n).buffer.set(e,this._currentBufferOffset),c.setInt32(H.BUFFER_INDEX_OFFSET,this._currentBufferIndex,!0),c.setInt32(H.BUFFER_OFFSET_OFFSET,this._currentBufferOffset,!0),this._currentBufferOffset+=n}return this}encodeValue(t){return O(t)}setValid(t,e){let n=(t+1)*H.ELEMENT_WIDTH,s=this._views.length;n>s&&this._views.reserve(n-s);let i=super.setValid(t,e);if(!i){let o=this._views.buffer,a=t*H.ELEMENT_WIDTH;for(let c=0;c<H.ELEMENT_WIDTH;c++)o[a+c]=0}return i}clear(){return this._variadicBuffers=[],this._currentBuffer=null,this._currentBufferIndex=0,this._currentBufferOffset=0,this._views.clear(),super.clear()}flush(){let{type:t,length:e,nullCount:n,_views:s,_nulls:i}=this;this._currentBuffer&&this._currentBufferOffset>0&&(this._variadicBuffers.push(this._currentBuffer.buffer.slice(0,this._currentBufferOffset)),this._currentBuffer=null,this._currentBufferOffset=0);let o=s.flush(e*H.ELEMENT_WIDTH),a=n>0?i.flush(e):void 0,c=this._variadicBuffers.slice();return this._variadicBuffers=[],this._currentBufferIndex=0,this.clear(),M({type:t,length:e,nullCount:n,nullBitmap:a,views:o,variadicBuffers:c})}finish(){return this.finished=!0,this}}});var Ui,kh=p(()=>{gl();hn();Ui=class extends _n{constructor(t){super(t)}setValue(t,e){return this.writeBinaryValue(t,Xe(e))}}});var zh,z0,V0=p(()=>{je();ml();yl();wh();xh();vh();Ah();Sh();Ih();Bh();_h();Lh();Th();Mh();Dh();Ch();Fh();Oh();Eh();Uh();Nh();Rh();Ph();gl();kh();zh=class extends F{visitNull(){return Ci}visitBool(){return pi}visitInt(){return Ce}visitInt8(){return xi}visitInt16(){return vi}visitInt32(){return Ai}visitInt64(){return Si}visitUint8(){return Ii}visitUint16(){return Bi}visitUint32(){return _i}visitUint64(){return Li}visitFloat(){return en}visitFloat16(){return gi}visitFloat32(){return bi}visitFloat64(){return wi}visitUtf8(){return Rs}visitLargeUtf8(){return Ps}visitBinary(){return Sn}visitLargeBinary(){return In}visitFixedSizeBinary(){return vs}visitDate(){return tn}visitDateDay(){return bs}visitDateMillisecond(){return ws}visitTimestamp(){return gr}visitTimestampSecond(){return Ms}visitTimestampMillisecond(){return Ds}visitTimestampMicrosecond(){return Cs}visitTimestampNanosecond(){return Fs}visitTime(){return br}visitTimeSecond(){return Os}visitTimeMillisecond(){return Es}visitTimeMicrosecond(){return Us}visitTimeNanosecond(){return Ns}visitDecimal(){return xs}visitList(){return Ti}visitLargeList(){return Mi}visitStruct(){return Fi}visitUnion(){return Bn}visitDenseUnion(){return Ei}visitSparseUnion(){return Oi}visitDictionary(){return mi}visitInterval(){return kr}visitIntervalDayTime(){return As}visitIntervalYearMonth(){return Ss}visitIntervalMonthDayNano(){return Is}visitDuration(){return yr}visitDurationSecond(){return Bs}visitDurationMillisecond(){return _s}visitDurationMicrosecond(){return Ls}visitDurationNanosecond(){return Ts}visitFixedSizeList(){return yi}visitMap(){return Di}visitBinaryView(){return _n}visitUtf8View(){return Ui}},z0=new zh});function Fe(r,t){return t instanceof r.constructor}function Ln(r,t){return r===t||Fe(r,t)}function Tn(r,t){return r===t||Fe(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function bl(r,t){return r===t||Fe(r,t)&&r.precision===t.precision}function Zv(r,t){return r===t||Fe(r,t)&&r.byteWidth===t.byteWidth}function Vh(r,t){return r===t||Fe(r,t)&&r.unit===t.unit}function Ga(r,t){return r===t||Fe(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function ja(r,t){return r===t||Fe(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function G0(r,t){return r===t||Fe(r,t)&&r.children.length===t.children.length&&rn.compareManyFields(r.children,t.children)}function Hv(r,t){return r===t||Fe(r,t)&&r.children.length===t.children.length&&rn.compareManyFields(r.children,t.children)}function Gh(r,t){return r===t||Fe(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&rn.compareManyFields(r.children,t.children)}function Xv(r,t){return r===t||Fe(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&rn.visit(r.indices,t.indices)&&rn.visit(r.dictionary,t.dictionary)}function wl(r,t){return r===t||Fe(r,t)&&r.unit===t.unit}function qa(r,t){return r===t||Fe(r,t)&&r.unit===t.unit}function Kv(r,t){return r===t||Fe(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&rn.compareManyFields(r.children,t.children)}function Jv(r,t){return r===t||Fe(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&rn.compareManyFields(r.children,t.children)}function Ni(r,t){return rn.compareSchemas(r,t)}function j0(r,t){return rn.compareFields(r,t)}function xl(r,t){return rn.visit(r,t)}var R,rn,$a=p(()=>{je();R=class extends F{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)}};R.prototype.visitNull=Ln;R.prototype.visitBool=Ln;R.prototype.visitInt=Tn;R.prototype.visitInt8=Tn;R.prototype.visitInt16=Tn;R.prototype.visitInt32=Tn;R.prototype.visitInt64=Tn;R.prototype.visitUint8=Tn;R.prototype.visitUint16=Tn;R.prototype.visitUint32=Tn;R.prototype.visitUint64=Tn;R.prototype.visitFloat=bl;R.prototype.visitFloat16=bl;R.prototype.visitFloat32=bl;R.prototype.visitFloat64=bl;R.prototype.visitUtf8=Ln;R.prototype.visitLargeUtf8=Ln;R.prototype.visitUtf8View=Ln;R.prototype.visitBinary=Ln;R.prototype.visitLargeBinary=Ln;R.prototype.visitBinaryView=Ln;R.prototype.visitFixedSizeBinary=Zv;R.prototype.visitDate=Vh;R.prototype.visitDateDay=Vh;R.prototype.visitDateMillisecond=Vh;R.prototype.visitTimestamp=Ga;R.prototype.visitTimestampSecond=Ga;R.prototype.visitTimestampMillisecond=Ga;R.prototype.visitTimestampMicrosecond=Ga;R.prototype.visitTimestampNanosecond=Ga;R.prototype.visitTime=ja;R.prototype.visitTimeSecond=ja;R.prototype.visitTimeMillisecond=ja;R.prototype.visitTimeMicrosecond=ja;R.prototype.visitTimeNanosecond=ja;R.prototype.visitDecimal=Ln;R.prototype.visitList=G0;R.prototype.visitLargeList=G0;R.prototype.visitStruct=Hv;R.prototype.visitUnion=Gh;R.prototype.visitDenseUnion=Gh;R.prototype.visitSparseUnion=Gh;R.prototype.visitDictionary=Xv;R.prototype.visitInterval=wl;R.prototype.visitIntervalDayTime=wl;R.prototype.visitIntervalYearMonth=wl;R.prototype.visitIntervalMonthDayNano=wl;R.prototype.visitDuration=qa;R.prototype.visitDurationSecond=qa;R.prototype.visitDurationMillisecond=qa;R.prototype.visitDurationMicrosecond=qa;R.prototype.visitDurationNanosecond=qa;R.prototype.visitFixedSizeList=Kv;R.prototype.visitMap=Jv;rn=new R});function Pr(r){let t=r.type,e=new(z0.getVisitFn(t)())(r);if(t.children&&t.children.length>0){let n=r.children||[],s={nullValues:r.nullValues},i=Array.isArray(n)?((o,a)=>n[a]||s):(({name:o})=>n[o]||s);for(let[o,a]of t.children.entries()){let{type:c}=a,l=i(a,o);e.children.push(Pr(Object.assign(Object.assign({},l),{type:c})))}}return e}function Mo(r,t){if(r instanceof D||r instanceof A||r.type instanceof w||ArrayBuffer.isView(r))return te(r);let e={type:t??vl(r),nullValues:[null]},n=[...Al(e)(r)],s=n.length===1?n[0]:n.reduce((i,o)=>i.concat(o));return w.isDictionary(s.type)?s.memoize():s}function jh(r){let t=Mo(r),e=new ct(new G(t.type.children),t.data[0]);return new st(e)}function vl(r){if(r.length===0)return new Et;let t=0,e=0,n=0,s=0,i=0,o=0,a=0,c=0;for(let l of r){if(l==null){++t;continue}switch(typeof l){case"bigint":++o;continue;case"boolean":++a;continue;case"number":++s;continue;case"string":++i;continue;case"object":Array.isArray(l)?++e:Object.prototype.toString.call(l)==="[object Date]"?++c:++n;continue}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}if(s+t===r.length)return new _e;if(i+t===r.length)return new Rt(new ce,new Dt);if(o+t===r.length)return new Qe;if(a+t===r.length)return new le;if(c+t===r.length)return new Kr;if(e+t===r.length){let l=r,u=vl(l[l.findIndex(f=>f!=null)]);if(l.every(f=>f==null||xl(u,vl(f))))return new Ct(new S("",u,!0))}else if(n+t===r.length){let l=new Map;for(let u of r)for(let f of Object.keys(u))!l.has(f)&&u[f]!=null&&l.set(f,new S(f,vl([u[f]]),!0));return new ut([...l.values()])}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}function Al(r){let{["queueingStrategy"]:t="count"}=r,{["highWaterMark"]:e=t!=="bytes"?Number.POSITIVE_INFINITY:Math.pow(2,14)}=r,n=t!=="bytes"?"length":"byteLength";return function*(s){let i=0,o=Pr(r);for(let a of s)o.append(a)[n]>=e&&++i&&(yield o.toVector());(o.finish().length>0||i===0)&&(yield o.toVector())}}function qh(r){let{["queueingStrategy"]:t="count"}=r,{["highWaterMark"]:e=t!=="bytes"?Number.POSITIVE_INFINITY:Math.pow(2,14)}=r,n=t!=="bytes"?"length":"byteLength";return function(s){return xe(this,arguments,function*(){var i,o,a,c;let l=0,u=Pr(r);try{for(var f=!0,h=He(s),m;m=yield Y(h.next()),i=m.done,!i;f=!0){c=m.value,f=!1;let y=c;u.append(y)[n]>=e&&++l&&(yield yield Y(u.toVector()))}}catch(y){o={error:y}}finally{try{!f&&!i&&(a=h.return)&&(yield Y(a.call(h)))}finally{if(o)throw o.error}}(u.finish().length>0||l===0)&&(yield yield Y(u.toVector()))})}}var Va=p(()=>{Pe();pe();yt();hr();he();V0();Ri();Mn();$a()});function Sl(r,t){return Qv(r,t.map(e=>e.data.concat()))}function Qv(r,t){let e=[...r.fields],n=[],s={numBatches:t.reduce((f,h)=>Math.max(f,h.length),0)},i=0,o=0,a=-1,c=t.length,l,u=[];for(;s.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a<c;)u[a]=l=t[a].shift(),o=Math.min(o,l?l.length:o);Number.isFinite(o)&&(u=tA(e,o,u,t,s),o>0&&(n[i++]=M({type:new ut(e),length:o,nullCount:0,children:u.slice()})))}return[r=r.assign(e),n.map(f=>new ct(r,f))]}function tA(r,t,e,n,s){var i;let o=(t+63&-64)>>3;for(let a=-1,c=n.length;++a<c;){let l=e[a],u=l?.length;if(u>=t)u===t?e[a]=l:(e[a]=l.slice(0,t),s.numBatches=Math.max(s.numBatches,n[a].unshift(l.slice(t,u-t))));else{let f=r[a];r[a]=f.clone({nullable:!0}),e[a]=(i=l?._changeLengthAndBackfillNullBitmap(t))!==null&&i!==void 0?i:M({type:f.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var q0=p(()=>{hr();yt();Mn()});function $h(r){let t={},e=Object.entries(r);for(let[n,s]of e)t[n]=te(s);return new st(t)}function Wh(r){let t={},e=Object.entries(r);for(let[n,s]of e)t[n]=Mo(s);return new st(t)}var $0,W0,st,Ri=p(()=>{Mt();hr();Va();he();pe();yt();$a();q0();nl();ii();rr();sl();il();vo();Mn();W0=Symbol.for("apache-arrow/Table"),st=class r{static isTable(t){return t?.[W0]===!0}constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new G([]),this._offsets=[0],this;let s,i;t[0]instanceof G&&(s=t.shift()),t.at(-1)instanceof Uint32Array&&(i=t.pop());let o=c=>{if(c){if(c instanceof ct)return[c];if(c instanceof r)return c.batches;if(c instanceof D){if(c.type instanceof ut)return[new ct(new G(c.type.children),c)]}else{if(Array.isArray(c))return c.flatMap(l=>o(l));if(typeof c[Symbol.iterator]=="function")return[...c].flatMap(l=>o(l));if(typeof c=="object"){let l=Object.keys(c),u=l.map(m=>new A([c[m]])),f=s??new G(l.map((m,y)=>new S(String(m),u[y].type,u[y].nullable))),[,h]=Sl(f,u);return h.length===0?[new ct(c)]:h}}}return[]},a=t.flatMap(c=>o(c));if(s=(n=s??((e=a[0])===null||e===void 0?void 0:e.schema))!==null&&n!==void 0?n:new G([]),!(s instanceof G))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let c of a){if(!(c instanceof ct))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Ni(s,c.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=s,this.batches=a,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=Jc(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(oi(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?Io.visit(new A(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
|
|
13
|
+
return true;`)}function gv(r){return typeof r!="bigint"?Dr(r):`${Dr(r)}n`}var r0=d(()=>{Ma()});function Lh(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function n0(r,t=0){return r.length>=t?r.subarray(0,t):ha(new r.constructor(t),r,0)}var je,xn,Co,ys,Rr=d(()=>{Gt();je=class{constructor(t,e=0,n=1){this.length=Math.ceil(e/n),this.buffer=new t(this.length),this.stride=n,this.BYTES_PER_ELEMENT=t.BYTES_PER_ELEMENT,this.ArrayType=t}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(t,e){return this}append(t){return this.set(this.length,t)}reserve(t){if(t>0){this.length+=t;let e=this.stride,n=this.length*e,s=this.buffer.length;n>=s&&this._resize(s===0?Lh(n*1,this.BYTES_PER_ELEMENT):Lh(n*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=Lh(t*this.stride,this.BYTES_PER_ELEMENT);let e=n0(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=n0(this.buffer,t)}},xn=class extends je{last(){return this.get(this.length-1)}get(t){return this.buffer[t]}set(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this}},Co=class extends xn{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(t){return this.buffer[t>>3]>>t%8&1}set(t,e){let{buffer:n}=this.reserve(t-this.length+1),s=t>>3,i=t%8,o=n[s]>>i&1;return e?o===0&&(n[s]|=1<<i,++this.numValid):o===1&&(n[s]&=~(1<<i),--this.numValid),this}clear(){return this.numValid=0,super.clear()}},ys=class extends xn{constructor(t){super(t.OffsetArrayType,1,1)}append(t){return this.set(this.length-1,t)}set(t,e){let n=this.length-1,s=this.reserve(t-n+1).buffer;return n<t++&&n>=0&&s.fill(s[n],n,t),s[t]=s[t-1]+e,this}flush(t=this.length-1){return t>this.length&&this.set(t-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(t+1)}}});var bt,kt,de,At=d(()=>{he();hr();Pa();yt();r0();Rr();bt=class{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t){throw new Error('"throughDOM" not available in this environment')}constructor({type:t,nullValues:e}){this.length=0,this.finished=!1,this.type=t,this.children=[],this.nullValues=e,this.stride=er(t),this._nulls=new Co,e&&e.length>0&&(this._isValid=e0(e))}toVector(){return new v([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0,{_offsets:e,_values:n,_nulls:s,_typeIds:i,children:o}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),s&&(t+=s.byteLength),i&&(t+=i.byteLength),o.reduce((a,c)=>a+c.byteLength,t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce((e,n)=>e+n.reservedByteLength,t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(t){return this.children[t]||null}flush(){let t,e,n,s,{type:i,length:o,nullCount:a,_typeIds:c,_offsets:l,_values:u,_nulls:f}=this;(e=c?.flush(o))?s=l?.flush(o):(s=l?.flush(o))?t=u?.flush(l.last()):t=u?.flush(o),a>0&&(n=f?.flush(o));let h=this.children.map(m=>m.flush());return this.clear(),M({type:i,length:o,nullCount:a,children:h,child:h[0],data:t,typeIds:e,nullBitmap:n,valueOffsets:s})}finish(){this.finished=!0;for(let t of this.children)t.finish();return this}clear(){var t,e,n,s;this.length=0,(t=this._nulls)===null||t===void 0||t.clear(),(e=this._values)===null||e===void 0||e.clear(),(n=this._offsets)===null||n===void 0||n.clear(),(s=this._typeIds)===null||s===void 0||s.clear();for(let i of this.children)i.clear();return this}};bt.prototype.length=1;bt.prototype.stride=1;bt.prototype.children=null;bt.prototype.finished=!1;bt.prototype.nullValues=null;bt.prototype._isValid=()=>!0;kt=class extends bt{constructor(t){super(t),this._values=new xn(this.ArrayType,0,this.stride)}setValue(t,e){let n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}},de=class extends bt{constructor(t){super(t),this._pendingLength=0,this._offsets=new ys(t.type)}setValue(t,e){let n=this._pending||(this._pending=new Map),s=n.get(t);s&&(this._pendingLength-=s.length),this._pendingLength+=e instanceof fr?e[ps].length:e.length,n.set(t,e)}setValid(t,e){return super.setValid(t,e)?!0:((this._pending||(this._pending=new Map)).set(t,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this}}});var mi,Th=d(()=>{mi=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,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()}}});var nr,s0=d(()=>{nt();Th();go();Uc();rh();nr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):ht.V1}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new ke).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new mi).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}dictionariesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,e){let n=this.bb.__offset(this.bb_pos,10);return n?(e||new mi).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}recordBatchesLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Tt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,ht.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)}}});function vl(r,t){return new Map([...r||new Map,...t||new Map])}function Mh(r,t=new Map){for(let e=-1,n=r.length;++e<n;){let i=r[e].type;if(w.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&&Mh(i.children,t)}return t}var i0,o0,G,S,pe=d(()=>{Mt();yt();i0=Symbol.for("apache-arrow/Schema"),o0=Symbol.for("apache-arrow/Field"),G=class r{static isSchema(t){return t?.[i0]===!0}constructor(t=[],e,n,s=ht.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=Mh(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){let e=new Set(t),n=this.fields.filter(s=>e.has(s.name));return new r(n,this.metadata)}selectAt(t){let e=t.map(n=>this.fields[n]).filter(Boolean);return new r(e,this.metadata)}assign(...t){let e=t[0]instanceof r?t[0]:Array.isArray(t[0])?new r(t[0]):new r(t),n=[...this.fields],s=vl(vl(new Map,this.metadata),e.metadata),i=e.fields.filter(a=>{let c=n.findIndex(l=>l.name===a.name);return~c?(n[c]=a.clone({metadata:vl(vl(new Map,n[c].metadata),a.metadata)}))&&!1:!0}),o=Mh(i,new Map);return new r([...n,...i],s,new Map([...this.dictionaries,...o]))}};G.prototype.fields=null;G.prototype.metadata=null;G.prototype.dictionaries=null;G.prototype[i0]=!0;Object.defineProperty(G,Symbol.hasInstance,{value:function(t){return Function.prototype[Symbol.hasInstance].call(this,t)||this===G&&G.isSchema(t)}});S=class r{static isField(t){return t?.[o0]===!0}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 r(`${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],r.new(e,n,s,i)}};S.prototype.type=null;S.prototype.name=null;S.prototype.nullable=null;S.prototype.metadata=null;S.prototype[o0]=!0;Object.defineProperty(S,Symbol.hasInstance,{value:function(t){return Function.prototype[Symbol.hasInstance].call(this,t)||this===S&&S.isField(t)}})});var bv,wv,An,Dh,Pr,Ch=d(()=>{Th();s0();nt();pe();Mt();Gt();Kr();bv=oi,wv=Zt,An=class{static decode(t){t=new wv(E(t));let e=nr.getRootAsFooter(t),n=G.decode(e.schema(),new Map,e.version());return new Dh(n,e)}static encode(t){let e=new bv,n=G.encode(e,t.schema);nr.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())Pr.encode(e,o);let s=e.endVector();nr.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())Pr.encode(e,o);let i=e.endVector();return nr.startFooter(e),nr.addSchema(e,n),nr.addVersion(e,ht.V5),nr.addRecordBatches(e,s),nr.addDictionaries(e,i),nr.finishFooterBuffer(e,nr.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=ht.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}},Dh=class extends An{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,e){super(t,e.version()),this._footer=e}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){let e=this._footer.recordBatches(t);if(e)return Pr.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return Pr.decode(e)}return null}},Pr=class r{static decode(t){return new r(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,e){let{metaDataLength:n}=e,s=BigInt(e.offset),i=BigInt(e.bodyLength);return mi.createBlock(t,s,n,i)}constructor(t,e,n){this.metaDataLength=t,this.offset=J(n),this.bodyLength=J(e)}}});var sr,a0=d(()=>{nt();go();$c();Uc();sr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):ht.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):Q.NONE}header(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Tt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,ht.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,Q.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,o){return r.startMessage(t),r.addVersion(t,e),r.addHeaderType(t,n),r.addHeader(t,s),r.addBodyLength(t,i),r.addCustomMetadata(t,o),r.endMessage(t)}}});var Fh,Sl,c0=d(()=>{$e();Dy();Vc();Hf();Sy();Iy();_y();By();Fy();Ey();Ty();qf();jf();Jf();Qf();Xf();Wf();My();Ly();Cy();th();$f();Yf();Zf();Kf();Fh=class extends F{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return Ba.startNull(e),Ba.endNull(e)}visitInt(t,e){return Tr.startInt(e),Tr.addBitWidth(e,t.bitWidth),Tr.addIsSigned(e,t.isSigned),Tr.endInt(e)}visitFloat(t,e){return Jn.startFloatingPoint(e),Jn.addPrecision(e,t.precision),Jn.endFloatingPoint(e)}visitBinary(t,e){return ba.startBinary(e),ba.endBinary(e)}visitBinaryView(t,e){return wa.startBinaryView(e),wa.endBinaryView(e)}visitLargeBinary(t,e){return Aa.startLargeBinary(e),Aa.endLargeBinary(e)}visitBool(t,e){return xa.startBool(e),xa.endBool(e)}visitUtf8(t,e){return La.startUtf8(e),La.endUtf8(e)}visitUtf8View(t,e){return Ta.startUtf8View(e),Ta.endUtf8View(e)}visitLargeUtf8(t,e){return Sa.startLargeUtf8(e),Sa.endLargeUtf8(e)}visitDecimal(t,e){return Xr.startDecimal(e),Xr.addScale(e,t.scale),Xr.addPrecision(e,t.precision),Xr.addBitWidth(e,t.bitWidth),Xr.endDecimal(e)}visitDate(t,e){return Zn.startDate(e),Zn.addUnit(e,t.unit),Zn.endDate(e)}visitTime(t,e){return yn.startTime(e),yn.addUnit(e,t.unit),yn.addBitWidth(e,t.bitWidth),yn.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return gn.startTimestamp(e),gn.addUnit(e,t.unit),n!==void 0&&gn.addTimezone(e,n),gn.endTimestamp(e)}visitInterval(t,e){return Qn.startInterval(e),Qn.addUnit(e,t.unit),Qn.endInterval(e)}visitDuration(t,e){return Hn.startDuration(e),Hn.addUnit(e,t.unit),Hn.endDuration(e)}visitList(t,e){return Ia.startList(e),Ia.endList(e)}visitLargeList(t,e){return va.startLargeList(e),va.endLargeList(e)}visitStruct(t,e){return _a.startStruct_(e),_a.endStruct_(e)}visitUnion(t,e){Mr.startTypeIdsVector(e,t.typeIds.length);let n=Mr.createTypeIdsVector(e,t.typeIds);return Mr.startUnion(e),Mr.addMode(e,t.mode),Mr.addTypeIds(e,n),Mr.endUnion(e)}visitDictionary(t,e){let n=this.visit(t.indices,e);return Hr.startDictionaryEncoding(e),Hr.addId(e,BigInt(t.id)),Hr.addIsOrdered(e,t.isOrdered),n!==void 0&&Hr.addIndexType(e,n),Hr.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Xn.startFixedSizeBinary(e),Xn.addByteWidth(e,t.byteWidth),Xn.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Kn.startFixedSizeList(e),Kn.addListSize(e,t.listSize),Kn.endFixedSizeList(e)}visitMap(t,e){return ts.startMap(e),ts.addKeysSorted(e,t.keysSorted),ts.endMap(e)}},Sl=new Fh});function h0(r,t=new Map){return new G(xv(r,t),Il(r.metadata),t)}function Eh(r){return new zt(r.count,p0(r.columns),m0(r.columns),null,y0(r.columns))}function d0(r){return new me(Eh(r.data),r.id,r.isDelta)}function xv(r,t){return(r.fields||[]).filter(Boolean).map(e=>S.fromJSON(e,t))}function l0(r,t){return(r.children||[]).filter(Boolean).map(e=>S.fromJSON(e,t))}function p0(r){return(r||[]).reduce((t,e)=>[...t,new dr(e.count,Av(e.VALIDITY)),...p0(e.children)],[])}function m0(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let s=r[e];if(s.VALIDITY&&t.push(new Nt(t.length,s.VALIDITY.length)),s.TYPE_ID&&t.push(new Nt(t.length,s.TYPE_ID.length)),s.OFFSET&&t.push(new Nt(t.length,s.OFFSET.length)),s.DATA&&t.push(new Nt(t.length,s.DATA.length)),s.VIEWS&&t.push(new Nt(t.length,s.VIEWS.length)),s.VARIADIC_DATA_BUFFERS)for(let i of s.VARIADIC_DATA_BUFFERS)t.push(new Nt(t.length,i.length));t=m0(s.children,t)}return t}function Av(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function y0(r){return(r||[]).reduce((t,e)=>[...t,...e.VARIADIC_DATA_BUFFERS?[e.VARIADIC_DATA_BUFFERS.length]:[],...y0(e.children)],[])}function g0(r,t){let e,n,s,i,o,a;return!t||!(i=r.dictionary)?(o=f0(r,l0(r,t)),s=new S(r.name,o,r.nullable,Il(r.metadata))):t.has(e=i.id)?(n=(n=i.indexType)?u0(n):new Dt,a=new Rt(t.get(e),n,e,i.isOrdered),s=new S(r.name,a,r.nullable,Il(r.metadata))):(n=(n=i.indexType)?u0(n):new Dt,t.set(e,o=f0(r,l0(r,t))),a=new Rt(o,n,e,i.isOrdered),s=new S(r.name,a,r.nullable,Il(r.metadata))),s||null}function Il(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function u0(r){return new Lt(r.isSigned,r.bitWidth)}function f0(r,t){let e=r.type.name;switch(e){case"NONE":return new Ot;case"null":return new Ot;case"binary":return new ze;case"largebinary":return new Or;case"binaryview":return new H;case"utf8":return new ce;case"largeutf8":return new Nr;case"utf8view":return new Le;case"bool":return new le;case"list":return new Ct((t||[])[0]);case"largelist":return new tr((t||[])[0]);case"struct":return new ut(t||[]);case"struct_":return new ut(t||[])}switch(e){case"int":{let n=r.type;return new Lt(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new ae(ot[n.precision])}case"decimal":{let n=r.type;return new Ve(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new Te(mt[n.unit])}case"time":{let n=r.type;return new Kt(A[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new Jt(A[n.unit],n.timezone)}case"interval":{let n=r.type;return new ue(et[n.unit])}case"duration":{let n=r.type;return new Me(A[n.unit])}case"union":{let n=r.type,[s,...i]=(n.mode+"").toLowerCase(),o=s.toUpperCase()+i.join("");return new De(lt[o],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new Ge(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new gt(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new fe((t||[])[0],n.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var b0=d(()=>{pe();yt();gs();Mt()});function Iv(r,t){return(()=>{switch(t){case Q.Schema:return G.fromJSON(r);case Q.RecordBatch:return zt.fromJSON(r);case Q.DictionaryBatch:return me.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${Q[t]}, type: ${t} }`)})}function Bv(r,t){return(()=>{switch(t){case Q.Schema:return G.decode(r.header(new ke),new Map,r.version());case Q.RecordBatch:return zt.decode(r.header(new ie),r.version());case Q.DictionaryBatch:return me.decode(r.header(new mn),r.version())}throw new Error(`Unrecognized Message type: { name: ${Q[t]}, type: ${t} }`)})}function _v(r,t=new Map,e=ht.V5){let n=Ov(r,t);return new G(n,Bl(r),t,e)}function Lv(r,t=ht.V5){return new zt(r.length(),Cv(r),Fv(r,t),v0(r.compression()),Ev(r))}function Tv(r,t=ht.V5){return new me(zt.decode(r.data(),t),r.id(),r.isDelta())}function Mv(r){return new Nt(r.offset(),r.length())}function Dv(r){return new dr(r.length(),r.nullCount())}function Cv(r){let t=[];for(let e,n=-1,s=-1,i=r.nodesLength();++n<i;)(e=r.nodes(n))&&(t[++s]=dr.decode(e));return t}function Fv(r,t){let e=[];for(let n,s=-1,i=-1,o=r.buffersLength();++s<o;)(n=r.buffers(s))&&(t<ht.V4&&(n.bb_pos+=8*(s+1)),e[++i]=Nt.decode(n));return e}function Ev(r){let t=[],e=Math.trunc(r.variadicBufferCountsLength());for(let n=0;n<e;++n)t.push(J(r.variadicBufferCounts(n)));return t}function Ov(r,t){let e=[];for(let n,s=-1,i=-1,o=r.fieldsLength();++s<o;)(n=r.fields(s))&&(e[++i]=S.decode(n,t));return e}function w0(r,t){let e=[];for(let n,s=-1,i=-1,o=r.childrenLength();++s<o;)(n=r.children(s))&&(e[++i]=S.decode(n,t));return e}function Nv(r,t){let e,n,s,i,o,a;return!t||!(a=r.dictionary())?(s=A0(r,w0(r,t)),n=new S(r.name(),s,r.nullable(),Bl(r))):t.has(e=J(a.id()))?(i=(i=a.indexType())?x0(i):new Dt,o=new Rt(t.get(e),i,e,a.isOrdered()),n=new S(r.name(),o,r.nullable(),Bl(r))):(i=(i=a.indexType())?x0(i):new Dt,t.set(e,s=A0(r,w0(r,t))),o=new Rt(s,i,e,a.isOrdered()),n=new S(r.name(),o,r.nullable(),Bl(r))),n||null}function Bl(r){let 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 Uv(r){let t=new Map;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 x0(r){return new Lt(r.isSigned(),r.bitWidth())}function A0(r,t){let e=r.typeType();switch(e){case k.NONE:return new Ot;case k.Null:return new Ot;case k.Binary:return new ze;case k.LargeBinary:return new Or;case k.BinaryView:return new H;case k.Utf8:return new ce;case k.LargeUtf8:return new Nr;case k.Utf8View:return new Le;case k.Bool:return new le;case k.List:return new Ct((t||[])[0]);case k.LargeList:return new tr((t||[])[0]);case k.Struct_:return new ut(t||[])}switch(e){case k.Int:{let n=r.type(new Tr);return new Lt(n.isSigned(),n.bitWidth())}case k.FloatingPoint:{let n=r.type(new Jn);return new ae(n.precision())}case k.Decimal:{let n=r.type(new Xr);return new Ve(n.scale(),n.precision(),n.bitWidth())}case k.Date:{let n=r.type(new Zn);return new Te(n.unit())}case k.Time:{let n=r.type(new yn);return new Kt(n.unit(),n.bitWidth())}case k.Timestamp:{let n=r.type(new gn);return new Jt(n.unit(),n.timezone())}case k.Interval:{let n=r.type(new Qn);return new ue(n.unit())}case k.Duration:{let n=r.type(new Hn);return new Me(n.unit())}case k.Union:{let n=r.type(new Mr);return new De(n.mode(),n.typeIdsArray()||[],t||[])}case k.FixedSizeBinary:{let n=r.type(new Xn);return new Ge(n.byteWidth())}case k.FixedSizeList:{let n=r.type(new Kn);return new gt(n.listSize(),(t||[])[0])}case k.Map:{let n=r.type(new ts);return new fe((t||[])[0],n.keysSorted())}}throw new Error(`Unrecognized type: "${k[e]}" (${e})`)}function v0(r){return r?new yi(r.codec(),r.method()):null}function Rv(r,t){let e=t.fields.map(i=>S.encode(r,i));ke.startFieldsVector(r,e.length);let n=ke.createFieldsVector(r,e),s=t.metadata&&t.metadata.size>0?ke.createCustomMetadataVector(r,[...t.metadata].map(([i,o])=>{let a=r.createString(`${i}`),c=r.createString(`${o}`);return Tt.startKeyValue(r),Tt.addKey(r,a),Tt.addValue(r,c),Tt.endKeyValue(r)})):-1;return ke.startSchema(r),ke.addFields(r,n),ke.addEndianness(r,$v?Yn.Little:Yn.Big),s!==-1&&ke.addCustomMetadata(r,s),ke.endSchema(r)}function Pv(r,t){let e=-1,n=-1,s=-1,i=t.type,o=t.typeId;w.isDictionary(i)?(o=i.dictionary.typeId,s=Sl.visit(i,r),n=Sl.visit(i.dictionary,r)):n=Sl.visit(i,r);let a=(i.children||[]).map(u=>S.encode(r,u)),c=oe.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?oe.createCustomMetadataVector(r,[...t.metadata].map(([u,f])=>{let h=r.createString(`${u}`),m=r.createString(`${f}`);return Tt.startKeyValue(r),Tt.addKey(r,h),Tt.addValue(r,m),Tt.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),oe.startField(r),oe.addType(r,n),oe.addTypeType(r,o),oe.addChildren(r,c),oe.addNullable(r,!!t.nullable),e!==-1&&oe.addName(r,e),s!==-1&&oe.addDictionary(r,s),l!==-1&&oe.addCustomMetadata(r,l),oe.endField(r)}function kv(r,t){let e=t.nodes||[],n=t.buffers||[],s=t.variadicBufferCounts||[];ie.startNodesVector(r,e.length);for(let l of e.slice().reverse())dr.encode(r,l);let i=r.endVector();ie.startBuffersVector(r,n.length);for(let l of n.slice().reverse())Nt.encode(r,l);let o=r.endVector(),a=null;t.compression!==null&&(a=S0(r,t.compression));let c=-1;return s.length>0&&(c=ie.createVariadicBufferCountsVector(r,s.map(BigInt))),ie.startRecordBatch(r),ie.addLength(r,BigInt(t.length)),ie.addNodes(r,i),ie.addBuffers(r,o),t.compression!==null&&a&&ie.addCompression(r,a),c!==-1&&ie.addVariadicBufferCounts(r,c),ie.endRecordBatch(r)}function S0(r,t){return pn.startBodyCompression(r),pn.addCodec(r,t.type),pn.addMethod(r,t.method),pn.endBodyCompression(r)}function zv(r,t){let e=zt.encode(r,t.data);return mn.startDictionaryBatch(r),mn.addId(r,BigInt(t.id)),mn.addIsDelta(r,t.isDelta),mn.addData(r,e),mn.endDictionaryBatch(r)}function Vv(r,t){return yo.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function Gv(r,t){return mo.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var vv,Sv,ye,zt,me,Nt,dr,yi,$v,gs=d(()=>{nt();rh();Vc();Vf();Ay();kf();eh();zf();Gc();go();Gf();Hf();qf();jf();Jf();Qf();Xf();Wf();th();Yf();Zf();Kf();a0();Pf();Rf();pe();Gt();Kr();Mt();c0();b0();yt();vv=oi,Sv=Zt,ye=class r{static fromJSON(t,e){let n=new r(0,ht.V5,e);return n._createHeader=Iv(t,e),n}static decode(t){t=new Sv(E(t));let e=sr.getRootAsMessage(t),n=e.bodyLength(),s=e.version(),i=e.headerType(),o=Uv(e),a=new r(n,s,i,void 0,o);return a._createHeader=Bv(e,i),a}static encode(t){let e=new vv,n=-1;t.isSchema()?n=G.encode(e,t.header()):t.isRecordBatch()?n=zt.encode(e,t.header()):t.isDictionaryBatch()&&(n=me.encode(e,t.header()));let s=t.metadata&&t.metadata.size>0?sr.createCustomMetadataVector(e,[...t.metadata].map(([i,o])=>{let a=e.createString(`${i}`),c=e.createString(`${o}`);return Tt.startKeyValue(e),Tt.addKey(e,a),Tt.addValue(e,c),Tt.endKeyValue(e)})):-1;return sr.startMessage(e),sr.addVersion(e,ht.V5),sr.addHeader(e,n),sr.addHeaderType(e,t.headerType),sr.addBodyLength(e,BigInt(t.bodyLength)),s!==-1&&sr.addCustomMetadata(e,s),sr.finishMessageBuffer(e,sr.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof G)return new r(0,ht.V5,Q.Schema,t);if(t instanceof zt)return new r(e,ht.V5,Q.RecordBatch,t,t.metadata);if(t instanceof me)return new r(e,ht.V5,Q.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get compression(){return this._compression}get bodyLength(){return this._bodyLength}get metadata(){return this._metadata}header(){return this._createHeader()}isSchema(){return this.headerType===Q.Schema}isRecordBatch(){return this.headerType===Q.RecordBatch}isDictionaryBatch(){return this.headerType===Q.DictionaryBatch}constructor(t,e,n,s,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),this._compression=s?.compression,s&&(this._createHeader=()=>s),this._bodyLength=J(t),this._metadata=i||new Map}},zt=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}get compression(){return this._compression}get variadicBufferCounts(){return this._variadicBufferCounts}get metadata(){return this._metadata}constructor(t,e,n,s,i=[],o){this._nodes=e,this._buffers=n,this._length=J(t),this._compression=s,this._variadicBufferCounts=i,this._metadata=o||new Map}},me=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,e,n=!1){this._data=t,this._isDelta=n,this._id=J(e)}},Nt=class{constructor(t,e){this.offset=J(t),this.length=J(e)}},dr=class{constructor(t,e){this.length=J(t),this.nullCount=J(e)}},yi=class{constructor(t,e=ai.BUFFER){this.type=t,this.method=e}};S.encode=Pv;S.decode=Nv;S.fromJSON=g0;G.encode=Rv;G.decode=_v;G.fromJSON=h0;zt.encode=kv;zt.decode=Lv;zt.fromJSON=Eh;me.encode=zv;me.decode=Tv;me.fromJSON=d0;dr.encode=Vv;dr.decode=Dv;Nt.encode=Gv;Nt.decode=Mv;yi.encode=S0;yi.decode=v0;$v=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})()});var vt,$a,gi,_l,ja=d(()=>{Pe();pa();vt=Object.freeze({done:!0,value:void 0}),$a=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},gi=class{tee(){return this._getDOMStream().tee()}pipe(t,e){return this._getNodeStream().pipe(t,e)}pipeTo(t,e){return this._getDOMStream().pipeTo(t,e)}pipeThrough(t,e){return this._getDOMStream().pipeThrough(t,e)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}},_l=class extends gi{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return B(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){let{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(vt);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Yt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Yt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return B(this,void 0,void 0,function*(){return yield this.abort(t),vt})}return(t){return B(this,void 0,void 0,function*(){return yield this.close(),vt})}read(t){return B(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return B(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(vt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}});var pr,mr,qe,Oh,vn,bs=d(()=>{Pe();pa();dn();ja();Gt();Wn();pr=class extends _l{write(t){if((t=E(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?fo(this.toUint8Array(!0)):this.toUint8Array(!1).then(fo)}toUint8Array(t=!1){return t?Je(this._values)[0]:B(this,void 0,void 0,function*(){var e,n,s,i;let o=[],a=0;try{for(var c=!0,l=He(this),u;u=yield l.next(),e=u.done,!e;c=!0){i=u.value,c=!1;let f=i;o.push(f),a+=f.byteLength}}catch(f){n={error:f}}finally{try{!c&&!e&&(s=l.return)&&(yield s.call(l))}finally{if(n)throw n.error}}return Je(o,a)[0]})}},mr=class{constructor(t){t&&(this.source=new Oh(Yt.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)}},qe=class r{constructor(t){t instanceof r?this.source=t.source:t instanceof pr?this.source=new vn(Yt.fromAsyncIterable(t)):Ec(t)?this.source=new vn(Yt.fromNodeStream(t)):fa(t)?this.source=new vn(Yt.fromDOMStream(t)):Cc(t)?this.source=new vn(Yt.fromDOMStream(t.body)):Br(t)?this.source=new vn(Yt.fromIterable(t)):Ke(t)?this.source=new vn(Yt.fromAsyncIterable(t)):lr(t)&&(this.source=new vn(Yt.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)}},Oh=class{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,e="read"){return this.source.next({cmd:e,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||vt)}return(t){return Object.create(this.source.return&&this.source.return(t)||vt)}},vn=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return B(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return B(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return B(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return B(this,arguments,void 0,function*(e,n="read"){return yield this.source.next({cmd:n,size:e})})}throw(t){return B(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||vt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return B(this,void 0,void 0,function*(){let e=this.source.return&&(yield this.source.return(t))||vt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}}});var qa,ws,Nh=d(()=>{Pe();bs();Gt();qa=class extends mr{constructor(t,e){super(),this.position=0,this.buffer=E(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){let{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){let{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){let 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}}},ws=class extends qe{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=B(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return B(this,void 0,void 0,function*(){let{buffer:e,byteOffset:n}=yield this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)})}seek(t){return B(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 B(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size:n,position:s}=this;if(e&&s<n){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let i=s,o=0,a=0,c=Math.min(n,i+Math.min(n-i,t)),l=new Uint8Array(Math.max(0,(this.position=c)-i));for(;(i+=a)<c&&(o+=a)<l.byteLength;)({bytesRead:a}=yield e.read(l,o,l.byteLength-o,i));return l}return null})}readAt(t,e){return B(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:n,size:s}=this;if(n&&t+e<s){let i=Math.min(s,t+e),o=new Uint8Array(i-t);return(yield n.read(o,0,e,t)).buffer}return new Uint8Array(e)})}close(){return B(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return B(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return B(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}}});var Rh={};Re(Rh,{BaseInt64:()=>Wa,Int128:()=>Ya,Int64:()=>Sn,Uint64:()=>Ft});function Fo(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}var Eo,Uh,Wa,Ft,Sn,Ya,Ph=d(()=>{Eo=8,Uh=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],Wa=class{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){let e=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]),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?65536: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){let e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return`${Fo(this.buffer[1])} ${Fo(this.buffer[0])}`}},Ft=class r extends Wa{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,e=new Uint32Array(2)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.length,s=new r(e);for(let i=0;i<n;){let o=Eo<n-i?Eo:n-i,a=new r(new Uint32Array([Number.parseInt(t.slice(i,i+o),10),0])),c=new r(new Uint32Array([Uh[o],0]));s.times(c),s.plus(a),i+=o}return s}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,s=t.length;++n<s;)r.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}},Sn=class r extends Wa{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(t){return this._times(t),this}plus(t){return this._plus(t),this}lessThan(t){let e=this.buffer[1]<<0,n=t.buffer[1]<<0;return e<n||e===n&&this.buffer[0]<t.buffer[0]}static from(t,e=new Uint32Array(2)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.startsWith("-"),s=t.length,i=new r(e);for(let o=n?1:0;o<s;){let a=Eo<s-o?Eo:s-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new r(new Uint32Array([Uh[a],0]));i.times(l),i.plus(c),o+=a}return n?i.negate():i}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,s=t.length;++n<s;)r.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}},Ya=class r{constructor(t){this.buffer=t}high(){return new Sn(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new Sn(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){let e=new Ft(new Uint32Array([this.buffer[3],0])),n=new Ft(new Uint32Array([this.buffer[2],0])),s=new Ft(new Uint32Array([this.buffer[1],0])),i=new Ft(new Uint32Array([this.buffer[0],0])),o=new Ft(new Uint32Array([t.buffer[3],0])),a=new Ft(new Uint32Array([t.buffer[2],0])),c=new Ft(new Uint32Array([t.buffer[1],0])),l=new Ft(new Uint32Array([t.buffer[0],0])),u=Ft.multiply(i,l);this.buffer[0]=u.low();let f=new Ft(new Uint32Array([u.high(),0]));return u=Ft.multiply(s,l),f.plus(u),u=Ft.multiply(i,c),f.plus(u),this.buffer[1]=f.low(),this.buffer[3]=f.lessThan(u)?1:0,this.buffer[2]=f.high(),new Ft(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(Ft.multiply(n,l)).plus(Ft.multiply(s,c)).plus(Ft.multiply(i,a)),this.buffer[3]+=Ft.multiply(e,l).plus(Ft.multiply(n,c)).plus(Ft.multiply(s,a)).plus(Ft.multiply(i,o)).low(),this}plus(t){let e=new Uint32Array(4);return e[3]=this.buffer[3]+t.buffer[3]>>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]<this.buffer[0]>>>0&&++e[1],e[1]<this.buffer[1]>>>0&&++e[2],e[2]<this.buffer[2]>>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return`${Fo(this.buffer[3])} ${Fo(this.buffer[2])} ${Fo(this.buffer[1])} ${Fo(this.buffer[0])}`}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){let n=t.startsWith("-"),s=t.length,i=new r(e);for(let o=n?1:0;o<s;){let a=Eo<s-o?Eo:s-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new r(new Uint32Array([Uh[a],0,0,0]));i.times(l),i.plus(c),o+=a}return n?i.negate():i}static convertArray(t){let e=new Uint32Array(t.length*4);for(let n=-1,s=t.length;++n<s;)r.from(t[n],new Uint32Array(e.buffer,e.byteOffset+16*n,4));return e}}});var $h={};Re($h,{toIntervalDayTimeInt32Array:()=>kh,toIntervalDayTimeObjects:()=>Vh,toIntervalMonthDayNanoInt32Array:()=>zh,toIntervalMonthDayNanoObjects:()=>Gh});function kh(r){var t,e;let n=r.length,s=new Int32Array(n*2);for(let i=0,o=0;i<n;i++){let a=r[i];s[o++]=(t=a.days)!==null&&t!==void 0?t:0,s[o++]=(e=a.milliseconds)!==null&&e!==void 0?e:0}return s}function zh(r){var t,e;let n=r.length,s=new Int32Array(n*4);for(let i=0,o=0;i<n;i++){let a=r[i];s[o++]=(t=a.months)!==null&&t!==void 0?t:0,s[o++]=(e=a.days)!==null&&e!==void 0?e:0;let c=a.nanoseconds;if(c){let l=BigInt(c);s[o++]=Number(l&BigInt(4294967295))>>>0,s[o++]=Number(l>>BigInt(32))>>>0}else o+=2}return s}function Vh(r){let t=r.length,e=new Array(t/2);for(let n=0,s=0;n<t;n+=2)e[s++]={days:r[n],milliseconds:r[n+1]};return e}function Gh(r,t){let e=r.length,n=new Array(e/4);for(let s=0,i=0;s<e;s+=4){let o=BigInt(r[s+3])<<BigInt(32)|BigInt(r[s+2]>>>0);n[i++]={months:r[s],days:r[s+1],nanoseconds:t?`${o}`:o}}return n}var Ll=d(()=>{});function B0(r){let t=new Uint8Array(r.length/2);for(let e=0;e<r.length;e+=2)t[e>>1]=Number.parseInt(r.slice(e,e+2),16);return t}function jv(r){return B0(r.join(""))}function _0(r,t){let e=new Uint8Array(r.length*16),n=new DataView(e.buffer);for(let[s,i]of r.entries()){let o=s*16,a=i.SIZE;if(n.setInt32(o,a,!0),i.INLINED!==void 0){let c=t(i.INLINED);for(let l=0;l<c.length&&l<12;l++)e[o+4+l]=c[l]}else{let c=i.PREFIX_HEX;for(let l=0;l<8&&l<c.length;l+=2)e[o+4+(l>>1)]=Number.parseInt(c.slice(l,l+2),16);n.setInt32(o+8,i.BUFFER_INDEX,!0),n.setInt32(o+12,i.OFFSET,!0)}}return e}function qv(r){return _0(r,t=>{let 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})}function Wv(r){return _0(r,t=>new TextEncoder().encode(t))}var Oo,Tl,Ml,L0=d(()=>{hr();pe();yt();$e();di();dn();Ph();Mt();Gt();Ll();Oo=class extends F{constructor(t,e,n,s,i=ht.V5,o=[]){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.variadicBufferIndex=-1,this.bytes=t,this.nodes=e,this.buffers=n,this.dictionaries=s,this.metadataVersion=i,this.variadicBufferCounts=o}visit(t){return super.visit(t instanceof S?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return M({type:t,length:e})}visitBool(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitInt(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({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 M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitUtf8View(t,{length:e,nullCount:n}=this.nextFieldNode()){let s=this.readNullBitmap(t,n),i=this.readData(t),o=this.readVariadicBuffers(this.nextVariadicBufferCount());return M({type:t,length:e,nullCount:n,nullBitmap:s,views:i,variadicBuffers:o})}visitBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({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 M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinaryView(t,{length:e,nullCount:n}=this.nextFieldNode()){let s=this.readNullBitmap(t,n),i=this.readData(t),o=this.readVariadicBuffers(this.nextVariadicBufferCount());return M({type:t,length:e,nullCount:n,nullBitmap:s,views:i,variadicBuffers:o})}visitFixedSizeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDate(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTime(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitList(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitLargeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({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 M({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<ht.V5&&this.readNullBitmap(t,n),t.mode===lt.Sparse?this.visitSparseUnion(t,{length:e,nullCount:n}):this.visitDenseUnion(t,{length:e,nullCount:n})}visitDenseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({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 M({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({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 M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return M({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 M({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)}readVariadicBuffers(t){return Array.from({length:t},()=>this.readData(null))}nextVariadicBufferCount(){var t;return(t=this.variadicBufferCounts[++this.variadicBufferIndex])!==null&&t!==void 0?t:0}readDictionary(t){return this.dictionaries.get(t.id)}},Tl=class extends Oo{constructor(t,e,n,s,i,o=[]){super(new Uint8Array(0),e,n,s,i,o),this.sources=t}readNullBitmap(t,e,{offset:n}=this.nextBufferRange()){return e<=0?new Uint8Array(0):hi(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return K(Uint8Array,K(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return K(Uint8Array,K(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:n}=this;if(w.isTimestamp(t))return K(Uint8Array,Sn.convertArray(n[e]));if((w.isInt(t)||w.isTime(t))&&t.bitWidth===64||w.isDuration(t))return K(Uint8Array,Sn.convertArray(n[e]));if(w.isDate(t)&&t.unit===mt.MILLISECOND)return K(Uint8Array,Sn.convertArray(n[e]));if(w.isDecimal(t))return K(Uint8Array,Ya.convertArray(n[e]));if(w.isBinary(t)||w.isLargeBinary(t)||w.isFixedSizeBinary(t))return jv(n[e]);if(w.isBinaryView(t))return qv(n[e]);if(w.isUtf8View(t))return Wv(n[e]);if(w.isBool(t))return hi(n[e]);if(w.isUtf8(t)||w.isLargeUtf8(t))return Xe(n[e].join(""));if(w.isInterval(t))switch(t.unit){case et.DAY_TIME:return kh(n[e]);case et.MONTH_DAY_NANO:return zh(n[e]);default:break}return K(Uint8Array,K(t.ArrayType,n[e].map(s=>+s)))}readVariadicBuffers(t){let e=[];for(let n=0;n<t;n++){let{offset:s}=this.nextBufferRange(),i=this.sources[s];e.push(B0(i))}return e}};Ml=class extends Oo{constructor(t,e,n,s,i,o=[]){super(new Uint8Array(0),e,n,s,i,o),this.bodyChunks=t}readData(t,e=this.nextBufferRange()){return this.bodyChunks[this.buffersIndex]}}});var In,Dl=d(()=>{Rr();At();Gt();In=class extends de{constructor(t){super(t),this._values=new je(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,E(e))}_flushPending(t,e){let n=this._offsets,s=this._values.reserve(e).buffer,i=0;for(let[o,a]of t)if(a===void 0)n.set(o,0);else{let c=a.length;s.set(a,i),n.set(o,c),i+=c}}}});var Bn,Cl=d(()=>{Gt();Rr();At();Bn=class extends de{constructor(t){super(t),this._values=new je(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,E(e))}_flushPending(t,e){let n=this._offsets,s=this._values.reserve(e).buffer,i=0;for(let[o,a]of t)if(a===void 0)n.set(o,BigInt(0));else{let c=a.length;s.set(a,i),n.set(o,BigInt(c)),i+=c}}}});var bi,jh=d(()=>{Rr();At();bi=class extends bt{constructor(t){super(t),this._values=new Co}setValue(t,e){this._values.set(t,+e)}}});var en,xs,As,qh=d(()=>{At();rr();en=class extends kt{};en.prototype._setValue=fh;xs=class extends en{};xs.prototype._setValue=Wc;As=class extends en{};As.prototype._setValue=Yc});var vs,Wh=d(()=>{At();rr();vs=class extends kt{};vs.prototype._setValue=ph});var wi,Yh=d(()=>{yt();At();Za();wi=class extends bt{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new Rt(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=kr({type:this.type.indices,nullValues:e}),this.dictionary=kr({type:this.type.dictionary,nullValues:null}),typeof n=="function"&&(this.valueToKey=n)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(t){return this.indices.isValid(t)}setValid(t,e){let n=this.indices;return e=n.setValid(t,e),this.length=n.length,e}setValue(t,e){let n=this._keysToIndices,s=this.valueToKey(e),i=n[s];return i===void 0&&(n[s]=i=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,i)}flush(){let t=this.type,e=this._dictionary,n=this.dictionary.toVector(),s=this.indices.flush().clone(t);return s.dictionary=e?e.concat(n):n,this.finished||(this._dictionaryOffset+=n.length),this._dictionary=s.dictionary,this.clear(),s}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(t){return typeof t=="string"?t:`${t}`}}});var Ss,Zh=d(()=>{At();rr();Ss=class extends kt{};Ss.prototype._setValue=uh});var xi,Hh=d(()=>{pe();At();yt();xi=class extends bt{setValue(t,e){let[n]=this.children,s=t*this.stride;for(let i=-1,o=this.stride;++i<o;)n.set(s+i,e[i])}setValid(t,e){return super.setValid(t,e)||this.children[0].setValid((t+1)*this.stride-1,!1),e}addChild(t,e="0"){if(this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");let n=this.children.push(t);return this.type=new gt(this.type.listSize,new S(e,t.type,!0)),n}}});var rn,Ai,vi,Si,Xh=d(()=>{Ra();At();rn=class extends kt{setValue(t,e){this._values.set(t,e)}},Ai=class extends rn{setValue(t,e){super.setValue(t,Ua(e))}},vi=class extends rn{},Si=class extends rn{}});var zr,Is,Bs,_s,Kh=d(()=>{At();rr();zr=class extends kt{};zr.prototype._setValue=mh;Is=class extends zr{};Is.prototype._setValue=rl;Bs=class extends zr{};Bs.prototype._setValue=nl;_s=class extends zr{};_s.prototype._setValue=sl});var yr,Ls,Ts,Ms,Ds,Jh=d(()=>{At();rr();yr=class extends kt{};yr.prototype._setValue=yh;Ls=class extends yr{};Ls.prototype._setValue=il;Ts=class extends yr{};Ts.prototype._setValue=ol;Ms=class extends yr{};Ms.prototype._setValue=al;Ds=class extends yr{};Ds.prototype._setValue=cl});var Ce,Ii,Bi,_i,Li,Ti,Mi,Di,Ci,Qh=d(()=>{At();Ce=class extends kt{setValue(t,e){this._values.set(t,e)}},Ii=class extends Ce{},Bi=class extends Ce{},_i=class extends Ce{},Li=class extends Ce{},Ti=class extends Ce{},Mi=class extends Ce{},Di=class extends Ce{},Ci=class extends Ce{}});var Fi,td=d(()=>{pe();yt();Rr();At();Fi=class extends de{constructor(t){super(t),this._offsets=new ys(t.type)}addChild(t,e="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new Ct(new S(e,t.type,!0)),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[s,i]of t)if(typeof i>"u")e.set(s,0);else{let o=i,a=o.length,c=e.set(s,a).buffer[s];for(let l=-1;++l<a;)n.set(c+l,o[l])}}}});var Ei,ed=d(()=>{pe();yt();Rr();Kr();At();Ei=class extends de{constructor(t){super(t),this._offsets=new ys(t.type)}addChild(t,e="0"){if(this.numChildren>0)throw new Error("LargeListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new tr(new S(e,t.type,!0)),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[s,i]of t)if(typeof i>"u")e.set(s,BigInt(0));else{let o=i,a=o.length,c=J(e.set(s,BigInt(a)).buffer[s]);for(let l=-1;++l<a;)n.set(c+l,o[l])}}}});var Oi,rd=d(()=>{pe();yt();At();Oi=class extends de{set(t,e){return super.set(t,e)}setValue(t,e){let n=e instanceof Map?e:new Map(Object.entries(e)),s=this._pending||(this._pending=new Map),i=s.get(t);i&&(this._pendingLength-=i.size),this._pendingLength+=n.size,s.set(t,n)}addChild(t,e=`${this.numChildren}`){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new fe(new S(e,t.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[s,i]of t)if(i===void 0)e.set(s,0);else{let{[s]:o,[s+1]:a}=e.set(s,i.size).buffer;for(let c of i.entries())if(n.set(o,c),++o>=a)break}}}});var Ni,nd=d(()=>{At();Ni=class extends bt{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}}});var Ui,sd=d(()=>{pe();At();yt();Ui=class extends bt{setValue(t,e){let{children:n,type:s}=this;switch(Array.isArray(e)||e.constructor){case!0:return s.children.forEach((i,o)=>n[o].set(t,e[o]));case Map:return s.children.forEach((i,o)=>n[o].set(t,e.get(i.name)));default:return s.children.forEach((i,o)=>n[o].set(t,e[i.name]))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach(n=>n.setValid(t,e)),e}addChild(t,e=`${this.numChildren}`){let n=this.children.push(t);return this.type=new ut([...this.type.children,new S(e,t.type,!0)]),n}}});var gr,Cs,Fs,Es,Os,id=d(()=>{At();rr();gr=class extends kt{};gr.prototype._setValue=hh;Cs=class extends gr{};Cs.prototype._setValue=Zc;Fs=class extends gr{};Fs.prototype._setValue=Hc;Es=class extends gr{};Es.prototype._setValue=Xc;Os=class extends gr{};Os.prototype._setValue=Kc});var br,Ns,Us,Rs,Ps,od=d(()=>{At();rr();br=class extends kt{};br.prototype._setValue=dh;Ns=class extends br{};Ns.prototype._setValue=Jc;Us=class extends br{};Us.prototype._setValue=Qc;Rs=class extends br{};Rs.prototype._setValue=tl;Ps=class extends br{};Ps.prototype._setValue=el});var _n,Ri,Pi,ad=d(()=>{pe();Rr();At();yt();_n=class extends bt{constructor(t){super(t),this._typeIds=new xn(Int8Array,0,1),typeof t.valueToChildTypeId=="function"&&(this._valueToChildTypeId=t.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(t,e){return this.set(this.length,t,e)}set(t,e,n){return n===void 0&&(n=this._valueToChildTypeId(this,e,t)),this.setValue(t,e,n),this}setValue(t,e,n){this._typeIds.set(t,n);let s=this.type.typeIdToChildIndex[n],i=this.children[s];i?.set(t,e),this.length=Math.max(t+1,this.length)}addChild(t,e=`${this.children.length}`){let n=this.children.push(t),{type:{children:s,mode:i,typeIds:o}}=this,a=[...s,new S(e,t.type)];return this.type=new De(i,[...o,n],a),n}_valueToChildTypeId(t,e,n){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},Ri=class extends _n{},Pi=class extends _n{constructor(t){super(t),this._offsets=new xn(Int32Array)}setValue(t,e,n){let s=this._typeIds.set(t,n).buffer[t],i=this.getChildAt(this.type.typeIdToChildIndex[s]),o=this._offsets.set(t,i.length).buffer[t];i?.set(o,e),this.length=Math.max(t+1,this.length)}}});var ks,cd=d(()=>{dn();Dl();Rr();At();ks=class extends de{constructor(t){super(t),this._values=new je(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Xe(e))}_flushPending(t,e){}};ks.prototype._flushPending=In.prototype._flushPending});var zs,ld=d(()=>{dn();Rr();At();Cl();zs=class extends de{constructor(t){super(t),this._values=new je(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Xe(e))}_flushPending(t,e){}};zs.prototype._flushPending=Bn.prototype._flushPending});var Ln,Fl=d(()=>{yt();At();Rr();Gt();hr();Ln=class extends bt{constructor(t){super(t),this._variadicBuffers=[],this._currentBuffer=null,this._currentBufferIndex=0,this._currentBufferOffset=0,this._bufferSize=32*1024*1024,this._views=new je(Uint8Array)}get byteLength(){let t=0;this._views&&(t+=this._views.byteLength),this._nulls&&(t+=this._nulls.byteLength);for(let e of this._variadicBuffers)t+=e.byteLength;return this._currentBuffer&&(t+=this._currentBuffer.byteLength),t}setValue(t,e){return this.writeBinaryValue(t,this.encodeValue(e))}writeBinaryValue(t,e){let n=e.length,s=(t+1)*H.ELEMENT_WIDTH,i=this._views.length;s>i&&this._views.reserve(s-i);let o=this._views.buffer,a=t*H.ELEMENT_WIDTH,c=new DataView(o.buffer,o.byteOffset+a,H.ELEMENT_WIDTH);if(c.setInt32(H.LENGTH_OFFSET,n,!0),n<=H.INLINE_CAPACITY){o.set(e,a+H.INLINE_OFFSET);for(let l=n;l<H.INLINE_CAPACITY;l++)o[a+H.INLINE_OFFSET+l]=0}else{let l=new DataView(e.buffer,e.byteOffset,Math.min(4,n));c.setUint32(H.INLINE_OFFSET,l.getUint32(0,!0),!0),(!this._currentBuffer||this._currentBufferOffset+n>this._bufferSize)&&(this._currentBuffer&&this._variadicBuffers.push(this._currentBuffer.buffer.slice(0,this._currentBufferOffset)),this._currentBuffer=new je(Uint8Array),this._currentBufferIndex=this._variadicBuffers.length,this._currentBufferOffset=0),this._currentBuffer.reserve(n).buffer.set(e,this._currentBufferOffset),c.setInt32(H.BUFFER_INDEX_OFFSET,this._currentBufferIndex,!0),c.setInt32(H.BUFFER_OFFSET_OFFSET,this._currentBufferOffset,!0),this._currentBufferOffset+=n}return this}encodeValue(t){return E(t)}setValid(t,e){let n=(t+1)*H.ELEMENT_WIDTH,s=this._views.length;n>s&&this._views.reserve(n-s);let i=super.setValid(t,e);if(!i){let o=this._views.buffer,a=t*H.ELEMENT_WIDTH;for(let c=0;c<H.ELEMENT_WIDTH;c++)o[a+c]=0}return i}clear(){return this._variadicBuffers=[],this._currentBuffer=null,this._currentBufferIndex=0,this._currentBufferOffset=0,this._views.clear(),super.clear()}flush(){let{type:t,length:e,nullCount:n,_views:s,_nulls:i}=this;this._currentBuffer&&this._currentBufferOffset>0&&(this._variadicBuffers.push(this._currentBuffer.buffer.slice(0,this._currentBufferOffset)),this._currentBuffer=null,this._currentBufferOffset=0);let o=s.flush(e*H.ELEMENT_WIDTH),a=n>0?i.flush(e):void 0,c=this._variadicBuffers.slice();return this._variadicBuffers=[],this._currentBufferIndex=0,this.clear(),M({type:t,length:e,nullCount:n,nullBitmap:a,views:o,variadicBuffers:c})}finish(){return this.finished=!0,this}}});var ki,ud=d(()=>{Fl();dn();ki=class extends Ln{constructor(t){super(t)}setValue(t,e){return this.writeBinaryValue(t,Xe(e))}}});var fd,T0,M0=d(()=>{$e();Dl();Cl();jh();qh();Wh();Yh();Zh();Hh();Xh();Kh();Jh();Qh();td();ed();rd();nd();sd();id();od();ad();cd();ld();Fl();ud();fd=class extends F{visitNull(){return Ni}visitBool(){return bi}visitInt(){return Ce}visitInt8(){return Ii}visitInt16(){return Bi}visitInt32(){return _i}visitInt64(){return Li}visitUint8(){return Ti}visitUint16(){return Mi}visitUint32(){return Di}visitUint64(){return Ci}visitFloat(){return rn}visitFloat16(){return Ai}visitFloat32(){return vi}visitFloat64(){return Si}visitUtf8(){return ks}visitLargeUtf8(){return zs}visitBinary(){return In}visitLargeBinary(){return Bn}visitFixedSizeBinary(){return Ss}visitDate(){return en}visitDateDay(){return xs}visitDateMillisecond(){return As}visitTimestamp(){return gr}visitTimestampSecond(){return Cs}visitTimestampMillisecond(){return Fs}visitTimestampMicrosecond(){return Es}visitTimestampNanosecond(){return Os}visitTime(){return br}visitTimeSecond(){return Ns}visitTimeMillisecond(){return Us}visitTimeMicrosecond(){return Rs}visitTimeNanosecond(){return Ps}visitDecimal(){return vs}visitList(){return Fi}visitLargeList(){return Ei}visitStruct(){return Ui}visitUnion(){return _n}visitDenseUnion(){return Pi}visitSparseUnion(){return Ri}visitDictionary(){return wi}visitInterval(){return zr}visitIntervalDayTime(){return Is}visitIntervalYearMonth(){return Bs}visitIntervalMonthDayNano(){return _s}visitDuration(){return yr}visitDurationSecond(){return Ls}visitDurationMillisecond(){return Ts}visitDurationMicrosecond(){return Ms}visitDurationNanosecond(){return Ds}visitFixedSizeList(){return xi}visitMap(){return Oi}visitBinaryView(){return Ln}visitUtf8View(){return ki}},T0=new fd});function Fe(r,t){return t instanceof r.constructor}function Tn(r,t){return r===t||Fe(r,t)}function Mn(r,t){return r===t||Fe(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function El(r,t){return r===t||Fe(r,t)&&r.precision===t.precision}function Yv(r,t){return r===t||Fe(r,t)&&r.byteWidth===t.byteWidth}function hd(r,t){return r===t||Fe(r,t)&&r.unit===t.unit}function Ha(r,t){return r===t||Fe(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function Xa(r,t){return r===t||Fe(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function D0(r,t){return r===t||Fe(r,t)&&r.children.length===t.children.length&&nn.compareManyFields(r.children,t.children)}function Zv(r,t){return r===t||Fe(r,t)&&r.children.length===t.children.length&&nn.compareManyFields(r.children,t.children)}function dd(r,t){return r===t||Fe(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&nn.compareManyFields(r.children,t.children)}function Hv(r,t){return r===t||Fe(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&nn.visit(r.indices,t.indices)&&nn.visit(r.dictionary,t.dictionary)}function Ol(r,t){return r===t||Fe(r,t)&&r.unit===t.unit}function Ka(r,t){return r===t||Fe(r,t)&&r.unit===t.unit}function Xv(r,t){return r===t||Fe(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&nn.compareManyFields(r.children,t.children)}function Kv(r,t){return r===t||Fe(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&nn.compareManyFields(r.children,t.children)}function zi(r,t){return nn.compareSchemas(r,t)}function C0(r,t){return nn.compareFields(r,t)}function Nl(r,t){return nn.visit(r,t)}var R,nn,Ja=d(()=>{$e();R=class extends F{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)}};R.prototype.visitNull=Tn;R.prototype.visitBool=Tn;R.prototype.visitInt=Mn;R.prototype.visitInt8=Mn;R.prototype.visitInt16=Mn;R.prototype.visitInt32=Mn;R.prototype.visitInt64=Mn;R.prototype.visitUint8=Mn;R.prototype.visitUint16=Mn;R.prototype.visitUint32=Mn;R.prototype.visitUint64=Mn;R.prototype.visitFloat=El;R.prototype.visitFloat16=El;R.prototype.visitFloat32=El;R.prototype.visitFloat64=El;R.prototype.visitUtf8=Tn;R.prototype.visitLargeUtf8=Tn;R.prototype.visitUtf8View=Tn;R.prototype.visitBinary=Tn;R.prototype.visitLargeBinary=Tn;R.prototype.visitBinaryView=Tn;R.prototype.visitFixedSizeBinary=Yv;R.prototype.visitDate=hd;R.prototype.visitDateDay=hd;R.prototype.visitDateMillisecond=hd;R.prototype.visitTimestamp=Ha;R.prototype.visitTimestampSecond=Ha;R.prototype.visitTimestampMillisecond=Ha;R.prototype.visitTimestampMicrosecond=Ha;R.prototype.visitTimestampNanosecond=Ha;R.prototype.visitTime=Xa;R.prototype.visitTimeSecond=Xa;R.prototype.visitTimeMillisecond=Xa;R.prototype.visitTimeMicrosecond=Xa;R.prototype.visitTimeNanosecond=Xa;R.prototype.visitDecimal=Tn;R.prototype.visitList=D0;R.prototype.visitLargeList=D0;R.prototype.visitStruct=Zv;R.prototype.visitUnion=dd;R.prototype.visitDenseUnion=dd;R.prototype.visitSparseUnion=dd;R.prototype.visitDictionary=Hv;R.prototype.visitInterval=Ol;R.prototype.visitIntervalDayTime=Ol;R.prototype.visitIntervalYearMonth=Ol;R.prototype.visitIntervalMonthDayNano=Ol;R.prototype.visitDuration=Ka;R.prototype.visitDurationSecond=Ka;R.prototype.visitDurationMillisecond=Ka;R.prototype.visitDurationMicrosecond=Ka;R.prototype.visitDurationNanosecond=Ka;R.prototype.visitFixedSizeList=Xv;R.prototype.visitMap=Kv;nn=new R});function kr(r){let t=r.type,e=new(T0.getVisitFn(t)())(r);if(t.children&&t.children.length>0){let n=r.children||[],s={nullValues:r.nullValues},i=Array.isArray(n)?((o,a)=>n[a]||s):(({name:o})=>n[o]||s);for(let[o,a]of t.children.entries()){let{type:c}=a,l=i(a,o);e.children.push(kr(Object.assign(Object.assign({},l),{type:c})))}}return e}function No(r,t){if(r instanceof D||r instanceof v||r.type instanceof w||ArrayBuffer.isView(r))return te(r);let e={type:t??Ul(r),nullValues:[null]},n=[...Rl(e)(r)],s=n.length===1?n[0]:n.reduce((i,o)=>i.concat(o));return w.isDictionary(s.type)?s.memoize():s}function pd(r){let t=No(r),e=new ct(new G(t.type.children),t.data[0]);return new st(e)}function Ul(r){if(r.length===0)return new Ot;let t=0,e=0,n=0,s=0,i=0,o=0,a=0,c=0;for(let l of r){if(l==null){++t;continue}switch(typeof l){case"bigint":++o;continue;case"boolean":++a;continue;case"number":++s;continue;case"string":++i;continue;case"object":Array.isArray(l)?++e:Object.prototype.toString.call(l)==="[object Date]"?++c:++n;continue}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}if(s+t===r.length)return new _e;if(i+t===r.length)return new Rt(new ce,new Dt);if(o+t===r.length)return new Qe;if(a+t===r.length)return new le;if(c+t===r.length)return new Jr;if(e+t===r.length){let l=r,u=Ul(l[l.findIndex(f=>f!=null)]);if(l.every(f=>f==null||Nl(u,Ul(f))))return new Ct(new S("",u,!0))}else if(n+t===r.length){let l=new Map;for(let u of r)for(let f of Object.keys(u))!l.has(f)&&u[f]!=null&&l.set(f,new S(f,Ul([u[f]]),!0));return new ut([...l.values()])}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}function Rl(r){let{["queueingStrategy"]:t="count"}=r,{["highWaterMark"]:e=t!=="bytes"?Number.POSITIVE_INFINITY:Math.pow(2,14)}=r,n=t!=="bytes"?"length":"byteLength";return function*(s){let i=0,o=kr(r);for(let a of s)o.append(a)[n]>=e&&++i&&(yield o.toVector());(o.finish().length>0||i===0)&&(yield o.toVector())}}function md(r){let{["queueingStrategy"]:t="count"}=r,{["highWaterMark"]:e=t!=="bytes"?Number.POSITIVE_INFINITY:Math.pow(2,14)}=r,n=t!=="bytes"?"length":"byteLength";return function(s){return xe(this,arguments,function*(){var i,o,a,c;let l=0,u=kr(r);try{for(var f=!0,h=He(s),m;m=yield Y(h.next()),i=m.done,!i;f=!0){c=m.value,f=!1;let y=c;u.append(y)[n]>=e&&++l&&(yield yield Y(u.toVector()))}}catch(y){o={error:y}}finally{try{!f&&!i&&(a=h.return)&&(yield Y(a.call(h)))}finally{if(o)throw o.error}}(u.finish().length>0||l===0)&&(yield yield Y(u.toVector()))})}}var Za=d(()=>{Pe();pe();yt();hr();he();M0();Vi();Dn();Ja()});function Pl(r,t){return Jv(r,t.map(e=>e.data.concat()))}function Jv(r,t){let e=[...r.fields],n=[],s={numBatches:t.reduce((f,h)=>Math.max(f,h.length),0)},i=0,o=0,a=-1,c=t.length,l,u=[];for(;s.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a<c;)u[a]=l=t[a].shift(),o=Math.min(o,l?l.length:o);Number.isFinite(o)&&(u=Qv(e,o,u,t,s),o>0&&(n[i++]=M({type:new ut(e),length:o,nullCount:0,children:u.slice()})))}return[r=r.assign(e),n.map(f=>new ct(r,f))]}function Qv(r,t,e,n,s){var i;let o=(t+63&-64)>>3;for(let a=-1,c=n.length;++a<c;){let l=e[a],u=l?.length;if(u>=t)u===t?e[a]=l:(e[a]=l.slice(0,t),s.numBatches=Math.max(s.numBatches,n[a].unshift(l.slice(t,u-t))));else{let f=r[a];r[a]=f.clone({nullable:!0}),e[a]=(i=l?._changeLengthAndBackfillNullBitmap(t))!==null&&i!==void 0?i:M({type:f.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var F0=d(()=>{hr();yt();Dn()});function yd(r){let t={},e=Object.entries(r);for(let[n,s]of e)t[n]=te(s);return new st(t)}function gd(r){let t={},e=Object.entries(r);for(let[n,s]of e)t[n]=No(s);return new st(t)}var E0,O0,st,Vi=d(()=>{Mt();hr();Za();he();pe();yt();Ja();F0();bl();li();rr();wl();xl();Lo();Dn();O0=Symbol.for("apache-arrow/Table"),st=class r{static isTable(t){return t?.[O0]===!0}constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new G([]),this._offsets=[0],this;let s,i;t[0]instanceof G&&(s=t.shift()),t.at(-1)instanceof Uint32Array&&(i=t.pop());let o=c=>{if(c){if(c instanceof ct)return[c];if(c instanceof r)return c.batches;if(c instanceof D){if(c.type instanceof ut)return[new ct(new G(c.type.children),c)]}else{if(Array.isArray(c))return c.flatMap(l=>o(l));if(typeof c[Symbol.iterator]=="function")return[...c].flatMap(l=>o(l));if(typeof c=="object"){let l=Object.keys(c),u=l.map(m=>new v([c[m]])),f=s??new G(l.map((m,y)=>new S(String(m),u[y].type,u[y].nullable))),[,h]=Pl(f,u);return h.length===0?[new ct(c)]:h}}}return[]},a=t.flatMap(c=>o(c));if(s=(n=s??((e=a[0])===null||e===void 0?void 0:e.schema))!==null&&n!==void 0?n:new G([]),!(s instanceof G))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let c of a){if(!(c instanceof ct))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!zi(s,c.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=s,this.batches=a,this._offsets=i??pl(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=dl(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(ui(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?Do.visit(new v(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
|
|
14
14
|
${this.toArray().join(`,
|
|
15
15
|
`)}
|
|
16
|
-
]`}concat(...t){let e=this.schema,n=this.data.concat(t.flatMap(({data:s})=>s));return new r(e,n.map(s=>new ct(e,s)))}slice(t,e){let n=this.schema;[t,e]=Fa({length:this.numRows},t,e);let s=tl(this.data,this._offsets,t,e);return new r(n,s.map(i=>new ct(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){let e=this.data.map(n=>n.children[t]);if(e.length===0){let{type:n}=this.schema.fields[t],s=M({type:n,length:0,nullCount:0});e.push(s._changeLengthAndBackfillNullBitmap(this.numRows))}return new A(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 A([M({type:new Et,length:this.numRows})]));let i=n.fields.slice(),o=i[t].clone({type:e.type}),a=this.schema.fields.map((c,l)=>this.getChildAt(l));[i[t],a[t]]=[o,e],[n,s]=Sl(n,a)}return new r(n,s)}select(t){let 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){let e=this.schema.selectAt(t),n=this.batches.map(s=>s.selectAt(t));return new r(e,n)}assign(t){let e=this.schema.fields,[n,s]=t.schema.fields.reduce((a,c,l)=>{let[u,f]=a,h=e.findIndex(m=>m.name===c.name);return~h?f[h]=l:u.push(l),a},[[],[]]),i=this.schema.assign(t.schema),o=[...e.map((a,c)=>[c,s[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...n.map(a=>t.getChildAt(a))].filter(Boolean);return new r(...Sl(i,o))}};$0=Symbol.toStringTag;st[$0]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r[W0]=!0,r.isValid=So(Ua),r.get=So(Pt.getVisitFn(d.Struct)),r.set=el(Qt.getVisitFn(d.Struct)),r.indexOf=rl(ui.getVisitFn(d.Struct)),"Table"))(st.prototype);Object.defineProperty(st,Symbol.hasInstance,{value:function(t){return Function.prototype[Symbol.hasInstance].call(this,t)||this===st&&st.isTable(t)}})});function Y0(r,t,e=t.reduce((n,s)=>Math.max(n,s.length),0)){var n;let s=[...r.fields],i=[...t],o=(e+63&-64)>>3;for(let[a,c]of r.fields.entries()){let l=t[a];(!l||l.length!==e)&&(s[a]=c.clone({nullable:!0}),i[a]=(n=l?._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:M({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(s),M({type:new ut(s),length:e,children:i})]}function X0(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,o=r.length;++i<o;){let{type:a}=r[i],c=t[i];for(let l of[c,...((s=c?.dictionary)===null||s===void 0?void 0:s.data)||[]])X0(a.children,l?.children,e);if(w.isDictionary(a)){let{id:l}=a;if(!e.has(l))c?.dictionary&&e.set(l,c.dictionary);else if(e.get(l)!==c.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var Z0,H0,ct,Pi,Mn=p(()=>{hr();Ri();he();pe();yt();vo();ii();rr();sl();il();H0=Symbol.for("apache-arrow/RecordBatch"),ct=class r{static isRecordBatch(t){return t?.[H0]===!0}constructor(...t){switch(t.length){case 3:case 2:{if([this.schema]=t,!(this.schema instanceof G))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=M({nullCount:0,type:new ut(this.schema.fields),children:this.schema.fields.map(e=>M({type:e.type,nullCount:0}))}),this._metadata=new Map]=t,!(this.data instanceof D))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Y0(this.schema,this.data.children,this.data.length);break}case 1:{let[e]=t,{fields:n,children:s,length:i}=Object.keys(e).reduce((c,l,u)=>(c.children[u]=e[l],c.length=Math.max(c.length,e[l].length),c.fields[u]=S.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new G(n),a=M({type:new ut(n),length:i,children:s,nullCount:0});[this.schema,this.data]=Y0(o,a.children,i),this._metadata=new Map;break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get metadata(){return this._metadata}get dictionaries(){return this._dictionaries||(this._dictionaries=X0(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return Pt.visit(this.data,t)}at(t){return this.get(oi(t,this.numRows))}set(t,e){return Qt.visit(this.data,t,e)}indexOf(t,e){return ui.visit(this.data,t,e)}[Symbol.iterator](){return Io.visit(new A([this.data]))}toArray(){return[...this]}concat(...t){return new st(this.schema,[this,...t])}slice(t,e){let[n]=new A([this.data]).slice(t,e).data;return new r(this.schema,n,this._metadata)}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 A([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 A([M({type:new Et,length:this.numRows})]));let i=n.fields.slice(),o=s.children.slice(),a=i[t].clone({type:e.type});[i[t],o[t]]=[a,e.data[0]],n=new G(i,new Map(this.schema.metadata)),s=M({type:new ut(i),length:s.length,children:o})}return new r(n,s,this._metadata)}select(t){let e=this.schema.select(t),n=new ut(e.fields),s=[];for(let i of t){let o=this.schema.fields.findIndex(a=>a.name===i);~o&&(s[o]=this.data.children[o])}return new r(e,M({type:n,length:this.numRows,children:s}),this._metadata)}selectAt(t){let e=this.schema.selectAt(t),n=t.map(i=>this.data.children[i]).filter(Boolean),s=M({type:new ut(e.fields),length:this.numRows,children:n});return new r(e,s,this._metadata)}};Z0=Symbol.toStringTag;ct[Z0]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r[H0]=!0,"RecordBatch"))(ct.prototype);Object.defineProperty(ct,Symbol.hasInstance,{value:function(t){return Function.prototype[Symbol.hasInstance].call(this,t)||this===ct&&ct.isRecordBatch(t)}});Pi=class extends ct{constructor(t,e){let n=t.fields.map(i=>M({type:i.type})),s=M({type:new ut(t.fields),length:0,nullCount:0,children:n});super(t,s,e||new Map)}}});function Bl(r,t=0){for(let e=-1,n=Do.length;++e<n;)if(Do[e]!==r[t+e])return!1;return!0}var Zh,Hh,K0,J0,ks,ki,zi,Il,Yh,Do,Co,Xh,Q0,_l=p(()=>{Pe();Mt();nt();ms();qn();uh();Gt();ys();Ra();Zh=r=>`Expected ${Q[r]} Message in stream, but was null or length 0.`,Hh=r=>`Header pointer of flatbuffer-encoded ${Q[r]} Message is null or length 0.`,K0=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,J0=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,ks=class{constructor(t){this.source=t instanceof mr?t:new mr(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?At:t.value===-1&&(t=this.readMetadataLength()).done?At:(t=this.readMetadata(t.value)).done?At: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(Zh(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=O(this.source.read(t));if(e.byteLength<t)throw new Error(J0(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=Q.Schema,n=this.readMessage(e),s=n?.header();if(t&&!s)throw new Error(Hh(e));return s}readMetadataLength(){let t=this.source.read(Il),e=t&&new Zt(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}}readMetadata(t){let e=this.source.read(t);if(!e)return At;if(e.byteLength<t)throw new Error(K0(t,e.byteLength));return{done:!1,value:ye.decode(e)}}},ki=class{constructor(t,e){this.source=t instanceof $e?t:mc(t)?new gs(t,e):new $e(t)}[Symbol.asyncIterator](){return this}next(){return B(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?At:t.value===-1&&(t=yield this.readMetadataLength()).done?At:(t=yield this.readMetadata(t.value)).done?At:t})}throw(t){return B(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return B(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return B(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(Zh(t));return e.value})}readMessageBody(t){return B(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=O(yield this.source.read(t));if(e.byteLength<t)throw new Error(J0(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return B(this,arguments,void 0,function*(t=!1){let e=Q.Schema,n=yield this.readMessage(e),s=n?.header();if(t&&!s)throw new Error(Hh(e));return s})}readMetadataLength(){return B(this,void 0,void 0,function*(){let t=yield this.source.read(Il),e=t&&new Zt(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}})}readMetadata(t){return B(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return At;if(e.byteLength<t)throw new Error(K0(t,e.byteLength));return{done:!1,value:ye.decode(e)}})}},zi=class extends ks{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Na?t:new Na(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:ye.fromJSON(t.schema,Q.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:ye.fromJSON(e,Q.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:ye.fromJSON(e,Q.RecordBatch)}}return this._body=[],At}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]||[],...i.VIEWS&&[i.VIEWS]||[],...i.VARIADIC_DATA_BUFFERS||[],...e(i.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(Zh(t));return e.value}readSchema(){let t=Q.Schema,e=this.readMessage(t),n=e?.header();if(!e||!n)throw new Error(Hh(t));return n}},Il=4,Yh="ARROW1",Do=new Uint8Array(Yh.length);for(let r=0;r<Yh.length;r+=1)Do[r]=Yh.codePointAt(r);Co=Do.length,Xh=Co+Il,Q0=Co*2+Il});var Kh,Jh,tg,eg=p(()=>{ao();Kh=class{constructor(){this.LZ4_FRAME_MAGIC=new Uint8Array([4,34,77,24]),this.MIN_HEADER_LENGTH=7}isValidCodecEncode(t){let e=new Uint8Array([1,2,3,4,5,6,7,8]),n=t.encode(e);return this._isValidCompressed(n)}_isValidCompressed(t){return this._hasMinimumLength(t)&&this._hasValidMagicNumber(t)&&this._hasValidVersion(t)}_hasMinimumLength(t){return t.length>=this.MIN_HEADER_LENGTH}_hasValidMagicNumber(t){return this.LZ4_FRAME_MAGIC.every((e,n)=>t[n]===e)}_hasValidVersion(t){return(t[4]&192)>>6===1}},Jh=class{constructor(){this.ZSTD_MAGIC=new Uint8Array([40,181,47,253]),this.MIN_HEADER_LENGTH=6}isValidCodecEncode(t){let e=new Uint8Array([1,2,3,4,5,6,7,8]),n=t.encode(e);return this._isValidCompressed(n)}_isValidCompressed(t){return this._hasMinimumLength(t)&&this._hasValidMagicNumber(t)}_hasMinimumLength(t){return t.length>=this.MIN_HEADER_LENGTH}_hasValidMagicNumber(t){return this.ZSTD_MAGIC.every((e,n)=>t[n]===e)}},tg={[Ht.LZ4_FRAME]:new Kh,[Ht.ZSTD]:new Jh}});var Qh,zs,Ll=p(()=>{ao();eg();Qh=class{constructor(){this.registry={}}set(t,e){if(e?.encode&&typeof e.encode=="function"&&!tg[t].isValidCodecEncode(e))throw new Error(`Encoder for ${Ht[t]} is not valid.`);this.registry[t]=e}get(t){var e;return((e=this.registry)===null||e===void 0?void 0:e[t])||null}},zs=new Qh});function ig(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*rg(r){let t=Oe.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function ng(r){return xe(this,arguments,function*(){let e=yield Y(Oe.from(r));try{if(!(yield Y(e.open({autoDestroy:!1}))).closed)do yield yield Y(e);while(!(yield Y(e.reset().open())).closed)}finally{yield Y(e.cancel())}})}function rA(r){return new zr(new ed(r))}function nA(r){let t=r.peek(Co+7&-8);return t&&t.byteLength>=4?Bl(t)?new Cn(new Ml(r.read())):new zr(new Oo(r)):new zr(new Oo((function*(){})()))}function sA(r){return B(this,void 0,void 0,function*(){let t=yield r.peek(Co+7&-8);return t&&t.byteLength>=4?Bl(t)?new Cn(new Ml(yield r.read())):new Dn(new Eo(r)):new Dn(new Eo((function(){return xe(this,arguments,function*(){})})()))})}function iA(r){return B(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new gs(r,t);return t>=Q0&&Bl(yield e.readAt(0,Co+7&-8))?new Fo(new td(e)):new Dn(new Eo(e))})}var Oe,zr,Dn,Cn,Fo,Tl,Oo,Eo,Ml,td,ed,Wa=p(()=>{Pe();hr();he();yt();Mt();oh();aa();ms();ys();uh();k0();Mn();Ra();_l();qn();Ll();Xr();nt();Oe=class r extends di{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){let e=this._impl.open(t);return Ke(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 Yt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Yt.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof r?t:dc(t)?rA(t):mc(t)?iA(t):Ke(t)?B(this,void 0,void 0,function*(){return yield r.from(yield t)}):yc(t)||sa(t)||bc(t)||lr(t)?sA(new $e(t)):nA(new mr(t))}static readAll(t){return t instanceof r?t.isSync()?rg(t):ng(t):dc(t)||ArrayBuffer.isView(t)||Ir(t)||pc(t)?rg(t):ng(t)}},zr=class extends Oe{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return xe(this,arguments,function*(){yield Y(yield*so(He(this[Symbol.iterator]())))})}},Dn=class extends Oe{constructor(t){super(t),this._impl=t}readAll(){return B(this,void 0,void 0,function*(){var t,e,n,s;let i=new Array;try{for(var o=!0,a=He(this),c;c=yield a.next(),t=c.done,!t;o=!0){s=c.value,o=!1;let l=s;i.push(l)}}catch(l){e={error:l}}finally{try{!o&&!t&&(n=a.return)&&(yield n.call(a))}finally{if(e)throw e.error}}return i})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Cn=class extends zr{constructor(t){super(t),this._impl=t}},Fo=class extends Dn{constructor(t){super(t),this._impl=t}},Tl=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e,n){let s;if(t.compression!=null){let o=zs.get(t.compression.type);if(o?.decode&&typeof o.decode=="function"){let{decommpressedBody:a,buffers:c}=this._decompressBuffers(t,e,o);s=this._loadCompressedVectors(t,a,this.schema.fields),t=new zt(t.length,t.nodes,c,null)}else throw new Error("Record batch is compressed but codec not found")}else s=this._loadVectors(t,e,this.schema.fields);let i=M({type:new ut(this.schema.fields),length:t.length,children:s});return new ct(this.schema,i,n)}_loadDictionaryBatch(t,e){let{id:n,isDelta:s}=t,{dictionaries:i,schema:o}=this,a=i.get(n),c=o.dictionaries.get(n),l;if(t.data.compression!=null){let u=zs.get(t.data.compression.type);if(u?.decode&&typeof u.decode=="function"){let{decommpressedBody:f,buffers:h}=this._decompressBuffers(t.data,e,u);l=this._loadCompressedVectors(t.data,f,[c]),t=new me(new zt(t.data.length,t.data.nodes,h,null,t.data.variadicBufferCounts),n,s)}else throw new Error("Dictionary batch is compressed but codec not found")}else l=this._loadVectors(t.data,e,[c]);return(a&&s?a.concat(new A(l)):new A(l)).memoize()}_loadVectors(t,e,n){return new To(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion,t.variadicBufferCounts).visitMany(n)}_loadCompressedVectors(t,e,n){return new pl(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion,t.variadicBufferCounts).visitMany(n)}_decompressBuffers(t,e,n){let s=[],i=[],o=0;for(let{offset:a,length:c}of t.buffers){if(c===0){s.push(new Uint8Array(0)),i.push(new Ut(o,0));continue}let l=new Zt(e.subarray(a,a+c)),u=J(l.readInt64(0)),f=l.bytes().subarray(8),h=u===-1?f:n.decode(f);s.push(h);let m=(o+7&-8)-o;o+=m,i.push(new Ut(o,h.length)),o+=h.length}return{decommpressedBody:s,buffers:i}}},Oo=class extends Tl{constructor(t,e){super(e),this._reader=dc(t)?new zi(this._handle=t):new ks(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=ig(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):At}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):At}next(){if(this.closed)return At;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),s=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,s,t.metadata)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let 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 Pi(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},Eo=class extends Tl{constructor(t,e){super(e),this._reader=new ki(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return B(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 B(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=ig(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return B(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):At})}return(t){return B(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):At})}next(){return B(this,void 0,void 0,function*(){if(this.closed)return At;let t,{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),s=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,s,t.metadata)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let 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 Pi(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return B(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Ml=class extends Oo{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 Pa?t:new Pa(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){let s=this._reader.readMessage(Q.RecordBatch);if(s?.isRecordBatch()){let i=s.header(),o=this._reader.readMessageBody(s.bodyLength);return this._loadRecordBatch(i,o,s.metadata)}}return null}_readDictionaryBatch(t){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){let s=this._reader.readMessage(Q.DictionaryBatch);if(s?.isDictionaryBatch()){let i=s.header(),o=this._reader.readMessageBody(s.bodyLength),a=this._loadDictionaryBatch(i,o);this.dictionaries.set(i.id,a)}}}_readFooter(){let{_handle:t}=this,e=t.size-Xh,n=t.readInt32(e),s=t.readAt(e-n,n);return xn.decode(s)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let 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}},td=class extends Eo{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...e){let n=typeof e[0]!="number"?e.shift():void 0,s=e[0]instanceof Map?e.shift():void 0;super(t instanceof gs?t:new gs(t,n),s)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return B(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return B(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){let s=yield this._reader.readMessage(Q.RecordBatch);if(s?.isRecordBatch()){let i=s.header(),o=yield this._reader.readMessageBody(s.bodyLength);return this._loadRecordBatch(i,o,s.metadata)}}return null})}_readDictionaryBatch(t){return B(this,void 0,void 0,function*(){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){let s=yield this._reader.readMessage(Q.DictionaryBatch);if(s?.isDictionaryBatch()){let i=s.header(),o=yield this._reader.readMessageBody(s.bodyLength),a=this._loadDictionaryBatch(i,o);this.dictionaries.set(i.id,a)}}})}_readFooter(){return B(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-Xh,n=yield t.readInt32(e),s=yield t.readAt(e-n,n);return xn.decode(s)})}_readNextMessageAndValidate(t){return B(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},ed=class extends Oo{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new dl(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion,t.variadicBufferCounts).visitMany(n)}}});function ir(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new Ut(this._byteLength,t)),this._byteLength+=t,this}function oA(r){var t;let{type:e,length:n,typeIds:s,valueOffsets:i}=r;if(ir.call(this,s),e.mode===lt.Sparse)return rd.call(this,r);if(e.mode===lt.Dense){if(r.offset<=0)return ir.call(this,i),rd.call(this,r);{let o=new Int32Array(n),a=Object.create(null),c=Object.create(null);for(let l,u,f=-1;++f<n;)(l=s[f])!==void 0&&((u=a[l])===void 0&&(u=a[l]=i[f]),o[f]=i[f]-u,c[l]=((t=c[l])!==null&&t!==void 0?t:0)+1);ir.call(this,o),this.visitMany(r.children.map((l,u)=>{let f=e.typeIds[u],h=a[f],m=c[f];return l.slice(h,Math.min(n,m))}))}}return this}function aA(r){let t;return r.nullCount>=r.length?ir.call(this,new Uint8Array(r.length+7>>3)):(t=r.values)instanceof Uint8Array?ir.call(this,ai(r.offset,r.length,t)):ir.call(this,ci(r.values))}function Fn(r){return ir.call(this,r.values.subarray(0,r.length*r.stride))}function Dl(r){let{length:t,values:e,valueOffsets:n}=r,s=J(n[0]),i=J(n[t]),o=Math.min(i-s,e.byteLength-s);return ir.call(this,wc(-s,t+1,n)),ir.call(this,e.subarray(s,s+o)),this}function og(r){let{offset:t,length:e,stride:n,values:s,variadicBuffers:i=[]}=r;if(!s)throw new Error("BinaryView data is missing view buffer");let o=t*n,a=o+e*n;ir.call(this,s.subarray(o,a));for(let c of i)ir.call(this,c);return this._variadicBufferCounts.push(i.length),this}function Cl(r){let{length:t,valueOffsets:e}=r;if(e){let n=J(e[0]),s=J(e[t]);return ir.call(this,wc(-n,t+1,e)),this.visit(r.children[0].slice(n,s-n))}return this.visit(r.children[0])}function rd(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}var St,ag=p(()=>{he();je();Mt();Mn();Gt();li();ms();yt();Xr();St=class r extends F{static assemble(...t){let e=s=>s.flatMap(i=>Array.isArray(i)?e(i):i instanceof ct?i.data.children:i.data),n=new r;return n.visitMany(e(t)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[],this._variadicBufferCounts=[]}visit(t){if(t instanceof A)return this.visitMany(t.data),this;let{type:e}=t;if(!w.isDictionary(e)){let{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(w.isUnion(e))this.nodes.push(new dr(n,0));else{let{nullCount:s}=t;w.isNull(e)||ir.call(this,s<=0?new Uint8Array(0):ai(t.offset,n,t.nullBitmap)),this.nodes.push(new dr(n,s))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}get variadicBufferCounts(){return this._variadicBufferCounts}};St.prototype.visitBool=aA;St.prototype.visitInt=Fn;St.prototype.visitFloat=Fn;St.prototype.visitUtf8=Dl;St.prototype.visitLargeUtf8=Dl;St.prototype.visitUtf8View=og;St.prototype.visitBinary=Dl;St.prototype.visitLargeBinary=Dl;St.prototype.visitBinaryView=og;St.prototype.visitFixedSizeBinary=Fn;St.prototype.visitDate=Fn;St.prototype.visitTimestamp=Fn;St.prototype.visitTime=Fn;St.prototype.visitDecimal=Fn;St.prototype.visitList=Cl;St.prototype.visitLargeList=Cl;St.prototype.visitStruct=rd;St.prototype.visitUnion=oA;St.prototype.visitInterval=Fn;St.prototype.visitDuration=Fn;St.prototype.visitFixedSizeList=Cl;St.prototype.visitMap=Cl});var Fl,cg=p(()=>{je();Lc();Mt();Fl=class extends F{visit(t){return t==null?void 0:super.visit(t)}visitNull({typeId:t}){return{name:k[t].toLowerCase()}}visitInt({typeId:t,bitWidth:e,isSigned:n}){return{name:k[t].toLowerCase(),bitWidth:e,isSigned:n}}visitFloat({typeId:t,precision:e}){return{name:k[t].toLowerCase(),precision:ot[e]}}visitBinary({typeId:t}){return{name:k[t].toLowerCase()}}visitLargeBinary({typeId:t}){return{name:k[t].toLowerCase()}}visitBinaryView({typeId:t}){return{name:k[t].toLowerCase()}}visitBool({typeId:t}){return{name:k[t].toLowerCase()}}visitUtf8({typeId:t}){return{name:k[t].toLowerCase()}}visitLargeUtf8({typeId:t}){return{name:k[t].toLowerCase()}}visitUtf8View({typeId:t}){return{name:k[t].toLowerCase()}}visitDecimal({typeId:t,scale:e,precision:n,bitWidth:s}){return{name:k[t].toLowerCase(),scale:e,precision:n,bitWidth:s}}visitDate({typeId:t,unit:e}){return{name:k[t].toLowerCase(),unit:mt[e]}}visitTime({typeId:t,unit:e,bitWidth:n}){return{name:k[t].toLowerCase(),unit:v[e],bitWidth:n}}visitTimestamp({typeId:t,timezone:e,unit:n}){return{name:k[t].toLowerCase(),unit:v[n],timezone:e}}visitInterval({typeId:t,unit:e}){return{name:k[t].toLowerCase(),unit:et[e]}}visitDuration({typeId:t,unit:e}){return{name:k[t].toLocaleLowerCase(),unit:v[e]}}visitList({typeId:t}){return{name:k[t].toLowerCase()}}visitLargeList({typeId:t}){return{name:k[t].toLowerCase()}}visitStruct({typeId:t}){return{name:k[t].toLowerCase()}}visitUnion({typeId:t,mode:e,typeIds:n}){return{name:k[t].toLowerCase(),mode:lt[e].toUpperCase(),typeIds:[...n]}}visitDictionary(t){return this.visit(t.dictionary)}visitFixedSizeBinary({typeId:t,byteWidth:e}){return{name:k[t].toLowerCase(),byteWidth:e}}visitFixedSizeList({typeId:t,listSize:e}){return{name:k[t].toLowerCase(),listSize:e}}visitMap({typeId:t,keysSorted:e}){return{name:k[t].toLowerCase(),keysSorted:e}}}});function*nd(r){for(let t of r)yield t.reduce((e,n)=>`${e}${("0"+(n&255).toString(16)).slice(-2)}`,"").toUpperCase()}function*On(r,t){let e=new Uint32Array(r.buffer,r.byteOffset,r.byteLength/Uint32Array.BYTES_PER_ELEMENT);for(let n=-1,s=e.length/t;++n<s;)yield`${si.new(e.subarray((n+0)*t,(n+1)*t),!1)}`}function lg(r,t){let n=r.values,s=new DataView(n.buffer,n.byteOffset,n.byteLength),i=n.byteLength/16,o=h=>Array.from(h).map(m=>("0"+(m&255).toString(16)).slice(-2)).join("").toUpperCase(),a=Array.from({length:i},(h,m)=>{let y=m*16,g=s.getInt32(y,!0);return[y,g]}).map(([h,m])=>m>12?{SIZE:m,PREFIX_HEX:o(n.subarray(h+4,h+8)),BUFFER_INDEX:s.getInt32(h+8,!0),OFFSET:s.getInt32(h+12,!0)}:{SIZE:m,INLINED:t(n.subarray(h+4,h+4+m))}),c=[...new Set(a.map(h=>h.BUFFER_INDEX).filter(h=>h!==void 0))],l=c.map(h=>o(r.variadicBuffers[h])),u=new Map(c.map((h,m)=>[h,m]));return{VIEWS:a.map(h=>h.BUFFER_INDEX!==void 0?Object.assign(Object.assign({},h),{BUFFER_INDEX:u.get(h.BUFFER_INDEX)}):h),VARIADIC_DATA_BUFFERS:l}}var Ya,ug=p(()=>{Mc();he();je();Mt();Mt();li();hl();yt();Ya=class r extends F{static assemble(...t){let e=new r;return t.map(({schema:n,data:s})=>e.visitMany(n.fields,s.children))}visit({name:t},e){let{length:n}=e,{offset:s,nullCount:i,nullBitmap:o}=e,a=w.isDictionary(e.type)?e.type.indices:e.type,c=Object.assign([],e.buffers,{[Z.VALIDITY]:void 0});return Object.assign({name:t,count:n,VALIDITY:w.isNull(a)||w.isUnion(a)?void 0:i<=0?Array.from({length:n},()=>1):[...new Qr(o,s,n,null,Kc)]},super.visit(e.clone(a,s,n,0,c)))}visitNull(){return{}}visitBool({values:t,offset:e,length:n}){return{DATA:[...new Qr(t,e,n,null,Ao)]}}visitInt(t){return{DATA:t.type.bitWidth<64?[...t.values]:[...On(t.values,2)]}}visitFloat(t){return{DATA:[...t.values]}}visitUtf8(t){return{DATA:[...new A([t])],OFFSET:[...t.valueOffsets]}}visitLargeUtf8(t){return{DATA:[...new A([t])],OFFSET:[...On(t.valueOffsets,2)]}}visitBinary(t){return{DATA:[...nd(new A([t]))],OFFSET:[...t.valueOffsets]}}visitLargeBinary(t){return{DATA:[...nd(new A([t]))],OFFSET:[...On(t.valueOffsets,2)]}}visitBinaryView(t){return lg(t,e=>Array.from(e).map(n=>("0"+(n&255).toString(16)).slice(-2)).join("").toUpperCase())}visitUtf8View(t){return lg(t,e=>Array.from(e).map(n=>String.fromCodePoint(n)).join(""))}visitFixedSizeBinary(t){return{DATA:[...nd(new A([t]))]}}visitDate(t){return{DATA:t.type.unit===mt.DAY?[...t.values]:[...On(t.values,2)]}}visitTimestamp(t){return{DATA:[...On(t.values,2)]}}visitTime(t){return{DATA:t.type.unit<v.MICROSECOND?[...t.values]:[...On(t.values,2)]}}visitDecimal(t){return{DATA:[...On(t.values,4)]}}visitList(t){return{OFFSET:[...t.valueOffsets],children:this.visitMany(t.type.children,t.children)}}visitLargeList(t){return{OFFSET:[...On(t.valueOffsets,2)],children:this.visitMany(t.type.children,t.children)}}visitStruct(t){return{children:this.visitMany(t.type.children,t.children)}}visitUnion(t){return{TYPE_ID:[...t.typeIds],OFFSET:t.type.mode===lt.Dense?[...t.valueOffsets]:void 0,children:this.visitMany(t.type.children,t.children)}}visitInterval(t){switch(t.type.unit){case et.YEAR_MONTH:return{DATA:[...t.values]};case et.DAY_TIME:return{DATA:yh(t.values)};case et.MONTH_DAY_NANO:return{DATA:gh(t.values,!0)}}}visitDuration(t){return{DATA:[...On(t.values,2)]}}visitFixedSizeList(t){return{children:this.visitMany(t.type.children,t.children)}}visitMap(t){return{OFFSET:[...t.valueOffsets],children:this.visitMany(t.type.children,t.children)}}}});function sd(r,t){let e=t;t instanceof st&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function id(r,t){return B(this,void 0,void 0,function*(){var e,n,s,i,o,a,c;try{for(e=!0,n=He(t);s=yield n.next(),i=s.done,!i;e=!0){c=s.value,e=!1;let l=c;r.write(l)}}catch(l){o={error:l}}finally{try{!e&&!i&&(a=n.return)&&(yield a.call(n))}finally{if(o)throw o.error}}return r.finish()})}function fg({name:r,type:t,nullable:e}){let n=new Fl;return{name:r,nullable:e,type:n.visit(t),children:(t.children||[]).map(s=>fg(s)),dictionary:w.isDictionary(t)?{id:t.id,isOrdered:t.isOrdered,indexType:n.visit(t.indices)}:void 0}}function cA(r,t,e=!1){let[n]=Ya.assemble(new ct({[t]:r}));return JSON.stringify({id:t,isDelta:e,data:{count:r.length,columns:n}},null,2)}function lA(r){let[t]=Ya.assemble(r);return JSON.stringify({count:r.numRows,columns:t},null,2)}var nn,En,Un,Za,Ol=p(()=>{Pe();Ri();_l();he();yt();ms();ms();oh();Mt();$a();ys();ag();cg();ug();Gt();Mn();Ra();qn();ao();Ll();nt();nn=class extends di{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){if(super(),this._position=0,this._started=!1,this._compression=null,this._sink=new pr,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,ve(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1,compressionType:null}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1,t.compressionType!=null){if(this._writeLegacyIpcFormat)throw new Error("Legacy IPC format does not support columnar compression. Use modern IPC format (writeLegacyIpcFormat=false).");if(Object.values(Ht).includes(t.compressionType))this._compression=new hi(t.compressionType);else{let e=Object.values(Ht).filter(n=>typeof n=="string");throw new Error(`Unsupported compressionType: ${t.compressionType} Available types: ${e.join(", ")}`)}}else this._compression=null}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return Ke(t)?t.then(e=>this.writeAll(e)):lr(t)?id(this,t):sd(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){return t===this._sink||t instanceof pr?this._sink=t:(this._sink=new pr,t&&Mm(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&Dm(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!e||!Ni(e,this._schema))&&(e==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof st&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof ct&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!Ni(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof ct?t instanceof Pi||this._writeRecordBatch(t):t instanceof st?this.writeAll(t.batches):Ir(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,s=ye.encode(t),i=s.byteLength,o=this._writeLegacyIpcFormat?4:8,a=i+o+n&~n,c=a-i-o;return t.headerType===Q.RecordBatch?this._recordBatchBlocks.push(new Rr(a,t.bodyLength,this._position)):t.headerType===Q.DictionaryBatch&&this._dictionaryBlocks.push(new Rr(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),i>0&&this._write(s),this._writePadding(c)}_write(t){if(this._started){let e=O(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(ye.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Do)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:s,buffers:i,variadicBufferCounts:o}=this._assembleRecordBatch(t),a=new zt(t.numRows,n,s,this._compression,o,t.metadata),c=ye.from(a,e);return this._writeDictionaries(t)._writeMessage(c)._writeBodyBuffers(i)}_assembleRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:s,buffers:i,variadicBufferCounts:o}=St.assemble(t);return this._compression!=null&&({byteLength:e,bufferRegions:s,buffers:i}=this._compressBodyBuffers(i)),{byteLength:e,nodes:n,bufferRegions:s,buffers:i,variadicBufferCounts:o}}_compressBodyBuffers(t){let e=zs.get(this._compression.type);if(!e?.encode||typeof e.encode!="function")throw new Error(`Codec for compression type "${Ht[this._compression.type]}" has invalid encode method`);let n=0,s=[],i=[];for(let a of t){let c=O(a);if(c.length===0){s.push(new Uint8Array(0),new Uint8Array(0)),i.push(new Ut(n,0));continue}let l=e.encode(c),u=l.length<c.length,f=u?l:c,h=u?f.length:-1,m=new Zt(new Uint8Array(8));m.writeInt64(0,BigInt(h)),s.push(m.bytes(),new Uint8Array(f));let y=(n+7&-8)-n;n+=y;let g=8+f.length;i.push(new Ut(n,g)),n+=g}let o=(n+7&-8)-n;return n+=o,{byteLength:n,bufferRegions:i,buffers:s}}_writeDictionaryBatch(t,e,n=!1){let{byteLength:s,nodes:i,bufferRegions:o,buffers:a,variadicBufferCounts:c}=this._assembleRecordBatch(new A([t])),l=new zt(t.length,i,o,this._compression,c),u=new me(l,e,n),f=ye.from(u,s);return this._writeMessage(f)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e=this._compression!=null?2:1,n=new Array(e);for(let s=0;s<t.length;s+=e){let i=0;for(let a=-1;++a<e;)n[a]=t[s+a],i+=n[a].byteLength;if(i===0)continue;for(let a of n)this._write(a);let o=(i+7&-8)-i;o>0&&this._writePadding(o)}return this}_writeDictionaries(t){var e,n;for(let[s,i]of t.dictionaries){let o=(e=i?.data)!==null&&e!==void 0?e:[],a=this._seenDictionaries.get(s),c=(n=this._dictionaryDeltaOffsets.get(s))!==null&&n!==void 0?n:0;if(!a||a.data[0]!==o[0])for(let[l,u]of o.entries())this._writeDictionaryBatch(u,s,l>0);else if(c<o.length)for(let l of o.slice(c))this._writeDictionaryBatch(l,s,!0);this._seenDictionaries.set(s,i),this._dictionaryDeltaOffsets.set(s,o.length)}return this}},En=class r extends nn{static writeAll(t,e){let n=new r(e);return Ke(t)?t.then(s=>n.writeAll(s)):lr(t)?id(n,t):sd(n,t)}},Un=class r extends nn{static writeAll(t,e){let n=new r(e);return Ke(t)?t.then(s=>n.writeAll(s)):lr(t)?id(n,t):sd(n,t)}constructor(t){super(t),this._autoDestroy=!0,this._writeLegacyIpcFormat=!1}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,n=!1){if(!n&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,n)}_writeFooter(t){let e=xn.encode(new xn(t,ht.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}},Za=class r extends nn{static writeAll(t){return new r().writeAll(t)}constructor(){super(),this._autoDestroy=!0,this._recordBatches=[],this._recordBatchesWithDictionaries=[]}_writeMessage(){return this}_writeFooter(t){return this}_writeSchema(t){return this._write(`{
|
|
17
|
-
"schema": ${JSON.stringify({fields:t.fields.map(e=>
|
|
18
|
-
`),this._write(
|
|
16
|
+
]`}concat(...t){let e=this.schema,n=this.data.concat(t.flatMap(({data:s})=>s));return new r(e,n.map(s=>new ct(e,s)))}slice(t,e){let n=this.schema;[t,e]=ka({length:this.numRows},t,e);let s=ml(this.data,this._offsets,t,e);return new r(n,s.map(i=>new ct(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){let e=this.data.map(n=>n.children[t]);if(e.length===0){let{type:n}=this.schema.fields[t],s=M({type:n,length:0,nullCount:0});e.push(s._changeLengthAndBackfillNullBitmap(this.numRows))}return new v(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 v([M({type:new Ot,length:this.numRows})]));let i=n.fields.slice(),o=i[t].clone({type:e.type}),a=this.schema.fields.map((c,l)=>this.getChildAt(l));[i[t],a[t]]=[o,e],[n,s]=Pl(n,a)}return new r(n,s)}select(t){let 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){let e=this.schema.selectAt(t),n=this.batches.map(s=>s.selectAt(t));return new r(e,n)}assign(t){let e=this.schema.fields,[n,s]=t.schema.fields.reduce((a,c,l)=>{let[u,f]=a,h=e.findIndex(m=>m.name===c.name);return~h?f[h]=l:u.push(l),a},[[],[]]),i=this.schema.assign(t.schema),o=[...e.map((a,c)=>[c,s[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...n.map(a=>t.getChildAt(a))].filter(Boolean);return new r(...Pl(i,o))}};E0=Symbol.toStringTag;st[E0]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r[O0]=!0,r.isValid=Mo(Ga),r.get=Mo(Pt.getVisitFn(p.Struct)),r.set=yl(Qt.getVisitFn(p.Struct)),r.indexOf=gl(pi.getVisitFn(p.Struct)),"Table"))(st.prototype);Object.defineProperty(st,Symbol.hasInstance,{value:function(t){return Function.prototype[Symbol.hasInstance].call(this,t)||this===st&&st.isTable(t)}})});function N0(r,t,e=t.reduce((n,s)=>Math.max(n,s.length),0)){var n;let s=[...r.fields],i=[...t],o=(e+63&-64)>>3;for(let[a,c]of r.fields.entries()){let l=t[a];(!l||l.length!==e)&&(s[a]=c.clone({nullable:!0}),i[a]=(n=l?._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:M({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(s),M({type:new ut(s),length:e,children:i})]}function P0(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,o=r.length;++i<o;){let{type:a}=r[i],c=t[i];for(let l of[c,...((s=c?.dictionary)===null||s===void 0?void 0:s.data)||[]])P0(a.children,l?.children,e);if(w.isDictionary(a)){let{id:l}=a;if(!e.has(l))c?.dictionary&&e.set(l,c.dictionary);else if(e.get(l)!==c.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var U0,R0,ct,Gi,Dn=d(()=>{hr();Vi();he();pe();yt();Lo();li();rr();wl();xl();R0=Symbol.for("apache-arrow/RecordBatch"),ct=class r{static isRecordBatch(t){return t?.[R0]===!0}constructor(...t){switch(t.length){case 3:case 2:{if([this.schema]=t,!(this.schema instanceof G))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=M({nullCount:0,type:new ut(this.schema.fields),children:this.schema.fields.map(e=>M({type:e.type,nullCount:0}))}),this._metadata=new Map]=t,!(this.data instanceof D))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=N0(this.schema,this.data.children,this.data.length);break}case 1:{let[e]=t,{fields:n,children:s,length:i}=Object.keys(e).reduce((c,l,u)=>(c.children[u]=e[l],c.length=Math.max(c.length,e[l].length),c.fields[u]=S.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new G(n),a=M({type:new ut(n),length:i,children:s,nullCount:0});[this.schema,this.data]=N0(o,a.children,i),this._metadata=new Map;break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get metadata(){return this._metadata}get dictionaries(){return this._dictionaries||(this._dictionaries=P0(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return Pt.visit(this.data,t)}at(t){return this.get(ui(t,this.numRows))}set(t,e){return Qt.visit(this.data,t,e)}indexOf(t,e){return pi.visit(this.data,t,e)}[Symbol.iterator](){return Do.visit(new v([this.data]))}toArray(){return[...this]}concat(...t){return new st(this.schema,[this,...t])}slice(t,e){let[n]=new v([this.data]).slice(t,e).data;return new r(this.schema,n,this._metadata)}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 v([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 v([M({type:new Ot,length:this.numRows})]));let i=n.fields.slice(),o=s.children.slice(),a=i[t].clone({type:e.type});[i[t],o[t]]=[a,e.data[0]],n=new G(i,new Map(this.schema.metadata)),s=M({type:new ut(i),length:s.length,children:o})}return new r(n,s,this._metadata)}select(t){let e=this.schema.select(t),n=new ut(e.fields),s=[];for(let i of t){let o=this.schema.fields.findIndex(a=>a.name===i);~o&&(s[o]=this.data.children[o])}return new r(e,M({type:n,length:this.numRows,children:s}),this._metadata)}selectAt(t){let e=this.schema.selectAt(t),n=t.map(i=>this.data.children[i]).filter(Boolean),s=M({type:new ut(e.fields),length:this.numRows,children:n});return new r(e,s,this._metadata)}};U0=Symbol.toStringTag;ct[U0]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r[R0]=!0,"RecordBatch"))(ct.prototype);Object.defineProperty(ct,Symbol.hasInstance,{value:function(t){return Function.prototype[Symbol.hasInstance].call(this,t)||this===ct&&ct.isRecordBatch(t)}});Gi=class extends ct{constructor(t,e){let n=t.fields.map(i=>M({type:i.type})),s=M({type:new ut(t.fields),length:0,nullCount:0,children:n});super(t,s,e||new Map)}}});function zl(r,t=0){for(let e=-1,n=Uo.length;++e<n;)if(Uo[e]!==r[t+e])return!1;return!0}var wd,xd,k0,z0,Vs,$i,ji,kl,bd,Uo,Ro,Ad,V0,Vl=d(()=>{Pe();Mt();nt();gs();Wn();Nh();Gt();bs();ja();wd=r=>`Expected ${Q[r]} Message in stream, but was null or length 0.`,xd=r=>`Header pointer of flatbuffer-encoded ${Q[r]} Message is null or length 0.`,k0=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,z0=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,Vs=class{constructor(t){this.source=t instanceof mr?t:new mr(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?vt:t.value===-1&&(t=this.readMetadataLength()).done?vt:(t=this.readMetadata(t.value)).done?vt: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(wd(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=E(this.source.read(t));if(e.byteLength<t)throw new Error(z0(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=Q.Schema,n=this.readMessage(e),s=n?.header();if(t&&!s)throw new Error(xd(e));return s}readMetadataLength(){let t=this.source.read(kl),e=t&&new Zt(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}}readMetadata(t){let e=this.source.read(t);if(!e)return vt;if(e.byteLength<t)throw new Error(k0(t,e.byteLength));return{done:!1,value:ye.decode(e)}}},$i=class{constructor(t,e){this.source=t instanceof qe?t:Dc(t)?new ws(t,e):new qe(t)}[Symbol.asyncIterator](){return this}next(){return B(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?vt:t.value===-1&&(t=yield this.readMetadataLength()).done?vt:(t=yield this.readMetadata(t.value)).done?vt:t})}throw(t){return B(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return B(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return B(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(wd(t));return e.value})}readMessageBody(t){return B(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=E(yield this.source.read(t));if(e.byteLength<t)throw new Error(z0(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return B(this,arguments,void 0,function*(t=!1){let e=Q.Schema,n=yield this.readMessage(e),s=n?.header();if(t&&!s)throw new Error(xd(e));return s})}readMetadataLength(){return B(this,void 0,void 0,function*(){let t=yield this.source.read(kl),e=t&&new Zt(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}})}readMetadata(t){return B(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return vt;if(e.byteLength<t)throw new Error(k0(t,e.byteLength));return{done:!1,value:ye.decode(e)}})}},ji=class extends Vs{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof $a?t:new $a(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:ye.fromJSON(t.schema,Q.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:ye.fromJSON(e,Q.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:ye.fromJSON(e,Q.RecordBatch)}}return this._body=[],vt}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]||[],...i.VIEWS&&[i.VIEWS]||[],...i.VARIADIC_DATA_BUFFERS||[],...e(i.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(wd(t));return e.value}readSchema(){let t=Q.Schema,e=this.readMessage(t),n=e?.header();if(!e||!n)throw new Error(xd(t));return n}},kl=4,bd="ARROW1",Uo=new Uint8Array(bd.length);for(let r=0;r<bd.length;r+=1)Uo[r]=bd.codePointAt(r);Ro=Uo.length,Ad=Ro+kl,V0=Ro*2+kl});var vd,Sd,G0,$0=d(()=>{po();vd=class{constructor(){this.LZ4_FRAME_MAGIC=new Uint8Array([4,34,77,24]),this.MIN_HEADER_LENGTH=7}isValidCodecEncode(t){let e=new Uint8Array([1,2,3,4,5,6,7,8]),n=t.encode(e);return this._isValidCompressed(n)}_isValidCompressed(t){return this._hasMinimumLength(t)&&this._hasValidMagicNumber(t)&&this._hasValidVersion(t)}_hasMinimumLength(t){return t.length>=this.MIN_HEADER_LENGTH}_hasValidMagicNumber(t){return this.LZ4_FRAME_MAGIC.every((e,n)=>t[n]===e)}_hasValidVersion(t){return(t[4]&192)>>6===1}},Sd=class{constructor(){this.ZSTD_MAGIC=new Uint8Array([40,181,47,253]),this.MIN_HEADER_LENGTH=6}isValidCodecEncode(t){let e=new Uint8Array([1,2,3,4,5,6,7,8]),n=t.encode(e);return this._isValidCompressed(n)}_isValidCompressed(t){return this._hasMinimumLength(t)&&this._hasValidMagicNumber(t)}_hasMinimumLength(t){return t.length>=this.MIN_HEADER_LENGTH}_hasValidMagicNumber(t){return this.ZSTD_MAGIC.every((e,n)=>t[n]===e)}},G0={[Ht.LZ4_FRAME]:new vd,[Ht.ZSTD]:new Sd}});var Id,Gs,Gl=d(()=>{po();$0();Id=class{constructor(){this.registry={}}set(t,e){if(e?.encode&&typeof e.encode=="function"&&!G0[t].isValidCodecEncode(e))throw new Error(`Encoder for ${Ht[t]} is not valid.`);this.registry[t]=e}get(t){var e;return((e=this.registry)===null||e===void 0?void 0:e[t])||null}},Gs=new Id});function Y0(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*j0(r){let t=Ee.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function q0(r){return xe(this,arguments,function*(){let e=yield Y(Ee.from(r));try{if(!(yield Y(e.open({autoDestroy:!1}))).closed)do yield yield Y(e);while(!(yield Y(e.reset().open())).closed)}finally{yield Y(e.cancel())}})}function eS(r){return new Vr(new _d(r))}function rS(r){let t=r.peek(Ro+7&-8);return t&&t.byteLength>=4?zl(t)?new Fn(new jl(r.read())):new Vr(new ko(r)):new Vr(new ko((function*(){})()))}function nS(r){return B(this,void 0,void 0,function*(){let t=yield r.peek(Ro+7&-8);return t&&t.byteLength>=4?zl(t)?new Fn(new jl(yield r.read())):new Cn(new zo(r)):new Cn(new zo((function(){return xe(this,arguments,function*(){})})()))})}function sS(r){return B(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new ws(r,t);return t>=V0&&zl(yield e.readAt(0,Ro+7&-8))?new Po(new Bd(e)):new Cn(new zo(e))})}var Ee,Vr,Cn,Fn,Po,$l,ko,zo,jl,Bd,_d,Qa=d(()=>{Pe();hr();he();yt();Mt();Ch();pa();gs();bs();Nh();L0();Dn();ja();Vl();Wn();Gl();Kr();nt();Ee=class r extends gi{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){let e=this._impl.open(t);return Ke(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 Yt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Yt.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof r?t:Tc(t)?eS(t):Dc(t)?sS(t):Ke(t)?B(this,void 0,void 0,function*(){return yield r.from(yield t)}):Cc(t)||fa(t)||Ec(t)||lr(t)?nS(new qe(t)):rS(new mr(t))}static readAll(t){return t instanceof r?t.isSync()?j0(t):q0(t):Tc(t)||ArrayBuffer.isView(t)||Br(t)||Mc(t)?j0(t):q0(t)}},Vr=class extends Ee{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return xe(this,arguments,function*(){yield Y(yield*uo(He(this[Symbol.iterator]())))})}},Cn=class extends Ee{constructor(t){super(t),this._impl=t}readAll(){return B(this,void 0,void 0,function*(){var t,e,n,s;let i=new Array;try{for(var o=!0,a=He(this),c;c=yield a.next(),t=c.done,!t;o=!0){s=c.value,o=!1;let l=s;i.push(l)}}catch(l){e={error:l}}finally{try{!o&&!t&&(n=a.return)&&(yield n.call(a))}finally{if(e)throw e.error}}return i})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Fn=class extends Vr{constructor(t){super(t),this._impl=t}},Po=class extends Cn{constructor(t){super(t),this._impl=t}},$l=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e,n){let s;if(t.compression!=null){let o=Gs.get(t.compression.type);if(o?.decode&&typeof o.decode=="function"){let{decommpressedBody:a,buffers:c}=this._decompressBuffers(t,e,o);s=this._loadCompressedVectors(t,a,this.schema.fields),t=new zt(t.length,t.nodes,c,null)}else throw new Error("Record batch is compressed but codec not found")}else s=this._loadVectors(t,e,this.schema.fields);let i=M({type:new ut(this.schema.fields),length:t.length,children:s});return new ct(this.schema,i,n)}_loadDictionaryBatch(t,e){let{id:n,isDelta:s}=t,{dictionaries:i,schema:o}=this,a=i.get(n),c=o.dictionaries.get(n),l;if(t.data.compression!=null){let u=Gs.get(t.data.compression.type);if(u?.decode&&typeof u.decode=="function"){let{decommpressedBody:f,buffers:h}=this._decompressBuffers(t.data,e,u);l=this._loadCompressedVectors(t.data,f,[c]),t=new me(new zt(t.data.length,t.data.nodes,h,null,t.data.variadicBufferCounts),n,s)}else throw new Error("Dictionary batch is compressed but codec not found")}else l=this._loadVectors(t.data,e,[c]);return(a&&s?a.concat(new v(l)):new v(l)).memoize()}_loadVectors(t,e,n){return new Oo(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion,t.variadicBufferCounts).visitMany(n)}_loadCompressedVectors(t,e,n){return new Ml(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion,t.variadicBufferCounts).visitMany(n)}_decompressBuffers(t,e,n){let s=[],i=[],o=0;for(let{offset:a,length:c}of t.buffers){if(c===0){s.push(new Uint8Array(0)),i.push(new Nt(o,0));continue}let l=new Zt(e.subarray(a,a+c)),u=J(l.readInt64(0)),f=l.bytes().subarray(8),h=u===-1?f:n.decode(f);s.push(h);let m=(o+7&-8)-o;o+=m,i.push(new Nt(o,h.length)),o+=h.length}return{decommpressedBody:s,buffers:i}}},ko=class extends $l{constructor(t,e){super(e),this._reader=Tc(t)?new ji(this._handle=t):new Vs(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=Y0(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):vt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):vt}next(){if(this.closed)return vt;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),s=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,s,t.metadata)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let 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 Gi(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},zo=class extends $l{constructor(t,e){super(e),this._reader=new $i(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return B(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 B(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Y0(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return B(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):vt})}return(t){return B(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):vt})}next(){return B(this,void 0,void 0,function*(){if(this.closed)return vt;let t,{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),s=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,s,t.metadata)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let 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 Gi(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return B(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},jl=class extends ko{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 qa?t:new qa(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){let s=this._reader.readMessage(Q.RecordBatch);if(s?.isRecordBatch()){let i=s.header(),o=this._reader.readMessageBody(s.bodyLength);return this._loadRecordBatch(i,o,s.metadata)}}return null}_readDictionaryBatch(t){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){let s=this._reader.readMessage(Q.DictionaryBatch);if(s?.isDictionaryBatch()){let i=s.header(),o=this._reader.readMessageBody(s.bodyLength),a=this._loadDictionaryBatch(i,o);this.dictionaries.set(i.id,a)}}}_readFooter(){let{_handle:t}=this,e=t.size-Ad,n=t.readInt32(e),s=t.readAt(e-n,n);return An.decode(s)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let 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}},Bd=class extends zo{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...e){let n=typeof e[0]!="number"?e.shift():void 0,s=e[0]instanceof Map?e.shift():void 0;super(t instanceof ws?t:new ws(t,n),s)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return B(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return B(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){let s=yield this._reader.readMessage(Q.RecordBatch);if(s?.isRecordBatch()){let i=s.header(),o=yield this._reader.readMessageBody(s.bodyLength);return this._loadRecordBatch(i,o,s.metadata)}}return null})}_readDictionaryBatch(t){return B(this,void 0,void 0,function*(){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){let s=yield this._reader.readMessage(Q.DictionaryBatch);if(s?.isDictionaryBatch()){let i=s.header(),o=yield this._reader.readMessageBody(s.bodyLength),a=this._loadDictionaryBatch(i,o);this.dictionaries.set(i.id,a)}}})}_readFooter(){return B(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-Ad,n=yield t.readInt32(e),s=yield t.readAt(e-n,n);return An.decode(s)})}_readNextMessageAndValidate(t){return B(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},_d=class extends ko{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new Tl(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion,t.variadicBufferCounts).visitMany(n)}}});function ir(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new Nt(this._byteLength,t)),this._byteLength+=t,this}function iS(r){var t;let{type:e,length:n,typeIds:s,valueOffsets:i}=r;if(ir.call(this,s),e.mode===lt.Sparse)return Ld.call(this,r);if(e.mode===lt.Dense){if(r.offset<=0)return ir.call(this,i),Ld.call(this,r);{let o=new Int32Array(n),a=Object.create(null),c=Object.create(null);for(let l,u,f=-1;++f<n;)(l=s[f])!==void 0&&((u=a[l])===void 0&&(u=a[l]=i[f]),o[f]=i[f]-u,c[l]=((t=c[l])!==null&&t!==void 0?t:0)+1);ir.call(this,o),this.visitMany(r.children.map((l,u)=>{let f=e.typeIds[u],h=a[f],m=c[f];return l.slice(h,Math.min(n,m))}))}}return this}function oS(r){let t;return r.nullCount>=r.length?ir.call(this,new Uint8Array(r.length+7>>3)):(t=r.values)instanceof Uint8Array?ir.call(this,fi(r.offset,r.length,t)):ir.call(this,hi(r.values))}function En(r){return ir.call(this,r.values.subarray(0,r.length*r.stride))}function ql(r){let{length:t,values:e,valueOffsets:n}=r,s=J(n[0]),i=J(n[t]),o=Math.min(i-s,e.byteLength-s);return ir.call(this,Oc(-s,t+1,n)),ir.call(this,e.subarray(s,s+o)),this}function Z0(r){let{offset:t,length:e,stride:n,values:s,variadicBuffers:i=[]}=r;if(!s)throw new Error("BinaryView data is missing view buffer");let o=t*n,a=o+e*n;ir.call(this,s.subarray(o,a));for(let c of i)ir.call(this,c);return this._variadicBufferCounts.push(i.length),this}function Wl(r){let{length:t,valueOffsets:e}=r;if(e){let n=J(e[0]),s=J(e[t]);return ir.call(this,Oc(-n,t+1,e)),this.visit(r.children[0].slice(n,s-n))}return this.visit(r.children[0])}function Ld(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}var St,H0=d(()=>{he();$e();Mt();Dn();Gt();di();gs();yt();Kr();St=class r extends F{static assemble(...t){let e=s=>s.flatMap(i=>Array.isArray(i)?e(i):i instanceof ct?i.data.children:i.data),n=new r;return n.visitMany(e(t)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[],this._variadicBufferCounts=[]}visit(t){if(t instanceof v)return this.visitMany(t.data),this;let{type:e}=t;if(!w.isDictionary(e)){let{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(w.isUnion(e))this.nodes.push(new dr(n,0));else{let{nullCount:s}=t;w.isNull(e)||ir.call(this,s<=0?new Uint8Array(0):fi(t.offset,n,t.nullBitmap)),this.nodes.push(new dr(n,s))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}get variadicBufferCounts(){return this._variadicBufferCounts}};St.prototype.visitBool=oS;St.prototype.visitInt=En;St.prototype.visitFloat=En;St.prototype.visitUtf8=ql;St.prototype.visitLargeUtf8=ql;St.prototype.visitUtf8View=Z0;St.prototype.visitBinary=ql;St.prototype.visitLargeBinary=ql;St.prototype.visitBinaryView=Z0;St.prototype.visitFixedSizeBinary=En;St.prototype.visitDate=En;St.prototype.visitTimestamp=En;St.prototype.visitTime=En;St.prototype.visitDecimal=En;St.prototype.visitList=Wl;St.prototype.visitLargeList=Wl;St.prototype.visitStruct=Ld;St.prototype.visitUnion=iS;St.prototype.visitInterval=En;St.prototype.visitDuration=En;St.prototype.visitFixedSizeList=Wl;St.prototype.visitMap=Wl});var Yl,X0=d(()=>{$e();Gc();Mt();Yl=class extends F{visit(t){return t==null?void 0:super.visit(t)}visitNull({typeId:t}){return{name:k[t].toLowerCase()}}visitInt({typeId:t,bitWidth:e,isSigned:n}){return{name:k[t].toLowerCase(),bitWidth:e,isSigned:n}}visitFloat({typeId:t,precision:e}){return{name:k[t].toLowerCase(),precision:ot[e]}}visitBinary({typeId:t}){return{name:k[t].toLowerCase()}}visitLargeBinary({typeId:t}){return{name:k[t].toLowerCase()}}visitBinaryView({typeId:t}){return{name:k[t].toLowerCase()}}visitBool({typeId:t}){return{name:k[t].toLowerCase()}}visitUtf8({typeId:t}){return{name:k[t].toLowerCase()}}visitLargeUtf8({typeId:t}){return{name:k[t].toLowerCase()}}visitUtf8View({typeId:t}){return{name:k[t].toLowerCase()}}visitDecimal({typeId:t,scale:e,precision:n,bitWidth:s}){return{name:k[t].toLowerCase(),scale:e,precision:n,bitWidth:s}}visitDate({typeId:t,unit:e}){return{name:k[t].toLowerCase(),unit:mt[e]}}visitTime({typeId:t,unit:e,bitWidth:n}){return{name:k[t].toLowerCase(),unit:A[e],bitWidth:n}}visitTimestamp({typeId:t,timezone:e,unit:n}){return{name:k[t].toLowerCase(),unit:A[n],timezone:e}}visitInterval({typeId:t,unit:e}){return{name:k[t].toLowerCase(),unit:et[e]}}visitDuration({typeId:t,unit:e}){return{name:k[t].toLocaleLowerCase(),unit:A[e]}}visitList({typeId:t}){return{name:k[t].toLowerCase()}}visitLargeList({typeId:t}){return{name:k[t].toLowerCase()}}visitStruct({typeId:t}){return{name:k[t].toLowerCase()}}visitUnion({typeId:t,mode:e,typeIds:n}){return{name:k[t].toLowerCase(),mode:lt[e].toUpperCase(),typeIds:[...n]}}visitDictionary(t){return this.visit(t.dictionary)}visitFixedSizeBinary({typeId:t,byteWidth:e}){return{name:k[t].toLowerCase(),byteWidth:e}}visitFixedSizeList({typeId:t,listSize:e}){return{name:k[t].toLowerCase(),listSize:e}}visitMap({typeId:t,keysSorted:e}){return{name:k[t].toLowerCase(),keysSorted:e}}}});function*Td(r){for(let t of r)yield t.reduce((e,n)=>`${e}${("0"+(n&255).toString(16)).slice(-2)}`,"").toUpperCase()}function*On(r,t){let e=new Uint32Array(r.buffer,r.byteOffset,r.byteLength/Uint32Array.BYTES_PER_ELEMENT);for(let n=-1,s=e.length/t;++n<s;)yield`${ci.new(e.subarray((n+0)*t,(n+1)*t),!1)}`}function K0(r,t){let n=r.values,s=new DataView(n.buffer,n.byteOffset,n.byteLength),i=n.byteLength/16,o=h=>Array.from(h).map(m=>("0"+(m&255).toString(16)).slice(-2)).join("").toUpperCase(),a=Array.from({length:i},(h,m)=>{let y=m*16,g=s.getInt32(y,!0);return[y,g]}).map(([h,m])=>m>12?{SIZE:m,PREFIX_HEX:o(n.subarray(h+4,h+8)),BUFFER_INDEX:s.getInt32(h+8,!0),OFFSET:s.getInt32(h+12,!0)}:{SIZE:m,INLINED:t(n.subarray(h+4,h+4+m))}),c=[...new Set(a.map(h=>h.BUFFER_INDEX).filter(h=>h!==void 0))],l=c.map(h=>o(r.variadicBuffers[h])),u=new Map(c.map((h,m)=>[h,m]));return{VIEWS:a.map(h=>h.BUFFER_INDEX!==void 0?Object.assign(Object.assign({},h),{BUFFER_INDEX:u.get(h.BUFFER_INDEX)}):h),VARIADIC_DATA_BUFFERS:l}}var tc,J0=d(()=>{jc();he();$e();Mt();Mt();di();Ll();yt();tc=class r extends F{static assemble(...t){let e=new r;return t.map(({schema:n,data:s})=>e.visitMany(n.fields,s.children))}visit({name:t},e){let{length:n}=e,{offset:s,nullCount:i,nullBitmap:o}=e,a=w.isDictionary(e.type)?e.type.indices:e.type,c=Object.assign([],e.buffers,{[Z.VALIDITY]:void 0});return Object.assign({name:t,count:n,VALIDITY:w.isNull(a)||w.isUnion(a)?void 0:i<=0?Array.from({length:n},()=>1):[...new tn(o,s,n,null,hl)]},super.visit(e.clone(a,s,n,0,c)))}visitNull(){return{}}visitBool({values:t,offset:e,length:n}){return{DATA:[...new tn(t,e,n,null,To)]}}visitInt(t){return{DATA:t.type.bitWidth<64?[...t.values]:[...On(t.values,2)]}}visitFloat(t){return{DATA:[...t.values]}}visitUtf8(t){return{DATA:[...new v([t])],OFFSET:[...t.valueOffsets]}}visitLargeUtf8(t){return{DATA:[...new v([t])],OFFSET:[...On(t.valueOffsets,2)]}}visitBinary(t){return{DATA:[...Td(new v([t]))],OFFSET:[...t.valueOffsets]}}visitLargeBinary(t){return{DATA:[...Td(new v([t]))],OFFSET:[...On(t.valueOffsets,2)]}}visitBinaryView(t){return K0(t,e=>Array.from(e).map(n=>("0"+(n&255).toString(16)).slice(-2)).join("").toUpperCase())}visitUtf8View(t){return K0(t,e=>Array.from(e).map(n=>String.fromCodePoint(n)).join(""))}visitFixedSizeBinary(t){return{DATA:[...Td(new v([t]))]}}visitDate(t){return{DATA:t.type.unit===mt.DAY?[...t.values]:[...On(t.values,2)]}}visitTimestamp(t){return{DATA:[...On(t.values,2)]}}visitTime(t){return{DATA:t.type.unit<A.MICROSECOND?[...t.values]:[...On(t.values,2)]}}visitDecimal(t){return{DATA:[...On(t.values,4)]}}visitList(t){return{OFFSET:[...t.valueOffsets],children:this.visitMany(t.type.children,t.children)}}visitLargeList(t){return{OFFSET:[...On(t.valueOffsets,2)],children:this.visitMany(t.type.children,t.children)}}visitStruct(t){return{children:this.visitMany(t.type.children,t.children)}}visitUnion(t){return{TYPE_ID:[...t.typeIds],OFFSET:t.type.mode===lt.Dense?[...t.valueOffsets]:void 0,children:this.visitMany(t.type.children,t.children)}}visitInterval(t){switch(t.type.unit){case et.YEAR_MONTH:return{DATA:[...t.values]};case et.DAY_TIME:return{DATA:Vh(t.values)};case et.MONTH_DAY_NANO:return{DATA:Gh(t.values,!0)}}}visitDuration(t){return{DATA:[...On(t.values,2)]}}visitFixedSizeList(t){return{children:this.visitMany(t.type.children,t.children)}}visitMap(t){return{OFFSET:[...t.valueOffsets],children:this.visitMany(t.type.children,t.children)}}}});function Md(r,t){let e=t;t instanceof st&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function Dd(r,t){return B(this,void 0,void 0,function*(){var e,n,s,i,o,a,c;try{for(e=!0,n=He(t);s=yield n.next(),i=s.done,!i;e=!0){c=s.value,e=!1;let l=c;r.write(l)}}catch(l){o={error:l}}finally{try{!e&&!i&&(a=n.return)&&(yield a.call(n))}finally{if(o)throw o.error}}return r.finish()})}function Q0({name:r,type:t,nullable:e}){let n=new Yl;return{name:r,nullable:e,type:n.visit(t),children:(t.children||[]).map(s=>Q0(s)),dictionary:w.isDictionary(t)?{id:t.id,isOrdered:t.isOrdered,indexType:n.visit(t.indices)}:void 0}}function aS(r,t,e=!1){let[n]=tc.assemble(new ct({[t]:r}));return JSON.stringify({id:t,isDelta:e,data:{count:r.length,columns:n}},null,2)}function cS(r){let[t]=tc.assemble(r);return JSON.stringify({count:r.numRows,columns:t},null,2)}var sn,Nn,Un,ec,Zl=d(()=>{Pe();Vi();Vl();he();yt();gs();gs();Ch();Mt();Ja();bs();H0();X0();J0();Gt();Dn();ja();Wn();po();Gl();nt();sn=class extends gi{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){if(super(),this._position=0,this._started=!1,this._compression=null,this._sink=new pr,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Ae(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1,compressionType:null}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1,t.compressionType!=null){if(this._writeLegacyIpcFormat)throw new Error("Legacy IPC format does not support columnar compression. Use modern IPC format (writeLegacyIpcFormat=false).");if(Object.values(Ht).includes(t.compressionType))this._compression=new yi(t.compressionType);else{let e=Object.values(Ht).filter(n=>typeof n=="string");throw new Error(`Unsupported compressionType: ${t.compressionType} Available types: ${e.join(", ")}`)}}else this._compression=null}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return Ke(t)?t.then(e=>this.writeAll(e)):lr(t)?Dd(this,t):Md(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){return t===this._sink||t instanceof pr?this._sink=t:(this._sink=new pr,t&&gy(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&by(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!e||!zi(e,this._schema))&&(e==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof st&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof ct&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!zi(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof ct?t instanceof Gi||this._writeRecordBatch(t):t instanceof st?this.writeAll(t.batches):Br(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,s=ye.encode(t),i=s.byteLength,o=this._writeLegacyIpcFormat?4:8,a=i+o+n&~n,c=a-i-o;return t.headerType===Q.RecordBatch?this._recordBatchBlocks.push(new Pr(a,t.bodyLength,this._position)):t.headerType===Q.DictionaryBatch&&this._dictionaryBlocks.push(new Pr(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),i>0&&this._write(s),this._writePadding(c)}_write(t){if(this._started){let e=E(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(ye.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Uo)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:s,buffers:i,variadicBufferCounts:o}=this._assembleRecordBatch(t),a=new zt(t.numRows,n,s,this._compression,o,t.metadata),c=ye.from(a,e);return this._writeDictionaries(t)._writeMessage(c)._writeBodyBuffers(i)}_assembleRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:s,buffers:i,variadicBufferCounts:o}=St.assemble(t);return this._compression!=null&&({byteLength:e,bufferRegions:s,buffers:i}=this._compressBodyBuffers(i)),{byteLength:e,nodes:n,bufferRegions:s,buffers:i,variadicBufferCounts:o}}_compressBodyBuffers(t){let e=Gs.get(this._compression.type);if(!e?.encode||typeof e.encode!="function")throw new Error(`Codec for compression type "${Ht[this._compression.type]}" has invalid encode method`);let n=0,s=[],i=[];for(let a of t){let c=E(a);if(c.length===0){s.push(new Uint8Array(0),new Uint8Array(0)),i.push(new Nt(n,0));continue}let l=e.encode(c),u=l.length<c.length,f=u?l:c,h=u?f.length:-1,m=new Zt(new Uint8Array(8));m.writeInt64(0,BigInt(h)),s.push(m.bytes(),new Uint8Array(f));let y=(n+7&-8)-n;n+=y;let g=8+f.length;i.push(new Nt(n,g)),n+=g}let o=(n+7&-8)-n;return n+=o,{byteLength:n,bufferRegions:i,buffers:s}}_writeDictionaryBatch(t,e,n=!1){let{byteLength:s,nodes:i,bufferRegions:o,buffers:a,variadicBufferCounts:c}=this._assembleRecordBatch(new v([t])),l=new zt(t.length,i,o,this._compression,c),u=new me(l,e,n),f=ye.from(u,s);return this._writeMessage(f)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e=this._compression!=null?2:1,n=new Array(e);for(let s=0;s<t.length;s+=e){let i=0;for(let a=-1;++a<e;)n[a]=t[s+a],i+=n[a].byteLength;if(i===0)continue;for(let a of n)this._write(a);let o=(i+7&-8)-i;o>0&&this._writePadding(o)}return this}_writeDictionaries(t){var e,n;for(let[s,i]of t.dictionaries){let o=(e=i?.data)!==null&&e!==void 0?e:[],a=this._seenDictionaries.get(s),c=(n=this._dictionaryDeltaOffsets.get(s))!==null&&n!==void 0?n:0;if(!a||a.data[0]!==o[0])for(let[l,u]of o.entries())this._writeDictionaryBatch(u,s,l>0);else if(c<o.length)for(let l of o.slice(c))this._writeDictionaryBatch(l,s,!0);this._seenDictionaries.set(s,i),this._dictionaryDeltaOffsets.set(s,o.length)}return this}},Nn=class r extends sn{static writeAll(t,e){let n=new r(e);return Ke(t)?t.then(s=>n.writeAll(s)):lr(t)?Dd(n,t):Md(n,t)}},Un=class r extends sn{static writeAll(t,e){let n=new r(e);return Ke(t)?t.then(s=>n.writeAll(s)):lr(t)?Dd(n,t):Md(n,t)}constructor(t){super(t),this._autoDestroy=!0,this._writeLegacyIpcFormat=!1}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,n=!1){if(!n&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,n)}_writeFooter(t){let e=An.encode(new An(t,ht.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}},ec=class r extends sn{static writeAll(t){return new r().writeAll(t)}constructor(){super(),this._autoDestroy=!0,this._recordBatches=[],this._recordBatchesWithDictionaries=[]}_writeMessage(){return this}_writeFooter(t){return this}_writeSchema(t){return this._write(`{
|
|
17
|
+
"schema": ${JSON.stringify({fields:t.fields.map(e=>Q0(e))},null,2)}`)}_writeDictionaries(t){return t.dictionaries.size>0&&this._recordBatchesWithDictionaries.push(t),this}_writeDictionaryBatch(t,e,n=!1){return this._write(this._dictionaryBlocks.length===0?" ":`,
|
|
18
|
+
`),this._write(aS(t,e,n)),this._dictionaryBlocks.push(new Pr(0,0,0)),this}_writeRecordBatch(t){return this._writeDictionaries(t),this._recordBatches.push(t),this}close(){if(this._recordBatchesWithDictionaries.length>0){this._write(`,
|
|
19
19
|
"dictionaries": [
|
|
20
20
|
`);for(let t of this._recordBatchesWithDictionaries)super._writeDictionaries(t);this._write(`
|
|
21
21
|
]`)}if(this._recordBatches.length>0){for(let t=-1,e=this._recordBatches.length;++t<e;)this._write(t===0?`,
|
|
22
22
|
"batches": [
|
|
23
23
|
`:`,
|
|
24
|
-
`),this._write(
|
|
24
|
+
`),this._write(cS(this._recordBatches[t])),this._recordBatchBlocks.push(new Pr(0,0,0));this._write(`
|
|
25
25
|
]`)}return this._schema&&this._write(`
|
|
26
|
-
}`),this._recordBatchesWithDictionaries=[],this._recordBatches=[],super.close()}}});function hg(r,t){if(lr(r))return fA(r,t);if(Ir(r))return uA(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function uA(r,t){let e=null,n=t?.type==="bytes"||!1,s=t?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){i(o,e||(e=r[Symbol.iterator]()))},pull(o){e?i(o,e):o.close()},cancel(){e?.return&&e.return(),e=null}}),Object.assign({highWaterMark:n?s:void 0},t));function i(o,a){let c,l=null,u=o.desiredSize||null;for(;!(l=a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=O(l.value))&&(u!=null&&n&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()}}function fA(r,t){let e=null,n=t?.type==="bytes"||!1,s=t?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return B(this,void 0,void 0,function*(){yield i(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return B(this,void 0,void 0,function*(){e?yield i(o,e):o.close()})},cancel(){return B(this,void 0,void 0,function*(){e?.return&&(yield e.return()),e=null})}}),Object.assign({highWaterMark:n?s:void 0},t));function i(o,a){return B(this,void 0,void 0,function*(){let c,l=null,u=o.desiredSize||null;for(;!(l=yield a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=O(l.value))&&(u!=null&&n&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()})}}var dg=p(()=>{Pe();Gt();qn()});function yg(r){return new od(r)}var od,pg,mg,gg=p(()=>{Pe();Va();od=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:s="count"}=t,i=_m(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=Pr(i),this._getSize=s!=="bytes"?pg:mg;let{["highWaterMark"]:o=s==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:a=s==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:c=>{this._maybeFlush(this._builder,this._controller=c)},start:c=>{this._maybeFlush(this._builder,this._controller=c)}},{highWaterMark:o,size:s!=="bytes"?pg:mg}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:c=>this._writeValueAndReturnChunkSize(c)})}_writeValueAndReturnChunkSize(t){let e=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(t)),this._bufferedSize-e}_maybeFlush(t,e){e!=null&&(this._bufferedSize>=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))}_enqueue(t,e){this._bufferedSize=0,this._controller=null,e==null?t.close():t.enqueue(e)}},pg=r=>{var t;return(t=r?.length)!==null&&t!==void 0?t:0},mg=r=>{var t;return(t=r?.byteLength)!==null&&t!==void 0?t:0}});function El(r,t){let e=new pr,n=null,s=new ReadableStream({cancel(){return B(this,void 0,void 0,function*(){yield e.close()})},start(a){return B(this,void 0,void 0,function*(){yield o(a,n||(n=yield i()))})},pull(a){return B(this,void 0,void 0,function*(){n?yield o(a,n):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:s};function i(){return B(this,void 0,void 0,function*(){return yield(yield Oe.from(e)).open(t)})}function o(a,c){return B(this,void 0,void 0,function*(){let l=a.desiredSize,u=null;for(;!(u=yield c.next()).done;)if(a.enqueue(u.value),l!=null&&--l<=0)return;a.close()})}}var bg=p(()=>{Pe();ys();Wa()});function Ul(r,t){let e=new this(r),n=new $e(e),s=new ReadableStream({cancel(){return B(this,void 0,void 0,function*(){yield n.cancel()})},pull(o){return B(this,void 0,void 0,function*(){yield i(o)})},start(o){return B(this,void 0,void 0,function*(){yield i(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:s};function i(o){return B(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield n.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}var wg=p(()=>{Pe();ys()});function Uo(r){let t=Oe.from(r);return Ke(t)?t.then(e=>Uo(e)):t.isAsync()?t.readAll().then(e=>new st(e)):new st(t.readAll())}function Ha(r,t="stream",e=null){let n={compressionType:e};return(t==="stream"?En:Un).writeAll(r,n).toUint8Array(!0)}var xg=p(()=>{Ri();qn();Wa();Ol()});var ad={};Re(ad,{isArrowData:()=>kl,isArrowDataType:()=>Pl,isArrowField:()=>Rl,isArrowRecordBatch:()=>Vl,isArrowSchema:()=>Nl,isArrowTable:()=>Gl,isArrowVector:()=>zl});function Nl(r){return G.isSchema(r)}function Rl(r){return S.isField(r)}function Pl(r){return w.isDataType(r)}function kl(r){return D.isData(r)}function zl(r){return A.isVector(r)}function Vl(r){return ct.isRecordBatch(r)}function Gl(r){return st.isTable(r)}var cd=p(()=>{pe();yt();hr();he();Mn();Ri()});var vg,ld=p(()=>{Tc();ao();Mt();hr();yt();Ri();he();je();pe();Ca();Zc();vt();Va();wh();Fh();xh();vh();Ah();Sh();Bh();Th();Uh();Eh();_h();Lh();Rh();kh();Ph();ml();gl();yl();Mh();Dh();Ih();Ch();Oh();Nh();ys();Wa();Ol();xg();Ll();_l();ms();Mn();cd();Mc();dh();li();Da();Gt();vo();Aa();hl();cd();$a();vg=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Nf),hh),Jf),Rf),ef),Kf),Ff),bh),ad),{compareSchemas:Ni,compareFields:j0,compareTypes:xl})});var wr={};Re(wr,{AsyncByteQueue:()=>pr,AsyncByteStream:()=>$e,AsyncMessageReader:()=>ki,AsyncRecordBatchFileReader:()=>Fo,AsyncRecordBatchStreamReader:()=>Dn,Binary:()=>ze,BinaryBuilder:()=>Sn,BinaryView:()=>H,BinaryViewBuilder:()=>_n,Bool:()=>le,BoolBuilder:()=>pi,BufferType:()=>Z,Builder:()=>bt,ByteStream:()=>mr,CompressionType:()=>Ht,Data:()=>D,DataType:()=>w,DateBuilder:()=>tn,DateDay:()=>Qn,DateDayBuilder:()=>bs,DateMillisecond:()=>ts,DateMillisecondBuilder:()=>ws,DateUnit:()=>mt,Date_:()=>Te,Decimal:()=>Ve,DecimalBuilder:()=>xs,DenseUnion:()=>gn,DenseUnionBuilder:()=>Ei,Dictionary:()=>Rt,DictionaryBuilder:()=>mi,Duration:()=>Me,DurationBuilder:()=>yr,DurationMicrosecond:()=>La,DurationMicrosecondBuilder:()=>Ls,DurationMillisecond:()=>_a,DurationMillisecondBuilder:()=>_s,DurationNanosecond:()=>Ta,DurationNanosecondBuilder:()=>Ts,DurationSecond:()=>Ba,DurationSecondBuilder:()=>Bs,Field:()=>S,FixedSizeBinary:()=>Ge,FixedSizeBinaryBuilder:()=>vs,FixedSizeList:()=>gt,FixedSizeListBuilder:()=>yi,Float:()=>ae,Float16:()=>Fr,Float16Builder:()=>gi,Float32:()=>Xt,Float32Builder:()=>bi,Float64:()=>_e,Float64Builder:()=>wi,FloatBuilder:()=>en,Int:()=>Lt,Int16:()=>Se,Int16Builder:()=>vi,Int32:()=>Dt,Int32Builder:()=>Ai,Int64:()=>Qe,Int64Builder:()=>Si,Int8:()=>Ae,Int8Builder:()=>xi,IntBuilder:()=>Ce,Interval:()=>ue,IntervalBuilder:()=>kr,IntervalDayTime:()=>cs,IntervalDayTimeBuilder:()=>As,IntervalMonthDayNano:()=>Ia,IntervalMonthDayNanoBuilder:()=>Is,IntervalUnit:()=>et,IntervalYearMonth:()=>ls,IntervalYearMonthBuilder:()=>Ss,JSONMessageReader:()=>zi,LargeBinary:()=>Or,LargeBinaryBuilder:()=>In,LargeList:()=>tr,LargeListBuilder:()=>Mi,LargeUtf8:()=>Er,LargeUtf8Builder:()=>Ps,List:()=>Ct,ListBuilder:()=>Ti,MapBuilder:()=>Di,MapRow:()=>fr,Map_:()=>fe,Message:()=>ye,MessageHeader:()=>Q,MessageReader:()=>ks,MetadataVersion:()=>ht,Null:()=>Et,NullBuilder:()=>Ci,Precision:()=>ot,RecordBatch:()=>ct,RecordBatchFileReader:()=>Cn,RecordBatchFileWriter:()=>Un,RecordBatchJSONWriter:()=>Za,RecordBatchReader:()=>Oe,RecordBatchStreamReader:()=>zr,RecordBatchStreamWriter:()=>En,RecordBatchWriter:()=>nn,Schema:()=>G,SparseUnion:()=>us,SparseUnionBuilder:()=>Oi,Struct:()=>ut,StructBuilder:()=>Fi,StructRow:()=>Jr,Table:()=>st,Time:()=>Kt,TimeBuilder:()=>br,TimeMicrosecond:()=>ns,TimeMicrosecondBuilder:()=>Us,TimeMillisecond:()=>rs,TimeMillisecondBuilder:()=>Es,TimeNanosecond:()=>ss,TimeNanosecondBuilder:()=>Ns,TimeSecond:()=>es,TimeSecondBuilder:()=>Os,TimeUnit:()=>v,Timestamp:()=>Jt,TimestampBuilder:()=>gr,TimestampMicrosecond:()=>os,TimestampMicrosecondBuilder:()=>Cs,TimestampMillisecond:()=>Kr,TimestampMillisecondBuilder:()=>Ds,TimestampNanosecond:()=>as,TimestampNanosecondBuilder:()=>Fs,TimestampSecond:()=>is,TimestampSecondBuilder:()=>Ms,Type:()=>d,Uint16:()=>Be,Uint16Builder:()=>Bi,Uint32:()=>qt,Uint32Builder:()=>_i,Uint64:()=>Cr,Uint64Builder:()=>Li,Uint8:()=>Ie,Uint8Builder:()=>Ii,Union:()=>De,UnionBuilder:()=>Bn,UnionMode:()=>lt,Utf8:()=>ce,Utf8Builder:()=>Rs,Utf8View:()=>Le,Utf8ViewBuilder:()=>Ui,Vector:()=>A,Visitor:()=>F,builderThroughAsyncIterable:()=>qh,builderThroughIterable:()=>Al,compressionRegistry:()=>zs,isArrowData:()=>kl,isArrowDataType:()=>Pl,isArrowField:()=>Rl,isArrowRecordBatch:()=>Vl,isArrowSchema:()=>Nl,isArrowTable:()=>Gl,isArrowVector:()=>zl,makeBuilder:()=>Pr,makeData:()=>M,makeTable:()=>$h,makeVector:()=>te,tableFromArrays:()=>Wh,tableFromIPC:()=>Uo,tableFromJSON:()=>jh,tableToIPC:()=>Ha,util:()=>vg,vectorFromArray:()=>Mo});var Vr=p(()=>{aa();vt();Wa();Ol();dg();gg();bg();wg();ld();ld();Yt.toDOMStream=hg;bt.throughDOM=yg;Oe.throughDOM=El;Cn.throughDOM=El;zr.throughDOM=El;nn.throughDOM=Ul;Un.throughDOM=Ul;En.throughDOM=Ul});var jl,ud,Ag=p(()=>{"use strict";Vr();jl=new G([new S("POSITION",new gt(3,new S("value",new Xt,!1)),!1)]),ud=new G([...jl.fields,new S("indices",new Ct(new S("item",new qt,!1)),!0)])});var Vs=p(()=>{"use strict";Im();Ag()});function pA(r,t="float32"){return r instanceof Date?"date-millisecond":typeof r=="number"?t:typeof r=="boolean"?"bool":typeof r=="string"?"utf8":"null"}function Ig(r){let t=fd(r);return t!=="null"?{type:t,nullable:!1}:r.length>0?(t=pA(r[0]),{type:t,nullable:!0}):{type:"null",nullable:!0}}function fd(r){if(typeof Float16Array<"u"&&r instanceof Float16Array)return"float16";switch(r.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case BigInt64Array:return"int64";case BigUint64Array:return"uint64";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}var hd=p(()=>{"use strict"});function ql(r){return{fields:r.fields.map(t=>Vi(t)),metadata:Tg(r.metadata)}}function Tg(r){return Object.fromEntries(r)}function dd(r){return r?new Map(Object.entries(r)):new Map}function Vi(r){return{name:r.name,type:Mg(r.type),nullable:r.nullable,metadata:Tg(r.metadata)}}function Nn(r,t){return new S(r.name,$l(r.type,t),r.nullable,dd(r.metadata))}function Mg(r){if(Bg(r,"BinaryView"))return"binary-view";if(Bg(r,"Utf8View"))return"utf8-view";if(mA(r,"LargeList"))return{type:"large-list",children:[Vi(r.valueField)]};switch(r.constructor){case Et:return"null";case ze:return"binary";case Ge:return{type:"fixed-size-binary",byteWidth:r.byteWidth};case le:return"bool";case Lt:let t=r;return`${t.isSigned?"":"u"}int${t.bitWidth}`;case Ae:return"int8";case Se:return"int16";case Dt:return"int32";case Qe:return"int64";case Ie:return"uint8";case Be:return"uint16";case qt:return"uint32";case Cr:return"uint64";case ae:switch(r.precision){case ot.HALF:return"float16";case ot.SINGLE:return"float32";case ot.DOUBLE:return"float64";default:return"float16"}case Fr:return"float16";case Xt:return"float32";case _e:return"float64";case ce:return"utf8";case Ve:let n=r;return{type:"decimal",bitWidth:n.bitWidth,precision:n.precision,scale:n.scale};case Te:return r.unit===mt.DAY?"date-day":"date-millisecond";case Qn:return"date-day";case ts:return"date-millisecond";case Kt:switch(r.unit){case v.SECOND:return"time-second";case v.MILLISECOND:return"time-millisecond";case v.MICROSECOND:return"time-microsecond";case v.NANOSECOND:return"time-nanosecond";default:return"time-second"}case rs:return"time-millisecond";case es:return"time-second";case ns:return"time-microsecond";case ss:return"time-nanosecond";case Jt:switch(r.unit){case v.SECOND:return"timestamp-second";case v.MILLISECOND:return"timestamp-millisecond";case v.MICROSECOND:return"timestamp-microsecond";case v.NANOSECOND:return"timestamp-nanosecond";default:return"timestamp-second"}case is:return"timestamp-second";case Kr:return"timestamp-millisecond";case os:return"timestamp-microsecond";case as:return"timestamp-nanosecond";case ue:switch(r.unit){case et.DAY_TIME:return"interval-daytime";case et.YEAR_MONTH:return"interval-yearmonth";default:return"interval-daytime"}case cs:return"interval-daytime";case ls:return"interval-yearmonth";case fe:let c=r;return{type:"map",keysSorted:c.keysSorted,children:c.children.map(g=>Vi(g))};case Ct:let u=r.valueField;return{type:"list",children:[Vi(u)]};case gt:let f=r;return{type:"fixed-size-list",listSize:f.listSize,children:[Vi(f.children[0])]};case ut:return{type:"struct",children:r.children.map(g=>Vi(g))};case us:case gn:let m=r;return{type:m instanceof gn?"dense-union":"sparse-union",typeIds:m.typeIds,children:m.children.map(g=>Vi(g)),typeIdToChildIndex:{...m.typeIdToChildIndex}};case Rt:let y=r;return{type:"dictionary",id:y.id,indices:yA(y.indices),dictionary:Mg(y.dictionary),isOrdered:y.isOrdered};default:throw new Error(`arrow type not supported: ${r.constructor.name}`)}}function $l(r,t){if(typeof r=="object")switch(r.type){case"decimal":return new Ve(r.scale,r.precision,r.bitWidth);case"map":{let e=r.children.map(n=>Nn(n,t));return new fe(e[0],r.keysSorted)}case"list":{let e=Nn(r.children[0],t);return new Ct(e)}case"large-list":{let e=Nn(r.children[0],t),n=Xa("LargeList");if(!n)throw new Error("LargeList requires an Apache Arrow runtime that exports the LargeList constructor");return new n(e)}case"fixed-size-list":{let e=Nn(r.children[0],t);return new gt(r.listSize,e)}case"fixed-size-binary":return new Ge(r.byteWidth);case"struct":{let e=r.children.map(n=>Nn(n,t));return new ut(e)}case"sparse-union":case"dense-union":{let e=r.children.map(n=>Nn(n,t));return r.type==="dense-union"?new gn(r.typeIds,e):new us(r.typeIds,e)}case"dictionary":return new Rt($l(r.dictionary,t),bA(r.indices),r.id,r.isOrdered);default:throw new Error("array type not supported")}switch(r){case"null":return new Et;case"binary":return _g("BinaryView",new ze,t);case"binary-view":return Lg("BinaryView");case"bool":return new le;case"int8":return new Ae;case"int16":return new Se;case"int32":return new Dt;case"int64":return new Qe;case"uint8":return new Ie;case"uint16":return new Be;case"uint32":return new qt;case"uint64":return new Cr;case"float16":return new Fr;case"float32":return new Xt;case"float64":return new _e;case"utf8":return _g("Utf8View",new ce,t);case"utf8-view":return Lg("Utf8View");case"date-day":return new Qn;case"date-millisecond":return new ts;case"time-second":return new es;case"time-millisecond":return new rs;case"time-microsecond":return new ns;case"time-nanosecond":return new ss;case"timestamp-second":return new is;case"timestamp-millisecond":return new Kr;case"timestamp-microsecond":return new os;case"timestamp-nanosecond":return new as;case"interval-daytime":return new cs;case"interval-yearmonth":return new ls;default:throw new Error("array type not supported")}}function Xa(r){return wr[r]}function Bg(r,t){let e=Xa(t);if(e&&r instanceof e)return!0;let n=w;return!!(t==="BinaryView"?n.isBinaryView:n.isUtf8View)?.(r)}function mA(r,t){let e=Xa(t);return!!(e&&r instanceof e)}function _g(r,t,e){let n=e?.viewTypes||"never";if(n==="never")return t;let s=Xa(r);if(s)return new s;if(n==="require")throw new Error(`${r} requires apache-arrow 21.2.0 or later; the installed runtime does not support it`);return t}function Lg(r){let t=Xa(r);if(!t)throw new Error(`${r} requires apache-arrow 21.2.0 or later; the installed runtime does not support it`);return new t}function yA(r){if(r instanceof Lt){let e=`${r.isSigned?"int":"uint"}${r.bitWidth}`;if(gA(e))return e}switch(r.constructor){case Ae:return"int8";case Se:return"int16";case Dt:return"int32";case Ie:return"uint8";case Be:return"uint16";case qt:return"uint32";default:throw new Error(`arrow dictionary index type not supported: ${r.constructor.name}`)}}function gA(r){return["int8","int16","int32","uint8","uint16","uint32"].includes(r)}function bA(r){switch(r){case"int8":return new Ae;case"int16":return new Se;case"int32":return new Dt;case"uint8":return new Ie;case"uint16":return new Be;case"uint32":return new qt;default:throw new Error(`schema dictionary index type not supported: ${r}`)}}var Wl=p(()=>{"use strict";Vr()});function sn(r){let t=r?.POSITION;if(!t||!("value"in t)||!t.value.length)return null;let e=1/0,n=1/0,s=1/0,i=-1/0,o=-1/0,a=-1/0,c=t.value,l=c.length;for(let u=0;u<l;u+=3){let f=c[u],h=c[u+1],m=c[u+2];e=f<e?f:e,n=h<n?h:n,s=m<s?m:s,i=f>i?f:i,o=h>o?h:o,a=m>a?m:a}return[[e,n,s],[i,o,a]]}var pd=p(()=>{"use strict"});function Dg(r){return r.type instanceof gt?r.type.listSize:1}function md(r,t,e){let n=wA(r,t,e);return new A([n])}function wA(r,t,e){let n=xA(r,t,e),s=n.children[0].type,i=e==="float16"&&jn(r)?ra(r):r,o={[Z.DATA]:i},a=new D(s,0,i.length,0,o);return new D(n,0,i.length/t,0,void 0,[a])}function xA(r,t,e){let n=e||Ig(r).type,s=$l(n);return new gt(t,new S("value",s,!1))}var yd=p(()=>{"use strict";Vs();Vr();hd();Wl()});function Ee(r,t){switch(t){case"columnar-table":return vA(r);case"arrow-table":return AA(r);default:throw new Error(t)}}function vA(r){let t={},e=Fg(r);for(let[n,s]of Object.entries(r.attributes))t[n]=s.value;return{shape:"columnar-table",schema:r.schema,data:t,topology:r.topology,indices:e?r.indices:void 0}}function AA(r,t){return Yl(r.attributes,{schema:r.schema,topology:r.topology,mode:r.mode,boundingBox:r.header?.boundingBox,indices:Fg(r)?r.indices:void 0})}function Yl(r,t={}){let e=[],n={},s=IA(r);for(let c of s){let l=r[c],{value:u,size:f=1}=l,h=SA(u,f,l.componentType);if(n[c]=h,e.push(BA(t.schema,c,h,l.componentType)),c==="POSITION"&&t.indices?.value?.length){let m=ud.fields.find(y=>y.name==="indices");n.indices=LA(t.indices.value,h.length,m.type),e.push(m)}}let i=new G(e,TA(t)),o=n[s[0]]?.length===0?new st(i):new st(i,n);return{shape:"arrow-table",schema:ql(o.schema),data:o,topology:t.topology||"point-list",indices:t.indices}}function SA(r,t,e){if(e==="float16"){let n=jn(r)?ra(r):r;if(t===1){let s=new D(new Fr,0,n.length,0,{[Z.DATA]:n});return new A([s])}return md(r,t,e)}return t===1?te(r):md(r,t)}function IA(r){let t=Object.keys(r),e=Cg.filter(s=>s in r),n=t.filter(s=>!Cg.includes(s));return[...e,...n]}function Fg(r){return!!r.indices?.value?.length}function BA(r,t,e,n){if(t==="POSITION"&&_A(e)){let i=jl.fields[0],o=r?.fields.find(c=>c.name===t);if(!o?.metadata)return i;let a=new Map(i.metadata);for(let[c,l]of Object.entries(o.metadata))a.set(c,l);return new S(i.name,i.type,i.nullable,a)}let s=r?.fields.find(i=>i.name===t);if(n==="float16"){let i=new Map(Object.entries(s?.metadata||{}));return i.set("componentType","float16"),new S(t,e.type,!1,i)}if(s&&s.type.toString()!==e.type.toString()){let i=Nn(s);return new S(t,e.type,i.nullable,i.metadata)}return s?Nn(s):new S(t,e.type,!1)}function _A(r){return r.type instanceof gt&&r.type.listSize===3&&r.type.children[0].type instanceof Xt}function LA(r,t,e){let n=e,s=r instanceof Uint32Array?r:Uint32Array.from(r),i=new Int32Array(t+1);t>0&&i.fill(s.length,1);let o=new Uint8Array(Math.ceil(t/8));t>0&&(o[0]=1);let a=new D(n.children[0].type,0,s.length,0,{[Z.DATA]:s}),c=new D(n,0,t,Math.max(0,t-1),{[Z.OFFSET]:i,[Z.VALIDITY]:o},[a]);return new A([c])}function TA(r){let t={...r.schema?.metadata};return r.topology&&(t.topology||=r.topology),Number.isFinite(r.mode)&&(t.mode||=String(r.mode)),r.boundingBox&&(t.boundingBox||=JSON.stringify(r.boundingBox)),dd(t)}var Cg,Og=p(()=>{"use strict";Vs();Vs();Vr();yd();Wl();Cg=["POSITION"]});function ee(r){if(r.shape==="arrow-table")return MA(r);throw new Error(r.shape)}function MA(r){let t=r.data,e=ql(t.schema),n=e.fields,s={},i=[];for(let u of n){let{name:f}=u;if(f==="indices")continue;let h=t.getChild(f),m=Dg(h),y=EA(h,m),g=CA(u.metadata),x=g.componentType==="float16"?UA(y):y,I=i.find(q=>q.data.length===h.data.length&&s[q.name].value.constructor===x.constructor&&q.data.every((T,b)=>Eg(T,h.data[b])));s[f]={value:I?s[I.name].value:x,size:m,...g},I||i.push({name:f,data:h.data})}OA(e);let o=e.metadata.topology,a=NA(e),c=RA(t),l=s.POSITION?.transform?.type==="quantization"?DA(e)||sn(s):sn(s);return{schema:e,attributes:s,topology:o,mode:a,indices:c,header:{vertexCount:t.numRows,boundingBox:l??void 0}}}function DA(r){let t=r.metadata?.boundingBox;if(!t)return null;try{let e=JSON.parse(t);if(Array.isArray(e)&&e.length===2&&e.every(n=>Array.isArray(n)&&n.length===3&&n.every(s=>typeof s=="number")))return e}catch{}return null}function CA(r={}){let t={};if(r.byteOffset!==void 0&&(t.byteOffset=Number(r.byteOffset)),r.byteStride!==void 0&&(t.byteStride=Number(r.byteStride)),r.normalized!==void 0&&(t.normalized=r.normalized==="true"),r.componentType==="float16"&&(t.componentType="float16"),r["loaders.gl.transform"])try{let e=JSON.parse(r["loaders.gl.transform"]);FA(e)&&(t.transform=e)}catch{}return t}function FA(r){if(!r||typeof r!="object"||!("type"in r))return!1;let t=r;return t.type==="octahedron"?Number.isInteger(t.bits)&&t.bits>=1&&t.bits<=30:t.type==="quantization"&&Number.isInteger(t.bits)&&t.bits>=1&&t.bits<=30&&Array.isArray(t.origin)&&t.origin.every(e=>typeof e=="number")&&typeof t.range=="number"}function OA(r){r.metadata||={},r.metadata.topology||="point-list",r.metadata.mode||="0"}function EA(r,t){if(!(r.type instanceof gt))return r.toArray();let n=r.data[0].children[0].values.constructor,s=new n(r.length*t),i=0;for(let o of r.data){let a=o.children[0],c=o.length*t,l=a.offset||o.offset*t,u=l+c<=a.values.length?l:0,f=a.values.subarray(u,u+c);s.set(f,i),i+=c}return s}function UA(r){let t=fc(r.length);for(let e=0;e<r.length;e++)hc(t,e,Hu(r,e));return t}function NA(r){let t=Number(r.metadata?.mode);return Number.isFinite(t)?t:0}function RA(r){let t=r.getChild("indices");if(!t?.isValid(0))return;let e=t.data[0],n=e.valueOffsets,s=n[e.offset],i=n[e.offset+1];return{value:e.children[0].values.subarray(s,i),size:1}}function Eg(r,t){let e=Object.values(t.buffers);return r.type.toString()===t.type.toString()&&r.offset===t.offset&&r.length===t.length&&r.nullCount===t.nullCount&&r.dictionary===t.dictionary&&Object.values(r.buffers).every((n,s)=>{let i=e[s];return n===i||!!(n&&i&&n.buffer===i.buffer&&n.byteOffset===i.byteOffset&&n.byteLength===i.byteLength)})&&r.children.length===t.children.length&&r.children.every((n,s)=>Eg(n,t.children[s]))}var Ug=p(()=>{"use strict";Vs();Vr();yd();Wl();pd()});function Gi(r,t={}){return{fields:PA(r),metadata:t}}function Ng(r,t,e){let n=t.componentType||fd(t.value),s=e||Rg(t),i=t.size===1?n:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:n}]};return{name:r,type:i,nullable:!1,metadata:s}}function PA(r){let t=[];for(let e in r){let n=r[e];t.push(Ng(e,n))}return t}function Rg(r){let t={};return"byteOffset"in r&&(t.byteOffset=r.byteOffset.toString(10)),"byteStride"in r&&(t.byteStride=r.byteStride.toString(10)),"normalized"in r&&(t.normalized=r.normalized.toString()),r.componentType&&(t.componentType=r.componentType),r.transform&&(t["loaders.gl.transform"]=JSON.stringify(r.transform)),t}var Pg=p(()=>{"use strict";hd()});var or=p(()=>{"use strict";pd();Og();Ug();Pg()});var kg,zg=p(()=>{"use strict";kg={name:"LAS",id:"las",module:"pointclouds",encoding:"binary",format:"las",extensions:["las","laz"],mimeTypes:["application/octet-stream"],text:!1,binary:!0,tests:["LASF"]}});function Gg(r){return r?.las?.shape||Vg}function qg(r,t){if(t==="uint8norm"||!r.attributes.COLOR_0)return r;let e=r.attributes.COLOR_0,n=e.value instanceof Uint16Array?65535:255,s=t==="float16"?ti(e.value,n):na(e.value,n),i={...r.attributes};for(let[o,a]of Object.entries(i))a.value===e.value&&(i[o]={...a,value:s,normalized:!1,...t==="float16"?{componentType:"float16"}:{}});return{...r,attributes:i}}var kA,Vg,jg,$g=p(()=>{"use strict";Vs();zg();kA="5.0.0-beta.7",Vg="arrow-table";jg={...kg,dataType:null,batchType:null,version:kA,worker:!1,options:{las:{shape:Vg,fp64:!1,colorDepth:8,colorFormat:"uint8norm",columns:void 0,extraBytes:"raw",recoverMissingChunkTable:!1,compatibilityMode:"auto"}}}});function Zl(r){return r.variadicBuffers??[]}function Hl(r,t,e,n,s,i,o,a){return Reflect.construct(D,[r,t,e,n,s,i,o,a])}var gd=p(()=>{Vr()});function Wg(r,t={}){let e={...t,copies:new WeakMap};return zA(r)?jA(r,e):VA(r)?Yg(r,e):GA(r)?Zg(r,e):Xl(r,e)}function zA(r){return"batches"in r}function VA(r){return"schema"in r&&"data"in r&&!Array.isArray(r.data)}function GA(r){return"data"in r&&Array.isArray(r.data)}function jA(r,t){let e=r.batches.map(n=>Yg(n,t));return new st(r.schema,e)}function Yg(r,t){return new ct(r.schema,Xl(r.data,t))}function Xl(r,t){let e=r.children.map(i=>Xl(i,t)),n=r.dictionary?Zg(r.dictionary,t):void 0,s={[Z.OFFSET]:Ka(r.buffers[Z.OFFSET],t),[Z.DATA]:Ka(r.buffers[Z.DATA],t),[Z.VALIDITY]:Ka(r.buffers[Z.VALIDITY],t),[Z.TYPE]:Ka(r.buffers[Z.TYPE],t)};return Hl(r.type,r.offset,r.length,r._nullCount,s,e,n,Zl(r).map(i=>Ka(i,t)))}function Zg(r,t){return new A(r.data.map(e=>Xl(e,t)))}function Ka(r,t){if(!qA(r)||t.copy==="none"||t.copy!=="all"&&r.byteOffset===0&&r.byteLength===r.buffer.byteLength)return r;let e=t.copies.get(r);return e||(e=r instanceof Uint8Array?new Uint8Array(r):r.slice(),t.copies.set(r,e)),e}function qA(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var bd=p(()=>{Vr();gd()});var Hg=p(()=>{});var Xg=p(()=>{});var Kg=p(()=>{});var Jg=p(()=>{});function Qg(r,t){let e=Wg(r,t);return{transport:"arrow-js",version:1,schema:Ha(new st(e.schema,[])),metadataVersion:e.schema.metadataVersion,batches:e.batches.map(n=>wd(n.data))}}function tb(r){if(r.transport!=="arrow-js"||r.version!==1)throw new Error("Unsupported Arrow column-buffer transport protocol.");let t=Uo(r.schema).schema,e=new G(t.fields,t.metadata,t.dictionaries,r.metadataVersion),n=new ut(e.fields),s=r.batches.map(i=>new ct(e,xd(i,n)));return new st(e,s)}function wd(r){return{offset:r.offset,length:r.length,nullCount:r.nullCount,buffers:{[Z.OFFSET]:r.buffers[Z.OFFSET],[Z.DATA]:r.buffers[Z.DATA],[Z.VALIDITY]:r.buffers[Z.VALIDITY],[Z.TYPE]:r.buffers[Z.TYPE]},children:r.children.map(t=>wd(t)),variadicBuffers:Zl(r),dictionary:r.dictionary?.data.map(t=>wd(t))}}function xd(r,t){let e=r.children.map((s,i)=>xd(s,t.children[i].type)),n=r.dictionary&&w.isDictionary(t)?new A(r.dictionary.map(s=>xd(s,t.dictionary))):void 0;return Hl(t,r.offset,r.length,r.nullCount,r.buffers,e,n,r.variadicBuffers)}var eb=p(()=>{Vr();gd();bd()});var rb=p(()=>{Xg();Hg();Kg();Jg();bd();eb()});var nb=p(()=>{rb()});function re(r){if(!$A(r))throw new Error("Workers require Arrow table output");let{data:t,...e}=r;return{...structuredClone(e),data:Qg(t,{copy:"all"})}}function Ro(r){if(!WA(r))throw new Error("Workers require Arrow column transport");return{...r,data:tb(r.data)}}function $A(r){let t=r;return!!(t&&t.shape==="arrow-table"&&t.data&&typeof t.data=="object"&&"batches"in t.data)}function WA(r){let t=r;return!!(t&&t.shape==="arrow-table"&&t.data&&t.data.transport==="arrow-js"&&Array.isArray(t.data.batches))}var Gs=p(()=>{"use strict";nb()});function sb(...r){return YA(r)}function YA(r){let t=r.map(i=>i instanceof ArrayBuffer?new Uint8Array(i):i),e=t.reduce((i,o)=>i+o.byteLength,0),n=new Uint8Array(e),s=0;for(let i of t)n.set(i,s),s+=i.byteLength;return n.buffer}var ib=p(()=>{"use strict"});function ZA(r){return ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r)}var js,ob=p(()=>{"use strict";js=class{offset=0;ended=!1;maxRewindBytes;chunks=[];scratch=new ArrayBuffer(8);checkpoints=[];constructor(t){this.maxRewindBytes=t?.maxRewindBytes||0}get arrayBuffers(){return this.chunks.map(t=>t.buffer)}write(t){this.chunks.push(ZA(t))}end(){this.chunks=[],this.checkpoints=[],this.offset=0,this.ended=!0}hasAvailableBytes(t){return this.getAvailableByteLength()>=t}getAvailableByteLength(){let t=-this.offset;for(let e of this.chunks)t+=e.byteLength,t>0;return Math.max(0,t)}findBufferOffsets(t){let e=-this.offset,n=[];for(let s=0;s<this.chunks.length;s++){let i=this.chunks[s];if(e+i.byteLength<=0){e+=i.byteLength;continue}let o=e<=0?Math.abs(e):0,a;if(o+t<=i.byteLength)return a=o+t,n.push([s,[o,a]]),n;a=i.byteLength,n.push([s,[o,a]]),t-=i.byteLength-o,e+=i.byteLength}return null}getDataView(t){let e=this.findBufferOffsets(t);if(!e){if(this.ended)throw new Error("binary data exhausted");return null}let n;if(e.length===1){let[s,[i,o]]=e[0],a=this.chunks[s];n=new DataView(a.buffer,a.byteOffset+i,o-i)}else{let s=this.combineBufferOffsets(e);n=new DataView(s.buffer,s.byteOffset,s.byteLength)}return this.offset+=t,this.disposeBuffers(),n}readByte(){let t=this.findBufferOffsets(1);if(!t)throw new Error("binary data exhausted");let[e,[n]]=t[0],s=this.chunks[e][n];return this.offset++,this.disposeBuffers(),s}readUint16LE(){let t=this.readByte(),e=this.readByte();return t|e<<8}readUint32LE(){let t=this.readByte(),e=this.readByte(),n=this.readByte(),s=this.readByte();return(t|e<<8|n<<16|s<<24>>>0)>>>0}readInt32LE(){return this.readUint32LE()|0}readFloat64LE(){let t=this.getContiguousDataView(8);if(t)return t.getFloat64(0,!0);let e=new Uint8Array(this.scratch);return this.readInto(e,0,8),new DataView(this.scratch).getFloat64(0,!0)}readInto(t,e,n){let s=this.findBufferOffsets(n);if(!s)throw new Error("binary data exhausted");let i=e;for(let[o,[a,c]]of s){let l=this.chunks[o];t.set(l.subarray(a,c),i),i+=c-a}this.offset+=n,this.disposeBuffers()}readBytes(t){let e=this.findBufferOffsets(t);if(!e)throw new Error("binary data exhausted");let n;if(e.length===1){let[s,[i,o]]=e[0];n=this.chunks[s].subarray(i,o)}else n=this.combineBufferOffsets(e);return this.offset+=t,this.disposeBuffers(),n}skip(t){this.offset+=t}rewind(t){this.offset-=t}checkpoint(){let t={offset:this.offset};return this.checkpoints.push(t),t}restore(t){this.offset=t.offset,this.checkpoints.pop()}discardConsumed(){this.disposeBuffers()}_combineArrayBuffers(t){return this.combineBufferOffsets(t).buffer}getContiguousDataView(t){let e=this.findBufferOffsets(t);if(!e||e.length!==1)return null;let[n,[s,i]]=e[0],o=this.chunks[n],a=new DataView(o.buffer,o.byteOffset+s,i-s);return this.offset+=t,this.disposeBuffers(),a}disposeBuffers(){let t=this.checkpoints.length>0?Math.min(...this.checkpoints.map(e=>e.offset)):Number.POSITIVE_INFINITY;for(;this.chunks.length>0&&this.offset-this.maxRewindBytes>=this.chunks[0].byteLength&&t>=this.chunks[0].byteLength;){this.offset-=this.chunks[0].byteLength;for(let e of this.checkpoints)e.offset-=this.chunks[0].byteLength;t-=this.chunks[0].byteLength,this.chunks.shift()}}combineBufferOffsets(t){let e=0;for(let[,[i,o]]of t)e+=o-i;let n=new Uint8Array(e),s=0;for(let[i,[o,a]]of t){let c=this.chunks[i];n.set(c.subarray(o,a),s),s+=a-o}return n}}});async function*Kl(r,t={}){let e=new TextDecoder(void 0,t);for await(let n of r)yield typeof n=="string"?n:e.decode(n,{stream:!0})}async function*Jl(r){let t="";for await(let e of r){t+=e;let n;for(n=t.indexOf(`
|
|
26
|
+
}`),this._recordBatchesWithDictionaries=[],this._recordBatches=[],super.close()}}});function tb(r,t){if(lr(r))return uS(r,t);if(Br(r))return lS(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function lS(r,t){let e=null,n=t?.type==="bytes"||!1,s=t?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){i(o,e||(e=r[Symbol.iterator]()))},pull(o){e?i(o,e):o.close()},cancel(){e?.return&&e.return(),e=null}}),Object.assign({highWaterMark:n?s:void 0},t));function i(o,a){let c,l=null,u=o.desiredSize||null;for(;!(l=a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=E(l.value))&&(u!=null&&n&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()}}function uS(r,t){let e=null,n=t?.type==="bytes"||!1,s=t?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return B(this,void 0,void 0,function*(){yield i(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return B(this,void 0,void 0,function*(){e?yield i(o,e):o.close()})},cancel(){return B(this,void 0,void 0,function*(){e?.return&&(yield e.return()),e=null})}}),Object.assign({highWaterMark:n?s:void 0},t));function i(o,a){return B(this,void 0,void 0,function*(){let c,l=null,u=o.desiredSize||null;for(;!(l=yield a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=E(l.value))&&(u!=null&&n&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()})}}var eb=d(()=>{Pe();Gt();Wn()});function sb(r){return new Cd(r)}var Cd,rb,nb,ib=d(()=>{Pe();Za();Cd=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:s="count"}=t,i=py(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=kr(i),this._getSize=s!=="bytes"?rb:nb;let{["highWaterMark"]:o=s==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:a=s==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:c=>{this._maybeFlush(this._builder,this._controller=c)},start:c=>{this._maybeFlush(this._builder,this._controller=c)}},{highWaterMark:o,size:s!=="bytes"?rb:nb}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:c=>this._writeValueAndReturnChunkSize(c)})}_writeValueAndReturnChunkSize(t){let e=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(t)),this._bufferedSize-e}_maybeFlush(t,e){e!=null&&(this._bufferedSize>=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))}_enqueue(t,e){this._bufferedSize=0,this._controller=null,e==null?t.close():t.enqueue(e)}},rb=r=>{var t;return(t=r?.length)!==null&&t!==void 0?t:0},nb=r=>{var t;return(t=r?.byteLength)!==null&&t!==void 0?t:0}});function Hl(r,t){let e=new pr,n=null,s=new ReadableStream({cancel(){return B(this,void 0,void 0,function*(){yield e.close()})},start(a){return B(this,void 0,void 0,function*(){yield o(a,n||(n=yield i()))})},pull(a){return B(this,void 0,void 0,function*(){n?yield o(a,n):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:s};function i(){return B(this,void 0,void 0,function*(){return yield(yield Ee.from(e)).open(t)})}function o(a,c){return B(this,void 0,void 0,function*(){let l=a.desiredSize,u=null;for(;!(u=yield c.next()).done;)if(a.enqueue(u.value),l!=null&&--l<=0)return;a.close()})}}var ob=d(()=>{Pe();bs();Qa()});function Xl(r,t){let e=new this(r),n=new qe(e),s=new ReadableStream({cancel(){return B(this,void 0,void 0,function*(){yield n.cancel()})},pull(o){return B(this,void 0,void 0,function*(){yield i(o)})},start(o){return B(this,void 0,void 0,function*(){yield i(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:s};function i(o){return B(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield n.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}var ab=d(()=>{Pe();bs()});function Vo(r){let t=Ee.from(r);return Ke(t)?t.then(e=>Vo(e)):t.isAsync()?t.readAll().then(e=>new st(e)):new st(t.readAll())}function rc(r,t="stream",e=null){let n={compressionType:e};return(t==="stream"?Nn:Un).writeAll(r,n).toUint8Array(!0)}var cb=d(()=>{Vi();Wn();Qa();Zl()});var Fd={};Re(Fd,{isArrowData:()=>tu,isArrowDataType:()=>Ql,isArrowField:()=>Jl,isArrowRecordBatch:()=>ru,isArrowSchema:()=>Kl,isArrowTable:()=>nu,isArrowVector:()=>eu});function Kl(r){return G.isSchema(r)}function Jl(r){return S.isField(r)}function Ql(r){return w.isDataType(r)}function tu(r){return D.isData(r)}function eu(r){return v.isVector(r)}function ru(r){return ct.isRecordBatch(r)}function nu(r){return st.isTable(r)}var Ed=d(()=>{pe();yt();hr();he();Dn();Vi()});var lb,Od=d(()=>{$c();po();Mt();hr();yt();Vi();he();$e();pe();Pa();ll();At();Za();jh();nd();qh();Wh();Yh();Zh();Xh();Qh();od();id();Kh();Jh();cd();ud();ld();Dl();Fl();Cl();td();ed();Hh();rd();sd();ad();bs();Qa();Zl();cb();Gl();Vl();gs();Dn();Ed();jc();Ph();di();Ra();Gt();Lo();Ma();Ll();Ed();Ja();lb=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ah),Rh),Sh),ch),Lf),vh),nh),$h),Fd),{compareSchemas:zi,compareFields:C0,compareTypes:Nl})});var wr={};Re(wr,{AsyncByteQueue:()=>pr,AsyncByteStream:()=>qe,AsyncMessageReader:()=>$i,AsyncRecordBatchFileReader:()=>Po,AsyncRecordBatchStreamReader:()=>Cn,Binary:()=>ze,BinaryBuilder:()=>In,BinaryView:()=>H,BinaryViewBuilder:()=>Ln,Bool:()=>le,BoolBuilder:()=>bi,BufferType:()=>Z,Builder:()=>bt,ByteStream:()=>mr,CompressionType:()=>Ht,Data:()=>D,DataType:()=>w,DateBuilder:()=>en,DateDay:()=>es,DateDayBuilder:()=>xs,DateMillisecond:()=>rs,DateMillisecondBuilder:()=>As,DateUnit:()=>mt,Date_:()=>Te,Decimal:()=>Ve,DecimalBuilder:()=>vs,DenseUnion:()=>bn,DenseUnionBuilder:()=>Pi,Dictionary:()=>Rt,DictionaryBuilder:()=>wi,Duration:()=>Me,DurationBuilder:()=>yr,DurationMicrosecond:()=>Oa,DurationMicrosecondBuilder:()=>Ms,DurationMillisecond:()=>Ea,DurationMillisecondBuilder:()=>Ts,DurationNanosecond:()=>Na,DurationNanosecondBuilder:()=>Ds,DurationSecond:()=>Fa,DurationSecondBuilder:()=>Ls,Field:()=>S,FixedSizeBinary:()=>Ge,FixedSizeBinaryBuilder:()=>Ss,FixedSizeList:()=>gt,FixedSizeListBuilder:()=>xi,Float:()=>ae,Float16:()=>Er,Float16Builder:()=>Ai,Float32:()=>Xt,Float32Builder:()=>vi,Float64:()=>_e,Float64Builder:()=>Si,FloatBuilder:()=>rn,Int:()=>Lt,Int16:()=>Se,Int16Builder:()=>Bi,Int32:()=>Dt,Int32Builder:()=>_i,Int64:()=>Qe,Int64Builder:()=>Li,Int8:()=>ve,Int8Builder:()=>Ii,IntBuilder:()=>Ce,Interval:()=>ue,IntervalBuilder:()=>zr,IntervalDayTime:()=>us,IntervalDayTimeBuilder:()=>Is,IntervalMonthDayNano:()=>Ca,IntervalMonthDayNanoBuilder:()=>_s,IntervalUnit:()=>et,IntervalYearMonth:()=>fs,IntervalYearMonthBuilder:()=>Bs,JSONMessageReader:()=>ji,LargeBinary:()=>Or,LargeBinaryBuilder:()=>Bn,LargeList:()=>tr,LargeListBuilder:()=>Ei,LargeUtf8:()=>Nr,LargeUtf8Builder:()=>zs,List:()=>Ct,ListBuilder:()=>Fi,MapBuilder:()=>Oi,MapRow:()=>fr,Map_:()=>fe,Message:()=>ye,MessageHeader:()=>Q,MessageReader:()=>Vs,MetadataVersion:()=>ht,Null:()=>Ot,NullBuilder:()=>Ni,Precision:()=>ot,RecordBatch:()=>ct,RecordBatchFileReader:()=>Fn,RecordBatchFileWriter:()=>Un,RecordBatchJSONWriter:()=>ec,RecordBatchReader:()=>Ee,RecordBatchStreamReader:()=>Vr,RecordBatchStreamWriter:()=>Nn,RecordBatchWriter:()=>sn,Schema:()=>G,SparseUnion:()=>hs,SparseUnionBuilder:()=>Ri,Struct:()=>ut,StructBuilder:()=>Ui,StructRow:()=>Qr,Table:()=>st,Time:()=>Kt,TimeBuilder:()=>br,TimeMicrosecond:()=>is,TimeMicrosecondBuilder:()=>Rs,TimeMillisecond:()=>ss,TimeMillisecondBuilder:()=>Us,TimeNanosecond:()=>os,TimeNanosecondBuilder:()=>Ps,TimeSecond:()=>ns,TimeSecondBuilder:()=>Ns,TimeUnit:()=>A,Timestamp:()=>Jt,TimestampBuilder:()=>gr,TimestampMicrosecond:()=>cs,TimestampMicrosecondBuilder:()=>Es,TimestampMillisecond:()=>Jr,TimestampMillisecondBuilder:()=>Fs,TimestampNanosecond:()=>ls,TimestampNanosecondBuilder:()=>Os,TimestampSecond:()=>as,TimestampSecondBuilder:()=>Cs,Type:()=>p,Uint16:()=>Be,Uint16Builder:()=>Mi,Uint32:()=>jt,Uint32Builder:()=>Di,Uint64:()=>Fr,Uint64Builder:()=>Ci,Uint8:()=>Ie,Uint8Builder:()=>Ti,Union:()=>De,UnionBuilder:()=>_n,UnionMode:()=>lt,Utf8:()=>ce,Utf8Builder:()=>ks,Utf8View:()=>Le,Utf8ViewBuilder:()=>ki,Vector:()=>v,Visitor:()=>F,builderThroughAsyncIterable:()=>md,builderThroughIterable:()=>Rl,compressionRegistry:()=>Gs,isArrowData:()=>tu,isArrowDataType:()=>Ql,isArrowField:()=>Jl,isArrowRecordBatch:()=>ru,isArrowSchema:()=>Kl,isArrowTable:()=>nu,isArrowVector:()=>eu,makeBuilder:()=>kr,makeData:()=>M,makeTable:()=>yd,makeVector:()=>te,tableFromArrays:()=>gd,tableFromIPC:()=>Vo,tableFromJSON:()=>pd,tableToIPC:()=>rc,util:()=>lb,vectorFromArray:()=>No});var Gr=d(()=>{pa();At();Qa();Zl();eb();ib();ob();ab();Od();Od();Yt.toDOMStream=tb;bt.throughDOM=sb;Ee.throughDOM=Hl;Fn.throughDOM=Hl;Vr.throughDOM=Hl;sn.throughDOM=Xl;Un.throughDOM=Xl;Nn.throughDOM=Xl});var su,Nd,ub=d(()=>{"use strict";Gr();su=new G([new S("POSITION",new gt(3,new S("value",new Xt,!1)),!1)]),Nd=new G([...su.fields,new S("indices",new Ct(new S("item",new jt,!1)),!0)])});var $s=d(()=>{"use strict";hy();ub()});function dS(r,t="float32"){return r instanceof Date?"date-millisecond":typeof r=="number"?t:typeof r=="boolean"?"bool":typeof r=="string"?"utf8":"null"}function hb(r){let t=Ud(r);return t!=="null"?{type:t,nullable:!1}:r.length>0?(t=dS(r[0]),{type:t,nullable:!0}):{type:"null",nullable:!0}}function Ud(r){if(typeof Float16Array<"u"&&r instanceof Float16Array)return"float16";switch(r.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case BigInt64Array:return"int64";case BigUint64Array:return"uint64";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}var Rd=d(()=>{"use strict"});function iu(r){return{fields:r.fields.map(t=>qi(t)),metadata:yb(r.metadata)}}function yb(r){return Object.fromEntries(r)}function Pd(r){return r?new Map(Object.entries(r)):new Map}function qi(r){return{name:r.name,type:gb(r.type),nullable:r.nullable,metadata:yb(r.metadata)}}function Rn(r,t){return new S(r.name,ou(r.type,t),r.nullable,Pd(r.metadata))}function gb(r){if(db(r,"BinaryView"))return"binary-view";if(db(r,"Utf8View"))return"utf8-view";if(pS(r,"LargeList"))return{type:"large-list",children:[qi(r.valueField)]};switch(r.constructor){case Ot:return"null";case ze:return"binary";case Ge:return{type:"fixed-size-binary",byteWidth:r.byteWidth};case le:return"bool";case Lt:let t=r;return`${t.isSigned?"":"u"}int${t.bitWidth}`;case ve:return"int8";case Se:return"int16";case Dt:return"int32";case Qe:return"int64";case Ie:return"uint8";case Be:return"uint16";case jt:return"uint32";case Fr:return"uint64";case ae:switch(r.precision){case ot.HALF:return"float16";case ot.SINGLE:return"float32";case ot.DOUBLE:return"float64";default:return"float16"}case Er:return"float16";case Xt:return"float32";case _e:return"float64";case ce:return"utf8";case Ve:let n=r;return{type:"decimal",bitWidth:n.bitWidth,precision:n.precision,scale:n.scale};case Te:return r.unit===mt.DAY?"date-day":"date-millisecond";case es:return"date-day";case rs:return"date-millisecond";case Kt:switch(r.unit){case A.SECOND:return"time-second";case A.MILLISECOND:return"time-millisecond";case A.MICROSECOND:return"time-microsecond";case A.NANOSECOND:return"time-nanosecond";default:return"time-second"}case ss:return"time-millisecond";case ns:return"time-second";case is:return"time-microsecond";case os:return"time-nanosecond";case Jt:switch(r.unit){case A.SECOND:return"timestamp-second";case A.MILLISECOND:return"timestamp-millisecond";case A.MICROSECOND:return"timestamp-microsecond";case A.NANOSECOND:return"timestamp-nanosecond";default:return"timestamp-second"}case as:return"timestamp-second";case Jr:return"timestamp-millisecond";case cs:return"timestamp-microsecond";case ls:return"timestamp-nanosecond";case ue:switch(r.unit){case et.DAY_TIME:return"interval-daytime";case et.YEAR_MONTH:return"interval-yearmonth";default:return"interval-daytime"}case us:return"interval-daytime";case fs:return"interval-yearmonth";case fe:let c=r;return{type:"map",keysSorted:c.keysSorted,children:c.children.map(g=>qi(g))};case Ct:let u=r.valueField;return{type:"list",children:[qi(u)]};case gt:let f=r;return{type:"fixed-size-list",listSize:f.listSize,children:[qi(f.children[0])]};case ut:return{type:"struct",children:r.children.map(g=>qi(g))};case hs:case bn:let m=r;return{type:m instanceof bn?"dense-union":"sparse-union",typeIds:m.typeIds,children:m.children.map(g=>qi(g)),typeIdToChildIndex:{...m.typeIdToChildIndex}};case Rt:let y=r;return{type:"dictionary",id:y.id,indices:mS(y.indices),dictionary:gb(y.dictionary),isOrdered:y.isOrdered};default:throw new Error(`arrow type not supported: ${r.constructor.name}`)}}function ou(r,t){if(typeof r=="object")switch(r.type){case"decimal":return new Ve(r.scale,r.precision,r.bitWidth);case"map":{let e=r.children.map(n=>Rn(n,t));return new fe(e[0],r.keysSorted)}case"list":{let e=Rn(r.children[0],t);return new Ct(e)}case"large-list":{let e=Rn(r.children[0],t),n=nc("LargeList");if(!n)throw new Error("LargeList requires an Apache Arrow runtime that exports the LargeList constructor");return new n(e)}case"fixed-size-list":{let e=Rn(r.children[0],t);return new gt(r.listSize,e)}case"fixed-size-binary":return new Ge(r.byteWidth);case"struct":{let e=r.children.map(n=>Rn(n,t));return new ut(e)}case"sparse-union":case"dense-union":{let e=r.children.map(n=>Rn(n,t));return r.type==="dense-union"?new bn(r.typeIds,e):new hs(r.typeIds,e)}case"dictionary":return new Rt(ou(r.dictionary,t),gS(r.indices),r.id,r.isOrdered);default:throw new Error("array type not supported")}switch(r){case"null":return new Ot;case"binary":return pb("BinaryView",new ze,t);case"binary-view":return mb("BinaryView");case"bool":return new le;case"int8":return new ve;case"int16":return new Se;case"int32":return new Dt;case"int64":return new Qe;case"uint8":return new Ie;case"uint16":return new Be;case"uint32":return new jt;case"uint64":return new Fr;case"float16":return new Er;case"float32":return new Xt;case"float64":return new _e;case"utf8":return pb("Utf8View",new ce,t);case"utf8-view":return mb("Utf8View");case"date-day":return new es;case"date-millisecond":return new rs;case"time-second":return new ns;case"time-millisecond":return new ss;case"time-microsecond":return new is;case"time-nanosecond":return new os;case"timestamp-second":return new as;case"timestamp-millisecond":return new Jr;case"timestamp-microsecond":return new cs;case"timestamp-nanosecond":return new ls;case"interval-daytime":return new us;case"interval-yearmonth":return new fs;default:throw new Error("array type not supported")}}function nc(r){return wr[r]}function db(r,t){let e=nc(t);if(e&&r instanceof e)return!0;let n=w;return!!(t==="BinaryView"?n.isBinaryView:n.isUtf8View)?.(r)}function pS(r,t){let e=nc(t);return!!(e&&r instanceof e)}function pb(r,t,e){let n=e?.viewTypes||"never";if(n==="never")return t;let s=nc(r);if(s)return new s;if(n==="require")throw new Error(`${r} requires apache-arrow 21.2.0 or later; the installed runtime does not support it`);return t}function mb(r){let t=nc(r);if(!t)throw new Error(`${r} requires apache-arrow 21.2.0 or later; the installed runtime does not support it`);return new t}function mS(r){if(r instanceof Lt){let e=`${r.isSigned?"int":"uint"}${r.bitWidth}`;if(yS(e))return e}switch(r.constructor){case ve:return"int8";case Se:return"int16";case Dt:return"int32";case Ie:return"uint8";case Be:return"uint16";case jt:return"uint32";default:throw new Error(`arrow dictionary index type not supported: ${r.constructor.name}`)}}function yS(r){return["int8","int16","int32","uint8","uint16","uint32"].includes(r)}function gS(r){switch(r){case"int8":return new ve;case"int16":return new Se;case"int32":return new Dt;case"uint8":return new Ie;case"uint16":return new Be;case"uint32":return new jt;default:throw new Error(`schema dictionary index type not supported: ${r}`)}}var au=d(()=>{"use strict";Gr()});function on(r){let t=r?.POSITION;if(!t||!("value"in t)||!t.value.length)return null;let e=1/0,n=1/0,s=1/0,i=-1/0,o=-1/0,a=-1/0,c=t.value,l=c.length;for(let u=0;u<l;u+=3){let f=c[u],h=c[u+1],m=c[u+2];e=f<e?f:e,n=h<n?h:n,s=m<s?m:s,i=f>i?f:i,o=h>o?h:o,a=m>a?m:a}return[[e,n,s],[i,o,a]]}var kd=d(()=>{"use strict"});function bb(r){return r.type instanceof gt?r.type.listSize:1}function zd(r,t,e){let n=bS(r,t,e);return new v([n])}function bS(r,t,e){let n=wS(r,t,e),s=n.children[0].type,i=e==="float16"&&qn(r)?la(r):r,o={[Z.DATA]:i},a=new D(s,0,i.length,0,o);return new D(n,0,i.length/t,0,void 0,[a])}function wS(r,t,e){let n=e||hb(r).type,s=ou(n);return new gt(t,new S("value",s,!1))}var Vd=d(()=>{"use strict";$s();Gr();Rd();au()});function Oe(r,t){switch(t){case"columnar-table":return xS(r);case"arrow-table":return AS(r);default:throw new Error(t)}}function xS(r){let t={},e=xb(r);for(let[n,s]of Object.entries(r.attributes))t[n]=s.value;return{shape:"columnar-table",schema:r.schema,data:t,topology:r.topology,indices:e?r.indices:void 0}}function AS(r,t){return cu(r.attributes,{schema:r.schema,topology:r.topology,mode:r.mode,boundingBox:r.header?.boundingBox,indices:xb(r)?r.indices:void 0})}function cu(r,t={}){let e=[],n={},s=SS(r);for(let c of s){let l=r[c],{value:u,size:f=1}=l,h=vS(u,f,l.componentType);if(n[c]=h,e.push(IS(t.schema,c,h,l.componentType)),c==="POSITION"&&t.indices?.value?.length){let m=Nd.fields.find(y=>y.name==="indices");n.indices=_S(t.indices.value,h.length,m.type),e.push(m)}}let i=new G(e,LS(t)),o=n[s[0]]?.length===0?new st(i):new st(i,n);return{shape:"arrow-table",schema:iu(o.schema),data:o,topology:t.topology||"point-list",indices:t.indices}}function vS(r,t,e){if(e==="float16"){let n=qn(r)?la(r):r;if(t===1){let s=new D(new Er,0,n.length,0,{[Z.DATA]:n});return new v([s])}return zd(r,t,e)}return t===1?te(r):zd(r,t)}function SS(r){let t=Object.keys(r),e=wb.filter(s=>s in r),n=t.filter(s=>!wb.includes(s));return[...e,...n]}function xb(r){return!!r.indices?.value?.length}function IS(r,t,e,n){if(t==="POSITION"&&BS(e)){let i=su.fields[0],o=r?.fields.find(c=>c.name===t);if(!o?.metadata)return i;let a=new Map(i.metadata);for(let[c,l]of Object.entries(o.metadata))a.set(c,l);return new S(i.name,i.type,i.nullable,a)}let s=r?.fields.find(i=>i.name===t);if(n==="float16"){let i=new Map(Object.entries(s?.metadata||{}));return i.set("componentType","float16"),new S(t,e.type,!1,i)}if(s&&s.type.toString()!==e.type.toString()){let i=Rn(s);return new S(t,e.type,i.nullable,i.metadata)}return s?Rn(s):new S(t,e.type,!1)}function BS(r){return r.type instanceof gt&&r.type.listSize===3&&r.type.children[0].type instanceof Xt}function _S(r,t,e){let n=e,s=r instanceof Uint32Array?r:Uint32Array.from(r),i=new Int32Array(t+1);t>0&&i.fill(s.length,1);let o=new Uint8Array(Math.ceil(t/8));t>0&&(o[0]=1);let a=new D(n.children[0].type,0,s.length,0,{[Z.DATA]:s}),c=new D(n,0,t,Math.max(0,t-1),{[Z.OFFSET]:i,[Z.VALIDITY]:o},[a]);return new v([c])}function LS(r){let t={...r.schema?.metadata};return r.topology&&(t.topology||=r.topology),Number.isFinite(r.mode)&&(t.mode||=String(r.mode)),r.boundingBox&&(t.boundingBox||=JSON.stringify(r.boundingBox)),Pd(t)}var wb,Ab=d(()=>{"use strict";$s();$s();Gr();Vd();au();wb=["POSITION"]});function ee(r){if(r.shape==="arrow-table")return TS(r);throw new Error(r.shape)}function TS(r){let t=r.data,e=iu(t.schema),n=e.fields,s={},i=[];for(let u of n){let{name:f}=u;if(f==="indices")continue;let h=t.getChild(f),m=bb(h),y=ES(h,m),g=DS(u.metadata),x=g.componentType==="float16"?OS(y):y,I=i.find(j=>j.data.length===h.data.length&&s[j.name].value.constructor===x.constructor&&j.data.every((T,b)=>vb(T,h.data[b])));s[f]={value:I?s[I.name].value:x,size:m,...g},I||i.push({name:f,data:h.data})}FS(e);let o=e.metadata.topology,a=NS(e),c=US(t),l=s.POSITION?.transform?.type==="quantization"?MS(e)||on(s):on(s);return{schema:e,attributes:s,topology:o,mode:a,indices:c,header:{vertexCount:t.numRows,boundingBox:l??void 0}}}function MS(r){let t=r.metadata?.boundingBox;if(!t)return null;try{let e=JSON.parse(t);if(Array.isArray(e)&&e.length===2&&e.every(n=>Array.isArray(n)&&n.length===3&&n.every(s=>typeof s=="number")))return e}catch{}return null}function DS(r={}){let t={};if(r.byteOffset!==void 0&&(t.byteOffset=Number(r.byteOffset)),r.byteStride!==void 0&&(t.byteStride=Number(r.byteStride)),r.normalized!==void 0&&(t.normalized=r.normalized==="true"),r.componentType==="float16"&&(t.componentType="float16"),r["loaders.gl.transform"])try{let e=JSON.parse(r["loaders.gl.transform"]);CS(e)&&(t.transform=e)}catch{}return t}function CS(r){if(!r||typeof r!="object"||!("type"in r))return!1;let t=r;return t.type==="octahedron"?Number.isInteger(t.bits)&&t.bits>=1&&t.bits<=30:t.type==="quantization"&&Number.isInteger(t.bits)&&t.bits>=1&&t.bits<=30&&Array.isArray(t.origin)&&t.origin.every(e=>typeof e=="number")&&typeof t.range=="number"}function FS(r){r.metadata||={},r.metadata.topology||="point-list",r.metadata.mode||="0"}function ES(r,t){if(!(r.type instanceof gt))return r.toArray();let n=r.data[0].children[0].values.constructor,s=new n(r.length*t),i=0;for(let o of r.data){let a=o.children[0],c=o.length*t,l=a.offset||o.offset*t,u=l+c<=a.values.length?l:0,f=a.values.subarray(u,u+c);s.set(f,i),i+=c}return s}function OS(r){let t=_c(r.length);for(let e=0;e<r.length;e++)Lc(t,e,Af(r,e));return t}function NS(r){let t=Number(r.metadata?.mode);return Number.isFinite(t)?t:0}function US(r){let t=r.getChild("indices");if(!t?.isValid(0))return;let e=t.data[0],n=e.valueOffsets,s=n[e.offset],i=n[e.offset+1];return{value:e.children[0].values.subarray(s,i),size:1}}function vb(r,t){let e=Object.values(t.buffers);return r.type.toString()===t.type.toString()&&r.offset===t.offset&&r.length===t.length&&r.nullCount===t.nullCount&&r.dictionary===t.dictionary&&Object.values(r.buffers).every((n,s)=>{let i=e[s];return n===i||!!(n&&i&&n.buffer===i.buffer&&n.byteOffset===i.byteOffset&&n.byteLength===i.byteLength)})&&r.children.length===t.children.length&&r.children.every((n,s)=>vb(n,t.children[s]))}var Sb=d(()=>{"use strict";$s();Gr();Vd();au();kd()});function Wi(r,t={}){return{fields:RS(r),metadata:t}}function Ib(r,t,e){let n=t.componentType||Ud(t.value),s=e||Bb(t),i=t.size===1?n:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:n}]};return{name:r,type:i,nullable:!1,metadata:s}}function RS(r){let t=[];for(let e in r){let n=r[e];t.push(Ib(e,n))}return t}function Bb(r){let t={};return"byteOffset"in r&&(t.byteOffset=r.byteOffset.toString(10)),"byteStride"in r&&(t.byteStride=r.byteStride.toString(10)),"normalized"in r&&(t.normalized=r.normalized.toString()),r.componentType&&(t.componentType=r.componentType),r.transform&&(t["loaders.gl.transform"]=JSON.stringify(r.transform)),t}var _b=d(()=>{"use strict";Rd()});var or=d(()=>{"use strict";kd();Ab();Sb();_b()});var Lb,Tb=d(()=>{"use strict";Lb={name:"LAS",id:"las",module:"pointclouds",encoding:"binary",format:"las",extensions:["las","laz"],mimeTypes:["application/octet-stream"],text:!1,binary:!0,tests:["LASF"]}});function Db(r){return r?.las?.shape||Mb}function Fb(r,t){if(t==="uint8norm"||!r.attributes.COLOR_0)return r;let e=r.attributes.COLOR_0,n=e.value instanceof Uint16Array?65535:255,s=t==="float16"?si(e.value,n):ua(e.value,n),i={...r.attributes};for(let[o,a]of Object.entries(i))a.value===e.value&&(i[o]={...a,value:s,normalized:!1,...t==="float16"?{componentType:"float16"}:{}});return{...r,attributes:i}}var PS,Mb,Cb,Eb=d(()=>{"use strict";$s();Tb();PS="5.0.0-beta.8",Mb="arrow-table";Cb={...Lb,dataType:null,batchType:null,version:PS,worker:!1,options:{las:{shape:Mb,fp64:!1,colorDepth:8,colorFormat:"uint8norm",columns:void 0,extraBytes:"raw",recoverMissingChunkTable:!1,compatibilityMode:"auto"}}}});var lu=d(()=>{});var uu=d(()=>{});function sc(r){return r.variadicBuffers??[]}function ic(r,t,e,n,s,i,o,a){return Reflect.construct(D,[r,t,e,n,s,i,o,a])}var fu=d(()=>{Gr()});function Gd(r,t={}){let e={...t,copies:new WeakMap};return kS(r)?GS(r,e):zS(r)?Ob(r,e):VS(r)?Nb(r,e):hu(r,e)}function kS(r){return"batches"in r}function zS(r){return"schema"in r&&"data"in r&&!Array.isArray(r.data)}function VS(r){return"data"in r&&Array.isArray(r.data)}function GS(r,t){let e=r.batches.map(n=>Ob(n,t));return new st(r.schema,e)}function Ob(r,t){return new ct(r.schema,hu(r.data,t))}function hu(r,t){let e=r.children.map(i=>hu(i,t)),n=r.dictionary?Nb(r.dictionary,t):void 0,s={[Z.OFFSET]:oc(r.buffers[Z.OFFSET],t),[Z.DATA]:oc(r.buffers[Z.DATA],t),[Z.VALIDITY]:oc(r.buffers[Z.VALIDITY],t),[Z.TYPE]:oc(r.buffers[Z.TYPE],t)};return ic(r.type,r.offset,r.length,r._nullCount,s,e,n,sc(r).map(i=>oc(i,t)))}function Nb(r,t){return new v(r.data.map(e=>hu(e,t)))}function oc(r,t){if(!$S(r)||t.copy==="none"||t.copy!=="all"&&r.byteOffset===0&&r.byteLength===r.buffer.byteLength)return r;let e=t.copies.get(r);return e||(e=r instanceof Uint8Array?new Uint8Array(r):r.slice(),t.copies.set(r,e)),e}function $S(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var du=d(()=>{Gr();fu()});var Ub=d(()=>{fu();du()});var $d=d(()=>{lu()});var jd=d(()=>{lu();uu();Ub();$d()});var kb=d(()=>{lu();jd()});var zb=d(()=>{uu()});function Vb(r,t){let e=Gd(r,t);return{transport:"arrow-js",version:1,schema:rc(new st(e.schema,[])),metadataVersion:e.schema.metadataVersion,batches:e.batches.map(n=>qd(n.data))}}function Gb(r){if(r.transport!=="arrow-js"||r.version!==1)throw new Error("Unsupported Arrow column-buffer transport protocol.");let t=Vo(r.schema).schema,e=new G(t.fields,t.metadata,t.dictionaries,r.metadataVersion),n=new ut(e.fields),s=r.batches.map(i=>new ct(e,Wd(i,n)));return new st(e,s)}function qd(r){return{offset:r.offset,length:r.length,nullCount:r.nullCount,buffers:{[Z.OFFSET]:r.buffers[Z.OFFSET],[Z.DATA]:r.buffers[Z.DATA],[Z.VALIDITY]:r.buffers[Z.VALIDITY],[Z.TYPE]:r.buffers[Z.TYPE]},children:r.children.map(t=>qd(t)),variadicBuffers:sc(r),dictionary:r.dictionary?.data.map(t=>qd(t))}}function Wd(r,t){let e=r.children.map((s,i)=>Wd(s,t.children[i].type)),n=r.dictionary&&w.isDictionary(t)?new v(r.dictionary.map(s=>Wd(s,t.dictionary))):void 0;return ic(t,r.offset,r.length,r.nullCount,r.buffers,e,n,r.variadicBuffers)}var $b=d(()=>{Gr();fu();du()});var jb=d(()=>{});var qb=d(()=>{jd();$d();kb();uu();zb();du();$b();jb()});var Wb=d(()=>{qb()});function re(r){if(!YS(r))throw new Error("Workers require Arrow table output");let{data:t,...e}=r;return{...structuredClone(e),data:Vb(t,{copy:"all"})}}function $o(r){if(!ZS(r))throw new Error("Workers require Arrow column transport");return{...r,data:Gb(r.data)}}function YS(r){let t=r;return!!(t&&t.shape==="arrow-table"&&t.data&&typeof t.data=="object"&&"batches"in t.data)}function ZS(r){let t=r;return!!(t&&t.shape==="arrow-table"&&t.data&&t.data.transport==="arrow-js"&&Array.isArray(t.data.batches))}var js=d(()=>{"use strict";Wb()});var ac,HS,pu,XS,KS,Yd=d(()=>{ac=globalThis,HS=globalThis.document||{},pu=globalThis.process||{},XS=globalThis.console,KS=globalThis.navigator||{}});function mu(r){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let t=typeof navigator<"u"&&navigator.userAgent,e=r||t;return!!(e&&e.indexOf("Electron")>=0)}var yu=d(()=>{});function qs(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||mu()}var Zd=d(()=>{yu()});var Yb=d(()=>{Zd();yu();Yd()});var Zb=d(()=>{});var Hd,gu=d(()=>{Yd();Zd();Yb();yu();Zb();Hd="5.0.0"});function jo(r,t){if(!r)throw new Error(t||"Assertion failed")}var Xd=d(()=>{});function bu(r){if(!r)return 0;let t;switch(typeof r){case"number":t=r;break;case"object":t=r.logLevel||r.priority||0;break;default:return 0}return jo(Number.isFinite(t)&&t>=0),t}function Kd(r){let{logLevel:t,message:e}=r;r.logLevel=bu(t);let n=r.args?Array.from(r.args):[];for(;n.length&&n.shift()!==e;);switch(typeof t){case"string":case"function":e!==void 0&&n.unshift(e),r.message=t;break;case"object":Object.assign(r,t);break;default:}typeof r.message=="function"&&(r.message=r.message());let s=typeof r.message;return jo(s==="string"||s==="object"),Object.assign(r,{args:n},r.opts)}var wu=d(()=>{Xd()});var Ws,Yi,cc=d(()=>{wu();Ws=()=>{},Yi=class{constructor({level:t=0}={}){this.userData={},this._onceCache=new Set,this._level=t}set level(t){this.setLevel(t)}get level(){return this.getLevel()}setLevel(t){return this._level=t,this}getLevel(){return this._level}warn(t,...e){return this._log("warn",0,t,e,{once:!0})}error(t,...e){return this._log("error",0,t,e)}log(t,e,...n){return this._log("log",t,e,n)}info(t,e,...n){return this._log("info",t,e,n)}once(t,e,...n){return this._log("once",t,e,n,{once:!0})}_log(t,e,n,s,i={}){let o=Kd({logLevel:e,message:n,args:this._buildArgs(e,n,s),opts:i});return this._createLogFunction(t,o,i)}_buildArgs(t,e,n){return[t,e,...n]}_createLogFunction(t,e,n){if(!this._shouldLog(e.logLevel))return Ws;let s=this._getOnceTag(n.tag??e.tag??e.message);if((n.once||e.once)&&s!==void 0){if(this._onceCache.has(s))return Ws;this._onceCache.add(s)}return this._emit(t,e)}_shouldLog(t){return this.getLevel()>=bu(t)}_getOnceTag(t){if(t!==void 0)try{return typeof t=="string"?t:String(t)}catch{return}}}});function QS(r){try{let t=window[r],e="__storage_test__";return t.setItem(e,e),t.removeItem(e),t}catch{return null}}var lc,Jd=d(()=>{lc=class{constructor(t,e,n="sessionStorage"){this.storage=QS(n),this.id=t,this.config=e,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){if(Object.assign(this.config,t),this.storage){let e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let t={};if(this.storage){let e=this.storage.getItem(this.id);t=e?JSON.parse(e):{}}return Object.assign(this.config,t),this}}});function Hb(r){let t;return r<10?t=`${r.toFixed(2)}ms`:r<100?t=`${r.toFixed(1)}ms`:r<1e3?t=`${r.toFixed(0)}ms`:t=`${(r/1e3).toFixed(2)}s`,t}function Qd(r,t=8){let e=Math.max(t-r.length,0);return`${" ".repeat(e)}${r}`}var tp=d(()=>{});function Xb(r){return typeof r!="string"?r:(r=r.toUpperCase(),uc[r]||uc.WHITE)}function ep(r,t,e){return!qs&&typeof r=="string"&&(t&&(r=`\x1B[${Xb(t)}m${r}\x1B[39m`),e&&(r=`\x1B[${Xb(e)+tI}m${r}\x1B[49m`)),r}var uc,tI,xu=d(()=>{gu();(function(r){r[r.BLACK=30]="BLACK",r[r.RED=31]="RED",r[r.GREEN=32]="GREEN",r[r.YELLOW=33]="YELLOW",r[r.BLUE=34]="BLUE",r[r.MAGENTA=35]="MAGENTA",r[r.CYAN=36]="CYAN",r[r.WHITE=37]="WHITE",r[r.BRIGHT_BLACK=90]="BRIGHT_BLACK",r[r.BRIGHT_RED=91]="BRIGHT_RED",r[r.BRIGHT_GREEN=92]="BRIGHT_GREEN",r[r.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",r[r.BRIGHT_BLUE=94]="BRIGHT_BLUE",r[r.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",r[r.BRIGHT_CYAN=96]="BRIGHT_CYAN",r[r.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(uc||(uc={}));tI=10});function rp(r,t=["constructor"]){let e=Object.getPrototypeOf(r),n=Object.getOwnPropertyNames(e),s=r;for(let i of n){let o=s[i];typeof o=="function"&&(t.find(a=>i===a)||(s[i]=o.bind(r)))}}var np=d(()=>{});var Au,xr,fc=d(()=>{gu();Au=class{getHighResolutionTimer(){let t;if(qs()&&ac.performance)t=ac?.performance?.now?.();else if("hrtime"in pu){let e=pu?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}getMemoryUsageMB(){let e=ac?.performance?.memory?.usedJSHeapSize;return e==null?null:Math.trunc(e/1024/1024)}},xr=new Au;globalThis.Probe=Au;globalThis.probe=xr});function eI(r,t,e){if(typeof t=="string"){let n=e.time?Qd(Hb(e.total)):"";t=e.time?`${r}: ${n} ${t}`:`${r}: ${t}`,t=ep(t,e.color,e.background)}return t}function rI(r){for(let t in r)for(let e in r[t])return e||"untitled";return"empty"}var qo,sp,Pn,ip=d(()=>{gu();cc();Jd();tp();xu();np();Xd();fc();wu();wu();qo={debug:qs()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},sp={enabled:!0,level:0},Pn=class extends Yi{constructor({id:t}={id:""}){super({level:0}),this.VERSION=Hd,this._startTs=xr.getHighResolutionTimer(),this._deltaTs=xr.getHighResolutionTimer(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=t,this.userData={},this._storage=new lc(`__probe-${this.id}__`,{[this.id]:sp}),this.timeStamp(`${this.id} started`),rp(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((xr.getHighResolutionTimer()-this._startTs).toPrecision(10))}getDelta(){return Number((xr.getHighResolutionTimer()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(t=!0){return this._updateConfiguration({enabled:t}),this}setLevel(t){return this._updateConfiguration({level:t}),this}get(t){return this._getConfiguration()[t]}set(t,e){this._updateConfiguration({[t]:e})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,e){if(!t)throw new Error(e||"Assertion failed")}warn(t,...e){return this._log("warn",0,t,e,{method:qo.warn,once:!0})}error(t,...e){return this._log("error",0,t,e,{method:qo.error})}deprecated(t,e){return this.warn(`\`${t}\` is deprecated and will be removed in a later version. Use \`${e}\` instead`)}removed(t,e){return this.error(`\`${t}\` has been removed. Use \`${e}\` instead`)}probe(t,e,...n){let s=xr.getMemoryUsageMB();if(s!==null){let i=`${s}MB `;typeof e=="function"?e=()=>`${i}${e()}`:typeof e=="string"&&(e=`${i}${e}`)}return this._log("log",t,e,n,{method:qo.log,time:!0,once:!0})}log(t,e,...n){return this._log("log",t,e,n,{method:qo.debug})}info(t,e,...n){return this._log("info",t,e,n,{method:console.info})}once(t,e,...n){return this._log("once",t,e,n,{method:qo.debug||qo.info,once:!0})}table(t,e,n){return e?this._log("table",t,e,n&&[n]||[],{method:console.table||Ws,tag:rI(e)}):Ws}time(t,e){return this._log("time",t,e,[],{method:console.time?console.time:console.info})}timeEnd(t,e){return this._log("time",t,e,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(t,e){return this._log("time",t,e,[],{method:console.timeStamp||Ws})}group(t,e,n={collapsed:!1}){let s=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",t,e,[],{method:s})}groupCollapsed(t,e,n={}){return this.group(t,e,Object.assign({},n,{collapsed:!0}))}groupEnd(t){return this._log("groupEnd",t,"",[],{method:console.groupEnd||Ws})}withGroup(t,e,n){this.group(t,e)();try{n()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&super._shouldLog(t)}_emit(t,e){let n=e.method;jo(n),e.total=this.getTotal(),e.delta=this.getDelta(),this._deltaTs=xr.getHighResolutionTimer();let s=eI(this.id,e.message,e);return n.bind(console,s,...e.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(sp),this._storage.config[this.id]}_updateConfiguration(t){let e=this._storage.config[this.id]||{...sp};this._storage.setConfiguration({[this.id]:{...e,...t}})}};Pn.VERSION=Hd});var Kb=d(()=>{cc()});var Jb=d(()=>{cc()});var Qb=d(()=>{fc()});var tw=d(()=>{fc();globalThis.probe||(globalThis.probe=xr)});var Y8,ew=d(()=>{ip();fc();ip();Kb();cc();Jb();xu();xu();tp();np();Jd();Qb();tw();Y8=new Pn({id:"@probe.gl/log"})});function sI(){let r=new Pn({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=r,globalThis.loaders.version=nI,globalThis.probe||={},globalThis.probe.loaders=r,r}function hc(){}var op,nI,cp,ap,cP,rw=d(()=>{"use strict";ew();op="5.0.0-beta.8",nI=op[0]>="0"&&op[0]<="9"?`v${op}`:"";cp=sI(),ap=class{log(){return hc}info(){return hc}once(){return hc}warn(){return hc}error(){return hc}};cP=new ap});function nw(...r){return iI(r)}function iI(r){let t=r.map(i=>i instanceof ArrayBuffer?new Uint8Array(i):i),e=t.reduce((i,o)=>i+o.byteLength,0),n=new Uint8Array(e),s=0;for(let i of t)n.set(i,s),s+=i.byteLength;return n.buffer}var sw=d(()=>{"use strict"});function oI(r){return ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r)}var Ys,iw=d(()=>{"use strict";Ys=class{offset=0;ended=!1;maxRewindBytes;chunks=[];scratch=new ArrayBuffer(8);checkpoints=[];constructor(t){this.maxRewindBytes=t?.maxRewindBytes||0}get arrayBuffers(){return this.chunks.map(t=>t.buffer)}write(t){this.chunks.push(oI(t))}end(){this.chunks=[],this.checkpoints=[],this.offset=0,this.ended=!0}hasAvailableBytes(t){return this.getAvailableByteLength()>=t}getAvailableByteLength(){let t=-this.offset;for(let e of this.chunks)t+=e.byteLength,t>0;return Math.max(0,t)}findBufferOffsets(t){let e=-this.offset,n=[];for(let s=0;s<this.chunks.length;s++){let i=this.chunks[s];if(e+i.byteLength<=0){e+=i.byteLength;continue}let o=e<=0?Math.abs(e):0,a;if(o+t<=i.byteLength)return a=o+t,n.push([s,[o,a]]),n;a=i.byteLength,n.push([s,[o,a]]),t-=i.byteLength-o,e+=i.byteLength}return null}getDataView(t){let e=this.findBufferOffsets(t);if(!e){if(this.ended)throw new Error("binary data exhausted");return null}let n;if(e.length===1){let[s,[i,o]]=e[0],a=this.chunks[s];n=new DataView(a.buffer,a.byteOffset+i,o-i)}else{let s=this.combineBufferOffsets(e);n=new DataView(s.buffer,s.byteOffset,s.byteLength)}return this.offset+=t,this.disposeBuffers(),n}readByte(){let t=this.findBufferOffsets(1);if(!t)throw new Error("binary data exhausted");let[e,[n]]=t[0],s=this.chunks[e][n];return this.offset++,this.disposeBuffers(),s}readUint16LE(){let t=this.readByte(),e=this.readByte();return t|e<<8}readUint32LE(){let t=this.readByte(),e=this.readByte(),n=this.readByte(),s=this.readByte();return(t|e<<8|n<<16|s<<24>>>0)>>>0}readInt32LE(){return this.readUint32LE()|0}readFloat64LE(){let t=this.getContiguousDataView(8);if(t)return t.getFloat64(0,!0);let e=new Uint8Array(this.scratch);return this.readInto(e,0,8),new DataView(this.scratch).getFloat64(0,!0)}readInto(t,e,n){let s=this.findBufferOffsets(n);if(!s)throw new Error("binary data exhausted");let i=e;for(let[o,[a,c]]of s){let l=this.chunks[o];t.set(l.subarray(a,c),i),i+=c-a}this.offset+=n,this.disposeBuffers()}readBytes(t){let e=this.findBufferOffsets(t);if(!e)throw new Error("binary data exhausted");let n;if(e.length===1){let[s,[i,o]]=e[0];n=this.chunks[s].subarray(i,o)}else n=this.combineBufferOffsets(e);return this.offset+=t,this.disposeBuffers(),n}skip(t){this.offset+=t}rewind(t){this.offset-=t}checkpoint(){let t={offset:this.offset};return this.checkpoints.push(t),t}restore(t){this.offset=t.offset,this.checkpoints.pop()}discardConsumed(){this.disposeBuffers()}_combineArrayBuffers(t){return this.combineBufferOffsets(t).buffer}getContiguousDataView(t){let e=this.findBufferOffsets(t);if(!e||e.length!==1)return null;let[n,[s,i]]=e[0],o=this.chunks[n],a=new DataView(o.buffer,o.byteOffset+s,i-s);return this.offset+=t,this.disposeBuffers(),a}disposeBuffers(){let t=this.checkpoints.length>0?Math.min(...this.checkpoints.map(e=>e.offset)):Number.POSITIVE_INFINITY;for(;this.chunks.length>0&&this.offset-this.maxRewindBytes>=this.chunks[0].byteLength&&t>=this.chunks[0].byteLength;){this.offset-=this.chunks[0].byteLength;for(let e of this.checkpoints)e.offset-=this.chunks[0].byteLength;t-=this.chunks[0].byteLength,this.chunks.shift()}}combineBufferOffsets(t){let e=0;for(let[,[i,o]]of t)e+=o-i;let n=new Uint8Array(e),s=0;for(let[i,[o,a]]of t){let c=this.chunks[i];n.set(c.subarray(o,a),s),s+=a-o}return n}}});async function*vu(r,t={}){let e=new TextDecoder(void 0,t);for await(let n of r)yield typeof n=="string"?n:e.decode(n,{stream:!0})}async function*Su(r){let t="";for await(let e of r){t+=e;let n;for(n=t.indexOf(`
|
|
27
27
|
`);n>=0;){let s=t.slice(0,n+1);t=t.slice(n+1),yield s,n=t.indexOf(`
|
|
28
|
-
`)}}t.length>0&&(yield t)}var ab=p(()=>{"use strict"});async function vd(r,t){let e=HA(r);for(;;){let{done:n,value:s}=await e.next();if(n){e.return&&e.return();return}if(t(s))return}}async function Ad(r){let t=[];for await(let e of r)t.push(lb(e));return sb(...t)}async function*Ql(r){for await(let t of r)yield lb(t)}function lb(r){if(r instanceof ArrayBuffer)return r;if(ArrayBuffer.isView(r)){let{buffer:t,byteOffset:e,byteLength:n}=r;return cb(t,e,n)}return cb(r)}function cb(r,t=0,e=r.byteLength-t){let n=new Uint8Array(r,t,e),s=new Uint8Array(n.length);return s.set(n),s.buffer}function HA(r){if(typeof r[Symbol.asyncIterator]=="function")return r[Symbol.asyncIterator]();if(typeof r[Symbol.iterator]=="function"){let t=r[Symbol.iterator]();return XA(t)}return r}function XA(r){return{next(t){return Promise.resolve(r.next(t))},return(t){return typeof r.return=="function"?Promise.resolve(r.return(t)):Promise.resolve({done:!0,value:t})},throw(t){return typeof r.throw=="function"?Promise.resolve(r.throw(t)):Promise.reject(t)}}}var ub=p(()=>{"use strict";ib()});function Yd(r){return new Bd(r)}function Ld(r){return{intensity:!!r.intensities,classification:!!r.classifications,color:!!(r.colors||r.rawColors),gpsTime:!!r.gpsTimes,nir:!!r.nir,scanAngle:!!r.scanAngles,userData:!!r.userData,pointSourceId:!!r.pointSourceIds,flags:!!(r.scannerChannels||r.scanDirectionFlags||r.edgeOfFlightLines||r.syntheticFlags||r.keyPointFlags||r.withheldFlags||r.overlapFlags),waveform:!!r.waveforms,extraBytes:!!r.extraBytes}}function bb(r){return(r.intensity?1:0)|(r.classification?2:0)|(r.color?4:0)|(r.gpsTime?8:0)|(r.nir?16:0)|(r.scanAngle?32:0)|(r.userData?64:0)|(r.pointSourceId?128:0)|(r.flags?256:0)|(r.waveform?512:0)|(r.extraBytes?1024:0)}function jr(r,t){return new _d(r,t)}function fu(r,t){let e=jr(r,t),n=new Uint8Array(t.pointCount*t.pointDataRecordLength);return e.decodeInto(n,0,t.pointCount),n}function wb(r,t){if(!mu(t.pointDataRecordFormat))throw new it("Legacy LAZ chunk byte length is not self-describing");let e=$o(r),n=qo(t),s=t.pointDataRecordLength,i=ec(t.pointDataRecordFormat,n),o=s+4,a=i*4;if(e.byteLength<o+a)throw new it;let c=new DataView(e.buffer,e.byteOffset,e.byteLength),l=o+a;for(let u=0;u<i;u++)l+=c.getUint32(o+u*4,!0);if(e.byteLength<l)throw new it;return l}function Zd(r,t){let e=new eu($o(r)),n=new ne(e),s=Bt(32,2);n.readInitBytes();let i=[],o=0,a=0,c=t.pointCount;for(let l=0;l<t.chunkCount;l++){let u;t.variable?(o=s.decompress(n,o,0)>>>0,u=o):(u=Math.min(t.chunkSize,c),c-=u),a=s.decompress(n,a,1)>>>0,i.push({pointCount:u,byteLength:a})}return i}function hu(r){if(!mu(r.pointDataRecordFormat))return r.pointDataRecordLength+4;let t=qo(r);return r.pointDataRecordLength+4+ec(r.pointDataRecordFormat,t)*4}function du(r,t){if(!mu(t.pointDataRecordFormat))throw new it("Legacy LAZ chunk byte length is not self-describing");let e=Td($o(r),t);if(!e)throw new it("LAZ chunk decoder needs the complete layered size header");return e.byteLength}function Td(r,t){let e=qo(t),n=t.pointDataRecordLength+4,s=ec(t.pointDataRecordFormat,e),i=s*4;if(r.byteLength<n+i)return null;let o=new DataView(r.buffer,r.byteOffset,r.byteLength),a=n+i,c=[];for(let u=0;u<s;u++){let f=o.getUint32(n+u*4,!0);a+=f,c.push(f)}let l=n+i;return{byteLength:a,layerByteLengths:c,getByteLength:u=>l+c.slice(0,u).reduce((f,h)=>f+h,0)}}function KA(r,t){if(t.extraBytes)return ec(r.pointDataRecordFormat,qo(r));let e=2;return t.classifications&&(e=3),(t.scannerChannels||t.scanDirectionFlags||t.edgeOfFlightLines||t.syntheticFlags||t.keyPointFlags||t.withheldFlags||t.overlapFlags)&&(e=4),t.intensities&&(e=5),t.scanAngles&&(e=6),t.userData&&(e=7),t.pointSourceIds&&(e=8),t.gpsTimes&&(e=9),(t.colors||t.rawColors)&&(e=10),t.nir&&(e=11),t.waveforms&&(e=r.pointDataRecordFormat===9?10:12),Math.min(e,ec(r.pointDataRecordFormat,qo(r)))}function Id(r){let t=r.byteItemVersion===1?4:2;return Math.max(iS,r.pointDataRecordLength*t+512)}function db(r){return r[0]<r[1]?r[1]<r[2]?r[1]:Math.max(r[0],r[2]):r[0]<r[2]?r[0]:Math.max(r[1],r[2])}function aS(r,t,e,n){let s=qo(t);for(let i of[t.point10ItemVersion,t.gpsTime11ItemVersion,t.rgb12ItemVersion,t.byteItemVersion])if(i!==void 0&&i!==1&&i!==2)throw new Error(`Unsupported legacy LASzip item version ${i}`);switch(t.pointDataRecordFormat){case 0:return new Ud(r,s,t);case 1:return new Nd(r,s,t);case 2:return new Rd(r,s,t);case 3:return new Pd(r,s,t,e==="point-data"?n:null);case 4:return new kd(r,s,t);case 5:return new zd(r,s,t);case 6:return new Vd(r,s,e,t,n);case 7:return new Gd(r,s,e,t,n);case 8:return new jd(r,s,e,t,n);case 9:return new qd(r,s,e,t,n);case 10:return new $d(r,s,e,t,n);default:throw new Error(`TypeScript LAZ decoder does not support point format ${t.pointDataRecordFormat}`)}}function cS(r){return r<=5||r>=6&&r<=10}function Bt(r,t){let e=new Dd(r,t);return e.init(),e}function ge(r,t){return Array.from({length:r},()=>new jt(t))}function qo(r){let t=lS(r.pointDataRecordFormat),e=r.pointDataRecordLength-t;if(e<0)throw new Error(`Invalid point record length ${r.pointDataRecordLength}`);return e}function lS(r){switch(r){case 0:return 20;case 1:return 28;case 2:return 26;case 3:return 34;case 4:return 57;case 5:return 63;case 6:return 30;case 7:return 36;case 8:return 38;case 9:return 59;case 10:return 67;default:throw new Error(`TypeScript LAZ decoder does not support point format ${r}`)}}function mu(r){return r>=6&&r<=10}function ec(r,t){switch(r){case 6:return 9+t;case 7:return 10+t;case 8:return 11+t;case 9:return 10+t;case 10:return 12+t;default:throw new Error(`TypeScript LAZ decoder does not support point format ${r}`)}}function uS(){return{x:0,y:0,z:0,intensity:0,returns:0,flags:0,classification:0,userData:0,scanAngle:0,pointSourceId:0,gpsTime:0}}function pb(){return{x:0,y:0,z:0,intensity:0,bitByte:0,classification:0,scanAngleRank:0,userData:0,pointSourceId:0}}function fS(r,t){r.x=ko(t),r.y=ko(t),r.z=ko(t),r.intensity=Ys(t),r.bitByte=t.getByte(),r.classification=t.getByte(),r.scanAngleRank=Wd(t.getByte()),r.userData=t.getByte(),r.pointSourceId=Ys(t)}function hS(r,t){r.x=t.x,r.y=t.y,r.z=t.z,r.intensity=t.intensity,r.bitByte=t.bitByte,r.classification=t.classification,r.scanAngleRank=t.scanAngleRank,r.userData=t.userData,r.pointSourceId=t.pointSourceId}function dS(r,t,e){Ue(r.x,t,e),Ue(r.y,t,e+4),Ue(r.z,t,e+8),ar(r.intensity,t,e+12),t[e+14]=r.bitByte,t[e+15]=r.classification,t[e+16]=r.scanAngleRank&255,t[e+17]=r.userData,ar(r.pointSourceId,t,e+18)}function Rn(r,t,e,n,s,i,o){let a=o*3;t[a]=r.x*s[0]+i[0],t[a+1]=r.y*s[1]+i[1],t[a+2]=r.z*s[2]+i[2],e&&(e[o]=r.intensity),n&&(n[o]=r.classification&31)}function Wi(r,t,e){let n=r.classification>>5;t.syntheticFlags&&(t.syntheticFlags[e]=n&1),t.keyPointFlags&&(t.keyPointFlags[e]=n>>1&1),t.withheldFlags&&(t.withheldFlags[e]=n>>2&1),t.overlapFlags&&(t.overlapFlags[e]=0),t.scanAngles&&(t.scanAngles[e]=r.scanAngleRank),t.userData&&(t.userData[e]=r.userData),t.pointSourceIds&&(t.pointSourceIds[e]=r.pointSourceId),t.returnNumbers&&(t.returnNumbers[e]=r.bitByte&7),t.numberOfReturns&&(t.numberOfReturns[e]=r.bitByte>>3&7),t.scannerChannels&&(t.scannerChannels[e]=0),t.scanDirectionFlags&&(t.scanDirectionFlags[e]=r.bitByte>>6&1),t.edgeOfFlightLines&&(t.edgeOfFlightLines[e]=r.bitByte>>7&1)}function mb(r){return r.bitByte&7}function yb(r){return r.bitByte>>3&7}function pS(r){return r.bitByte>>6&1}function gb(r,t){r.x=t.x,r.y=t.y,r.z=t.z,r.intensity=t.intensity,r.returns=t.returns,r.flags=t.flags,r.classification=t.classification,r.userData=t.userData,r.scanAngle=t.scanAngle,r.pointSourceId=t.pointSourceId,r.gpsTime=t.gpsTime}function mS(r,t,e){r.x=Gr(t,e),r.y=Gr(t,e+4),r.z=Gr(t,e+8),r.intensity=au(t,e+12),r.returns=t[e+14],r.flags=t[e+15],r.classification=t[e+16],r.userData=t[e+17],r.scanAngle=IS(t,e+18),r.pointSourceId=au(t,e+20),r.gpsTime=_S(t,e+22)}function yS(r,t){r.x=ko(t),r.y=ko(t),r.z=ko(t),r.intensity=Ys(t),r.returns=t.getByte(),r.flags=t.getByte(),r.classification=t.getByte(),r.userData=t.getByte(),r.scanAngle=Xd(Ys(t)),r.pointSourceId=Ys(t),r.gpsTime=Sb(t)}function gS(r,t,e){Ue(r.x,t,e),Ue(r.y,t,e+4),Ue(r.z,t,e+8),ar(r.intensity,t,e+12),t[e+14]=r.returns,t[e+15]=r.flags,t[e+16]=r.classification,t[e+17]=r.userData,BS(r.scanAngle,t,e+18),ar(r.pointSourceId,t,e+20),Ib(r.gpsTime,t,e+22)}function rc(r,t,e){Ws(r,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),Yi(r,t,e),Zi(r,t,e)}function Ws(r,t,e,n,s,i,o){let a=o*3;t[a]=r.x*s[0]+i[0],t[a+1]=r.y*s[1]+i[1],t[a+2]=r.z*s[2]+i[2],e&&(e[o]=r.intensity),n&&(n[o]=r.classification)}function Yi(r,t,e){t.gpsTimes&&(t.gpsTimes[e]=r.gpsTime)}function Zi(r,t,e){t.scanAngles&&(t.scanAngles[e]=r.scanAngle),t.userData&&(t.userData[e]=r.userData),t.pointSourceIds&&(t.pointSourceIds[e]=r.pointSourceId),t.returnNumbers&&(t.returnNumbers[e]=r.returns&15),t.numberOfReturns&&(t.numberOfReturns[e]=r.returns>>4),t.scannerChannels&&(t.scannerChannels[e]=r.flags>>4&3),t.scanDirectionFlags&&(t.scanDirectionFlags[e]=r.flags>>6&1),t.edgeOfFlightLines&&(t.edgeOfFlightLines[e]=r.flags>>7&1),t.syntheticFlags&&(t.syntheticFlags[e]=r.flags&1),t.keyPointFlags&&(t.keyPointFlags[e]=r.flags>>1&1),t.withheldFlags&&(t.withheldFlags[e]=r.flags>>2&1),t.overlapFlags&&(t.overlapFlags[e]=r.flags>>3&1)}function ou(r,t,e){t.nir&&(t.nir[e]=r)}function Hi(r,t,e,n,s){if(n.colors){let o=s*4;n.colors[o]=r&255,n.colors[o+1]=t&255,n.colors[o+2]=e&255,n.colors[o+3]=255;return}if(!n.rawColors)return;let i=s*3;n.rawColors[i]=r,n.rawColors[i+1]=t,n.rawColors[i+2]=e}function bS(r){return r.flags>>4&3}function wS(r,t){r.flags=(t&3)<<4|r.flags&-49}function xS(r,t){r.flags=t&15|r.flags&240}function vS(r,t){r.flags=(t&1)<<6|r.flags&191}function AS(r,t){r.flags=(t&1)<<7|r.flags&127}function SS(r){return r.flags&15|(r.flags>>6&1)<<4|(r.flags>>7&1)<<5}function au(r,t){return r[t]|r[t+1]<<8}function Ys(r){let t=r.getByte(),e=r.getByte();return t|e<<8}function ar(r,t,e){t[e]=r&255,t[e+1]=r>>8&255}function IS(r,t){return Xd(au(r,t))}function BS(r,t,e){ar(r,t,e)}function cu(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24>>>0)>>>0}function lu(r,t,e){Ue(r,t,e)}function vb(r,t){let e=cu(r,t),n=cu(r,t+4);return BigInt(n)<<32n|BigInt(e)}function Ab(r,t,e){lu(Number(r&0xffffffffn),t,e),lu(Number(r>>32n&0xffffffffn),t,e+4)}function Gr(r,t){return r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24}function ko(r){let t=r.getByte(),e=r.getByte(),n=r.getByte(),s=r.getByte();return t|e<<8|n<<16|s<<24}function Ue(r,t,e){t[e]=r&255,t[e+1]=r>>8&255,t[e+2]=r>>16&255,t[e+3]=r>>24&255}function _S(r,t){for(let e=0;e<8;e++)Hd[e]=r[t+e];return ji.getFloat64(0,!0)}function Sb(r){for(let t=0;t<8;t++)Hd[t]=r.getByte();return ji.getFloat64(0,!0)}function Ib(r,t,e){ji.setFloat64(0,r,!0);for(let n=0;n<8;n++)t[e+n]=Hd[n]}function $s(r){return r<=0?0:r>=255?255:r}function Xd(r){let t=r&65535;return t&32768?t-65536:t}function Wd(r){let t=r&255;return t&128?t-256:t}function an(r){return r|0}function uu(r){return ji.setFloat64(0,r,!0),ji.getBigUint64(0,!0)}function zo(r){return ji.setBigUint64(0,r,!0),ji.getFloat64(0,!0)}function qs(r,t){let e=BigInt.asIntN(64,BigInt.asIntN(64,uu(r))+BigInt(t));return zo(BigInt.asUintN(64,e))}function $o(r){return r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function LS(r){let t=r.reduce((s,i)=>s+i.byteLength,0),e=new Uint8Array(t),n=0;for(let s of r)e.set(s,n),n+=s.byteLength;return e}var it,Bd,_d,Po,JA,pu,QA,tS,Ja,eS,fb,rS,nS,on,Vo,tu,sS,Sd,xb,Hd,ji,iS,hb,oS,eu,jt,Md,ne,Dd,Go,Zs,Qa,Hs,Nt,Cd,qi,Fd,tc,Od,ru,nu,su,Ed,$i,Ud,jo,Nd,Rd,Pd,iu,kd,zd,Vd,Gd,jd,qd,$d,Bb=p(()=>{"use strict";it=class extends Error{constructor(t="LAZ chunk decoder needs more compressed data"){super(t),this.name="NeedsMoreData"}},Bd=class{metadata;chunks=[];closed=!1;compressed=null;cursor=null;fedByteLength=0;requiredByteLength=null;progressiveRequiredByteLength=null;progressiveSelectionKey=null;constructor(t){this.metadata=t}feed(t){if(this.closed)throw new Error("Cannot feed a closed LAZ chunk decoder");let e=$o(t);this.chunks.push(e),this.compressed=null,this.fedByteLength+=e.byteLength}close(){this.closed=!0}get remainingPointCount(){return this.cursor?.remainingPointCount??this.metadata.pointCount}decode(){if(!this.closed)throw new it("LAZ chunk decoder input is not closed");return this.decodeAvailable()}readBatch(t){if(!this.cursor){if(!this.hasCompleteChunk())return null;let i=this.getCompressedAvailable(),o=this.requiredByteLength??i.byteLength;this.cursor=jr(i.subarray(0,o),this.metadata)}if(this.cursor.remainingPointCount<=0)return null;let e=this.metadata.pointDataRecordLength,n=Math.min(t,this.cursor.remainingPointCount),s=new Uint8Array(n*e);return this.cursor.decodeInto(s,0,n),s}readPositionDataBatch(t,e){if(t.colors||t.rawColors||t.nir)throw new Error("Position-only LAZ batches cannot request color or NIR output");return this.readPointDataBatch(t,e)}readPointDataBatch(t,e){let n=this.metadata.pointDataRecordFormat;if(n<6||n>10)throw new Error("Progressive LAZ point-data batches require point formats 6-10");let s=n===7||n===8||n===10;if((t.colors||t.rawColors)&&!s)throw new Error(`Point format ${n} does not contain RGB data`);if(t.nir&&n!==8&&n!==10)throw new Error("NIR output requires point format 8 or 10");if(t.waveforms&&n!==9&&n!==10)throw new Error("Waveform output requires point format 9 or 10");if(!this.cursor){let o=this.getProgressivePointData(t);if(!o)return null;this.cursor=jr(o,this.metadata)}if(this.cursor.remainingPointCount<=0)return 0;let i=Math.min(e,this.cursor.remainingPointCount);return this.cursor.decodeIntoPointData(t,i)}hasCompleteChunk(){if(!mu(this.metadata.pointDataRecordFormat))return this.closed;if(this.requiredByteLength!==null)return this.fedByteLength>=this.requiredByteLength;if(this.fedByteLength<hu(this.metadata))return!1;try{let t=this.getCompressedAvailable();return this.requiredByteLength=wb(t,this.metadata),this.requiredByteLength<=this.fedByteLength}catch(t){if(t instanceof it)return!1;throw t}}decodeAvailable(){let t=this.getCompressedAvailable(),e=this.requiredByteLength??t.byteLength;return fu(t.subarray(0,e),this.metadata)}getCompressedAvailable(){return this.compressed||=LS(this.chunks),this.compressed}getProgressivePointData(t){let e=bb(Ld(t));if(this.progressiveSelectionKey!==e&&(this.progressiveRequiredByteLength=null,this.progressiveSelectionKey=e),this.progressiveRequiredByteLength===null){let o=this.getCompressedAvailable(),a=Td(o,this.metadata);if(!a)return null;let c=KA(this.metadata,t);this.progressiveRequiredByteLength=a.getByteLength(c)}if(this.fedByteLength<this.progressiveRequiredByteLength)return null;let n=this.getCompressedAvailable(),s=Td(n,this.metadata),i=new Uint8Array(s.byteLength);return i.set(n.subarray(0,Math.min(n.byteLength,s.byteLength))),i}};_d=class{metadata;stream;decoder=null;pointIndex=0;outputMode=null;pointDataSelectionKey=null;constructor(t,e){this.metadata=e,this.stream=new eu($o(t))}feed(t){if(this.metadata.pointDataRecordFormat>5)throw new Error("Only legacy PDRF 0-5 LAZ cursors accept additional compressed input");this.stream.append($o(t))}discardConsumedInput(){if(this.metadata.pointDataRecordFormat>5)throw new Error("Only legacy PDRF 0-5 LAZ cursors can discard consumed input");this.stream.discardConsumedInput()}get remainingPointCount(){return this.metadata.pointCount-this.pointIndex}get compressedByteOffset(){return this.stream.byteOffset}get requiredInputByteLength(){if(this.metadata.pointDataRecordFormat>5)return this.stream.byteOffset;let t=this.pointIndex===0?this.metadata.pointDataRecordLength+4:Id(this.metadata);return this.stream.byteOffset+t}decodeInto(t,e,n){let s=Math.min(n,this.remainingPointCount),i=this.selectOutputMode("raw",s);if(!i)return 0;let o=e;for(let a=0;a<s;a++)o=i.decompress(t,o);return this.pointIndex+=s,s}decodeAvailableInto(t,e,n,s=!1){if(this.metadata.pointDataRecordFormat>5)throw new Error("Available-point decoding is limited to legacy PDRF 0-5 LAZ chunks");let i=Math.min(n,this.remainingPointCount);if(i===0)return 0;let o=this.selectOutputMode("raw",i),a=0,c=e;for(;a<i;){let l=this.pointIndex===0?this.metadata.pointDataRecordLength+4:Id(this.metadata);if(!s&&this.stream.availableByteLength<l)break;try{c=o.decompress(t,c)}catch(u){throw u instanceof it&&!s?new Error(`Legacy LAZ point exceeded the ${l}-byte streaming lookahead`):u}a++,this.pointIndex++}return a}decodeAvailableIntoPointData(t,e,n=!1){if(this.metadata.pointDataRecordFormat>5)throw new Error("Available point-data decoding is limited to legacy PDRF 0-5 LAZ chunks");let s=Math.min(e,this.remainingPointCount);if(s===0)return 0;let i=Ld(t),o=this.selectOutputMode("point-data",s,i),a=0,c=t.pointOffset;for(;a<s;){let l=this.pointIndex===0?this.metadata.pointDataRecordLength+4:Id(this.metadata);if(!n&&this.stream.availableByteLength<l)break;try{t.pointOffset=c+a,o.decompressPointData?o.decompressPointData(t,t.pointOffset):o.decompressPointDataBatch(t,1)}catch(u){throw t.pointOffset=c,u instanceof it&&!n?new Error(`Legacy LAZ point exceeded the ${l}-byte streaming lookahead`):u}a++,this.pointIndex++}return t.pointOffset=c,a}decodeIntoPointData(t,e){let n=Math.min(e,this.remainingPointCount);if(n>0&&!cS(this.metadata.pointDataRecordFormat))throw new Error(`TypeScript LAZ decoder does not support direct point-data output for point format ${this.metadata.pointDataRecordFormat}`);let s=Ld(t),i=this.selectOutputMode("point-data",n,s);if(!i)return 0;if(i.decompressPointDataBatch)i.decompressPointDataBatch(t,n);else for(let o=0;o<n;o++)i.decompressPointData(t,t.pointOffset+o);return this.pointIndex+=n,n}selectOutputMode(t,e,n=null){if(e===0)return null;if(this.outputMode&&this.outputMode!==t)throw new Error("Cannot mix raw and point-data decoding in one LAZ chunk cursor");if(t==="point-data"){let s=bb(n);if(this.pointDataSelectionKey!==null&&this.pointDataSelectionKey!==s)throw new Error("Cannot change selected point-data fields in one LAZ chunk cursor");this.pointDataSelectionKey=s}return this.outputMode=t,this.decoder||=aS(this.stream,this.metadata,t,n),this.decoder}};Po=16777216,JA=4294967295,pu=13,QA=1<<pu,tS=2**(31-pu),Ja=15,eS=1<<Ja,fb=2**(31-Ja),rS=[[0,1,2,3,4,5,3,4,4,5,5,5,5,5,5,5],[1,0,1,3,3,3,3,3,3,3,3,3,3,3,3,3],[2,1,2,4,4,4,4,4,4,4,4,3,3,3,3,3],[3,3,4,5,4,4,4,4,4,4,4,4,4,4,4,4],[4,3,4,4,5,4,4,4,4,4,4,4,4,4,4,4],[5,3,4,4,4,5,4,4,4,4,4,4,4,4,4,4],[3,3,4,4,4,4,5,4,4,4,4,4,4,4,4,4],[4,3,4,4,4,4,4,5,4,4,4,4,4,4,4,4],[4,3,4,4,4,4,4,4,5,4,4,4,4,4,4,4],[5,3,4,4,4,4,4,4,4,5,4,4,4,4,4,4],[5,3,4,4,4,4,4,4,4,4,5,4,4,4,4,4],[5,3,3,4,4,4,4,4,4,4,4,5,5,4,4,4],[5,3,3,4,4,4,4,4,4,4,4,5,5,5,4,4],[5,3,3,4,4,4,4,4,4,4,4,4,5,5,5,4],[5,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5],[5,3,3,4,4,4,4,4,4,4,4,4,4,4,5,5]],nS=[[0,1,2,3,4,5,6,7,7,7,7,7,7,7,7,7],[1,0,1,2,3,4,5,6,7,7,7,7,7,7,7,7],[2,1,0,1,2,3,4,5,6,7,7,7,7,7,7,7],[3,2,1,0,1,2,3,4,5,6,7,7,7,7,7,7],[4,3,2,1,0,1,2,3,4,5,6,7,7,7,7,7],[5,4,3,2,1,0,1,2,3,4,5,6,7,7,7,7],[6,5,4,3,2,1,0,1,2,3,4,5,6,7,7,7],[7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,7],[7,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7],[7,7,7,6,5,4,3,2,1,0,1,2,3,4,5,6],[7,7,7,7,6,5,4,3,2,1,0,1,2,3,4,5],[7,7,7,7,7,6,5,4,3,2,1,0,1,2,3,4],[7,7,7,7,7,7,6,5,4,3,2,1,0,1,2,3],[7,7,7,7,7,7,7,6,5,4,3,2,1,0,1,2],[7,7,7,7,7,7,7,7,6,5,4,3,2,1,0,1],[7,7,7,7,7,7,7,7,7,6,5,4,3,2,1,0]],on=500,Vo=-10,tu=511,sS=on-Vo+1,Sd=on-Vo+2,xb=new ArrayBuffer(8),Hd=new Uint8Array(xb),ji=new DataView(xb),iS=16*1024;hb=[[15,14,13,12,11,10,9,8],[14,0,1,3,6,10,10,9],[13,1,2,4,7,11,11,10],[12,3,4,5,8,12,12,11],[11,6,7,8,9,13,13,12],[10,10,11,12,13,14,14,13],[9,10,11,12,13,14,15,14],[8,9,10,11,12,13,14,15]],oS=[[0,1,2,3,4,5,6,7],[1,0,1,2,3,4,5,6],[2,1,0,1,2,3,4,5],[3,2,1,0,1,2,3,4],[4,3,2,1,0,1,2,3],[5,4,3,2,1,0,1,2],[6,5,4,3,2,1,0,1],[7,6,5,4,3,2,1,0]],eu=class{bytes;length;offset=0;discardedByteLength=0;constructor(t){this.bytes=t,this.length=t.byteLength}get byteOffset(){return this.discardedByteLength+this.offset}get availableByteLength(){return this.length-this.offset}get data(){return this.length===this.bytes.byteLength?this.bytes:this.bytes.subarray(0,this.length)}append(t){if(t.byteLength===0)return;let e=this.length+t.byteLength;if(e>this.bytes.byteLength){let n=Math.max(e,Math.max(64,this.bytes.byteLength*2)),s=new Uint8Array(n);s.set(this.bytes.subarray(0,this.length)),this.bytes=s}this.bytes.set(t,this.length),this.length=e}discardConsumedInput(){this.offset!==0&&(this.bytes=this.bytes.slice(this.offset,this.length),this.discardedByteLength+=this.offset,this.length-=this.offset,this.offset=0)}getByte(){if(this.offset>=this.length)throw new it;return this.bytes[this.offset++]}getBytes(t,e,n){if(this.offset+n>this.length)throw new it;t.set(this.bytes.subarray(this.offset,this.offset+n),e),this.offset+=n}consume(t){if(this.offset+t>this.length)throw new it;let e=this.offset;return this.offset+=t,e}getUint32(){let t=this.getByte(),e=this.getByte(),n=this.getByte(),s=this.getByte();return(t|e<<8|n<<16|s<<24>>>0)>>>0}},jt=class{symbols;distribution;symbolCount;decoderTable;totalCount=0;updateCycle;symbolsUntilUpdate;lastSymbol;tableSize=0;tableShift=0;constructor(t){if(t<2||t>2048)throw new Error(`Invalid arithmetic model symbol count ${t}`);if(this.symbols=t,this.lastSymbol=t-1,t>16){let e=3;for(;t>1<<e+2;)e++;this.tableSize=1<<e,this.tableShift=Ja-e,this.decoderTable=new Uint32Array(this.tableSize+2)}else this.decoderTable=null;this.distribution=new Uint32Array(t),this.symbolCount=new Uint32Array(t),this.symbolCount.fill(1),this.updateCycle=t,this.symbolsUntilUpdate=t,this.update(),this.symbolsUntilUpdate=this.updateCycle=t+6>>1}update(){if(this.totalCount+=this.updateCycle,this.totalCount>eS){this.totalCount=0;for(let i=0;i<this.symbols;i++)this.symbolCount[i]=this.symbolCount[i]+1>>1,this.totalCount+=this.symbolCount[i]}let t=0,e=0,n=2147483648/this.totalCount|0;if(this.decoderTable){for(let i=0;i<this.symbols;i++){this.distribution[i]=n*t/fb|0,t+=this.symbolCount[i];let o=this.distribution[i]>>this.tableShift;for(;e<o;)this.decoderTable[++e]=i-1}for(this.decoderTable[0]=0;e<=this.tableSize;)this.decoderTable[++e]=this.symbols-1}else for(let i=0;i<this.symbols;i++)this.distribution[i]=n*t/fb|0,t+=this.symbolCount[i];this.updateCycle=5*this.updateCycle>>2;let s=this.symbols+6<<3;this.updateCycle>s&&(this.updateCycle=s),this.symbolsUntilUpdate=this.updateCycle}},Md=class{updateCycle=4;bitsUntilUpdate=4;bit0Prob=1<<pu-1;bit0Count=1;bitCount=2;update(){this.bitCount+=this.updateCycle,this.bitCount>QA&&(this.bitCount=this.bitCount+1>>1,this.bit0Count=this.bit0Count+1>>1,this.bit0Count===this.bitCount&&this.bitCount++);let t=2147483648/this.bitCount|0;this.bit0Prob=this.bit0Count*t/tS|0,this.updateCycle=5*this.updateCycle>>2,this.updateCycle>64&&(this.updateCycle=64),this.bitsUntilUpdate=this.updateCycle}},ne=class{input;inputBytes=null;inputOffset=0;inputEnd=0;value=0;length=JA;valid=!1;constructor(t=null){this.input=t}initStream(t,e){e?(this.inputBytes=t.data,this.inputOffset=t.consume(e),this.inputEnd=this.inputOffset+e,this.input=null,this.readInitBytes(),this.valid=!0):this.valid=!1}readInitBytes(){if(this.inputBytes){let e=this.inputOffset;if(e+4>this.inputEnd)throw new it;this.value=(this.inputBytes[e]<<24>>>0|this.inputBytes[e+1]<<16|this.inputBytes[e+2]<<8|this.inputBytes[e+3])>>>0,this.inputOffset=e+4;return}let t=this.input;this.value=(t.getByte()<<24>>>0|t.getByte()<<16|t.getByte()<<8|t.getByte())>>>0}decodeBit(t){let e=this.value,n=this.length,s=t.bit0Prob*(n>>>pu),i=e>=s?1:0;return i===0?(this.length=s>>>0,t.bit0Count++):(this.value=e-s>>>0,this.length=n-s>>>0),this.length<Po&&this.renormalize(),--t.bitsUntilUpdate===0&&t.update(),i}decodeSymbol(t){let e,n,s=this.length,i=s,o=this.value,a=t.distribution,c=t.decoderTable;if(c){s>>>=Ja;let l=o/s|0,u=l>>t.tableShift;e=c[u];let f=c[u+1]+1;for(;f>e+1;){let h=e+f>>1;a[h]>l?f=h:e=h}n=a[e]*s,e!==t.lastSymbol&&(i=a[e+1]*s)}else{n=0,e=0,s>>>=Ja;let l=t.symbols,u=l>>1;do{let f=s*a[u];f>o?(l=u,i=f):(e=u,n=f),u=e+l>>1}while(u!==e)}return this.value=o-n>>>0,this.length=i-n>>>0,this.length<Po&&this.renormalize(),t.symbolCount[e]++,--t.symbolsUntilUpdate===0&&t.update(),e}readBits(t){if(t>19){let i=this.readShort();return(this.readBits(t-16)<<16|i)>>>0}let e=this.length>>>t,n=this.value,s=n/e|0;return this.value=n-e*s>>>0,this.length=e>>>0,e<Po&&this.renormalize(),s>>>0}readShort(){let t=this.length>>>16,e=this.value,n=e/t|0;return this.value=e-t*n>>>0,this.length=t>>>0,t<Po&&this.renormalize(),n&65535}readInt(){let t=this.readShort();return(this.readShort()<<16|t)>>>0}readUint64(){let t=this.readInt(),e=this.readInt();return BigInt(e)<<32n|BigInt(t)}renormalize(){let t=this.value,e=this.length;if(this.inputBytes){let n=this.inputBytes,s=this.inputEnd,i=this.inputOffset;do{if(i>=s)throw new it;t=(t<<8|n[i++])>>>0,e=e<<8>>>0}while(e<Po);this.inputOffset=i}else{let n=this.input;do t=(t<<8|n.getByte())>>>0,e=e<<8>>>0;while(e<Po)}this.value=t,this.length=e}},Dd=class{contexts;bitsHigh;corrBits;corrRange;corrMin;mBits=[];mCorrector0=new Md;mCorrector=[];k=0;constructor(t=16,e=1,n=8,s=0){if(this.contexts=e,this.bitsHigh=n,s){for(this.corrBits=0,this.corrRange=s;s;)s>>=1,this.corrBits++;this.corrRange===1<<this.corrBits-1&&this.corrBits--,this.corrMin=-(this.corrRange/2)}else t&&t<32?(this.corrBits=t,this.corrRange=1<<t,this.corrMin=-(this.corrRange/2)):(this.corrBits=32,this.corrRange=0,this.corrMin=-2147483648)}init(){if(!this.mBits.length){for(let t=0;t<this.contexts;t++)this.mBits.push(new jt(this.corrBits+1));for(let t=1;t<=this.corrBits;t++){let e=t<=this.bitsHigh?1<<t:1<<this.bitsHigh;this.mCorrector.push(new jt(e))}}}decompress(t,e,n){let s=t.decodeSymbol(this.mBits[n]);this.k=s;let i;if(s)if(s<32){let a=this.bitsHigh,c=this.mCorrector[s-1];if(s<=a)i=t.decodeSymbol(c);else{let l=s-a;i=t.decodeSymbol(c),i=i<<l|t.readBits(l)}i>=1<<s-1?i+=1:i-=(1<<s)-1}else i=this.corrMin;else i=t.decodeBit(this.mCorrector0);let o=an(e+i);return this.corrRange===0||(o<0?o=an(o+this.corrRange):o>=this.corrRange&&(o=an(o-this.corrRange))),o}},Go=class{value0=0;value1=0;value2=0;value3=0;value4=0;high=!0;add(t){this.high?t<this.value2?(this.value4=this.value3,this.value3=this.value2,t<this.value0?(this.value2=this.value1,this.value1=this.value0,this.value0=t):t<this.value1?(this.value2=this.value1,this.value1=t):this.value2=t):(t<this.value3?(this.value4=this.value3,this.value3=t):this.value4=t,this.high=!1):this.value2<t?(this.value0=this.value1,this.value1=this.value2,this.value4<t?(this.value2=this.value3,this.value3=this.value4,this.value4=t):this.value3<t?(this.value2=this.value3,this.value3=t):this.value2=t):(this.value1<t?(this.value0=this.value1,this.value1=t):this.value0=t,this.high=!0)}get(){return this.value2}};Zs=class{itemVersion;stream;decoder;changedValuesModel=new jt(64);bitByteModel=ge(256,256);classificationModel=ge(256,256);scanAngleRankModel=ge(2,256);userDataModel=ge(256,256);intensity=Bt(16,4);pointSourceId=Bt(16,1);dx=Bt(32,2);dy=Bt(32,22);z=Bt(32,20);lastIntensity=new Array(16).fill(0);lastHeight=new Array(8).fill(0);lastXDiffMedian=Array.from({length:16},()=>new Go);lastYDiffMedian=Array.from({length:16},()=>new Go);haveLast=!1;last=pb();firstPoint=pb();legacyXDiffs=[0,0,0];legacyYDiffs=[0,0,0];legacyDifferenceIndex=0;legacyScanAngle=null;constructor(t,e=2){this.itemVersion=e,this.stream=t,this.decoder=new ne(t),e===1&&(this.legacyScanAngle=Bt(8,2),this.dx=Bt(32,1),this.dy=Bt(32,20),this.intensity=Bt(16,1))}getDecoder(){return this.decoder}decompress(t,e){let n=this.decompressPoint();return dS(n,t,e),e+20}decompressPoint(){if(!this.haveLast)return this.haveLast=!0,fS(this.last,this.stream),hS(this.firstPoint,this.last),this.itemVersion===2&&(this.last.intensity=0),this.firstPoint;if(this.itemVersion===1)return this.decompressLegacyPoint();let t=this.decoder.decodeSymbol(this.changedValuesModel);if(t){t&32&&(this.last.bitByte=this.decoder.decodeSymbol(this.bitByteModel[this.last.bitByte]));let h=mb(this.last),m=yb(this.last),y=hb[m][h];if(t&16?(this.last.intensity=this.intensity.decompress(this.decoder,this.lastIntensity[y],y<3?y:3)&65535,this.lastIntensity[y]=this.last.intensity):this.last.intensity=this.lastIntensity[y],t&8&&(this.last.classification=this.decoder.decodeSymbol(this.classificationModel[this.last.classification])),t&4){let g=this.decoder.decodeSymbol(this.scanAngleRankModel[pS(this.last)]);this.last.scanAngleRank=Wd(this.last.scanAngleRank+g)}t&2&&(this.last.userData=this.decoder.decodeSymbol(this.userDataModel[this.last.userData])),t&1&&(this.last.pointSourceId=this.pointSourceId.decompress(this.decoder,this.last.pointSourceId,0)&65535)}let e=mb(this.last),n=yb(this.last),s=hb[n][e],i=oS[n][e],o=this.lastXDiffMedian[s].get(),a=this.dx.decompress(this.decoder,o,n===1?1:0);this.last.x=an(this.last.x+a),this.lastXDiffMedian[s].add(a);let c=this.lastYDiffMedian[s].get(),l=Math.min(this.dx.k,20)&-2,u=this.dy.decompress(this.decoder,c,(n===1?1:0)+l);this.last.y=an(this.last.y+u),this.lastYDiffMedian[s].add(u);let f=Math.min(this.dx.k+this.dy.k>>1,18)&-2;return this.last.z=this.z.decompress(this.decoder,this.lastHeight[i],(n===1?1:0)+f),this.lastHeight[i]=this.last.z,this.last}decompressLegacyPoint(){let t=this.dx.decompress(this.decoder,db(this.legacyXDiffs),0);this.last.x=an(this.last.x+t);let e=this.dx.k,n=this.dy.decompress(this.decoder,db(this.legacyYDiffs),Math.min(e,19));this.last.y=an(this.last.y+n),e=e+this.dy.k>>1,this.last.z=this.z.decompress(this.decoder,this.last.z,Math.min(e,19));let s=this.decoder.decodeSymbol(this.changedValuesModel);return s&32&&(this.last.intensity=this.intensity.decompress(this.decoder,this.last.intensity,0)&65535),s&16&&(this.last.bitByte=this.decoder.decodeSymbol(this.bitByteModel[this.last.bitByte])),s&8&&(this.last.classification=this.decoder.decodeSymbol(this.classificationModel[this.last.classification])),s&4&&(this.last.scanAngleRank=Wd(this.legacyScanAngle.decompress(this.decoder,this.last.scanAngleRank&255,e<3?1:0))),s&2&&(this.last.userData=this.decoder.decodeSymbol(this.userDataModel[this.last.userData])),s&1&&(this.last.pointSourceId=this.pointSourceId.decompress(this.decoder,this.last.pointSourceId,0)&65535),this.legacyXDiffs[this.legacyDifferenceIndex]=t,this.legacyYDiffs[this.legacyDifferenceIndex]=n,this.legacyDifferenceIndex=(this.legacyDifferenceIndex+1)%3,this.last}readFirstMetadata(){this.decoder.readInitBytes()}},Qa=class{itemVersion;stream;decoder;haveLast=!1;lastRed=0;lastGreen=0;lastBlue=0;usedModel=new jt(128);diffModel=ge(6,256);legacyRgb=null;constructor(t,e,n=2){this.itemVersion=n,this.stream=t,this.decoder=e,n===1&&(this.usedModel=new jt(64),this.legacyRgb=Bt(8,6))}decompress(t,e){return this.decompressRgb(),ar(this.lastRed,t,e),ar(this.lastGreen,t,e+2),ar(this.lastBlue,t,e+4),e+6}decompressRgb(){if(!this.haveLast){this.haveLast=!0,this.lastRed=Ys(this.stream),this.lastGreen=Ys(this.stream),this.lastBlue=Ys(this.stream);return}let t=this.decoder.decodeSymbol(this.usedModel);if(this.itemVersion===1){this.lastRed=this.decodeLegacyColor(this.lastRed,0,t),this.lastGreen=this.decodeLegacyColor(this.lastGreen,1,t),this.lastBlue=this.decodeLegacyColor(this.lastBlue,2,t);return}let e=0,n=0,s=0;if(t&1?e=this.decoder.decodeSymbol(this.diffModel[0])+(this.lastRed&255)&255:e=this.lastRed&255,t&2?e|=(this.decoder.decodeSymbol(this.diffModel[1])+(this.lastRed>>8)&255)<<8:e|=this.lastRed&65280,t&64){let i=(e&255)-(this.lastRed&255);t&4?n=this.decoder.decodeSymbol(this.diffModel[2])+$s(i+(this.lastGreen&255))&255:n=this.lastGreen&255,t&16?(i=(i+((n&255)-(this.lastGreen&255)))/2|0,s=this.decoder.decodeSymbol(this.diffModel[4])+$s(i+(this.lastBlue&255))&255):s=this.lastBlue&255,i=(e>>8)-(this.lastRed>>8),t&8?n|=(this.decoder.decodeSymbol(this.diffModel[3])+$s(i+(this.lastGreen>>8))&255)<<8:n|=this.lastGreen&65280,t&32?(i=(i+(n>>8)-(this.lastGreen>>8))/2|0,s|=(this.decoder.decodeSymbol(this.diffModel[5])+$s(i+(this.lastBlue>>8))&255)<<8):s|=this.lastBlue&65280}else n=e,s=e;this.lastRed=e,this.lastGreen=n,this.lastBlue=s}decodeLegacyColor(t,e,n){let s=0;for(let i=0;i<2;i++){let o=e*2+i,a=t>>i*8&255,c=n&1<<o?this.legacyRgb.decompress(this.decoder,a,o):a;s|=c<<i*8}return s}get decodedRed(){return this.lastRed}get decodedGreen(){return this.lastGreen}get decodedBlue(){return this.lastBlue}},Hs=class{itemVersion;stream;decoder;count;haveLast=!1;last;models;legacyBytes;constructor(t,e,n,s=2){this.itemVersion=s,this.stream=t,this.decoder=e,this.count=n,this.last=new Uint8Array(n),this.models=ge(n,256),this.legacyBytes=s===1?Bt(8,n):null}get byteCount(){return this.count}decompress(t,e){return this.decompressToTarget(t,e),e+this.count}decompressToTarget(t,e=0){if(this.count!==0){if(!this.haveLast){this.stream.getBytes(this.last,0,this.count),t?.set(this.last,e),this.haveLast=!0;return}for(let n=0;n<this.count;n++){let s=this.itemVersion===1?this.legacyBytes.decompress(this.decoder,this.last[n],n):this.last[n]+this.decoder.decodeSymbol(this.models[n])&255;t&&(t[e+n]=s),this.last[n]=s}}}};(function(r){r[r.Full=0]="Full",r[r.PointData=1]="PointData"})(Nt||(Nt={}));Cd=class{changedValuesModel=ge(8,128);scannerChannelModel=new jt(3);returnNumberGpsSameModel=new jt(13);numberReturnsModel=ge(16,16);returnNumberModel=ge(16,16);classModel=[];flagModel=[];userDataModel=[];gpsTimeMultiModel;gpsTime0DiffModel;dx=Bt(32,2);dy=Bt(32,22);z=Bt(32,20);intensity=null;scanAngle;pointSourceId;gpsTime;haveLast=!1;last=uS();lastIntensity=[];lastZ=new Array(8).fill(0);lastXDiffMedian=Array.from({length:12},()=>new Go);lastYDiffMedian=Array.from({length:12},()=>new Go);lastGpsSequence=0;nextGpsSequence=0;lastGpsTime=[];lastGpsTimeDiff=[];multiExtremeCounter=[];gpsTimeChange=!1;constructor(t,e){(t===Nt.Full||e?.classification)&&(this.classModel=ge(64,256)),(t===Nt.Full||e?.intensity)&&(this.intensity=Bt(16,4),this.lastIntensity=new Array(8).fill(0)),(t===Nt.Full||e?.userData)&&(this.userDataModel=ge(64,256)),(t===Nt.Full||e?.scanAngle)&&(this.scanAngle=Bt(16,2)),(t===Nt.Full||e?.pointSourceId)&&(this.pointSourceId=Bt(16,1)),(t===Nt.Full||e?.flags)&&(this.flagModel=ge(64,64)),(t===Nt.Full||e?.gpsTime)&&(this.gpsTimeMultiModel=new jt(515),this.gpsTime0DiffModel=new jt(5),this.gpsTime=Bt(32,9),this.lastGpsTime=new Array(4).fill(0),this.lastGpsTimeDiff=new Array(4).fill(0),this.multiExtremeCounter=new Array(4).fill(0))}},qi=class{stream;contexts;activeContext=null;decompressOptionalFields;xy=new ne;z=new ne;classification;flags;intensity;scanAngle;userData;pointSourceId;gpsTime;sizes=[];currentScannerChannel=0;itemContextChannel=0;itemVersion;constructor(t,e=Nt.Full,n=3,s=null){this.stream=t,this.itemVersion=n,this.contexts=Array.from({length:4},()=>new Cd(e,s)),this.decompressOptionalFields=e===Nt.Full,this.classification=this.decompressOptionalFields||s?.classification?new ne:null,this.flags=this.decompressOptionalFields||s?.flags?new ne:null,this.intensity=this.decompressOptionalFields||s?.intensity?new ne:null,this.scanAngle=this.decompressOptionalFields||s?.scanAngle?new ne:null,this.userData=this.decompressOptionalFields||s?.userData?new ne:null,this.pointSourceId=this.decompressOptionalFields||s?.pointSourceId?new ne:null,this.gpsTime=this.decompressOptionalFields||s?.gpsTime?new ne:null}readSizes(){this.sizes=[];for(let t=0;t<9;t++)this.sizes.push(this.stream.getUint32())}readData(){let t=0;this.xy.initStream(this.stream,this.sizes[t++]),this.z.initStream(this.stream,this.sizes[t++]),this.initializeOptionalStream(this.classification,this.sizes[t++]),this.initializeOptionalStream(this.flags,this.sizes[t++]),this.initializeOptionalStream(this.intensity,this.sizes[t++]),this.initializeOptionalStream(this.scanAngle,this.sizes[t++]),this.initializeOptionalStream(this.userData,this.sizes[t++]),this.initializeOptionalStream(this.pointSourceId,this.sizes[t++]),this.initializeOptionalStream(this.gpsTime,this.sizes[t++])}initializeOptionalStream(t,e){t?t.initStream(this.stream,e):this.stream.consume(e)}decompress(t,e){let n=this.decompressPoint(t,e);return gS(n,t,e),e+30}decompressPoint(t,e=0){let n=this.gpsTime!==null;if(!this.activeContext){let rt=this.contexts[0].last;t?(this.stream.getBytes(t,e,30),mS(rt,t,e)):yS(rt,this.stream),this.currentScannerChannel=bS(rt),this.itemContextChannel=this.currentScannerChannel;let tt=this.contexts[this.currentScannerChannel];return tt.last!==rt&&gb(tt.last,rt),tt.haveLast=!0,n&&(tt.lastGpsTime[0]=tt.last.gpsTime),this.activeContext=tt,tt.lastZ.fill(tt.last.z),tt.lastIntensity.length&&tt.lastIntensity.fill(tt.last.intensity),tt.last}let s=this.activeContext,i=s.last.returns,o=i&15,a=(o===1?1:0)|(o>=i>>4?1:0)<<1|(s.gpsTimeChange?1:0)<<2,c=this.xy.decodeSymbol(s.changedValuesModel[a]),l=!!(c>>6&1),u=!!(c>>5&1),f=!!(c>>4&1),h=!!(c>>3&1),m=!!(c>>2&1),y=!!(c>>1&1),g=!!(c&1),x=g&&!y,I=y&&!g,q=g&&y;this.itemContextChannel=0;let T=this.currentScannerChannel,b=s;if(l){let rt=this.xy.decodeSymbol(s.scannerChannelModel);T=(T+rt+1)%4,b=this.contexts[T],this.activeContext=b,this.itemContextChannel=T}this.currentScannerChannel=T,this.itemVersion>=4&&(this.itemContextChannel=T),b.haveLast||(b.haveLast=!0,gb(b.last,s.last),b.lastZ.fill(s.last.z),b.lastIntensity.length&&b.lastIntensity.fill(s.last.intensity),n&&(b.lastGpsTime[0]=s.last.gpsTime)),wS(b.last,T);let C=b.last.returns>>4,_=b.last.returns&15;m&&(C=this.xy.decodeSymbol(b.numberReturnsModel[C])),x?_=(_+1)%16:I?_=(_+15)%16:q&&(_=f?this.xy.decodeSymbol(b.returnNumberModel[_]):(_+this.xy.decodeSymbol(b.returnNumberGpsSameModel)+2)%16),b.last.returns=C<<4|_;let $=rS[C][_]<<1|(f?1:0),X=b.lastXDiffMedian[$].get(),ft=b.dx.decompress(this.xy,X,C===1?1:0);b.last.x=an(b.last.x+ft),b.lastXDiffMedian[$].add(ft);let dt=Math.min(b.dx.k,20)&-2,It=b.lastYDiffMedian[$].get(),se=b.dy.decompress(this.xy,It,(C===1?1:0)|dt);if(b.last.y=an(b.last.y+se),b.lastYDiffMedian[$].add(se),this.z.valid){let rt=Math.min(b.dx.k+b.dy.k>>1,18)&-2,tt=nS[C][_],Ye=b.z.decompress(this.z,b.lastZ[tt],(C===1?1:0)|rt);b.last.z=Ye,b.lastZ[tt]=Ye}if(this.classification?.valid){let rt=(_===1&&_>=C?1:0)|(b.last.classification&31)<<1;b.last.classification=this.classification.decodeSymbol(b.classModel[rt])}if(this.flags?.valid){let rt=SS(b.last),tt=this.flags.decodeSymbol(b.flagModel[rt]);AS(b.last,tt>>5&1),vS(b.last,tt>>4&1),xS(b.last,tt&15)}if(this.intensity?.valid){let rt=(f?1:0)|(_>=C?1:0)<<1|(_===1?1:0)<<2,tt=b.intensity.decompress(this.intensity,b.lastIntensity[rt],rt>>1);b.lastIntensity[rt]=tt&65535,b.last.intensity=tt&65535}if(h&&this.scanAngle&&(b.last.scanAngle=Xd(b.scanAngle.decompress(this.scanAngle,b.last.scanAngle,f?1:0))),this.userData?.valid){let rt=b.last.userData>>2;b.last.userData=this.userData.decodeSymbol(b.userDataModel[rt])}return u&&this.pointSourceId&&(b.last.pointSourceId=b.pointSourceId.decompress(this.pointSourceId,b.last.pointSourceId,0)&65535),f&&this.gpsTime&&this.decodeGpsTime(b),b.gpsTimeChange=f,b.last}decodeGpsTime(t){let e=this.gpsTime;for(;;){if(t.lastGpsTimeDiff[t.lastGpsSequence]===0){let n=e.decodeSymbol(t.gpsTime0DiffModel);if(n===0){let s=t.gpsTime.decompress(e,0,0);t.lastGpsTimeDiff[t.lastGpsSequence]=s,t.lastGpsTime[t.lastGpsSequence]=qs(t.lastGpsTime[t.lastGpsSequence],s),t.multiExtremeCounter[t.lastGpsSequence]=0}else if(n===1){t.nextGpsSequence=t.nextGpsSequence+1&3;let s=uu(t.lastGpsTime[t.lastGpsSequence]),i=t.gpsTime.decompress(e,Number(s>>32n)|0,8),o=e.readInt();t.lastGpsTime[t.nextGpsSequence]=zo(BigInt(i>>>0)<<32n|BigInt(o)),t.lastGpsSequence=t.nextGpsSequence,t.lastGpsTimeDiff[t.lastGpsSequence]=0,t.multiExtremeCounter[t.lastGpsSequence]=0}else{t.lastGpsSequence=t.lastGpsSequence+n-1&3;continue}}else{let n=e.decodeSymbol(t.gpsTimeMultiModel),s=0;if(n===1){let i=t.gpsTime.decompress(e,t.lastGpsTimeDiff[t.lastGpsSequence],1);t.lastGpsTime[t.lastGpsSequence]=qs(t.lastGpsTime[t.lastGpsSequence],i),t.multiExtremeCounter[t.lastGpsSequence]=0}else if(n<tu){if(n===0)s=t.gpsTime.decompress(e,0,7),t.multiExtremeCounter[t.lastGpsSequence]++,t.multiExtremeCounter[t.lastGpsSequence]>3&&(t.multiExtremeCounter[t.lastGpsSequence]=0,t.lastGpsTimeDiff[t.lastGpsSequence]=s);else if(n<on){let i=n<10?2:3;s=t.gpsTime.decompress(e,n*t.lastGpsTimeDiff[t.lastGpsSequence],i)}else n===on?(s=t.gpsTime.decompress(e,on*t.lastGpsTimeDiff[t.lastGpsSequence],4),t.multiExtremeCounter[t.lastGpsSequence]++,t.multiExtremeCounter[t.lastGpsSequence]>3&&(t.multiExtremeCounter[t.lastGpsSequence]=0,t.lastGpsTimeDiff[t.lastGpsSequence]=s)):(n=on-n,n>Vo?s=t.gpsTime.decompress(e,n*t.lastGpsTimeDiff[t.lastGpsSequence],5):(s=t.gpsTime.decompress(e,Vo*t.lastGpsTimeDiff[t.lastGpsSequence],6),t.multiExtremeCounter[t.lastGpsSequence]++,t.multiExtremeCounter[t.lastGpsSequence]>3&&(t.multiExtremeCounter[t.lastGpsSequence]=0,t.lastGpsTimeDiff[t.lastGpsSequence]=s)));t.lastGpsTime[t.lastGpsSequence]=qs(t.lastGpsTime[t.lastGpsSequence],s)}else if(n===tu){t.nextGpsSequence=t.nextGpsSequence+1&3;let i=uu(t.lastGpsTime[t.lastGpsSequence]),o=t.gpsTime.decompress(e,Number(i>>32n)|0,8),a=e.readInt();t.lastGpsTime[t.nextGpsSequence]=zo(BigInt(o>>>0)<<32n|BigInt(a)),t.lastGpsSequence=t.nextGpsSequence,t.lastGpsTimeDiff[t.lastGpsSequence]=0,t.multiExtremeCounter[t.lastGpsSequence]=0}else if(n>=tu){t.lastGpsSequence=t.lastGpsSequence+n-tu&3;continue}}t.last.gpsTime=t.lastGpsTime[t.lastGpsSequence];break}}},Fd=class{haveLast=!1;lastRed=0;lastGreen=0;lastBlue=0;usedModel=new jt(128);diffModel=ge(6,256)},tc=class{stream;contexts=Array.from({length:4},()=>new Fd);activeContext=null;lastChannel=-1;rgbCount=0;rgb=new ne;decodedRed=0;decodedGreen=0;decodedBlue=0;itemVersion;constructor(t,e=3){this.stream=t,this.itemVersion=e}readSizes(){this.rgbCount=this.stream.getUint32()}readData(){this.rgb.initStream(this.stream,this.rgbCount)}decompress(t,e,n){return this.decompressRgb(n),ar(this.decodedRed,t,e),ar(this.decodedGreen,t,e+2),ar(this.decodedBlue,t,e+4),e+6}decompressRgb(t){if(this.lastChannel===-1){this.decodedRed=this.stream.getByte()|this.stream.getByte()<<8,this.decodedGreen=this.stream.getByte()|this.stream.getByte()<<8,this.decodedBlue=this.stream.getByte()|this.stream.getByte()<<8;let c=this.contexts[t];c.lastRed=this.decodedRed,c.lastGreen=this.decodedGreen,c.lastBlue=this.decodedBlue,c.haveLast=!0,this.lastChannel=t,this.activeContext=c;return}if(this.rgbCount===0){let c=this.activeContext;this.decodedRed=c.lastRed,this.decodedGreen=c.lastGreen,this.decodedBlue=c.lastBlue;return}let e=this.activeContext,n=e;if(t!==this.lastChannel){let c=e;e=this.contexts[t],n=c,this.lastChannel=t,e.haveLast||(e.haveLast=!0,e.lastRed=c.lastRed,e.lastGreen=c.lastGreen,e.lastBlue=c.lastBlue,n=e),this.itemVersion>=4&&(n=e),this.activeContext=e}let s=this.rgb.decodeSymbol(e.usedModel),i=0,o=0,a=0;if(s&1?i=this.rgb.decodeSymbol(e.diffModel[0])+(n.lastRed&255)&255:i=n.lastRed&255,s&2){let c=this.rgb.decodeSymbol(e.diffModel[1]);i|=(c+(n.lastRed>>8)&255)<<8}else i|=n.lastRed&65280;if(s&64){let c=(i&255)-(n.lastRed&255);if(s&4?o=this.rgb.decodeSymbol(e.diffModel[2])+$s(c+(n.lastGreen&255))&255:o=n.lastGreen&255,s&16){let l=this.rgb.decodeSymbol(e.diffModel[4]);c=(c+((o&255)-(n.lastGreen&255)))/2|0,a=l+$s(c+(n.lastBlue&255))&255}else a=n.lastBlue&255;if(c=(i>>8)-(n.lastRed>>8),s&8){let l=this.rgb.decodeSymbol(e.diffModel[3]);o|=(l+$s(c+(n.lastGreen>>8))&255)<<8}else o|=n.lastGreen&65280;if(s&32){let l=this.rgb.decodeSymbol(e.diffModel[5]);c=(c+(o>>8)-(n.lastGreen>>8))/2|0,a|=(l+$s(c+(n.lastBlue>>8))&255)<<8}else a|=n.lastBlue&65280}else o=i,a=i;n.lastRed=i,n.lastGreen=o,n.lastBlue=a,this.decodedRed=i,this.decodedGreen=o,this.decodedBlue=a}},Od=class{haveLast=!1;lastValue=0;usedModel=new jt(4);diffModel=ge(2,256)},ru=class{stream;contexts=Array.from({length:4},()=>new Od);lastChannel=-1;nirCount=0;nir=new ne;scratch=new Uint8Array(2);decodedNir=0;itemVersion;constructor(t,e=3){this.stream=t,this.itemVersion=e}readSizes(){this.nirCount=this.stream.getUint32()}readData(){this.nir.initStream(this.stream,this.nirCount)}decompress(t,e,n){if(this.lastChannel===-1){this.stream.getBytes(t,e,2);let c=this.contexts[n];return c.lastValue=au(t,e),c.haveLast=!0,this.lastChannel=n,this.decodedNir=c.lastValue,e+2}if(this.nirCount===0)return ar(this.contexts[this.lastChannel].lastValue,t,e),this.decodedNir=this.contexts[this.lastChannel].lastValue,e+2;let s=this.contexts[n],i=this.contexts[this.lastChannel];n!==this.lastChannel&&(this.lastChannel=n,s.haveLast||(s.haveLast=!0,s.lastValue=i.lastValue,i=s),this.itemVersion>=4&&(i=s));let o=this.nir.decodeSymbol(s.usedModel),a=o&1?this.nir.decodeSymbol(s.diffModel[0])+(i.lastValue&255)&255:i.lastValue&255;return a|=o&2?(this.nir.decodeSymbol(s.diffModel[1])+(i.lastValue>>8)&255)<<8:i.lastValue&65280,i.lastValue=a,this.decodedNir=a,ar(a,t,e),e+2}decompressNir(t){return this.decompress(this.scratch,0,t),this.decodedNir}},nu=class{haveLast=!1;descriptorIndex=0;offset=0n;packetSize=0;returnPointBits=0;xBits=0;yBits=0;zBits=0;lastOffsetDifference=0;lastOffsetDifferenceSymbol=0;descriptorModel=new jt(256);offsetDifferenceModels=ge(4,4);offsetDifferenceDecompressor=Bt(32,1);packetSizeDecompressor=Bt(32,1);returnPointDecompressor=Bt(32,1);vectorDecompressor=Bt(32,3)},su=class{stream;contexts=Array.from({length:4},()=>new nu);lastChannel=-1;wavePacketByteCount=0;decoder=new ne;itemVersion;constructor(t,e){this.stream=t,this.itemVersion=e}readSizes(){this.wavePacketByteCount=this.stream.getUint32()}readData(){this.decoder.initStream(this.stream,this.wavePacketByteCount)}decompress(t,e,n){if(this.lastChannel===-1){this.stream.getBytes(t,e,29);let a=this.contexts[n];return this.readContext(a,t,e),a.haveLast=!0,this.lastChannel=n,e+29}let s=this.contexts[this.lastChannel],i=this.contexts[n],o=i;return n!==this.lastChannel&&(o=s,i.haveLast?this.itemVersion>=4&&(o=i):(this.copyLastWavePacket(i,s),i.haveLast=!0,o=i),this.lastChannel=n),this.wavePacketByteCount&&this.decodeContext(i,o),this.writeContext(o,t,e),e+29}decompressToTarget(t,e,n){this.decompress(t,e,n)}decodeContext(t,e){e.descriptorIndex=this.decoder.decodeSymbol(t.descriptorModel);let n=this.decoder.decodeSymbol(t.offsetDifferenceModels[t.lastOffsetDifferenceSymbol]);switch(t.lastOffsetDifferenceSymbol=n,n){case 0:break;case 1:e.offset=BigInt.asUintN(64,e.offset+BigInt(e.packetSize));break;case 2:t.lastOffsetDifference=t.offsetDifferenceDecompressor.decompress(this.decoder,t.lastOffsetDifference,0),e.offset=BigInt.asUintN(64,e.offset+BigInt(t.lastOffsetDifference));break;default:e.offset=this.decoder.readUint64();break}e.packetSize=t.packetSizeDecompressor.decompress(this.decoder,e.packetSize|0,0)>>>0,e.returnPointBits=t.returnPointDecompressor.decompress(this.decoder,e.returnPointBits,0),e.xBits=t.vectorDecompressor.decompress(this.decoder,e.xBits,0),e.yBits=t.vectorDecompressor.decompress(this.decoder,e.yBits,1),e.zBits=t.vectorDecompressor.decompress(this.decoder,e.zBits,2)}copyLastWavePacket(t,e){t.descriptorIndex=e.descriptorIndex,t.offset=e.offset,t.packetSize=e.packetSize,t.returnPointBits=e.returnPointBits,t.xBits=e.xBits,t.yBits=e.yBits,t.zBits=e.zBits}readContext(t,e,n){t.descriptorIndex=e[n],t.offset=vb(e,n+1),t.packetSize=cu(e,n+9),t.returnPointBits=Gr(e,n+13),t.xBits=Gr(e,n+17),t.yBits=Gr(e,n+21),t.zBits=Gr(e,n+25)}writeContext(t,e,n){e[n]=t.descriptorIndex,Ab(t.offset,e,n+1),lu(t.packetSize,e,n+9),Ue(t.returnPointBits,e,n+13),Ue(t.xBits,e,n+17),Ue(t.yBits,e,n+21),Ue(t.zBits,e,n+25)}},Ed=class{haveLast=!1;last;byteModel;constructor(t){this.last=new Uint8Array(t),this.byteModel=ge(t,256)}},$i=class{stream;count;contexts;lastChannel=-1;byteCount;byteDecoder;itemVersion;constructor(t,e,n=3){this.stream=t,this.count=e,this.itemVersion=n,this.contexts=Array.from({length:4},()=>new Ed(e)),this.byteCount=new Array(e).fill(0),this.byteDecoder=Array.from({length:e},()=>new ne)}readSizes(){for(let t=0;t<this.count;t++)this.byteCount[t]=this.stream.getUint32()}readData(){for(let t=0;t<this.count;t++)this.byteDecoder[t].initStream(this.stream,this.byteCount[t])}decompress(t,e,n){if(this.lastChannel===-1){this.stream.getBytes(t,e,this.count);let o=this.contexts[n];return o.last.set(t.subarray(e,e+this.count)),o.haveLast=!0,this.lastChannel=n,e+this.count}let s=this.contexts[n],i=this.contexts[this.lastChannel].last;n!==this.lastChannel&&(this.lastChannel=n,s.haveLast||(s.haveLast=!0,s.last.set(i),i=this.contexts[this.lastChannel].last),this.itemVersion>=4&&(i=s.last));for(let o=0;o<this.count;o++)if(this.byteCount[o]){let a=i[o]+this.byteDecoder[o].decodeSymbol(s.byteModel[o])&255;t[e+o]=a,i[o]=a}else t[e+o]=i[o];return e+this.count}};Ud=class{point;bytes;first=!0;constructor(t,e,n){this.point=new Zs(t,n.point10ItemVersion??2),this.bytes=new Hs(t,this.point.getDecoder(),e,n.byteItemVersion??2)}decompress(t,e){return e=this.point.decompress(t,e),e=this.bytes.decompress(t,e),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint();this.bytes.decompressToTarget(t.extraBytes,e*this.bytes.byteCount),this.readFirstMetadata(),Rn(n,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),Wi(n,t,e)}decompressPointDataBatch(t,e){for(let n=0;n<e;n++)this.decompressPointData(t,t.pointOffset+n)}readFirstMetadata(){this.first&&(this.point.readFirstMetadata(),this.first=!1)}},jo=class{itemVersion;stream;decoder;gpsTimeMultiModel=new jt(516);gpsTime0DiffModel=new jt(6);gpsTime=Bt(32,9);lastGpsSequence=0;nextGpsSequence=0;lastGpsTime=new Array(4).fill(0);lastGpsTimeDiff=new Array(4).fill(0);multiExtremeCounter=new Array(4).fill(0);haveLast=!1;constructor(t,e,n=2){this.itemVersion=n,this.stream=t,this.decoder=e,n===1&&(this.gpsTimeMultiModel=new jt(512),this.gpsTime0DiffModel=new jt(3),this.gpsTime=Bt(32,6))}decompress(t,e){return Ib(this.decompressGpsTime(),t,e),e+8}decompressGpsTime(){return this.haveLast?(this.itemVersion===1?this.decodeLegacyGpsTime():this.decodeGpsTime(),this.lastGpsTime[this.lastGpsSequence]):(this.lastGpsTime[0]=Sb(this.stream),this.haveLast=!0,this.lastGpsTime[0])}decodeLegacyGpsTime(){let t=this.lastGpsTimeDiff[0];if(t===0){let o=this.decoder.decodeSymbol(this.gpsTime0DiffModel);if(o===1){let a=this.gpsTime.decompress(this.decoder,0,0);this.lastGpsTimeDiff[0]=a,this.lastGpsTime[0]=qs(this.lastGpsTime[0],a)}else o===2&&(this.lastGpsTime[0]=zo(this.decoder.readUint64()));return}let e=this.decoder.decodeSymbol(this.gpsTimeMultiModel);if(e===511)return;if(e===510){this.lastGpsTime[0]=zo(this.decoder.readUint64());return}let n=e===1?1:e===0?2:e<10?3:e<50?4:5,s=e===0?Math.trunc(t/4):an(e*t),i=this.gpsTime.decompress(this.decoder,s,n);e===1?(this.lastGpsTimeDiff[0]=i,this.multiExtremeCounter[0]=0):(e===0||e===509)&&++this.multiExtremeCounter[0]>3&&(this.lastGpsTimeDiff[0]=i,this.multiExtremeCounter[0]=0),this.lastGpsTime[0]=qs(this.lastGpsTime[0],i)}decodeGpsTime(){for(;;){if(this.lastGpsTimeDiff[this.lastGpsSequence]===0){let n=this.decoder.decodeSymbol(this.gpsTime0DiffModel);if(n===0)break;if(n===1){let s=this.gpsTime.decompress(this.decoder,0,0);this.lastGpsTimeDiff[this.lastGpsSequence]=s,this.lastGpsTime[this.lastGpsSequence]=qs(this.lastGpsTime[this.lastGpsSequence],s),this.multiExtremeCounter[this.lastGpsSequence]=0;break}if(n===2){this.readFullGpsTime();break}this.lastGpsSequence=this.lastGpsSequence+n-2&3;continue}let t=this.decoder.decodeSymbol(this.gpsTimeMultiModel),e=0;if(t===1){let n=this.gpsTime.decompress(this.decoder,this.lastGpsTimeDiff[this.lastGpsSequence],1);this.lastGpsTime[this.lastGpsSequence]=qs(this.lastGpsTime[this.lastGpsSequence],n),this.multiExtremeCounter[this.lastGpsSequence]=0}else if(t<sS){if(t===0)e=this.gpsTime.decompress(this.decoder,0,7),this.multiExtremeCounter[this.lastGpsSequence]++,this.multiExtremeCounter[this.lastGpsSequence]>3&&(this.multiExtremeCounter[this.lastGpsSequence]=0,this.lastGpsTimeDiff[this.lastGpsSequence]=e);else if(t<on){let n=t<10?2:3;e=this.gpsTime.decompress(this.decoder,t*this.lastGpsTimeDiff[this.lastGpsSequence],n)}else t===on?(e=this.gpsTime.decompress(this.decoder,on*this.lastGpsTimeDiff[this.lastGpsSequence],4),this.multiExtremeCounter[this.lastGpsSequence]++,this.multiExtremeCounter[this.lastGpsSequence]>3&&(this.multiExtremeCounter[this.lastGpsSequence]=0,this.lastGpsTimeDiff[this.lastGpsSequence]=e)):(t=on-t,t>Vo?e=this.gpsTime.decompress(this.decoder,t*this.lastGpsTimeDiff[this.lastGpsSequence],5):(e=this.gpsTime.decompress(this.decoder,Vo*this.lastGpsTimeDiff[this.lastGpsSequence],6),this.multiExtremeCounter[this.lastGpsSequence]++,this.multiExtremeCounter[this.lastGpsSequence]>3&&(this.multiExtremeCounter[this.lastGpsSequence]=0,this.lastGpsTimeDiff[this.lastGpsSequence]=e)));this.lastGpsTime[this.lastGpsSequence]=qs(this.lastGpsTime[this.lastGpsSequence],e)}else if(t===Sd)this.readFullGpsTime();else if(t>=Sd){this.lastGpsSequence=this.lastGpsSequence+t-Sd&3;continue}break}}readFullGpsTime(){this.nextGpsSequence=this.nextGpsSequence+1&3;let t=uu(this.lastGpsTime[this.lastGpsSequence]),e=this.gpsTime.decompress(this.decoder,Number(t>>32n)|0,8),n=this.decoder.readInt();this.lastGpsTime[this.nextGpsSequence]=zo(BigInt(e>>>0)<<32n|BigInt(n)),this.lastGpsSequence=this.nextGpsSequence,this.lastGpsTimeDiff[this.lastGpsSequence]=0,this.multiExtremeCounter[this.lastGpsSequence]=0}},Nd=class{point;gpsTime;bytes;first=!0;constructor(t,e,n){this.point=new Zs(t,n.point10ItemVersion??2);let s=this.point.getDecoder();this.gpsTime=new jo(t,s,n.gpsTime11ItemVersion??2),this.bytes=new Hs(t,s,e,n.byteItemVersion??2)}decompress(t,e){return e=this.point.decompress(t,e),e=this.gpsTime.decompress(t,e),e=this.bytes.decompress(t,e),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint(),s=this.gpsTime.decompressGpsTime();this.bytes.decompressToTarget(t.extraBytes,e*this.bytes.byteCount),this.readFirstMetadata(),Rn(n,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),Wi(n,t,e),t.gpsTimes&&(t.gpsTimes[e]=s)}decompressPointDataBatch(t,e){for(let n=0;n<e;n++)this.decompressPointData(t,t.pointOffset+n)}readFirstMetadata(){this.first&&(this.point.readFirstMetadata(),this.first=!1)}},Rd=class{point;rgb;bytes;first=!0;constructor(t,e,n){this.point=new Zs(t,n.point10ItemVersion??2);let s=this.point.getDecoder();this.rgb=new Qa(t,s,n.rgb12ItemVersion??2),this.bytes=new Hs(t,s,e,n.byteItemVersion??2)}decompress(t,e){return e=this.point.decompress(t,e),e=this.rgb.decompress(t,e),e=this.bytes.decompress(t,e),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint();this.rgb.decompressRgb(),this.bytes.decompressToTarget(t.extraBytes,e*this.bytes.byteCount),this.readFirstMetadata(),Rn(n,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),Wi(n,t,e),Hi(this.rgb.decodedRed,this.rgb.decodedGreen,this.rgb.decodedBlue,t,e)}decompressPointDataBatch(t,e){for(let n=0;n<e;n++)this.decompressPointData(t,t.pointOffset+n)}readFirstMetadata(){this.first&&(this.point.readFirstMetadata(),this.first=!1)}},Pd=class{point;gpsTime;rgb;bytes;first=!0;directCommonOutput;constructor(t,e,n,s=null){this.point=new Zs(t,n.point10ItemVersion??2);let i=this.point.getDecoder();this.gpsTime=new jo(t,i,n.gpsTime11ItemVersion??2),this.rgb=new Qa(t,i,n.rgb12ItemVersion??2),this.bytes=new Hs(t,i,e,n.byteItemVersion??2),this.directCommonOutput=!!(s&&!s.gpsTime&&!s.scanAngle&&!s.userData&&!s.pointSourceId&&!s.flags&&!s.waveform&&!s.extraBytes)}decompress(t,e){return e=this.point.decompress(t,e),e=this.gpsTime.decompress(t,e),e=this.rgb.decompress(t,e),e=this.bytes.decompress(t,e),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint(),s=this.gpsTime.decompressGpsTime();if(this.rgb.decompressRgb(),this.directCommonOutput){if(this.bytes.decompressToTarget(),this.readFirstMetadata(),Rn(n,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),t.colors){let i=e*4;t.colors[i]=this.rgb.decodedRed&255,t.colors[i+1]=this.rgb.decodedGreen&255,t.colors[i+2]=this.rgb.decodedBlue&255,t.colors[i+3]=255}else if(t.rawColors){let i=e*3;t.rawColors[i]=this.rgb.decodedRed,t.rawColors[i+1]=this.rgb.decodedGreen,t.rawColors[i+2]=this.rgb.decodedBlue}return}this.bytes.decompressToTarget(t.extraBytes,e*this.bytes.byteCount),this.readFirstMetadata(),Rn(n,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),Wi(n,t,e),t.gpsTimes&&(t.gpsTimes[e]=s),Hi(this.rgb.decodedRed,this.rgb.decodedGreen,this.rgb.decodedBlue,t,e)}decompressPointDataBatch(t,e){let n=t.positions,s=t.intensities,i=t.classifications,o=t.colors,a=t.rawColors,c=t.scale,l=t.offset,u=this.bytes.byteCount,f=t.pointOffset;if(!!!(t.gpsTimes||t.scanAngles||t.userData||t.pointSourceIds||t.returnNumbers||t.numberOfReturns||t.scannerChannels||t.scanDirectionFlags||t.edgeOfFlightLines||t.syntheticFlags||t.keyPointFlags||t.withheldFlags||t.overlapFlags)&&!t.extraBytes){for(let m=0;m<e;m++){let y=this.point.decompressPoint();if(this.gpsTime.decompressGpsTime(),this.rgb.decompressRgb(),this.bytes.decompressToTarget(),this.readFirstMetadata(),Rn(y,n,s,i,c,l,f),o){let g=f*4;o[g]=this.rgb.decodedRed&255,o[g+1]=this.rgb.decodedGreen&255,o[g+2]=this.rgb.decodedBlue&255,o[g+3]=255}else if(a){let g=f*3;a[g]=this.rgb.decodedRed,a[g+1]=this.rgb.decodedGreen,a[g+2]=this.rgb.decodedBlue}f++}return}for(let m=0;m<e;m++){let y=this.point.decompressPoint(),g=this.gpsTime.decompressGpsTime();this.rgb.decompressRgb(),this.bytes.decompressToTarget(t.extraBytes,f*u),this.readFirstMetadata(),Rn(y,n,s,i,c,l,f),Wi(y,t,f),t.gpsTimes&&(t.gpsTimes[f]=g),Hi(this.rgb.decodedRed,this.rgb.decodedGreen,this.rgb.decodedBlue,t,f),f++}}readFirstMetadata(){this.first&&(this.point.readFirstMetadata(),this.first=!1)}},iu=class{stream;decoder;context=new nu;constructor(t,e){this.stream=t,this.decoder=e}decompress(t,e){let n=this.context;if(!n.haveLast)return this.stream.getBytes(t,e,29),this.readContext(t,e),n.haveLast=!0,e+29;n.descriptorIndex=this.decoder.decodeSymbol(n.descriptorModel);let s=this.decoder.decodeSymbol(n.offsetDifferenceModels[n.lastOffsetDifferenceSymbol]);switch(n.lastOffsetDifferenceSymbol=s,s){case 0:break;case 1:n.offset=BigInt.asUintN(64,n.offset+BigInt(n.packetSize));break;case 2:n.lastOffsetDifference=n.offsetDifferenceDecompressor.decompress(this.decoder,n.lastOffsetDifference,0),n.offset=BigInt.asUintN(64,n.offset+BigInt(n.lastOffsetDifference));break;default:n.offset=this.decoder.readUint64();break}return n.packetSize=n.packetSizeDecompressor.decompress(this.decoder,n.packetSize|0,0)>>>0,n.returnPointBits=n.returnPointDecompressor.decompress(this.decoder,n.returnPointBits,0),n.xBits=n.vectorDecompressor.decompress(this.decoder,n.xBits,0),n.yBits=n.vectorDecompressor.decompress(this.decoder,n.yBits,1),n.zBits=n.vectorDecompressor.decompress(this.decoder,n.zBits,2),this.writeContext(t,e),e+29}decompressToTarget(t,e){this.decompress(t,e)}readContext(t,e){let n=this.context;n.descriptorIndex=t[e],n.offset=vb(t,e+1),n.packetSize=cu(t,e+9),n.returnPointBits=Gr(t,e+13),n.xBits=Gr(t,e+17),n.yBits=Gr(t,e+21),n.zBits=Gr(t,e+25)}writeContext(t,e){let n=this.context;t[e]=n.descriptorIndex,Ab(n.offset,t,e+1),lu(n.packetSize,t,e+9),Ue(n.returnPointBits,t,e+13),Ue(n.xBits,t,e+17),Ue(n.yBits,t,e+21),Ue(n.zBits,t,e+25)}},kd=class{point;gpsTime;wavePacket;bytes;waveformScratch=new Uint8Array(29);first=!0;constructor(t,e,n){this.point=new Zs(t,n.point10ItemVersion??2);let s=this.point.getDecoder();this.gpsTime=new jo(t,s,n.gpsTime11ItemVersion??2),this.wavePacket=new iu(t,s),this.bytes=new Hs(t,s,e,n.byteItemVersion??2)}decompress(t,e){return e=this.point.decompress(t,e),e=this.gpsTime.decompress(t,e),e=this.wavePacket.decompress(t,e),e=this.bytes.decompress(t,e),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint(),s=this.gpsTime.decompressGpsTime();t.waveforms?this.wavePacket.decompressToTarget(t.waveforms,e*29):this.wavePacket.decompressToTarget(this.waveformScratch,0),this.bytes.decompressToTarget(t.extraBytes,e*this.bytes.byteCount),this.readFirstMetadata(),Rn(n,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),Wi(n,t,e),t.gpsTimes&&(t.gpsTimes[e]=s)}decompressPointDataBatch(t,e){for(let n=0;n<e;n++)this.decompressPointData(t,t.pointOffset+n)}readFirstMetadata(){this.first&&(this.point.readFirstMetadata(),this.first=!1)}},zd=class{point;gpsTime;rgb;wavePacket;bytes;waveformScratch=new Uint8Array(29);first=!0;constructor(t,e,n){this.point=new Zs(t,n.point10ItemVersion??2);let s=this.point.getDecoder();this.gpsTime=new jo(t,s,n.gpsTime11ItemVersion??2),this.rgb=new Qa(t,s,n.rgb12ItemVersion??2),this.wavePacket=new iu(t,s),this.bytes=new Hs(t,s,e,n.byteItemVersion??2)}decompress(t,e){return e=this.point.decompress(t,e),e=this.gpsTime.decompress(t,e),e=this.rgb.decompress(t,e),e=this.wavePacket.decompress(t,e),e=this.bytes.decompress(t,e),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint(),s=this.gpsTime.decompressGpsTime();this.rgb.decompressRgb(),t.waveforms?this.wavePacket.decompressToTarget(t.waveforms,e*29):this.wavePacket.decompressToTarget(this.waveformScratch,0),this.bytes.decompressToTarget(t.extraBytes,e*this.bytes.byteCount),this.readFirstMetadata(),Rn(n,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),Wi(n,t,e),t.gpsTimes&&(t.gpsTimes[e]=s),Hi(this.rgb.decodedRed,this.rgb.decodedGreen,this.rgb.decodedBlue,t,e)}decompressPointDataBatch(t,e){for(let n=0;n<e;n++)this.decompressPointData(t,t.pointOffset+n)}readFirstMetadata(){this.first&&(this.point.readFirstMetadata(),this.first=!1)}},Vd=class{stream;point;bytes;extraByteCount;first=!0;constructor(t,e,n,s,i){this.stream=t,this.extraByteCount=e,this.point=new qi(t,n==="raw"?Nt.Full:Nt.PointData,s.point14ItemVersion??3,i),this.bytes=(n==="raw"||i?.extraBytes)&&e?new $i(t,e,s.byte14ItemVersion??3):null}decompress(t,e){return e=this.point.decompress(t,e),this.bytes&&(e=this.bytes.decompress(t,e,this.point.itemContextChannel)),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint();this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,e*this.extraByteCount,this.point.itemContextChannel):this.first&&this.extraByteCount&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),rc(n,t,e)}decompressPointDataBatch(t,e){let n=t.positions,s=t.intensities,i=t.classifications,o=t.scale,a=t.offset,c=t.pointOffset;for(let l=0;l<e;l++){let u=this.point.decompressPoint();this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,c*this.extraByteCount,this.point.itemContextChannel):this.first&&this.extraByteCount&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),Ws(u,n,s,i,o,a,c++),Yi(u,t,c-1),Zi(u,t,c-1)}}readFirstMetadata(){if(this.first){this.stream.getUint32(),this.point.readSizes();let t=0;if(this.bytes)this.bytes.readSizes();else for(let e=0;e<this.extraByteCount;e++)t+=this.stream.getUint32();this.point.readData(),this.bytes?this.bytes.readData():this.stream.consume(t),this.first=!1}}},Gd=class{stream;point;rgb;bytes;extraByteCount;first=!0;constructor(t,e,n,s,i){this.stream=t,this.extraByteCount=e,this.point=new qi(t,n==="raw"?Nt.Full:Nt.PointData,s.point14ItemVersion??3,i),this.rgb=n==="raw"||i?.color?new tc(t,s.rgb14ItemVersion??3):null,this.bytes=(n==="raw"||i?.extraBytes)&&e?new $i(t,e,s.byte14ItemVersion??3):null}decompress(t,e){return e=this.point.decompress(t,e),e=this.rgb.decompress(t,e,this.point.itemContextChannel),this.bytes&&(e=this.bytes.decompress(t,e,this.point.itemContextChannel)),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint();this.rgb?this.rgb.decompressRgb(this.point.itemContextChannel):this.first&&this.stream.consume(6),this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,e*this.extraByteCount,this.point.itemContextChannel):this.first&&this.extraByteCount&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),rc(n,t,e),this.rgb&&Hi(this.rgb.decodedRed,this.rgb.decodedGreen,this.rgb.decodedBlue,t,e)}decompressPointDataBatch(t,e){let n=t.positions,s=t.intensities,i=t.classifications,o=t.colors,a=t.rawColors,c=t.scale,l=t.offset,u=t.pointOffset,f=e;if(this.first&&f>0){let y=this.point.decompressPoint();if(this.rgb?this.rgb.decompressRgb(this.point.itemContextChannel):this.stream.consume(6),this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,u*this.extraByteCount,this.point.itemContextChannel):this.extraByteCount&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),Ws(y,n,s,i,c,l,u),Yi(y,t,u),Zi(y,t,u),o&&this.rgb){let g=u*4;o[g]=this.rgb.decodedRed&255,o[g+1]=this.rgb.decodedGreen&255,o[g+2]=this.rgb.decodedBlue&255,o[g+3]=255}else if(a&&this.rgb){let g=u*3;a[g]=this.rgb.decodedRed,a[g+1]=this.rgb.decodedGreen,a[g+2]=this.rgb.decodedBlue}u++,f--}let h=!!(t.gpsTimes||t.scanAngles||t.userData||t.pointSourceIds||t.returnNumbers||t.numberOfReturns||t.scannerChannels||t.scanDirectionFlags||t.edgeOfFlightLines||t.syntheticFlags||t.keyPointFlags||t.withheldFlags||t.overlapFlags),m=!!(this.bytes&&t.extraBytes);if(!h&&!m){for(let y=0;y<f;y++){let g=this.point.decompressPoint();if(this.rgb?.decompressRgb(this.point.itemContextChannel),Ws(g,n,s,i,c,l,u),o&&this.rgb){let x=u*4;o[x]=this.rgb.decodedRed&255,o[x+1]=this.rgb.decodedGreen&255,o[x+2]=this.rgb.decodedBlue&255,o[x+3]=255}else if(a&&this.rgb){let x=u*3;a[x]=this.rgb.decodedRed,a[x+1]=this.rgb.decodedGreen,a[x+2]=this.rgb.decodedBlue}u++}return}for(let y=0;y<f;y++){let g=this.point.decompressPoint();if(this.rgb?.decompressRgb(this.point.itemContextChannel),this.bytes&&t.extraBytes&&this.bytes.decompress(t.extraBytes,u*this.extraByteCount,this.point.itemContextChannel),Ws(g,n,s,i,c,l,u),Yi(g,t,u),Zi(g,t,u),o&&this.rgb){let x=u*4;o[x]=this.rgb.decodedRed&255,o[x+1]=this.rgb.decodedGreen&255,o[x+2]=this.rgb.decodedBlue&255,o[x+3]=255}else if(a&&this.rgb){let x=u*3;a[x]=this.rgb.decodedRed,a[x+1]=this.rgb.decodedGreen,a[x+2]=this.rgb.decodedBlue}u++}}readFirstMetadata(){if(this.first){this.stream.getUint32(),this.point.readSizes();let t=this.rgb?0:this.stream.getUint32();this.rgb?.readSizes();let e=0;if(this.bytes)this.bytes.readSizes();else for(let n=0;n<this.extraByteCount;n++)e+=this.stream.getUint32();this.point.readData(),this.rgb?this.rgb.readData():this.stream.consume(t),this.bytes?this.bytes.readData():this.stream.consume(e),this.first=!1}}},jd=class{stream;point;rgb;nir;bytes;extraByteCount;first=!0;constructor(t,e,n,s,i){this.stream=t,this.extraByteCount=e,this.point=new qi(t,n==="raw"?Nt.Full:Nt.PointData,s.point14ItemVersion??3,i),this.rgb=n==="raw"||i?.color?new tc(t,s.rgb14ItemVersion??3):null,this.nir=n==="raw"||i?.nir?new ru(t,s.rgb14ItemVersion??3):null,this.bytes=(n==="raw"||i?.extraBytes)&&e?new $i(t,e,s.byte14ItemVersion??3):null}decompress(t,e){return e=this.point.decompress(t,e),e=this.rgb.decompress(t,e,this.point.itemContextChannel),e=this.nir.decompress(t,e,this.point.itemContextChannel),this.bytes&&(e=this.bytes.decompress(t,e,this.point.itemContextChannel)),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint();this.rgb?this.rgb.decompressRgb(this.point.itemContextChannel):this.first&&this.stream.consume(6),!this.nir&&this.first&&this.stream.consume(2);let s=this.nir?this.nir.decompressNir(this.point.itemContextChannel):0;this.bytes&&t.extraBytes&&this.bytes.decompress(t.extraBytes,e*this.extraByteCount,this.point.itemContextChannel),this.first&&this.stream.consume(this.bytes?0:this.extraByteCount),this.readFirstMetadata(),rc(n,t,e),ou(s,t,e),this.rgb&&Hi(this.rgb.decodedRed,this.rgb.decodedGreen,this.rgb.decodedBlue,t,e)}decompressPointDataBatch(t,e){let n=t.positions,s=t.intensities,i=t.classifications,o=t.colors,a=t.rawColors,c=t.scale,l=t.offset,u=t.pointOffset;for(let f=0;f<e;f++){let h=this.point.decompressPoint();this.rgb?this.rgb.decompressRgb(this.point.itemContextChannel):this.first&&this.stream.consume(6),!this.nir&&this.first&&this.stream.consume(2);let m=this.nir?this.nir.decompressNir(this.point.itemContextChannel):0;if(this.bytes&&t.extraBytes&&this.bytes.decompress(t.extraBytes,u*this.extraByteCount,this.point.itemContextChannel),this.first&&this.stream.consume(this.bytes?0:this.extraByteCount),this.readFirstMetadata(),Ws(h,n,s,i,c,l,u),Yi(h,t,u),Zi(h,t,u),o&&this.rgb){let y=u*4;o[y]=this.rgb.decodedRed&255,o[y+1]=this.rgb.decodedGreen&255,o[y+2]=this.rgb.decodedBlue&255,o[y+3]=255}else if(a&&this.rgb){let y=u*3;a[y]=this.rgb.decodedRed,a[y+1]=this.rgb.decodedGreen,a[y+2]=this.rgb.decodedBlue}ou(m,t,u),u++}}readFirstMetadata(){if(this.first){this.stream.getUint32(),this.point.readSizes();let t=this.rgb?0:this.stream.getUint32();this.rgb?.readSizes();let e=this.nir?0:this.stream.getUint32();this.nir?.readSizes();let n=0;if(this.bytes)this.bytes.readSizes();else for(let s=0;s<this.extraByteCount;s++)n+=this.stream.getUint32();this.point.readData(),this.rgb?this.rgb.readData():this.stream.consume(t),this.nir?this.nir.readData():this.stream.consume(e),this.bytes?this.bytes.readData():this.stream.consume(n),this.first=!1}}},qd=class{stream;point;wavePacket;bytes;extraByteCount;first=!0;waveformScratch=new Uint8Array(29);constructor(t,e,n,s,i){this.stream=t,this.extraByteCount=e,this.point=new qi(t,n==="raw"?Nt.Full:Nt.PointData,s.point14ItemVersion??3,i),this.wavePacket=n==="raw"||i?.waveform?new su(t,s.wavePacketItemVersion??3):null,this.bytes=(n==="raw"||i?.extraBytes)&&e?new $i(t,e,s.byte14ItemVersion??3):null}decompress(t,e){return e=this.point.decompress(t,e),e=this.wavePacket.decompress(t,e,this.point.itemContextChannel),this.bytes&&(e=this.bytes.decompress(t,e,this.point.itemContextChannel)),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint();this.wavePacket?(this.wavePacket.decompressToTarget(this.waveformScratch,0,this.point.itemContextChannel),t.waveforms&&t.waveforms.set(this.waveformScratch,e*29)):this.first&&this.stream.consume(29),this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,e*this.extraByteCount,this.point.itemContextChannel):this.first&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),rc(n,t,e)}decompressPointDataBatch(t,e){let n=t.positions,s=t.intensities,i=t.classifications,o=t.scale,a=t.offset,c=t.pointOffset;for(let l=0;l<e;l++){let u=this.point.decompressPoint();this.wavePacket?(this.wavePacket.decompressToTarget(this.waveformScratch,0,this.point.itemContextChannel),t.waveforms&&t.waveforms.set(this.waveformScratch,c*29)):this.first&&this.stream.consume(29),this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,c*this.extraByteCount,this.point.itemContextChannel):this.first&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),Ws(u,n,s,i,o,a,c++),Yi(u,t,c-1),Zi(u,t,c-1)}}readFirstMetadata(){if(this.first){this.stream.getUint32(),this.point.readSizes();let t=this.wavePacket?0:this.stream.getUint32();this.wavePacket?.readSizes();let e=0;if(this.bytes)this.bytes.readSizes();else for(let n=0;n<this.extraByteCount;n++)e+=this.stream.getUint32();this.point.readData(),this.wavePacket?this.wavePacket.readData():this.stream.consume(t),this.bytes?this.bytes.readData():this.stream.consume(e),this.first=!1}}},$d=class{stream;point;rgb;nir;wavePacket;bytes;extraByteCount;first=!0;waveformScratch=new Uint8Array(29);constructor(t,e,n,s,i){this.stream=t,this.extraByteCount=e,this.point=new qi(t,n==="raw"?Nt.Full:Nt.PointData,s.point14ItemVersion??3,i),this.rgb=n==="raw"||i?.color?new tc(t,s.rgb14ItemVersion??3):null,this.nir=n==="raw"||i?.nir?new ru(t,s.rgb14ItemVersion??3):null,this.wavePacket=n==="raw"||i?.waveform?new su(t,s.wavePacketItemVersion??3):null,this.bytes=(n==="raw"||i?.extraBytes)&&e?new $i(t,e,s.byte14ItemVersion??3):null}decompress(t,e){return e=this.point.decompress(t,e),e=this.rgb.decompress(t,e,this.point.itemContextChannel),e=this.nir.decompress(t,e,this.point.itemContextChannel),e=this.wavePacket.decompress(t,e,this.point.itemContextChannel),this.bytes&&(e=this.bytes.decompress(t,e,this.point.itemContextChannel)),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint();this.rgb?this.rgb.decompressRgb(this.point.itemContextChannel):this.first&&this.stream.consume(6);let s=this.nir?this.nir.decompressNir(this.point.itemContextChannel):0;this.first&&this.stream.consume(this.nir?0:2),this.wavePacket?(this.wavePacket.decompressToTarget(this.waveformScratch,0,this.point.itemContextChannel),t.waveforms&&t.waveforms.set(this.waveformScratch,e*29)):this.first&&this.stream.consume(29),this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,e*this.extraByteCount,this.point.itemContextChannel):this.first&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),rc(n,t,e),ou(s,t,e),this.rgb&&Hi(this.rgb.decodedRed,this.rgb.decodedGreen,this.rgb.decodedBlue,t,e)}decompressPointDataBatch(t,e){let n=t.positions,s=t.intensities,i=t.classifications,o=t.colors,a=t.rawColors,c=t.scale,l=t.offset,u=t.pointOffset;for(let f=0;f<e;f++){let h=this.point.decompressPoint();this.rgb?this.rgb.decompressRgb(this.point.itemContextChannel):this.first&&this.stream.consume(6);let m=this.nir?this.nir.decompressNir(this.point.itemContextChannel):0;if(this.first&&this.stream.consume(this.nir?0:2),this.wavePacket?(this.wavePacket.decompressToTarget(this.waveformScratch,0,this.point.itemContextChannel),t.waveforms&&t.waveforms.set(this.waveformScratch,u*29)):this.first&&this.stream.consume(29),this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,u*this.extraByteCount,this.point.itemContextChannel):this.first&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),Ws(h,n,s,i,c,l,u),Yi(h,t,u),Zi(h,t,u),o&&this.rgb){let y=u*4;o[y]=this.rgb.decodedRed&255,o[y+1]=this.rgb.decodedGreen&255,o[y+2]=this.rgb.decodedBlue&255,o[y+3]=255}else if(a&&this.rgb){let y=u*3;a[y]=this.rgb.decodedRed,a[y+1]=this.rgb.decodedGreen,a[y+2]=this.rgb.decodedBlue}ou(m,t,u),u++}}readFirstMetadata(){if(this.first){this.stream.getUint32(),this.point.readSizes();let t=this.rgb?0:this.stream.getUint32();this.rgb?.readSizes();let e=this.nir?0:this.stream.getUint32();this.nir?.readSizes();let n=this.wavePacket?0:this.stream.getUint32();this.wavePacket?.readSizes();let s=0;if(this.bytes)this.bytes.readSizes();else for(let i=0;i<this.extraByteCount;i++)s+=this.stream.getUint32();this.point.readData(),this.rgb?this.rgb.readData():this.stream.consume(t),this.nir?this.nir.readData():this.stream.consume(e),this.wavePacket?this.wavePacket.readData():this.stream.consume(n),this.bytes?this.bytes.readData():this.stream.consume(s),this.first=!1}}}});function We(r){return r|0}var Ot,Kd,$t,_t,Xi,_b=p(()=>{"use strict";Ot=class{symbols;distribution;symbolCount;lastSymbol;totalCount=0;updateCycle;symbolsUntilUpdate;constructor(t){if(t<2||t>2048)throw new Error(`Invalid arithmetic model symbol count ${t}`);this.symbols=t,this.lastSymbol=t-1,this.distribution=new Uint32Array(t),this.symbolCount=new Uint32Array(t),this.symbolCount.fill(1),this.updateCycle=t,this.symbolsUntilUpdate=t,this.update(),this.symbolsUntilUpdate=this.updateCycle=t+6>>1}update(){if(this.totalCount+=this.updateCycle,this.totalCount>32768){this.totalCount=0;for(let s=0;s<this.symbols;s++)this.symbolCount[s]=this.symbolCount[s]+1>>1,this.totalCount+=this.symbolCount[s]}let t=0,e=2147483648/this.totalCount|0;for(let s=0;s<this.symbols;s++)this.distribution[s]=e*t/65536|0,t+=this.symbolCount[s];this.updateCycle=5*this.updateCycle>>2;let n=this.symbols+6<<3;this.updateCycle>n&&(this.updateCycle=n),this.symbolsUntilUpdate=this.updateCycle}},Kd=class{updateCycle=4;bitsUntilUpdate=4;bit0Probability=4096;bit0Count=1;bitCount=2;update(){this.bitCount+=this.updateCycle,this.bitCount>8192&&(this.bitCount=this.bitCount+1>>1,this.bit0Count=this.bit0Count+1>>1,this.bit0Count===this.bitCount&&this.bitCount++);let t=2147483648/this.bitCount|0;this.bit0Probability=this.bit0Count*t/262144|0,this.updateCycle=5*this.updateCycle>>2,this.updateCycle>64&&(this.updateCycle=64),this.bitsUntilUpdate=this.updateCycle}},$t=class{bytes=[];base=0;length=4294967295;finished=!1;encodeBit(t,e){let n=t.bit0Probability*(this.length>>>13);if(e===0)this.length=n>>>0,t.bit0Count++;else if(e===1)this.addToBase(n),this.length=this.length-n>>>0;else throw new Error(`Invalid arithmetic bit ${e}`);this.renormalizeIfNeeded(),--t.bitsUntilUpdate===0&&t.update()}encodeSymbol(t,e){if(!Number.isInteger(e)||e<0||e>t.lastSymbol)throw new Error(`Invalid arithmetic symbol ${e}`);let n=this.length,s;e===t.lastSymbol?(s=t.distribution[e]*(n>>>15),this.addToBase(s),this.length=n-s>>>0):(n>>>=15,s=t.distribution[e]*n,this.addToBase(s),this.length=t.distribution[e+1]*n-s>>>0),this.renormalizeIfNeeded(),t.symbolCount[e]++,--t.symbolsUntilUpdate===0&&t.update()}writeBits(t,e){if(!Number.isInteger(t)||t<1||t>32)throw new Error(`Invalid arithmetic bit count ${t}`);t>19&&(this.writeShort(e&65535),e>>>=16,t-=16);let n=this.length>>>t;this.addToBase(e*n),this.length=n>>>0,this.renormalizeIfNeeded()}writeShort(t){let e=this.length>>>16;this.addToBase((t&65535)*e),this.length=e>>>0,this.renormalizeIfNeeded()}writeInt(t){this.writeShort(t&65535),this.writeShort(t>>>16)}finish(){if(this.finished)return Uint8Array.from(this.bytes);this.finished=!0;let t=this.base,e=!0;return this.length>2*16777216?(this.base=this.base+16777216>>>0,this.length=8388608):(this.base=this.base+8388608>>>0,this.length=32768,e=!1),t>this.base&&this.propagateCarry(),this.renormalize(),this.bytes.push(0,0),e&&this.bytes.push(0),Uint8Array.from(this.bytes)}addToBase(t){let e=this.base;this.base=this.base+t>>>0,e>this.base&&this.propagateCarry()}propagateCarry(){let t=this.bytes.length-1;for(;t>=0&&this.bytes[t]===255;)this.bytes[t--]=0;if(t<0)throw new Error("LASzip arithmetic carry precedes encoded output");this.bytes[t]++}renormalizeIfNeeded(){this.length<16777216&&this.renormalize()}renormalize(){do this.bytes.push(this.base>>>24),this.base=this.base<<8>>>0,this.length=this.length<<8>>>0;while(this.length<16777216)}},_t=class{encoder;contexts;bitsHigh;correctionBits;correctionRange;correctionMinimum;bitModels;zeroBitCorrector=new Kd;correctorModels;k=0;constructor(t,e=16,n=1,s=8,i=0){if(this.encoder=t,this.contexts=n,this.bitsHigh=s,i){let o=i,a=0;for(;o;)o>>=1,a++;i===2**(a-1)&&a--,this.correctionBits=a,this.correctionRange=i,this.correctionMinimum=-(i/2)}else e&&e<32?(this.correctionBits=e,this.correctionRange=2**e,this.correctionMinimum=-(this.correctionRange/2)):(this.correctionBits=32,this.correctionRange=0,this.correctionMinimum=-2147483648);this.bitModels=Array.from({length:this.contexts},()=>new Ot(this.correctionBits+1)),this.correctorModels=Array.from({length:this.correctionBits},(o,a)=>{let c=a+1;return new Ot(2**Math.min(c,this.bitsHigh))})}compress(t,e,n=0){if(!Number.isInteger(n)||n<0||n>=this.contexts)throw new Error(`Invalid integer compressor context ${n}`);let s=We(e-t);this.correctionRange&&(s<this.correctionMinimum?s+=this.correctionRange:s>this.correctionMinimum+this.correctionRange-1&&(s-=this.correctionRange)),this.writeCorrector(s,this.bitModels[n])}writeCorrector(t,e){let n=t<=0?-t:t-1,s=0;for(;n;)n>>>=1,s++;if(this.k=s,this.encoder.encodeSymbol(e,s),s===0){this.encoder.encodeBit(this.zeroBitCorrector,t);return}if(s===32){if(t!==this.correctionMinimum)throw new Error(`Invalid ${s}-bit integer correction ${t}`);return}let i=t<0?t+(2**s-1):t-1,o=this.correctorModels[s-1];if(s<=this.bitsHigh)this.encoder.encodeSymbol(o,i);else{let a=s-this.bitsHigh,c=2**a-1,l=i&c;i>>>=a,this.encoder.encodeSymbol(o,i),this.encoder.writeBits(a,l)}}},Xi=class{value0=0;value1=0;value2=0;value3=0;value4=0;high=!0;add(t){this.high?t<this.value2?(this.value4=this.value3,this.value3=this.value2,t<this.value0?(this.value2=this.value1,this.value1=this.value0,this.value0=t):t<this.value1?(this.value2=this.value1,this.value1=t):this.value2=t):(t<this.value3?(this.value4=this.value3,this.value3=t):this.value4=t,this.high=!1):this.value2<t?(this.value0=this.value1,this.value1=this.value2,this.value4<t?(this.value2=this.value3,this.value3=this.value4,this.value4=t):this.value3<t?(this.value2=this.value3,this.value3=t):this.value2=t):(this.value1<t?(this.value0=this.value1,this.value1=t):this.value0=t,this.high=!0)}get(){return this.value2}}});function cp(r,t){let e=PS(r);if(OS(e,t),t.pointCount===0)return new Uint8Array(0);if(t.pointDataRecordFormat<=5)return FS(e,t);let n=t.pointDataRecordLength,s=t.pointDataRecordFormat,i=Iu[s],o=n-i,a=e.subarray(0,n),c=Cb(a,0),l=new sp(c),u=s===7||s===8||s===10?vu(a,30):null,f=u?new ip(u,Wo(c)):null,h=s===8||s===10?new op(nc(a,36),Wo(c)):null,m=s===9?30:s===10?38:-1,y=m>=0?new rp(Au(a,m),Wo(c),t.wavePacketItemVersion??3):null,g=o?new ap(a.subarray(i,n),Wo(c)):null;for(let X=1;X<t.pointCount;X++){let ft=X*n,dt=e.subarray(ft,ft+n),It=l.encode(Cb(dt,0));f?.encode(vu(dt,30),It),h?.encode(nc(dt,36),It),y?.encode(Au(dt,m),It),g?.encode(dt.subarray(i,n),It)}let x=l.finish(),I=f?.finish(),q=h?.finish(),T=y?.finish(),b=g?.finish()||[],C=[...x,...I?[I]:[],...q?[q]:[],...T?[T]:[],...b],_=new Uint8Array(4+C.length*4),$=new DataView(_.buffer);$.setUint32(0,t.pointCount,!0);for(let X=0;X<C.length;X++)$.setUint32(4+X*4,C[X].byteLength,!0);return Pb([a,_,...C])}function lp(r,t={}){if(r.length===0)return new Uint8Array(0);let e=new $t,n=new _t(e,32,2),s=0,i=0;for(let o of r)ES(o),t.variable&&(n.compress(s,o.pointCount,0),s=o.pointCount),n.compress(i,o.byteLength,1),i=o.byteLength;return e.finish()}function up(r){let t=r.pointDataRecordFormat<=5,e=r.itemVersion||(t?2:3);if(t&&e!==2)throw new Error("Legacy LASzip point formats require item version 2");if(!t&&e!==3)throw new Error("Modern LASzip point formats require item version 3");let n=US(r.pointDataRecordFormat,r.pointDataRecordLength),s=Tb+n.length*6,i=new Uint8Array(Lb+s),o=new DataView(i.buffer),a=Lb;Nb(o,2,"laszip encoded",16),o.setUint16(18,22204,!0),o.setUint16(20,s,!0),Nb(o,22,"loaders.gl LAZ writer",32),o.setUint16(a,t?2:3,!0),o.setUint16(a+2,0,!0),o.setUint8(a+4,t?2:3),o.setUint8(a+5,0),o.setUint16(a+6,1,!0),o.setUint32(a+8,0,!0),o.setUint32(a+12,r.chunkSize,!0),i.fill(255,a+16,a+32),o.setUint16(a+32,n.length,!0);for(let c=0;c<n.length;c++){let l=a+Tb+c*6,u=n[c];o.setUint16(l,u.type,!0),o.setUint16(l+2,u.size,!0),o.setUint16(l+4,u.version??e,!0)}return i}function FS(r,t){let e=t.pointDataRecordLength,n=t.pointDataRecordFormat,s=Iu[n],i=e-s,o=r.subarray(0,e),a=new $t,c=new Jd(a,Fb(o,0)),l=n===1||n===3||n===4||n===5?new Qd(a,Ob(o,20)):null,u=n===2?20:n===3||n===5?28:-1,f=u>=0?new tp(a,vu(o,u)):null,h=n===4?28:n===5?34:-1,m=h>=0?new ep(a,Au(o,h)):null,y=i?new np(a,o.subarray(s,e)):null;for(let g=1;g<t.pointCount;g++){let x=g*e,I=r.subarray(x,x+e);c.encode(Fb(I,0)),l?.encode(Ob(I,20)),f?.encode(vu(I,u)),m?.encode(Au(I,h)),y?.encode(I.subarray(s,e))}return Pb([o,a.finish()])}function OS(r,t){if([t.point10ItemVersion,t.gpsTime11ItemVersion,t.rgb12ItemVersion,t.byteItemVersion].some(s=>s!==void 0&&s!==2))throw new Error("TypeScript LAZ encoder only supports legacy item version 2");if(!Number.isInteger(t.pointCount)||t.pointCount<0)throw new Error(`Invalid LAZ chunk point count ${t.pointCount}`);let e=Iu[t.pointDataRecordFormat];if(!e)throw new Error(`TypeScript LAZ encoder does not support point format ${t.pointDataRecordFormat}`);if(!Number.isInteger(t.pointDataRecordLength)||t.pointDataRecordLength<e)throw new Error(`Invalid point record length ${t.pointDataRecordLength} for point format ${t.pointDataRecordFormat}`);if(t.point14ItemVersion!==void 0&&t.point14ItemVersion!==3)throw new Error("TypeScript LAZ encoder only supports Point14 item version 3");if(t.pointDataRecordFormat>=7&&t.rgb14ItemVersion!==void 0&&t.rgb14ItemVersion!==3)throw new Error("TypeScript LAZ encoder only supports RGB14 item version 3");if((t.pointDataRecordFormat===9||t.pointDataRecordFormat===10)&&t.wavePacketItemVersion!==void 0&&t.wavePacketItemVersion!==3)throw new Error("TypeScript LAZ encoder only supports WavePacket14 item version 3");if(t.pointDataRecordLength>e&&t.byte14ItemVersion!==void 0&&t.byte14ItemVersion!==3)throw new Error("TypeScript LAZ encoder only supports Byte14 item version 3");let n=t.pointCount*t.pointDataRecordLength;if(r.byteLength!==n)throw new Error(`LAZ chunk input has ${r.byteLength} bytes; expected ${n}`)}function ES(r){if(!Number.isInteger(r.pointCount)||r.pointCount<=0||r.pointCount>4294967295)throw new Error(`Invalid LAZ chunk point count ${r.pointCount}`);if(!Number.isInteger(r.byteLength)||r.byteLength<=0||r.byteLength>4294967295)throw new Error(`Invalid LAZ chunk byte length ${r.byteLength}`)}function US(r,t){let e=Iu[r];if(!e||t<e)throw new Error(`Invalid point record length ${t} for point format ${r}`);if(r<=5){let i=[{type:6,size:20}];(r===1||r===3||r===4||r===5)&&i.push({type:7,size:8}),(r===2||r===3||r===5)&&i.push({type:8,size:6}),(r===4||r===5)&&i.push({type:9,size:29,version:1});let o=t-e;return o>0&&i.push({type:0,size:o}),i}let n=[{type:10,size:30}];r===7?n.push({type:11,size:6}):r===8?n.push({type:12,size:8}):r===10&&n.push({type:12,size:8}),(r===9||r===10)&&n.push({type:13,size:29});let s=t-e;return s>0&&n.push({type:14,size:s}),n}function Cb(r,t){let e=new DataView(r.buffer,r.byteOffset+t,30);return{x:e.getInt32(0,!0),y:e.getInt32(4,!0),z:e.getInt32(8,!0),intensity:e.getUint16(12,!0),returns:e.getUint8(14),flags:e.getUint8(15),classification:e.getUint8(16),userData:e.getUint8(17),scanAngle:e.getInt16(18,!0),pointSourceId:e.getUint16(20,!0),gpsTimeBits:e.getBigUint64(22,!0)}}function Fb(r,t){let e=new DataView(r.buffer,r.byteOffset+t,20);return{x:e.getInt32(0,!0),y:e.getInt32(4,!0),z:e.getInt32(8,!0),intensity:e.getUint16(12,!0),bitByte:e.getUint8(14),classification:e.getUint8(15),scanAngleRank:e.getInt8(16),userData:e.getUint8(17),pointSourceId:e.getUint16(18,!0)}}function vu(r,t){return{red:nc(r,t),green:nc(r,t+2),blue:nc(r,t+4)}}function Au(r,t){let e=new DataView(r.buffer,r.byteOffset+t,29);return{descriptorIndex:e.getUint8(0),offset:e.getBigUint64(1,!0),packetSize:e.getUint32(9,!0),returnPointBits:e.getInt32(13,!0),xBits:e.getInt32(17,!0),yBits:e.getInt32(21,!0),zBits:e.getInt32(25,!0)}}function Ob(r,t){return new DataView(r.buffer,r.byteOffset+t,8).getFloat64(0,!0)}function Eb(r,t){return BigInt.asIntN(64,Su(r)-Su(t))}function Su(r){let t=new ArrayBuffer(8),e=new DataView(t);return e.setFloat64(0,r,!0),e.getBigUint64(0,!0)}function nc(r,t){return r[t]|r[t+1]<<8}function NS(r,t){r.x=t.x,r.y=t.y,r.z=t.z,r.intensity=t.intensity,r.returns=t.returns,r.flags=t.flags,r.classification=t.classification,r.userData=t.userData,r.scanAngle=t.scanAngle,r.pointSourceId=t.pointSourceId,r.gpsTimeBits=t.gpsTimeBits}function Wo(r){return r.flags>>4&3}function Ub(r){return r.flags>>2&48|r.flags&15}function vr(r,t){return Array.from({length:r},()=>new Ot(t))}function be(r){return r&255}function RS(r){return r&255}function Xs(r){return Math.min(255,Math.max(0,r))}function Rb(r,t){let e=Math.fround(Math.fround(r)/Math.fround(t));return e>=0?Math.trunc(e+.5):Math.trunc(e-.5)}function PS(r){return r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function Pb(r){let t=r.reduce((s,i)=>s+i.byteLength,0),e=new Uint8Array(t),n=0;for(let s of r)e.set(s,n),n+=s.byteLength;return e}function Nb(r,t,e,n){for(let s=0;s<n;s++)r.setUint8(t+s,e.charCodeAt(s)||0)}var Iu,Lb,Tb,xr,Ki,Mb,Db,TS,MS,DS,CS,Jd,Qd,tp,ep,yu,rp,np,gu,sp,bu,ip,wu,op,xu,ap,kb=p(()=>{"use strict";_b();Iu={0:20,1:28,2:26,3:34,4:57,5:63,6:30,7:36,8:38,9:59,10:67},Lb=54,Tb=34,xr=500,Ki=-10,Mb=511,Db=xr-Ki+2,TS=[[0,1,2,3,4,5,3,4,4,5,5,5,5,5,5,5],[1,0,1,3,3,3,3,3,3,3,3,3,3,3,3,3],[2,1,2,4,4,4,4,4,4,4,4,3,3,3,3,3],[3,3,4,5,4,4,4,4,4,4,4,4,4,4,4,4],[4,3,4,4,5,4,4,4,4,4,4,4,4,4,4,4],[5,3,4,4,4,5,4,4,4,4,4,4,4,4,4,4],[3,3,4,4,4,4,5,4,4,4,4,4,4,4,4,4],[4,3,4,4,4,4,4,5,4,4,4,4,4,4,4,4],[4,3,4,4,4,4,4,4,5,4,4,4,4,4,4,4],[5,3,4,4,4,4,4,4,4,5,4,4,4,4,4,4],[5,3,4,4,4,4,4,4,4,4,5,4,4,4,4,4],[5,3,3,4,4,4,4,4,4,4,4,5,5,4,4,4],[5,3,3,4,4,4,4,4,4,4,4,5,5,5,4,4],[5,3,3,4,4,4,4,4,4,4,4,4,5,5,5,4],[5,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5],[5,3,3,4,4,4,4,4,4,4,4,4,4,4,5,5]],MS=[[15,14,13,12,11,10,9,8],[14,0,1,3,6,10,10,9],[13,1,2,4,7,11,11,10],[12,3,4,5,8,12,12,11],[11,6,7,8,9,13,13,12],[10,10,11,12,13,14,14,13],[9,10,11,12,13,14,15,14],[8,9,10,11,12,13,14,15]],DS=[[0,1,2,3,4,5,6,7],[1,0,1,2,3,4,5,6],[2,1,0,1,2,3,4,5],[3,2,1,0,1,2,3,4],[4,3,2,1,0,1,2,3],[5,4,3,2,1,0,1,2],[6,5,4,3,2,1,0,1],[7,6,5,4,3,2,1,0]],CS=[[0,1,2,3,4,5,6,7,7,7,7,7,7,7,7,7],[1,0,1,2,3,4,5,6,7,7,7,7,7,7,7,7],[2,1,0,1,2,3,4,5,6,7,7,7,7,7,7,7],[3,2,1,0,1,2,3,4,5,6,7,7,7,7,7,7],[4,3,2,1,0,1,2,3,4,5,6,7,7,7,7,7],[5,4,3,2,1,0,1,2,3,4,5,6,7,7,7,7],[6,5,4,3,2,1,0,1,2,3,4,5,6,7,7,7],[7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,7],[7,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7],[7,7,7,6,5,4,3,2,1,0,1,2,3,4,5,6],[7,7,7,7,6,5,4,3,2,1,0,1,2,3,4,5],[7,7,7,7,7,6,5,4,3,2,1,0,1,2,3,4],[7,7,7,7,7,7,6,5,4,3,2,1,0,1,2,3],[7,7,7,7,7,7,7,6,5,4,3,2,1,0,1,2],[7,7,7,7,7,7,7,7,6,5,4,3,2,1,0,1],[7,7,7,7,7,7,7,7,7,6,5,4,3,2,1,0]];Jd=class{encoder;changedValuesModel=new Ot(64);bitByteModels=vr(256,256);classificationModels=vr(256,256);scanAngleRankModels=vr(2,256);userDataModels=vr(256,256);intensityCompressor;pointSourceIdCompressor;xDifferenceCompressor;yDifferenceCompressor;zCompressor;lastIntensity=new Array(16).fill(0);lastHeight=new Array(8).fill(0);lastXDifferenceMedian=Array.from({length:16},()=>new Xi);lastYDifferenceMedian=Array.from({length:16},()=>new Xi);last;constructor(t,e){this.encoder=t,this.last={...e},this.intensityCompressor=new _t(t,16,4),this.pointSourceIdCompressor=new _t(t,16,1),this.xDifferenceCompressor=new _t(t,32,2),this.yDifferenceCompressor=new _t(t,32,22),this.zCompressor=new _t(t,32,20)}encode(t){let e=this.last,n=t.bitByte&7,s=t.bitByte>>3&7,i=MS[s][n],o=DS[s][n],a=(t.bitByte!==e.bitByte?32:0)|(t.intensity!==this.lastIntensity[i]?16:0)|(t.classification!==e.classification?8:0)|(t.scanAngleRank!==e.scanAngleRank?4:0)|(t.userData!==e.userData?2:0)|(t.pointSourceId!==e.pointSourceId?1:0);this.encoder.encodeSymbol(this.changedValuesModel,a),a&32&&this.encoder.encodeSymbol(this.bitByteModels[e.bitByte],t.bitByte),a&16&&(this.intensityCompressor.compress(this.lastIntensity[i],t.intensity,i<3?i:3),this.lastIntensity[i]=t.intensity),a&8&&this.encoder.encodeSymbol(this.classificationModels[e.classification],t.classification),a&4&&this.encoder.encodeSymbol(this.scanAngleRankModels[t.bitByte>>6&1],RS(t.scanAngleRank-e.scanAngleRank)),a&2&&this.encoder.encodeSymbol(this.userDataModels[e.userData],t.userData),a&1&&this.pointSourceIdCompressor.compress(e.pointSourceId,t.pointSourceId);let c=this.lastXDifferenceMedian[i].get(),l=We(t.x-e.x);this.xDifferenceCompressor.compress(c,l,s===1?1:0),this.lastXDifferenceMedian[i].add(l);let u=this.lastYDifferenceMedian[i].get(),f=Math.min(this.xDifferenceCompressor.k,20)&-2,h=We(t.y-e.y);this.yDifferenceCompressor.compress(u,h,(s===1?1:0)+f),this.lastYDifferenceMedian[i].add(h);let m=Math.min(this.xDifferenceCompressor.k+this.yDifferenceCompressor.k>>1,18)&-2;this.zCompressor.compress(this.lastHeight[o],t.z,(s===1?1:0)+m),this.lastHeight[o]=t.z,this.last={...t}}},Qd=class{encoder;gpsTimeMultiModel;gpsTime0DiffModel;gpsTime;lastGpsTime;lastGpsTimeDifference=[0,0,0,0];multiExtremeCounter=[0,0,0,0];lastGpsSequence=0;nextGpsSequence=0;constructor(t,e){this.encoder=t,this.gpsTimeMultiModel=new Ot(516),this.gpsTime0DiffModel=new Ot(6),this.gpsTime=new _t(t,32,9),this.lastGpsTime=[e,0,0,0]}encode(t){let e=this.lastGpsSequence,n=Eb(t,this.lastGpsTime[e]),s=Number(BigInt.asIntN(32,n)),i=n===BigInt(s);if(this.lastGpsTimeDifference[e]===0)if(i)s===0?this.encoder.encodeSymbol(this.gpsTime0DiffModel,0):(this.encoder.encodeSymbol(this.gpsTime0DiffModel,1),this.gpsTime.compress(0,s,0),this.lastGpsTimeDifference[e]=s,this.multiExtremeCounter[e]=0);else if(this.selectSequence(t,!1)){this.encode(t);return}else this.encoder.encodeSymbol(this.gpsTime0DiffModel,2),this.startSequence(t);else if(i){let o=this.lastGpsTimeDifference[e],a=Rb(s,o);a===1?(this.encoder.encodeSymbol(this.gpsTimeMultiModel,1),this.gpsTime.compress(o,s,1),this.multiExtremeCounter[e]=0):a>0&&a<xr?(this.encoder.encodeSymbol(this.gpsTimeMultiModel,a),this.gpsTime.compress(We(a*o),s,a<10?2:3)):a>=xr?(this.encoder.encodeSymbol(this.gpsTimeMultiModel,xr),this.gpsTime.compress(We(xr*o),s,4),this.recordExtremeDifference(e,s)):a<0&&a>Ki?(this.encoder.encodeSymbol(this.gpsTimeMultiModel,xr-a),this.gpsTime.compress(We(a*o),s,5)):a<0?(this.encoder.encodeSymbol(this.gpsTimeMultiModel,xr-Ki),this.gpsTime.compress(We(Ki*o),s,6),this.recordExtremeDifference(e,s)):(this.encoder.encodeSymbol(this.gpsTimeMultiModel,0),this.gpsTime.compress(0,s,7),this.recordExtremeDifference(e,s))}else if(this.selectSequence(t,!0)){this.encode(t);return}else this.encoder.encodeSymbol(this.gpsTimeMultiModel,Db),this.startSequence(t);this.lastGpsTime[this.lastGpsSequence]=t}selectSequence(t,e){for(let n=1;n<4;n++){let s=this.lastGpsSequence+n&3,i=Eb(t,this.lastGpsTime[s]);if(i===BigInt.asIntN(32,i))return this.encoder.encodeSymbol(e?this.gpsTimeMultiModel:this.gpsTime0DiffModel,e?Db+n:n+2),this.lastGpsSequence=s,!0}return!1}startSequence(t){let e=Su(this.lastGpsTime[this.lastGpsSequence]),n=Su(t);this.gpsTime.compress(Number(BigInt.asIntN(32,e>>32n)),Number(BigInt.asIntN(32,n>>32n)),8),this.encoder.writeInt(Number(n&0xffffffffn)),this.nextGpsSequence=this.nextGpsSequence+1&3,this.lastGpsSequence=this.nextGpsSequence,this.lastGpsTimeDifference[this.lastGpsSequence]=0,this.multiExtremeCounter[this.lastGpsSequence]=0}recordExtremeDifference(t,e){this.multiExtremeCounter[t]++,this.multiExtremeCounter[t]>3&&(this.multiExtremeCounter[t]=0,this.lastGpsTimeDifference[t]=e)}},tp=class{encoder;usedModel=new Ot(128);differenceModels=vr(6,256);red;green;blue;constructor(t,e){this.encoder=t,this.red=e.red,this.green=e.green,this.blue=e.blue}encode(t){let e=this.red,n=this.green,s=this.blue,i=((t.red&255)!==(e&255)?1:0)|((t.red&65280)!==(e&65280)?2:0)|((t.green&255)!==(n&255)?4:0)|((t.green&65280)!==(n&65280)?8:0)|((t.blue&255)!==(s&255)?16:0)|((t.blue&65280)!==(s&65280)?32:0);((t.red&255)!==(t.green&255)||(t.red&255)!==(t.blue&255)||(t.red&65280)!==(t.green&65280)||(t.red&65280)!==(t.blue&65280))&&(i|=64),this.encoder.encodeSymbol(this.usedModel,i);let o=0,a=0;i&1&&(o=(t.red&255)-(e&255),this.encoder.encodeSymbol(this.differenceModels[0],be(o))),i&2&&(a=(t.red>>8)-(e>>8),this.encoder.encodeSymbol(this.differenceModels[1],be(a))),i&64&&(i&4&&this.encoder.encodeSymbol(this.differenceModels[2],be((t.green&255)-Xs(o+(n&255)))),i&16&&(o=Math.trunc((o+(t.green&255)-(n&255))/2),this.encoder.encodeSymbol(this.differenceModels[4],be((t.blue&255)-Xs(o+(s&255))))),i&8&&this.encoder.encodeSymbol(this.differenceModels[3],be((t.green>>8)-Xs(a+(n>>8)))),i&32&&(a=Math.trunc((a+(t.green>>8)-(n>>8))/2),this.encoder.encodeSymbol(this.differenceModels[5],be((t.blue>>8)-Xs(a+(s>>8)))))),this.red=t.red,this.green=t.green,this.blue=t.blue}},ep=class{encoder;descriptorModel;offsetDifferenceModels;offsetDifferenceCompressor;packetSizeCompressor;returnPointCompressor;vectorCompressor;last;lastOffsetDifference=0;lastOffsetDifferenceSymbol=0;constructor(t,e){this.encoder=t,this.descriptorModel=new Ot(256),this.offsetDifferenceModels=vr(4,4),this.offsetDifferenceCompressor=new _t(t,32,1),this.packetSizeCompressor=new _t(t,32,1),this.returnPointCompressor=new _t(t,32,1),this.vectorCompressor=new _t(t,32,3),this.last={...e}}encode(t){let e=this.last;this.encoder.encodeSymbol(this.descriptorModel,t.descriptorIndex);let n=0;if(t.offset===e.offset)n=0;else if(t.offset===e.offset+BigInt(e.packetSize))n=1;else{let s=BigInt.asIntN(64,t.offset-e.offset);s===BigInt.asIntN(32,s)?n=2:n=3}if(this.encoder.encodeSymbol(this.offsetDifferenceModels[this.lastOffsetDifferenceSymbol],n),this.lastOffsetDifferenceSymbol=n,n===2){let s=Number(BigInt.asIntN(32,t.offset-e.offset));this.offsetDifferenceCompressor.compress(this.lastOffsetDifference,s,0),this.lastOffsetDifference=s}n===3&&(this.encoder.writeInt(Number(t.offset&0xffffffffn)),this.encoder.writeInt(Number(t.offset>>32n))),this.packetSizeCompressor.compress(e.packetSize,t.packetSize,0),this.returnPointCompressor.compress(e.returnPointBits,t.returnPointBits,0),this.vectorCompressor.compress(e.xBits,t.xBits,0),this.vectorCompressor.compress(e.yBits,t.yBits,1),this.vectorCompressor.compress(e.zBits,t.zBits,2),this.last={...t}}},yu=class{packet;descriptorModel=new Ot(256);offsetDifferenceModels=vr(4,4);offsetDifferenceCompressor;packetSizeCompressor;returnPointCompressor;vectorCompressor;lastOffsetDifference=0;lastOffsetDifferenceSymbol=0;haveLast=!1;constructor(t,e){this.packet={...e},this.offsetDifferenceCompressor=new _t(t,32,1),this.packetSizeCompressor=new _t(t,32,1),this.returnPointCompressor=new _t(t,32,1),this.vectorCompressor=new _t(t,32,3),this.haveLast=!0}},rp=class{encoder=new $t;contexts=new Array(4).fill(null);itemVersion;lastChannel;constructor(t,e,n){this.itemVersion=n,this.lastChannel=e,this.contexts[e]=new yu(this.encoder,t)}encode(t,e){let n=this.contexts[this.lastChannel],s=this.contexts[e],i=s;e!==this.lastChannel&&(s?this.itemVersion<4&&(i=s,s=n):(s=new yu(this.encoder,n.packet),this.contexts[e]=s,i=s),this.lastChannel=e),this.encodePacket(i,s,t)}finish(){return this.encoder.finish()}encodePacket(t,e,n){let s=e.packet;this.encoder.encodeSymbol(t.descriptorModel,n.descriptorIndex);let i=0;if(n.offset===s.offset?i=0:n.offset===s.offset+BigInt(s.packetSize)?i=1:BigInt.asIntN(64,n.offset-s.offset)===BigInt.asIntN(32,n.offset-s.offset)?i=2:i=3,this.encoder.encodeSymbol(t.offsetDifferenceModels[t.lastOffsetDifferenceSymbol],i),t.lastOffsetDifferenceSymbol=i,i===2){let o=Number(BigInt.asIntN(32,n.offset-s.offset));t.offsetDifferenceCompressor.compress(t.lastOffsetDifference,o,0),t.lastOffsetDifference=o}else i===3&&(this.encoder.writeInt(Number(n.offset&0xffffffffn)),this.encoder.writeInt(Number(n.offset>>32n)));t.packetSizeCompressor.compress(s.packetSize,n.packetSize,0),t.returnPointCompressor.compress(s.returnPointBits,n.returnPointBits,0),t.vectorCompressor.compress(s.xBits,n.xBits,0),t.vectorCompressor.compress(s.yBits,n.yBits,1),t.vectorCompressor.compress(s.zBits,n.zBits,2),e.packet={...n}}},np=class{encoder;models;last;constructor(t,e){this.encoder=t,this.models=vr(e.byteLength,256),this.last=new Uint8Array(e)}encode(t){for(let e=0;e<t.byteLength;e++){let n=t[e]-this.last[e];this.encoder.encodeSymbol(this.models[e],be(n)),this.last[e]=t[e]}}},gu=class{changedValuesModels=vr(8,128);scannerChannelModel=new Ot(3);returnNumberGpsSameModel=new Ot(13);numberReturnsModels=new Array(16).fill(null);returnNumberModels=new Array(16).fill(null);classificationModels=new Array(64).fill(null);flagModels=new Array(64).fill(null);userDataModels=new Array(64).fill(null);gpsTimeMultiplierModel=new Ot(515);gpsTimeZeroDifferenceModel=new Ot(5);xDifferenceCompressor;yDifferenceCompressor;zCompressor;intensityCompressor;scanAngleCompressor;pointSourceIdCompressor;gpsTimeCompressor;lastXDifferenceMedian=Array.from({length:12},()=>new Xi);lastYDifferenceMedian=Array.from({length:12},()=>new Xi);lastZ;lastIntensity;lastGpsTimeBits;lastGpsTimeDifference=new Array(4).fill(0);gpsTimeExtremeCounter=new Array(4).fill(0);lastGpsSequence=0;nextGpsSequence=0;gpsTimeChanged=!1;last;constructor(t,e){this.last={...t},this.xDifferenceCompressor=new _t(e.xy,32,2),this.yDifferenceCompressor=new _t(e.xy,32,22),this.zCompressor=new _t(e.z,32,20),this.intensityCompressor=new _t(e.intensity,16,4),this.scanAngleCompressor=new _t(e.scanAngle,16,2),this.pointSourceIdCompressor=new _t(e.pointSourceId,16,1),this.gpsTimeCompressor=new _t(e.gpsTime,32,9),this.lastZ=new Array(8).fill(t.z),this.lastIntensity=new Array(8).fill(t.intensity),this.lastGpsTimeBits=[t.gpsTimeBits,0n,0n,0n]}},sp=class{layers={xy:new $t,z:new $t,classification:new $t,flags:new $t,intensity:new $t,scanAngle:new $t,userData:new $t,pointSourceId:new $t,gpsTime:new $t};contexts=new Array(4).fill(null);currentScannerChannel;changed={classification:!1,flags:!1,intensity:!1,scanAngle:!1,userData:!1,pointSourceId:!1,gpsTime:!1};constructor(t){this.currentScannerChannel=Wo(t),this.contexts[this.currentScannerChannel]=new gu(t,this.layers)}encode(t){let e=this.contexts[this.currentScannerChannel],n=e.last,s=Wo(t);s!==this.currentScannerChannel&&this.contexts[s]&&(n=this.contexts[s].last);let i=t.pointSourceId!==n.pointSourceId,o=t.gpsTimeBits!==n.gpsTimeBits,a=t.scanAngle!==n.scanAngle,c=n.returns>>4,l=n.returns&15,u=t.returns>>4,f=t.returns&15,h=(l===1?1:0)|(l>=c?2:0)|(e.gpsTimeChanged?4:0),m=(s!==this.currentScannerChannel?64:0)|(i?32:0)|(o?16:0)|(a?8:0)|(u!==c?4:0);f!==l&&(f===(l+1)%16?m|=1:f===(l+15)%16?m|=2:m|=3),this.layers.xy.encodeSymbol(e.changedValuesModels[h],m);let y=0;if(s!==this.currentScannerChannel){let xt=s-this.currentScannerChannel;this.layers.xy.encodeSymbol(e.scannerChannelModel,(xt+3)%4),this.contexts[s]||=new gu(e.last,this.layers),this.currentScannerChannel=s,y=s,n=this.contexts[s].last}let g=this.contexts[this.currentScannerChannel];if(u!==c){let xt=g.numberReturnsModels[c];xt||(xt=new Ot(16),g.numberReturnsModels[c]=xt),this.layers.xy.encodeSymbol(xt,u)}if((m&3)===3)if(o){let xt=g.returnNumberModels[l];xt||(xt=new Ot(16),g.returnNumberModels[l]=xt),this.layers.xy.encodeSymbol(xt,f)}else{let xt=f-l;this.layers.xy.encodeSymbol(g.returnNumberGpsSameModel,(xt+14)%16)}let x=TS[u][f],I=CS[u][f],q=(f===1?2:0)|(f>=u?1:0),T=x<<1|(o?1:0),b=g.lastXDifferenceMedian[T].get(),C=We(t.x-n.x);g.xDifferenceCompressor.compress(b,C,u===1?1:0),g.lastXDifferenceMedian[T].add(C);let _=g.lastYDifferenceMedian[T].get(),$=We(t.y-n.y),X=(u===1?1:0)|Math.min(g.xDifferenceCompressor.k,20)&-2;g.yDifferenceCompressor.compress(_,$,X),g.lastYDifferenceMedian[T].add($);let ft=(u===1?1:0)|Math.min(g.xDifferenceCompressor.k+g.yDifferenceCompressor.k>>1,18)&-2;g.zCompressor.compress(g.lastZ[I],t.z,ft),g.lastZ[I]=t.z,t.classification!==n.classification&&(this.changed.classification=!0);let dt=(n.classification&31)<<1|(q===3?1:0),It=g.classificationModels[dt];It||(It=new Ot(256),g.classificationModels[dt]=It),this.layers.classification.encodeSymbol(It,t.classification);let se=Ub(n),rt=Ub(t);rt!==se&&(this.changed.flags=!0);let tt=g.flagModels[se];tt||(tt=new Ot(64),g.flagModels[se]=tt),this.layers.flags.encodeSymbol(tt,rt),t.intensity!==n.intensity&&(this.changed.intensity=!0);let Ye=q<<1|(o?1:0);g.intensityCompressor.compress(g.lastIntensity[Ye],t.intensity,q),g.lastIntensity[Ye]=t.intensity,a&&(this.changed.scanAngle=!0,g.scanAngleCompressor.compress(n.scanAngle,t.scanAngle,o?1:0)),t.userData!==n.userData&&(this.changed.userData=!0);let Ne=n.userData>>2,Ze=g.userDataModels[Ne];return Ze||(Ze=new Ot(256),g.userDataModels[Ne]=Ze),this.layers.userData.encodeSymbol(Ze,t.userData),i&&(this.changed.pointSourceId=!0,g.pointSourceIdCompressor.compress(n.pointSourceId,t.pointSourceId)),o&&(this.changed.gpsTime=!0,this.encodeGpsTime(g,t.gpsTimeBits)),NS(g.last,t),g.gpsTimeChanged=o,y}finish(){return[this.layers.xy.finish(),this.layers.z.finish(),this.changed.classification?this.layers.classification.finish():new Uint8Array(0),this.changed.flags?this.layers.flags.finish():new Uint8Array(0),this.changed.intensity?this.layers.intensity.finish():new Uint8Array(0),this.changed.scanAngle?this.layers.scanAngle.finish():new Uint8Array(0),this.changed.userData?this.layers.userData.finish():new Uint8Array(0),this.changed.pointSourceId?this.layers.pointSourceId.finish():new Uint8Array(0),this.changed.gpsTime?this.layers.gpsTime.finish():new Uint8Array(0)]}encodeGpsTime(t,e){let n=t.lastGpsSequence,s=BigInt.asIntN(64,e-t.lastGpsTimeBits[n]),i=Number(BigInt.asIntN(32,s)),o=s===BigInt(i);if(t.lastGpsTimeDifference[n]===0)if(o)this.layers.gpsTime.encodeSymbol(t.gpsTimeZeroDifferenceModel,0),t.gpsTimeCompressor.compress(0,i,0),t.lastGpsTimeDifference[n]=i,t.gpsTimeExtremeCounter[n]=0;else if(this.selectGpsTimeSequence(t,e,!1)){this.encodeGpsTime(t,e);return}else this.layers.gpsTime.encodeSymbol(t.gpsTimeZeroDifferenceModel,1),this.startGpsTimeSequence(t,e);else if(o){let a=t.lastGpsTimeDifference[n],c=Rb(i,a);c===1?(this.layers.gpsTime.encodeSymbol(t.gpsTimeMultiplierModel,1),t.gpsTimeCompressor.compress(a,i,1),t.gpsTimeExtremeCounter[n]=0):c>0?c<xr?(this.layers.gpsTime.encodeSymbol(t.gpsTimeMultiplierModel,c),t.gpsTimeCompressor.compress(We(c*a),i,c<10?2:3)):(this.layers.gpsTime.encodeSymbol(t.gpsTimeMultiplierModel,xr),t.gpsTimeCompressor.compress(We(xr*a),i,4),this.recordExtremeGpsDifference(t,n,i)):c<0?c>Ki?(this.layers.gpsTime.encodeSymbol(t.gpsTimeMultiplierModel,xr-c),t.gpsTimeCompressor.compress(We(c*a),i,5)):(this.layers.gpsTime.encodeSymbol(t.gpsTimeMultiplierModel,xr-Ki),t.gpsTimeCompressor.compress(We(Ki*a),i,6),this.recordExtremeGpsDifference(t,n,i)):(this.layers.gpsTime.encodeSymbol(t.gpsTimeMultiplierModel,0),t.gpsTimeCompressor.compress(0,i,7),this.recordExtremeGpsDifference(t,n,i))}else if(this.selectGpsTimeSequence(t,e,!0)){this.encodeGpsTime(t,e);return}else this.layers.gpsTime.encodeSymbol(t.gpsTimeMultiplierModel,Mb),this.startGpsTimeSequence(t,e);t.lastGpsTimeBits[t.lastGpsSequence]=e}selectGpsTimeSequence(t,e,n){for(let s=1;s<4;s++){let i=t.lastGpsSequence+s&3,o=BigInt.asIntN(64,e-t.lastGpsTimeBits[i]);if(o===BigInt.asIntN(32,o)){let a=n?Mb+s:s+1,c=n?t.gpsTimeMultiplierModel:t.gpsTimeZeroDifferenceModel;return this.layers.gpsTime.encodeSymbol(c,a),t.lastGpsSequence=i,!0}}return!1}startGpsTimeSequence(t,e){let n=t.lastGpsTimeBits[t.lastGpsSequence];t.gpsTimeCompressor.compress(Number(BigInt.asIntN(32,n>>32n)),Number(BigInt.asIntN(32,e>>32n)),8),this.layers.gpsTime.writeInt(Number(e&0xffffffffn)),t.nextGpsSequence=t.nextGpsSequence+1&3,t.lastGpsSequence=t.nextGpsSequence,t.lastGpsTimeDifference[t.lastGpsSequence]=0,t.gpsTimeExtremeCounter[t.lastGpsSequence]=0}recordExtremeGpsDifference(t,e,n){t.gpsTimeExtremeCounter[e]++,t.gpsTimeExtremeCounter[e]>3&&(t.lastGpsTimeDifference[e]=n,t.gpsTimeExtremeCounter[e]=0)}},bu=class{red;green;blue;usedModel=new Ot(128);differenceModels=vr(6,256);constructor(t){this.red=t.red,this.green=t.green,this.blue=t.blue}},ip=class{encoder=new $t;contexts=new Array(4).fill(null);currentContext;changed=!1;constructor(t,e){this.currentContext=e,this.contexts[e]=new bu(t)}encode(t,e){let n=this.contexts[this.currentContext];e!==this.currentContext&&(this.currentContext=e,this.contexts[e]||(this.contexts[e]=new bu({red:n.red,green:n.green,blue:n.blue}),n=this.contexts[e]));let s=this.contexts[this.currentContext],i=((t.red&255)!==(n.red&255)?1:0)|((t.red&65280)!==(n.red&65280)?2:0)|((t.green&255)!==(n.green&255)?4:0)|((t.green&65280)!==(n.green&65280)?8:0)|((t.blue&255)!==(n.blue&255)?16:0)|((t.blue&65280)!==(n.blue&65280)?32:0);((t.red&255)!==(t.green&255)||(t.red&255)!==(t.blue&255)||(t.red&65280)!==(t.green&65280)||(t.red&65280)!==(t.blue&65280))&&(i|=64),this.encoder.encodeSymbol(s.usedModel,i);let o=0,a=0;if(i&1&&(o=(t.red&255)-(n.red&255),this.encoder.encodeSymbol(s.differenceModels[0],be(o))),i&2&&(a=(t.red>>8)-(n.red>>8),this.encoder.encodeSymbol(s.differenceModels[1],be(a))),i&64){if(i&4){let c=(t.green&255)-Xs(o+(n.green&255));this.encoder.encodeSymbol(s.differenceModels[2],be(c))}if(i&16){o=Math.trunc((o+(t.green&255)-(n.green&255))/2);let c=(t.blue&255)-Xs(o+(n.blue&255));this.encoder.encodeSymbol(s.differenceModels[4],be(c))}if(i&8){let c=(t.green>>8)-Xs(a+(n.green>>8));this.encoder.encodeSymbol(s.differenceModels[3],be(c))}if(i&32){a=Math.trunc((a+(t.green>>8)-(n.green>>8))/2);let c=(t.blue>>8)-Xs(a+(n.blue>>8));this.encoder.encodeSymbol(s.differenceModels[5],be(c))}}this.changed||=i!==0,n.red=t.red,n.green=t.green,n.blue=t.blue}finish(){return this.changed?this.encoder.finish():new Uint8Array(0)}},wu=class{value;usedModel=new Ot(4);differenceModels=vr(2,256);constructor(t){this.value=t}},op=class{encoder=new $t;contexts=new Array(4).fill(null);currentContext;changed=!1;constructor(t,e){this.currentContext=e,this.contexts[e]=new wu(t)}encode(t,e){let n=this.contexts[this.currentContext];e!==this.currentContext&&(this.currentContext=e,this.contexts[e]||(this.contexts[e]=new wu(n.value),n=this.contexts[e]));let s=this.contexts[this.currentContext],i=((t&255)!==(n.value&255)?1:0)|((t&65280)!==(n.value&65280)?2:0);this.encoder.encodeSymbol(s.usedModel,i),i&1&&this.encoder.encodeSymbol(s.differenceModels[0],be((t&255)-(n.value&255))),i&2&&this.encoder.encodeSymbol(s.differenceModels[1],be((t>>8)-(n.value>>8))),this.changed||=i!==0,n.value=t}finish(){return this.changed?this.encoder.finish():new Uint8Array(0)}},xu=class{values;models;constructor(t){this.values=t.slice(),this.models=vr(t.byteLength,256)}},ap=class{encoders;contexts=new Array(4).fill(null);changed;currentContext;constructor(t,e){this.encoders=Array.from({length:t.byteLength},()=>new $t),this.changed=new Array(t.byteLength).fill(!1),this.currentContext=e,this.contexts[e]=new xu(t)}encode(t,e){let n=this.contexts[this.currentContext];e!==this.currentContext&&(this.currentContext=e,this.contexts[e]||(this.contexts[e]=new xu(n.values),n=this.contexts[e]));let s=this.contexts[this.currentContext];for(let i=0;i<t.byteLength;i++){let o=t[i]-n.values[i];this.encoders[i].encodeSymbol(s.models[i],be(o)),o&&(this.changed[i]=!0,n.values[i]=t[i])}}finish(){return this.encoders.map((t,e)=>this.changed[e]?t.finish():new Uint8Array(0))}}});function sc(r){return{...r,batchType:"data",length:r.data.numRows}}var zb=p(()=>{"use strict"});var Yo=p(()=>{"use strict";ob();ab();ub();Bb();kb();zb()});function Vb(r,t){let e=kS(r);return Gi(t,e)}function kS(r){let t={};return t.las_pointsOffset=r.pointsOffset.toString(10),t.las_pointsFormatId=r.pointsFormatId.toString(10),t.las_pointsStructSize=r.pointsStructSize.toString(10),t.las_pointsCount=r.pointsCount.toString(10),t.las_scale=JSON.stringify(r.scale),t.las_offset=JSON.stringify(r.offset),r.maxs!==void 0&&(t.las_maxs=JSON.stringify(r.maxs)),r.mins!==void 0&&(t.las_mins=JSON.stringify(r.mins)),t.las_totalToRead=r.totalToRead.toString(10),t.las_pointsFortotalReadmatId=r.totalRead.toString(10),r.versionAsString!==void 0&&(t.las_versionAsString=r.versionAsString),r.isCompressed!==void 0&&(t.las_isCompressed=r.isCompressed.toString()),t}var Gb=p(()=>{"use strict";or()});function jb(r,t){let e=t.vlrs.find(y=>y.userId==="lascompatible"&&y.recordId===22204);if(!e)return;if(!["1.0","1.1","1.2","1.3"].includes(r.versionAsString||"")||![1,3,4,5].includes(r.pointsFormatId))throw new Error("LASLoader: compatibility mode requires a legacy LAS point format");let n=new DataView(e.data.buffer,e.data.byteOffset,e.data.byteLength);if(n.byteLength<4)throw new Error("LASLoader: truncated LASzip compatibility VLR");let s=n.getUint16(2,!0);if(s!==3&&s!==4||n.byteLength!==(s===3?156:174))throw new Error(`LASLoader: unsupported LASzip compatibility VLR version ${s} or length`);let i=new Map,o=0;for(let y of t.extraBytes){let g=y.dataType>20?y.dataType-20:y.dataType>10?y.dataType-10:y.dataType,x=y.dataType>20?3:y.dataType>10?2:1,I=y.dataType===0?y.options:g<=2?x:g<=4?2*x:g<=6||g===9?4*x:8*x;if(y.dataType>30||!I)throw new Error("LASLoader: invalid compatibility Extra Bytes layout");i.set(y.name,{byteOffset:o,dataType:y.dataType}),o+=I}let a={1:28,3:34,4:57,5:63}[r.pointsFormatId];if(o!==r.pointsStructSize-a)throw new Error("LASLoader: compatibility descriptors do not match point record length");let c=ic(i,"LAS 1.4 scan angle",4),l=ic(i,"LAS 1.4 extended returns",1),u=ic(i,"LAS 1.4 classification",1),f=ic(i,"LAS 1.4 flags and channel",1),h=i.has("LAS 1.4 NIR band")?ic(i,"LAS 1.4 NIR band",3):void 0,m=r.pointsFormatId===1?6:r.pointsFormatId===3?h===void 0?7:8:r.pointsFormatId===4?9:10;if(r.pointsFormatId===5&&h===void 0)throw new Error("LASLoader: compatibility waveform color points require NIR");return{pointDataRecordFormat:m,version:s===3?"1.4":"1.5",scanAngleByteOffset:c,returnsByteOffset:l,classificationByteOffset:u,flagsByteOffset:f,nirByteOffset:h}}function ic(r,t,e){let n=r.get(t);if(!n||n.dataType!==e)throw new Error(`LASLoader: missing or invalid compatibility field ${t}`);return n.byteOffset}function fp(r,t,e,n,s){if(!s.classifications&&!s.returnNumbers&&!s.numberOfReturns&&!s.scanAngles&&!s.overlapFlags&&!s.scannerChannels&&!s.nir)return;let i=r.getUint8(t+n.returnsByteOffset),o=r.getUint8(t+n.flagsByteOffset);if(s.classifications&&(s.classifications[e]+=r.getUint8(t+n.classificationByteOffset)),s.returnNumbers&&(s.returnNumbers[e]+=i>>4),s.numberOfReturns&&(s.numberOfReturns[e]+=i&15),s.scanAngles){let a=s.scanAngles[e],c=Math.fround(a/Math.fround(.006)),l=Math.sign(c)*Math.floor(Math.abs(c)+.5);s.scanAngles[e]=l+r.getInt16(t+n.scanAngleByteOffset,!0)}s.overlapFlags&&(s.overlapFlags[e]=o&1),s.scannerChannels&&(s.scannerChannels[e]=o>>1&3),s.nir&&n.nirByteOffset!==void 0&&(s.nir[e]=r.getUint16(t+n.nirByteOffset,!0))}var qb=p(()=>{"use strict"});function Wb(r){if(r.byteLength%192!==0)throw new Error(`LAS Extra Bytes VLR length ${r.byteLength} is not a multiple of 192`);let t=[],e=new DataView(r.buffer,r.byteOffset,r.byteLength);for(let n=0;n<r.byteLength;n+=192){let s=[e.getFloat64(n+112,!0),e.getFloat64(n+120,!0),e.getFloat64(n+128,!0)],i=[e.getFloat64(n+136,!0),e.getFloat64(n+144,!0),e.getFloat64(n+152,!0)];t.push({dataType:r[n+2],options:r[n+3],name:$b(r,n+4,32),description:$b(r,n+160,32),scale:s[0],offset:i[0],scales:s,offsets:i,data:r.slice(n,n+192)})}return t}function Yb(r,t,e){let n=0,s=new Set,i=[];for(let o=0;o<t.length;o++){let a=t[o],c=VS(a.dataType),l=GS(a.dataType),f=jS(c)*l;if(a.dataType<1||a.dataType>30||!f)throw new Error(`Unsupported typed LAS Extra Bytes data type ${a.dataType}`);let h=`EXTRA_BYTES_${zS(a.name)}`;h==="EXTRA_BYTES_"&&(h=`EXTRA_BYTES_${o}`);let m=h,y=1;for(;s.has(h);)h=`${m}_${y++}`;s.add(h);let g=a.options&8?a.scales.slice(0,l):new Array(l).fill(1),x=a.options&16?a.offsets.slice(0,l):new Array(l).fill(0),q=c!==10&&(c===7||c===8?g.some(T=>T!==1)||x.some(T=>T!==0):!!(a.options&24));i.push({name:h,value:hp(c,r*l,q),size:l,scalarDataType:c,byteOffset:n,byteLength:f,outputFloat64:q,scales:g,offsets:x}),n+=f}if(n!==e)throw new Error(`LAS Extra Bytes descriptors use ${n} bytes; point records provide ${e}`);return i}function $b(r,t,e){let n=new TextDecoder().decode(r.subarray(t,t+e)),s=n.length;for(;s>0&&n[s-1]==="\0";)s--;return n.slice(0,s).trim()}function zS(r){return r.trim().replace(/[^A-Za-z0-9_]+/g,"_")}function VS(r){return r>20?r-20:r>10?r-10:r}function GS(r){return r>20?3:r>10?2:1}function jS(r){return r<=2?1:r<=4?2:r<=6||r===9?4:r===7||r===8||r===10?8:0}function qS(r,t,e){switch(e){case 1:return r.getUint8(t);case 2:return r.getInt8(t);case 3:return r.getUint16(t,!0);case 4:return r.getInt16(t,!0);case 5:return r.getUint32(t,!0);case 6:return r.getInt32(t,!0);case 7:return r.getBigUint64(t,!0);case 8:return r.getBigInt64(t,!0);case 9:return r.getFloat32(t,!0);case 10:return r.getFloat64(t,!0);default:throw new Error(`Unsupported typed LAS Extra Bytes scalar data type ${e}`)}}function hp(r,t,e){if(e&&r!==10)return new Float64Array(t);switch(r){case 1:return new Uint8Array(t);case 2:return new Int8Array(t);case 3:return new Uint16Array(t);case 4:return new Int16Array(t);case 5:return new Uint32Array(t);case 6:return new Int32Array(t);case 7:return new BigUint64Array(t);case 8:return new BigInt64Array(t);case 9:return new Float32Array(t);case 10:return new Float64Array(t);default:throw new Error(`Unsupported typed LAS Extra Bytes scalar data type ${r}`)}}function dp(r,t,e,n,s){let i=qS(r,t,e.scalarDataType);e.value instanceof BigInt64Array||e.value instanceof BigUint64Array?e.value[n]=i:e.value[n]=Number(i)*e.scales[s]+e.offsets[s]}var Zb=p(()=>{"use strict"});function Js(r,t,e){return{pointDataRecordFormat:r.pointsFormatId,pointDataRecordLength:r.pointsStructSize,pointCount:e,point10ItemVersion:t.items.find(n=>n.type===6)?.version,gpsTime11ItemVersion:t.items.find(n=>n.type===7)?.version,rgb12ItemVersion:t.items.find(n=>n.type===8)?.version,byteItemVersion:t.items.find(n=>n.type===0)?.version,point14ItemVersion:t.point14ItemVersion??void 0,rgb14ItemVersion:t.rgb14ItemVersion??void 0,wavePacketItemVersion:t.wavePacketItemVersion??void 0,byte14ItemVersion:t.byte14ItemVersion??void 0}}function Qb(r,t={}){let e=iw(r);if(e.isCompressed){let s=new Uint8Array(r),i=wp(s,e);if(xp(e,i),e.pointsFormatId<=5||e.pointsFormatId>=6&&e.pointsFormatId<=10)return KS(s,e,i,t);let o=oI(r,e,i),a=e.pointsCount;return _u(o,{...e,pointsOffset:0,pointsCount:a,totalToRead:a,totalRead:a},t)}let n=e.pointsCount;return _u(r,{...e,totalToRead:n,totalRead:n},t)}function tw(r,t,e){if(t.pointDataRecordFormat<6||t.pointDataRecordFormat>8)throw new Error(`LASLoader: standalone Arrow chunk decode supports PDRF 6-8; received ${t.pointDataRecordFormat}`);let n=t.pointCount,s={pointsOffset:0,pointsFormatId:t.pointDataRecordFormat,pointsStructSize:t.pointDataRecordLength,pointsCount:n,scale:t.scale,offset:t.offset,maxs:[0,0,0],mins:[0,0,0],totalToRead:n,totalRead:n,hasColor:ow(t.pointDataRecordFormat),versionAsString:"1.4",isCompressed:!0,headerSize:Jb,vlrCount:0},i=Du(n,s,e);if(i.waveforms||i.extraBytes||i.typedExtraBytes)throw new Error("LASLoader: standalone Arrow chunk decode only supports direct LAZ columns");let a=jr(r,t).decodeIntoPointData(i.target,n);if(a!==n)throw new Error(`LASLoader: standalone LAZ chunk produced ${a} points; expected ${n}`);return ew(s,i,n,e,!0)}function KS(r,t,e,n){let s=t.pointsCount,i=Du(s,t,n),o=vp(r,t,e,n),a=0,c=t.pointsOffset+(e.compressor===1?0:Wt);for(let l of o)JS(r,c,l.byteLength,l.pointCount,t,e,i,a),c+=l.byteLength,a+=l.pointCount;if(a!==s)throw new Error(`LASLoader: decoded ${a} LAZ points; expected ${s}`);return ew(t,i,s,n)}function ew(r,t,e,n,s=!1){let i=s&&t.rawColors?t.rawColors:t.colors?t.colors:t.rawColors?fw(t.rawColors,e,n):null;return pp({...r,pointsOffset:0,pointsCount:e,totalRead:e},t.positions,i,t.intensities,t.classifications,t.syntheticFlags,t.keyPointFlags,t.withheldFlags,t.overlapFlags,t.gpsTimes,t.nir,t.scanAngles,t.userData,t.pointSourceIds,t.returnNumbers,t.numberOfReturns,t.scannerChannels,t.scanDirectionFlags,t.edgeOfFlightLines,t.waveforms,t.extraBytes,t.typedExtraBytes)}function JS(r,t,e,n,s,i,o,a){let c=r.subarray(t,t+e);if(c.byteLength!==e)throw new it("LASLoader: truncated LAZ chunk");let l=jr(c,Js(s,i,n));o.target.pointOffset=a;let u=l.decodeIntoPointData(o.target,n);if(u!==n)throw new Error(`LASLoader: decoded ${u} points from a ${n}-point LAZ chunk`);Sp(o,a,n)}async function*rw(r,t={}){let e=Ho(t),n=qI(r),s=new Uint8Array(0),i=0,o=null,a=0,c=0;for(;;){let l=await n.next();if(l.done)break;let u=l.value;if(s=hw(s,_p(u)),o||(o=jI(s,i),o&&(o.totalToRead=o.pointsCount)),!!o){if(o.isCompressed){yield*eI(s,n,o,t);return}for(let f of VI(s,i,o,a,c,e))a=f.sourcePointIndex,c=f.totalRead,s=f.pending,i=f.absoluteOffset,yield _u(f.arrayBuffer,f.header,t)}}if(!o)throw new Error("LASLoader: incomplete LAS header");if(c<o.totalToRead)throw new Error("LASLoader: truncated LAS point data")}async function*QS(r,t,e,n,s){if(n.variableChunks){let m=await BI(r,t);yield*sw(m,e,n,s);return}if(e.pointsFormatId<=5){yield*tI(r,t,e,n,s);return}let i={...e,totalToRead:e.pointsCount},o=Ho(s),a=Mu(o,e.pointsStructSize,Cu(s)),c=0,l=[],u=new js;u.write(r),await Qi(u,t,e.pointsOffset+Wt,"LASLoader: incomplete compressed LAZ point data"),u.skip(e.pointsOffset);let f=Fu(u.getDataView(Wt));for(;c<e.pointsCount;){let m=Math.min(n.chunkSize,e.pointsCount-c),y=Js(e,n,m),g=await MI(u,t,y);l.push(g),Ip(u,g,a.stats);let x=u.readBytes(g);s.las?.recoverMissingChunkTable&&f===e.pointsOffset&&Ap(x,y);for(let I of Bp(x,y,i,a))yield I;c+=m}await Tu(u,t,e,n,f,l,s);let h=Ji(i,a);h&&(yield h)}async function*tI(r,t,e,n,s={}){let i={...e,totalToRead:e.pointsCount},o=Ho(s),a=Mu(o,e.pointsStructSize,Cu(s)),c=[],l=new js;l.write(r),await Qi(l,t,e.pointsOffset+(n.compressor===1?0:Wt),"LASLoader: incomplete compressed LAZ point data"),l.skip(e.pointsOffset);let u=n.compressor===1?0:Fu(l.getDataView(Wt)),f=0;for(;f<e.pointsCount;){let m=n.compressor===1?e.pointsCount:Math.min(n.chunkSize,e.pointsCount-f),y=Js(e,n,m),g=jr(new Uint8Array(0),y),x=0,I=0,q=!1;for(;g.remainingPointCount>0;){let T=l.getAvailableByteLength(),b=nw(T,x,g.requiredInputByteLength-I);if(b>x){let X=l.checkpoint();l.skip(x);let ft=b-x;Ip(l,ft,a.stats),g.feed(l.readBytes(ft)),l.restore(X),x=b}let C=o-a.batchPointCount,_=g.decodeAvailableInto(a.rawBatch,a.batchPointCount*e.pointsStructSize,C,q);if(_>0){if(n.compressor===1){let X=g.compressedByteOffset-I;l.skip(X),x-=X,I=g.compressedByteOffset,g.discardConsumedInput()}if(a.batchPointCount+=_,a.batchPointCount===o){let X=Ji(i,a);X&&(yield X)}continue}if(q)throw new it(`LASLoader: truncated legacy LAZ chunk after ${m-g.remainingPointCount} of ${m} points with ${T} bytes available`);let $=await t.next();$.done?q=!0:l.write($.value)}l.skip(g.compressedByteOffset-I),c.push(g.compressedByteOffset),f+=m}n.compressor!==1&&await Tu(l,t,e,n,u,c,s);let h=Ji(i,a);h&&(yield h)}function nw(r,t,e){return Math.min(r,Math.max(e,t+XS))}async function*eI(r,t,e,n){let{pending:s,laszip:i}=await II(r,t,e);if(xp(e,i),!i.variableChunks&&e.pointsFormatId<=5){yield*rI(s,t,e,i,n);return}if(!i.variableChunks&&e.pointsFormatId>=6&&e.pointsFormatId<=10){yield*nI(s,t,e,i,n);return}for await(let o of QS(s,t,e,i,n))yield _u(o.arrayBuffer,o.header,n)}async function*rI(r,t,e,n,s){let i={...e,totalToRead:e.pointsCount},o=Du(Ho(s),e,s),a=Cu(s),c=[],l=new js;l.write(r),await Qi(l,t,e.pointsOffset+(n.compressor===1?0:Wt),"LASLoader: incomplete compressed LAZ point data"),l.skip(e.pointsOffset);let u=n.compressor===1?0:Fu(l.getDataView(Wt)),f=0;for(;f<e.pointsCount;){let m=n.compressor===1?e.pointsCount:Math.min(n.chunkSize,e.pointsCount-f),y=Js(e,n,m),g=jr(new Uint8Array(0),y),x=0,I=0,q=!1;for(;g.remainingPointCount>0;){let T=l.getAvailableByteLength(),b=nw(T,x,g.requiredInputByteLength-I);if(b>x){let X=l.checkpoint();l.skip(x);let ft=b-x;Ip(l,ft,a),g.feed(l.readBytes(ft)),l.restore(X),x=b}o.target.pointOffset=o.batchPointCount;let C=o.batchCapacity-o.batchPointCount,_=g.decodeAvailableIntoPointData(o.target,C,q);if(_>0){if(n.compressor===1){let X=g.compressedByteOffset-I;l.skip(X),x-=X,I=g.compressedByteOffset,g.discardConsumedInput()}if(Sp(o,o.batchPointCount,_),o.batchPointCount+=_,o.batchPointCount===o.batchCapacity){let X=Lu(i,o,s);X&&(yield X)}continue}if(q)throw new it(`LASLoader: truncated legacy LAZ chunk after ${m-g.remainingPointCount} of ${m} points with ${T} bytes available`);let $=await t.next();$.done?q=!0:l.write($.value)}l.skip(g.compressedByteOffset-I),c.push(g.compressedByteOffset),f+=m}n.compressor!==1&&await Tu(l,t,e,n,u,c,s);let h=Lu(i,o,s);h&&(yield h)}async function*nI(r,t,e,n,s){let i={...e,totalToRead:e.pointsCount},o=Du(Ho(s),e,s),a=0,c=[],l=new js;l.write(r),await Qi(l,t,e.pointsOffset+Wt,"LASLoader: incomplete compressed LAZ point data"),l.skip(e.pointsOffset);let u=Fu(l.getDataView(Wt));for(;a<e.pointsCount;){let h=Math.min(n.chunkSize,e.pointsCount-a),m=Js(e,n,h),y=yield*sI(l,t,m,i,o,s,!!(s.las?.recoverMissingChunkTable&&u===e.pointsOffset));c.push(y),a+=h}await Tu(l,t,e,n,u,c,s);let f=Lu(i,o,s);f&&(yield f)}async function*sI(r,t,e,n,s,i,o){let a=hu(e);await Qi(r,t,a,"LASLoader: incomplete layered LAZ chunk header");let c=r.readBytes(a);o&&Ap(c,e);let l=du(c,e),u=Yd(e);u.feed(c);let f=a;for(;f<l;){if(yield*Hb(u,n,s,i),r.getAvailableByteLength()===0){let m=await t.next();if(m.done)throw new it("LASLoader: incomplete layered LAZ chunk payload");r.write(m.value)}let h=Math.min(r.getAvailableByteLength(),l-f);u.feed(r.readBytes(h)),f+=h}if(u.close(),yield*Hb(u,n,s,i),u.remainingPointCount!==0)throw new it(`LASLoader: layered LAZ chunk produced ${e.pointCount-u.remainingPointCount} of ${e.pointCount} points`);return l}function*Hb(r,t,e,n){for(;r.remainingPointCount>0;){let s=e.batchCapacity-e.batchPointCount;e.target.pointOffset=e.batchPointCount;let i=r.readPointDataBatch(e.target,s);if(!i)return;if(Sp(e,e.batchPointCount,i),e.batchPointCount+=i,e.batchPointCount===e.batchCapacity){let o=Lu(t,e,n);o&&(yield o)}}}function*iI(r,t,e,n,s={}){let i=n||wp(new Uint8Array(r),t);if(xp(t,i),t.pointsFormatId<=5||i.variableChunks){yield*sw(new Uint8Array(r),t,i,{...s,batchSize:e});return}let o={...t,totalToRead:t.pointsCount},a=Mu(e,t.pointsStructSize),c=new Uint8Array(r),l=vp(c,t,i,s),u=t.pointsOffset+(i.compressor===1?0:Wt);for(let h of l){let m=Js(t,i,h.pointCount),y=c.subarray(u,u+h.byteLength);for(let g of Bp(y,m,o,a))yield g;u+=h.byteLength}let f=Ji(o,a);f&&(yield f)}function*sw(r,t,e,n={}){let s=Ho(n),i={...t,totalToRead:t.pointsCount},o=Mu(s,t.pointsStructSize,Cu(n)),a=vp(r,t,e,n),c=t.pointsOffset+(e.compressor===1?0:Wt);for(let u of a){let f=r.subarray(c,c+u.byteLength);if(f.byteLength<u.byteLength)throw new it("LASLoader: truncated legacy LAZ chunk");let h=Js(t,e,u.pointCount);if(e.compressor===1)yield*Bp(f,h,i,o);else{let m=fu(f,h);NI(m.byteLength,o.stats),yield*RI(m,i,o)}c+=u.byteLength}let l=Ji(i,o);l&&(yield l)}function oI(r,t,e){let n=t.pointsCount,s=new Uint8Array(n*t.pointsStructSize),i=0;for(let o of iI(r,t,Xb,e)){let a=new Uint8Array(o.arrayBuffer);s.set(a,i),i+=a.byteLength}return s}function iw(r){let t=new DataView(r);if(r.byteLength<227||t.getUint32(0,!0)!==Kb)throw new Error("LASLoader: invalid LAS header");let e=t.getUint8(24),n=t.getUint8(25);if(e!==1||n>5)throw new Error(`LASLoader: unsupported LAS version ${e}.${n}`);let s=t.getUint16(94,!0),i=t.getUint16(6,!0),o=t.getUint32(100,!0),a=t.getUint8(104),c=a&WS,l=!!(a&$S),u=t.getUint32(107,!0),h=(e>1||n>=4?Ks(t,247):u)||u,m=t.getUint32(96,!0),y=t.getUint16(105,!0);if(n===5){if(s<393)throw new Error("LASLoader: LAS 1.5 header must be at least 393 bytes");if(c<6||c>10)throw new Error(`LASLoader: LAS 1.5 requires point data record formats 6-10; received ${c}`);if((i&16)===0)throw new Error("LASLoader: LAS 1.5 requires the WKT global encoding flag");if((i&65440)!==0)throw new Error("LASLoader: LAS 1.5 Global Encoding contains reserved bits");if((i&64)!==0&&(i&1)===0)throw new Error("LASLoader: LAS 1.5 Time Offset Flag requires GPS Time Type");let b=t.getFloat64(375,!0),C=t.getFloat64(383,!0);if(!Number.isFinite(b)||!Number.isFinite(C)||b!==0&&C!==0&&b<C)throw new Error("LASLoader: LAS 1.5 GPS time range is invalid")}let g=[t.getFloat64(131,!0),t.getFloat64(139,!0),t.getFloat64(147,!0)],x=[t.getFloat64(155,!0),t.getFloat64(163,!0),t.getFloat64(171,!0)],I=[t.getFloat64(179,!0),t.getFloat64(195,!0),t.getFloat64(211,!0)],q=[t.getFloat64(187,!0),t.getFloat64(203,!0),t.getFloat64(219,!0)],T={pointsOffset:m,pointsFormatId:c,pointsStructSize:y,pointsCount:h,scale:g,offset:x,maxs:I,mins:q,totalToRead:h,totalRead:0,hasColor:ow(c),versionAsString:`${e}.${n}`,isCompressed:l,headerSize:s,vlrCount:o,userHeaderData:n===5&&s>393?new Uint8Array(r,393,s-393).slice():void 0};return aI(r,T)&&(T.metadata=cI(r,T)),T}function aI(r,t){let e=t.headerSize+t.vlrCount*54;return r.byteLength>=Math.max(e,t.pointsOffset)}function cI(r,t){let e=new DataView(r),s=(t.versionAsString||"1.0").split(".").map(Number),i=s[0]>1||s[0]===1&&s[1]>=4,o=lI(e,t),a=i?Ks(e,235):0,c=i?e.getUint32(243,!0):0,l=uI(e,a,c),u={fileSourceId:e.getUint16(4,!0),globalEncoding:e.getUint16(6,!0),waveformDataOffset:s[0]>1||s[0]===1&&s[1]>=3?e.getBigUint64(227,!0):void 0,projectId:yI(new Uint8Array(r,8,16)),systemIdentifier:Zo(new Uint8Array(r),26,32),generatingSoftware:Zo(new Uint8Array(r),58,32),creationDayOfYear:e.getUint16(90,!0),creationYear:e.getUint16(92,!0),headerSize:t.headerSize,userHeaderData:t.userHeaderData,vlrCount:t.vlrCount,evlrOffset:a||void 0,evlrCount:c||void 0,maxGpsTime:s[1]===5?e.getFloat64(375,!0):void 0,minGpsTime:s[1]===5?e.getFloat64(383,!0):void 0,timeOffset:s[1]===5?e.getUint16(391,!0):void 0,pointsByReturn:mI(e,i),vlrs:o,evlrs:l,extraBytes:[],waveformPacketDescriptors:[]};for(let f of o.concat(l.map(h=>({...h,data:h.data||new Uint8Array}))))fI(f,u);return u.compatibility=jb(t,u),hI(u),u}function lI(r,t){let e=new Uint8Array(r.buffer,r.byteOffset,r.byteLength),n=[],s=t.headerSize;for(let i=0;i<t.vlrCount&&!(s+54>e.byteLength);i++){let o=r.getUint16(s+20,!0),a=s+54;if(a+o>e.byteLength)break;n.push({reserved:r.getUint16(s,!0),userId:Zo(e,s+2,16),recordId:r.getUint16(s+18,!0),description:Zo(e,s+22,32),offset:s,data:e.slice(a,a+o)}),s=a+o}return n}function uI(r,t,e){if(!t||!e||t>=r.byteLength)return[];let n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength),s=[],i=t;for(let o=0;o<e&&!(i+60>n.byteLength);o++){let a=Ks(r,i+20),c=i+60;if(a>n.byteLength-c)break;s.push({reserved:r.getUint16(i,!0),userId:Zo(n,i+2,16),recordId:r.getUint16(i+18,!0),description:Zo(n,i+28,32),offset:i,data:n.slice(c,c+a),dataOffset:c,dataLength:a}),i=c+a}return s}function fI(r,t){let e=r.data;e&&(r.userId==="LASF_Spec"&&r.recordId===4?t.extraBytes.push(...Wb(e)):r.userId==="LASF_Spec"&&r.recordId>=100&&r.recordId<=354?t.waveformPacketDescriptors.push(pI(r.recordId,e)):r.userId==="LASF_Projection"&&r.recordId===2111?t.wktMathTransform=Bu(e):r.userId==="LASF_Projection"&&r.recordId===2112?t.wkt=Bu(e):r.userId==="LASF_Projection"&&r.recordId===34735?t.geotiff={...t.geotiff,keys:gI(e)}:r.userId==="LASF_Projection"&&r.recordId===34736?t.geotiff={...t.geotiff,doubles:bI(e)}:r.userId==="LASF_Projection"&&r.recordId===34737&&(t.geotiff={...t.geotiff,ascii:Bu(e)}))}function hI(r){let t=r.geotiff,e=t?.keys;if(!t||!e||e.length<4)return;let n=e[3];if(e.length<4+n*4)return;let s=[];for(let i=0;i<n;i++){let o=4+i*4,a={keyId:e[o],tiffTagLocation:e[o+1],count:e[o+2],valueOffset:e[o+3]};a.value=dI(a,t),a.value===void 0&&delete a.value,s.push(a)}t.keyDirectory={version:e[0],keyRevision:e[1],minorRevision:e[2],entries:s}}function dI(r,t){if(r.tiffTagLocation===0)return r.valueOffset;if(r.tiffTagLocation===34735&&t.keys){let e=t.keys.slice(r.valueOffset,r.valueOffset+r.count);return e.length===r.count?Array.from(e):void 0}if(r.tiffTagLocation===34736&&t.doubles){let e=t.doubles.slice(r.valueOffset,r.valueOffset+r.count);return e.length!==r.count?void 0:r.count===1?e[0]:Array.from(e)}if(r.tiffTagLocation===34737&&t.ascii!==void 0){let e=r.valueOffset+r.count;return e>t.ascii.length?void 0:t.ascii.slice(r.valueOffset,e).replace(/\|$/,"")}}function pI(r,t){if(t.byteLength<28)throw new Error(`LASLoader: waveform descriptor VLR ${r} is truncated`);let e=new DataView(t.buffer,t.byteOffset,t.byteLength);return{recordId:r,bitsPerSample:e.getUint8(2),compressionType:e.getUint8(3),numberOfSamples:e.getUint32(4,!0),temporalSampleSpacing:e.getUint32(8,!0),digitizerGain:e.getFloat64(12,!0),digitizerOffset:e.getFloat64(20,!0)}}function mI(r,t){let e=t?15:5,n=t?255:111,s=[];for(let i=0;i<e;i++)s.push(t?Ks(r,n+i*8):r.getUint32(n+i*4,!0));return s}function Zo(r,t,e){return Bu(r.subarray(t,t+e))}function Bu(r){let t=r.length;for(;t>0&&r[t-1]===0;)t--;return new TextDecoder().decode(r.subarray(0,t)).trim()}function yI(r){let t=(n,s)=>Array.from(r.subarray(n,n+s),i=>i.toString(16).padStart(2,"0")).reverse().join(""),e=(n,s)=>Array.from(r.subarray(n,n+s),i=>i.toString(16).padStart(2,"0")).join("");return`${t(0,4)}-${t(4,2)}-${t(6,2)}-${e(8,2)}${e(10,6)}`}function gI(r){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),e=new Uint16Array(Math.floor(r.byteLength/2));for(let n=0;n<e.length;n++)e[n]=t.getUint16(n*2,!0);return e}function bI(r){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),e=new Float64Array(Math.floor(r.byteLength/8));for(let n=0;n<e.length;n++)e[n]=t.getFloat64(n*8,!0);return e}function _u(r,t,e={}){let n=t.pointsCount,s=e.las?.fp64?Float64Array:Float32Array,i=new s(n*3),o=uw(e),a=t.hasColor&&o.color?new Uint8Array(n*4):null,c=o.intensity?new Uint16Array(n):null,l=o.classification?new Uint8Array(n):null,u=o.synthetic?new Uint8Array(n):null,f=o.keyPoint?new Uint8Array(n):null,h=o.withheld?new Uint8Array(n):null,m=o.overlap?new Uint8Array(n):null,y=o.gpsTime&&gp(t.pointsFormatId)>=0?new Float64Array(n):null,g=o.nir&&(bp(t.pointsFormatId)>=0||e.las?.compatibilityMode!=="raw"&&t.metadata?.compatibility?.nirByteOffset!==void 0)?new Uint16Array(n):null,x=o.scanAngle?new Int16Array(n):null,I=o.userData?new Uint8Array(n):null,q=o.pointSourceId?new Uint16Array(n):null,T=o.returnNumber?new Uint8Array(n):null,b=o.numberOfReturns?new Uint8Array(n):null,C=o.scannerChannel?new Uint8Array(n):null,_=o.scanDirectionFlag?new Uint8Array(n):null,$=o.edgeOfFlightLine?new Uint8Array(n):null,X=o.waveform&&yp(t.pointsFormatId)>=0?new Uint8Array(n*29):null,ft=Math.max(0,t.pointsStructSize-Pn(t.pointsFormatId)),dt=o.extraBytes&&e.las?.extraBytes!=="typed"&&ft?new Uint8Array(n*ft):null,It=o.extraBytes&&e.las?.extraBytes==="typed"?cw(n,t):null;return xI(wI(r),t,e,{positions:i,colors:a,intensities:c,classifications:l,syntheticFlags:u,keyPointFlags:f,withheldFlags:h,overlapFlags:m,gpsTimes:y,nir:g,scanAngles:x,userData:I,pointSourceIds:q,returnNumbers:T,numberOfReturns:b,scannerChannels:C,scanDirectionFlags:_,edgeOfFlightLines:$,waveforms:X,extraBytes:dt,typedExtraBytes:It,pointOffset:0,sourcePointIndex:0,pointCount:n}),pp(t,i,a,c,l,u,f,h,m,y,g,x,I,q,T,b,C,_,$,X,dt,It)}function pp(r,t,e,n,s,i,o,a,c,l,u,f,h,m,y,g,x,I,q,T,b,C){let _={POSITION:{value:t,size:3}};if(n&&(_.intensity={value:n,size:1}),s&&(_.classification={value:s,size:1}),i&&(_.synthetic={value:i,size:1}),o&&(_.keyPoint={value:o,size:1}),a&&(_.withheld={value:a,size:1}),c&&(_.overlap={value:c,size:1}),e&&(_.COLOR_0={value:e,size:e instanceof Uint16Array?3:4}),l&&(_.GPS_TIME={value:l,size:1}),u&&(_.NIR={value:u,size:1}),f&&(_.scanAngle={value:f,size:1}),h&&(_.userData={value:h,size:1}),m&&(_.pointSourceId={value:m,size:1}),y&&(_.returnNumber={value:y,size:1}),g&&(_.numberOfReturns={value:g,size:1}),x&&(_.scannerChannel={value:x,size:1}),I&&(_.scanDirectionFlag={value:I,size:1}),q&&(_.edgeOfFlightLine={value:q,size:1}),T&&(_.WAVEFORM={value:T,size:29}),b&&(_.EXTRA_BYTES={value:b,size:b.length/Math.max(r.pointsCount,1)}),C)for(let ft of C)_[ft.name]={value:ft.value,size:ft.size};let $={};for(let[ft,dt]of Object.entries(_))!(dt.value instanceof BigInt64Array)&&!(dt.value instanceof BigUint64Array)&&($[ft]={...dt,value:dt.value});let X=Vb(r,$);return{...Yl(_,{schema:X,topology:"point-list",mode:0,boundingBox:zI(r)}),loader:"las",loaderData:r,progress:r.totalRead/r.totalToRead}}function wI(r){return ArrayBuffer.isView(r)?new DataView(r.buffer,r.byteOffset,r.byteLength):new DataView(r)}function xI(r,t,e,n){let{scale:[s,i,o],offset:[a,c,l]}=t,u=t.pointsFormatId,f=t.pointsStructSize,h=n.colors?mp(u):-1,m=h>=0?AI(r,t,n.sourcePointIndex,n.pointCount,e.las?.colorDepth):!1,y=n.intensities,g=n.classifications,x=n.syntheticFlags,I=n.keyPointFlags,q=n.withheldFlags,T=n.overlapFlags,b=n.gpsTimes,C=n.nir,_=n.scanAngles,$=n.userData,X=n.pointSourceIds,ft=n.returnNumbers,dt=n.numberOfReturns,It=n.scannerChannels,se=n.scanDirectionFlags,rt=n.edgeOfFlightLines,tt=n.waveforms,Ye=n.extraBytes,Ne=n.typedExtraBytes,Ze=b?gp(u):-1,xt=C?bp(u):-1;for(let Gn=0;Gn<n.pointCount;Gn++){let Qs=n.sourcePointIndex+Gn,wt=t.pointsOffset+Qs*f,pt=n.pointOffset+Gn;n.positions[pt*3]=r.getInt32(wt,!0)*s+a,n.positions[pt*3+1]=r.getInt32(wt+4,!0)*i+c,n.positions[pt*3+2]=r.getInt32(wt+8,!0)*o+l,y&&(y[pt]=r.getUint16(wt+12,!0)),g&&(g[pt]=vI(r,wt,u)),b&&Ze>=0&&(b[pt]=r.getFloat64(wt+Ze,!0)),C&&xt>=0&&(C[pt]=r.getUint16(wt+xt,!0)),_&&(_[pt]=u<=5?r.getInt8(wt+16):r.getInt16(wt+18,!0)),$&&($[pt]=r.getUint8(wt+17)),X&&(X[pt]=r.getUint16(wt+(u<=5?18:20),!0));let ln=r.getUint8(wt+14),$r=r.getUint8(wt+15),un=u<=5?$r>>5:$r;if(x&&(x[pt]=un&1),I&&(I[pt]=un>>1&1),q&&(q[pt]=un>>2&1),T&&(T[pt]=u<=5?0:un>>3&1),ft&&(ft[pt]=u<=5?ln&7:ln&15),dt&&(dt[pt]=u<=5?ln>>3&7:ln>>4),It&&(It[pt]=u<=5?0:$r>>4&3),se&&(se[pt]=u<=5?ln>>6&1:$r>>6&1),rt&&(rt[pt]=u<=5?ln>>7&1:$r>>7&1),tt){let Ar=yp(u);if(Ar>=0){let Sr=new Uint8Array(r.buffer,r.byteOffset+wt+Ar,29);tt.set(Sr,pt*29)}}if(Ye){let Ar=Pn(u),Sr=t.pointsStructSize-Ar;Sr>0&&Ye.set(new Uint8Array(r.buffer,r.byteOffset+wt+Ar,Sr),pt*Sr)}if(Ne&&EI(r,wt,u,pt,Ne),e.las?.compatibilityMode!=="raw"&&t.metadata?.compatibility&&fp(r,wt+Pn(u),pt,t.metadata.compatibility,n),h>=0&&n.colors){let Ar=r.getUint16(wt+h,!0),Sr=r.getUint16(wt+h+2,!0),eo=r.getUint16(wt+h+4,!0);n.colors[pt*4]=m?Ar/256:Ar,n.colors[pt*4+1]=m?Sr/256:Sr,n.colors[pt*4+2]=m?eo/256:eo,n.colors[pt*4+3]=255}}}function vI(r,t,e){return e<=5?r.getUint8(t+15)&31:r.getUint8(t+16)}function ow(r){return mp(r)>=0}function mp(r){switch(r){case 2:return 20;case 3:return 28;case 5:return 28;case 7:case 8:case 10:return 30;default:return-1}}function yp(r){switch(r){case 4:return 28;case 5:return 34;case 9:return 30;case 10:return 38;default:return-1}}function gp(r){return r===1||r===3||r===4||r===5?20:r>=6&&r<=10?22:-1}function bp(r){return r===8||r===10?36:-1}function AI(r,t,e,n,s){if(s===8)return!1;if(s===16)return!0;if(s!=="auto")return!1;let i=mp(t.pointsFormatId);if(i<0)return!1;for(let o=0;o<n;o++){let a=t.pointsOffset+(e+o)*t.pointsStructSize;if(r.getUint16(a+i,!0)>255||r.getUint16(a+i+2,!0)>255||r.getUint16(a+i+4,!0)>255)return!0}return!1}function Ho(r){let t=r.batchSize??r.core?.batchSize;return typeof t=="number"?t:Xb}function wp(r,t){let e=new DataView(r.buffer,r.byteOffset,r.byteLength),n=t.headerSize||Jb,s=t.vlrCount||0;for(let i=0;i<s;i++){if(n+54>r.byteLength)throw new it("LASLoader: incomplete VLR header");let o=kI(r,n+2,16),a=e.getUint16(n+18,!0),c=e.getUint16(n+20,!0),l=n+54;if(l+c>r.byteLength)throw new it("LASLoader: incomplete VLR data");if(o===YS&&a===ZS){if(c<34)throw new Error("LASLoader: malformed LASzip VLR");let u=e.getUint32(l+12,!0),f=e.getUint16(l+32,!0);if(34+f*6>c)throw new Error("LASLoader: malformed LASzip VLR item table");let m=null,y=null,g=null,x=null,I=null,q=[];for(let T=0;T<f;T++){let b=l+34+T*6,C=e.getUint16(b,!0),_=e.getUint16(b+2,!0),$=e.getUint16(b+4,!0);if(q.push({type:C,size:_,version:$}),[0,6,7,8].includes(C)){if($!==1&&$!==2)throw new Error(`LASLoader: unsupported legacy LASzip item type ${C} version ${$}`)}else if(C===9){if($!==1)throw new Error(`LASLoader: unsupported WavePacket13 item version ${$}`);g=$}else if([10,11,12,14].includes(C)){if($!==2&&$!==3&&$!==4)throw new Error(`LASLoader: unsupported LAS 1.4 item type ${C} version ${$}`);C===10?m=$:C===11||C===12?y=$:I=$}else if(C===13){if($!==3&&$!==4)throw new Error(`LASLoader: unsupported WavePacket14 item version ${$}`);x=$}}return{compressor:e.getUint16(l,!0),coder:e.getUint16(l+2,!0),chunkSize:u,variableChunks:e.getUint16(l,!0)!==1&&(u===0||u===HS),items:q,point14ItemVersion:m,rgb14ItemVersion:y,wavePacket13ItemVersion:g,wavePacketItemVersion:x,byte14ItemVersion:I}}n=l+c}throw new Error("LASLoader: compressed LAZ file does not contain a LASzip VLR")}function xp(r,t){if(![0,1,2,3,4,5,6,7,8,9,10].includes(r.pointsFormatId))throw new Error(`LASLoader: TypeScript LAZ streaming only supports point formats 0-10; received ${r.pointsFormatId}`);if(r.pointsFormatId<=5&&t.compressor!==1&&t.compressor!==2)throw new Error(`LASLoader: legacy TypeScript LAZ decoding requires LASzip compressor 1 or 2; received ${t.compressor}`);if(r.pointsFormatId>=6&&t.compressor!==3)throw new Error(`LASLoader: LAS 1.4 TypeScript LAZ decoding requires LASzip compressor 3; received ${t.compressor}`);if(t.coder!==0)throw new Error(`LASLoader: TypeScript LAZ decoding requires LASzip arithmetic coder 0; received ${t.coder}`);if(SI(r,t.items),r.pointsFormatId>=6&&!t.point14ItemVersion)throw new Error(`LASLoader: point format ${r.pointsFormatId} requires a Point14 LASzip item`);if((r.pointsFormatId===4||r.pointsFormatId===5)&&!t.wavePacket13ItemVersion)throw new Error(`LASLoader: point format ${r.pointsFormatId} requires a WavePacket13 LASzip item`);if((r.pointsFormatId===7||r.pointsFormatId===8||r.pointsFormatId===10)&&!t.rgb14ItemVersion)throw new Error(`LASLoader: point format ${r.pointsFormatId} requires an RGB14 or RGBNIR14 LASzip item`);if(r.pointsFormatId>=6&&r.pointsStructSize>Pn(r.pointsFormatId)&&!t.byte14ItemVersion)throw new Error(`LASLoader: point format ${r.pointsFormatId} with Extra Bytes requires a Byte14 LASzip item`);if((r.pointsFormatId===9||r.pointsFormatId===10)&&!t.wavePacketItemVersion)throw new Error(`LASLoader: point format ${r.pointsFormatId} requires a WavePacket14 LASzip item`)}function SI(r,t){let e=r.pointsFormatId,n=Pn(e),s=r.pointsStructSize-n;if(s<0)throw new Error(`LASLoader: point format ${e} record length ${r.pointsStructSize} is smaller than ${n}`);let i=[];switch(e){case 0:i.push({type:6,size:20});break;case 1:i.push({type:6,size:20},{type:7,size:8});break;case 2:i.push({type:6,size:20},{type:8,size:6});break;case 3:i.push({type:6,size:20},{type:7,size:8},{type:8,size:6});break;case 4:i.push({type:6,size:20},{type:7,size:8},{type:9,size:29});break;case 5:i.push({type:6,size:20},{type:7,size:8},{type:8,size:6},{type:9,size:29});break;case 6:i.push({type:10,size:30});break;case 7:i.push({type:10,size:30},{type:11,size:6});break;case 8:i.push({type:10,size:30},{type:12,size:8});break;case 9:i.push({type:10,size:30},{type:13,size:29});break;case 10:i.push({type:10,size:30},{type:12,size:8},{type:13,size:29});break;default:return}if(s>0&&i.push({type:e<=5?0:14,size:s}),t.length!==i.length)throw new Error(`LASLoader: point format ${e} has ${t.length} LASzip items; expected ${i.length}`);for(let o=0;o<i.length;o++){let a=t[o],c=i[o];if(a.type!==c.type)throw new Error(`LASLoader: LASzip item ${o} has type ${a.type}; expected ${c.type} for point format ${e}`);if(a.size!==c.size)throw new Error(`LASLoader: LASzip item ${o} has size ${a.size}; expected ${c.size} for point format ${e}`)}}async function II(r,t,e){let n=r;for(;;){try{return{pending:n,laszip:wp(n,e)}}catch(i){if(!(i instanceof it))throw i}let s=await t.next();if(s.done)throw new it("LASLoader: incomplete LASzip VLR");n=hw(n,_p(s.value))}}async function BI(r,t){let e=[r],n=r.byteLength;for(;;){let o=await t.next();if(o.done)break;let a=_p(o.value);e.push(a),n+=a.byteLength}if(e.length===1)return r;let s=new Uint8Array(n),i=0;for(let o of e)s.set(o,i),i+=o.byteLength;return s}async function Tu(r,t,e,n,s,i,o){if(o.las?.recoverMissingChunkTable&&s===e.pointsOffset){if(n.variableChunks)throw new Error("LASLoader: cannot recover a missing variable-size LAZ chunk table");for(;;){if(r.getAvailableByteLength())throw new Error("LASLoader: unexpected bytes after recovered LAZ chunks");let h=await t.next();if(h.done)return;r.write(h.value)}}let a=i.reduce((h,m)=>h+m,0),c=e.pointsOffset+Wt+a,l=s===-1?c:s;if(!Number.isSafeInteger(l)||l<c)throw new Error("LASLoader: LAZ chunk table byte lengths overlap the chunk table");let u=l-c;await Qi(r,t,u,"LASLoader: incomplete LAZ chunk table"),r.skip(u);let f=await TI(r,t,e,n);if(f.length!==i.length)throw new Error(`LASLoader: LAZ chunk table contains ${f.length} chunks; decoded ${i.length}`);for(let h=0;h<f.length;h++)if(f[h].byteLength!==i[h])throw new Error(`LASLoader: LAZ chunk ${h} has ${f[h].byteLength} table bytes; decoded ${i[h]}`);s===-1&&await _I(r,t,l)}async function _I(r,t,e){let n=new Uint8Array(Wt),s=0;for(;;){let o=r.getAvailableByteLength();if(o>0){let c=r.readBytes(Math.min(o,65536));LI(n,c),s+=c.byteLength;continue}let a=await t.next();if(a.done)break;r.write(a.value)}if(s<Wt)throw new it("LASLoader: incomplete non-seekable LAZ chunk-table footer");let i=Ks(new DataView(n.buffer),0);if(!Number.isSafeInteger(i)||i!==e)throw new Error(`LASLoader: non-seekable LAZ footer points to ${i}; expected ${e}`)}function LI(r,t){if(t.byteLength>=r.byteLength){r.set(t.subarray(t.byteLength-r.byteLength));return}r.copyWithin(0,t.byteLength),r.set(t,r.byteLength-t.byteLength)}async function TI(r,t,e,n){let s=64;for(;;){let i=r.getAvailableByteLength();if(i>=8){let a=r.checkpoint();try{let c=r.readBytes(Math.min(i,s)),l=aw(c,e,n);return r.restore(a),l}catch(c){if(r.restore(a),!(c instanceof it))throw c;if(s*=2,s<=i)continue}}let o=await t.next();if(o.done)throw new it("LASLoader: incomplete LAZ chunk table");r.write(o.value)}}async function Qi(r,t,e,n){for(;!r.hasAvailableBytes(e);){let s=await t.next();if(s.done)throw new it(n);r.write(s.value)}}async function MI(r,t,e){for(;;){let n=r.checkpoint(),s;try{s=DI(r,e)}finally{r.restore(n)}if(s!==null)return await Qi(r,t,s,"LASLoader: truncated LAZ chunk"),s;let i=await t.next();if(i.done)throw new it("LASLoader: truncated LAZ chunk");r.write(i.value)}}function DI(r,t){if(t.pointDataRecordFormat<6||t.pointDataRecordFormat>10)return null;let e=t.pointDataRecordLength-Pn(t.pointDataRecordFormat);if(e<0)throw new Error(`Invalid point record length ${t.pointDataRecordLength}`);let n=CI(t.pointDataRecordFormat)+e,s=t.pointDataRecordLength+4,i=n*4,o=s+i;if(!r.hasAvailableBytes(o))return null;r.skip(s);let a=o;for(let c=0;c<n;c++)a+=r.readUint32LE();return a}function Pn(r){switch(r){case 0:return 20;case 1:return 28;case 2:return 26;case 3:return 34;case 4:return 57;case 5:return 63;case 6:return 30;case 7:return 36;case 8:return 38;case 9:return 59;case 10:return 67;default:throw new Error(`Unsupported LAS point format ${r}`)}}function CI(r){switch(r){case 6:return 9;case 7:return 10;case 8:return 11;case 9:return 10;case 10:return 12;default:throw new Error(`Unsupported LAS 1.4 point format ${r}`)}}function vp(r,t,e,n){if(e.compressor===1)return[{pointCount:t.pointsCount,byteLength:r.byteLength-t.pointsOffset}];let s=$I(new DataView(r.buffer,r.byteOffset,r.byteLength),t.pointsOffset);return FI(r,t,e,s,n)}function FI(r,t,e,n,s){if(s.las?.recoverMissingChunkTable&&n===t.pointsOffset)return OI(r,t,e);if(!Number.isSafeInteger(n)||n<0||n+8>r.byteLength)throw new it("LASLoader: incomplete LAZ chunk table");let i=aw(r.subarray(n),t,e),o=i.reduce((a,c)=>a+c.byteLength,0);if(t.pointsOffset+Wt+o>n)throw new Error("LASLoader: LAZ chunk table byte lengths overlap the chunk table");return i}function OI(r,t,e){if(e.variableChunks||!e.chunkSize)throw new Error("LASLoader: cannot recover a missing variable-size LAZ chunk table");let n=[],s=t.pointsOffset+Wt,i=0;for(;i<t.pointsCount;){let o=Math.min(e.chunkSize,t.pointsCount-i),a=Js(t,e,o),c=r.subarray(s),l;if(t.pointsFormatId<=5){let u=jr(c,a),f=new Uint8Array(Math.min(o,256)*t.pointsStructSize);for(;u.remainingPointCount;)u.decodeInto(f,0,Math.min(u.remainingPointCount,256));l=u.compressedByteOffset}else Ap(c,a),l=du(c,a);if(!l||s+l>r.byteLength)throw new it("LASLoader: truncated LAZ chunk during table recovery");n.push({pointCount:o,byteLength:l}),s+=l,i+=o}if(s!==r.byteLength)throw new Error("LASLoader: unexpected bytes after recovered LAZ chunks");return n}function Ap(r,t){if(r.byteLength<t.pointDataRecordLength+4)throw new it("LASLoader: truncated recovered layered LAZ chunk header");let n=new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(t.pointDataRecordLength,!0);if(n!==t.pointCount)throw new Error(`LASLoader: recovered layered LAZ chunk contains ${n} points; expected ${t.pointCount}`)}function aw(r,t,e){if(r.byteLength<8)throw new it("LASLoader: incomplete LAZ chunk table");let n=new DataView(r.buffer,r.byteOffset,r.byteLength),s=n.getUint32(0,!0),i=n.getUint32(4,!0);if(s!==0)throw new Error(`LASLoader: unsupported LAZ chunk table version ${s}`);if(i===0){if(t.pointsCount!==0)throw new Error("LASLoader: missing LAZ chunk table");return[]}let o=Zd(r.subarray(8),{chunkCount:i,pointCount:t.pointsCount,chunkSize:e.chunkSize,variable:e.variableChunks}),a=0;for(let c of o){if(c.pointCount===0||c.byteLength===0)throw new Error("LASLoader: invalid empty LAZ chunk-table entry");a+=c.pointCount}if(a!==t.pointsCount)throw new Error(`LASLoader: LAZ chunk table contains ${a} points; expected ${t.pointsCount}`);return o}function Mu(r,t,e){return e&&e.rawBatchAllocations++,{rawBatch:new Uint8Array(r*t),batchPointCount:0,totalRead:0,rawBatchAllocations:1,stats:e}}function Du(r,t,e){let n=e.las?.fp64?Float64Array:Float32Array,s=new n(r*3),i=uw(e),o=t.hasColor&&i.color&&(e.las?.colorDepth===16||e.las?.colorDepth==="auto"),a=t.hasColor&&i.color&&!o?new Uint8Array(r*4):null,c=o?new Uint16Array(r*3):null,l=i.intensity?new Uint16Array(r):null,u=i.classification?new Uint8Array(r):null,f=i.synthetic?new Uint8Array(r):null,h=i.keyPoint?new Uint8Array(r):null,m=i.withheld?new Uint8Array(r):null,y=i.overlap?new Uint8Array(r):null,g=i.gpsTime&&gp(t.pointsFormatId)>=0?new Float64Array(r):null,x=i.nir&&(bp(t.pointsFormatId)>=0||e.las?.compatibilityMode!=="raw"&&t.metadata?.compatibility?.nirByteOffset!==void 0)?new Uint16Array(r):null,I=i.scanAngle?new Int16Array(r):null,q=i.userData?new Uint8Array(r):null,T=i.pointSourceId?new Uint16Array(r):null,b=i.returnNumber?new Uint8Array(r):null,C=i.numberOfReturns?new Uint8Array(r):null,_=i.scannerChannel?new Uint8Array(r):null,$=i.scanDirectionFlag?new Uint8Array(r):null,X=i.edgeOfFlightLine?new Uint8Array(r):null,ft=i.waveform&&yp(t.pointsFormatId)>=0?new Uint8Array(r*29):null,dt=Math.max(0,t.pointsStructSize-Pn(t.pointsFormatId)),It=i.extraBytes&&e.las?.extraBytes!=="typed"&&dt?new Uint8Array(r*dt):null,se=i.extraBytes&&e.las?.extraBytes==="typed"?cw(r,t):null,rt=se?.length&&dt?new Uint8Array(r*dt):null,tt=i.classification||i.returnNumber||i.numberOfReturns||i.scanAngle||i.overlap||i.scannerChannel||i.nir,Ye=e.las?.compatibilityMode==="raw"||!tt?null:t.metadata?.compatibility||null,Ne=Ye&&!It&&!rt?new Uint8Array(r*dt):null;return{batchCapacity:r,positions:s,colors:a,rawColors:c,intensities:l,classifications:u,syntheticFlags:f,keyPointFlags:h,withheldFlags:m,overlapFlags:y,gpsTimes:g,nir:x,scanAngles:I,userData:q,pointSourceIds:T,returnNumbers:b,numberOfReturns:C,scannerChannels:_,scanDirectionFlags:$,edgeOfFlightLines:X,waveforms:ft,extraBytes:It,typedExtraBytes:se,typedExtraBytesSource:rt,compatibilityLayout:Ye,compatibilityExtraBytesSource:Ne,target:{positions:s,intensities:l,classifications:u,syntheticFlags:f,keyPointFlags:h,withheldFlags:m,overlapFlags:y,gpsTimes:g,nir:x,scanAngles:I,userData:q,pointSourceIds:T,returnNumbers:b,numberOfReturns:C,scannerChannels:_,scanDirectionFlags:$,edgeOfFlightLines:X,waveforms:ft,extraBytes:It||rt||Ne,colors:a,rawColors:c,pointOffset:0,scale:t.scale,offset:t.offset},batchPointCount:0,totalRead:0}}function cw(r,t){let e=t.pointsStructSize-Pn(t.pointsFormatId);return Yb(r,t.metadata?.extraBytes||[],e)}function lw(r){return r<=2?1:r<=4?2:r<=6||r===9?4:r===7||r===8||r===10?8:0}function EI(r,t,e,n,s){let i=t+Pn(e);for(let o of s){let a=n*o.size,c=i+o.byteOffset;for(let l=0;l<o.size;l++)dp(r,c+l*lw(o.scalarDataType),o,a+l,l)}}function UI(r,t,e,n,s){let i=new DataView(r.buffer,r.byteOffset,r.byteLength);for(let o=0;o<n;o++){let a=e+o,c=a*t;for(let l of s){let u=a*l.size,f=lw(l.scalarDataType);for(let h=0;h<l.size;h++)dp(i,c+l.byteOffset+h*f,l,u+h,h)}}}function Sp(r,t,e){let n=r.extraBytes||r.typedExtraBytesSource||r.compatibilityExtraBytesSource;if(r.compatibilityLayout&&n&&e){let s=new DataView(n.buffer,n.byteOffset,n.byteLength),i=n.length/r.batchCapacity;for(let o=t;o<t+e;o++)fp(s,o*i,o,r.compatibilityLayout,r)}!r.typedExtraBytesSource||!r.typedExtraBytes?.length||e===0||UI(r.typedExtraBytesSource,r.typedExtraBytesSource.length/r.batchCapacity,t,e,r.typedExtraBytes)}function Cu(r){return r.las?.lazStreamingStats}function Ip(r,t,e){if(!e)return;let n=r.findBufferOffsets(t);n&&n.length>1&&(e.copiedBytes+=t,e.chunkConcatenations++)}function NI(r,t){t&&(t.copiedBytes+=r,t.decodedChunkAllocations++)}function*Bp(r,t,e,n){let s=e.pointsStructSize,i=jr(r,t);for(;i.remainingPointCount>0;){let o=n.rawBatch.byteLength/s,a=o-n.batchPointCount,c=i.decodeInto(n.rawBatch,n.batchPointCount*s,a);if(n.batchPointCount+=c,n.batchPointCount===o){let l=Ji(e,n);l&&(yield l)}}}function*RI(r,t,e){let n=t.pointsStructSize,s=r.byteLength/n;for(let i=0;i<s;i++){let o=i*n,a=e.batchPointCount*n;if(e.rawBatch.set(r.subarray(o,o+n),a),e.batchPointCount++,e.batchPointCount===e.rawBatch.byteLength/n){let c=Ji(t,e);c&&(yield c)}}}function Ji(r,t){if(t.batchPointCount===0)return null;let e=t.batchPointCount*r.pointsStructSize,n=e===t.rawBatch.byteLength,s=n?t.rawBatch.buffer:t.rawBatch.buffer.slice(0,e);t.totalRead+=t.batchPointCount;let i={...r,pointsOffset:0,pointsCount:t.batchPointCount,totalRead:t.totalRead};return t.batchPointCount=0,n&&(t.rawBatch=new Uint8Array(t.rawBatch.byteLength),t.rawBatchAllocations++,t.stats&&t.stats.rawBatchAllocations++),{arrayBuffer:s,header:i}}function Lu(r,t,e){if(t.batchPointCount===0)return null;t.totalRead+=t.batchPointCount;let n={...r,pointsOffset:0,pointsCount:t.batchPointCount,totalRead:t.totalRead},s=t.batchPointCount,i=s===t.batchCapacity,o=i?t.positions:t.positions.subarray(0,s*3),a=t.intensities?i?t.intensities:t.intensities.subarray(0,s):null,c=t.classifications?i?t.classifications:t.classifications.subarray(0,s):null,l=t.syntheticFlags?i?t.syntheticFlags:t.syntheticFlags.subarray(0,s):null,u=t.keyPointFlags?i?t.keyPointFlags:t.keyPointFlags.subarray(0,s):null,f=t.withheldFlags?i?t.withheldFlags:t.withheldFlags.subarray(0,s):null,h=t.overlapFlags?i?t.overlapFlags:t.overlapFlags.subarray(0,s):null,m=t.colors?i?t.colors:t.colors.subarray(0,s*4):t.rawColors?fw(t.rawColors,s,e):null,y=t.gpsTimes?i?t.gpsTimes:t.gpsTimes.subarray(0,s):null,g=t.nir?i?t.nir:t.nir.subarray(0,s):null,x=t.scanAngles?i?t.scanAngles:t.scanAngles.subarray(0,s):null,I=t.userData?i?t.userData:t.userData.subarray(0,s):null,q=t.pointSourceIds?i?t.pointSourceIds:t.pointSourceIds.subarray(0,s):null,T=t.returnNumbers?i?t.returnNumbers:t.returnNumbers.subarray(0,s):null,b=t.numberOfReturns?i?t.numberOfReturns:t.numberOfReturns.subarray(0,s):null,C=t.scannerChannels?i?t.scannerChannels:t.scannerChannels.subarray(0,s):null,_=t.scanDirectionFlags?i?t.scanDirectionFlags:t.scanDirectionFlags.subarray(0,s):null,$=t.edgeOfFlightLines?i?t.edgeOfFlightLines:t.edgeOfFlightLines.subarray(0,s):null,X=t.waveforms?i?t.waveforms:t.waveforms.subarray(0,s*29):null,ft=t.extraBytes?t.extraBytes.length/t.batchCapacity:0,dt=t.extraBytes?i?t.extraBytes:t.extraBytes.subarray(0,s*ft):null,It=t.typedExtraBytes?t.typedExtraBytes.map(rt=>({...rt,value:i?rt.value:rt.value.subarray(0,s*rt.size)})):null,se=pp(n,o,m,a,c,l,u,f,h,y,g,x,I,q,T,b,C,_,$,X,dt,It);if(t.batchPointCount=0,i){let rt=e.las?.fp64?Float64Array:Float32Array;t.positions=new rt(t.positions.length),t.colors=t.colors?new Uint8Array(t.colors.length):null,t.rawColors=t.rawColors?new Uint16Array(t.rawColors.length):null,t.intensities=t.intensities?new Uint16Array(t.intensities.length):null,t.classifications=t.classifications?new Uint8Array(t.classifications.length):null,t.syntheticFlags=t.syntheticFlags?new Uint8Array(t.syntheticFlags.length):null,t.keyPointFlags=t.keyPointFlags?new Uint8Array(t.keyPointFlags.length):null,t.withheldFlags=t.withheldFlags?new Uint8Array(t.withheldFlags.length):null,t.overlapFlags=t.overlapFlags?new Uint8Array(t.overlapFlags.length):null,t.gpsTimes=t.gpsTimes?new Float64Array(t.gpsTimes.length):null,t.nir=t.nir?new Uint16Array(t.nir.length):null,t.scanAngles=t.scanAngles?new Int16Array(t.scanAngles.length):null,t.userData=t.userData?new Uint8Array(t.userData.length):null,t.pointSourceIds=t.pointSourceIds?new Uint16Array(t.pointSourceIds.length):null,t.returnNumbers=t.returnNumbers?new Uint8Array(t.returnNumbers.length):null,t.numberOfReturns=t.numberOfReturns?new Uint8Array(t.numberOfReturns.length):null,t.scannerChannels=t.scannerChannels?new Uint8Array(t.scannerChannels.length):null,t.scanDirectionFlags=t.scanDirectionFlags?new Uint8Array(t.scanDirectionFlags.length):null,t.edgeOfFlightLines=t.edgeOfFlightLines?new Uint8Array(t.edgeOfFlightLines.length):null,t.waveforms=t.waveforms?new Uint8Array(t.waveforms.length):null,t.extraBytes=t.extraBytes?new Uint8Array(t.extraBytes.length):null,t.typedExtraBytes=t.typedExtraBytes?t.typedExtraBytes.map(tt=>({...tt,value:hp(tt.scalarDataType,tt.value.length,tt.outputFloat64)})):null,t.typedExtraBytesSource=t.typedExtraBytesSource?new Uint8Array(t.typedExtraBytesSource.length):null,t.target.positions=t.positions,t.target.colors=t.colors,t.target.rawColors=t.rawColors,t.target.intensities=t.intensities,t.target.classifications=t.classifications,t.target.syntheticFlags=t.syntheticFlags,t.target.keyPointFlags=t.keyPointFlags,t.target.withheldFlags=t.withheldFlags,t.target.overlapFlags=t.overlapFlags,t.target.gpsTimes=t.gpsTimes,t.target.nir=t.nir,t.target.scanAngles=t.scanAngles,t.target.userData=t.userData,t.target.pointSourceIds=t.pointSourceIds,t.target.returnNumbers=t.returnNumbers,t.target.numberOfReturns=t.numberOfReturns,t.target.scannerChannels=t.scannerChannels,t.target.scanDirectionFlags=t.scanDirectionFlags,t.target.edgeOfFlightLines=t.edgeOfFlightLines,t.target.waveforms=t.waveforms,t.compatibilityExtraBytesSource=t.compatibilityExtraBytesSource?new Uint8Array(t.compatibilityExtraBytesSource.length):null,t.target.extraBytes=t.extraBytes||t.typedExtraBytesSource||t.compatibilityExtraBytesSource}return se}function uw(r){let t=r.las?.columns;if(!t)return{intensity:!0,classification:!0,synthetic:!0,keyPoint:!0,withheld:!0,overlap:!0,color:!0,gpsTime:!0,nir:!0,scanAngle:!0,userData:!0,pointSourceId:!0,returnNumber:!0,numberOfReturns:!0,scannerChannel:!0,scanDirectionFlag:!0,edgeOfFlightLine:!0,waveform:!0,extraBytes:r.las?.extraBytes==="typed"};let e=!1,n=!1,s=!1,i=!1,o=!1,a=!1,c=!1,l=!1,u=!1,f=!1,h=!1,m=!1,y=!1,g=!1,x=!1,I=!1,q=!1,T=!1,b=!1;for(let C of t)switch(C){case"POSITION":break;case"intensity":e=!0;break;case"classification":n=!0;break;case"synthetic":s=!0;break;case"keyPoint":i=!0;break;case"withheld":o=!0;break;case"overlap":a=!0;break;case"COLOR_0":c=!0;break;case"GPS_TIME":l=!0;break;case"NIR":u=!0;break;case"scanAngle":f=!0;break;case"userData":h=!0;break;case"pointSourceId":m=!0;break;case"returnNumber":y=!0;break;case"numberOfReturns":g=!0;break;case"scannerChannel":x=!0;break;case"scanDirectionFlag":I=!0;break;case"edgeOfFlightLine":q=!0;break;case"WAVEFORM":T=!0;break;case"EXTRA_BYTES":b=!0;break;default:throw new Error(`LASLoader: unsupported column ${C}`)}return{intensity:e,classification:n,synthetic:s,keyPoint:i,withheld:o,overlap:a,color:c,gpsTime:l,nir:u,scanAngle:f,userData:h,pointSourceId:m,returnNumber:y,numberOfReturns:g,scannerChannel:x,scanDirectionFlag:I,edgeOfFlightLine:q,waveform:T,extraBytes:b}}function fw(r,t,e){let n=new Uint8Array(t*4),s=new Uint32Array(n.buffer);if(PI(r,t,e.las?.colorDepth))for(let o=0;o<t;o++){let a=o*3,c=r[a]>>8&255,l=r[a+1]>>8&255,u=r[a+2]>>8&255;s[o]=4278190080|u<<16|l<<8|c}else for(let o=0;o<t;o++){let a=o*3,c=r[a]&255,l=r[a+1]&255,u=r[a+2]&255;s[o]=4278190080|u<<16|l<<8|c}return n}function PI(r,t,e){if(e===8)return!1;if(e===16)return!0;if(e!=="auto")return!1;for(let n=0;n<t*3;n++)if(r[n]>255)return!0;return!1}function kI(r,t,e){let n=t,s=t+e;for(;n<s&&r[n]!==0;)n++;return String.fromCharCode(...r.subarray(t,n))}function zI(r){let t=r.mins||[0,0,0],e=r.maxs||[0,0,0];return[[t[0],t[1],t[2]],[e[0],e[1],e[2]]]}function*VI(r,t,e,n,s,i){for(;n<e.pointsCount&&s<e.totalToRead;){let o=GI(r,t,e,n,s,i);if(!o)return;r=o.pending,t=o.absoluteOffset,n=o.sourcePointIndex,s=o.totalRead,yield o}}function GI(r,t,e,n,s,i){let o=e.pointsStructSize,c=e.pointsOffset+n*o-t;if(c<0)throw new Error("LASLoader: invalid streaming point offset");if(c+o>r.byteLength)return null;let l=Math.floor((r.byteLength-c)/o),u=Math.min(i,l,e.pointsCount-n,e.totalToRead-s);if(u<=0)return null;n+=u,s+=u;let f={...e,pointsOffset:r.byteOffset+c,pointsCount:u,totalRead:s},h=e.pointsOffset+n*o,m=Math.max(0,Math.min(r.byteLength,h-t));return{arrayBuffer:r.buffer,header:f,pending:r.subarray(m),absoluteOffset:t+m,sourcePointIndex:n,totalRead:s}}function jI(r,t){if(t!==0||r.byteLength<227)return null;let e=new DataView(r.buffer,r.byteOffset,r.byteLength);if(e.getUint32(0,!0)!==Kb)throw new Error("LASLoader: invalid LAS header");let n=e.getUint32(96,!0);return r.byteLength<Math.max(n,255)?null:iw(r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength))}function hw(r,t){if(r.byteLength===0)return t;let e=new Uint8Array(r.byteLength+t.byteLength);return e.set(r),e.set(t,r.byteLength),e}function _p(r){let t=ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r),e=new Uint8Array(t.byteLength);return e.set(t),e}function qI(r){if(Symbol.asyncIterator in r)return r[Symbol.asyncIterator]();let t=r[Symbol.iterator]();return{async next(){return t.next()}}}function $I(r,t){return dw(r,t)?r.byteLength<Wt?0:Ks(r,r.byteLength-Wt):Ks(r,t)}function Fu(r){return dw(r,0)?-1:Ks(r,0)}function dw(r,t){return r.byteLength>=t+8&&r.getUint32(t,!0)===4294967295&&r.getUint32(t+4,!0)===4294967295}function Ks(r,t){if(r.byteLength<t+8)return 0;let e=r.getUint32(t,!0);return r.getUint32(t+4,!0)*2**32+e}var Xb,Kb,Jb,$S,WS,YS,ZS,HS,Wt,XS,pw=p(()=>{"use strict";or();Yo();Gb();qb();Zb();Xb=1e3*100,Kb=1179861324,Jb=375,$S=128,WS=63,YS="laszip encoded",ZS=22204,HS=4294967295,Wt=8,XS=64*1024});function mw(r,t){let e=t?.las?._chunk;return e?tw(r,e.metadata,t||{}):Qb(r,t)}function Ou(r,t){let e=t?.las?.colorFormat===void 0||t.las.colorFormat==="uint8norm"?r:{...Ee(qg(ee(r),t.las.colorFormat),"arrow-table"),loader:r.loader,loaderData:r.loaderData,progress:r.progress};return Gg(t)==="arrow-table"?e:{...ee(e),loader:e.loader,loaderData:e.loaderData,progress:e.progress}}async function*YI(r,t){for await(let e of r)yield Ou(e,t)}function yw(r,t){return Ou(Ro(r),t)}var WI,gw=p(()=>{"use strict";or();$g();Gs();pw();WI={...jg,worker:!0,workerInBatches:!0,serializeWorkerResult:re,serializeWorkerBatch:re,deserializeWorkerResult:yw,deserializeWorkerBatch:yw,parse:async(r,t)=>Ou(mw(r,t),t),parseSync:(r,t)=>Ou(mw(r,t),t),parseInBatches:async function*(r,t){yield*YI(rw(r,t),t)}}});var bw={};Re(bw,{LASLoaderWithParser:()=>WI});var ww=p(()=>{"use strict";gw()});function Cw(r,t){let e=r.length,n=new Uint8Array(t),s=0,i=0,o,a,c;do if(o=r[s++],o<32){if(o++,i+o>t)throw new Error("Output buffer is not large enough");if(s+o>e)throw new Error("Invalid compressed data");do n[i++]=r[s++];while(--o)}else{if(a=o>>5,c=i-((o&31)<<8)-1,s>=e)throw new Error("Invalid compressed data");if(a===7&&(a+=r[s++],s>=e))throw new Error("Invalid compressed data");if(c-=r[s++],i+a+2>t)throw new Error("Output buffer is not large enough");if(c<0)throw new Error("Invalid compressed data");if(c>=i)throw new Error("Invalid compressed data");do n[i++]=n[c++];while(--a+2)}while(s<e);return n}var Fw=p(()=>{"use strict"});function Ow(r,t,e="uint8norm"){let n=[];for(let s of Object.keys(r.offset))switch(s){case"x":n.push({name:"POSITION",type:{type:"fixed-size-list",listSize:3,children:[{name:"xyz",type:"float32"}]},metadata:{attribute:"POSITION"}});break;case"y":case"z":break;case"normal_x":n.push({name:"NORMAL",type:{type:"fixed-size-list",listSize:3,children:[{name:"xyz",type:"float32"}]},metadata:{attribute:"NORMAL"}});break;case"normal_y":case"normal_z":break;case"rgb":let i=e==="float16"?"float16":e==="float32"?"float32":"uint8";n.push({name:"COLOR_0",type:{type:"fixed-size-list",listSize:3,children:[{name:"rgb",type:i}]},metadata:{attribute:"COLOR",...e==="float16"?{componentType:"float16"}:{}}});break;default:}return{fields:n,metadata:t}}var Ew=p(()=>{"use strict"});function Qo(r,t){let e=new TextDecoder().decode(r),n=oc(e),s={};switch(n.data){case"ascii":s=N2(n,e);break;case"binary":s=R2(n,r);break;case"binary_compressed":s=P2(n,r);break;default:throw new Error(`PCD: ${n.data} files are not supported`)}s=U2(s,t?.pcd?.colorFormat);let i=E2(n,s),o=Object.fromEntries([["topology","point-list"],["mode","0"],["boundingBox",JSON.stringify(i.boundingBox)]]),a=Ow(n,o,t?.pcd?.colorFormat);return{loader:"pcd",loaderData:n,header:i,schema:a,topology:"point-list",mode:0,attributes:s}}function E2(r,t){if(typeof r.width=="number"&&typeof r.height=="number"){let e=r.width*r.height,n=sn(t);if(!n)throw new Error("PCD point cloud is missing positions");return{vertexCount:e,boundingBox:n}}return{vertexCount:r.vertexCount,boundingBox:r.boundingBox}}function U2(r,t="uint8norm"){let e={POSITION:{value:new Float32Array(r.position),size:3}};return r.normal&&r.normal.length>0&&(e.NORMAL={value:new Float32Array(r.normal),size:3}),r.color&&r.color.length>0&&(e.COLOR_0=Ep(r.color,t)),r.intensity&&r.intensity.length>0&&(e.COLOR_0=Ep(r.color,t)),!e.COLOR_0&&r.label&&r.label.length>0&&(e.COLOR_0=Ep(r.label,t)),e}function Ep(r,t){return t==="float16"?{value:ti(r,255),size:3,componentType:"float16"}:t==="float32"?{value:Float32Array.from(r,e=>e/255),size:3}:{value:new Uint8Array(r),size:3}}function oc(r){let t=r.search(/[\r\n]DATA\s(\S*)\s/i),e=/[\r\n]DATA\s(\S*)\s/i.exec(r.substr(t-1)),n={};if(n.data=e&&e[1],e!==null&&(n.headerLen=(e&&e[0].length)+t),n.str=r.substr(0,n.headerLen),n.str=n.str.replace(/\#.*/gi,""),n.version=/VERSION (.*)/i.exec(n.str),n.fields=/FIELDS (.*)/i.exec(n.str),n.size=/SIZE (.*)/i.exec(n.str),n.type=/TYPE (.*)/i.exec(n.str),n.count=/COUNT (.*)/i.exec(n.str),n.width=/WIDTH (.*)/i.exec(n.str),n.height=/HEIGHT (.*)/i.exec(n.str),n.viewpoint=/VIEWPOINT (.*)/i.exec(n.str),n.points=/POINTS (.*)/i.exec(n.str),n.version!==null&&(n.version=parseFloat(n.version[1])),n.fields!==null&&(n.fields=n.fields[1].split(" ")),n.type!==null&&(n.type=n.type[1].split(" ")),n.width!==null&&(n.width=parseInt(n.width[1],10)),n.height!==null&&(n.height=parseInt(n.height[1],10)),n.viewpoint!==null&&(n.viewpoint=n.viewpoint[1]),n.points!==null&&(n.points=parseInt(n.points[1],10)),n.points===null&&typeof n.width=="number"&&typeof n.height=="number"&&(n.points=n.width*n.height),n.size!==null&&(n.size=n.size[1].split(" ").map(i=>parseInt(i,10))),n.count!==null)n.count=n.count[1].split(" ").map(i=>parseInt(i,10));else if(n.count=[],n.fields!==null)for(let i=0;i<n.fields.length;i++)n.count.push(1);n.offset={};let s=0;for(let i=0,o=n.fields.length;i<o;i++)n.data==="ascii"?n.offset[n.fields[i]]=i:(n.offset[n.fields[i]]=s,s+=n.size[i]*n.count[i]);return n.rowSize=s,n}function N2(r,t){let e=[],n=[],s=[],i=[],o=[],a=r.offset,l=t.substr(r.headerLen).split(`
|
|
29
|
-
`);for(let u=0;u<l.length;u++)if(l[u]!==""){let f=l[u].split(" ");if(a.x!==void 0&&(e.push(parseFloat(f[a.x])),e.push(parseFloat(f[a.y])),e.push(parseFloat(f[a.z]))),a.rgb!==void 0){let h=parseFloat(f[a.rgb]),m=new Float32Array([h]),y=new DataView(m.buffer,0);s.push(y.getUint8(0)),s.push(y.getUint8(1)),s.push(y.getUint8(2))}a.normal_x!==void 0&&(n.push(parseFloat(f[a.normal_x])),n.push(parseFloat(f[a.normal_y])),n.push(parseFloat(f[a.normal_z]))),a.intensity!==void 0&&i.push(parseFloat(f[a.intensity])),a.label!==void 0&&o.push(parseInt(f[a.label]))}return{position:e,normal:n,color:s}}function
|
|
28
|
+
`)}}t.length>0&&(yield t)}var ow=d(()=>{"use strict"});async function lp(r,t){let e=aI(r);for(;;){let{done:n,value:s}=await e.next();if(n){e.return&&e.return();return}if(t(s))return}}async function up(r){let t=[];for await(let e of r)t.push(cw(e));return nw(...t)}async function*Iu(r){for await(let t of r)yield cw(t)}function cw(r){if(r instanceof ArrayBuffer)return r;if(ArrayBuffer.isView(r)){let{buffer:t,byteOffset:e,byteLength:n}=r;return aw(t,e,n)}return aw(r)}function aw(r,t=0,e=r.byteLength-t){let n=new Uint8Array(r,t,e),s=new Uint8Array(n.length);return s.set(n),s.buffer}function aI(r){if(typeof r[Symbol.asyncIterator]=="function")return r[Symbol.asyncIterator]();if(typeof r[Symbol.iterator]=="function"){let t=r[Symbol.iterator]();return cI(t)}return r}function cI(r){return{next(t){return Promise.resolve(r.next(t))},return(t){return typeof r.return=="function"?Promise.resolve(r.return(t)):Promise.resolve({done:!0,value:t})},throw(t){return typeof r.throw=="function"?Promise.resolve(r.throw(t)):Promise.reject(t)}}}var lw=d(()=>{"use strict";sw()});function Np(r){return new dp(r)}function mp(r){return{intensity:!!r.intensities,classification:!!r.classifications,color:!!(r.colors||r.rawColors),gpsTime:!!r.gpsTimes,nir:!!r.nir,scanAngle:!!r.scanAngles,userData:!!r.userData,pointSourceId:!!r.pointSourceIds,flags:!!(r.scannerChannels||r.scanDirectionFlags||r.edgeOfFlightLines||r.syntheticFlags||r.keyPointFlags||r.withheldFlags||r.overlapFlags),waveform:!!r.waveforms,extraBytes:!!r.extraBytes}}function gw(r){return(r.intensity?1:0)|(r.classification?2:0)|(r.color?4:0)|(r.gpsTime?8:0)|(r.nir?16:0)|(r.scanAngle?32:0)|(r.userData?64:0)|(r.pointSourceId?128:0)|(r.flags?256:0)|(r.waveform?512:0)|(r.extraBytes?1024:0)}function jr(r,t){return new pp(r,t)}function Uu(r,t){let e=jr(r,t),n=new Uint8Array(t.pointCount*t.pointDataRecordLength);return e.decodeInto(n,0,t.pointCount),n}function bw(r,t){if(!zu(t.pointDataRecordFormat))throw new it("Legacy LAZ chunk byte length is not self-describing");let e=Qo(r),n=Jo(t),s=t.pointDataRecordLength,i=yc(t.pointDataRecordFormat,n),o=s+4,a=i*4;if(e.byteLength<o+a)throw new it;let c=new DataView(e.buffer,e.byteOffset,e.byteLength),l=o+a;for(let u=0;u<i;u++)l+=c.getUint32(o+u*4,!0);if(e.byteLength<l)throw new it;return l}function Up(r,t){let e=new _u(Qo(r)),n=new ne(e),s=Bt(32,2);n.readInitBytes();let i=[],o=0,a=0,c=t.pointCount;for(let l=0;l<t.chunkCount;l++){let u;t.variable?(o=s.decompress(n,o,0)>>>0,u=o):(u=Math.min(t.chunkSize,c),c-=u),a=s.decompress(n,a,1)>>>0,i.push({pointCount:u,byteLength:a})}return i}function Ru(r){if(!zu(r.pointDataRecordFormat))return r.pointDataRecordLength+4;let t=Jo(r);return r.pointDataRecordLength+4+yc(r.pointDataRecordFormat,t)*4}function Pu(r,t){if(!zu(t.pointDataRecordFormat))throw new it("Legacy LAZ chunk byte length is not self-describing");let e=yp(Qo(r),t);if(!e)throw new it("LAZ chunk decoder needs the complete layered size header");return e.byteLength}function yp(r,t){let e=Jo(t),n=t.pointDataRecordLength+4,s=yc(t.pointDataRecordFormat,e),i=s*4;if(r.byteLength<n+i)return null;let o=new DataView(r.buffer,r.byteOffset,r.byteLength),a=n+i,c=[];for(let u=0;u<s;u++){let f=o.getUint32(n+u*4,!0);a+=f,c.push(f)}let l=n+i;return{byteLength:a,layerByteLengths:c,getByteLength:u=>l+c.slice(0,u).reduce((f,h)=>f+h,0)}}function lI(r,t){if(t.extraBytes)return yc(r.pointDataRecordFormat,Jo(r));let e=2;return t.classifications&&(e=3),(t.scannerChannels||t.scanDirectionFlags||t.edgeOfFlightLines||t.syntheticFlags||t.keyPointFlags||t.withheldFlags||t.overlapFlags)&&(e=4),t.intensities&&(e=5),t.scanAngles&&(e=6),t.userData&&(e=7),t.pointSourceIds&&(e=8),t.gpsTimes&&(e=9),(t.colors||t.rawColors)&&(e=10),t.nir&&(e=11),t.waveforms&&(e=r.pointDataRecordFormat===9?10:12),Math.min(e,yc(r.pointDataRecordFormat,Jo(r)))}function hp(r){let t=r.byteItemVersion===1?4:2;return Math.max(gI,r.pointDataRecordLength*t+512)}function hw(r){return r[0]<r[1]?r[1]<r[2]?r[1]:Math.max(r[0],r[2]):r[0]<r[2]?r[0]:Math.max(r[1],r[2])}function wI(r,t,e,n){let s=Jo(t);for(let i of[t.point10ItemVersion,t.gpsTime11ItemVersion,t.rgb12ItemVersion,t.byteItemVersion])if(i!==void 0&&i!==1&&i!==2)throw new Error(`Unsupported legacy LASzip item version ${i}`);switch(t.pointDataRecordFormat){case 0:return new Sp(r,s,t);case 1:return new Ip(r,s,t);case 2:return new Bp(r,s,t);case 3:return new _p(r,s,t,e==="point-data"?n:null);case 4:return new Lp(r,s,t);case 5:return new Tp(r,s,t);case 6:return new Mp(r,s,e,t,n);case 7:return new Dp(r,s,e,t,n);case 8:return new Cp(r,s,e,t,n);case 9:return new Fp(r,s,e,t,n);case 10:return new Ep(r,s,e,t,n);default:throw new Error(`TypeScript LAZ decoder does not support point format ${t.pointDataRecordFormat}`)}}function xI(r){return r<=5||r>=6&&r<=10}function Bt(r,t){let e=new bp(r,t);return e.init(),e}function ge(r,t){return Array.from({length:r},()=>new $t(t))}function Jo(r){let t=AI(r.pointDataRecordFormat),e=r.pointDataRecordLength-t;if(e<0)throw new Error(`Invalid point record length ${r.pointDataRecordLength}`);return e}function AI(r){switch(r){case 0:return 20;case 1:return 28;case 2:return 26;case 3:return 34;case 4:return 57;case 5:return 63;case 6:return 30;case 7:return 36;case 8:return 38;case 9:return 59;case 10:return 67;default:throw new Error(`TypeScript LAZ decoder does not support point format ${r}`)}}function zu(r){return r>=6&&r<=10}function yc(r,t){switch(r){case 6:return 9+t;case 7:return 10+t;case 8:return 11+t;case 9:return 10+t;case 10:return 12+t;default:throw new Error(`TypeScript LAZ decoder does not support point format ${r}`)}}function vI(){return{x:0,y:0,z:0,intensity:0,returns:0,flags:0,classification:0,userData:0,scanAngle:0,pointSourceId:0,gpsTime:0}}function dw(){return{x:0,y:0,z:0,intensity:0,bitByte:0,classification:0,scanAngleRank:0,userData:0,pointSourceId:0}}function SI(r,t){r.x=Yo(t),r.y=Yo(t),r.z=Yo(t),r.intensity=Ks(t),r.bitByte=t.getByte(),r.classification=t.getByte(),r.scanAngleRank=Op(t.getByte()),r.userData=t.getByte(),r.pointSourceId=Ks(t)}function II(r,t){r.x=t.x,r.y=t.y,r.z=t.z,r.intensity=t.intensity,r.bitByte=t.bitByte,r.classification=t.classification,r.scanAngleRank=t.scanAngleRank,r.userData=t.userData,r.pointSourceId=t.pointSourceId}function BI(r,t,e){Ne(r.x,t,e),Ne(r.y,t,e+4),Ne(r.z,t,e+8),ar(r.intensity,t,e+12),t[e+14]=r.bitByte,t[e+15]=r.classification,t[e+16]=r.scanAngleRank&255,t[e+17]=r.userData,ar(r.pointSourceId,t,e+18)}function kn(r,t,e,n,s,i,o){let a=o*3;t[a]=r.x*s[0]+i[0],t[a+1]=r.y*s[1]+i[1],t[a+2]=r.z*s[2]+i[2],e&&(e[o]=r.intensity),n&&(n[o]=r.classification&31)}function Ki(r,t,e){let n=r.classification>>5;t.syntheticFlags&&(t.syntheticFlags[e]=n&1),t.keyPointFlags&&(t.keyPointFlags[e]=n>>1&1),t.withheldFlags&&(t.withheldFlags[e]=n>>2&1),t.overlapFlags&&(t.overlapFlags[e]=0),t.scanAngles&&(t.scanAngles[e]=r.scanAngleRank),t.userData&&(t.userData[e]=r.userData),t.pointSourceIds&&(t.pointSourceIds[e]=r.pointSourceId),t.returnNumbers&&(t.returnNumbers[e]=r.bitByte&7),t.numberOfReturns&&(t.numberOfReturns[e]=r.bitByte>>3&7),t.scannerChannels&&(t.scannerChannels[e]=0),t.scanDirectionFlags&&(t.scanDirectionFlags[e]=r.bitByte>>6&1),t.edgeOfFlightLines&&(t.edgeOfFlightLines[e]=r.bitByte>>7&1)}function pw(r){return r.bitByte&7}function mw(r){return r.bitByte>>3&7}function _I(r){return r.bitByte>>6&1}function yw(r,t){r.x=t.x,r.y=t.y,r.z=t.z,r.intensity=t.intensity,r.returns=t.returns,r.flags=t.flags,r.classification=t.classification,r.userData=t.userData,r.scanAngle=t.scanAngle,r.pointSourceId=t.pointSourceId,r.gpsTime=t.gpsTime}function LI(r,t,e){r.x=$r(t,e),r.y=$r(t,e+4),r.z=$r(t,e+8),r.intensity=Fu(t,e+12),r.returns=t[e+14],r.flags=t[e+15],r.classification=t[e+16],r.userData=t[e+17],r.scanAngle=UI(t,e+18),r.pointSourceId=Fu(t,e+20),r.gpsTime=PI(t,e+22)}function TI(r,t){r.x=Yo(t),r.y=Yo(t),r.z=Yo(t),r.intensity=Ks(t),r.returns=t.getByte(),r.flags=t.getByte(),r.classification=t.getByte(),r.userData=t.getByte(),r.scanAngle=Pp(Ks(t)),r.pointSourceId=Ks(t),r.gpsTime=vw(t)}function MI(r,t,e){Ne(r.x,t,e),Ne(r.y,t,e+4),Ne(r.z,t,e+8),ar(r.intensity,t,e+12),t[e+14]=r.returns,t[e+15]=r.flags,t[e+16]=r.classification,t[e+17]=r.userData,RI(r.scanAngle,t,e+18),ar(r.pointSourceId,t,e+20),Sw(r.gpsTime,t,e+22)}function gc(r,t,e){Xs(r,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),Ji(r,t,e),Qi(r,t,e)}function Xs(r,t,e,n,s,i,o){let a=o*3;t[a]=r.x*s[0]+i[0],t[a+1]=r.y*s[1]+i[1],t[a+2]=r.z*s[2]+i[2],e&&(e[o]=r.intensity),n&&(n[o]=r.classification)}function Ji(r,t,e){t.gpsTimes&&(t.gpsTimes[e]=r.gpsTime)}function Qi(r,t,e){t.scanAngles&&(t.scanAngles[e]=r.scanAngle),t.userData&&(t.userData[e]=r.userData),t.pointSourceIds&&(t.pointSourceIds[e]=r.pointSourceId),t.returnNumbers&&(t.returnNumbers[e]=r.returns&15),t.numberOfReturns&&(t.numberOfReturns[e]=r.returns>>4),t.scannerChannels&&(t.scannerChannels[e]=r.flags>>4&3),t.scanDirectionFlags&&(t.scanDirectionFlags[e]=r.flags>>6&1),t.edgeOfFlightLines&&(t.edgeOfFlightLines[e]=r.flags>>7&1),t.syntheticFlags&&(t.syntheticFlags[e]=r.flags&1),t.keyPointFlags&&(t.keyPointFlags[e]=r.flags>>1&1),t.withheldFlags&&(t.withheldFlags[e]=r.flags>>2&1),t.overlapFlags&&(t.overlapFlags[e]=r.flags>>3&1)}function Cu(r,t,e){t.nir&&(t.nir[e]=r)}function to(r,t,e,n,s){if(n.colors){let o=s*4;n.colors[o]=r&255,n.colors[o+1]=t&255,n.colors[o+2]=e&255,n.colors[o+3]=255;return}if(!n.rawColors)return;let i=s*3;n.rawColors[i]=r,n.rawColors[i+1]=t,n.rawColors[i+2]=e}function DI(r){return r.flags>>4&3}function CI(r,t){r.flags=(t&3)<<4|r.flags&-49}function FI(r,t){r.flags=t&15|r.flags&240}function EI(r,t){r.flags=(t&1)<<6|r.flags&191}function OI(r,t){r.flags=(t&1)<<7|r.flags&127}function NI(r){return r.flags&15|(r.flags>>6&1)<<4|(r.flags>>7&1)<<5}function Fu(r,t){return r[t]|r[t+1]<<8}function Ks(r){let t=r.getByte(),e=r.getByte();return t|e<<8}function ar(r,t,e){t[e]=r&255,t[e+1]=r>>8&255}function UI(r,t){return Pp(Fu(r,t))}function RI(r,t,e){ar(r,t,e)}function Eu(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24>>>0)>>>0}function Ou(r,t,e){Ne(r,t,e)}function xw(r,t){let e=Eu(r,t),n=Eu(r,t+4);return BigInt(n)<<32n|BigInt(e)}function Aw(r,t,e){Ou(Number(r&0xffffffffn),t,e),Ou(Number(r>>32n&0xffffffffn),t,e+4)}function $r(r,t){return r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24}function Yo(r){let t=r.getByte(),e=r.getByte(),n=r.getByte(),s=r.getByte();return t|e<<8|n<<16|s<<24}function Ne(r,t,e){t[e]=r&255,t[e+1]=r>>8&255,t[e+2]=r>>16&255,t[e+3]=r>>24&255}function PI(r,t){for(let e=0;e<8;e++)Rp[e]=r[t+e];return Zi.getFloat64(0,!0)}function vw(r){for(let t=0;t<8;t++)Rp[t]=r.getByte();return Zi.getFloat64(0,!0)}function Sw(r,t,e){Zi.setFloat64(0,r,!0);for(let n=0;n<8;n++)t[e+n]=Rp[n]}function Hs(r){return r<=0?0:r>=255?255:r}function Pp(r){let t=r&65535;return t&32768?t-65536:t}function Op(r){let t=r&255;return t&128?t-256:t}function cn(r){return r|0}function Nu(r){return Zi.setFloat64(0,r,!0),Zi.getBigUint64(0,!0)}function Zo(r){return Zi.setBigUint64(0,r,!0),Zi.getFloat64(0,!0)}function Zs(r,t){let e=BigInt.asIntN(64,BigInt.asIntN(64,Nu(r))+BigInt(t));return Zo(BigInt.asUintN(64,e))}function Qo(r){return r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function kI(r){let t=r.reduce((s,i)=>s+i.byteLength,0),e=new Uint8Array(t),n=0;for(let s of r)e.set(s,n),n+=s.byteLength;return e}var it,dp,pp,Wo,uI,ku,fI,hI,dc,dI,uw,pI,mI,an,Ho,Bu,yI,fp,ww,Rp,Zi,gI,fw,bI,_u,$t,gp,ne,bp,Xo,Js,pc,Qs,Ut,wp,Hi,xp,mc,Ap,Lu,Tu,Mu,vp,Xi,Sp,Ko,Ip,Bp,_p,Du,Lp,Tp,Mp,Dp,Cp,Fp,Ep,Iw=d(()=>{"use strict";it=class extends Error{constructor(t="LAZ chunk decoder needs more compressed data"){super(t),this.name="NeedsMoreData"}},dp=class{metadata;chunks=[];closed=!1;compressed=null;cursor=null;fedByteLength=0;requiredByteLength=null;progressiveRequiredByteLength=null;progressiveSelectionKey=null;constructor(t){this.metadata=t}feed(t){if(this.closed)throw new Error("Cannot feed a closed LAZ chunk decoder");let e=Qo(t);this.chunks.push(e),this.compressed=null,this.fedByteLength+=e.byteLength}close(){this.closed=!0}get remainingPointCount(){return this.cursor?.remainingPointCount??this.metadata.pointCount}decode(){if(!this.closed)throw new it("LAZ chunk decoder input is not closed");return this.decodeAvailable()}readBatch(t){if(!this.cursor){if(!this.hasCompleteChunk())return null;let i=this.getCompressedAvailable(),o=this.requiredByteLength??i.byteLength;this.cursor=jr(i.subarray(0,o),this.metadata)}if(this.cursor.remainingPointCount<=0)return null;let e=this.metadata.pointDataRecordLength,n=Math.min(t,this.cursor.remainingPointCount),s=new Uint8Array(n*e);return this.cursor.decodeInto(s,0,n),s}readPositionDataBatch(t,e){if(t.colors||t.rawColors||t.nir)throw new Error("Position-only LAZ batches cannot request color or NIR output");return this.readPointDataBatch(t,e)}readPointDataBatch(t,e){let n=this.metadata.pointDataRecordFormat;if(n<6||n>10)throw new Error("Progressive LAZ point-data batches require point formats 6-10");let s=n===7||n===8||n===10;if((t.colors||t.rawColors)&&!s)throw new Error(`Point format ${n} does not contain RGB data`);if(t.nir&&n!==8&&n!==10)throw new Error("NIR output requires point format 8 or 10");if(t.waveforms&&n!==9&&n!==10)throw new Error("Waveform output requires point format 9 or 10");if(!this.cursor){let o=this.getProgressivePointData(t);if(!o)return null;this.cursor=jr(o,this.metadata)}if(this.cursor.remainingPointCount<=0)return 0;let i=Math.min(e,this.cursor.remainingPointCount);return this.cursor.decodeIntoPointData(t,i)}hasCompleteChunk(){if(!zu(this.metadata.pointDataRecordFormat))return this.closed;if(this.requiredByteLength!==null)return this.fedByteLength>=this.requiredByteLength;if(this.fedByteLength<Ru(this.metadata))return!1;try{let t=this.getCompressedAvailable();return this.requiredByteLength=bw(t,this.metadata),this.requiredByteLength<=this.fedByteLength}catch(t){if(t instanceof it)return!1;throw t}}decodeAvailable(){let t=this.getCompressedAvailable(),e=this.requiredByteLength??t.byteLength;return Uu(t.subarray(0,e),this.metadata)}getCompressedAvailable(){return this.compressed||=kI(this.chunks),this.compressed}getProgressivePointData(t){let e=gw(mp(t));if(this.progressiveSelectionKey!==e&&(this.progressiveRequiredByteLength=null,this.progressiveSelectionKey=e),this.progressiveRequiredByteLength===null){let o=this.getCompressedAvailable(),a=yp(o,this.metadata);if(!a)return null;let c=lI(this.metadata,t);this.progressiveRequiredByteLength=a.getByteLength(c)}if(this.fedByteLength<this.progressiveRequiredByteLength)return null;let n=this.getCompressedAvailable(),s=yp(n,this.metadata),i=new Uint8Array(s.byteLength);return i.set(n.subarray(0,Math.min(n.byteLength,s.byteLength))),i}};pp=class{metadata;stream;decoder=null;pointIndex=0;outputMode=null;pointDataSelectionKey=null;constructor(t,e){this.metadata=e,this.stream=new _u(Qo(t))}feed(t){if(this.metadata.pointDataRecordFormat>5)throw new Error("Only legacy PDRF 0-5 LAZ cursors accept additional compressed input");this.stream.append(Qo(t))}discardConsumedInput(){if(this.metadata.pointDataRecordFormat>5)throw new Error("Only legacy PDRF 0-5 LAZ cursors can discard consumed input");this.stream.discardConsumedInput()}get remainingPointCount(){return this.metadata.pointCount-this.pointIndex}get compressedByteOffset(){return this.stream.byteOffset}get requiredInputByteLength(){if(this.metadata.pointDataRecordFormat>5)return this.stream.byteOffset;let t=this.pointIndex===0?this.metadata.pointDataRecordLength+4:hp(this.metadata);return this.stream.byteOffset+t}decodeInto(t,e,n){let s=Math.min(n,this.remainingPointCount),i=this.selectOutputMode("raw",s);if(!i)return 0;let o=e;for(let a=0;a<s;a++)o=i.decompress(t,o);return this.pointIndex+=s,s}decodeAvailableInto(t,e,n,s=!1){if(this.metadata.pointDataRecordFormat>5)throw new Error("Available-point decoding is limited to legacy PDRF 0-5 LAZ chunks");let i=Math.min(n,this.remainingPointCount);if(i===0)return 0;let o=this.selectOutputMode("raw",i),a=0,c=e;for(;a<i;){let l=this.pointIndex===0?this.metadata.pointDataRecordLength+4:hp(this.metadata);if(!s&&this.stream.availableByteLength<l)break;try{c=o.decompress(t,c)}catch(u){throw u instanceof it&&!s?new Error(`Legacy LAZ point exceeded the ${l}-byte streaming lookahead`):u}a++,this.pointIndex++}return a}decodeAvailableIntoPointData(t,e,n=!1){if(this.metadata.pointDataRecordFormat>5)throw new Error("Available point-data decoding is limited to legacy PDRF 0-5 LAZ chunks");let s=Math.min(e,this.remainingPointCount);if(s===0)return 0;let i=mp(t),o=this.selectOutputMode("point-data",s,i),a=0,c=t.pointOffset;for(;a<s;){let l=this.pointIndex===0?this.metadata.pointDataRecordLength+4:hp(this.metadata);if(!n&&this.stream.availableByteLength<l)break;try{t.pointOffset=c+a,o.decompressPointData?o.decompressPointData(t,t.pointOffset):o.decompressPointDataBatch(t,1)}catch(u){throw t.pointOffset=c,u instanceof it&&!n?new Error(`Legacy LAZ point exceeded the ${l}-byte streaming lookahead`):u}a++,this.pointIndex++}return t.pointOffset=c,a}decodeIntoPointData(t,e){let n=Math.min(e,this.remainingPointCount);if(n>0&&!xI(this.metadata.pointDataRecordFormat))throw new Error(`TypeScript LAZ decoder does not support direct point-data output for point format ${this.metadata.pointDataRecordFormat}`);let s=mp(t),i=this.selectOutputMode("point-data",n,s);if(!i)return 0;if(i.decompressPointDataBatch)i.decompressPointDataBatch(t,n);else for(let o=0;o<n;o++)i.decompressPointData(t,t.pointOffset+o);return this.pointIndex+=n,n}selectOutputMode(t,e,n=null){if(e===0)return null;if(this.outputMode&&this.outputMode!==t)throw new Error("Cannot mix raw and point-data decoding in one LAZ chunk cursor");if(t==="point-data"){let s=gw(n);if(this.pointDataSelectionKey!==null&&this.pointDataSelectionKey!==s)throw new Error("Cannot change selected point-data fields in one LAZ chunk cursor");this.pointDataSelectionKey=s}return this.outputMode=t,this.decoder||=wI(this.stream,this.metadata,t,n),this.decoder}};Wo=16777216,uI=4294967295,ku=13,fI=1<<ku,hI=2**(31-ku),dc=15,dI=1<<dc,uw=2**(31-dc),pI=[[0,1,2,3,4,5,3,4,4,5,5,5,5,5,5,5],[1,0,1,3,3,3,3,3,3,3,3,3,3,3,3,3],[2,1,2,4,4,4,4,4,4,4,4,3,3,3,3,3],[3,3,4,5,4,4,4,4,4,4,4,4,4,4,4,4],[4,3,4,4,5,4,4,4,4,4,4,4,4,4,4,4],[5,3,4,4,4,5,4,4,4,4,4,4,4,4,4,4],[3,3,4,4,4,4,5,4,4,4,4,4,4,4,4,4],[4,3,4,4,4,4,4,5,4,4,4,4,4,4,4,4],[4,3,4,4,4,4,4,4,5,4,4,4,4,4,4,4],[5,3,4,4,4,4,4,4,4,5,4,4,4,4,4,4],[5,3,4,4,4,4,4,4,4,4,5,4,4,4,4,4],[5,3,3,4,4,4,4,4,4,4,4,5,5,4,4,4],[5,3,3,4,4,4,4,4,4,4,4,5,5,5,4,4],[5,3,3,4,4,4,4,4,4,4,4,4,5,5,5,4],[5,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5],[5,3,3,4,4,4,4,4,4,4,4,4,4,4,5,5]],mI=[[0,1,2,3,4,5,6,7,7,7,7,7,7,7,7,7],[1,0,1,2,3,4,5,6,7,7,7,7,7,7,7,7],[2,1,0,1,2,3,4,5,6,7,7,7,7,7,7,7],[3,2,1,0,1,2,3,4,5,6,7,7,7,7,7,7],[4,3,2,1,0,1,2,3,4,5,6,7,7,7,7,7],[5,4,3,2,1,0,1,2,3,4,5,6,7,7,7,7],[6,5,4,3,2,1,0,1,2,3,4,5,6,7,7,7],[7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,7],[7,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7],[7,7,7,6,5,4,3,2,1,0,1,2,3,4,5,6],[7,7,7,7,6,5,4,3,2,1,0,1,2,3,4,5],[7,7,7,7,7,6,5,4,3,2,1,0,1,2,3,4],[7,7,7,7,7,7,6,5,4,3,2,1,0,1,2,3],[7,7,7,7,7,7,7,6,5,4,3,2,1,0,1,2],[7,7,7,7,7,7,7,7,6,5,4,3,2,1,0,1],[7,7,7,7,7,7,7,7,7,6,5,4,3,2,1,0]],an=500,Ho=-10,Bu=511,yI=an-Ho+1,fp=an-Ho+2,ww=new ArrayBuffer(8),Rp=new Uint8Array(ww),Zi=new DataView(ww),gI=16*1024;fw=[[15,14,13,12,11,10,9,8],[14,0,1,3,6,10,10,9],[13,1,2,4,7,11,11,10],[12,3,4,5,8,12,12,11],[11,6,7,8,9,13,13,12],[10,10,11,12,13,14,14,13],[9,10,11,12,13,14,15,14],[8,9,10,11,12,13,14,15]],bI=[[0,1,2,3,4,5,6,7],[1,0,1,2,3,4,5,6],[2,1,0,1,2,3,4,5],[3,2,1,0,1,2,3,4],[4,3,2,1,0,1,2,3],[5,4,3,2,1,0,1,2],[6,5,4,3,2,1,0,1],[7,6,5,4,3,2,1,0]],_u=class{bytes;length;offset=0;discardedByteLength=0;constructor(t){this.bytes=t,this.length=t.byteLength}get byteOffset(){return this.discardedByteLength+this.offset}get availableByteLength(){return this.length-this.offset}get data(){return this.length===this.bytes.byteLength?this.bytes:this.bytes.subarray(0,this.length)}append(t){if(t.byteLength===0)return;let e=this.length+t.byteLength;if(e>this.bytes.byteLength){let n=Math.max(e,Math.max(64,this.bytes.byteLength*2)),s=new Uint8Array(n);s.set(this.bytes.subarray(0,this.length)),this.bytes=s}this.bytes.set(t,this.length),this.length=e}discardConsumedInput(){this.offset!==0&&(this.bytes=this.bytes.slice(this.offset,this.length),this.discardedByteLength+=this.offset,this.length-=this.offset,this.offset=0)}getByte(){if(this.offset>=this.length)throw new it;return this.bytes[this.offset++]}getBytes(t,e,n){if(this.offset+n>this.length)throw new it;t.set(this.bytes.subarray(this.offset,this.offset+n),e),this.offset+=n}consume(t){if(this.offset+t>this.length)throw new it;let e=this.offset;return this.offset+=t,e}getUint32(){let t=this.getByte(),e=this.getByte(),n=this.getByte(),s=this.getByte();return(t|e<<8|n<<16|s<<24>>>0)>>>0}},$t=class{symbols;distribution;symbolCount;decoderTable;totalCount=0;updateCycle;symbolsUntilUpdate;lastSymbol;tableSize=0;tableShift=0;constructor(t){if(t<2||t>2048)throw new Error(`Invalid arithmetic model symbol count ${t}`);if(this.symbols=t,this.lastSymbol=t-1,t>16){let e=3;for(;t>1<<e+2;)e++;this.tableSize=1<<e,this.tableShift=dc-e,this.decoderTable=new Uint32Array(this.tableSize+2)}else this.decoderTable=null;this.distribution=new Uint32Array(t),this.symbolCount=new Uint32Array(t),this.symbolCount.fill(1),this.updateCycle=t,this.symbolsUntilUpdate=t,this.update(),this.symbolsUntilUpdate=this.updateCycle=t+6>>1}update(){if(this.totalCount+=this.updateCycle,this.totalCount>dI){this.totalCount=0;for(let i=0;i<this.symbols;i++)this.symbolCount[i]=this.symbolCount[i]+1>>1,this.totalCount+=this.symbolCount[i]}let t=0,e=0,n=2147483648/this.totalCount|0;if(this.decoderTable){for(let i=0;i<this.symbols;i++){this.distribution[i]=n*t/uw|0,t+=this.symbolCount[i];let o=this.distribution[i]>>this.tableShift;for(;e<o;)this.decoderTable[++e]=i-1}for(this.decoderTable[0]=0;e<=this.tableSize;)this.decoderTable[++e]=this.symbols-1}else for(let i=0;i<this.symbols;i++)this.distribution[i]=n*t/uw|0,t+=this.symbolCount[i];this.updateCycle=5*this.updateCycle>>2;let s=this.symbols+6<<3;this.updateCycle>s&&(this.updateCycle=s),this.symbolsUntilUpdate=this.updateCycle}},gp=class{updateCycle=4;bitsUntilUpdate=4;bit0Prob=1<<ku-1;bit0Count=1;bitCount=2;update(){this.bitCount+=this.updateCycle,this.bitCount>fI&&(this.bitCount=this.bitCount+1>>1,this.bit0Count=this.bit0Count+1>>1,this.bit0Count===this.bitCount&&this.bitCount++);let t=2147483648/this.bitCount|0;this.bit0Prob=this.bit0Count*t/hI|0,this.updateCycle=5*this.updateCycle>>2,this.updateCycle>64&&(this.updateCycle=64),this.bitsUntilUpdate=this.updateCycle}},ne=class{input;inputBytes=null;inputOffset=0;inputEnd=0;value=0;length=uI;valid=!1;constructor(t=null){this.input=t}initStream(t,e){e?(this.inputBytes=t.data,this.inputOffset=t.consume(e),this.inputEnd=this.inputOffset+e,this.input=null,this.readInitBytes(),this.valid=!0):this.valid=!1}readInitBytes(){if(this.inputBytes){let e=this.inputOffset;if(e+4>this.inputEnd)throw new it;this.value=(this.inputBytes[e]<<24>>>0|this.inputBytes[e+1]<<16|this.inputBytes[e+2]<<8|this.inputBytes[e+3])>>>0,this.inputOffset=e+4;return}let t=this.input;this.value=(t.getByte()<<24>>>0|t.getByte()<<16|t.getByte()<<8|t.getByte())>>>0}decodeBit(t){let e=this.value,n=this.length,s=t.bit0Prob*(n>>>ku),i=e>=s?1:0;return i===0?(this.length=s>>>0,t.bit0Count++):(this.value=e-s>>>0,this.length=n-s>>>0),this.length<Wo&&this.renormalize(),--t.bitsUntilUpdate===0&&t.update(),i}decodeSymbol(t){let e,n,s=this.length,i=s,o=this.value,a=t.distribution,c=t.decoderTable;if(c){s>>>=dc;let l=o/s|0,u=l>>t.tableShift;e=c[u];let f=c[u+1]+1;for(;f>e+1;){let h=e+f>>1;a[h]>l?f=h:e=h}n=a[e]*s,e!==t.lastSymbol&&(i=a[e+1]*s)}else{n=0,e=0,s>>>=dc;let l=t.symbols,u=l>>1;do{let f=s*a[u];f>o?(l=u,i=f):(e=u,n=f),u=e+l>>1}while(u!==e)}return this.value=o-n>>>0,this.length=i-n>>>0,this.length<Wo&&this.renormalize(),t.symbolCount[e]++,--t.symbolsUntilUpdate===0&&t.update(),e}readBits(t){if(t>19){let i=this.readShort();return(this.readBits(t-16)<<16|i)>>>0}let e=this.length>>>t,n=this.value,s=n/e|0;return this.value=n-e*s>>>0,this.length=e>>>0,e<Wo&&this.renormalize(),s>>>0}readShort(){let t=this.length>>>16,e=this.value,n=e/t|0;return this.value=e-t*n>>>0,this.length=t>>>0,t<Wo&&this.renormalize(),n&65535}readInt(){let t=this.readShort();return(this.readShort()<<16|t)>>>0}readUint64(){let t=this.readInt(),e=this.readInt();return BigInt(e)<<32n|BigInt(t)}renormalize(){let t=this.value,e=this.length;if(this.inputBytes){let n=this.inputBytes,s=this.inputEnd,i=this.inputOffset;do{if(i>=s)throw new it;t=(t<<8|n[i++])>>>0,e=e<<8>>>0}while(e<Wo);this.inputOffset=i}else{let n=this.input;do t=(t<<8|n.getByte())>>>0,e=e<<8>>>0;while(e<Wo)}this.value=t,this.length=e}},bp=class{contexts;bitsHigh;corrBits;corrRange;corrMin;mBits=[];mCorrector0=new gp;mCorrector=[];k=0;constructor(t=16,e=1,n=8,s=0){if(this.contexts=e,this.bitsHigh=n,s){for(this.corrBits=0,this.corrRange=s;s;)s>>=1,this.corrBits++;this.corrRange===1<<this.corrBits-1&&this.corrBits--,this.corrMin=-(this.corrRange/2)}else t&&t<32?(this.corrBits=t,this.corrRange=1<<t,this.corrMin=-(this.corrRange/2)):(this.corrBits=32,this.corrRange=0,this.corrMin=-2147483648)}init(){if(!this.mBits.length){for(let t=0;t<this.contexts;t++)this.mBits.push(new $t(this.corrBits+1));for(let t=1;t<=this.corrBits;t++){let e=t<=this.bitsHigh?1<<t:1<<this.bitsHigh;this.mCorrector.push(new $t(e))}}}decompress(t,e,n){let s=t.decodeSymbol(this.mBits[n]);this.k=s;let i;if(s)if(s<32){let a=this.bitsHigh,c=this.mCorrector[s-1];if(s<=a)i=t.decodeSymbol(c);else{let l=s-a;i=t.decodeSymbol(c),i=i<<l|t.readBits(l)}i>=1<<s-1?i+=1:i-=(1<<s)-1}else i=this.corrMin;else i=t.decodeBit(this.mCorrector0);let o=cn(e+i);return this.corrRange===0||(o<0?o=cn(o+this.corrRange):o>=this.corrRange&&(o=cn(o-this.corrRange))),o}},Xo=class{value0=0;value1=0;value2=0;value3=0;value4=0;high=!0;add(t){this.high?t<this.value2?(this.value4=this.value3,this.value3=this.value2,t<this.value0?(this.value2=this.value1,this.value1=this.value0,this.value0=t):t<this.value1?(this.value2=this.value1,this.value1=t):this.value2=t):(t<this.value3?(this.value4=this.value3,this.value3=t):this.value4=t,this.high=!1):this.value2<t?(this.value0=this.value1,this.value1=this.value2,this.value4<t?(this.value2=this.value3,this.value3=this.value4,this.value4=t):this.value3<t?(this.value2=this.value3,this.value3=t):this.value2=t):(this.value1<t?(this.value0=this.value1,this.value1=t):this.value0=t,this.high=!0)}get(){return this.value2}};Js=class{itemVersion;stream;decoder;changedValuesModel=new $t(64);bitByteModel=ge(256,256);classificationModel=ge(256,256);scanAngleRankModel=ge(2,256);userDataModel=ge(256,256);intensity=Bt(16,4);pointSourceId=Bt(16,1);dx=Bt(32,2);dy=Bt(32,22);z=Bt(32,20);lastIntensity=new Array(16).fill(0);lastHeight=new Array(8).fill(0);lastXDiffMedian=Array.from({length:16},()=>new Xo);lastYDiffMedian=Array.from({length:16},()=>new Xo);haveLast=!1;last=dw();firstPoint=dw();legacyXDiffs=[0,0,0];legacyYDiffs=[0,0,0];legacyDifferenceIndex=0;legacyScanAngle=null;constructor(t,e=2){this.itemVersion=e,this.stream=t,this.decoder=new ne(t),e===1&&(this.legacyScanAngle=Bt(8,2),this.dx=Bt(32,1),this.dy=Bt(32,20),this.intensity=Bt(16,1))}getDecoder(){return this.decoder}decompress(t,e){let n=this.decompressPoint();return BI(n,t,e),e+20}decompressPoint(){if(!this.haveLast)return this.haveLast=!0,SI(this.last,this.stream),II(this.firstPoint,this.last),this.itemVersion===2&&(this.last.intensity=0),this.firstPoint;if(this.itemVersion===1)return this.decompressLegacyPoint();let t=this.decoder.decodeSymbol(this.changedValuesModel);if(t){t&32&&(this.last.bitByte=this.decoder.decodeSymbol(this.bitByteModel[this.last.bitByte]));let h=pw(this.last),m=mw(this.last),y=fw[m][h];if(t&16?(this.last.intensity=this.intensity.decompress(this.decoder,this.lastIntensity[y],y<3?y:3)&65535,this.lastIntensity[y]=this.last.intensity):this.last.intensity=this.lastIntensity[y],t&8&&(this.last.classification=this.decoder.decodeSymbol(this.classificationModel[this.last.classification])),t&4){let g=this.decoder.decodeSymbol(this.scanAngleRankModel[_I(this.last)]);this.last.scanAngleRank=Op(this.last.scanAngleRank+g)}t&2&&(this.last.userData=this.decoder.decodeSymbol(this.userDataModel[this.last.userData])),t&1&&(this.last.pointSourceId=this.pointSourceId.decompress(this.decoder,this.last.pointSourceId,0)&65535)}let e=pw(this.last),n=mw(this.last),s=fw[n][e],i=bI[n][e],o=this.lastXDiffMedian[s].get(),a=this.dx.decompress(this.decoder,o,n===1?1:0);this.last.x=cn(this.last.x+a),this.lastXDiffMedian[s].add(a);let c=this.lastYDiffMedian[s].get(),l=Math.min(this.dx.k,20)&-2,u=this.dy.decompress(this.decoder,c,(n===1?1:0)+l);this.last.y=cn(this.last.y+u),this.lastYDiffMedian[s].add(u);let f=Math.min(this.dx.k+this.dy.k>>1,18)&-2;return this.last.z=this.z.decompress(this.decoder,this.lastHeight[i],(n===1?1:0)+f),this.lastHeight[i]=this.last.z,this.last}decompressLegacyPoint(){let t=this.dx.decompress(this.decoder,hw(this.legacyXDiffs),0);this.last.x=cn(this.last.x+t);let e=this.dx.k,n=this.dy.decompress(this.decoder,hw(this.legacyYDiffs),Math.min(e,19));this.last.y=cn(this.last.y+n),e=e+this.dy.k>>1,this.last.z=this.z.decompress(this.decoder,this.last.z,Math.min(e,19));let s=this.decoder.decodeSymbol(this.changedValuesModel);return s&32&&(this.last.intensity=this.intensity.decompress(this.decoder,this.last.intensity,0)&65535),s&16&&(this.last.bitByte=this.decoder.decodeSymbol(this.bitByteModel[this.last.bitByte])),s&8&&(this.last.classification=this.decoder.decodeSymbol(this.classificationModel[this.last.classification])),s&4&&(this.last.scanAngleRank=Op(this.legacyScanAngle.decompress(this.decoder,this.last.scanAngleRank&255,e<3?1:0))),s&2&&(this.last.userData=this.decoder.decodeSymbol(this.userDataModel[this.last.userData])),s&1&&(this.last.pointSourceId=this.pointSourceId.decompress(this.decoder,this.last.pointSourceId,0)&65535),this.legacyXDiffs[this.legacyDifferenceIndex]=t,this.legacyYDiffs[this.legacyDifferenceIndex]=n,this.legacyDifferenceIndex=(this.legacyDifferenceIndex+1)%3,this.last}readFirstMetadata(){this.decoder.readInitBytes()}},pc=class{itemVersion;stream;decoder;haveLast=!1;lastRed=0;lastGreen=0;lastBlue=0;usedModel=new $t(128);diffModel=ge(6,256);legacyRgb=null;constructor(t,e,n=2){this.itemVersion=n,this.stream=t,this.decoder=e,n===1&&(this.usedModel=new $t(64),this.legacyRgb=Bt(8,6))}decompress(t,e){return this.decompressRgb(),ar(this.lastRed,t,e),ar(this.lastGreen,t,e+2),ar(this.lastBlue,t,e+4),e+6}decompressRgb(){if(!this.haveLast){this.haveLast=!0,this.lastRed=Ks(this.stream),this.lastGreen=Ks(this.stream),this.lastBlue=Ks(this.stream);return}let t=this.decoder.decodeSymbol(this.usedModel);if(this.itemVersion===1){this.lastRed=this.decodeLegacyColor(this.lastRed,0,t),this.lastGreen=this.decodeLegacyColor(this.lastGreen,1,t),this.lastBlue=this.decodeLegacyColor(this.lastBlue,2,t);return}let e=0,n=0,s=0;if(t&1?e=this.decoder.decodeSymbol(this.diffModel[0])+(this.lastRed&255)&255:e=this.lastRed&255,t&2?e|=(this.decoder.decodeSymbol(this.diffModel[1])+(this.lastRed>>8)&255)<<8:e|=this.lastRed&65280,t&64){let i=(e&255)-(this.lastRed&255);t&4?n=this.decoder.decodeSymbol(this.diffModel[2])+Hs(i+(this.lastGreen&255))&255:n=this.lastGreen&255,t&16?(i=(i+((n&255)-(this.lastGreen&255)))/2|0,s=this.decoder.decodeSymbol(this.diffModel[4])+Hs(i+(this.lastBlue&255))&255):s=this.lastBlue&255,i=(e>>8)-(this.lastRed>>8),t&8?n|=(this.decoder.decodeSymbol(this.diffModel[3])+Hs(i+(this.lastGreen>>8))&255)<<8:n|=this.lastGreen&65280,t&32?(i=(i+(n>>8)-(this.lastGreen>>8))/2|0,s|=(this.decoder.decodeSymbol(this.diffModel[5])+Hs(i+(this.lastBlue>>8))&255)<<8):s|=this.lastBlue&65280}else n=e,s=e;this.lastRed=e,this.lastGreen=n,this.lastBlue=s}decodeLegacyColor(t,e,n){let s=0;for(let i=0;i<2;i++){let o=e*2+i,a=t>>i*8&255,c=n&1<<o?this.legacyRgb.decompress(this.decoder,a,o):a;s|=c<<i*8}return s}get decodedRed(){return this.lastRed}get decodedGreen(){return this.lastGreen}get decodedBlue(){return this.lastBlue}},Qs=class{itemVersion;stream;decoder;count;haveLast=!1;last;models;legacyBytes;constructor(t,e,n,s=2){this.itemVersion=s,this.stream=t,this.decoder=e,this.count=n,this.last=new Uint8Array(n),this.models=ge(n,256),this.legacyBytes=s===1?Bt(8,n):null}get byteCount(){return this.count}decompress(t,e){return this.decompressToTarget(t,e),e+this.count}decompressToTarget(t,e=0){if(this.count!==0){if(!this.haveLast){this.stream.getBytes(this.last,0,this.count),t?.set(this.last,e),this.haveLast=!0;return}for(let n=0;n<this.count;n++){let s=this.itemVersion===1?this.legacyBytes.decompress(this.decoder,this.last[n],n):this.last[n]+this.decoder.decodeSymbol(this.models[n])&255;t&&(t[e+n]=s),this.last[n]=s}}}};(function(r){r[r.Full=0]="Full",r[r.PointData=1]="PointData"})(Ut||(Ut={}));wp=class{changedValuesModel=ge(8,128);scannerChannelModel=new $t(3);returnNumberGpsSameModel=new $t(13);numberReturnsModel=ge(16,16);returnNumberModel=ge(16,16);classModel=[];flagModel=[];userDataModel=[];gpsTimeMultiModel;gpsTime0DiffModel;dx=Bt(32,2);dy=Bt(32,22);z=Bt(32,20);intensity=null;scanAngle;pointSourceId;gpsTime;haveLast=!1;last=vI();lastIntensity=[];lastZ=new Array(8).fill(0);lastXDiffMedian=Array.from({length:12},()=>new Xo);lastYDiffMedian=Array.from({length:12},()=>new Xo);lastGpsSequence=0;nextGpsSequence=0;lastGpsTime=[];lastGpsTimeDiff=[];multiExtremeCounter=[];gpsTimeChange=!1;constructor(t,e){(t===Ut.Full||e?.classification)&&(this.classModel=ge(64,256)),(t===Ut.Full||e?.intensity)&&(this.intensity=Bt(16,4),this.lastIntensity=new Array(8).fill(0)),(t===Ut.Full||e?.userData)&&(this.userDataModel=ge(64,256)),(t===Ut.Full||e?.scanAngle)&&(this.scanAngle=Bt(16,2)),(t===Ut.Full||e?.pointSourceId)&&(this.pointSourceId=Bt(16,1)),(t===Ut.Full||e?.flags)&&(this.flagModel=ge(64,64)),(t===Ut.Full||e?.gpsTime)&&(this.gpsTimeMultiModel=new $t(515),this.gpsTime0DiffModel=new $t(5),this.gpsTime=Bt(32,9),this.lastGpsTime=new Array(4).fill(0),this.lastGpsTimeDiff=new Array(4).fill(0),this.multiExtremeCounter=new Array(4).fill(0))}},Hi=class{stream;contexts;activeContext=null;decompressOptionalFields;xy=new ne;z=new ne;classification;flags;intensity;scanAngle;userData;pointSourceId;gpsTime;sizes=[];currentScannerChannel=0;itemContextChannel=0;itemVersion;constructor(t,e=Ut.Full,n=3,s=null){this.stream=t,this.itemVersion=n,this.contexts=Array.from({length:4},()=>new wp(e,s)),this.decompressOptionalFields=e===Ut.Full,this.classification=this.decompressOptionalFields||s?.classification?new ne:null,this.flags=this.decompressOptionalFields||s?.flags?new ne:null,this.intensity=this.decompressOptionalFields||s?.intensity?new ne:null,this.scanAngle=this.decompressOptionalFields||s?.scanAngle?new ne:null,this.userData=this.decompressOptionalFields||s?.userData?new ne:null,this.pointSourceId=this.decompressOptionalFields||s?.pointSourceId?new ne:null,this.gpsTime=this.decompressOptionalFields||s?.gpsTime?new ne:null}readSizes(){this.sizes=[];for(let t=0;t<9;t++)this.sizes.push(this.stream.getUint32())}readData(){let t=0;this.xy.initStream(this.stream,this.sizes[t++]),this.z.initStream(this.stream,this.sizes[t++]),this.initializeOptionalStream(this.classification,this.sizes[t++]),this.initializeOptionalStream(this.flags,this.sizes[t++]),this.initializeOptionalStream(this.intensity,this.sizes[t++]),this.initializeOptionalStream(this.scanAngle,this.sizes[t++]),this.initializeOptionalStream(this.userData,this.sizes[t++]),this.initializeOptionalStream(this.pointSourceId,this.sizes[t++]),this.initializeOptionalStream(this.gpsTime,this.sizes[t++])}initializeOptionalStream(t,e){t?t.initStream(this.stream,e):this.stream.consume(e)}decompress(t,e){let n=this.decompressPoint(t,e);return MI(n,t,e),e+30}decompressPoint(t,e=0){let n=this.gpsTime!==null;if(!this.activeContext){let rt=this.contexts[0].last;t?(this.stream.getBytes(t,e,30),LI(rt,t,e)):TI(rt,this.stream),this.currentScannerChannel=DI(rt),this.itemContextChannel=this.currentScannerChannel;let tt=this.contexts[this.currentScannerChannel];return tt.last!==rt&&yw(tt.last,rt),tt.haveLast=!0,n&&(tt.lastGpsTime[0]=tt.last.gpsTime),this.activeContext=tt,tt.lastZ.fill(tt.last.z),tt.lastIntensity.length&&tt.lastIntensity.fill(tt.last.intensity),tt.last}let s=this.activeContext,i=s.last.returns,o=i&15,a=(o===1?1:0)|(o>=i>>4?1:0)<<1|(s.gpsTimeChange?1:0)<<2,c=this.xy.decodeSymbol(s.changedValuesModel[a]),l=!!(c>>6&1),u=!!(c>>5&1),f=!!(c>>4&1),h=!!(c>>3&1),m=!!(c>>2&1),y=!!(c>>1&1),g=!!(c&1),x=g&&!y,I=y&&!g,j=g&&y;this.itemContextChannel=0;let T=this.currentScannerChannel,b=s;if(l){let rt=this.xy.decodeSymbol(s.scannerChannelModel);T=(T+rt+1)%4,b=this.contexts[T],this.activeContext=b,this.itemContextChannel=T}this.currentScannerChannel=T,this.itemVersion>=4&&(this.itemContextChannel=T),b.haveLast||(b.haveLast=!0,yw(b.last,s.last),b.lastZ.fill(s.last.z),b.lastIntensity.length&&b.lastIntensity.fill(s.last.intensity),n&&(b.lastGpsTime[0]=s.last.gpsTime)),CI(b.last,T);let C=b.last.returns>>4,_=b.last.returns&15;m&&(C=this.xy.decodeSymbol(b.numberReturnsModel[C])),x?_=(_+1)%16:I?_=(_+15)%16:j&&(_=f?this.xy.decodeSymbol(b.returnNumberModel[_]):(_+this.xy.decodeSymbol(b.returnNumberGpsSameModel)+2)%16),b.last.returns=C<<4|_;let q=pI[C][_]<<1|(f?1:0),X=b.lastXDiffMedian[q].get(),ft=b.dx.decompress(this.xy,X,C===1?1:0);b.last.x=cn(b.last.x+ft),b.lastXDiffMedian[q].add(ft);let dt=Math.min(b.dx.k,20)&-2,It=b.lastYDiffMedian[q].get(),se=b.dy.decompress(this.xy,It,(C===1?1:0)|dt);if(b.last.y=cn(b.last.y+se),b.lastYDiffMedian[q].add(se),this.z.valid){let rt=Math.min(b.dx.k+b.dy.k>>1,18)&-2,tt=mI[C][_],Ye=b.z.decompress(this.z,b.lastZ[tt],(C===1?1:0)|rt);b.last.z=Ye,b.lastZ[tt]=Ye}if(this.classification?.valid){let rt=(_===1&&_>=C?1:0)|(b.last.classification&31)<<1;b.last.classification=this.classification.decodeSymbol(b.classModel[rt])}if(this.flags?.valid){let rt=NI(b.last),tt=this.flags.decodeSymbol(b.flagModel[rt]);OI(b.last,tt>>5&1),EI(b.last,tt>>4&1),FI(b.last,tt&15)}if(this.intensity?.valid){let rt=(f?1:0)|(_>=C?1:0)<<1|(_===1?1:0)<<2,tt=b.intensity.decompress(this.intensity,b.lastIntensity[rt],rt>>1);b.lastIntensity[rt]=tt&65535,b.last.intensity=tt&65535}if(h&&this.scanAngle&&(b.last.scanAngle=Pp(b.scanAngle.decompress(this.scanAngle,b.last.scanAngle,f?1:0))),this.userData?.valid){let rt=b.last.userData>>2;b.last.userData=this.userData.decodeSymbol(b.userDataModel[rt])}return u&&this.pointSourceId&&(b.last.pointSourceId=b.pointSourceId.decompress(this.pointSourceId,b.last.pointSourceId,0)&65535),f&&this.gpsTime&&this.decodeGpsTime(b),b.gpsTimeChange=f,b.last}decodeGpsTime(t){let e=this.gpsTime;for(;;){if(t.lastGpsTimeDiff[t.lastGpsSequence]===0){let n=e.decodeSymbol(t.gpsTime0DiffModel);if(n===0){let s=t.gpsTime.decompress(e,0,0);t.lastGpsTimeDiff[t.lastGpsSequence]=s,t.lastGpsTime[t.lastGpsSequence]=Zs(t.lastGpsTime[t.lastGpsSequence],s),t.multiExtremeCounter[t.lastGpsSequence]=0}else if(n===1){t.nextGpsSequence=t.nextGpsSequence+1&3;let s=Nu(t.lastGpsTime[t.lastGpsSequence]),i=t.gpsTime.decompress(e,Number(s>>32n)|0,8),o=e.readInt();t.lastGpsTime[t.nextGpsSequence]=Zo(BigInt(i>>>0)<<32n|BigInt(o)),t.lastGpsSequence=t.nextGpsSequence,t.lastGpsTimeDiff[t.lastGpsSequence]=0,t.multiExtremeCounter[t.lastGpsSequence]=0}else{t.lastGpsSequence=t.lastGpsSequence+n-1&3;continue}}else{let n=e.decodeSymbol(t.gpsTimeMultiModel),s=0;if(n===1){let i=t.gpsTime.decompress(e,t.lastGpsTimeDiff[t.lastGpsSequence],1);t.lastGpsTime[t.lastGpsSequence]=Zs(t.lastGpsTime[t.lastGpsSequence],i),t.multiExtremeCounter[t.lastGpsSequence]=0}else if(n<Bu){if(n===0)s=t.gpsTime.decompress(e,0,7),t.multiExtremeCounter[t.lastGpsSequence]++,t.multiExtremeCounter[t.lastGpsSequence]>3&&(t.multiExtremeCounter[t.lastGpsSequence]=0,t.lastGpsTimeDiff[t.lastGpsSequence]=s);else if(n<an){let i=n<10?2:3;s=t.gpsTime.decompress(e,n*t.lastGpsTimeDiff[t.lastGpsSequence],i)}else n===an?(s=t.gpsTime.decompress(e,an*t.lastGpsTimeDiff[t.lastGpsSequence],4),t.multiExtremeCounter[t.lastGpsSequence]++,t.multiExtremeCounter[t.lastGpsSequence]>3&&(t.multiExtremeCounter[t.lastGpsSequence]=0,t.lastGpsTimeDiff[t.lastGpsSequence]=s)):(n=an-n,n>Ho?s=t.gpsTime.decompress(e,n*t.lastGpsTimeDiff[t.lastGpsSequence],5):(s=t.gpsTime.decompress(e,Ho*t.lastGpsTimeDiff[t.lastGpsSequence],6),t.multiExtremeCounter[t.lastGpsSequence]++,t.multiExtremeCounter[t.lastGpsSequence]>3&&(t.multiExtremeCounter[t.lastGpsSequence]=0,t.lastGpsTimeDiff[t.lastGpsSequence]=s)));t.lastGpsTime[t.lastGpsSequence]=Zs(t.lastGpsTime[t.lastGpsSequence],s)}else if(n===Bu){t.nextGpsSequence=t.nextGpsSequence+1&3;let i=Nu(t.lastGpsTime[t.lastGpsSequence]),o=t.gpsTime.decompress(e,Number(i>>32n)|0,8),a=e.readInt();t.lastGpsTime[t.nextGpsSequence]=Zo(BigInt(o>>>0)<<32n|BigInt(a)),t.lastGpsSequence=t.nextGpsSequence,t.lastGpsTimeDiff[t.lastGpsSequence]=0,t.multiExtremeCounter[t.lastGpsSequence]=0}else if(n>=Bu){t.lastGpsSequence=t.lastGpsSequence+n-Bu&3;continue}}t.last.gpsTime=t.lastGpsTime[t.lastGpsSequence];break}}},xp=class{haveLast=!1;lastRed=0;lastGreen=0;lastBlue=0;usedModel=new $t(128);diffModel=ge(6,256)},mc=class{stream;contexts=Array.from({length:4},()=>new xp);activeContext=null;lastChannel=-1;rgbCount=0;rgb=new ne;decodedRed=0;decodedGreen=0;decodedBlue=0;itemVersion;constructor(t,e=3){this.stream=t,this.itemVersion=e}readSizes(){this.rgbCount=this.stream.getUint32()}readData(){this.rgb.initStream(this.stream,this.rgbCount)}decompress(t,e,n){return this.decompressRgb(n),ar(this.decodedRed,t,e),ar(this.decodedGreen,t,e+2),ar(this.decodedBlue,t,e+4),e+6}decompressRgb(t){if(this.lastChannel===-1){this.decodedRed=this.stream.getByte()|this.stream.getByte()<<8,this.decodedGreen=this.stream.getByte()|this.stream.getByte()<<8,this.decodedBlue=this.stream.getByte()|this.stream.getByte()<<8;let c=this.contexts[t];c.lastRed=this.decodedRed,c.lastGreen=this.decodedGreen,c.lastBlue=this.decodedBlue,c.haveLast=!0,this.lastChannel=t,this.activeContext=c;return}if(this.rgbCount===0){let c=this.activeContext;this.decodedRed=c.lastRed,this.decodedGreen=c.lastGreen,this.decodedBlue=c.lastBlue;return}let e=this.activeContext,n=e;if(t!==this.lastChannel){let c=e;e=this.contexts[t],n=c,this.lastChannel=t,e.haveLast||(e.haveLast=!0,e.lastRed=c.lastRed,e.lastGreen=c.lastGreen,e.lastBlue=c.lastBlue,n=e),this.itemVersion>=4&&(n=e),this.activeContext=e}let s=this.rgb.decodeSymbol(e.usedModel),i=0,o=0,a=0;if(s&1?i=this.rgb.decodeSymbol(e.diffModel[0])+(n.lastRed&255)&255:i=n.lastRed&255,s&2){let c=this.rgb.decodeSymbol(e.diffModel[1]);i|=(c+(n.lastRed>>8)&255)<<8}else i|=n.lastRed&65280;if(s&64){let c=(i&255)-(n.lastRed&255);if(s&4?o=this.rgb.decodeSymbol(e.diffModel[2])+Hs(c+(n.lastGreen&255))&255:o=n.lastGreen&255,s&16){let l=this.rgb.decodeSymbol(e.diffModel[4]);c=(c+((o&255)-(n.lastGreen&255)))/2|0,a=l+Hs(c+(n.lastBlue&255))&255}else a=n.lastBlue&255;if(c=(i>>8)-(n.lastRed>>8),s&8){let l=this.rgb.decodeSymbol(e.diffModel[3]);o|=(l+Hs(c+(n.lastGreen>>8))&255)<<8}else o|=n.lastGreen&65280;if(s&32){let l=this.rgb.decodeSymbol(e.diffModel[5]);c=(c+(o>>8)-(n.lastGreen>>8))/2|0,a|=(l+Hs(c+(n.lastBlue>>8))&255)<<8}else a|=n.lastBlue&65280}else o=i,a=i;n.lastRed=i,n.lastGreen=o,n.lastBlue=a,this.decodedRed=i,this.decodedGreen=o,this.decodedBlue=a}},Ap=class{haveLast=!1;lastValue=0;usedModel=new $t(4);diffModel=ge(2,256)},Lu=class{stream;contexts=Array.from({length:4},()=>new Ap);lastChannel=-1;nirCount=0;nir=new ne;scratch=new Uint8Array(2);decodedNir=0;itemVersion;constructor(t,e=3){this.stream=t,this.itemVersion=e}readSizes(){this.nirCount=this.stream.getUint32()}readData(){this.nir.initStream(this.stream,this.nirCount)}decompress(t,e,n){if(this.lastChannel===-1){this.stream.getBytes(t,e,2);let c=this.contexts[n];return c.lastValue=Fu(t,e),c.haveLast=!0,this.lastChannel=n,this.decodedNir=c.lastValue,e+2}if(this.nirCount===0)return ar(this.contexts[this.lastChannel].lastValue,t,e),this.decodedNir=this.contexts[this.lastChannel].lastValue,e+2;let s=this.contexts[n],i=this.contexts[this.lastChannel];n!==this.lastChannel&&(this.lastChannel=n,s.haveLast||(s.haveLast=!0,s.lastValue=i.lastValue,i=s),this.itemVersion>=4&&(i=s));let o=this.nir.decodeSymbol(s.usedModel),a=o&1?this.nir.decodeSymbol(s.diffModel[0])+(i.lastValue&255)&255:i.lastValue&255;return a|=o&2?(this.nir.decodeSymbol(s.diffModel[1])+(i.lastValue>>8)&255)<<8:i.lastValue&65280,i.lastValue=a,this.decodedNir=a,ar(a,t,e),e+2}decompressNir(t){return this.decompress(this.scratch,0,t),this.decodedNir}},Tu=class{haveLast=!1;descriptorIndex=0;offset=0n;packetSize=0;returnPointBits=0;xBits=0;yBits=0;zBits=0;lastOffsetDifference=0;lastOffsetDifferenceSymbol=0;descriptorModel=new $t(256);offsetDifferenceModels=ge(4,4);offsetDifferenceDecompressor=Bt(32,1);packetSizeDecompressor=Bt(32,1);returnPointDecompressor=Bt(32,1);vectorDecompressor=Bt(32,3)},Mu=class{stream;contexts=Array.from({length:4},()=>new Tu);lastChannel=-1;wavePacketByteCount=0;decoder=new ne;itemVersion;constructor(t,e){this.stream=t,this.itemVersion=e}readSizes(){this.wavePacketByteCount=this.stream.getUint32()}readData(){this.decoder.initStream(this.stream,this.wavePacketByteCount)}decompress(t,e,n){if(this.lastChannel===-1){this.stream.getBytes(t,e,29);let a=this.contexts[n];return this.readContext(a,t,e),a.haveLast=!0,this.lastChannel=n,e+29}let s=this.contexts[this.lastChannel],i=this.contexts[n],o=i;return n!==this.lastChannel&&(o=s,i.haveLast?this.itemVersion>=4&&(o=i):(this.copyLastWavePacket(i,s),i.haveLast=!0,o=i),this.lastChannel=n),this.wavePacketByteCount&&this.decodeContext(i,o),this.writeContext(o,t,e),e+29}decompressToTarget(t,e,n){this.decompress(t,e,n)}decodeContext(t,e){e.descriptorIndex=this.decoder.decodeSymbol(t.descriptorModel);let n=this.decoder.decodeSymbol(t.offsetDifferenceModels[t.lastOffsetDifferenceSymbol]);switch(t.lastOffsetDifferenceSymbol=n,n){case 0:break;case 1:e.offset=BigInt.asUintN(64,e.offset+BigInt(e.packetSize));break;case 2:t.lastOffsetDifference=t.offsetDifferenceDecompressor.decompress(this.decoder,t.lastOffsetDifference,0),e.offset=BigInt.asUintN(64,e.offset+BigInt(t.lastOffsetDifference));break;default:e.offset=this.decoder.readUint64();break}e.packetSize=t.packetSizeDecompressor.decompress(this.decoder,e.packetSize|0,0)>>>0,e.returnPointBits=t.returnPointDecompressor.decompress(this.decoder,e.returnPointBits,0),e.xBits=t.vectorDecompressor.decompress(this.decoder,e.xBits,0),e.yBits=t.vectorDecompressor.decompress(this.decoder,e.yBits,1),e.zBits=t.vectorDecompressor.decompress(this.decoder,e.zBits,2)}copyLastWavePacket(t,e){t.descriptorIndex=e.descriptorIndex,t.offset=e.offset,t.packetSize=e.packetSize,t.returnPointBits=e.returnPointBits,t.xBits=e.xBits,t.yBits=e.yBits,t.zBits=e.zBits}readContext(t,e,n){t.descriptorIndex=e[n],t.offset=xw(e,n+1),t.packetSize=Eu(e,n+9),t.returnPointBits=$r(e,n+13),t.xBits=$r(e,n+17),t.yBits=$r(e,n+21),t.zBits=$r(e,n+25)}writeContext(t,e,n){e[n]=t.descriptorIndex,Aw(t.offset,e,n+1),Ou(t.packetSize,e,n+9),Ne(t.returnPointBits,e,n+13),Ne(t.xBits,e,n+17),Ne(t.yBits,e,n+21),Ne(t.zBits,e,n+25)}},vp=class{haveLast=!1;last;byteModel;constructor(t){this.last=new Uint8Array(t),this.byteModel=ge(t,256)}},Xi=class{stream;count;contexts;lastChannel=-1;byteCount;byteDecoder;itemVersion;constructor(t,e,n=3){this.stream=t,this.count=e,this.itemVersion=n,this.contexts=Array.from({length:4},()=>new vp(e)),this.byteCount=new Array(e).fill(0),this.byteDecoder=Array.from({length:e},()=>new ne)}readSizes(){for(let t=0;t<this.count;t++)this.byteCount[t]=this.stream.getUint32()}readData(){for(let t=0;t<this.count;t++)this.byteDecoder[t].initStream(this.stream,this.byteCount[t])}decompress(t,e,n){if(this.lastChannel===-1){this.stream.getBytes(t,e,this.count);let o=this.contexts[n];return o.last.set(t.subarray(e,e+this.count)),o.haveLast=!0,this.lastChannel=n,e+this.count}let s=this.contexts[n],i=this.contexts[this.lastChannel].last;n!==this.lastChannel&&(this.lastChannel=n,s.haveLast||(s.haveLast=!0,s.last.set(i),i=this.contexts[this.lastChannel].last),this.itemVersion>=4&&(i=s.last));for(let o=0;o<this.count;o++)if(this.byteCount[o]){let a=i[o]+this.byteDecoder[o].decodeSymbol(s.byteModel[o])&255;t[e+o]=a,i[o]=a}else t[e+o]=i[o];return e+this.count}};Sp=class{point;bytes;first=!0;constructor(t,e,n){this.point=new Js(t,n.point10ItemVersion??2),this.bytes=new Qs(t,this.point.getDecoder(),e,n.byteItemVersion??2)}decompress(t,e){return e=this.point.decompress(t,e),e=this.bytes.decompress(t,e),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint();this.bytes.decompressToTarget(t.extraBytes,e*this.bytes.byteCount),this.readFirstMetadata(),kn(n,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),Ki(n,t,e)}decompressPointDataBatch(t,e){for(let n=0;n<e;n++)this.decompressPointData(t,t.pointOffset+n)}readFirstMetadata(){this.first&&(this.point.readFirstMetadata(),this.first=!1)}},Ko=class{itemVersion;stream;decoder;gpsTimeMultiModel=new $t(516);gpsTime0DiffModel=new $t(6);gpsTime=Bt(32,9);lastGpsSequence=0;nextGpsSequence=0;lastGpsTime=new Array(4).fill(0);lastGpsTimeDiff=new Array(4).fill(0);multiExtremeCounter=new Array(4).fill(0);haveLast=!1;constructor(t,e,n=2){this.itemVersion=n,this.stream=t,this.decoder=e,n===1&&(this.gpsTimeMultiModel=new $t(512),this.gpsTime0DiffModel=new $t(3),this.gpsTime=Bt(32,6))}decompress(t,e){return Sw(this.decompressGpsTime(),t,e),e+8}decompressGpsTime(){return this.haveLast?(this.itemVersion===1?this.decodeLegacyGpsTime():this.decodeGpsTime(),this.lastGpsTime[this.lastGpsSequence]):(this.lastGpsTime[0]=vw(this.stream),this.haveLast=!0,this.lastGpsTime[0])}decodeLegacyGpsTime(){let t=this.lastGpsTimeDiff[0];if(t===0){let o=this.decoder.decodeSymbol(this.gpsTime0DiffModel);if(o===1){let a=this.gpsTime.decompress(this.decoder,0,0);this.lastGpsTimeDiff[0]=a,this.lastGpsTime[0]=Zs(this.lastGpsTime[0],a)}else o===2&&(this.lastGpsTime[0]=Zo(this.decoder.readUint64()));return}let e=this.decoder.decodeSymbol(this.gpsTimeMultiModel);if(e===511)return;if(e===510){this.lastGpsTime[0]=Zo(this.decoder.readUint64());return}let n=e===1?1:e===0?2:e<10?3:e<50?4:5,s=e===0?Math.trunc(t/4):cn(e*t),i=this.gpsTime.decompress(this.decoder,s,n);e===1?(this.lastGpsTimeDiff[0]=i,this.multiExtremeCounter[0]=0):(e===0||e===509)&&++this.multiExtremeCounter[0]>3&&(this.lastGpsTimeDiff[0]=i,this.multiExtremeCounter[0]=0),this.lastGpsTime[0]=Zs(this.lastGpsTime[0],i)}decodeGpsTime(){for(;;){if(this.lastGpsTimeDiff[this.lastGpsSequence]===0){let n=this.decoder.decodeSymbol(this.gpsTime0DiffModel);if(n===0)break;if(n===1){let s=this.gpsTime.decompress(this.decoder,0,0);this.lastGpsTimeDiff[this.lastGpsSequence]=s,this.lastGpsTime[this.lastGpsSequence]=Zs(this.lastGpsTime[this.lastGpsSequence],s),this.multiExtremeCounter[this.lastGpsSequence]=0;break}if(n===2){this.readFullGpsTime();break}this.lastGpsSequence=this.lastGpsSequence+n-2&3;continue}let t=this.decoder.decodeSymbol(this.gpsTimeMultiModel),e=0;if(t===1){let n=this.gpsTime.decompress(this.decoder,this.lastGpsTimeDiff[this.lastGpsSequence],1);this.lastGpsTime[this.lastGpsSequence]=Zs(this.lastGpsTime[this.lastGpsSequence],n),this.multiExtremeCounter[this.lastGpsSequence]=0}else if(t<yI){if(t===0)e=this.gpsTime.decompress(this.decoder,0,7),this.multiExtremeCounter[this.lastGpsSequence]++,this.multiExtremeCounter[this.lastGpsSequence]>3&&(this.multiExtremeCounter[this.lastGpsSequence]=0,this.lastGpsTimeDiff[this.lastGpsSequence]=e);else if(t<an){let n=t<10?2:3;e=this.gpsTime.decompress(this.decoder,t*this.lastGpsTimeDiff[this.lastGpsSequence],n)}else t===an?(e=this.gpsTime.decompress(this.decoder,an*this.lastGpsTimeDiff[this.lastGpsSequence],4),this.multiExtremeCounter[this.lastGpsSequence]++,this.multiExtremeCounter[this.lastGpsSequence]>3&&(this.multiExtremeCounter[this.lastGpsSequence]=0,this.lastGpsTimeDiff[this.lastGpsSequence]=e)):(t=an-t,t>Ho?e=this.gpsTime.decompress(this.decoder,t*this.lastGpsTimeDiff[this.lastGpsSequence],5):(e=this.gpsTime.decompress(this.decoder,Ho*this.lastGpsTimeDiff[this.lastGpsSequence],6),this.multiExtremeCounter[this.lastGpsSequence]++,this.multiExtremeCounter[this.lastGpsSequence]>3&&(this.multiExtremeCounter[this.lastGpsSequence]=0,this.lastGpsTimeDiff[this.lastGpsSequence]=e)));this.lastGpsTime[this.lastGpsSequence]=Zs(this.lastGpsTime[this.lastGpsSequence],e)}else if(t===fp)this.readFullGpsTime();else if(t>=fp){this.lastGpsSequence=this.lastGpsSequence+t-fp&3;continue}break}}readFullGpsTime(){this.nextGpsSequence=this.nextGpsSequence+1&3;let t=Nu(this.lastGpsTime[this.lastGpsSequence]),e=this.gpsTime.decompress(this.decoder,Number(t>>32n)|0,8),n=this.decoder.readInt();this.lastGpsTime[this.nextGpsSequence]=Zo(BigInt(e>>>0)<<32n|BigInt(n)),this.lastGpsSequence=this.nextGpsSequence,this.lastGpsTimeDiff[this.lastGpsSequence]=0,this.multiExtremeCounter[this.lastGpsSequence]=0}},Ip=class{point;gpsTime;bytes;first=!0;constructor(t,e,n){this.point=new Js(t,n.point10ItemVersion??2);let s=this.point.getDecoder();this.gpsTime=new Ko(t,s,n.gpsTime11ItemVersion??2),this.bytes=new Qs(t,s,e,n.byteItemVersion??2)}decompress(t,e){return e=this.point.decompress(t,e),e=this.gpsTime.decompress(t,e),e=this.bytes.decompress(t,e),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint(),s=this.gpsTime.decompressGpsTime();this.bytes.decompressToTarget(t.extraBytes,e*this.bytes.byteCount),this.readFirstMetadata(),kn(n,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),Ki(n,t,e),t.gpsTimes&&(t.gpsTimes[e]=s)}decompressPointDataBatch(t,e){for(let n=0;n<e;n++)this.decompressPointData(t,t.pointOffset+n)}readFirstMetadata(){this.first&&(this.point.readFirstMetadata(),this.first=!1)}},Bp=class{point;rgb;bytes;first=!0;constructor(t,e,n){this.point=new Js(t,n.point10ItemVersion??2);let s=this.point.getDecoder();this.rgb=new pc(t,s,n.rgb12ItemVersion??2),this.bytes=new Qs(t,s,e,n.byteItemVersion??2)}decompress(t,e){return e=this.point.decompress(t,e),e=this.rgb.decompress(t,e),e=this.bytes.decompress(t,e),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint();this.rgb.decompressRgb(),this.bytes.decompressToTarget(t.extraBytes,e*this.bytes.byteCount),this.readFirstMetadata(),kn(n,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),Ki(n,t,e),to(this.rgb.decodedRed,this.rgb.decodedGreen,this.rgb.decodedBlue,t,e)}decompressPointDataBatch(t,e){for(let n=0;n<e;n++)this.decompressPointData(t,t.pointOffset+n)}readFirstMetadata(){this.first&&(this.point.readFirstMetadata(),this.first=!1)}},_p=class{point;gpsTime;rgb;bytes;first=!0;directCommonOutput;constructor(t,e,n,s=null){this.point=new Js(t,n.point10ItemVersion??2);let i=this.point.getDecoder();this.gpsTime=new Ko(t,i,n.gpsTime11ItemVersion??2),this.rgb=new pc(t,i,n.rgb12ItemVersion??2),this.bytes=new Qs(t,i,e,n.byteItemVersion??2),this.directCommonOutput=!!(s&&!s.gpsTime&&!s.scanAngle&&!s.userData&&!s.pointSourceId&&!s.flags&&!s.waveform&&!s.extraBytes)}decompress(t,e){return e=this.point.decompress(t,e),e=this.gpsTime.decompress(t,e),e=this.rgb.decompress(t,e),e=this.bytes.decompress(t,e),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint(),s=this.gpsTime.decompressGpsTime();if(this.rgb.decompressRgb(),this.directCommonOutput){if(this.bytes.decompressToTarget(),this.readFirstMetadata(),kn(n,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),t.colors){let i=e*4;t.colors[i]=this.rgb.decodedRed&255,t.colors[i+1]=this.rgb.decodedGreen&255,t.colors[i+2]=this.rgb.decodedBlue&255,t.colors[i+3]=255}else if(t.rawColors){let i=e*3;t.rawColors[i]=this.rgb.decodedRed,t.rawColors[i+1]=this.rgb.decodedGreen,t.rawColors[i+2]=this.rgb.decodedBlue}return}this.bytes.decompressToTarget(t.extraBytes,e*this.bytes.byteCount),this.readFirstMetadata(),kn(n,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),Ki(n,t,e),t.gpsTimes&&(t.gpsTimes[e]=s),to(this.rgb.decodedRed,this.rgb.decodedGreen,this.rgb.decodedBlue,t,e)}decompressPointDataBatch(t,e){let n=t.positions,s=t.intensities,i=t.classifications,o=t.colors,a=t.rawColors,c=t.scale,l=t.offset,u=this.bytes.byteCount,f=t.pointOffset;if(!!!(t.gpsTimes||t.scanAngles||t.userData||t.pointSourceIds||t.returnNumbers||t.numberOfReturns||t.scannerChannels||t.scanDirectionFlags||t.edgeOfFlightLines||t.syntheticFlags||t.keyPointFlags||t.withheldFlags||t.overlapFlags)&&!t.extraBytes){for(let m=0;m<e;m++){let y=this.point.decompressPoint();if(this.gpsTime.decompressGpsTime(),this.rgb.decompressRgb(),this.bytes.decompressToTarget(),this.readFirstMetadata(),kn(y,n,s,i,c,l,f),o){let g=f*4;o[g]=this.rgb.decodedRed&255,o[g+1]=this.rgb.decodedGreen&255,o[g+2]=this.rgb.decodedBlue&255,o[g+3]=255}else if(a){let g=f*3;a[g]=this.rgb.decodedRed,a[g+1]=this.rgb.decodedGreen,a[g+2]=this.rgb.decodedBlue}f++}return}for(let m=0;m<e;m++){let y=this.point.decompressPoint(),g=this.gpsTime.decompressGpsTime();this.rgb.decompressRgb(),this.bytes.decompressToTarget(t.extraBytes,f*u),this.readFirstMetadata(),kn(y,n,s,i,c,l,f),Ki(y,t,f),t.gpsTimes&&(t.gpsTimes[f]=g),to(this.rgb.decodedRed,this.rgb.decodedGreen,this.rgb.decodedBlue,t,f),f++}}readFirstMetadata(){this.first&&(this.point.readFirstMetadata(),this.first=!1)}},Du=class{stream;decoder;context=new Tu;constructor(t,e){this.stream=t,this.decoder=e}decompress(t,e){let n=this.context;if(!n.haveLast)return this.stream.getBytes(t,e,29),this.readContext(t,e),n.haveLast=!0,e+29;n.descriptorIndex=this.decoder.decodeSymbol(n.descriptorModel);let s=this.decoder.decodeSymbol(n.offsetDifferenceModels[n.lastOffsetDifferenceSymbol]);switch(n.lastOffsetDifferenceSymbol=s,s){case 0:break;case 1:n.offset=BigInt.asUintN(64,n.offset+BigInt(n.packetSize));break;case 2:n.lastOffsetDifference=n.offsetDifferenceDecompressor.decompress(this.decoder,n.lastOffsetDifference,0),n.offset=BigInt.asUintN(64,n.offset+BigInt(n.lastOffsetDifference));break;default:n.offset=this.decoder.readUint64();break}return n.packetSize=n.packetSizeDecompressor.decompress(this.decoder,n.packetSize|0,0)>>>0,n.returnPointBits=n.returnPointDecompressor.decompress(this.decoder,n.returnPointBits,0),n.xBits=n.vectorDecompressor.decompress(this.decoder,n.xBits,0),n.yBits=n.vectorDecompressor.decompress(this.decoder,n.yBits,1),n.zBits=n.vectorDecompressor.decompress(this.decoder,n.zBits,2),this.writeContext(t,e),e+29}decompressToTarget(t,e){this.decompress(t,e)}readContext(t,e){let n=this.context;n.descriptorIndex=t[e],n.offset=xw(t,e+1),n.packetSize=Eu(t,e+9),n.returnPointBits=$r(t,e+13),n.xBits=$r(t,e+17),n.yBits=$r(t,e+21),n.zBits=$r(t,e+25)}writeContext(t,e){let n=this.context;t[e]=n.descriptorIndex,Aw(n.offset,t,e+1),Ou(n.packetSize,t,e+9),Ne(n.returnPointBits,t,e+13),Ne(n.xBits,t,e+17),Ne(n.yBits,t,e+21),Ne(n.zBits,t,e+25)}},Lp=class{point;gpsTime;wavePacket;bytes;waveformScratch=new Uint8Array(29);first=!0;constructor(t,e,n){this.point=new Js(t,n.point10ItemVersion??2);let s=this.point.getDecoder();this.gpsTime=new Ko(t,s,n.gpsTime11ItemVersion??2),this.wavePacket=new Du(t,s),this.bytes=new Qs(t,s,e,n.byteItemVersion??2)}decompress(t,e){return e=this.point.decompress(t,e),e=this.gpsTime.decompress(t,e),e=this.wavePacket.decompress(t,e),e=this.bytes.decompress(t,e),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint(),s=this.gpsTime.decompressGpsTime();t.waveforms?this.wavePacket.decompressToTarget(t.waveforms,e*29):this.wavePacket.decompressToTarget(this.waveformScratch,0),this.bytes.decompressToTarget(t.extraBytes,e*this.bytes.byteCount),this.readFirstMetadata(),kn(n,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),Ki(n,t,e),t.gpsTimes&&(t.gpsTimes[e]=s)}decompressPointDataBatch(t,e){for(let n=0;n<e;n++)this.decompressPointData(t,t.pointOffset+n)}readFirstMetadata(){this.first&&(this.point.readFirstMetadata(),this.first=!1)}},Tp=class{point;gpsTime;rgb;wavePacket;bytes;waveformScratch=new Uint8Array(29);first=!0;constructor(t,e,n){this.point=new Js(t,n.point10ItemVersion??2);let s=this.point.getDecoder();this.gpsTime=new Ko(t,s,n.gpsTime11ItemVersion??2),this.rgb=new pc(t,s,n.rgb12ItemVersion??2),this.wavePacket=new Du(t,s),this.bytes=new Qs(t,s,e,n.byteItemVersion??2)}decompress(t,e){return e=this.point.decompress(t,e),e=this.gpsTime.decompress(t,e),e=this.rgb.decompress(t,e),e=this.wavePacket.decompress(t,e),e=this.bytes.decompress(t,e),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint(),s=this.gpsTime.decompressGpsTime();this.rgb.decompressRgb(),t.waveforms?this.wavePacket.decompressToTarget(t.waveforms,e*29):this.wavePacket.decompressToTarget(this.waveformScratch,0),this.bytes.decompressToTarget(t.extraBytes,e*this.bytes.byteCount),this.readFirstMetadata(),kn(n,t.positions,t.intensities,t.classifications,t.scale,t.offset,e),Ki(n,t,e),t.gpsTimes&&(t.gpsTimes[e]=s),to(this.rgb.decodedRed,this.rgb.decodedGreen,this.rgb.decodedBlue,t,e)}decompressPointDataBatch(t,e){for(let n=0;n<e;n++)this.decompressPointData(t,t.pointOffset+n)}readFirstMetadata(){this.first&&(this.point.readFirstMetadata(),this.first=!1)}},Mp=class{stream;point;bytes;extraByteCount;first=!0;constructor(t,e,n,s,i){this.stream=t,this.extraByteCount=e,this.point=new Hi(t,n==="raw"?Ut.Full:Ut.PointData,s.point14ItemVersion??3,i),this.bytes=(n==="raw"||i?.extraBytes)&&e?new Xi(t,e,s.byte14ItemVersion??3):null}decompress(t,e){return e=this.point.decompress(t,e),this.bytes&&(e=this.bytes.decompress(t,e,this.point.itemContextChannel)),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint();this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,e*this.extraByteCount,this.point.itemContextChannel):this.first&&this.extraByteCount&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),gc(n,t,e)}decompressPointDataBatch(t,e){let n=t.positions,s=t.intensities,i=t.classifications,o=t.scale,a=t.offset,c=t.pointOffset;for(let l=0;l<e;l++){let u=this.point.decompressPoint();this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,c*this.extraByteCount,this.point.itemContextChannel):this.first&&this.extraByteCount&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),Xs(u,n,s,i,o,a,c++),Ji(u,t,c-1),Qi(u,t,c-1)}}readFirstMetadata(){if(this.first){this.stream.getUint32(),this.point.readSizes();let t=0;if(this.bytes)this.bytes.readSizes();else for(let e=0;e<this.extraByteCount;e++)t+=this.stream.getUint32();this.point.readData(),this.bytes?this.bytes.readData():this.stream.consume(t),this.first=!1}}},Dp=class{stream;point;rgb;bytes;extraByteCount;first=!0;constructor(t,e,n,s,i){this.stream=t,this.extraByteCount=e,this.point=new Hi(t,n==="raw"?Ut.Full:Ut.PointData,s.point14ItemVersion??3,i),this.rgb=n==="raw"||i?.color?new mc(t,s.rgb14ItemVersion??3):null,this.bytes=(n==="raw"||i?.extraBytes)&&e?new Xi(t,e,s.byte14ItemVersion??3):null}decompress(t,e){return e=this.point.decompress(t,e),e=this.rgb.decompress(t,e,this.point.itemContextChannel),this.bytes&&(e=this.bytes.decompress(t,e,this.point.itemContextChannel)),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint();this.rgb?this.rgb.decompressRgb(this.point.itemContextChannel):this.first&&this.stream.consume(6),this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,e*this.extraByteCount,this.point.itemContextChannel):this.first&&this.extraByteCount&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),gc(n,t,e),this.rgb&&to(this.rgb.decodedRed,this.rgb.decodedGreen,this.rgb.decodedBlue,t,e)}decompressPointDataBatch(t,e){let n=t.positions,s=t.intensities,i=t.classifications,o=t.colors,a=t.rawColors,c=t.scale,l=t.offset,u=t.pointOffset,f=e;if(this.first&&f>0){let y=this.point.decompressPoint();if(this.rgb?this.rgb.decompressRgb(this.point.itemContextChannel):this.stream.consume(6),this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,u*this.extraByteCount,this.point.itemContextChannel):this.extraByteCount&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),Xs(y,n,s,i,c,l,u),Ji(y,t,u),Qi(y,t,u),o&&this.rgb){let g=u*4;o[g]=this.rgb.decodedRed&255,o[g+1]=this.rgb.decodedGreen&255,o[g+2]=this.rgb.decodedBlue&255,o[g+3]=255}else if(a&&this.rgb){let g=u*3;a[g]=this.rgb.decodedRed,a[g+1]=this.rgb.decodedGreen,a[g+2]=this.rgb.decodedBlue}u++,f--}let h=!!(t.gpsTimes||t.scanAngles||t.userData||t.pointSourceIds||t.returnNumbers||t.numberOfReturns||t.scannerChannels||t.scanDirectionFlags||t.edgeOfFlightLines||t.syntheticFlags||t.keyPointFlags||t.withheldFlags||t.overlapFlags),m=!!(this.bytes&&t.extraBytes);if(!h&&!m){for(let y=0;y<f;y++){let g=this.point.decompressPoint();if(this.rgb?.decompressRgb(this.point.itemContextChannel),Xs(g,n,s,i,c,l,u),o&&this.rgb){let x=u*4;o[x]=this.rgb.decodedRed&255,o[x+1]=this.rgb.decodedGreen&255,o[x+2]=this.rgb.decodedBlue&255,o[x+3]=255}else if(a&&this.rgb){let x=u*3;a[x]=this.rgb.decodedRed,a[x+1]=this.rgb.decodedGreen,a[x+2]=this.rgb.decodedBlue}u++}return}for(let y=0;y<f;y++){let g=this.point.decompressPoint();if(this.rgb?.decompressRgb(this.point.itemContextChannel),this.bytes&&t.extraBytes&&this.bytes.decompress(t.extraBytes,u*this.extraByteCount,this.point.itemContextChannel),Xs(g,n,s,i,c,l,u),Ji(g,t,u),Qi(g,t,u),o&&this.rgb){let x=u*4;o[x]=this.rgb.decodedRed&255,o[x+1]=this.rgb.decodedGreen&255,o[x+2]=this.rgb.decodedBlue&255,o[x+3]=255}else if(a&&this.rgb){let x=u*3;a[x]=this.rgb.decodedRed,a[x+1]=this.rgb.decodedGreen,a[x+2]=this.rgb.decodedBlue}u++}}readFirstMetadata(){if(this.first){this.stream.getUint32(),this.point.readSizes();let t=this.rgb?0:this.stream.getUint32();this.rgb?.readSizes();let e=0;if(this.bytes)this.bytes.readSizes();else for(let n=0;n<this.extraByteCount;n++)e+=this.stream.getUint32();this.point.readData(),this.rgb?this.rgb.readData():this.stream.consume(t),this.bytes?this.bytes.readData():this.stream.consume(e),this.first=!1}}},Cp=class{stream;point;rgb;nir;bytes;extraByteCount;first=!0;constructor(t,e,n,s,i){this.stream=t,this.extraByteCount=e,this.point=new Hi(t,n==="raw"?Ut.Full:Ut.PointData,s.point14ItemVersion??3,i),this.rgb=n==="raw"||i?.color?new mc(t,s.rgb14ItemVersion??3):null,this.nir=n==="raw"||i?.nir?new Lu(t,s.rgb14ItemVersion??3):null,this.bytes=(n==="raw"||i?.extraBytes)&&e?new Xi(t,e,s.byte14ItemVersion??3):null}decompress(t,e){return e=this.point.decompress(t,e),e=this.rgb.decompress(t,e,this.point.itemContextChannel),e=this.nir.decompress(t,e,this.point.itemContextChannel),this.bytes&&(e=this.bytes.decompress(t,e,this.point.itemContextChannel)),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint();this.rgb?this.rgb.decompressRgb(this.point.itemContextChannel):this.first&&this.stream.consume(6),!this.nir&&this.first&&this.stream.consume(2);let s=this.nir?this.nir.decompressNir(this.point.itemContextChannel):0;this.bytes&&t.extraBytes&&this.bytes.decompress(t.extraBytes,e*this.extraByteCount,this.point.itemContextChannel),this.first&&this.stream.consume(this.bytes?0:this.extraByteCount),this.readFirstMetadata(),gc(n,t,e),Cu(s,t,e),this.rgb&&to(this.rgb.decodedRed,this.rgb.decodedGreen,this.rgb.decodedBlue,t,e)}decompressPointDataBatch(t,e){let n=t.positions,s=t.intensities,i=t.classifications,o=t.colors,a=t.rawColors,c=t.scale,l=t.offset,u=t.pointOffset;for(let f=0;f<e;f++){let h=this.point.decompressPoint();this.rgb?this.rgb.decompressRgb(this.point.itemContextChannel):this.first&&this.stream.consume(6),!this.nir&&this.first&&this.stream.consume(2);let m=this.nir?this.nir.decompressNir(this.point.itemContextChannel):0;if(this.bytes&&t.extraBytes&&this.bytes.decompress(t.extraBytes,u*this.extraByteCount,this.point.itemContextChannel),this.first&&this.stream.consume(this.bytes?0:this.extraByteCount),this.readFirstMetadata(),Xs(h,n,s,i,c,l,u),Ji(h,t,u),Qi(h,t,u),o&&this.rgb){let y=u*4;o[y]=this.rgb.decodedRed&255,o[y+1]=this.rgb.decodedGreen&255,o[y+2]=this.rgb.decodedBlue&255,o[y+3]=255}else if(a&&this.rgb){let y=u*3;a[y]=this.rgb.decodedRed,a[y+1]=this.rgb.decodedGreen,a[y+2]=this.rgb.decodedBlue}Cu(m,t,u),u++}}readFirstMetadata(){if(this.first){this.stream.getUint32(),this.point.readSizes();let t=this.rgb?0:this.stream.getUint32();this.rgb?.readSizes();let e=this.nir?0:this.stream.getUint32();this.nir?.readSizes();let n=0;if(this.bytes)this.bytes.readSizes();else for(let s=0;s<this.extraByteCount;s++)n+=this.stream.getUint32();this.point.readData(),this.rgb?this.rgb.readData():this.stream.consume(t),this.nir?this.nir.readData():this.stream.consume(e),this.bytes?this.bytes.readData():this.stream.consume(n),this.first=!1}}},Fp=class{stream;point;wavePacket;bytes;extraByteCount;first=!0;waveformScratch=new Uint8Array(29);constructor(t,e,n,s,i){this.stream=t,this.extraByteCount=e,this.point=new Hi(t,n==="raw"?Ut.Full:Ut.PointData,s.point14ItemVersion??3,i),this.wavePacket=n==="raw"||i?.waveform?new Mu(t,s.wavePacketItemVersion??3):null,this.bytes=(n==="raw"||i?.extraBytes)&&e?new Xi(t,e,s.byte14ItemVersion??3):null}decompress(t,e){return e=this.point.decompress(t,e),e=this.wavePacket.decompress(t,e,this.point.itemContextChannel),this.bytes&&(e=this.bytes.decompress(t,e,this.point.itemContextChannel)),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint();this.wavePacket?(this.wavePacket.decompressToTarget(this.waveformScratch,0,this.point.itemContextChannel),t.waveforms&&t.waveforms.set(this.waveformScratch,e*29)):this.first&&this.stream.consume(29),this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,e*this.extraByteCount,this.point.itemContextChannel):this.first&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),gc(n,t,e)}decompressPointDataBatch(t,e){let n=t.positions,s=t.intensities,i=t.classifications,o=t.scale,a=t.offset,c=t.pointOffset;for(let l=0;l<e;l++){let u=this.point.decompressPoint();this.wavePacket?(this.wavePacket.decompressToTarget(this.waveformScratch,0,this.point.itemContextChannel),t.waveforms&&t.waveforms.set(this.waveformScratch,c*29)):this.first&&this.stream.consume(29),this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,c*this.extraByteCount,this.point.itemContextChannel):this.first&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),Xs(u,n,s,i,o,a,c++),Ji(u,t,c-1),Qi(u,t,c-1)}}readFirstMetadata(){if(this.first){this.stream.getUint32(),this.point.readSizes();let t=this.wavePacket?0:this.stream.getUint32();this.wavePacket?.readSizes();let e=0;if(this.bytes)this.bytes.readSizes();else for(let n=0;n<this.extraByteCount;n++)e+=this.stream.getUint32();this.point.readData(),this.wavePacket?this.wavePacket.readData():this.stream.consume(t),this.bytes?this.bytes.readData():this.stream.consume(e),this.first=!1}}},Ep=class{stream;point;rgb;nir;wavePacket;bytes;extraByteCount;first=!0;waveformScratch=new Uint8Array(29);constructor(t,e,n,s,i){this.stream=t,this.extraByteCount=e,this.point=new Hi(t,n==="raw"?Ut.Full:Ut.PointData,s.point14ItemVersion??3,i),this.rgb=n==="raw"||i?.color?new mc(t,s.rgb14ItemVersion??3):null,this.nir=n==="raw"||i?.nir?new Lu(t,s.rgb14ItemVersion??3):null,this.wavePacket=n==="raw"||i?.waveform?new Mu(t,s.wavePacketItemVersion??3):null,this.bytes=(n==="raw"||i?.extraBytes)&&e?new Xi(t,e,s.byte14ItemVersion??3):null}decompress(t,e){return e=this.point.decompress(t,e),e=this.rgb.decompress(t,e,this.point.itemContextChannel),e=this.nir.decompress(t,e,this.point.itemContextChannel),e=this.wavePacket.decompress(t,e,this.point.itemContextChannel),this.bytes&&(e=this.bytes.decompress(t,e,this.point.itemContextChannel)),this.readFirstMetadata(),e}decompressPointData(t,e){let n=this.point.decompressPoint();this.rgb?this.rgb.decompressRgb(this.point.itemContextChannel):this.first&&this.stream.consume(6);let s=this.nir?this.nir.decompressNir(this.point.itemContextChannel):0;this.first&&this.stream.consume(this.nir?0:2),this.wavePacket?(this.wavePacket.decompressToTarget(this.waveformScratch,0,this.point.itemContextChannel),t.waveforms&&t.waveforms.set(this.waveformScratch,e*29)):this.first&&this.stream.consume(29),this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,e*this.extraByteCount,this.point.itemContextChannel):this.first&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),gc(n,t,e),Cu(s,t,e),this.rgb&&to(this.rgb.decodedRed,this.rgb.decodedGreen,this.rgb.decodedBlue,t,e)}decompressPointDataBatch(t,e){let n=t.positions,s=t.intensities,i=t.classifications,o=t.colors,a=t.rawColors,c=t.scale,l=t.offset,u=t.pointOffset;for(let f=0;f<e;f++){let h=this.point.decompressPoint();this.rgb?this.rgb.decompressRgb(this.point.itemContextChannel):this.first&&this.stream.consume(6);let m=this.nir?this.nir.decompressNir(this.point.itemContextChannel):0;if(this.first&&this.stream.consume(this.nir?0:2),this.wavePacket?(this.wavePacket.decompressToTarget(this.waveformScratch,0,this.point.itemContextChannel),t.waveforms&&t.waveforms.set(this.waveformScratch,u*29)):this.first&&this.stream.consume(29),this.bytes&&t.extraBytes?this.bytes.decompress(t.extraBytes,u*this.extraByteCount,this.point.itemContextChannel):this.first&&this.stream.consume(this.extraByteCount),this.readFirstMetadata(),Xs(h,n,s,i,c,l,u),Ji(h,t,u),Qi(h,t,u),o&&this.rgb){let y=u*4;o[y]=this.rgb.decodedRed&255,o[y+1]=this.rgb.decodedGreen&255,o[y+2]=this.rgb.decodedBlue&255,o[y+3]=255}else if(a&&this.rgb){let y=u*3;a[y]=this.rgb.decodedRed,a[y+1]=this.rgb.decodedGreen,a[y+2]=this.rgb.decodedBlue}Cu(m,t,u),u++}}readFirstMetadata(){if(this.first){this.stream.getUint32(),this.point.readSizes();let t=this.rgb?0:this.stream.getUint32();this.rgb?.readSizes();let e=this.nir?0:this.stream.getUint32();this.nir?.readSizes();let n=this.wavePacket?0:this.stream.getUint32();this.wavePacket?.readSizes();let s=0;if(this.bytes)this.bytes.readSizes();else for(let i=0;i<this.extraByteCount;i++)s+=this.stream.getUint32();this.point.readData(),this.rgb?this.rgb.readData():this.stream.consume(t),this.nir?this.nir.readData():this.stream.consume(e),this.wavePacket?this.wavePacket.readData():this.stream.consume(n),this.bytes?this.bytes.readData():this.stream.consume(s),this.first=!1}}}});function We(r){return r|0}var Et,kp,qt,_t,eo,Bw=d(()=>{"use strict";Et=class{symbols;distribution;symbolCount;lastSymbol;totalCount=0;updateCycle;symbolsUntilUpdate;constructor(t){if(t<2||t>2048)throw new Error(`Invalid arithmetic model symbol count ${t}`);this.symbols=t,this.lastSymbol=t-1,this.distribution=new Uint32Array(t),this.symbolCount=new Uint32Array(t),this.symbolCount.fill(1),this.updateCycle=t,this.symbolsUntilUpdate=t,this.update(),this.symbolsUntilUpdate=this.updateCycle=t+6>>1}update(){if(this.totalCount+=this.updateCycle,this.totalCount>32768){this.totalCount=0;for(let s=0;s<this.symbols;s++)this.symbolCount[s]=this.symbolCount[s]+1>>1,this.totalCount+=this.symbolCount[s]}let t=0,e=2147483648/this.totalCount|0;for(let s=0;s<this.symbols;s++)this.distribution[s]=e*t/65536|0,t+=this.symbolCount[s];this.updateCycle=5*this.updateCycle>>2;let n=this.symbols+6<<3;this.updateCycle>n&&(this.updateCycle=n),this.symbolsUntilUpdate=this.updateCycle}},kp=class{updateCycle=4;bitsUntilUpdate=4;bit0Probability=4096;bit0Count=1;bitCount=2;update(){this.bitCount+=this.updateCycle,this.bitCount>8192&&(this.bitCount=this.bitCount+1>>1,this.bit0Count=this.bit0Count+1>>1,this.bit0Count===this.bitCount&&this.bitCount++);let t=2147483648/this.bitCount|0;this.bit0Probability=this.bit0Count*t/262144|0,this.updateCycle=5*this.updateCycle>>2,this.updateCycle>64&&(this.updateCycle=64),this.bitsUntilUpdate=this.updateCycle}},qt=class{bytes=[];base=0;length=4294967295;finished=!1;encodeBit(t,e){let n=t.bit0Probability*(this.length>>>13);if(e===0)this.length=n>>>0,t.bit0Count++;else if(e===1)this.addToBase(n),this.length=this.length-n>>>0;else throw new Error(`Invalid arithmetic bit ${e}`);this.renormalizeIfNeeded(),--t.bitsUntilUpdate===0&&t.update()}encodeSymbol(t,e){if(!Number.isInteger(e)||e<0||e>t.lastSymbol)throw new Error(`Invalid arithmetic symbol ${e}`);let n=this.length,s;e===t.lastSymbol?(s=t.distribution[e]*(n>>>15),this.addToBase(s),this.length=n-s>>>0):(n>>>=15,s=t.distribution[e]*n,this.addToBase(s),this.length=t.distribution[e+1]*n-s>>>0),this.renormalizeIfNeeded(),t.symbolCount[e]++,--t.symbolsUntilUpdate===0&&t.update()}writeBits(t,e){if(!Number.isInteger(t)||t<1||t>32)throw new Error(`Invalid arithmetic bit count ${t}`);t>19&&(this.writeShort(e&65535),e>>>=16,t-=16);let n=this.length>>>t;this.addToBase(e*n),this.length=n>>>0,this.renormalizeIfNeeded()}writeShort(t){let e=this.length>>>16;this.addToBase((t&65535)*e),this.length=e>>>0,this.renormalizeIfNeeded()}writeInt(t){this.writeShort(t&65535),this.writeShort(t>>>16)}finish(){if(this.finished)return Uint8Array.from(this.bytes);this.finished=!0;let t=this.base,e=!0;return this.length>2*16777216?(this.base=this.base+16777216>>>0,this.length=8388608):(this.base=this.base+8388608>>>0,this.length=32768,e=!1),t>this.base&&this.propagateCarry(),this.renormalize(),this.bytes.push(0,0),e&&this.bytes.push(0),Uint8Array.from(this.bytes)}addToBase(t){let e=this.base;this.base=this.base+t>>>0,e>this.base&&this.propagateCarry()}propagateCarry(){let t=this.bytes.length-1;for(;t>=0&&this.bytes[t]===255;)this.bytes[t--]=0;if(t<0)throw new Error("LASzip arithmetic carry precedes encoded output");this.bytes[t]++}renormalizeIfNeeded(){this.length<16777216&&this.renormalize()}renormalize(){do this.bytes.push(this.base>>>24),this.base=this.base<<8>>>0,this.length=this.length<<8>>>0;while(this.length<16777216)}},_t=class{encoder;contexts;bitsHigh;correctionBits;correctionRange;correctionMinimum;bitModels;zeroBitCorrector=new kp;correctorModels;k=0;constructor(t,e=16,n=1,s=8,i=0){if(this.encoder=t,this.contexts=n,this.bitsHigh=s,i){let o=i,a=0;for(;o;)o>>=1,a++;i===2**(a-1)&&a--,this.correctionBits=a,this.correctionRange=i,this.correctionMinimum=-(i/2)}else e&&e<32?(this.correctionBits=e,this.correctionRange=2**e,this.correctionMinimum=-(this.correctionRange/2)):(this.correctionBits=32,this.correctionRange=0,this.correctionMinimum=-2147483648);this.bitModels=Array.from({length:this.contexts},()=>new Et(this.correctionBits+1)),this.correctorModels=Array.from({length:this.correctionBits},(o,a)=>{let c=a+1;return new Et(2**Math.min(c,this.bitsHigh))})}compress(t,e,n=0){if(!Number.isInteger(n)||n<0||n>=this.contexts)throw new Error(`Invalid integer compressor context ${n}`);let s=We(e-t);this.correctionRange&&(s<this.correctionMinimum?s+=this.correctionRange:s>this.correctionMinimum+this.correctionRange-1&&(s-=this.correctionRange)),this.writeCorrector(s,this.bitModels[n])}writeCorrector(t,e){let n=t<=0?-t:t-1,s=0;for(;n;)n>>>=1,s++;if(this.k=s,this.encoder.encodeSymbol(e,s),s===0){this.encoder.encodeBit(this.zeroBitCorrector,t);return}if(s===32){if(t!==this.correctionMinimum)throw new Error(`Invalid ${s}-bit integer correction ${t}`);return}let i=t<0?t+(2**s-1):t-1,o=this.correctorModels[s-1];if(s<=this.bitsHigh)this.encoder.encodeSymbol(o,i);else{let a=s-this.bitsHigh,c=2**a-1,l=i&c;i>>>=a,this.encoder.encodeSymbol(o,i),this.encoder.writeBits(a,l)}}},eo=class{value0=0;value1=0;value2=0;value3=0;value4=0;high=!0;add(t){this.high?t<this.value2?(this.value4=this.value3,this.value3=this.value2,t<this.value0?(this.value2=this.value1,this.value1=this.value0,this.value0=t):t<this.value1?(this.value2=this.value1,this.value1=t):this.value2=t):(t<this.value3?(this.value4=this.value3,this.value3=t):this.value4=t,this.high=!1):this.value2<t?(this.value0=this.value1,this.value1=this.value2,this.value4<t?(this.value2=this.value3,this.value3=this.value4,this.value4=t):this.value3<t?(this.value2=this.value3,this.value3=t):this.value2=t):(this.value1<t?(this.value0=this.value1,this.value1=t):this.value0=t,this.high=!0)}get(){return this.value2}}});function Xp(r,t){let e=XI(r);if(qI(e,t),t.pointCount===0)return new Uint8Array(0);if(t.pointDataRecordFormat<=5)return jI(e,t);let n=t.pointDataRecordLength,s=t.pointDataRecordFormat,i=Hu[s],o=n-i,a=e.subarray(0,n),c=Dw(a,0),l=new Wp(c),u=s===7||s===8||s===10?Wu(a,30):null,f=u?new Yp(u,ta(c)):null,h=s===8||s===10?new Zp(bc(a,36),ta(c)):null,m=s===9?30:s===10?38:-1,y=m>=0?new jp(Yu(a,m),ta(c),t.wavePacketItemVersion??3):null,g=o?new Hp(a.subarray(i,n),ta(c)):null;for(let X=1;X<t.pointCount;X++){let ft=X*n,dt=e.subarray(ft,ft+n),It=l.encode(Dw(dt,0));f?.encode(Wu(dt,30),It),h?.encode(bc(dt,36),It),y?.encode(Yu(dt,m),It),g?.encode(dt.subarray(i,n),It)}let x=l.finish(),I=f?.finish(),j=h?.finish(),T=y?.finish(),b=g?.finish()||[],C=[...x,...I?[I]:[],...j?[j]:[],...T?[T]:[],...b],_=new Uint8Array(4+C.length*4),q=new DataView(_.buffer);q.setUint32(0,t.pointCount,!0);for(let X=0;X<C.length;X++)q.setUint32(4+X*4,C[X].byteLength,!0);return Rw([a,_,...C])}function Kp(r,t={}){if(r.length===0)return new Uint8Array(0);let e=new qt,n=new _t(e,32,2),s=0,i=0;for(let o of r)WI(o),t.variable&&(n.compress(s,o.pointCount,0),s=o.pointCount),n.compress(i,o.byteLength,1),i=o.byteLength;return e.finish()}function Jp(r){let t=r.pointDataRecordFormat<=5,e=r.itemVersion||(t?2:3);if(t&&e!==2)throw new Error("Legacy LASzip point formats require item version 2");if(!t&&e!==3)throw new Error("Modern LASzip point formats require item version 3");let n=YI(r.pointDataRecordFormat,r.pointDataRecordLength),s=Lw+n.length*6,i=new Uint8Array(_w+s),o=new DataView(i.buffer),a=_w;Nw(o,2,"laszip encoded",16),o.setUint16(18,22204,!0),o.setUint16(20,s,!0),Nw(o,22,"loaders.gl LAZ writer",32),o.setUint16(a,t?2:3,!0),o.setUint16(a+2,0,!0),o.setUint8(a+4,t?2:3),o.setUint8(a+5,0),o.setUint16(a+6,1,!0),o.setUint32(a+8,0,!0),o.setUint32(a+12,r.chunkSize,!0),i.fill(255,a+16,a+32),o.setUint16(a+32,n.length,!0);for(let c=0;c<n.length;c++){let l=a+Lw+c*6,u=n[c];o.setUint16(l,u.type,!0),o.setUint16(l+2,u.size,!0),o.setUint16(l+4,u.version??e,!0)}return i}function jI(r,t){let e=t.pointDataRecordLength,n=t.pointDataRecordFormat,s=Hu[n],i=e-s,o=r.subarray(0,e),a=new qt,c=new zp(a,Cw(o,0)),l=n===1||n===3||n===4||n===5?new Vp(a,Fw(o,20)):null,u=n===2?20:n===3||n===5?28:-1,f=u>=0?new Gp(a,Wu(o,u)):null,h=n===4?28:n===5?34:-1,m=h>=0?new $p(a,Yu(o,h)):null,y=i?new qp(a,o.subarray(s,e)):null;for(let g=1;g<t.pointCount;g++){let x=g*e,I=r.subarray(x,x+e);c.encode(Cw(I,0)),l?.encode(Fw(I,20)),f?.encode(Wu(I,u)),m?.encode(Yu(I,h)),y?.encode(I.subarray(s,e))}return Rw([o,a.finish()])}function qI(r,t){if([t.point10ItemVersion,t.gpsTime11ItemVersion,t.rgb12ItemVersion,t.byteItemVersion].some(s=>s!==void 0&&s!==2))throw new Error("TypeScript LAZ encoder only supports legacy item version 2");if(!Number.isInteger(t.pointCount)||t.pointCount<0)throw new Error(`Invalid LAZ chunk point count ${t.pointCount}`);let e=Hu[t.pointDataRecordFormat];if(!e)throw new Error(`TypeScript LAZ encoder does not support point format ${t.pointDataRecordFormat}`);if(!Number.isInteger(t.pointDataRecordLength)||t.pointDataRecordLength<e)throw new Error(`Invalid point record length ${t.pointDataRecordLength} for point format ${t.pointDataRecordFormat}`);if(t.point14ItemVersion!==void 0&&t.point14ItemVersion!==3)throw new Error("TypeScript LAZ encoder only supports Point14 item version 3");if(t.pointDataRecordFormat>=7&&t.rgb14ItemVersion!==void 0&&t.rgb14ItemVersion!==3)throw new Error("TypeScript LAZ encoder only supports RGB14 item version 3");if((t.pointDataRecordFormat===9||t.pointDataRecordFormat===10)&&t.wavePacketItemVersion!==void 0&&t.wavePacketItemVersion!==3)throw new Error("TypeScript LAZ encoder only supports WavePacket14 item version 3");if(t.pointDataRecordLength>e&&t.byte14ItemVersion!==void 0&&t.byte14ItemVersion!==3)throw new Error("TypeScript LAZ encoder only supports Byte14 item version 3");let n=t.pointCount*t.pointDataRecordLength;if(r.byteLength!==n)throw new Error(`LAZ chunk input has ${r.byteLength} bytes; expected ${n}`)}function WI(r){if(!Number.isInteger(r.pointCount)||r.pointCount<=0||r.pointCount>4294967295)throw new Error(`Invalid LAZ chunk point count ${r.pointCount}`);if(!Number.isInteger(r.byteLength)||r.byteLength<=0||r.byteLength>4294967295)throw new Error(`Invalid LAZ chunk byte length ${r.byteLength}`)}function YI(r,t){let e=Hu[r];if(!e||t<e)throw new Error(`Invalid point record length ${t} for point format ${r}`);if(r<=5){let i=[{type:6,size:20}];(r===1||r===3||r===4||r===5)&&i.push({type:7,size:8}),(r===2||r===3||r===5)&&i.push({type:8,size:6}),(r===4||r===5)&&i.push({type:9,size:29,version:1});let o=t-e;return o>0&&i.push({type:0,size:o}),i}let n=[{type:10,size:30}];r===7?n.push({type:11,size:6}):r===8?n.push({type:12,size:8}):r===10&&n.push({type:12,size:8}),(r===9||r===10)&&n.push({type:13,size:29});let s=t-e;return s>0&&n.push({type:14,size:s}),n}function Dw(r,t){let e=new DataView(r.buffer,r.byteOffset+t,30);return{x:e.getInt32(0,!0),y:e.getInt32(4,!0),z:e.getInt32(8,!0),intensity:e.getUint16(12,!0),returns:e.getUint8(14),flags:e.getUint8(15),classification:e.getUint8(16),userData:e.getUint8(17),scanAngle:e.getInt16(18,!0),pointSourceId:e.getUint16(20,!0),gpsTimeBits:e.getBigUint64(22,!0)}}function Cw(r,t){let e=new DataView(r.buffer,r.byteOffset+t,20);return{x:e.getInt32(0,!0),y:e.getInt32(4,!0),z:e.getInt32(8,!0),intensity:e.getUint16(12,!0),bitByte:e.getUint8(14),classification:e.getUint8(15),scanAngleRank:e.getInt8(16),userData:e.getUint8(17),pointSourceId:e.getUint16(18,!0)}}function Wu(r,t){return{red:bc(r,t),green:bc(r,t+2),blue:bc(r,t+4)}}function Yu(r,t){let e=new DataView(r.buffer,r.byteOffset+t,29);return{descriptorIndex:e.getUint8(0),offset:e.getBigUint64(1,!0),packetSize:e.getUint32(9,!0),returnPointBits:e.getInt32(13,!0),xBits:e.getInt32(17,!0),yBits:e.getInt32(21,!0),zBits:e.getInt32(25,!0)}}function Fw(r,t){return new DataView(r.buffer,r.byteOffset+t,8).getFloat64(0,!0)}function Ew(r,t){return BigInt.asIntN(64,Zu(r)-Zu(t))}function Zu(r){let t=new ArrayBuffer(8),e=new DataView(t);return e.setFloat64(0,r,!0),e.getBigUint64(0,!0)}function bc(r,t){return r[t]|r[t+1]<<8}function ZI(r,t){r.x=t.x,r.y=t.y,r.z=t.z,r.intensity=t.intensity,r.returns=t.returns,r.flags=t.flags,r.classification=t.classification,r.userData=t.userData,r.scanAngle=t.scanAngle,r.pointSourceId=t.pointSourceId,r.gpsTimeBits=t.gpsTimeBits}function ta(r){return r.flags>>4&3}function Ow(r){return r.flags>>2&48|r.flags&15}function vr(r,t){return Array.from({length:r},()=>new Et(t))}function be(r){return r&255}function HI(r){return r&255}function ti(r){return Math.min(255,Math.max(0,r))}function Uw(r,t){let e=Math.fround(Math.fround(r)/Math.fround(t));return e>=0?Math.trunc(e+.5):Math.trunc(e-.5)}function XI(r){return r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function Rw(r){let t=r.reduce((s,i)=>s+i.byteLength,0),e=new Uint8Array(t),n=0;for(let s of r)e.set(s,n),n+=s.byteLength;return e}function Nw(r,t,e,n){for(let s=0;s<n;s++)r.setUint8(t+s,e.charCodeAt(s)||0)}var Hu,_w,Lw,Ar,ro,Tw,Mw,zI,VI,GI,$I,zp,Vp,Gp,$p,Vu,jp,qp,Gu,Wp,$u,Yp,ju,Zp,qu,Hp,Pw=d(()=>{"use strict";Bw();Hu={0:20,1:28,2:26,3:34,4:57,5:63,6:30,7:36,8:38,9:59,10:67},_w=54,Lw=34,Ar=500,ro=-10,Tw=511,Mw=Ar-ro+2,zI=[[0,1,2,3,4,5,3,4,4,5,5,5,5,5,5,5],[1,0,1,3,3,3,3,3,3,3,3,3,3,3,3,3],[2,1,2,4,4,4,4,4,4,4,4,3,3,3,3,3],[3,3,4,5,4,4,4,4,4,4,4,4,4,4,4,4],[4,3,4,4,5,4,4,4,4,4,4,4,4,4,4,4],[5,3,4,4,4,5,4,4,4,4,4,4,4,4,4,4],[3,3,4,4,4,4,5,4,4,4,4,4,4,4,4,4],[4,3,4,4,4,4,4,5,4,4,4,4,4,4,4,4],[4,3,4,4,4,4,4,4,5,4,4,4,4,4,4,4],[5,3,4,4,4,4,4,4,4,5,4,4,4,4,4,4],[5,3,4,4,4,4,4,4,4,4,5,4,4,4,4,4],[5,3,3,4,4,4,4,4,4,4,4,5,5,4,4,4],[5,3,3,4,4,4,4,4,4,4,4,5,5,5,4,4],[5,3,3,4,4,4,4,4,4,4,4,4,5,5,5,4],[5,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5],[5,3,3,4,4,4,4,4,4,4,4,4,4,4,5,5]],VI=[[15,14,13,12,11,10,9,8],[14,0,1,3,6,10,10,9],[13,1,2,4,7,11,11,10],[12,3,4,5,8,12,12,11],[11,6,7,8,9,13,13,12],[10,10,11,12,13,14,14,13],[9,10,11,12,13,14,15,14],[8,9,10,11,12,13,14,15]],GI=[[0,1,2,3,4,5,6,7],[1,0,1,2,3,4,5,6],[2,1,0,1,2,3,4,5],[3,2,1,0,1,2,3,4],[4,3,2,1,0,1,2,3],[5,4,3,2,1,0,1,2],[6,5,4,3,2,1,0,1],[7,6,5,4,3,2,1,0]],$I=[[0,1,2,3,4,5,6,7,7,7,7,7,7,7,7,7],[1,0,1,2,3,4,5,6,7,7,7,7,7,7,7,7],[2,1,0,1,2,3,4,5,6,7,7,7,7,7,7,7],[3,2,1,0,1,2,3,4,5,6,7,7,7,7,7,7],[4,3,2,1,0,1,2,3,4,5,6,7,7,7,7,7],[5,4,3,2,1,0,1,2,3,4,5,6,7,7,7,7],[6,5,4,3,2,1,0,1,2,3,4,5,6,7,7,7],[7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,7],[7,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7],[7,7,7,6,5,4,3,2,1,0,1,2,3,4,5,6],[7,7,7,7,6,5,4,3,2,1,0,1,2,3,4,5],[7,7,7,7,7,6,5,4,3,2,1,0,1,2,3,4],[7,7,7,7,7,7,6,5,4,3,2,1,0,1,2,3],[7,7,7,7,7,7,7,6,5,4,3,2,1,0,1,2],[7,7,7,7,7,7,7,7,6,5,4,3,2,1,0,1],[7,7,7,7,7,7,7,7,7,6,5,4,3,2,1,0]];zp=class{encoder;changedValuesModel=new Et(64);bitByteModels=vr(256,256);classificationModels=vr(256,256);scanAngleRankModels=vr(2,256);userDataModels=vr(256,256);intensityCompressor;pointSourceIdCompressor;xDifferenceCompressor;yDifferenceCompressor;zCompressor;lastIntensity=new Array(16).fill(0);lastHeight=new Array(8).fill(0);lastXDifferenceMedian=Array.from({length:16},()=>new eo);lastYDifferenceMedian=Array.from({length:16},()=>new eo);last;constructor(t,e){this.encoder=t,this.last={...e},this.intensityCompressor=new _t(t,16,4),this.pointSourceIdCompressor=new _t(t,16,1),this.xDifferenceCompressor=new _t(t,32,2),this.yDifferenceCompressor=new _t(t,32,22),this.zCompressor=new _t(t,32,20)}encode(t){let e=this.last,n=t.bitByte&7,s=t.bitByte>>3&7,i=VI[s][n],o=GI[s][n],a=(t.bitByte!==e.bitByte?32:0)|(t.intensity!==this.lastIntensity[i]?16:0)|(t.classification!==e.classification?8:0)|(t.scanAngleRank!==e.scanAngleRank?4:0)|(t.userData!==e.userData?2:0)|(t.pointSourceId!==e.pointSourceId?1:0);this.encoder.encodeSymbol(this.changedValuesModel,a),a&32&&this.encoder.encodeSymbol(this.bitByteModels[e.bitByte],t.bitByte),a&16&&(this.intensityCompressor.compress(this.lastIntensity[i],t.intensity,i<3?i:3),this.lastIntensity[i]=t.intensity),a&8&&this.encoder.encodeSymbol(this.classificationModels[e.classification],t.classification),a&4&&this.encoder.encodeSymbol(this.scanAngleRankModels[t.bitByte>>6&1],HI(t.scanAngleRank-e.scanAngleRank)),a&2&&this.encoder.encodeSymbol(this.userDataModels[e.userData],t.userData),a&1&&this.pointSourceIdCompressor.compress(e.pointSourceId,t.pointSourceId);let c=this.lastXDifferenceMedian[i].get(),l=We(t.x-e.x);this.xDifferenceCompressor.compress(c,l,s===1?1:0),this.lastXDifferenceMedian[i].add(l);let u=this.lastYDifferenceMedian[i].get(),f=Math.min(this.xDifferenceCompressor.k,20)&-2,h=We(t.y-e.y);this.yDifferenceCompressor.compress(u,h,(s===1?1:0)+f),this.lastYDifferenceMedian[i].add(h);let m=Math.min(this.xDifferenceCompressor.k+this.yDifferenceCompressor.k>>1,18)&-2;this.zCompressor.compress(this.lastHeight[o],t.z,(s===1?1:0)+m),this.lastHeight[o]=t.z,this.last={...t}}},Vp=class{encoder;gpsTimeMultiModel;gpsTime0DiffModel;gpsTime;lastGpsTime;lastGpsTimeDifference=[0,0,0,0];multiExtremeCounter=[0,0,0,0];lastGpsSequence=0;nextGpsSequence=0;constructor(t,e){this.encoder=t,this.gpsTimeMultiModel=new Et(516),this.gpsTime0DiffModel=new Et(6),this.gpsTime=new _t(t,32,9),this.lastGpsTime=[e,0,0,0]}encode(t){let e=this.lastGpsSequence,n=Ew(t,this.lastGpsTime[e]),s=Number(BigInt.asIntN(32,n)),i=n===BigInt(s);if(this.lastGpsTimeDifference[e]===0)if(i)s===0?this.encoder.encodeSymbol(this.gpsTime0DiffModel,0):(this.encoder.encodeSymbol(this.gpsTime0DiffModel,1),this.gpsTime.compress(0,s,0),this.lastGpsTimeDifference[e]=s,this.multiExtremeCounter[e]=0);else if(this.selectSequence(t,!1)){this.encode(t);return}else this.encoder.encodeSymbol(this.gpsTime0DiffModel,2),this.startSequence(t);else if(i){let o=this.lastGpsTimeDifference[e],a=Uw(s,o);a===1?(this.encoder.encodeSymbol(this.gpsTimeMultiModel,1),this.gpsTime.compress(o,s,1),this.multiExtremeCounter[e]=0):a>0&&a<Ar?(this.encoder.encodeSymbol(this.gpsTimeMultiModel,a),this.gpsTime.compress(We(a*o),s,a<10?2:3)):a>=Ar?(this.encoder.encodeSymbol(this.gpsTimeMultiModel,Ar),this.gpsTime.compress(We(Ar*o),s,4),this.recordExtremeDifference(e,s)):a<0&&a>ro?(this.encoder.encodeSymbol(this.gpsTimeMultiModel,Ar-a),this.gpsTime.compress(We(a*o),s,5)):a<0?(this.encoder.encodeSymbol(this.gpsTimeMultiModel,Ar-ro),this.gpsTime.compress(We(ro*o),s,6),this.recordExtremeDifference(e,s)):(this.encoder.encodeSymbol(this.gpsTimeMultiModel,0),this.gpsTime.compress(0,s,7),this.recordExtremeDifference(e,s))}else if(this.selectSequence(t,!0)){this.encode(t);return}else this.encoder.encodeSymbol(this.gpsTimeMultiModel,Mw),this.startSequence(t);this.lastGpsTime[this.lastGpsSequence]=t}selectSequence(t,e){for(let n=1;n<4;n++){let s=this.lastGpsSequence+n&3,i=Ew(t,this.lastGpsTime[s]);if(i===BigInt.asIntN(32,i))return this.encoder.encodeSymbol(e?this.gpsTimeMultiModel:this.gpsTime0DiffModel,e?Mw+n:n+2),this.lastGpsSequence=s,!0}return!1}startSequence(t){let e=Zu(this.lastGpsTime[this.lastGpsSequence]),n=Zu(t);this.gpsTime.compress(Number(BigInt.asIntN(32,e>>32n)),Number(BigInt.asIntN(32,n>>32n)),8),this.encoder.writeInt(Number(n&0xffffffffn)),this.nextGpsSequence=this.nextGpsSequence+1&3,this.lastGpsSequence=this.nextGpsSequence,this.lastGpsTimeDifference[this.lastGpsSequence]=0,this.multiExtremeCounter[this.lastGpsSequence]=0}recordExtremeDifference(t,e){this.multiExtremeCounter[t]++,this.multiExtremeCounter[t]>3&&(this.multiExtremeCounter[t]=0,this.lastGpsTimeDifference[t]=e)}},Gp=class{encoder;usedModel=new Et(128);differenceModels=vr(6,256);red;green;blue;constructor(t,e){this.encoder=t,this.red=e.red,this.green=e.green,this.blue=e.blue}encode(t){let e=this.red,n=this.green,s=this.blue,i=((t.red&255)!==(e&255)?1:0)|((t.red&65280)!==(e&65280)?2:0)|((t.green&255)!==(n&255)?4:0)|((t.green&65280)!==(n&65280)?8:0)|((t.blue&255)!==(s&255)?16:0)|((t.blue&65280)!==(s&65280)?32:0);((t.red&255)!==(t.green&255)||(t.red&255)!==(t.blue&255)||(t.red&65280)!==(t.green&65280)||(t.red&65280)!==(t.blue&65280))&&(i|=64),this.encoder.encodeSymbol(this.usedModel,i);let o=0,a=0;i&1&&(o=(t.red&255)-(e&255),this.encoder.encodeSymbol(this.differenceModels[0],be(o))),i&2&&(a=(t.red>>8)-(e>>8),this.encoder.encodeSymbol(this.differenceModels[1],be(a))),i&64&&(i&4&&this.encoder.encodeSymbol(this.differenceModels[2],be((t.green&255)-ti(o+(n&255)))),i&16&&(o=Math.trunc((o+(t.green&255)-(n&255))/2),this.encoder.encodeSymbol(this.differenceModels[4],be((t.blue&255)-ti(o+(s&255))))),i&8&&this.encoder.encodeSymbol(this.differenceModels[3],be((t.green>>8)-ti(a+(n>>8)))),i&32&&(a=Math.trunc((a+(t.green>>8)-(n>>8))/2),this.encoder.encodeSymbol(this.differenceModels[5],be((t.blue>>8)-ti(a+(s>>8)))))),this.red=t.red,this.green=t.green,this.blue=t.blue}},$p=class{encoder;descriptorModel;offsetDifferenceModels;offsetDifferenceCompressor;packetSizeCompressor;returnPointCompressor;vectorCompressor;last;lastOffsetDifference=0;lastOffsetDifferenceSymbol=0;constructor(t,e){this.encoder=t,this.descriptorModel=new Et(256),this.offsetDifferenceModels=vr(4,4),this.offsetDifferenceCompressor=new _t(t,32,1),this.packetSizeCompressor=new _t(t,32,1),this.returnPointCompressor=new _t(t,32,1),this.vectorCompressor=new _t(t,32,3),this.last={...e}}encode(t){let e=this.last;this.encoder.encodeSymbol(this.descriptorModel,t.descriptorIndex);let n=0;if(t.offset===e.offset)n=0;else if(t.offset===e.offset+BigInt(e.packetSize))n=1;else{let s=BigInt.asIntN(64,t.offset-e.offset);s===BigInt.asIntN(32,s)?n=2:n=3}if(this.encoder.encodeSymbol(this.offsetDifferenceModels[this.lastOffsetDifferenceSymbol],n),this.lastOffsetDifferenceSymbol=n,n===2){let s=Number(BigInt.asIntN(32,t.offset-e.offset));this.offsetDifferenceCompressor.compress(this.lastOffsetDifference,s,0),this.lastOffsetDifference=s}n===3&&(this.encoder.writeInt(Number(t.offset&0xffffffffn)),this.encoder.writeInt(Number(t.offset>>32n))),this.packetSizeCompressor.compress(e.packetSize,t.packetSize,0),this.returnPointCompressor.compress(e.returnPointBits,t.returnPointBits,0),this.vectorCompressor.compress(e.xBits,t.xBits,0),this.vectorCompressor.compress(e.yBits,t.yBits,1),this.vectorCompressor.compress(e.zBits,t.zBits,2),this.last={...t}}},Vu=class{packet;descriptorModel=new Et(256);offsetDifferenceModels=vr(4,4);offsetDifferenceCompressor;packetSizeCompressor;returnPointCompressor;vectorCompressor;lastOffsetDifference=0;lastOffsetDifferenceSymbol=0;haveLast=!1;constructor(t,e){this.packet={...e},this.offsetDifferenceCompressor=new _t(t,32,1),this.packetSizeCompressor=new _t(t,32,1),this.returnPointCompressor=new _t(t,32,1),this.vectorCompressor=new _t(t,32,3),this.haveLast=!0}},jp=class{encoder=new qt;contexts=new Array(4).fill(null);itemVersion;lastChannel;constructor(t,e,n){this.itemVersion=n,this.lastChannel=e,this.contexts[e]=new Vu(this.encoder,t)}encode(t,e){let n=this.contexts[this.lastChannel],s=this.contexts[e],i=s;e!==this.lastChannel&&(s?this.itemVersion<4&&(i=s,s=n):(s=new Vu(this.encoder,n.packet),this.contexts[e]=s,i=s),this.lastChannel=e),this.encodePacket(i,s,t)}finish(){return this.encoder.finish()}encodePacket(t,e,n){let s=e.packet;this.encoder.encodeSymbol(t.descriptorModel,n.descriptorIndex);let i=0;if(n.offset===s.offset?i=0:n.offset===s.offset+BigInt(s.packetSize)?i=1:BigInt.asIntN(64,n.offset-s.offset)===BigInt.asIntN(32,n.offset-s.offset)?i=2:i=3,this.encoder.encodeSymbol(t.offsetDifferenceModels[t.lastOffsetDifferenceSymbol],i),t.lastOffsetDifferenceSymbol=i,i===2){let o=Number(BigInt.asIntN(32,n.offset-s.offset));t.offsetDifferenceCompressor.compress(t.lastOffsetDifference,o,0),t.lastOffsetDifference=o}else i===3&&(this.encoder.writeInt(Number(n.offset&0xffffffffn)),this.encoder.writeInt(Number(n.offset>>32n)));t.packetSizeCompressor.compress(s.packetSize,n.packetSize,0),t.returnPointCompressor.compress(s.returnPointBits,n.returnPointBits,0),t.vectorCompressor.compress(s.xBits,n.xBits,0),t.vectorCompressor.compress(s.yBits,n.yBits,1),t.vectorCompressor.compress(s.zBits,n.zBits,2),e.packet={...n}}},qp=class{encoder;models;last;constructor(t,e){this.encoder=t,this.models=vr(e.byteLength,256),this.last=new Uint8Array(e)}encode(t){for(let e=0;e<t.byteLength;e++){let n=t[e]-this.last[e];this.encoder.encodeSymbol(this.models[e],be(n)),this.last[e]=t[e]}}},Gu=class{changedValuesModels=vr(8,128);scannerChannelModel=new Et(3);returnNumberGpsSameModel=new Et(13);numberReturnsModels=new Array(16).fill(null);returnNumberModels=new Array(16).fill(null);classificationModels=new Array(64).fill(null);flagModels=new Array(64).fill(null);userDataModels=new Array(64).fill(null);gpsTimeMultiplierModel=new Et(515);gpsTimeZeroDifferenceModel=new Et(5);xDifferenceCompressor;yDifferenceCompressor;zCompressor;intensityCompressor;scanAngleCompressor;pointSourceIdCompressor;gpsTimeCompressor;lastXDifferenceMedian=Array.from({length:12},()=>new eo);lastYDifferenceMedian=Array.from({length:12},()=>new eo);lastZ;lastIntensity;lastGpsTimeBits;lastGpsTimeDifference=new Array(4).fill(0);gpsTimeExtremeCounter=new Array(4).fill(0);lastGpsSequence=0;nextGpsSequence=0;gpsTimeChanged=!1;last;constructor(t,e){this.last={...t},this.xDifferenceCompressor=new _t(e.xy,32,2),this.yDifferenceCompressor=new _t(e.xy,32,22),this.zCompressor=new _t(e.z,32,20),this.intensityCompressor=new _t(e.intensity,16,4),this.scanAngleCompressor=new _t(e.scanAngle,16,2),this.pointSourceIdCompressor=new _t(e.pointSourceId,16,1),this.gpsTimeCompressor=new _t(e.gpsTime,32,9),this.lastZ=new Array(8).fill(t.z),this.lastIntensity=new Array(8).fill(t.intensity),this.lastGpsTimeBits=[t.gpsTimeBits,0n,0n,0n]}},Wp=class{layers={xy:new qt,z:new qt,classification:new qt,flags:new qt,intensity:new qt,scanAngle:new qt,userData:new qt,pointSourceId:new qt,gpsTime:new qt};contexts=new Array(4).fill(null);currentScannerChannel;changed={classification:!1,flags:!1,intensity:!1,scanAngle:!1,userData:!1,pointSourceId:!1,gpsTime:!1};constructor(t){this.currentScannerChannel=ta(t),this.contexts[this.currentScannerChannel]=new Gu(t,this.layers)}encode(t){let e=this.contexts[this.currentScannerChannel],n=e.last,s=ta(t);s!==this.currentScannerChannel&&this.contexts[s]&&(n=this.contexts[s].last);let i=t.pointSourceId!==n.pointSourceId,o=t.gpsTimeBits!==n.gpsTimeBits,a=t.scanAngle!==n.scanAngle,c=n.returns>>4,l=n.returns&15,u=t.returns>>4,f=t.returns&15,h=(l===1?1:0)|(l>=c?2:0)|(e.gpsTimeChanged?4:0),m=(s!==this.currentScannerChannel?64:0)|(i?32:0)|(o?16:0)|(a?8:0)|(u!==c?4:0);f!==l&&(f===(l+1)%16?m|=1:f===(l+15)%16?m|=2:m|=3),this.layers.xy.encodeSymbol(e.changedValuesModels[h],m);let y=0;if(s!==this.currentScannerChannel){let xt=s-this.currentScannerChannel;this.layers.xy.encodeSymbol(e.scannerChannelModel,(xt+3)%4),this.contexts[s]||=new Gu(e.last,this.layers),this.currentScannerChannel=s,y=s,n=this.contexts[s].last}let g=this.contexts[this.currentScannerChannel];if(u!==c){let xt=g.numberReturnsModels[c];xt||(xt=new Et(16),g.numberReturnsModels[c]=xt),this.layers.xy.encodeSymbol(xt,u)}if((m&3)===3)if(o){let xt=g.returnNumberModels[l];xt||(xt=new Et(16),g.returnNumberModels[l]=xt),this.layers.xy.encodeSymbol(xt,f)}else{let xt=f-l;this.layers.xy.encodeSymbol(g.returnNumberGpsSameModel,(xt+14)%16)}let x=zI[u][f],I=$I[u][f],j=(f===1?2:0)|(f>=u?1:0),T=x<<1|(o?1:0),b=g.lastXDifferenceMedian[T].get(),C=We(t.x-n.x);g.xDifferenceCompressor.compress(b,C,u===1?1:0),g.lastXDifferenceMedian[T].add(C);let _=g.lastYDifferenceMedian[T].get(),q=We(t.y-n.y),X=(u===1?1:0)|Math.min(g.xDifferenceCompressor.k,20)&-2;g.yDifferenceCompressor.compress(_,q,X),g.lastYDifferenceMedian[T].add(q);let ft=(u===1?1:0)|Math.min(g.xDifferenceCompressor.k+g.yDifferenceCompressor.k>>1,18)&-2;g.zCompressor.compress(g.lastZ[I],t.z,ft),g.lastZ[I]=t.z,t.classification!==n.classification&&(this.changed.classification=!0);let dt=(n.classification&31)<<1|(j===3?1:0),It=g.classificationModels[dt];It||(It=new Et(256),g.classificationModels[dt]=It),this.layers.classification.encodeSymbol(It,t.classification);let se=Ow(n),rt=Ow(t);rt!==se&&(this.changed.flags=!0);let tt=g.flagModels[se];tt||(tt=new Et(64),g.flagModels[se]=tt),this.layers.flags.encodeSymbol(tt,rt),t.intensity!==n.intensity&&(this.changed.intensity=!0);let Ye=j<<1|(o?1:0);g.intensityCompressor.compress(g.lastIntensity[Ye],t.intensity,j),g.lastIntensity[Ye]=t.intensity,a&&(this.changed.scanAngle=!0,g.scanAngleCompressor.compress(n.scanAngle,t.scanAngle,o?1:0)),t.userData!==n.userData&&(this.changed.userData=!0);let Ue=n.userData>>2,Ze=g.userDataModels[Ue];return Ze||(Ze=new Et(256),g.userDataModels[Ue]=Ze),this.layers.userData.encodeSymbol(Ze,t.userData),i&&(this.changed.pointSourceId=!0,g.pointSourceIdCompressor.compress(n.pointSourceId,t.pointSourceId)),o&&(this.changed.gpsTime=!0,this.encodeGpsTime(g,t.gpsTimeBits)),ZI(g.last,t),g.gpsTimeChanged=o,y}finish(){return[this.layers.xy.finish(),this.layers.z.finish(),this.changed.classification?this.layers.classification.finish():new Uint8Array(0),this.changed.flags?this.layers.flags.finish():new Uint8Array(0),this.changed.intensity?this.layers.intensity.finish():new Uint8Array(0),this.changed.scanAngle?this.layers.scanAngle.finish():new Uint8Array(0),this.changed.userData?this.layers.userData.finish():new Uint8Array(0),this.changed.pointSourceId?this.layers.pointSourceId.finish():new Uint8Array(0),this.changed.gpsTime?this.layers.gpsTime.finish():new Uint8Array(0)]}encodeGpsTime(t,e){let n=t.lastGpsSequence,s=BigInt.asIntN(64,e-t.lastGpsTimeBits[n]),i=Number(BigInt.asIntN(32,s)),o=s===BigInt(i);if(t.lastGpsTimeDifference[n]===0)if(o)this.layers.gpsTime.encodeSymbol(t.gpsTimeZeroDifferenceModel,0),t.gpsTimeCompressor.compress(0,i,0),t.lastGpsTimeDifference[n]=i,t.gpsTimeExtremeCounter[n]=0;else if(this.selectGpsTimeSequence(t,e,!1)){this.encodeGpsTime(t,e);return}else this.layers.gpsTime.encodeSymbol(t.gpsTimeZeroDifferenceModel,1),this.startGpsTimeSequence(t,e);else if(o){let a=t.lastGpsTimeDifference[n],c=Uw(i,a);c===1?(this.layers.gpsTime.encodeSymbol(t.gpsTimeMultiplierModel,1),t.gpsTimeCompressor.compress(a,i,1),t.gpsTimeExtremeCounter[n]=0):c>0?c<Ar?(this.layers.gpsTime.encodeSymbol(t.gpsTimeMultiplierModel,c),t.gpsTimeCompressor.compress(We(c*a),i,c<10?2:3)):(this.layers.gpsTime.encodeSymbol(t.gpsTimeMultiplierModel,Ar),t.gpsTimeCompressor.compress(We(Ar*a),i,4),this.recordExtremeGpsDifference(t,n,i)):c<0?c>ro?(this.layers.gpsTime.encodeSymbol(t.gpsTimeMultiplierModel,Ar-c),t.gpsTimeCompressor.compress(We(c*a),i,5)):(this.layers.gpsTime.encodeSymbol(t.gpsTimeMultiplierModel,Ar-ro),t.gpsTimeCompressor.compress(We(ro*a),i,6),this.recordExtremeGpsDifference(t,n,i)):(this.layers.gpsTime.encodeSymbol(t.gpsTimeMultiplierModel,0),t.gpsTimeCompressor.compress(0,i,7),this.recordExtremeGpsDifference(t,n,i))}else if(this.selectGpsTimeSequence(t,e,!0)){this.encodeGpsTime(t,e);return}else this.layers.gpsTime.encodeSymbol(t.gpsTimeMultiplierModel,Tw),this.startGpsTimeSequence(t,e);t.lastGpsTimeBits[t.lastGpsSequence]=e}selectGpsTimeSequence(t,e,n){for(let s=1;s<4;s++){let i=t.lastGpsSequence+s&3,o=BigInt.asIntN(64,e-t.lastGpsTimeBits[i]);if(o===BigInt.asIntN(32,o)){let a=n?Tw+s:s+1,c=n?t.gpsTimeMultiplierModel:t.gpsTimeZeroDifferenceModel;return this.layers.gpsTime.encodeSymbol(c,a),t.lastGpsSequence=i,!0}}return!1}startGpsTimeSequence(t,e){let n=t.lastGpsTimeBits[t.lastGpsSequence];t.gpsTimeCompressor.compress(Number(BigInt.asIntN(32,n>>32n)),Number(BigInt.asIntN(32,e>>32n)),8),this.layers.gpsTime.writeInt(Number(e&0xffffffffn)),t.nextGpsSequence=t.nextGpsSequence+1&3,t.lastGpsSequence=t.nextGpsSequence,t.lastGpsTimeDifference[t.lastGpsSequence]=0,t.gpsTimeExtremeCounter[t.lastGpsSequence]=0}recordExtremeGpsDifference(t,e,n){t.gpsTimeExtremeCounter[e]++,t.gpsTimeExtremeCounter[e]>3&&(t.lastGpsTimeDifference[e]=n,t.gpsTimeExtremeCounter[e]=0)}},$u=class{red;green;blue;usedModel=new Et(128);differenceModels=vr(6,256);constructor(t){this.red=t.red,this.green=t.green,this.blue=t.blue}},Yp=class{encoder=new qt;contexts=new Array(4).fill(null);currentContext;changed=!1;constructor(t,e){this.currentContext=e,this.contexts[e]=new $u(t)}encode(t,e){let n=this.contexts[this.currentContext];e!==this.currentContext&&(this.currentContext=e,this.contexts[e]||(this.contexts[e]=new $u({red:n.red,green:n.green,blue:n.blue}),n=this.contexts[e]));let s=this.contexts[this.currentContext],i=((t.red&255)!==(n.red&255)?1:0)|((t.red&65280)!==(n.red&65280)?2:0)|((t.green&255)!==(n.green&255)?4:0)|((t.green&65280)!==(n.green&65280)?8:0)|((t.blue&255)!==(n.blue&255)?16:0)|((t.blue&65280)!==(n.blue&65280)?32:0);((t.red&255)!==(t.green&255)||(t.red&255)!==(t.blue&255)||(t.red&65280)!==(t.green&65280)||(t.red&65280)!==(t.blue&65280))&&(i|=64),this.encoder.encodeSymbol(s.usedModel,i);let o=0,a=0;if(i&1&&(o=(t.red&255)-(n.red&255),this.encoder.encodeSymbol(s.differenceModels[0],be(o))),i&2&&(a=(t.red>>8)-(n.red>>8),this.encoder.encodeSymbol(s.differenceModels[1],be(a))),i&64){if(i&4){let c=(t.green&255)-ti(o+(n.green&255));this.encoder.encodeSymbol(s.differenceModels[2],be(c))}if(i&16){o=Math.trunc((o+(t.green&255)-(n.green&255))/2);let c=(t.blue&255)-ti(o+(n.blue&255));this.encoder.encodeSymbol(s.differenceModels[4],be(c))}if(i&8){let c=(t.green>>8)-ti(a+(n.green>>8));this.encoder.encodeSymbol(s.differenceModels[3],be(c))}if(i&32){a=Math.trunc((a+(t.green>>8)-(n.green>>8))/2);let c=(t.blue>>8)-ti(a+(n.blue>>8));this.encoder.encodeSymbol(s.differenceModels[5],be(c))}}this.changed||=i!==0,n.red=t.red,n.green=t.green,n.blue=t.blue}finish(){return this.changed?this.encoder.finish():new Uint8Array(0)}},ju=class{value;usedModel=new Et(4);differenceModels=vr(2,256);constructor(t){this.value=t}},Zp=class{encoder=new qt;contexts=new Array(4).fill(null);currentContext;changed=!1;constructor(t,e){this.currentContext=e,this.contexts[e]=new ju(t)}encode(t,e){let n=this.contexts[this.currentContext];e!==this.currentContext&&(this.currentContext=e,this.contexts[e]||(this.contexts[e]=new ju(n.value),n=this.contexts[e]));let s=this.contexts[this.currentContext],i=((t&255)!==(n.value&255)?1:0)|((t&65280)!==(n.value&65280)?2:0);this.encoder.encodeSymbol(s.usedModel,i),i&1&&this.encoder.encodeSymbol(s.differenceModels[0],be((t&255)-(n.value&255))),i&2&&this.encoder.encodeSymbol(s.differenceModels[1],be((t>>8)-(n.value>>8))),this.changed||=i!==0,n.value=t}finish(){return this.changed?this.encoder.finish():new Uint8Array(0)}},qu=class{values;models;constructor(t){this.values=t.slice(),this.models=vr(t.byteLength,256)}},Hp=class{encoders;contexts=new Array(4).fill(null);changed;currentContext;constructor(t,e){this.encoders=Array.from({length:t.byteLength},()=>new qt),this.changed=new Array(t.byteLength).fill(!1),this.currentContext=e,this.contexts[e]=new qu(t)}encode(t,e){let n=this.contexts[this.currentContext];e!==this.currentContext&&(this.currentContext=e,this.contexts[e]||(this.contexts[e]=new qu(n.values),n=this.contexts[e]));let s=this.contexts[this.currentContext];for(let i=0;i<t.byteLength;i++){let o=t[i]-n.values[i];this.encoders[i].encodeSymbol(s.models[i],be(o)),o&&(this.changed[i]=!0,n.values[i]=t[i])}}finish(){return this.encoders.map((t,e)=>this.changed[e]?t.finish():new Uint8Array(0))}}});function wc(r){return{...r,batchType:"data",length:r.data.numRows}}var kw=d(()=>{"use strict"});var no=d(()=>{"use strict";rw();iw();ow();lw();Iw();Pw();kw()});function zw(r,t){let e=KI(r);return Wi(t,e)}function KI(r){let t={};return t.las_pointsOffset=r.pointsOffset.toString(10),t.las_pointsFormatId=r.pointsFormatId.toString(10),t.las_pointsStructSize=r.pointsStructSize.toString(10),t.las_pointsCount=r.pointsCount.toString(10),t.las_scale=JSON.stringify(r.scale),t.las_offset=JSON.stringify(r.offset),r.maxs!==void 0&&(t.las_maxs=JSON.stringify(r.maxs)),r.mins!==void 0&&(t.las_mins=JSON.stringify(r.mins)),t.las_totalToRead=r.totalToRead.toString(10),t.las_pointsFortotalReadmatId=r.totalRead.toString(10),r.versionAsString!==void 0&&(t.las_versionAsString=r.versionAsString),r.isCompressed!==void 0&&(t.las_isCompressed=r.isCompressed.toString()),t}var Vw=d(()=>{"use strict";or()});function Gw(r,t){let e=t.vlrs.find(y=>y.userId==="lascompatible"&&y.recordId===22204);if(!e)return;if(!["1.0","1.1","1.2","1.3"].includes(r.versionAsString||"")||![1,3,4,5].includes(r.pointsFormatId))throw new Error("LASLoader: compatibility mode requires a legacy LAS point format");let n=new DataView(e.data.buffer,e.data.byteOffset,e.data.byteLength);if(n.byteLength<4)throw new Error("LASLoader: truncated LASzip compatibility VLR");let s=n.getUint16(2,!0);if(s!==3&&s!==4||n.byteLength!==(s===3?156:174))throw new Error(`LASLoader: unsupported LASzip compatibility VLR version ${s} or length`);let i=new Map,o=0;for(let y of t.extraBytes){let g=y.dataType>20?y.dataType-20:y.dataType>10?y.dataType-10:y.dataType,x=y.dataType>20?3:y.dataType>10?2:1,I=y.dataType===0?y.options:g<=2?x:g<=4?2*x:g<=6||g===9?4*x:8*x;if(y.dataType>30||!I)throw new Error("LASLoader: invalid compatibility Extra Bytes layout");i.set(y.name,{byteOffset:o,dataType:y.dataType}),o+=I}let a={1:28,3:34,4:57,5:63}[r.pointsFormatId];if(o!==r.pointsStructSize-a)throw new Error("LASLoader: compatibility descriptors do not match point record length");let c=xc(i,"LAS 1.4 scan angle",4),l=xc(i,"LAS 1.4 extended returns",1),u=xc(i,"LAS 1.4 classification",1),f=xc(i,"LAS 1.4 flags and channel",1),h=i.has("LAS 1.4 NIR band")?xc(i,"LAS 1.4 NIR band",3):void 0,m=r.pointsFormatId===1?6:r.pointsFormatId===3?h===void 0?7:8:r.pointsFormatId===4?9:10;if(r.pointsFormatId===5&&h===void 0)throw new Error("LASLoader: compatibility waveform color points require NIR");return{pointDataRecordFormat:m,version:s===3?"1.4":"1.5",scanAngleByteOffset:c,returnsByteOffset:l,classificationByteOffset:u,flagsByteOffset:f,nirByteOffset:h}}function xc(r,t,e){let n=r.get(t);if(!n||n.dataType!==e)throw new Error(`LASLoader: missing or invalid compatibility field ${t}`);return n.byteOffset}function Qp(r,t,e,n,s){if(!s.classifications&&!s.returnNumbers&&!s.numberOfReturns&&!s.scanAngles&&!s.overlapFlags&&!s.scannerChannels&&!s.nir)return;let i=r.getUint8(t+n.returnsByteOffset),o=r.getUint8(t+n.flagsByteOffset);if(s.classifications&&(s.classifications[e]+=r.getUint8(t+n.classificationByteOffset)),s.returnNumbers&&(s.returnNumbers[e]+=i>>4),s.numberOfReturns&&(s.numberOfReturns[e]+=i&15),s.scanAngles){let a=s.scanAngles[e],c=Math.fround(a/Math.fround(.006)),l=Math.sign(c)*Math.floor(Math.abs(c)+.5);s.scanAngles[e]=l+r.getInt16(t+n.scanAngleByteOffset,!0)}s.overlapFlags&&(s.overlapFlags[e]=o&1),s.scannerChannels&&(s.scannerChannels[e]=o>>1&3),s.nir&&n.nirByteOffset!==void 0&&(s.nir[e]=r.getUint16(t+n.nirByteOffset,!0))}var $w=d(()=>{"use strict"});function qw(r){if(r.byteLength%192!==0)throw new Error(`LAS Extra Bytes VLR length ${r.byteLength} is not a multiple of 192`);let t=[],e=new DataView(r.buffer,r.byteOffset,r.byteLength);for(let n=0;n<r.byteLength;n+=192){let s=[e.getFloat64(n+112,!0),e.getFloat64(n+120,!0),e.getFloat64(n+128,!0)],i=[e.getFloat64(n+136,!0),e.getFloat64(n+144,!0),e.getFloat64(n+152,!0)];t.push({dataType:r[n+2],options:r[n+3],name:jw(r,n+4,32),description:jw(r,n+160,32),scale:s[0],offset:i[0],scales:s,offsets:i,data:r.slice(n,n+192)})}return t}function Ww(r,t,e){let n=0,s=new Set,i=[];for(let o=0;o<t.length;o++){let a=t[o],c=QI(a.dataType),l=tB(a.dataType),f=eB(c)*l;if(a.dataType<1||a.dataType>30||!f)throw new Error(`Unsupported typed LAS Extra Bytes data type ${a.dataType}`);let h=`EXTRA_BYTES_${JI(a.name)}`;h==="EXTRA_BYTES_"&&(h=`EXTRA_BYTES_${o}`);let m=h,y=1;for(;s.has(h);)h=`${m}_${y++}`;s.add(h);let g=a.options&8?a.scales.slice(0,l):new Array(l).fill(1),x=a.options&16?a.offsets.slice(0,l):new Array(l).fill(0),j=c!==10&&(c===7||c===8?g.some(T=>T!==1)||x.some(T=>T!==0):!!(a.options&24));i.push({name:h,value:tm(c,r*l,j),size:l,scalarDataType:c,byteOffset:n,byteLength:f,outputFloat64:j,scales:g,offsets:x}),n+=f}if(n!==e)throw new Error(`LAS Extra Bytes descriptors use ${n} bytes; point records provide ${e}`);return i}function jw(r,t,e){let n=new TextDecoder().decode(r.subarray(t,t+e)),s=n.length;for(;s>0&&n[s-1]==="\0";)s--;return n.slice(0,s).trim()}function JI(r){return r.trim().replace(/[^A-Za-z0-9_]+/g,"_")}function QI(r){return r>20?r-20:r>10?r-10:r}function tB(r){return r>20?3:r>10?2:1}function eB(r){return r<=2?1:r<=4?2:r<=6||r===9?4:r===7||r===8||r===10?8:0}function rB(r,t,e){switch(e){case 1:return r.getUint8(t);case 2:return r.getInt8(t);case 3:return r.getUint16(t,!0);case 4:return r.getInt16(t,!0);case 5:return r.getUint32(t,!0);case 6:return r.getInt32(t,!0);case 7:return r.getBigUint64(t,!0);case 8:return r.getBigInt64(t,!0);case 9:return r.getFloat32(t,!0);case 10:return r.getFloat64(t,!0);default:throw new Error(`Unsupported typed LAS Extra Bytes scalar data type ${e}`)}}function tm(r,t,e){if(e&&r!==10)return new Float64Array(t);switch(r){case 1:return new Uint8Array(t);case 2:return new Int8Array(t);case 3:return new Uint16Array(t);case 4:return new Int16Array(t);case 5:return new Uint32Array(t);case 6:return new Int32Array(t);case 7:return new BigUint64Array(t);case 8:return new BigInt64Array(t);case 9:return new Float32Array(t);case 10:return new Float64Array(t);default:throw new Error(`Unsupported typed LAS Extra Bytes scalar data type ${r}`)}}function em(r,t,e,n,s){let i=rB(r,t,e.scalarDataType);e.value instanceof BigInt64Array||e.value instanceof BigUint64Array?e.value[n]=i:e.value[n]=Number(i)*e.scales[s]+e.offsets[s]}var Yw=d(()=>{"use strict"});function ri(r,t,e){return{pointDataRecordFormat:r.pointsFormatId,pointDataRecordLength:r.pointsStructSize,pointCount:e,point10ItemVersion:t.items.find(n=>n.type===6)?.version,gpsTime11ItemVersion:t.items.find(n=>n.type===7)?.version,rgb12ItemVersion:t.items.find(n=>n.type===8)?.version,byteItemVersion:t.items.find(n=>n.type===0)?.version,point14ItemVersion:t.point14ItemVersion??void 0,rgb14ItemVersion:t.rgb14ItemVersion??void 0,wavePacketItemVersion:t.wavePacketItemVersion??void 0,byte14ItemVersion:t.byte14ItemVersion??void 0}}function Jw(r,t={}){let e=s1(r);if(e.isCompressed){let s=new Uint8Array(r),i=am(s,e);if(cm(e,i),e.pointsFormatId<=5||e.pointsFormatId>=6&&e.pointsFormatId<=10)return lB(s,e,i,t);let o=bB(r,e,i),a=e.pointsCount;return Ku(o,{...e,pointsOffset:0,pointsCount:a,totalToRead:a,totalRead:a},t)}let n=e.pointsCount;return Ku(r,{...e,totalToRead:n,totalRead:n},t)}function Qw(r,t,e){if(t.pointDataRecordFormat<6||t.pointDataRecordFormat>8)throw new Error(`LASLoader: standalone Arrow chunk decode supports PDRF 6-8; received ${t.pointDataRecordFormat}`);let n=t.pointCount,s={pointsOffset:0,pointsFormatId:t.pointDataRecordFormat,pointsStructSize:t.pointDataRecordLength,pointsCount:n,scale:t.scale,offset:t.offset,maxs:[0,0,0],mins:[0,0,0],totalToRead:n,totalRead:n,hasColor:i1(t.pointDataRecordFormat),versionAsString:"1.4",isCompressed:!0,headerSize:Kw,vlrCount:0},i=ef(n,s,e);if(i.waveforms||i.extraBytes||i.typedExtraBytes)throw new Error("LASLoader: standalone Arrow chunk decode only supports direct LAZ columns");let a=jr(r,t).decodeIntoPointData(i.target,n);if(a!==n)throw new Error(`LASLoader: standalone LAZ chunk produced ${a} points; expected ${n}`);return t1(s,i,n,e,!0)}function lB(r,t,e,n){let s=t.pointsCount,i=ef(s,t,n),o=lm(r,t,e,n),a=0,c=t.pointsOffset+(e.compressor===1?0:Wt);for(let l of o)uB(r,c,l.byteLength,l.pointCount,t,e,i,a),c+=l.byteLength,a+=l.pointCount;if(a!==s)throw new Error(`LASLoader: decoded ${a} LAZ points; expected ${s}`);return t1(t,i,s,n)}function t1(r,t,e,n,s=!1){let i=s&&t.rawColors?t.rawColors:t.colors?t.colors:t.rawColors?u1(t.rawColors,e,n):null;return rm({...r,pointsOffset:0,pointsCount:e,totalRead:e},t.positions,i,t.intensities,t.classifications,t.syntheticFlags,t.keyPointFlags,t.withheldFlags,t.overlapFlags,t.gpsTimes,t.nir,t.scanAngles,t.userData,t.pointSourceIds,t.returnNumbers,t.numberOfReturns,t.scannerChannels,t.scanDirectionFlags,t.edgeOfFlightLines,t.waveforms,t.extraBytes,t.typedExtraBytes)}function uB(r,t,e,n,s,i,o,a){let c=r.subarray(t,t+e);if(c.byteLength!==e)throw new it("LASLoader: truncated LAZ chunk");let l=jr(c,ri(s,i,n));o.target.pointOffset=a;let u=l.decodeIntoPointData(o.target,n);if(u!==n)throw new Error(`LASLoader: decoded ${u} points from a ${n}-point LAZ chunk`);fm(o,a,n)}async function*e1(r,t={}){let e=ra(t),n=r_(r),s=new Uint8Array(0),i=0,o=null,a=0,c=0;for(;;){let l=await n.next();if(l.done)break;let u=l.value;if(s=f1(s,pm(u)),o||(o=e_(s,i),o&&(o.totalToRead=o.pointsCount)),!!o){if(o.isCompressed){yield*dB(s,n,o,t);return}for(let f of QB(s,i,o,a,c,e))a=f.sourcePointIndex,c=f.totalRead,s=f.pending,i=f.absoluteOffset,yield Ku(f.arrayBuffer,f.header,t)}}if(!o)throw new Error("LASLoader: incomplete LAS header");if(c<o.totalToRead)throw new Error("LASLoader: truncated LAS point data")}async function*fB(r,t,e,n,s){if(n.variableChunks){let m=await RB(r,t);yield*n1(m,e,n,s);return}if(e.pointsFormatId<=5){yield*hB(r,t,e,n,s);return}let i={...e,totalToRead:e.pointsCount},o=ra(s),a=tf(o,e.pointsStructSize,rf(s)),c=0,l=[],u=new Ys;u.write(r),await io(u,t,e.pointsOffset+Wt,"LASLoader: incomplete compressed LAZ point data"),u.skip(e.pointsOffset);let f=nf(u.getDataView(Wt));for(;c<e.pointsCount;){let m=Math.min(n.chunkSize,e.pointsCount-c),y=ri(e,n,m),g=await VB(u,t,y);l.push(g),hm(u,g,a.stats);let x=u.readBytes(g);s.las?.recoverMissingChunkTable&&f===e.pointsOffset&&um(x,y);for(let I of dm(x,y,i,a))yield I;c+=m}await Qu(u,t,e,n,f,l,s);let h=so(i,a);h&&(yield h)}async function*hB(r,t,e,n,s={}){let i={...e,totalToRead:e.pointsCount},o=ra(s),a=tf(o,e.pointsStructSize,rf(s)),c=[],l=new Ys;l.write(r),await io(l,t,e.pointsOffset+(n.compressor===1?0:Wt),"LASLoader: incomplete compressed LAZ point data"),l.skip(e.pointsOffset);let u=n.compressor===1?0:nf(l.getDataView(Wt)),f=0;for(;f<e.pointsCount;){let m=n.compressor===1?e.pointsCount:Math.min(n.chunkSize,e.pointsCount-f),y=ri(e,n,m),g=jr(new Uint8Array(0),y),x=0,I=0,j=!1;for(;g.remainingPointCount>0;){let T=l.getAvailableByteLength(),b=r1(T,x,g.requiredInputByteLength-I);if(b>x){let X=l.checkpoint();l.skip(x);let ft=b-x;hm(l,ft,a.stats),g.feed(l.readBytes(ft)),l.restore(X),x=b}let C=o-a.batchPointCount,_=g.decodeAvailableInto(a.rawBatch,a.batchPointCount*e.pointsStructSize,C,j);if(_>0){if(n.compressor===1){let X=g.compressedByteOffset-I;l.skip(X),x-=X,I=g.compressedByteOffset,g.discardConsumedInput()}if(a.batchPointCount+=_,a.batchPointCount===o){let X=so(i,a);X&&(yield X)}continue}if(j)throw new it(`LASLoader: truncated legacy LAZ chunk after ${m-g.remainingPointCount} of ${m} points with ${T} bytes available`);let q=await t.next();q.done?j=!0:l.write(q.value)}l.skip(g.compressedByteOffset-I),c.push(g.compressedByteOffset),f+=m}n.compressor!==1&&await Qu(l,t,e,n,u,c,s);let h=so(i,a);h&&(yield h)}function r1(r,t,e){return Math.min(r,Math.max(e,t+cB))}async function*dB(r,t,e,n){let{pending:s,laszip:i}=await UB(r,t,e);if(cm(e,i),!i.variableChunks&&e.pointsFormatId<=5){yield*pB(s,t,e,i,n);return}if(!i.variableChunks&&e.pointsFormatId>=6&&e.pointsFormatId<=10){yield*mB(s,t,e,i,n);return}for await(let o of fB(s,t,e,i,n))yield Ku(o.arrayBuffer,o.header,n)}async function*pB(r,t,e,n,s){let i={...e,totalToRead:e.pointsCount},o=ef(ra(s),e,s),a=rf(s),c=[],l=new Ys;l.write(r),await io(l,t,e.pointsOffset+(n.compressor===1?0:Wt),"LASLoader: incomplete compressed LAZ point data"),l.skip(e.pointsOffset);let u=n.compressor===1?0:nf(l.getDataView(Wt)),f=0;for(;f<e.pointsCount;){let m=n.compressor===1?e.pointsCount:Math.min(n.chunkSize,e.pointsCount-f),y=ri(e,n,m),g=jr(new Uint8Array(0),y),x=0,I=0,j=!1;for(;g.remainingPointCount>0;){let T=l.getAvailableByteLength(),b=r1(T,x,g.requiredInputByteLength-I);if(b>x){let X=l.checkpoint();l.skip(x);let ft=b-x;hm(l,ft,a),g.feed(l.readBytes(ft)),l.restore(X),x=b}o.target.pointOffset=o.batchPointCount;let C=o.batchCapacity-o.batchPointCount,_=g.decodeAvailableIntoPointData(o.target,C,j);if(_>0){if(n.compressor===1){let X=g.compressedByteOffset-I;l.skip(X),x-=X,I=g.compressedByteOffset,g.discardConsumedInput()}if(fm(o,o.batchPointCount,_),o.batchPointCount+=_,o.batchPointCount===o.batchCapacity){let X=Ju(i,o,s);X&&(yield X)}continue}if(j)throw new it(`LASLoader: truncated legacy LAZ chunk after ${m-g.remainingPointCount} of ${m} points with ${T} bytes available`);let q=await t.next();q.done?j=!0:l.write(q.value)}l.skip(g.compressedByteOffset-I),c.push(g.compressedByteOffset),f+=m}n.compressor!==1&&await Qu(l,t,e,n,u,c,s);let h=Ju(i,o,s);h&&(yield h)}async function*mB(r,t,e,n,s){let i={...e,totalToRead:e.pointsCount},o=ef(ra(s),e,s),a=0,c=[],l=new Ys;l.write(r),await io(l,t,e.pointsOffset+Wt,"LASLoader: incomplete compressed LAZ point data"),l.skip(e.pointsOffset);let u=nf(l.getDataView(Wt));for(;a<e.pointsCount;){let h=Math.min(n.chunkSize,e.pointsCount-a),m=ri(e,n,h),y=yield*yB(l,t,m,i,o,s,!!(s.las?.recoverMissingChunkTable&&u===e.pointsOffset));c.push(y),a+=h}await Qu(l,t,e,n,u,c,s);let f=Ju(i,o,s);f&&(yield f)}async function*yB(r,t,e,n,s,i,o){let a=Ru(e);await io(r,t,a,"LASLoader: incomplete layered LAZ chunk header");let c=r.readBytes(a);o&&um(c,e);let l=Pu(c,e),u=Np(e);u.feed(c);let f=a;for(;f<l;){if(yield*Zw(u,n,s,i),r.getAvailableByteLength()===0){let m=await t.next();if(m.done)throw new it("LASLoader: incomplete layered LAZ chunk payload");r.write(m.value)}let h=Math.min(r.getAvailableByteLength(),l-f);u.feed(r.readBytes(h)),f+=h}if(u.close(),yield*Zw(u,n,s,i),u.remainingPointCount!==0)throw new it(`LASLoader: layered LAZ chunk produced ${e.pointCount-u.remainingPointCount} of ${e.pointCount} points`);return l}function*Zw(r,t,e,n){for(;r.remainingPointCount>0;){let s=e.batchCapacity-e.batchPointCount;e.target.pointOffset=e.batchPointCount;let i=r.readPointDataBatch(e.target,s);if(!i)return;if(fm(e,e.batchPointCount,i),e.batchPointCount+=i,e.batchPointCount===e.batchCapacity){let o=Ju(t,e,n);o&&(yield o)}}}function*gB(r,t,e,n,s={}){let i=n||am(new Uint8Array(r),t);if(cm(t,i),t.pointsFormatId<=5||i.variableChunks){yield*n1(new Uint8Array(r),t,i,{...s,batchSize:e});return}let o={...t,totalToRead:t.pointsCount},a=tf(e,t.pointsStructSize),c=new Uint8Array(r),l=lm(c,t,i,s),u=t.pointsOffset+(i.compressor===1?0:Wt);for(let h of l){let m=ri(t,i,h.pointCount),y=c.subarray(u,u+h.byteLength);for(let g of dm(y,m,o,a))yield g;u+=h.byteLength}let f=so(o,a);f&&(yield f)}function*n1(r,t,e,n={}){let s=ra(n),i={...t,totalToRead:t.pointsCount},o=tf(s,t.pointsStructSize,rf(n)),a=lm(r,t,e,n),c=t.pointsOffset+(e.compressor===1?0:Wt);for(let u of a){let f=r.subarray(c,c+u.byteLength);if(f.byteLength<u.byteLength)throw new it("LASLoader: truncated legacy LAZ chunk");let h=ri(t,e,u.pointCount);if(e.compressor===1)yield*dm(f,h,i,o);else{let m=Uu(f,h);ZB(m.byteLength,o.stats),yield*HB(m,i,o)}c+=u.byteLength}let l=so(i,o);l&&(yield l)}function bB(r,t,e){let n=t.pointsCount,s=new Uint8Array(n*t.pointsStructSize),i=0;for(let o of gB(r,t,Hw,e)){let a=new Uint8Array(o.arrayBuffer);s.set(a,i),i+=a.byteLength}return s}function s1(r){let t=new DataView(r);if(r.byteLength<227||t.getUint32(0,!0)!==Xw)throw new Error("LASLoader: invalid LAS header");let e=t.getUint8(24),n=t.getUint8(25);if(e!==1||n>5)throw new Error(`LASLoader: unsupported LAS version ${e}.${n}`);let s=t.getUint16(94,!0),i=t.getUint16(6,!0),o=t.getUint32(100,!0),a=t.getUint8(104),c=a&sB,l=!!(a&nB),u=t.getUint32(107,!0),h=(e>1||n>=4?ei(t,247):u)||u,m=t.getUint32(96,!0),y=t.getUint16(105,!0);if(n===5){if(s<393)throw new Error("LASLoader: LAS 1.5 header must be at least 393 bytes");if(c<6||c>10)throw new Error(`LASLoader: LAS 1.5 requires point data record formats 6-10; received ${c}`);if((i&16)===0)throw new Error("LASLoader: LAS 1.5 requires the WKT global encoding flag");if((i&65440)!==0)throw new Error("LASLoader: LAS 1.5 Global Encoding contains reserved bits");if((i&64)!==0&&(i&1)===0)throw new Error("LASLoader: LAS 1.5 Time Offset Flag requires GPS Time Type");let b=t.getFloat64(375,!0),C=t.getFloat64(383,!0);if(!Number.isFinite(b)||!Number.isFinite(C)||b!==0&&C!==0&&b<C)throw new Error("LASLoader: LAS 1.5 GPS time range is invalid")}let g=[t.getFloat64(131,!0),t.getFloat64(139,!0),t.getFloat64(147,!0)],x=[t.getFloat64(155,!0),t.getFloat64(163,!0),t.getFloat64(171,!0)],I=[t.getFloat64(179,!0),t.getFloat64(195,!0),t.getFloat64(211,!0)],j=[t.getFloat64(187,!0),t.getFloat64(203,!0),t.getFloat64(219,!0)],T={pointsOffset:m,pointsFormatId:c,pointsStructSize:y,pointsCount:h,scale:g,offset:x,maxs:I,mins:j,totalToRead:h,totalRead:0,hasColor:i1(c),versionAsString:`${e}.${n}`,isCompressed:l,headerSize:s,vlrCount:o,userHeaderData:n===5&&s>393?new Uint8Array(r,393,s-393).slice():void 0};return wB(r,T)&&(T.metadata=xB(r,T)),T}function wB(r,t){let e=t.headerSize+t.vlrCount*54;return r.byteLength>=Math.max(e,t.pointsOffset)}function xB(r,t){let e=new DataView(r),s=(t.versionAsString||"1.0").split(".").map(Number),i=s[0]>1||s[0]===1&&s[1]>=4,o=AB(e,t),a=i?ei(e,235):0,c=i?e.getUint32(243,!0):0,l=vB(e,a,c),u={fileSourceId:e.getUint16(4,!0),globalEncoding:e.getUint16(6,!0),waveformDataOffset:s[0]>1||s[0]===1&&s[1]>=3?e.getBigUint64(227,!0):void 0,projectId:TB(new Uint8Array(r,8,16)),systemIdentifier:ea(new Uint8Array(r),26,32),generatingSoftware:ea(new Uint8Array(r),58,32),creationDayOfYear:e.getUint16(90,!0),creationYear:e.getUint16(92,!0),headerSize:t.headerSize,userHeaderData:t.userHeaderData,vlrCount:t.vlrCount,evlrOffset:a||void 0,evlrCount:c||void 0,maxGpsTime:s[1]===5?e.getFloat64(375,!0):void 0,minGpsTime:s[1]===5?e.getFloat64(383,!0):void 0,timeOffset:s[1]===5?e.getUint16(391,!0):void 0,pointsByReturn:LB(e,i),vlrs:o,evlrs:l,extraBytes:[],waveformPacketDescriptors:[]};for(let f of o.concat(l.map(h=>({...h,data:h.data||new Uint8Array}))))SB(f,u);return u.compatibility=Gw(t,u),IB(u),u}function AB(r,t){let e=new Uint8Array(r.buffer,r.byteOffset,r.byteLength),n=[],s=t.headerSize;for(let i=0;i<t.vlrCount&&!(s+54>e.byteLength);i++){let o=r.getUint16(s+20,!0),a=s+54;if(a+o>e.byteLength)break;n.push({reserved:r.getUint16(s,!0),userId:ea(e,s+2,16),recordId:r.getUint16(s+18,!0),description:ea(e,s+22,32),offset:s,data:e.slice(a,a+o)}),s=a+o}return n}function vB(r,t,e){if(!t||!e||t>=r.byteLength)return[];let n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength),s=[],i=t;for(let o=0;o<e&&!(i+60>n.byteLength);o++){let a=ei(r,i+20),c=i+60;if(a>n.byteLength-c)break;s.push({reserved:r.getUint16(i,!0),userId:ea(n,i+2,16),recordId:r.getUint16(i+18,!0),description:ea(n,i+28,32),offset:i,data:n.slice(c,c+a),dataOffset:c,dataLength:a}),i=c+a}return s}function SB(r,t){let e=r.data;e&&(r.userId==="LASF_Spec"&&r.recordId===4?t.extraBytes.push(...qw(e)):r.userId==="LASF_Spec"&&r.recordId>=100&&r.recordId<=354?t.waveformPacketDescriptors.push(_B(r.recordId,e)):r.userId==="LASF_Projection"&&r.recordId===2111?t.wktMathTransform=Xu(e):r.userId==="LASF_Projection"&&r.recordId===2112?t.wkt=Xu(e):r.userId==="LASF_Projection"&&r.recordId===34735?t.geotiff={...t.geotiff,keys:MB(e)}:r.userId==="LASF_Projection"&&r.recordId===34736?t.geotiff={...t.geotiff,doubles:DB(e)}:r.userId==="LASF_Projection"&&r.recordId===34737&&(t.geotiff={...t.geotiff,ascii:Xu(e)}))}function IB(r){let t=r.geotiff,e=t?.keys;if(!t||!e||e.length<4)return;let n=e[3];if(e.length<4+n*4)return;let s=[];for(let i=0;i<n;i++){let o=4+i*4,a={keyId:e[o],tiffTagLocation:e[o+1],count:e[o+2],valueOffset:e[o+3]};a.value=BB(a,t),a.value===void 0&&delete a.value,s.push(a)}t.keyDirectory={version:e[0],keyRevision:e[1],minorRevision:e[2],entries:s}}function BB(r,t){if(r.tiffTagLocation===0)return r.valueOffset;if(r.tiffTagLocation===34735&&t.keys){let e=t.keys.slice(r.valueOffset,r.valueOffset+r.count);return e.length===r.count?Array.from(e):void 0}if(r.tiffTagLocation===34736&&t.doubles){let e=t.doubles.slice(r.valueOffset,r.valueOffset+r.count);return e.length!==r.count?void 0:r.count===1?e[0]:Array.from(e)}if(r.tiffTagLocation===34737&&t.ascii!==void 0){let e=r.valueOffset+r.count;return e>t.ascii.length?void 0:t.ascii.slice(r.valueOffset,e).replace(/\|$/,"")}}function _B(r,t){if(t.byteLength<28)throw new Error(`LASLoader: waveform descriptor VLR ${r} is truncated`);let e=new DataView(t.buffer,t.byteOffset,t.byteLength);return{recordId:r,bitsPerSample:e.getUint8(2),compressionType:e.getUint8(3),numberOfSamples:e.getUint32(4,!0),temporalSampleSpacing:e.getUint32(8,!0),digitizerGain:e.getFloat64(12,!0),digitizerOffset:e.getFloat64(20,!0)}}function LB(r,t){let e=t?15:5,n=t?255:111,s=[];for(let i=0;i<e;i++)s.push(t?ei(r,n+i*8):r.getUint32(n+i*4,!0));return s}function ea(r,t,e){return Xu(r.subarray(t,t+e))}function Xu(r){let t=r.length;for(;t>0&&r[t-1]===0;)t--;return new TextDecoder().decode(r.subarray(0,t)).trim()}function TB(r){let t=(n,s)=>Array.from(r.subarray(n,n+s),i=>i.toString(16).padStart(2,"0")).reverse().join(""),e=(n,s)=>Array.from(r.subarray(n,n+s),i=>i.toString(16).padStart(2,"0")).join("");return`${t(0,4)}-${t(4,2)}-${t(6,2)}-${e(8,2)}${e(10,6)}`}function MB(r){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),e=new Uint16Array(Math.floor(r.byteLength/2));for(let n=0;n<e.length;n++)e[n]=t.getUint16(n*2,!0);return e}function DB(r){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),e=new Float64Array(Math.floor(r.byteLength/8));for(let n=0;n<e.length;n++)e[n]=t.getFloat64(n*8,!0);return e}function Ku(r,t,e={}){let n=t.pointsCount,s=e.las?.fp64?Float64Array:Float32Array,i=new s(n*3),o=l1(e),a=t.hasColor&&o.color?new Uint8Array(n*4):null,c=o.intensity?new Uint16Array(n):null,l=o.classification?new Uint8Array(n):null,u=o.synthetic?new Uint8Array(n):null,f=o.keyPoint?new Uint8Array(n):null,h=o.withheld?new Uint8Array(n):null,m=o.overlap?new Uint8Array(n):null,y=o.gpsTime&&im(t.pointsFormatId)>=0?new Float64Array(n):null,g=o.nir&&(om(t.pointsFormatId)>=0||e.las?.compatibilityMode!=="raw"&&t.metadata?.compatibility?.nirByteOffset!==void 0)?new Uint16Array(n):null,x=o.scanAngle?new Int16Array(n):null,I=o.userData?new Uint8Array(n):null,j=o.pointSourceId?new Uint16Array(n):null,T=o.returnNumber?new Uint8Array(n):null,b=o.numberOfReturns?new Uint8Array(n):null,C=o.scannerChannel?new Uint8Array(n):null,_=o.scanDirectionFlag?new Uint8Array(n):null,q=o.edgeOfFlightLine?new Uint8Array(n):null,X=o.waveform&&sm(t.pointsFormatId)>=0?new Uint8Array(n*29):null,ft=Math.max(0,t.pointsStructSize-zn(t.pointsFormatId)),dt=o.extraBytes&&e.las?.extraBytes!=="typed"&&ft?new Uint8Array(n*ft):null,It=o.extraBytes&&e.las?.extraBytes==="typed"?a1(n,t):null;return FB(CB(r),t,e,{positions:i,colors:a,intensities:c,classifications:l,syntheticFlags:u,keyPointFlags:f,withheldFlags:h,overlapFlags:m,gpsTimes:y,nir:g,scanAngles:x,userData:I,pointSourceIds:j,returnNumbers:T,numberOfReturns:b,scannerChannels:C,scanDirectionFlags:_,edgeOfFlightLines:q,waveforms:X,extraBytes:dt,typedExtraBytes:It,pointOffset:0,sourcePointIndex:0,pointCount:n}),rm(t,i,a,c,l,u,f,h,m,y,g,x,I,j,T,b,C,_,q,X,dt,It)}function rm(r,t,e,n,s,i,o,a,c,l,u,f,h,m,y,g,x,I,j,T,b,C){let _={POSITION:{value:t,size:3}};if(n&&(_.intensity={value:n,size:1}),s&&(_.classification={value:s,size:1}),i&&(_.synthetic={value:i,size:1}),o&&(_.keyPoint={value:o,size:1}),a&&(_.withheld={value:a,size:1}),c&&(_.overlap={value:c,size:1}),e&&(_.COLOR_0={value:e,size:e instanceof Uint16Array?3:4}),l&&(_.GPS_TIME={value:l,size:1}),u&&(_.NIR={value:u,size:1}),f&&(_.scanAngle={value:f,size:1}),h&&(_.userData={value:h,size:1}),m&&(_.pointSourceId={value:m,size:1}),y&&(_.returnNumber={value:y,size:1}),g&&(_.numberOfReturns={value:g,size:1}),x&&(_.scannerChannel={value:x,size:1}),I&&(_.scanDirectionFlag={value:I,size:1}),j&&(_.edgeOfFlightLine={value:j,size:1}),T&&(_.WAVEFORM={value:T,size:29}),b&&(_.EXTRA_BYTES={value:b,size:b.length/Math.max(r.pointsCount,1)}),C)for(let ft of C)_[ft.name]={value:ft.value,size:ft.size};let q={};for(let[ft,dt]of Object.entries(_))!(dt.value instanceof BigInt64Array)&&!(dt.value instanceof BigUint64Array)&&(q[ft]={...dt,value:dt.value});let X=zw(r,q);return{...cu(_,{schema:X,topology:"point-list",mode:0,boundingBox:JB(r)}),loader:"las",loaderData:r,progress:r.totalRead/r.totalToRead}}function CB(r){return ArrayBuffer.isView(r)?new DataView(r.buffer,r.byteOffset,r.byteLength):new DataView(r)}function FB(r,t,e,n){let{scale:[s,i,o],offset:[a,c,l]}=t,u=t.pointsFormatId,f=t.pointsStructSize,h=n.colors?nm(u):-1,m=h>=0?OB(r,t,n.sourcePointIndex,n.pointCount,e.las?.colorDepth):!1,y=n.intensities,g=n.classifications,x=n.syntheticFlags,I=n.keyPointFlags,j=n.withheldFlags,T=n.overlapFlags,b=n.gpsTimes,C=n.nir,_=n.scanAngles,q=n.userData,X=n.pointSourceIds,ft=n.returnNumbers,dt=n.numberOfReturns,It=n.scannerChannels,se=n.scanDirectionFlags,rt=n.edgeOfFlightLines,tt=n.waveforms,Ye=n.extraBytes,Ue=n.typedExtraBytes,Ze=b?im(u):-1,xt=C?om(u):-1;for(let jn=0;jn<n.pointCount;jn++){let ni=n.sourcePointIndex+jn,wt=t.pointsOffset+ni*f,pt=n.pointOffset+jn;n.positions[pt*3]=r.getInt32(wt,!0)*s+a,n.positions[pt*3+1]=r.getInt32(wt+4,!0)*i+c,n.positions[pt*3+2]=r.getInt32(wt+8,!0)*o+l,y&&(y[pt]=r.getUint16(wt+12,!0)),g&&(g[pt]=EB(r,wt,u)),b&&Ze>=0&&(b[pt]=r.getFloat64(wt+Ze,!0)),C&&xt>=0&&(C[pt]=r.getUint16(wt+xt,!0)),_&&(_[pt]=u<=5?r.getInt8(wt+16):r.getInt16(wt+18,!0)),q&&(q[pt]=r.getUint8(wt+17)),X&&(X[pt]=r.getUint16(wt+(u<=5?18:20),!0));let un=r.getUint8(wt+14),Wr=r.getUint8(wt+15),fn=u<=5?Wr>>5:Wr;if(x&&(x[pt]=fn&1),I&&(I[pt]=fn>>1&1),j&&(j[pt]=fn>>2&1),T&&(T[pt]=u<=5?0:fn>>3&1),ft&&(ft[pt]=u<=5?un&7:un&15),dt&&(dt[pt]=u<=5?un>>3&7:un>>4),It&&(It[pt]=u<=5?0:Wr>>4&3),se&&(se[pt]=u<=5?un>>6&1:Wr>>6&1),rt&&(rt[pt]=u<=5?un>>7&1:Wr>>7&1),tt){let Sr=sm(u);if(Sr>=0){let Ir=new Uint8Array(r.buffer,r.byteOffset+wt+Sr,29);tt.set(Ir,pt*29)}}if(Ye){let Sr=zn(u),Ir=t.pointsStructSize-Sr;Ir>0&&Ye.set(new Uint8Array(r.buffer,r.byteOffset+wt+Sr,Ir),pt*Ir)}if(Ue&&WB(r,wt,u,pt,Ue),e.las?.compatibilityMode!=="raw"&&t.metadata?.compatibility&&Qp(r,wt+zn(u),pt,t.metadata.compatibility,n),h>=0&&n.colors){let Sr=r.getUint16(wt+h,!0),Ir=r.getUint16(wt+h+2,!0),ao=r.getUint16(wt+h+4,!0);n.colors[pt*4]=m?Sr/256:Sr,n.colors[pt*4+1]=m?Ir/256:Ir,n.colors[pt*4+2]=m?ao/256:ao,n.colors[pt*4+3]=255}}}function EB(r,t,e){return e<=5?r.getUint8(t+15)&31:r.getUint8(t+16)}function i1(r){return nm(r)>=0}function nm(r){switch(r){case 2:return 20;case 3:return 28;case 5:return 28;case 7:case 8:case 10:return 30;default:return-1}}function sm(r){switch(r){case 4:return 28;case 5:return 34;case 9:return 30;case 10:return 38;default:return-1}}function im(r){return r===1||r===3||r===4||r===5?20:r>=6&&r<=10?22:-1}function om(r){return r===8||r===10?36:-1}function OB(r,t,e,n,s){if(s===8)return!1;if(s===16)return!0;if(s!=="auto")return!1;let i=nm(t.pointsFormatId);if(i<0)return!1;for(let o=0;o<n;o++){let a=t.pointsOffset+(e+o)*t.pointsStructSize;if(r.getUint16(a+i,!0)>255||r.getUint16(a+i+2,!0)>255||r.getUint16(a+i+4,!0)>255)return!0}return!1}function ra(r){let t=r.batchSize??r.core?.batchSize;return typeof t=="number"?t:Hw}function am(r,t){let e=new DataView(r.buffer,r.byteOffset,r.byteLength),n=t.headerSize||Kw,s=t.vlrCount||0;for(let i=0;i<s;i++){if(n+54>r.byteLength)throw new it("LASLoader: incomplete VLR header");let o=KB(r,n+2,16),a=e.getUint16(n+18,!0),c=e.getUint16(n+20,!0),l=n+54;if(l+c>r.byteLength)throw new it("LASLoader: incomplete VLR data");if(o===iB&&a===oB){if(c<34)throw new Error("LASLoader: malformed LASzip VLR");let u=e.getUint32(l+12,!0),f=e.getUint16(l+32,!0);if(34+f*6>c)throw new Error("LASLoader: malformed LASzip VLR item table");let m=null,y=null,g=null,x=null,I=null,j=[];for(let T=0;T<f;T++){let b=l+34+T*6,C=e.getUint16(b,!0),_=e.getUint16(b+2,!0),q=e.getUint16(b+4,!0);if(j.push({type:C,size:_,version:q}),[0,6,7,8].includes(C)){if(q!==1&&q!==2)throw new Error(`LASLoader: unsupported legacy LASzip item type ${C} version ${q}`)}else if(C===9){if(q!==1)throw new Error(`LASLoader: unsupported WavePacket13 item version ${q}`);g=q}else if([10,11,12,14].includes(C)){if(q!==2&&q!==3&&q!==4)throw new Error(`LASLoader: unsupported LAS 1.4 item type ${C} version ${q}`);C===10?m=q:C===11||C===12?y=q:I=q}else if(C===13){if(q!==3&&q!==4)throw new Error(`LASLoader: unsupported WavePacket14 item version ${q}`);x=q}}return{compressor:e.getUint16(l,!0),coder:e.getUint16(l+2,!0),chunkSize:u,variableChunks:e.getUint16(l,!0)!==1&&(u===0||u===aB),items:j,point14ItemVersion:m,rgb14ItemVersion:y,wavePacket13ItemVersion:g,wavePacketItemVersion:x,byte14ItemVersion:I}}n=l+c}throw new Error("LASLoader: compressed LAZ file does not contain a LASzip VLR")}function cm(r,t){if(![0,1,2,3,4,5,6,7,8,9,10].includes(r.pointsFormatId))throw new Error(`LASLoader: TypeScript LAZ streaming only supports point formats 0-10; received ${r.pointsFormatId}`);if(r.pointsFormatId<=5&&t.compressor!==1&&t.compressor!==2)throw new Error(`LASLoader: legacy TypeScript LAZ decoding requires LASzip compressor 1 or 2; received ${t.compressor}`);if(r.pointsFormatId>=6&&t.compressor!==3)throw new Error(`LASLoader: LAS 1.4 TypeScript LAZ decoding requires LASzip compressor 3; received ${t.compressor}`);if(t.coder!==0)throw new Error(`LASLoader: TypeScript LAZ decoding requires LASzip arithmetic coder 0; received ${t.coder}`);if(NB(r,t.items),r.pointsFormatId>=6&&!t.point14ItemVersion)throw new Error(`LASLoader: point format ${r.pointsFormatId} requires a Point14 LASzip item`);if((r.pointsFormatId===4||r.pointsFormatId===5)&&!t.wavePacket13ItemVersion)throw new Error(`LASLoader: point format ${r.pointsFormatId} requires a WavePacket13 LASzip item`);if((r.pointsFormatId===7||r.pointsFormatId===8||r.pointsFormatId===10)&&!t.rgb14ItemVersion)throw new Error(`LASLoader: point format ${r.pointsFormatId} requires an RGB14 or RGBNIR14 LASzip item`);if(r.pointsFormatId>=6&&r.pointsStructSize>zn(r.pointsFormatId)&&!t.byte14ItemVersion)throw new Error(`LASLoader: point format ${r.pointsFormatId} with Extra Bytes requires a Byte14 LASzip item`);if((r.pointsFormatId===9||r.pointsFormatId===10)&&!t.wavePacketItemVersion)throw new Error(`LASLoader: point format ${r.pointsFormatId} requires a WavePacket14 LASzip item`)}function NB(r,t){let e=r.pointsFormatId,n=zn(e),s=r.pointsStructSize-n;if(s<0)throw new Error(`LASLoader: point format ${e} record length ${r.pointsStructSize} is smaller than ${n}`);let i=[];switch(e){case 0:i.push({type:6,size:20});break;case 1:i.push({type:6,size:20},{type:7,size:8});break;case 2:i.push({type:6,size:20},{type:8,size:6});break;case 3:i.push({type:6,size:20},{type:7,size:8},{type:8,size:6});break;case 4:i.push({type:6,size:20},{type:7,size:8},{type:9,size:29});break;case 5:i.push({type:6,size:20},{type:7,size:8},{type:8,size:6},{type:9,size:29});break;case 6:i.push({type:10,size:30});break;case 7:i.push({type:10,size:30},{type:11,size:6});break;case 8:i.push({type:10,size:30},{type:12,size:8});break;case 9:i.push({type:10,size:30},{type:13,size:29});break;case 10:i.push({type:10,size:30},{type:12,size:8},{type:13,size:29});break;default:return}if(s>0&&i.push({type:e<=5?0:14,size:s}),t.length!==i.length)throw new Error(`LASLoader: point format ${e} has ${t.length} LASzip items; expected ${i.length}`);for(let o=0;o<i.length;o++){let a=t[o],c=i[o];if(a.type!==c.type)throw new Error(`LASLoader: LASzip item ${o} has type ${a.type}; expected ${c.type} for point format ${e}`);if(a.size!==c.size)throw new Error(`LASLoader: LASzip item ${o} has size ${a.size}; expected ${c.size} for point format ${e}`)}}async function UB(r,t,e){let n=r;for(;;){try{return{pending:n,laszip:am(n,e)}}catch(i){if(!(i instanceof it))throw i}let s=await t.next();if(s.done)throw new it("LASLoader: incomplete LASzip VLR");n=f1(n,pm(s.value))}}async function RB(r,t){let e=[r],n=r.byteLength;for(;;){let o=await t.next();if(o.done)break;let a=pm(o.value);e.push(a),n+=a.byteLength}if(e.length===1)return r;let s=new Uint8Array(n),i=0;for(let o of e)s.set(o,i),i+=o.byteLength;return s}async function Qu(r,t,e,n,s,i,o){if(o.las?.recoverMissingChunkTable&&s===e.pointsOffset){if(n.variableChunks)throw new Error("LASLoader: cannot recover a missing variable-size LAZ chunk table");for(;;){if(r.getAvailableByteLength())throw new Error("LASLoader: unexpected bytes after recovered LAZ chunks");let h=await t.next();if(h.done)return;r.write(h.value)}}let a=i.reduce((h,m)=>h+m,0),c=e.pointsOffset+Wt+a,l=s===-1?c:s;if(!Number.isSafeInteger(l)||l<c)throw new Error("LASLoader: LAZ chunk table byte lengths overlap the chunk table");let u=l-c;await io(r,t,u,"LASLoader: incomplete LAZ chunk table"),r.skip(u);let f=await zB(r,t,e,n);if(f.length!==i.length)throw new Error(`LASLoader: LAZ chunk table contains ${f.length} chunks; decoded ${i.length}`);for(let h=0;h<f.length;h++)if(f[h].byteLength!==i[h])throw new Error(`LASLoader: LAZ chunk ${h} has ${f[h].byteLength} table bytes; decoded ${i[h]}`);s===-1&&await PB(r,t,l)}async function PB(r,t,e){let n=new Uint8Array(Wt),s=0;for(;;){let o=r.getAvailableByteLength();if(o>0){let c=r.readBytes(Math.min(o,65536));kB(n,c),s+=c.byteLength;continue}let a=await t.next();if(a.done)break;r.write(a.value)}if(s<Wt)throw new it("LASLoader: incomplete non-seekable LAZ chunk-table footer");let i=ei(new DataView(n.buffer),0);if(!Number.isSafeInteger(i)||i!==e)throw new Error(`LASLoader: non-seekable LAZ footer points to ${i}; expected ${e}`)}function kB(r,t){if(t.byteLength>=r.byteLength){r.set(t.subarray(t.byteLength-r.byteLength));return}r.copyWithin(0,t.byteLength),r.set(t,r.byteLength-t.byteLength)}async function zB(r,t,e,n){let s=64;for(;;){let i=r.getAvailableByteLength();if(i>=8){let a=r.checkpoint();try{let c=r.readBytes(Math.min(i,s)),l=o1(c,e,n);return r.restore(a),l}catch(c){if(r.restore(a),!(c instanceof it))throw c;if(s*=2,s<=i)continue}}let o=await t.next();if(o.done)throw new it("LASLoader: incomplete LAZ chunk table");r.write(o.value)}}async function io(r,t,e,n){for(;!r.hasAvailableBytes(e);){let s=await t.next();if(s.done)throw new it(n);r.write(s.value)}}async function VB(r,t,e){for(;;){let n=r.checkpoint(),s;try{s=GB(r,e)}finally{r.restore(n)}if(s!==null)return await io(r,t,s,"LASLoader: truncated LAZ chunk"),s;let i=await t.next();if(i.done)throw new it("LASLoader: truncated LAZ chunk");r.write(i.value)}}function GB(r,t){if(t.pointDataRecordFormat<6||t.pointDataRecordFormat>10)return null;let e=t.pointDataRecordLength-zn(t.pointDataRecordFormat);if(e<0)throw new Error(`Invalid point record length ${t.pointDataRecordLength}`);let n=$B(t.pointDataRecordFormat)+e,s=t.pointDataRecordLength+4,i=n*4,o=s+i;if(!r.hasAvailableBytes(o))return null;r.skip(s);let a=o;for(let c=0;c<n;c++)a+=r.readUint32LE();return a}function zn(r){switch(r){case 0:return 20;case 1:return 28;case 2:return 26;case 3:return 34;case 4:return 57;case 5:return 63;case 6:return 30;case 7:return 36;case 8:return 38;case 9:return 59;case 10:return 67;default:throw new Error(`Unsupported LAS point format ${r}`)}}function $B(r){switch(r){case 6:return 9;case 7:return 10;case 8:return 11;case 9:return 10;case 10:return 12;default:throw new Error(`Unsupported LAS 1.4 point format ${r}`)}}function lm(r,t,e,n){if(e.compressor===1)return[{pointCount:t.pointsCount,byteLength:r.byteLength-t.pointsOffset}];let s=n_(new DataView(r.buffer,r.byteOffset,r.byteLength),t.pointsOffset);return jB(r,t,e,s,n)}function jB(r,t,e,n,s){if(s.las?.recoverMissingChunkTable&&n===t.pointsOffset)return qB(r,t,e);if(!Number.isSafeInteger(n)||n<0||n+8>r.byteLength)throw new it("LASLoader: incomplete LAZ chunk table");let i=o1(r.subarray(n),t,e),o=i.reduce((a,c)=>a+c.byteLength,0);if(t.pointsOffset+Wt+o>n)throw new Error("LASLoader: LAZ chunk table byte lengths overlap the chunk table");return i}function qB(r,t,e){if(e.variableChunks||!e.chunkSize)throw new Error("LASLoader: cannot recover a missing variable-size LAZ chunk table");let n=[],s=t.pointsOffset+Wt,i=0;for(;i<t.pointsCount;){let o=Math.min(e.chunkSize,t.pointsCount-i),a=ri(t,e,o),c=r.subarray(s),l;if(t.pointsFormatId<=5){let u=jr(c,a),f=new Uint8Array(Math.min(o,256)*t.pointsStructSize);for(;u.remainingPointCount;)u.decodeInto(f,0,Math.min(u.remainingPointCount,256));l=u.compressedByteOffset}else um(c,a),l=Pu(c,a);if(!l||s+l>r.byteLength)throw new it("LASLoader: truncated LAZ chunk during table recovery");n.push({pointCount:o,byteLength:l}),s+=l,i+=o}if(s!==r.byteLength)throw new Error("LASLoader: unexpected bytes after recovered LAZ chunks");return n}function um(r,t){if(r.byteLength<t.pointDataRecordLength+4)throw new it("LASLoader: truncated recovered layered LAZ chunk header");let n=new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(t.pointDataRecordLength,!0);if(n!==t.pointCount)throw new Error(`LASLoader: recovered layered LAZ chunk contains ${n} points; expected ${t.pointCount}`)}function o1(r,t,e){if(r.byteLength<8)throw new it("LASLoader: incomplete LAZ chunk table");let n=new DataView(r.buffer,r.byteOffset,r.byteLength),s=n.getUint32(0,!0),i=n.getUint32(4,!0);if(s!==0)throw new Error(`LASLoader: unsupported LAZ chunk table version ${s}`);if(i===0){if(t.pointsCount!==0)throw new Error("LASLoader: missing LAZ chunk table");return[]}let o=Up(r.subarray(8),{chunkCount:i,pointCount:t.pointsCount,chunkSize:e.chunkSize,variable:e.variableChunks}),a=0;for(let c of o){if(c.pointCount===0||c.byteLength===0)throw new Error("LASLoader: invalid empty LAZ chunk-table entry");a+=c.pointCount}if(a!==t.pointsCount)throw new Error(`LASLoader: LAZ chunk table contains ${a} points; expected ${t.pointsCount}`);return o}function tf(r,t,e){return e&&e.rawBatchAllocations++,{rawBatch:new Uint8Array(r*t),batchPointCount:0,totalRead:0,rawBatchAllocations:1,stats:e}}function ef(r,t,e){let n=e.las?.fp64?Float64Array:Float32Array,s=new n(r*3),i=l1(e),o=t.hasColor&&i.color&&(e.las?.colorDepth===16||e.las?.colorDepth==="auto"),a=t.hasColor&&i.color&&!o?new Uint8Array(r*4):null,c=o?new Uint16Array(r*3):null,l=i.intensity?new Uint16Array(r):null,u=i.classification?new Uint8Array(r):null,f=i.synthetic?new Uint8Array(r):null,h=i.keyPoint?new Uint8Array(r):null,m=i.withheld?new Uint8Array(r):null,y=i.overlap?new Uint8Array(r):null,g=i.gpsTime&&im(t.pointsFormatId)>=0?new Float64Array(r):null,x=i.nir&&(om(t.pointsFormatId)>=0||e.las?.compatibilityMode!=="raw"&&t.metadata?.compatibility?.nirByteOffset!==void 0)?new Uint16Array(r):null,I=i.scanAngle?new Int16Array(r):null,j=i.userData?new Uint8Array(r):null,T=i.pointSourceId?new Uint16Array(r):null,b=i.returnNumber?new Uint8Array(r):null,C=i.numberOfReturns?new Uint8Array(r):null,_=i.scannerChannel?new Uint8Array(r):null,q=i.scanDirectionFlag?new Uint8Array(r):null,X=i.edgeOfFlightLine?new Uint8Array(r):null,ft=i.waveform&&sm(t.pointsFormatId)>=0?new Uint8Array(r*29):null,dt=Math.max(0,t.pointsStructSize-zn(t.pointsFormatId)),It=i.extraBytes&&e.las?.extraBytes!=="typed"&&dt?new Uint8Array(r*dt):null,se=i.extraBytes&&e.las?.extraBytes==="typed"?a1(r,t):null,rt=se?.length&&dt?new Uint8Array(r*dt):null,tt=i.classification||i.returnNumber||i.numberOfReturns||i.scanAngle||i.overlap||i.scannerChannel||i.nir,Ye=e.las?.compatibilityMode==="raw"||!tt?null:t.metadata?.compatibility||null,Ue=Ye&&!It&&!rt?new Uint8Array(r*dt):null;return{batchCapacity:r,positions:s,colors:a,rawColors:c,intensities:l,classifications:u,syntheticFlags:f,keyPointFlags:h,withheldFlags:m,overlapFlags:y,gpsTimes:g,nir:x,scanAngles:I,userData:j,pointSourceIds:T,returnNumbers:b,numberOfReturns:C,scannerChannels:_,scanDirectionFlags:q,edgeOfFlightLines:X,waveforms:ft,extraBytes:It,typedExtraBytes:se,typedExtraBytesSource:rt,compatibilityLayout:Ye,compatibilityExtraBytesSource:Ue,target:{positions:s,intensities:l,classifications:u,syntheticFlags:f,keyPointFlags:h,withheldFlags:m,overlapFlags:y,gpsTimes:g,nir:x,scanAngles:I,userData:j,pointSourceIds:T,returnNumbers:b,numberOfReturns:C,scannerChannels:_,scanDirectionFlags:q,edgeOfFlightLines:X,waveforms:ft,extraBytes:It||rt||Ue,colors:a,rawColors:c,pointOffset:0,scale:t.scale,offset:t.offset},batchPointCount:0,totalRead:0}}function a1(r,t){let e=t.pointsStructSize-zn(t.pointsFormatId);return Ww(r,t.metadata?.extraBytes||[],e)}function c1(r){return r<=2?1:r<=4?2:r<=6||r===9?4:r===7||r===8||r===10?8:0}function WB(r,t,e,n,s){let i=t+zn(e);for(let o of s){let a=n*o.size,c=i+o.byteOffset;for(let l=0;l<o.size;l++)em(r,c+l*c1(o.scalarDataType),o,a+l,l)}}function YB(r,t,e,n,s){let i=new DataView(r.buffer,r.byteOffset,r.byteLength);for(let o=0;o<n;o++){let a=e+o,c=a*t;for(let l of s){let u=a*l.size,f=c1(l.scalarDataType);for(let h=0;h<l.size;h++)em(i,c+l.byteOffset+h*f,l,u+h,h)}}}function fm(r,t,e){let n=r.extraBytes||r.typedExtraBytesSource||r.compatibilityExtraBytesSource;if(r.compatibilityLayout&&n&&e){let s=new DataView(n.buffer,n.byteOffset,n.byteLength),i=n.length/r.batchCapacity;for(let o=t;o<t+e;o++)Qp(s,o*i,o,r.compatibilityLayout,r)}!r.typedExtraBytesSource||!r.typedExtraBytes?.length||e===0||YB(r.typedExtraBytesSource,r.typedExtraBytesSource.length/r.batchCapacity,t,e,r.typedExtraBytes)}function rf(r){return r.las?.lazStreamingStats}function hm(r,t,e){if(!e)return;let n=r.findBufferOffsets(t);n&&n.length>1&&(e.copiedBytes+=t,e.chunkConcatenations++)}function ZB(r,t){t&&(t.copiedBytes+=r,t.decodedChunkAllocations++)}function*dm(r,t,e,n){let s=e.pointsStructSize,i=jr(r,t);for(;i.remainingPointCount>0;){let o=n.rawBatch.byteLength/s,a=o-n.batchPointCount,c=i.decodeInto(n.rawBatch,n.batchPointCount*s,a);if(n.batchPointCount+=c,n.batchPointCount===o){let l=so(e,n);l&&(yield l)}}}function*HB(r,t,e){let n=t.pointsStructSize,s=r.byteLength/n;for(let i=0;i<s;i++){let o=i*n,a=e.batchPointCount*n;if(e.rawBatch.set(r.subarray(o,o+n),a),e.batchPointCount++,e.batchPointCount===e.rawBatch.byteLength/n){let c=so(t,e);c&&(yield c)}}}function so(r,t){if(t.batchPointCount===0)return null;let e=t.batchPointCount*r.pointsStructSize,n=e===t.rawBatch.byteLength,s=n?t.rawBatch.buffer:t.rawBatch.buffer.slice(0,e);t.totalRead+=t.batchPointCount;let i={...r,pointsOffset:0,pointsCount:t.batchPointCount,totalRead:t.totalRead};return t.batchPointCount=0,n&&(t.rawBatch=new Uint8Array(t.rawBatch.byteLength),t.rawBatchAllocations++,t.stats&&t.stats.rawBatchAllocations++),{arrayBuffer:s,header:i}}function Ju(r,t,e){if(t.batchPointCount===0)return null;t.totalRead+=t.batchPointCount;let n={...r,pointsOffset:0,pointsCount:t.batchPointCount,totalRead:t.totalRead},s=t.batchPointCount,i=s===t.batchCapacity,o=i?t.positions:t.positions.subarray(0,s*3),a=t.intensities?i?t.intensities:t.intensities.subarray(0,s):null,c=t.classifications?i?t.classifications:t.classifications.subarray(0,s):null,l=t.syntheticFlags?i?t.syntheticFlags:t.syntheticFlags.subarray(0,s):null,u=t.keyPointFlags?i?t.keyPointFlags:t.keyPointFlags.subarray(0,s):null,f=t.withheldFlags?i?t.withheldFlags:t.withheldFlags.subarray(0,s):null,h=t.overlapFlags?i?t.overlapFlags:t.overlapFlags.subarray(0,s):null,m=t.colors?i?t.colors:t.colors.subarray(0,s*4):t.rawColors?u1(t.rawColors,s,e):null,y=t.gpsTimes?i?t.gpsTimes:t.gpsTimes.subarray(0,s):null,g=t.nir?i?t.nir:t.nir.subarray(0,s):null,x=t.scanAngles?i?t.scanAngles:t.scanAngles.subarray(0,s):null,I=t.userData?i?t.userData:t.userData.subarray(0,s):null,j=t.pointSourceIds?i?t.pointSourceIds:t.pointSourceIds.subarray(0,s):null,T=t.returnNumbers?i?t.returnNumbers:t.returnNumbers.subarray(0,s):null,b=t.numberOfReturns?i?t.numberOfReturns:t.numberOfReturns.subarray(0,s):null,C=t.scannerChannels?i?t.scannerChannels:t.scannerChannels.subarray(0,s):null,_=t.scanDirectionFlags?i?t.scanDirectionFlags:t.scanDirectionFlags.subarray(0,s):null,q=t.edgeOfFlightLines?i?t.edgeOfFlightLines:t.edgeOfFlightLines.subarray(0,s):null,X=t.waveforms?i?t.waveforms:t.waveforms.subarray(0,s*29):null,ft=t.extraBytes?t.extraBytes.length/t.batchCapacity:0,dt=t.extraBytes?i?t.extraBytes:t.extraBytes.subarray(0,s*ft):null,It=t.typedExtraBytes?t.typedExtraBytes.map(rt=>({...rt,value:i?rt.value:rt.value.subarray(0,s*rt.size)})):null,se=rm(n,o,m,a,c,l,u,f,h,y,g,x,I,j,T,b,C,_,q,X,dt,It);if(t.batchPointCount=0,i){let rt=e.las?.fp64?Float64Array:Float32Array;t.positions=new rt(t.positions.length),t.colors=t.colors?new Uint8Array(t.colors.length):null,t.rawColors=t.rawColors?new Uint16Array(t.rawColors.length):null,t.intensities=t.intensities?new Uint16Array(t.intensities.length):null,t.classifications=t.classifications?new Uint8Array(t.classifications.length):null,t.syntheticFlags=t.syntheticFlags?new Uint8Array(t.syntheticFlags.length):null,t.keyPointFlags=t.keyPointFlags?new Uint8Array(t.keyPointFlags.length):null,t.withheldFlags=t.withheldFlags?new Uint8Array(t.withheldFlags.length):null,t.overlapFlags=t.overlapFlags?new Uint8Array(t.overlapFlags.length):null,t.gpsTimes=t.gpsTimes?new Float64Array(t.gpsTimes.length):null,t.nir=t.nir?new Uint16Array(t.nir.length):null,t.scanAngles=t.scanAngles?new Int16Array(t.scanAngles.length):null,t.userData=t.userData?new Uint8Array(t.userData.length):null,t.pointSourceIds=t.pointSourceIds?new Uint16Array(t.pointSourceIds.length):null,t.returnNumbers=t.returnNumbers?new Uint8Array(t.returnNumbers.length):null,t.numberOfReturns=t.numberOfReturns?new Uint8Array(t.numberOfReturns.length):null,t.scannerChannels=t.scannerChannels?new Uint8Array(t.scannerChannels.length):null,t.scanDirectionFlags=t.scanDirectionFlags?new Uint8Array(t.scanDirectionFlags.length):null,t.edgeOfFlightLines=t.edgeOfFlightLines?new Uint8Array(t.edgeOfFlightLines.length):null,t.waveforms=t.waveforms?new Uint8Array(t.waveforms.length):null,t.extraBytes=t.extraBytes?new Uint8Array(t.extraBytes.length):null,t.typedExtraBytes=t.typedExtraBytes?t.typedExtraBytes.map(tt=>({...tt,value:tm(tt.scalarDataType,tt.value.length,tt.outputFloat64)})):null,t.typedExtraBytesSource=t.typedExtraBytesSource?new Uint8Array(t.typedExtraBytesSource.length):null,t.target.positions=t.positions,t.target.colors=t.colors,t.target.rawColors=t.rawColors,t.target.intensities=t.intensities,t.target.classifications=t.classifications,t.target.syntheticFlags=t.syntheticFlags,t.target.keyPointFlags=t.keyPointFlags,t.target.withheldFlags=t.withheldFlags,t.target.overlapFlags=t.overlapFlags,t.target.gpsTimes=t.gpsTimes,t.target.nir=t.nir,t.target.scanAngles=t.scanAngles,t.target.userData=t.userData,t.target.pointSourceIds=t.pointSourceIds,t.target.returnNumbers=t.returnNumbers,t.target.numberOfReturns=t.numberOfReturns,t.target.scannerChannels=t.scannerChannels,t.target.scanDirectionFlags=t.scanDirectionFlags,t.target.edgeOfFlightLines=t.edgeOfFlightLines,t.target.waveforms=t.waveforms,t.compatibilityExtraBytesSource=t.compatibilityExtraBytesSource?new Uint8Array(t.compatibilityExtraBytesSource.length):null,t.target.extraBytes=t.extraBytes||t.typedExtraBytesSource||t.compatibilityExtraBytesSource}return se}function l1(r){let t=r.las?.columns;if(!t)return{intensity:!0,classification:!0,synthetic:!0,keyPoint:!0,withheld:!0,overlap:!0,color:!0,gpsTime:!0,nir:!0,scanAngle:!0,userData:!0,pointSourceId:!0,returnNumber:!0,numberOfReturns:!0,scannerChannel:!0,scanDirectionFlag:!0,edgeOfFlightLine:!0,waveform:!0,extraBytes:r.las?.extraBytes==="typed"};let e=!1,n=!1,s=!1,i=!1,o=!1,a=!1,c=!1,l=!1,u=!1,f=!1,h=!1,m=!1,y=!1,g=!1,x=!1,I=!1,j=!1,T=!1,b=!1;for(let C of t)switch(C){case"POSITION":break;case"intensity":e=!0;break;case"classification":n=!0;break;case"synthetic":s=!0;break;case"keyPoint":i=!0;break;case"withheld":o=!0;break;case"overlap":a=!0;break;case"COLOR_0":c=!0;break;case"GPS_TIME":l=!0;break;case"NIR":u=!0;break;case"scanAngle":f=!0;break;case"userData":h=!0;break;case"pointSourceId":m=!0;break;case"returnNumber":y=!0;break;case"numberOfReturns":g=!0;break;case"scannerChannel":x=!0;break;case"scanDirectionFlag":I=!0;break;case"edgeOfFlightLine":j=!0;break;case"WAVEFORM":T=!0;break;case"EXTRA_BYTES":b=!0;break;default:throw new Error(`LASLoader: unsupported column ${C}`)}return{intensity:e,classification:n,synthetic:s,keyPoint:i,withheld:o,overlap:a,color:c,gpsTime:l,nir:u,scanAngle:f,userData:h,pointSourceId:m,returnNumber:y,numberOfReturns:g,scannerChannel:x,scanDirectionFlag:I,edgeOfFlightLine:j,waveform:T,extraBytes:b}}function u1(r,t,e){let n=new Uint8Array(t*4),s=new Uint32Array(n.buffer);if(XB(r,t,e.las?.colorDepth))for(let o=0;o<t;o++){let a=o*3,c=r[a]>>8&255,l=r[a+1]>>8&255,u=r[a+2]>>8&255;s[o]=4278190080|u<<16|l<<8|c}else for(let o=0;o<t;o++){let a=o*3,c=r[a]&255,l=r[a+1]&255,u=r[a+2]&255;s[o]=4278190080|u<<16|l<<8|c}return n}function XB(r,t,e){if(e===8)return!1;if(e===16)return!0;if(e!=="auto")return!1;for(let n=0;n<t*3;n++)if(r[n]>255)return!0;return!1}function KB(r,t,e){let n=t,s=t+e;for(;n<s&&r[n]!==0;)n++;return String.fromCharCode(...r.subarray(t,n))}function JB(r){let t=r.mins||[0,0,0],e=r.maxs||[0,0,0];return[[t[0],t[1],t[2]],[e[0],e[1],e[2]]]}function*QB(r,t,e,n,s,i){for(;n<e.pointsCount&&s<e.totalToRead;){let o=t_(r,t,e,n,s,i);if(!o)return;r=o.pending,t=o.absoluteOffset,n=o.sourcePointIndex,s=o.totalRead,yield o}}function t_(r,t,e,n,s,i){let o=e.pointsStructSize,c=e.pointsOffset+n*o-t;if(c<0)throw new Error("LASLoader: invalid streaming point offset");if(c+o>r.byteLength)return null;let l=Math.floor((r.byteLength-c)/o),u=Math.min(i,l,e.pointsCount-n,e.totalToRead-s);if(u<=0)return null;n+=u,s+=u;let f={...e,pointsOffset:r.byteOffset+c,pointsCount:u,totalRead:s},h=e.pointsOffset+n*o,m=Math.max(0,Math.min(r.byteLength,h-t));return{arrayBuffer:r.buffer,header:f,pending:r.subarray(m),absoluteOffset:t+m,sourcePointIndex:n,totalRead:s}}function e_(r,t){if(t!==0||r.byteLength<227)return null;let e=new DataView(r.buffer,r.byteOffset,r.byteLength);if(e.getUint32(0,!0)!==Xw)throw new Error("LASLoader: invalid LAS header");let n=e.getUint32(96,!0);return r.byteLength<Math.max(n,255)?null:s1(r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength))}function f1(r,t){if(r.byteLength===0)return t;let e=new Uint8Array(r.byteLength+t.byteLength);return e.set(r),e.set(t,r.byteLength),e}function pm(r){let t=ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r),e=new Uint8Array(t.byteLength);return e.set(t),e}function r_(r){if(Symbol.asyncIterator in r)return r[Symbol.asyncIterator]();let t=r[Symbol.iterator]();return{async next(){return t.next()}}}function n_(r,t){return h1(r,t)?r.byteLength<Wt?0:ei(r,r.byteLength-Wt):ei(r,t)}function nf(r){return h1(r,0)?-1:ei(r,0)}function h1(r,t){return r.byteLength>=t+8&&r.getUint32(t,!0)===4294967295&&r.getUint32(t+4,!0)===4294967295}function ei(r,t){if(r.byteLength<t+8)return 0;let e=r.getUint32(t,!0);return r.getUint32(t+4,!0)*2**32+e}var Hw,Xw,Kw,nB,sB,iB,oB,aB,Wt,cB,d1=d(()=>{"use strict";or();no();Vw();$w();Yw();Hw=1e3*100,Xw=1179861324,Kw=375,nB=128,sB=63,iB="laszip encoded",oB=22204,aB=4294967295,Wt=8,cB=64*1024});function p1(r,t){let e=t?.las?._chunk;return e?Qw(r,e.metadata,t||{}):Jw(r,t)}function sf(r,t){let e=t?.las?.colorFormat===void 0||t.las.colorFormat==="uint8norm"?r:{...Oe(Fb(ee(r),t.las.colorFormat),"arrow-table"),loader:r.loader,loaderData:r.loaderData,progress:r.progress};return Db(t)==="arrow-table"?e:{...ee(e),loader:e.loader,loaderData:e.loaderData,progress:e.progress}}async function*i_(r,t){for await(let e of r)yield sf(e,t)}function m1(r,t){return sf($o(r),t)}var s_,y1=d(()=>{"use strict";or();Eb();js();d1();s_={...Cb,worker:!0,workerInBatches:!0,serializeWorkerResult:re,serializeWorkerBatch:re,deserializeWorkerResult:m1,deserializeWorkerBatch:m1,parse:async(r,t)=>sf(p1(r,t),t),parseSync:(r,t)=>sf(p1(r,t),t),parseInBatches:async function*(r,t){yield*i_(e1(r,t),t)}}});var g1={};Re(g1,{LASLoaderWithParser:()=>s_});var b1=d(()=>{"use strict";y1()});function D1(r,t){let e=r.length,n=new Uint8Array(t),s=0,i=0,o,a,c;do if(o=r[s++],o<32){if(o++,i+o>t)throw new Error("Output buffer is not large enough");if(s+o>e)throw new Error("Invalid compressed data");do n[i++]=r[s++];while(--o)}else{if(a=o>>5,c=i-((o&31)<<8)-1,s>=e)throw new Error("Invalid compressed data");if(a===7&&(a+=r[s++],s>=e))throw new Error("Invalid compressed data");if(c-=r[s++],i+a+2>t)throw new Error("Output buffer is not large enough");if(c<0)throw new Error("Invalid compressed data");if(c>=i)throw new Error("Invalid compressed data");do n[i++]=n[c++];while(--a+2)}while(s<e);return n}var C1=d(()=>{"use strict"});function F1(r,t,e="uint8norm"){let n=[];for(let s of Object.keys(r.offset))switch(s){case"x":n.push({name:"POSITION",type:{type:"fixed-size-list",listSize:3,children:[{name:"xyz",type:"float32"}]},metadata:{attribute:"POSITION"}});break;case"y":case"z":break;case"normal_x":n.push({name:"NORMAL",type:{type:"fixed-size-list",listSize:3,children:[{name:"xyz",type:"float32"}]},metadata:{attribute:"NORMAL"}});break;case"normal_y":case"normal_z":break;case"rgb":let i=e==="float16"?"float16":e==="float32"?"float32":"uint8";n.push({name:"COLOR_0",type:{type:"fixed-size-list",listSize:3,children:[{name:"rgb",type:i}]},metadata:{attribute:"COLOR",...e==="float16"?{componentType:"float16"}:{}}});break;default:}return{fields:n,metadata:t}}var E1=d(()=>{"use strict"});function oa(r,t){let e=new TextDecoder().decode(r),n=Ac(e),s={};switch(n.data){case"ascii":s=Z_(n,e);break;case"binary":s=H_(n,r);break;case"binary_compressed":s=X_(n,r);break;default:throw new Error(`PCD: ${n.data} files are not supported`)}s=Y_(s,t?.pcd?.colorFormat);let i=W_(n,s),o=Object.fromEntries([["topology","point-list"],["mode","0"],["boundingBox",JSON.stringify(i.boundingBox)]]),a=F1(n,o,t?.pcd?.colorFormat);return{loader:"pcd",loaderData:n,header:i,schema:a,topology:"point-list",mode:0,attributes:s}}function W_(r,t){if(typeof r.width=="number"&&typeof r.height=="number"){let e=r.width*r.height,n=on(t);if(!n)throw new Error("PCD point cloud is missing positions");return{vertexCount:e,boundingBox:n}}return{vertexCount:r.vertexCount,boundingBox:r.boundingBox}}function Y_(r,t="uint8norm"){let e={POSITION:{value:new Float32Array(r.position),size:3}};return r.normal&&r.normal.length>0&&(e.NORMAL={value:new Float32Array(r.normal),size:3}),r.color&&r.color.length>0&&(e.COLOR_0=vm(r.color,t)),r.intensity&&r.intensity.length>0&&(e.COLOR_0=vm(r.color,t)),!e.COLOR_0&&r.label&&r.label.length>0&&(e.COLOR_0=vm(r.label,t)),e}function vm(r,t){return t==="float16"?{value:si(r,255),size:3,componentType:"float16"}:t==="float32"?{value:Float32Array.from(r,e=>e/255),size:3}:{value:new Uint8Array(r),size:3}}function Ac(r){let t=r.search(/[\r\n]DATA\s(\S*)\s/i),e=/[\r\n]DATA\s(\S*)\s/i.exec(r.substr(t-1)),n={};if(n.data=e&&e[1],e!==null&&(n.headerLen=(e&&e[0].length)+t),n.str=r.substr(0,n.headerLen),n.str=n.str.replace(/\#.*/gi,""),n.version=/VERSION (.*)/i.exec(n.str),n.fields=/FIELDS (.*)/i.exec(n.str),n.size=/SIZE (.*)/i.exec(n.str),n.type=/TYPE (.*)/i.exec(n.str),n.count=/COUNT (.*)/i.exec(n.str),n.width=/WIDTH (.*)/i.exec(n.str),n.height=/HEIGHT (.*)/i.exec(n.str),n.viewpoint=/VIEWPOINT (.*)/i.exec(n.str),n.points=/POINTS (.*)/i.exec(n.str),n.version!==null&&(n.version=parseFloat(n.version[1])),n.fields!==null&&(n.fields=n.fields[1].split(" ")),n.type!==null&&(n.type=n.type[1].split(" ")),n.width!==null&&(n.width=parseInt(n.width[1],10)),n.height!==null&&(n.height=parseInt(n.height[1],10)),n.viewpoint!==null&&(n.viewpoint=n.viewpoint[1]),n.points!==null&&(n.points=parseInt(n.points[1],10)),n.points===null&&typeof n.width=="number"&&typeof n.height=="number"&&(n.points=n.width*n.height),n.size!==null&&(n.size=n.size[1].split(" ").map(i=>parseInt(i,10))),n.count!==null)n.count=n.count[1].split(" ").map(i=>parseInt(i,10));else if(n.count=[],n.fields!==null)for(let i=0;i<n.fields.length;i++)n.count.push(1);n.offset={};let s=0;for(let i=0,o=n.fields.length;i<o;i++)n.data==="ascii"?n.offset[n.fields[i]]=i:(n.offset[n.fields[i]]=s,s+=n.size[i]*n.count[i]);return n.rowSize=s,n}function Z_(r,t){let e=[],n=[],s=[],i=[],o=[],a=r.offset,l=t.substr(r.headerLen).split(`
|
|
29
|
+
`);for(let u=0;u<l.length;u++)if(l[u]!==""){let f=l[u].split(" ");if(a.x!==void 0&&(e.push(parseFloat(f[a.x])),e.push(parseFloat(f[a.y])),e.push(parseFloat(f[a.z]))),a.rgb!==void 0){let h=parseFloat(f[a.rgb]),m=new Float32Array([h]),y=new DataView(m.buffer,0);s.push(y.getUint8(0)),s.push(y.getUint8(1)),s.push(y.getUint8(2))}a.normal_x!==void 0&&(n.push(parseFloat(f[a.normal_x])),n.push(parseFloat(f[a.normal_y])),n.push(parseFloat(f[a.normal_z]))),a.intensity!==void 0&&i.push(parseFloat(f[a.intensity])),a.label!==void 0&&o.push(parseInt(f[a.label]))}return{position:e,normal:n,color:s}}function H_(r,t){let e=[],n=[],s=[],i=[],o=[],a=new DataView(t,r.headerLen),c=r.offset;for(let l=0,u=0;l<r.points;l++,u+=r.rowSize)c.x!==void 0&&(e.push(a.getFloat32(u+c.x,we)),e.push(a.getFloat32(u+c.y,we)),e.push(a.getFloat32(u+c.z,we))),c.rgb!==void 0&&(s.push(a.getUint8(u+c.rgb+0)),s.push(a.getUint8(u+c.rgb+1)),s.push(a.getUint8(u+c.rgb+2))),c.normal_x!==void 0&&(n.push(a.getFloat32(u+c.normal_x,we)),n.push(a.getFloat32(u+c.normal_y,we)),n.push(a.getFloat32(u+c.normal_z,we))),c.intensity!==void 0&&i.push(a.getFloat32(u+c.intensity,we)),c.label!==void 0&&o.push(a.getInt32(u+c.label,we));return{position:e,normal:n,color:s,intensity:i,label:o}}function X_(r,t){let e=[],n=[],s=[],i=[],o=[],a=new Uint32Array(t.slice(r.headerLen,r.headerLen+8)),c=a[0],l=a[1],u=D1(new Uint8Array(t,r.headerLen+8,c),l),f=new DataView(u.buffer),h=r.offset;for(let m=0;m<r.points;m++){if(h.x!==void 0&&(e.push(f.getFloat32(r.points*h.x+r.size[0]*m,we)),e.push(f.getFloat32(r.points*h.y+r.size[1]*m,we)),e.push(f.getFloat32(r.points*h.z+r.size[2]*m,we))),h.rgb!==void 0&&(s.push(f.getUint8(r.points*h.rgb+r.size[3]*m+0)),s.push(f.getUint8(r.points*h.rgb+r.size[3]*m+1)),s.push(f.getUint8(r.points*h.rgb+r.size[3]*m+2))),h.normal_x!==void 0&&(n.push(f.getFloat32(r.points*h.normal_x+r.size[4]*m,we)),n.push(f.getFloat32(r.points*h.normal_y+r.size[5]*m,we)),n.push(f.getFloat32(r.points*h.normal_z+r.size[6]*m,we))),h.intensity!==void 0){let y=r.fields.indexOf("intensity");i.push(f.getFloat32(r.points*h.intensity+r.size[y]*m,we))}if(h.label!==void 0){let y=r.fields.indexOf("label");o.push(f.getInt32(r.points*h.label+r.size[y]*m,we))}}return{position:e,normal:n,color:s,intensity:i,label:o}}var we,O1=d(()=>{"use strict";$s();or();C1();E1();we=!0;});var N1,U1=d(()=>{"use strict";N1={name:"PCD (Point Cloud Data)",id:"pcd",module:"pointclouds",encoding:"text",format:"pcd",extensions:["pcd"],mimeTypes:["text/plain"],category:"pointcloud",text:!0,binary:!0}});async function J_(){let{PCDLoaderWithParser:r}=await Promise.resolve().then(()=>(Im(),Sm));return r}var K_,R1,P1=d(()=>{"use strict";U1();js();K_="5.0.0-beta.8";R1={...N1,dataType:null,batchType:null,version:K_,worker:!0,workerInBatches:!0,serializeWorkerResult:re,options:{pcd:{shape:"arrow-table",colorFormat:"uint8norm"}},preload:J_}});function k1(r,t){let e=Oe(r,"arrow-table");return t?.pcd?.shape==="mesh"?_m(e,r):{...e,loader:r.loader,loaderData:r.loaderData}}function e2(r){let t=r?.batchSize??r?.core?.batchSize;return typeof t=="number"?t:void 0}function*r2(r,t,e){let n=new TextDecoder().decode(r),s=Ac(n),i=n.slice(s.headerLen).split(/\r?\n/).filter(a=>a.trim().length>0),o=e||i.length||1;for(let a=0;a<i.length;a+=o){let c=i.slice(a,a+o),l=`${z1(s,c.length)}${c.join(`
|
|
30
30
|
`)}
|
|
31
|
-
`;yield
|
|
31
|
+
`;yield Bm(oa(new TextEncoder().encode(l).buffer,t),t)}}function*n2(r,t,e){let n=new TextDecoder().decode(r),s=Ac(n),i=e||s.points||1,o=new Uint8Array(r);for(let a=0;a<s.points;a+=i){let c=Math.min(i,s.points-a),l=new TextEncoder().encode(z1(s,c)),u=s.headerLen+a*s.rowSize,f=c*s.rowSize,h=new Uint8Array(l.length+f);h.set(l,0),h.set(o.subarray(u,u+f),l.length),yield Bm(oa(h.buffer,t),t)}}function Bm(r,t){let e=Oe(r,"arrow-table");return t?.pcd?.shape==="mesh"?_m(e,r):wc({...e,loader:r.loader,loaderData:r.loaderData})}function _m(r,t){return{...ee(r),loader:t.loader,loaderData:t.loaderData}}function z1(r,t){let e=r.str.split(/\r?\n/).filter(n=>n.trim().length>0).map(n=>/^WIDTH\s+/i.test(n)?`WIDTH ${t}`:/^HEIGHT\s+/i.test(n)?"HEIGHT 1":/^POINTS\s+/i.test(n)?`POINTS ${t}`:n);if(!e.some(n=>/^POINTS\s+/i.test(n))){let n=e.findIndex(s=>/^DATA\s+/i.test(s));e.splice(n>=0?n:e.length,0,`POINTS ${t}`)}return`${e.join(`
|
|
32
32
|
`)}
|
|
33
|
-
`}function
|
|
34
|
-
`);return
|
|
35
|
-
`?e+=2:e<r.length&&/\s/.test(r[e])&&(e+=1),{headerText:r.slice(0,e),headerLength:e}}function
|
|
36
|
-
`),a=0,c=0;for(let l=0;l<o.length;l++){let u=o[l];if(u=u.trim(),u!==""){c>=t.elements[a].count&&(a++,c=0);let f=
|
|
37
|
-
`),i=0,o=0;for(let a of s){let c=a.trim();if(c!==""){for(;i<t.elements.length&&o>=t.elements[i].count;)i++,o=0;if(i>=t.elements.length)break;
|
|
33
|
+
`}function V1(r,t){let e=$o(r);return t?.pcd?.shape==="mesh"?_m(e,e):e}function s2(r,t){return V1(r,t)}var Sk,Q_,t2,G1=d(()=>{"use strict";no();js();or();O1();P1();({preload:Sk,...Q_}=R1);t2={...Q_,parse:async(r,t)=>k1(oa(r,t),t),parseSync:(r,t)=>k1(oa(r,t),t),parseInBatches:async function*(r,t){let e=e2(t),n=await up(r),s=new TextDecoder().decode(n),i=Ac(s);if(i.data==="ascii"){yield*r2(n,t,e);return}if(i.data==="binary"){yield*n2(n,t,e);return}yield Bm(oa(n,t),t)},serializeWorkerResult:re,deserializeWorkerResult:V1,serializeWorkerBatch:re,deserializeWorkerBatch:s2}});var Sm={};Re(Sm,{PCDLoaderWithParser:()=>t2});var Im=d(()=>{"use strict";G1()});function ca(r,t){let e=f2(r),n=Wi(t,e);return h2(n,r),n}function f2(r){let t={};return t.ply_comments=JSON.stringify(r.comments),t.ply_elements=JSON.stringify(r.elements),r.format!==void 0&&(t.ply_format=r.format),r.version!==void 0&&(t.ply_version=r.version),r.headerLength!==void 0&&(t.ply_headerLength=r.headerLength.toString(10)),t}function h2(r,t){let e=d2(t);if(p2(e)){r.metadata["loaders_gl.semantic_type"]="gaussian-splats",r.metadata["loaders_gl.gaussian_splats.version"]="1";for(let n of r.fields)m2(n)}}function d2(r){let t=r.elements.find(e=>e.name==="vertex");return new Set(t?.properties.map(e=>e.name)||[])}function p2(r){return["x","y","z","f_dc_0","f_dc_1","f_dc_2","opacity","scale_0","scale_1","scale_2","rot_0","rot_1","rot_2","rot_3"].every(e=>r.has(e))}function m2(r){r.metadata||={};let t=r.metadata;if(r.name==="opacity"){t["loaders_gl.gaussian_splats.semantic"]="opacity",t["loaders_gl.gaussian_splats.encoding"]="logit";return}let e=lf(r.name,"scale");if(e!==void 0){t["loaders_gl.gaussian_splats.semantic"]="scale",t["loaders_gl.gaussian_splats.component"]=e,t["loaders_gl.gaussian_splats.encoding"]="log";return}let n=lf(r.name,"rot");if(n!==void 0){t["loaders_gl.gaussian_splats.semantic"]="rotation",t["loaders_gl.gaussian_splats.component"]=n,t["loaders_gl.gaussian_splats.encoding"]="quaternion";return}let s=lf(r.name,"f_dc");if(s!==void 0){t["loaders_gl.gaussian_splats.semantic"]="spherical_harmonic_dc",t["loaders_gl.gaussian_splats.component"]=s,t["loaders_gl.gaussian_splats.encoding"]="coefficient";return}let i=lf(r.name,"f_rest");i!==void 0&&(t["loaders_gl.gaussian_splats.semantic"]="spherical_harmonic_rest",t["loaders_gl.gaussian_splats.component"]=i,t["loaders_gl.gaussian_splats.encoding"]="coefficient")}function lf(r,t){return r.match(new RegExp(`^${t}_(\\d+)$`))?.[1]}var uf=d(()=>{"use strict";or()});function vc(r,t,e){let n=y2(t),s=on(n),i=t.indices.length||t.vertices.length/3,o=t.indices&&t.indices.length>0,a=o?4:0,c=o?"triangle-list":"point-list",l=ca(r,n),u={loader:"ply",loaderData:r,header:{vertexCount:i,boundingBox:s??void 0},schema:l,attributes:n,indices:{value:new Uint32Array(0),size:0},mode:a,topology:c};return t.indices.length>0&&(u.indices={value:new Uint32Array(t.indices),size:1}),u}function y2(r){let t={};for(let e of Object.keys(r))switch(e){case"vertices":r.vertices.length>0&&(t.POSITION={value:ff(r.vertices),size:3});break;case"normals":r.normals.length>0&&(t.NORMAL={value:ff(r.normals),size:3});break;case"uvs":r.uvs.length>0&&(t.TEXCOORD_0={value:ff(r.uvs),size:2});break;case"colors":r.colors.length>0&&(t.COLOR_0={value:g2(r.colors),size:3,normalized:!0});break;case"indices":break;default:r[e].length>0&&(t[e]={value:ff(r[e]),size:1});break}return t}function ff(r){return r instanceof Float32Array?r:new Float32Array(r)}function g2(r){return r instanceof Uint8Array?r:new Uint8Array(r)}var Mm=d(()=>{"use strict";or();uf()});function X1(r,t={}){let e,n;return r instanceof ArrayBuffer?(e=Gn(r,t),n=e.format==="ascii"?Z1(new TextDecoder().decode(r),e):T2(r,e,t)):(e=Gn(r,t),n=Z1(r,e)),vc(e,n)}function K1(r,t={}){if(!(r instanceof ArrayBuffer))return null;let e=Gn(r,t);if(e.format==="ascii")return null;let n=rx(r,e,t);return n?ex(e,n):null}function J1(r,t,e={},n){let s=nx(r,t,e,n);return s?ex(t,s):null}function Gn(r,t){let{headerText:e,headerLength:n}=r instanceof ArrayBuffer?b2(r):w2(r),s=e.indexOf("ply"),i=e.lastIndexOf("end_header"),o=i+10;if(s>=0&&i>=s+3&&o<e.length&&/\s/.test(e[o])){let a=e.slice(s+3,i).split(`
|
|
34
|
+
`);return Y1(a,n||o+1-s,t)}return Y1([],n,t)}function b2(r){let t=new Uint8Array(r),e=x2(t);return{headerText:new TextDecoder().decode(t.subarray(0,e)),headerLength:e}}function w2(r){let t=r.indexOf(Fm);if(t===-1)return{headerText:"",headerLength:0};let e=t+Fm.length;return r[e]==="\r"&&r[e+1]===`
|
|
35
|
+
`?e+=2:e<r.length&&/\s/.test(r[e])&&(e+=1),{headerText:r.slice(0,e),headerLength:e}}function x2(r){let t=new TextEncoder().encode(Fm),e=r.length-t.length;for(let n=0;n<=e;n++){let s=!0;for(let i=0;i<t.length;i++)if(r[n+i]!==t[i]){s=!1;break}if(s){let i=n+t.length;return r[i]===13&&r[i+1]===10?i+=2:i<r.length&&A2(r[i])&&(i+=1),i}}return r.length}function A2(r){return r===10||r===13||r===9||r===32}function Y1(r,t,e){let n={comments:[],elements:[],headerLength:t},s,i,o=null;for(let a=0;a<r.length;a++){let c=r[a];if(c=c.trim(),c!=="")switch(i=c.split(/\s+/),s=i.shift(),c=i.join(" "),s){case"format":n.format=i[0],n.version=i[1];break;case"comment":n.comments.push(c);break;case"element":o&&n.elements.push(o),o={name:i[0],count:parseInt(i[1],10),properties:[]};break;case"property":if(o){let l=v2(i);e?.propertyNameMapping&&l.name in e?.propertyNameMapping&&(l.name=e?.propertyNameMapping[l.name]),o.properties.push(l)}break;default:}}return o&&n.elements.push(o),n}function Q1(r){let t={indices:[],vertices:[],normals:[],uvs:[],colors:[]};for(let e of r.elements)if(e.name==="vertex")for(let n of e.properties)switch(n.name){case"x":case"y":case"z":case"nx":case"ny":case"nz":case"s":case"t":case"red":case"green":case"blue":break;default:t[n.name]=[];break}return t}function v2(r){let t=r[0];return t==="list"?{type:t,name:r[3],countType:r[1],itemType:r[2]}:{type:t,name:r[1]}}function Dm(r,t){switch(t){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(r,10);case"float":case"double":case"float32":case"float64":return parseFloat(r);default:throw new Error(t)}}function S2(r,t){let e=t.split(/\s+/),n={};for(let s=0;s<r.length;s++)if(r[s].type==="list"){let i=[],o=Dm(e.shift(),r[s].countType);for(let a=0;a<o;a++)i.push(Dm(e.shift(),r[s].itemType));n[r[s].name]=i}else n[r[s].name]=Dm(e.shift(),r[s].type);return n}function Z1(r,t){let e=Q1(t),n=/end_header\s([\s\S]*)$/,s="",i=n.exec(r);i!==null&&(s=i[1]);let o=s.split(`
|
|
36
|
+
`),a=0,c=0;for(let l=0;l<o.length;l++){let u=o[l];if(u=u.trim(),u!==""){c>=t.elements[a].count&&(a++,c=0);let f=S2(t.elements[a].properties,u);tx(e,t.elements[a].name,f),c++}}return e}function tx(r,t,e={}){if(t==="vertex")for(let n of Object.keys(e))switch(n){case"x":r.vertices.push(e.x,e.y,e.z);break;case"y":case"z":break;case"nx":"nx"in e&&"ny"in e&&"nz"in e&&r.normals.push(e.nx,e.ny,e.nz);break;case"ny":case"nz":break;case"s":"s"in e&&"t"in e&&r.uvs.push(e.s,e.t);break;case"t":break;case"red":"red"in e&&"green"in e&&"blue"in e&&r.colors.push(e.red,e.green,e.blue);break;case"green":case"blue":break;default:r[n].push(e[n])}else if(t==="face"){let n=e.vertex_indices||e.vertex_index;n.length===3?r.indices.push(n[0],n[1],n[2]):n.length===4&&(r.indices.push(n[0],n[1],n[3]),r.indices.push(n[1],n[2],n[3]))}}function Cm(r,t,e,n){switch(e){case"int8":case"char":return[r.getInt8(t),1];case"uint8":case"uchar":return[r.getUint8(t),1];case"int16":case"short":return[r.getInt16(t,n),2];case"uint16":case"ushort":return[r.getUint16(t,n),2];case"int32":case"int":return[r.getInt32(t,n),4];case"uint32":case"uint":return[r.getUint32(t,n),4];case"float32":case"float":return[r.getFloat32(t,n),4];case"float64":case"double":return[r.getFloat64(t,n),8];default:throw new Error(e)}}function I2(r,t,e,n){let s={},i,o=0;for(let a=0;a<e.length;a++)if(e[a].type==="list"){let c=[];i=Cm(r,t+o,e[a].countType,n);let l=i[0];o+=i[1];for(let u=0;u<l;u++)i=Cm(r,t+o,e[a].itemType,n),c.push(i[0]),o+=i[1];s[e[a].name]=c}else i=Cm(r,t+o,e[a].type,n),s[e[a].name]=i[0],o+=i[1];return[s,o]}function ex(r,t){let e=B2(t),n=ca(r,e);n.metadata.topology="point-list",n.metadata.mode="0";let s={},i=[];for(let a of n.fields){let c=e[a.name];if(!c)continue;let l=_2(c);s[a.name]=l,i.push(new S(a.name,l.type,!1,H1(a.metadata)))}let o=new G(i,H1(n.metadata));return{shape:"arrow-table",schema:n,data:new st(o,s),topology:"point-list"}}function B2(r){let t={};for(let e of Object.keys(r))switch(e){case"vertices":r.vertices.length>0&&(t.POSITION={value:hf(r.vertices),size:3});break;case"normals":r.normals.length>0&&(t.NORMAL={value:hf(r.normals),size:3});break;case"uvs":r.uvs.length>0&&(t.TEXCOORD_0={value:hf(r.uvs),size:2});break;case"colors":r.colors.length>0&&(t.COLOR_0={value:L2(r.colors),size:3,normalized:!0});break;case"indices":break;default:r[e].length>0&&(t[e]={value:hf(r[e]),size:1});break}return t}function _2(r){let{value:t,size:e}=r;if(e===1)return te(t);let s=te(t).data[0],i=new gt(e,new S("value",s.type,!1)),o=new D(i,0,t.length/e,0,{},[s]);return new v([o])}function H1(r){return new Map(Object.entries(r||{}))}function hf(r){return r instanceof Float32Array?r:new Float32Array(r)}function L2(r){return r instanceof Uint8Array?r:new Uint8Array(r)}function T2(r,t,e){let n=rx(r,t,e);if(n)return n;let s=Q1(t),i=t.format==="binary_little_endian",o=new DataView(r,t.headerLength),a,c=0;for(let l=0;l<t.elements.length;l++){let u=t.elements[l].count;for(let f=0;f<u;f++){a=I2(o,c,t.elements[l].properties,i),c+=a[1];let h=a[0];tx(s,t.elements[l].name,h)}}return s}function rx(r,t,e){let n=new Uint8Array(r,t.headerLength||0);return nx(n,t,e)}function nx(r,t,e,n){let s=t.elements[0];if(!n&&(e?._useLegacyBinaryPointCloudParser||!e?.pointCloud&&t.elements.length!==1||s?.name!=="vertex"||s.properties.some(l=>l.type==="list")))return null;let i=n||Em(t,e);if(!i||!s)return null;let o=M2(s),a=new DataView(r.buffer,r.byteOffset,r.byteLength),c=0;for(let l=0;l<s.count;l++){for(let u of i.properties){let f=u.read(a,c+u.offset,i.littleEndian);C2(o,u.name,f,l)}c+=i.vertexStride}return o}function Em(r,t){let e=r.elements[0];if(t?._useLegacyBinaryPointCloudParser||!t?.pointCloud&&r.elements.length!==1||e?.name!=="vertex"||e.properties.some(s=>s.type==="list"))return null;let n=F2(e);return{properties:n,vertexStride:E2(n),littleEndian:r.format==="binary_little_endian"}}function M2(r){let t={indices:[],vertices:[],normals:[],uvs:[],colors:[]},e=new Set(r.properties.map(s=>s.name)),n=r.count;e.has("x")&&e.has("y")&&e.has("z")&&(t.vertices=new Float32Array(n*3)),e.has("nx")&&e.has("ny")&&e.has("nz")&&(t.normals=new Float32Array(n*3)),e.has("s")&&e.has("t")&&(t.uvs=new Float32Array(n*2)),e.has("red")&&e.has("green")&&e.has("blue")&&(t.colors=new Uint8Array(n*3));for(let s of r.properties)D2(s.name)||(t[s.name]=new Float32Array(n));return t}function D2(r){switch(r){case"x":case"y":case"z":case"nx":case"ny":case"nz":case"s":case"t":case"red":case"green":case"blue":return!0;default:return!1}}function C2(r,t,e,n){switch(t){case"x":r.vertices[n*3]=e;break;case"y":r.vertices[n*3+1]=e;break;case"z":r.vertices[n*3+2]=e;break;case"nx":r.normals[n*3]=e;break;case"ny":r.normals[n*3+1]=e;break;case"nz":r.normals[n*3+2]=e;break;case"s":r.uvs[n*2]=e;break;case"t":r.uvs[n*2+1]=e;break;case"red":r.colors[n*3]=e;break;case"green":r.colors[n*3+1]=e;break;case"blue":r.colors[n*3+2]=e;break;default:r[t][n]=e}}function F2(r){let t=[],e=0;for(let n of r.properties)t.push({name:n.name,offset:e,read:N2(n.type),size:O2(n.type)}),e+=t[t.length-1].size;return t}function E2(r){if(r.length===0)return 0;let t=r[r.length-1];return t.offset+t.size}function O2(r){switch(r){case"int8":case"uint8":case"char":case"uchar":return 1;case"int16":case"uint16":case"short":case"ushort":return 2;case"int32":case"uint32":case"int":case"uint":case"float32":case"float":return 4;case"float64":case"double":return 8;default:throw new Error(r)}}function N2(r){switch(r){case"int8":case"char":return U2;case"uint8":case"uchar":return R2;case"int16":case"short":return P2;case"uint16":case"ushort":return k2;case"int32":case"int":return z2;case"uint32":case"uint":return V2;case"float32":case"float":return G2;case"float64":case"double":return $2;default:throw new Error(r)}}function U2(r,t){return r.getInt8(t)}function R2(r,t){return r.getUint8(t)}function P2(r,t,e){return r.getInt16(t,e)}function k2(r,t,e){return r.getUint16(t,e)}function z2(r,t,e){return r.getInt32(t,e)}function V2(r,t,e){return r.getUint32(t,e)}function G2(r,t,e){return r.getFloat32(t,e)}function $2(r,t,e){return r.getFloat64(t,e)}var Fm,df=d(()=>{"use strict";Gr();Mm();uf();Fm="end_header"});function Sc(r,t={}){let e=Gn(r,t),n=t.pointCloud?Z2(e):e;if(e.format==="ascii"){let s=r instanceof ArrayBuffer?new TextDecoder().decode(r):r;return W2(s,n)}if(!(r instanceof ArrayBuffer))throw new Error("Binary PLY parsing requires an ArrayBuffer.");return Y2(r,n)}function Ic(r){let t=q2(r);return tL(t)}function q2(r){let t=J2(r),e=Q2(r),n=on(t),s=t.POSITION?.value.length?t.POSITION.value.length/3:0,i=!!e?.value.length,o=i?4:0,a=i?"triangle-list":"point-list",c=ca(r.header,t);return{loader:"ply",loaderData:r.header,header:{vertexCount:s,boundingBox:n??void 0},schema:c,attributes:t,indices:e||{value:new Uint32Array(0),size:0},mode:o,topology:a}}function W2(r,t){let e=sx(t),s=oL(r).split(`
|
|
37
|
+
`),i=0,o=0;for(let a of s){let c=a.trim();if(c!==""){for(;i<t.elements.length&&o>=t.elements[i].count;)i++,o=0;if(i>=t.elements.length)break;H2(e[i],c),o++}}return{header:t,elements:e.map(ix)}}function Y2(r,t){let e=sx(t),n=new DataView(r,t.headerLength||0),s=t.format!=="binary_big_endian",i=0;for(let o=0;o<t.elements.length;o++){let a=t.elements[o];for(let c=0;c<a.count;c++)i+=X2(e[o],n,i,s)}return{header:t,elements:e.map(ix)}}function Z2(r){let t=r.elements[0];if(t?.name!=="vertex")throw new Error("PLY pointCloud parsing requires a leading vertex element");return{...r,elements:[t]}}function sx(r){return r.elements.map(t=>({element:t,properties:t.properties.map(e=>({property:e,values:[],offsets:e.type==="list"?[0]:void 0}))}))}function H2(r,t){let e=t.split(/\s+/),n=0;for(let s of r.properties){let i=s.property;if(i.type==="list"){let o=Om(e[n++],i.countType);for(let a=0;a<o;a++)s.values.push(Om(e[n++],i.itemType));s.offsets.push(s.values.length)}else s.values.push(Om(e[n++],i.type))}}function X2(r,t,e,n){let s=0;for(let i of r.properties){let o=i.property;if(o.type==="list"){let[a,c]=Nm(t,e+s,o.countType,n);s+=c;for(let l=0;l<a;l++){let[u,f]=Nm(t,e+s,o.itemType,n);i.values.push(u),s+=f}i.offsets.push(i.values.length)}else{let[a,c]=Nm(t,e+s,o.type,n);i.values.push(a),s+=c}}return s}function ix(r){let t=[],e={};for(let n of r.properties){let s=K2(n);e[n.property.name]=s,t.push(new S(n.property.name,s.type,!1))}return{element:r.element,table:new st(new G(t),e)}}function K2(r){let t=r.property;return t.type==="list"?aL(t.itemType,r.values,Int32Array.from(r.offsets||[0])):te(ax(r.values,t.type))}function J2(r){let t=ox(r,"vertex"),e={};if(!t)return e;let n=pf(t.table,["x","y","z"],"float");n&&(e.POSITION=n);let s=pf(t.table,["nx","ny","nz"],"float");s&&(e.NORMAL=s);let i=pf(t.table,["s","t"],"float");i&&(e.TEXCOORD_0=i);let o=pf(t.table,["red","green","blue"],"uchar");o&&(e.COLOR_0={...o,normalized:!0});let a=new Set(["x","y","z","nx","ny","nz","s","t","red","green","blue"]);for(let c of t.element.properties){if(c.type==="list"||a.has(c.name))continue;let l=t.table.getChild(c.name);l&&(e[c.name]={value:iL(l),size:1})}return e}function Q2(r){let t=ox(r,"face"),e=t?.table.getChild("vertex_indices")||t?.table.getChild("vertex_index");if(!e)return;let n=[];for(let s=0;s<e.length;s++){let i=e.get(s);i&&(i.length===3?n.push($n(i,0),$n(i,1),$n(i,2)):i.length===4&&(n.push($n(i,0),$n(i,1),$n(i,3)),n.push($n(i,1),$n(i,2),$n(i,3))))}return n.length>0?{value:new Uint32Array(n),size:1}:void 0}function $n(r,t){return"get"in r&&typeof r.get=="function"?Number(r.get(t)):Number(r[t])}function tL(r){let t=[],e={},n=sL(r.attributes);for(let o of n){let a=r.attributes[o],c=eL(a);if(e[o]=c,t.push(rL(r,o,c)),o==="POSITION"&&r.indices?.value.length){let l=nL(r.indices.value,c.length);e.indices=l,t.push(new S("indices",l.type,!0))}}let s=cx({...r.schema.metadata,topology:r.topology,mode:String(r.mode),boundingBox:r.header?.boundingBox?JSON.stringify(r.header.boundingBox):void 0}),i=new G(t,s);return{shape:"arrow-table",schema:r.schema,data:new st(i,e),topology:r.topology,indices:r.indices?.value.length?r.indices:void 0}}function eL(r){let{value:t,size:e}=r;if(e===1)return te(t);let s=te(t).data[0],i=new gt(e,new S("value",s.type,!1)),o=new D(i,0,t.length/e,0,{},[s]);return new v([o])}function rL(r,t,e){let n=r.schema.fields.find(s=>s.name===t);return new S(t,e.type,!1,cx(n?.metadata))}function nL(r,t){let e=r instanceof Uint32Array?r:Uint32Array.from(r),n=new Int32Array(t+1);t>0&&n.fill(e.length,1);let s=new Uint8Array(Math.ceil(t/8));t>0&&(s[0]=1);let i=new Ct(new S("item",new jt,!1)),o=new D(i.children[0].type,0,e.length,0,{[Z.DATA]:e}),a=new D(i,0,t,Math.max(0,t-1),{[Z.OFFSET]:n,[Z.VALIDITY]:s},[o]);return new v([a])}function pf(r,t,e){let n=t.map(o=>r.getChild(o));if(n.some(o=>!o))return null;let s=r.numRows,i=e==="uchar"?new Uint8Array(s*t.length):new Float32Array(s*t.length);for(let o=0;o<s;o++)for(let a=0;a<n.length;a++)i[o*n.length+a]=Number(n[a].get(o)??0);return{value:i,size:t.length}}function ox(r,t){return r.elements.find(e=>e.element.name===t)}function sL(r){let t=["POSITION","indices"];return[...t.filter(e=>e in r),...Object.keys(r).filter(e=>!t.includes(e))]}function iL(r){return r.data[0].values}function oL(r){let t=j2.exec(r);return t?r.slice(t.index+t[0].length):""}function aL(r,t,e){let n=cL(r),s=new Ct(new S("item",n,!1)),i=ax(t,r),o=new D(n,0,i.length,0,{[Z.DATA]:i}),a=new D(s,0,e.length-1,0,{[Z.OFFSET]:e},[o]);return new v([a])}function ax(r,t){switch(t){case"int8":case"char":return Int8Array.from(r);case"uint8":case"uchar":return Uint8Array.from(r);case"int16":case"short":return Int16Array.from(r);case"uint16":case"ushort":return Uint16Array.from(r);case"int32":case"int":return Int32Array.from(r);case"uint32":case"uint":return Uint32Array.from(r);case"float64":case"double":return Float64Array.from(r);default:return Float32Array.from(r)}}function cL(r){switch(r){case"int8":case"char":return new ve;case"uint8":case"uchar":return new Ie;case"int16":case"short":return new Se;case"uint16":case"ushort":return new Be;case"int32":case"int":return new Dt;case"uint32":case"uint":return new jt;case"float64":case"double":return new _e;default:return new Xt}}function Om(r,t){switch(t){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(r,10);case"float":case"double":case"float32":case"float64":return parseFloat(r);default:throw new Error(t)}}function Nm(r,t,e,n){switch(e){case"int8":case"char":return[r.getInt8(t),1];case"uint8":case"uchar":return[r.getUint8(t),1];case"int16":case"short":return[r.getInt16(t,n),2];case"uint16":case"ushort":return[r.getUint16(t,n),2];case"int32":case"int":return[r.getInt32(t,n),4];case"uint32":case"uint":return[r.getUint32(t,n),4];case"float32":case"float":return[r.getFloat32(t,n),4];case"float64":case"double":return[r.getFloat64(t,n),8];default:throw new Error(e)}}function cx(r){return new Map(Object.entries(r||{}).filter(t=>t[1]!==void 0))}var j2,Um=d(()=>{"use strict";or();Gr();df();uf();j2=/end_header\s/});async function*hx(r,t){if(t?.shape==="arrow-table"){yield*fL(r,t);return}let e=Su(vu(Iu(r))),n=await SL(e,t),s;if(n.format==="ascii")s=await BL(e,n);else throw new Error("Binary PLY can not yet be parsed in streaming mode");yield vc(n,s,t)}async function*fL(r,t){let e=Iu(r)[Symbol.asyncIterator](),{header:n,initialBodyBytes:s}=await mL(e,t),i;n.format==="ascii"?i=dL(e,n,s,t):i=Pm(n,t).properties.some(a=>a.type==="list")?pL(e,n,s,t):hL(e,n,s,t);for await(let o of i)yield{...o,loaderData:n}}async function*hL(r,t,e,n){let s=yL(t,n),i=km(n),o=xL(s),a=Em(t,n),c=s.count,l=e;for(;;){for(;c>0&&Math.floor(l.length/o)>=i;){let h=Math.min(i,c),m=lx(t,l,h,o,n,a);l=l.subarray(h*o),c-=h,yield m}if(n?.pointCloud&&c<=0)return;let{value:u,done:f}=await r.next();if(f)break;l=zm([l,gf(u)])}if(c>0){let u=Math.min(c,Math.floor(l.length/o));u>0&&(yield lx(t,l,u,o,n,a))}}async function*dL(r,t,e,n){let s=Pm(t,n),i=km(n),o=Su(vu(wL(r,e))),a=[],c=s.count;for await(let l of o){let u=l.trim();if(u!==""&&(a.push(u),c--,a.length>=i&&(yield ux(t,a,n),a=[]),c<=0))break}a.length>0&&(yield ux(t,a,n))}async function*pL(r,t,e,n){let s=Pm(t,n),i=km(n),o=t.format!=="binary_big_endian",a=s.count,c=e,l=[],u=0,f=0;for(;a>0;){let h=gL(c,s,o);if(h===null){let{value:y,done:g}=await r.next();if(g)break;c=zm([c,gf(y)]);continue}let m=c.subarray(0,h);l.push(m),u+=h,f++,a--,c=c.subarray(h),f>=i&&(yield fx(t,l,u,f,n),l=[],u=0,f=0)}f>0&&(yield fx(t,l,u,f,n))}async function mL(r,t){let e=new Uint8Array(0);for(;;){let{value:n,done:s}=await r.next();if(s)throw new Error("Incomplete PLY header");e=zm([e,gf(n)]);let i=AL(e);if(i===-1)continue;return{header:Gn(yf(e.subarray(0,i)),t),initialBodyBytes:e.subarray(i)}}}function Pm(r,t){let e=r.elements[0];if(!t?.pointCloud&&r.elements.length!==1||e?.name!=="vertex")throw new Error("PLY arrow-table batch parsing requires one vertex element");return e}function yL(r,t){let e=r.elements[0];if(!t?.pointCloud&&r.elements.length!==1||e?.name!=="vertex"||e.properties.some(n=>n.type==="list"))throw new Error("Binary PLY arrow-table batch parsing requires one scalar vertex element");return e}function lx(r,t,e,n,s,i){let o=r.elements[0],a={...r,headerLength:0,elements:[{...o,count:e}]},c=e*n,l=J1(t.subarray(0,c),a,s,i||void 0);if(!l)throw new Error("Failed to parse binary PLY Arrow batch");return l}function ux(r,t,e){let n=dx(r,t.length,e),s=Sc(`${n}${t.join(`
|
|
38
38
|
`)}
|
|
39
|
-
`,e);return
|
|
39
|
+
`,e);return Ic(s)}function fx(r,t,e,n,s){let i=dx(r,n,s),o=new TextEncoder().encode(i),a=new Uint8Array(o.length+e);a.set(o,0);let c=o.length;for(let u of t)a.set(u,c),c+=u.length;let l=Sc(yf(a),s);return Ic(l)}function gL(r,t,e){let n=new DataView(r.buffer,r.byteOffset,r.byteLength),s=0;for(let i of t.properties)if(i.type==="list"){let o=mf(i.countType);if(s+o>r.length)return null;let a=bL(n,s,i.countType,e);s+=o;let c=a*mf(i.itemType);if(s+c>r.length)return null;s+=c}else{let o=mf(i.type);if(s+o>r.length)return null;s+=o}return s}function bL(r,t,e,n){switch(e){case"int8":case"char":return r.getInt8(t);case"uint8":case"uchar":return r.getUint8(t);case"int16":case"short":return r.getInt16(t,n);case"uint16":case"ushort":return r.getUint16(t,n);case"int32":case"int":return r.getInt32(t,n);case"uint32":case"uint":return r.getUint32(t,n);case"float32":case"float":return r.getFloat32(t,n);case"float64":case"double":return r.getFloat64(t,n);default:throw new Error(e)}}function dx(r,t,e){let n=["ply",`format ${r.format} ${r.version||"1.0"}`],s=e?.pointCloud?r.elements.slice(0,1):r.elements;for(let i of r.comments)n.push(`comment ${i}`);for(let i of s){n.push(`element ${i.name} ${i.name==="vertex"?t:i.count}`);for(let o of i.properties)n.push(o.type==="list"?`property list ${o.countType} ${o.itemType} ${o.name}`:`property ${o.type} ${o.name}`)}return n.push("end_header"),`${n.join(`
|
|
40
40
|
`)}
|
|
41
|
-
`}async function*a_(r,t){for(t.length>0&&(yield qu(t));;){let{value:e,done:n}=await r.next();if(n)break;yield qu($u(e))}}function Kp(r){let t=r?.batchSize;return typeof t=="number"?t:KB}function c_(r){return r.properties.reduce((t,e)=>t+ju(e.type),0)}function ju(r){switch(r){case"int8":case"uint8":case"char":case"uchar":return 1;case"int16":case"uint16":case"short":case"ushort":return 2;case"int32":case"uint32":case"int":case"uint":case"float32":case"float":return 4;case"float64":case"double":return 8;default:throw new Error(r)}}function l_(r){let t=new TextEncoder().encode(JB),e=r.length-t.length;for(let n=0;n<=e;n++){let s=!0;for(let i=0;i<t.length;i++)if(r[n+i]!==t[i]){s=!1;break}if(s){let i=n+t.length;return i===r.length||r[i]===13&&i+1===r.length?-1:(r[i]===13&&r[i+1]===10?i+=2:i<r.length&&u_(r[i])&&(i+=1),i)}}return-1}function u_(r){return r===10||r===13||r===9||r===32}function $u(r){return ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r)}function qu(r){let t=new Uint8Array(r.byteLength);return t.set(r),t.buffer}function Jp(r){let t=r.reduce((s,i)=>s+i.length,0),e=new Uint8Array(t),n=0;for(let s of r)e.set(s,n),n+=s.length;return e}async function f_(r,t){let e,n={comments:[],elements:[]};return await vd(r,s=>{if(s=s.trim(),s==="end_header")return!0;if(s==="")return!1;let i=s.split(/\s+/),o=i.shift();switch(s=i.join(" "),o){case"ply":break;case"format":n.format=i[0],n.version=i[1];break;case"comment":n.comments.push(s);break;case"element":e&&n.elements.push(e),e={name:i[0],count:parseInt(i[1],10),properties:[]};break;case"property":let a=h_(i,t.propertyNameMapping);e?.properties.push(a);break;default:console.log("unhandled",o,i)}return!1}),e&&n.elements.push(e),n}function h_(r,t){let e=r[0];return e==="list"?{type:e,name:r[3],countType:r[1],itemType:r[2]}:{type:e,name:r[1]}}async function d_(r,t){let e={indices:[],vertices:[],normals:[],uvs:[],colors:[]},n=0,s=0;for await(let i of r)if(i=i.trim(),i!==""){s>=t.elements[n].count&&(n++,s=0);let o=p_(t.elements[n].properties,i);m_(e,t.elements[n].name,o),s++}return e}function Hp(r,t){switch(t){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(r,10);case"float":case"double":case"float32":case"float64":return parseFloat(r);default:throw new Error(t)}}function p_(r,t){let e=t.split(/\s+/),n={};for(let s=0;s<r.length;s++)if(r[s].type==="list"){let i=[],o=Hp(e.shift(),r[s].countType);for(let a=0;a<o;a++)i.push(Hp(e.shift(),r[s].itemType));n[r[s].name]=i}else n[r[s].name]=Hp(e.shift(),r[s].type);return n}function m_(r,t,e={}){switch(t){case"vertex":r.vertices.push(e.x,e.y,e.z),"nx"in e&&"ny"in e&&"nz"in e&&r.normals.push(e.nx,e.ny,e.nz),"s"in e&&"t"in e&&r.uvs.push(e.s,e.t),"red"in e&&"green"in e&&"blue"in e&&r.colors.push(e.red,e.green,e.blue);break;case"face":let n=e.vertex_indices||e.vertex_index;n.length===3?r.indices.push(n[0],n[1],n[2]):n.length===4&&(r.indices.push(n[0],n[1],n[3]),r.indices.push(n[1],n[2],n[3]));break;default:break}}var KB,JB,m1=p(()=>{"use strict";Yo();Vp();Vu();Zp();KB=65536,JB="end_header"});var y1,g1=p(()=>{"use strict";y1={name:"PLY",id:"ply",module:"pointclouds",encoding:"text",format:"ply",extensions:["ply"],mimeTypes:["text/plain","application/octet-stream"],text:!0,binary:!0,tests:["ply"]}});async function g_(){let{PLYLoaderWithParser:r}=await Promise.resolve().then(()=>(tm(),Qp));return r}var y_,b1,w1=p(()=>{"use strict";g1();Gs();y_="5.0.0-beta.7";b1={dataType:null,batchType:null,...y1,version:y_,worker:!0,workerInBatches:!0,serializeWorkerResult:re,options:{ply:{shape:"arrow-table",colorFormat:"uint8norm"}},preload:g_}});function x1(r,t){let e=Ee(r,"arrow-table");return Wu(e,t,r.loaderData)}function em(r,t){if(t?.ply?._useLegacyParser)return x1(Kw(r,t?.ply),t);let e=Jw(r,t?.ply);if(e)return Wu(e,t,zn(r,t?.ply));let n=cc(r,t?.ply);return Wu(lc(n),t,n.header)}function Wu(r,t,e){let n=e||r.loaderData||{comments:[],elements:[]},s=t?.ply?.shape==="arrow-table"?{...r,loader:"ply",loaderData:n}:{...ee(r),loader:"ply",loaderData:n},i=t?.ply?.colorFormat||"uint8norm";if(i==="uint8norm")return s;let o=s,a=x_(rm(o)?ee(o):o,i);return t?.ply?.shape==="arrow-table"?{...Ee(a,"arrow-table"),loader:"ply",loaderData:n}:a}function x_(r,t){let e=r.attributes.COLOR_0;if(!e)return r;let n=e.value instanceof Uint16Array?65535:255,s=t==="float16"?ti(e.value,n):na(e.value,n),i={...r.attributes};for(let[o,a]of Object.entries(i))a.value===e.value&&(i[o]={...a,value:s,normalized:!1,...t==="float16"?{componentType:"float16"}:{}});return{...r,attributes:i,schema:Gi(i,r.schema.metadata)}}function rm(r){return"shape"in r&&r.shape==="arrow-table"}function v1(r,t){let e=Ro(r);return t?.ply?.shape==="mesh"?{...ee(e),loader:"ply",loaderData:e.loaderData}:e}function v_(r,t){return v1(r,t)}var l8,b_,w_,A1=p(()=>{"use strict";Yo();Vs();Gs();or();Vu();Zp();m1();w1();({preload:l8,...b_}=b1);w_={...b_,parse:async(r,t)=>em(r,t),parseTextSync:(r,t)=>em(r,t),parseSync:(r,t)=>em(r,t),parseInBatches:async function*(r,t){let e={...t?.ply,batchSize:t?.batchSize??t?.core?.batchSize};for await(let n of d1(r,e)){let s=rm(n)?Wu(n,t):x1(n,t);yield rm(s)?sc(s):s}},serializeWorkerResult:re,deserializeWorkerResult:v1,serializeWorkerBatch:re,deserializeWorkerBatch:v_}});var Qp={};Re(Qp,{PLYLoaderWithParser:()=>w_});var tm=p(()=>{"use strict";A1()});var D_={};Re(D_,{LASFormat:()=>No,LASLoader:()=>Lp,LASWorkerLoader:()=>xw,LASWriter:()=>Iw,PCDFormat:()=>Jo,PCDLoader:()=>kp,PCDWorkerLoader:()=>qw,PCDWriter:()=>Ww,PLYFormat:()=>ta,PLYLoader:()=>nm,PLYWorkerLoader:()=>S1,PLYWriter:()=>B1});var No={name:"LAS",id:"las",module:"pointclouds",encoding:"binary",format:"las",extensions:["las","laz"],mimeTypes:["application/octet-stream"],text:!1,binary:!0,tests:["LASF"]};var hA=typeof __VERSION__<"u"?__VERSION__:"latest",dA="arrow-table";var Sg={...No,dataType:null,batchType:null,version:hA,worker:!1,options:{las:{shape:dA,fp64:!1,colorDepth:8,colorFormat:"uint8norm",columns:void 0,extraBytes:"raw",recoverMissingChunkTable:!1,compatibilityMode:"auto"}}};async function ZI(){let{LASLoaderWithParser:r}=await Promise.resolve().then(()=>(ww(),bw));return r}var Lp={...Sg,worker:!0,workerInBatches:!0,preload:ZI},xw=Lp;Yo();or();var HI=typeof __VERSION__<"u"?__VERSION__:"latest",XI=227,KI=375,JI=393,Uu=54,Cp=192,QI=5e4,t2=4294967295,Fp=15,e2={0:20,1:28,2:26,3:34,4:57,5:63,6:30,7:36,8:38,9:59,10:67},Iw={...No,dataType:null,batchType:null,version:HI,extensions:["las","laz"],options:{las:{}},encode:async(r,t)=>Tp(r,t),encodeSync:Tp,encodeInBatches:async function*(r,t){let e=[];for await(let n of r)e.push(n);yield Tp(p2(e),t)}};function Tp(r,t={}){let e=t.las?.format||"las",n=t.las?.colorDepth;if(n!==void 0&&n!=="auto"&&n!==8&&n!==16)throw new Error("LASWriter: invalid source color depth");let s=h2(r),i=Lw(s,"POSITION");y2(i);let o=i.value.length/i.size;b2(s,o);let a=s.attributes.COLOR_0,c=s.attributes.intensity,l=s.attributes.classification,u=s.attributes.nir,f=i2(s,t,o),h=s.attributes.gpsTime,m=s.attributes.scanAngle,y=s.attributes.userData,g=s.attributes.pointSourceId,x=s.attributes.returnNumber,I=s.attributes.numberOfReturns,q=s.attributes.scannerChannel,T=s.attributes.scanDirectionFlag,b=s.attributes.edgeOfFlightLine,C=s.attributes.synthetic,_=s.attributes.keyPoint,$=s.attributes.withheld,X=s.attributes.overlap,ft=s.attributes.wavePacketDescriptorIndex,dt=s.attributes.wavePacketOffset,It=s.attributes.wavePacketSize,se=s.attributes.wavePacketReturnPoint,rt=s.attributes.wavePacketVector,tt=C2(i,o),Ye=T2(x,o),Ne=F2(s,t),Ze=O2(s,t,tt);g2(i,o,Ne,Ze);let xt=t.las?.pointDataRecordFormat??B2(t,a);w2(s,o,xt);let Gn=e2[xt];if(!Gn)throw new Error(`LASWriter: unsupported point data record format ${xt}`);let Qs=Gn+f.reduce((fn,ro)=>fn+ro.byteLength,0);if(Qs>65535)throw new Error(`LASWriter: point data record length ${Qs} exceeds the LAS limit`);u2(f);let wt=t.las?.version||(xt>=6?"1.4":"1.2"),pt=wt==="1.5"?JI:wt==="1.4"?KI:XI;n2(wt,xt,t);let ln=l2(h,o);if(wt==="1.5"&&t.las?.timeOffset&&!h)throw new Error("LASWriter: LAS 1.5 timeOffset requires a GPS time attribute");e==="laz"&&f2(wt,xt,t.las?.chunkSize),r2(wt,xt);let $r=new Uint8Array(o*Qs),un=new DataView($r.buffer);for(let fn=0;fn<o;fn++){let ro=fn*Qs;un.setInt32(ro,Math.round((qr(i,fn,0)-Ze[0])/Ne[0]),!0),un.setInt32(ro+4,Math.round((qr(i,fn,1)-Ze[1])/Ne[1]),!0),un.setInt32(ro+8,Math.round((qr(i,fn,2)-Ze[2])/Ne[2]),!0),x2(un,ro,fn,xt,Gn,{intensityAttribute:c,classificationAttribute:l,nirAttribute:u,colorAttribute:a,colorDepth:n,gpsTimeAttribute:h,scanAngleAttribute:m,userDataAttribute:y,pointSourceIdAttribute:g,returnNumberAttribute:x,numberOfReturnsAttribute:I,scannerChannelAttribute:q,scanDirectionFlagAttribute:T,edgeOfFlightLineAttribute:b,syntheticAttribute:C,keyPointAttribute:_,withheldAttribute:$,overlapAttribute:X,waveformDescriptorAttribute:ft,waveformOffsetAttribute:dt,waveformSizeAttribute:It,waveformReturnPointAttribute:se,waveformVectorAttribute:rt,extraByteFields:f})}let Ar={vertexCount:o,boundingBox:tt,scale:Ne,offset:Ze,version:wt,headerLength:pt,pointDataRecordFormat:xt,pointDataRecordLength:Qs,returnCounts:Ye,maxGpsTime:ln.maximum,minGpsTime:ln.minimum,timeOffset:t.las?.timeOffset||0,hasGpsTime:!!h,hasWkt:!!t.las?.wkt};if(e==="laz")return s2($r,Ar,t.las?.chunkSize,t.las?.variableChunkTable,f,t);let Sr=Bw(f,t),eo=pt+Sr.byteLength,Yu=new ArrayBuffer(eo+$r.byteLength);Mw(new DataView(Yu),{...Ar,pointDataOffset:eo,vlrCount:_w(f,t)});let im=new Uint8Array(Yu);return im.set(Sr,pt),im.set($r,eo),Yu}function r2(r,t){let n={0:"1.0",1:"1.1",2:"1.2",3:"1.2"}[t];if(n&&r<n)throw new Error(`LASWriter: point data record format ${t} requires LAS ${n} or newer; received ${r}`);if(t>=4&&t<=5&&!["1.3","1.4","1.5"].includes(r))throw new Error(`LASWriter: point data record format ${t} requires LAS 1.3; received ${r}`);if(t>=6&&!["1.4","1.5"].includes(r))throw new Error(`LASWriter: point data record format ${t} requires LAS 1.4; received ${r}`)}function n2(r,t,e){if(r==="1.5"){if(t<6||t>10)throw new Error("LASWriter: LAS 1.5 output requires point data record format 6-10");if(!e.las?.wkt?.trim())throw new Error("LASWriter: LAS 1.5 output requires las.wkt");let n=e.las?.timeOffset??0;if(!Number.isInteger(n)||n<0||n>65535)throw new Error("LASWriter: LAS 1.5 timeOffset must be an unsigned 16-bit integer")}}function s2(r,t,e,n=!1,s=[],i={}){let o=e||QI,a=up({pointDataRecordFormat:t.pointDataRecordFormat,pointDataRecordLength:t.pointDataRecordLength,chunkSize:n?t2:o}),c=Bw(s,i),l=t.headerLength+c.byteLength+a.byteLength,u=[],f=[];for(let T=0;T<t.vertexCount;T+=o){let b=Math.min(o,t.vertexCount-T),C=T*t.pointDataRecordLength,_=cp(r.subarray(C,C+b*t.pointDataRecordLength),{pointDataRecordFormat:t.pointDataRecordFormat,pointDataRecordLength:t.pointDataRecordLength,pointCount:b,point14ItemVersion:3,rgb14ItemVersion:3,byte14ItemVersion:3});u.push(_),f.push({pointCount:b,byteLength:_.byteLength})}let h=u.reduce((T,b)=>T+b.byteLength,0),m=lp(f,{variable:n}),y=l+8+h,g=new ArrayBuffer(y+8+m.byteLength),x=new Uint8Array(g),I=new DataView(g);Mw(I,{...t,pointDataOffset:l,vlrCount:_w(s,i)+1,compressed:!0}),x.set(c,t.headerLength),x.set(a,t.headerLength+c.byteLength),Op(I,l,y);let q=l+8;for(let T of u)x.set(T,q),q+=T.byteLength;return I.setUint32(y,0,!0),I.setUint32(y+4,f.length,!0),x.set(m,y+8),g}function i2(r,t,e){let n=t.las?.extraBytes||[],s=new Set;return n.map(i=>{if(s.has(i.attribute))throw new Error(`LASWriter: duplicate Extra Bytes attribute ${i.attribute}`);s.add(i.attribute);let o=r.attributes[i.attribute];if(!o)throw new Error(`LASWriter: Extra Bytes attribute ${i.attribute} is missing`);if(![1,3].includes(o.size))throw new Error(`LASWriter: Extra Bytes attribute ${i.attribute} must have size 1 or 3`);if(o.value.length<e*o.size)throw new Error(`LASWriter: Extra Bytes attribute ${i.attribute} is too short`);Tw(i.attribute,o);let a=o2(o.value,o.size);return{...i,meshAttribute:o,dataType:a,byteLength:a2(a,o.size),componentCount:o.size}})}function o2(r,t){let e=0;if(r instanceof Uint8Array?e=1:r instanceof Int8Array?e=2:r instanceof Uint16Array?e=3:r instanceof Int16Array?e=4:r instanceof Uint32Array?e=5:r instanceof Int32Array?e=6:r instanceof BigUint64Array?e=7:r instanceof BigInt64Array?e=8:r instanceof Float32Array?e=9:r instanceof Float64Array&&(e=10),e)return e+(t===3?20:0);throw new Error("LASWriter: Extra Bytes attributes require a supported typed array")}function a2(r,t){let e=r>20?r-20:r>10?r-10:r;return(e<=2?1:e<=4?2:e<=6||e===9?4:8)*t}function c2(r){if(r.length===0)return new Uint8Array(0);let t=new Uint8Array(r.length*Cp),e=new DataView(t.buffer),n=0;for(let o of r)e.setUint8(n+2,o.dataType),kn(e,n+4,o.name||o.attribute,32),kn(e,n+160,o.description||"",32),n+=Cp;let s=new Uint8Array(Uu+t.byteLength),i=new DataView(s.buffer);return kn(i,2,"LASF_Spec",16),i.setUint16(18,4,!0),i.setUint16(20,t.byteLength,!0),kn(i,22,"Extra Bytes",32),s.set(t,Uu),s}function Bw(r,t){let e=[];t.las?.wktMathTransform&&e.push(vw(2111,"WKT Math Transform",t.las.wktMathTransform)),t.las?.wkt&&e.push(vw(2112,"WKT Coordinate System",t.las.wkt));let n=c2(r);n.byteLength&&e.push(n);let s=e.reduce((a,c)=>a+c.byteLength,0),i=new Uint8Array(s),o=0;for(let a of e)i.set(a,o),o+=a.byteLength;return i}function vw(r,t,e){let n=new TextEncoder().encode(`${e}\0`);if(n.byteLength>65535)throw new Error(`LASWriter: WKT VLR ${r} exceeds the LAS VLR size limit`);let s=new Uint8Array(Uu+n.byteLength),i=new DataView(s.buffer);return kn(i,2,"LASF_Projection",16),i.setUint16(18,r,!0),i.setUint16(20,n.byteLength,!0),kn(i,22,t,32),s.set(n,Uu),s}function _w(r,t){return(t.las?.wktMathTransform?1:0)+(t.las?.wkt?1:0)+(r.length?1:0)}function l2(r,t){if(!r)return{minimum:0,maximum:0};let e=Number(r.value[0]),n=e;for(let s=1;s<t;s++){let i=Number(r.value[s*r.size]);e=Math.min(e,i),n=Math.max(n,i)}return{minimum:e,maximum:n}}function u2(r){let t=r.length*Cp;if(t>65535)throw new Error(`LASWriter: Extra Bytes VLR payload ${t} exceeds the LAS limit`)}function f2(r,t,e){if(t===1&&!["1.1","1.2","1.3","1.4","1.5"].includes(r))throw new Error(`LASWriter: LAZ PDRF 1 output requires LAS 1.1 or newer; received ${r}`);if(t>=2&&t<=3&&!["1.2","1.3","1.4","1.5"].includes(r))throw new Error(`LASWriter: LAZ PDRF ${t} output requires LAS 1.2 or newer; received ${r}`);if(t>=4&&t<=5&&!["1.3","1.4","1.5"].includes(r))throw new Error(`LASWriter: LAZ PDRF ${t} requires LAS 1.3 or newer; received ${r}`);if(t>=6&&!["1.4","1.5"].includes(r))throw new Error(`LASWriter: LAZ output requires LAS 1.4; received ${r}`);if(![0,1,2,3,4,5,6,7,8,9,10].includes(t))throw new Error(`LASWriter: LAZ output currently supports point data record formats 0-10; received ${t}`);if(e!==void 0&&(!Number.isInteger(e)||e<=0||e>4294967295))throw new Error(`LASWriter: invalid LAZ chunk size ${e}`)}function h2(r){return"shape"in r&&r.shape==="arrow-table"?ee(r):r}function d2(r){return"shape"in r&&r.shape==="arrow-table"?r:Ee(r,"arrow-table")}function p2(r){if(r.length===0)throw new Error("LASWriter: at least one input batch is required");if(r.length===1)return r[0];let t=r.map(s=>ee(d2(s))),e=t[0],n={};m2(t);for(let s of Object.keys(e.attributes)){let i=e.attributes[s],o=t.map(f=>f.attributes[s]?.value);if(o.some(f=>!f))continue;let a=o.reduce((f,h)=>f+h.length,0),c=i.value.constructor,l=new c(a),u=0;for(let f of o)l.set(f,u),u+=f.length;n[s]={...i,value:l}}return{...e,attributes:n,header:{...e.header,vertexCount:Lw({...e,attributes:n},"POSITION").value.length/3}}}function m2(r){let t=Object.keys(r[0].attributes);for(let e of r.slice(1)){if(Object.keys(e.attributes).length!==t.length||t.some(s=>!e.attributes[s]))throw new Error("LASWriter: encodeInBatches requires consistent attribute names");for(let s of t){let i=r[0].attributes[s],o=e.attributes[s];if(o.size!==i.size||o.value.constructor!==i.value.constructor)throw new Error(`LASWriter: encodeInBatches requires a consistent ${s} layout`)}}}function Lw(r,t){let e=r.attributes[t];if(!e)throw new Error(`LASWriter: ${t} attribute is required`);return e}function y2(r){if(r.size!==3)throw new Error("LASWriter: POSITION attribute must have size 3");if(r.value.length%r.size!==0)throw new Error("LASWriter: POSITION attribute length must be divisible by its size")}function g2(r,t,e,n){for(let s=0;s<3;s++){if(!Number.isFinite(e[s])||e[s]<=0)throw new Error("LASWriter: coordinate scale must be finite and positive");if(!Number.isFinite(n[s]))throw new Error("LASWriter: coordinate offset must be finite")}for(let s=0;s<t;s++)for(let i=0;i<3;i++){let o=r.value[s*r.size+i];if(!Number.isFinite(o))throw new Error("LASWriter: POSITION values must be finite");let a=Math.round((o-n[i])/e[i]);if(a<-2147483648||a>2147483647)throw new Error("LASWriter: encoded coordinate exceeds the signed 32-bit LAS range")}}function b2(r,t){let e=["intensity","classification","gpsTime","scanAngle","userData","pointSourceId","returnNumber","numberOfReturns","scannerChannel","scanDirectionFlag","edgeOfFlightLine","synthetic","keyPoint","withheld","overlap","nir","wavePacketDescriptorIndex","wavePacketOffset","wavePacketSize","wavePacketReturnPoint"];for(let i of e){let o=r.attributes[i];o&&Mp(i,o,t,1)}let n=r.attributes.COLOR_0;n&&Mp("COLOR_0",n,t,3,!1);let s=r.attributes.wavePacketVector;s&&Mp("wavePacketVector",s,t,3)}function w2(r,t,e){let n=e>=6?15:5,s=r.attributes.returnNumber,i=r.attributes.numberOfReturns;for(let o=0;o<t;o++){let a=cr(s,o,1),c=cr(i,o,1);if(a<1||a>n)throw new Error(`LASWriter: returnNumber must be between 1 and ${n} for point data record format ${e}`);if(c<1||c>n)throw new Error(`LASWriter: numberOfReturns must be between 1 and ${n} for point data record format ${e}`);if(a>c)throw new Error("LASWriter: returnNumber cannot exceed numberOfReturns")}}function Mp(r,t,e,n,s=!0){if(n===1?t.size!==1:t.size<n)throw new Error(`LASWriter: ${r} attribute must have size ${n}`);if(Tw(r,t),s&&t.value.length<e*t.size)throw new Error(`LASWriter: ${r} attribute is too short`);if(!s&&t.value.length<t.size)throw new Error(`LASWriter: ${r} attribute is too short`)}function Tw(r,t){for(let e of t.value)if(!Number.isFinite(Number(e)))throw new Error(`LASWriter: ${r} attribute must contain finite values`)}function Mw(r,t){let[e,n]=t.version.split(".").map(Number);kn(r,0,"LASF",4),r.setUint8(24,e),r.setUint8(25,n),kn(r,26,"loaders.gl",32),kn(r,58,"loaders.gl",32),r.setUint16(94,t.headerLength,!0),r.setUint32(96,t.pointDataOffset,!0),r.setUint32(100,t.vlrCount||0,!0),r.setUint8(104,t.pointDataRecordFormat|(t.compressed?128:0)),r.setUint16(105,t.pointDataRecordLength,!0);let s=t.version==="1.4"||t.version==="1.5";r.setUint32(107,s?0:t.vertexCount,!0);for(let i=0;i<5;i++)r.setUint32(111+i*4,s?0:t.returnCounts[i],!0);if(t.version==="1.5"?r.setUint16(6,16|(t.hasGpsTime?1:0)|(t.timeOffset?64:0),!0):t.version==="1.4"&&t.hasWkt&&r.setUint16(6,16,!0),r.setFloat64(131,t.scale[0],!0),r.setFloat64(139,t.scale[1],!0),r.setFloat64(147,t.scale[2],!0),r.setFloat64(155,t.offset[0],!0),r.setFloat64(163,t.offset[1],!0),r.setFloat64(171,t.offset[2],!0),r.setFloat64(179,t.boundingBox[1][0],!0),r.setFloat64(187,t.boundingBox[0][0],!0),r.setFloat64(195,t.boundingBox[1][1],!0),r.setFloat64(203,t.boundingBox[0][1],!0),r.setFloat64(211,t.boundingBox[1][2],!0),r.setFloat64(219,t.boundingBox[0][2],!0),s){Op(r,247,t.vertexCount);for(let i=0;i<Fp;i++)Op(r,255+i*8,t.returnCounts[i])}t.version==="1.5"&&(r.setFloat64(375,t.maxGpsTime,!0),r.setFloat64(383,t.minGpsTime,!0),r.setUint16(391,t.timeOffset,!0))}function x2(r,t,e,n,s,i){if(r.setUint16(t+12,Eu(i.intensityAttribute,e),!0),n<=5){let o=cr(i.returnNumberAttribute,e,1)&7,a=cr(i.numberOfReturnsAttribute,e,1)&7;r.setUint8(t+14,o|a<<3),r.setUint8(t+15,cr(i.classificationAttribute,e)&31),r.setInt8(t+16,Sw(i.scanAngleAttribute,e)),r.setUint8(t+17,cr(i.userDataAttribute,e)),r.setUint16(t+18,Eu(i.pointSourceIdAttribute,e),!0),(n===1||n===3||n>=4)&&r.setFloat64(t+20,Nu(i.gpsTimeAttribute,e),!0),(n===4||n===5)&&Aw(r,t+(n===4?28:34),e,i)}else{let o=cr(i.returnNumberAttribute,e,1)&15,a=cr(i.numberOfReturnsAttribute,e,1)&15,c=cr(i.scannerChannelAttribute,e)&3,l=o|a<<4,u=(Xo(i.syntheticAttribute,e)?1:0)|(Xo(i.keyPointAttribute,e)?2:0)|(Xo(i.withheldAttribute,e)?4:0)|(Xo(i.overlapAttribute,e)?8:0)|c<<4|(Xo(i.scanDirectionFlagAttribute,e)?64:0)|(Xo(i.edgeOfFlightLineAttribute,e)?128:0);r.setUint8(t+14,l),r.setUint8(t+15,u),r.setUint8(t+16,cr(i.classificationAttribute,e)),r.setUint8(t+17,cr(i.userDataAttribute,e)),r.setInt16(t+18,Sw(i.scanAngleAttribute,e),!0),r.setUint16(t+20,Eu(i.pointSourceIdAttribute,e),!0),r.setFloat64(t+22,Nu(i.gpsTimeAttribute,e),!0),(n===9||n===10)&&Aw(r,t+(n===9?30:38),e,i)}S2(r,t,e,n,i.colorAttribute,i.colorDepth),(n===8||n===10)&&r.setUint16(t+36,Eu(i.nirAttribute,e),!0),v2(r,t,e,s,i.extraByteFields)}function Aw(r,t,e,n){r.setUint8(t,cr(n.waveformDescriptorAttribute,e)),r.setBigUint64(t+1,L2(n.waveformOffsetAttribute,e),!0),r.setUint32(t+9,_2(n.waveformSizeAttribute,e),!0),r.setFloat32(t+13,Nu(n.waveformReturnPointAttribute,e),!0);for(let s=0;s<3;s++)r.setFloat32(t+17+s*4,qr(n.waveformVectorAttribute,e,s),!0)}function v2(r,t,e,n,s){let i=t+n;for(let o of s)for(let a=0;a<o.componentCount;a++)A2(r,i,e,a,o),i+=o.byteLength/o.componentCount}function A2(r,t,e,n,s){let i=s.meshAttribute.value[e*s.componentCount+n];switch(s.dataType>20?s.dataType-20:s.dataType>10?s.dataType-10:s.dataType){case 1:r.setUint8(t,Number(i));break;case 2:r.setInt8(t,Number(i));break;case 3:r.setUint16(t,Number(i),!0);break;case 4:r.setInt16(t,Number(i),!0);break;case 5:r.setUint32(t,Number(i),!0);break;case 6:r.setInt32(t,Number(i),!0);break;case 7:r.setBigUint64(t,BigInt(i),!0);break;case 8:r.setBigInt64(t,BigInt(i),!0);break;case 9:r.setFloat32(t,Number(i),!0);break;case 10:r.setFloat64(t,Number(i),!0);break;default:throw new Error(`LASWriter: unsupported Extra Bytes data type ${s.dataType}`)}}function S2(r,t,e,n,s,i){let o=I2(n);o<0||!s||(r.setUint16(t+o,Dp(s,e,0,i),!0),r.setUint16(t+o+2,Dp(s,e,1,i),!0),r.setUint16(t+o+4,Dp(s,e,2,i),!0))}function I2(r){switch(r){case 2:return 20;case 3:return 28;case 5:return 57;case 7:case 8:case 10:return 30;default:return-1}}function B2(r,t){return r.las?.format==="laz"||r.las?.version==="1.4"?t?7:6:t?2:0}function Op(r,t,e){r.setUint32(t,e>>>0,!0),r.setUint32(t+4,Math.floor(e/2**32),!0)}function kn(r,t,e,n){if(/[^\x00-\x7f]/.test(e))throw new Error("LASWriter fixed-width text must be ASCII");for(let s=0;s<n;s++)r.setUint8(t+s,e.charCodeAt(s)||0)}function qr(r,t,e){return r&&r.value[t*r.size+e]||0}function Eu(r,t){return r?Math.max(0,Math.min(65535,Math.round(qr(r,t,0)))):0}function _2(r,t){return r?Math.max(0,Math.min(4294967295,Math.round(qr(r,t,0)))):0}function L2(r,t){if(!r)return 0n;let e=r.value[t*r.size];return typeof e=="bigint"?e:BigInt(Math.max(0,Math.round(Number(e))))}function cr(r,t,e=0){return r?Math.max(0,Math.min(255,Math.round(qr(r,t,0)))):e}function Sw(r,t){return r?Math.max(-32768,Math.min(32767,Math.round(qr(r,t,0)))):0}function Nu(r,t){return r?qr(r,t,0):0}function Xo(r,t){return!!Nu(r,t)}function T2(r,t){let e=new Array(Fp).fill(0);for(let n=0;n<t;n++){let s=cr(r,n,1)&15;s>=1&&s<=Fp&&e[s-1]++}return e}function Dp(r,t,e,n){let s=qr(r,t,e);return r.normalized?M2(r,s):n===8?Ko(s*257):n===16?Ko(s):s<=1?Ko(s*65535):s<=255?Ko(s*257):Ko(s)}function M2(r,t){let e=D2(r.value);return Ko(t/e*65535)}function D2(r){return r instanceof Uint8Array||r instanceof Uint8ClampedArray?255:r instanceof Uint16Array?65535:1}function Ko(r){return Math.max(0,Math.min(65535,Math.round(r)))}function C2(r,t){if(t===0)return[[0,0,0],[0,0,0]];let e=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],n=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(let s=0;s<t;s++)for(let i=0;i<3;i++){let o=qr(r,s,i);e[i]=Math.min(e[i],o),n[i]=Math.max(n[i],o)}return[e,n]}function F2(r,t){return t.las?.scale||Dw(r.schema.metadata?.las_scale)||[.001,.001,.001]}function O2(r,t,e){return t.las?.offset||Dw(r.schema.metadata?.las_offset)||e[0]}function Dw(r){if(typeof r=="string")try{let t=JSON.parse(r);return Array.isArray(t)&&t.length===3&&t.every(e=>typeof e=="number")?[t[0],t[1],t[2]]:void 0}catch{return}}var Jo={name:"PCD (Point Cloud Data)",id:"pcd",module:"pointclouds",encoding:"text",format:"pcd",extensions:["pcd"],mimeTypes:["text/plain"],category:"pointcloud",text:!0,binary:!0};Gs();var Y2=typeof __VERSION__<"u"?__VERSION__:"latest";async function Z2(){let{PCDLoaderWithParser:r}=await Promise.resolve().then(()=>(Np(),Up));return r}var kp={...Jo,dataType:null,batchType:null,version:Y2,worker:!0,workerInBatches:!0,serializeWorkerResult:re,options:{pcd:{shape:"arrow-table",colorFormat:"uint8norm"}},preload:Z2},qw=kp;or();var H2=typeof __VERSION__<"u"?__VERSION__:"latest",Ww={...Jo,dataType:null,batchType:null,version:H2,options:{pcd:{}},text:!0,encode:async(r,t)=>$w(r,t),encodeSync:$w,encodeTextSync:Yw};function $w(r,t){let e=Yw(r,t);return new TextEncoder().encode(e).buffer}function Yw(r,t){let e=ee(X2(r)),n=K2(e,"POSITION"),s=e.attributes.NORMAL,i=e.attributes.COLOR_0,o=n.value.length/n.size,a=["x","y","z"],c=["4","4","4"],l=["F","F","F"],u=["1","1","1"];s&&(a.push("normal_x","normal_y","normal_z"),c.push("4","4","4"),l.push("F","F","F"),u.push("1","1","1")),i&&(a.push("rgb"),c.push("4"),l.push("F"),u.push("1"));let f=["# .PCD v0.7 - Point Cloud Data file generated by loaders.gl","VERSION 0.7",`FIELDS ${a.join(" ")}`,`SIZE ${c.join(" ")}`,`TYPE ${l.join(" ")}`,`COUNT ${u.join(" ")}`,`WIDTH ${o}`,"HEIGHT 1","VIEWPOINT 0 0 0 1 0 0 0",`POINTS ${o}`,"DATA ascii"];for(let h=0;h<o;h++){let m=[to(n,h,0),to(n,h,1),to(n,h,2)];s&&m.push(to(s,h,0),to(s,h,1),to(s,h,2)),i&&m.push(J2(i,h)),f.push(m.join(" "))}return`${f.join(`
|
|
41
|
+
`}async function*wL(r,t){for(t.length>0&&(yield yf(t));;){let{value:e,done:n}=await r.next();if(n)break;yield yf(gf(e))}}function km(r){let t=r?.batchSize;return typeof t=="number"?t:lL}function xL(r){return r.properties.reduce((t,e)=>t+mf(e.type),0)}function mf(r){switch(r){case"int8":case"uint8":case"char":case"uchar":return 1;case"int16":case"uint16":case"short":case"ushort":return 2;case"int32":case"uint32":case"int":case"uint":case"float32":case"float":return 4;case"float64":case"double":return 8;default:throw new Error(r)}}function AL(r){let t=new TextEncoder().encode(uL),e=r.length-t.length;for(let n=0;n<=e;n++){let s=!0;for(let i=0;i<t.length;i++)if(r[n+i]!==t[i]){s=!1;break}if(s){let i=n+t.length;return i===r.length||r[i]===13&&i+1===r.length?-1:(r[i]===13&&r[i+1]===10?i+=2:i<r.length&&vL(r[i])&&(i+=1),i)}}return-1}function vL(r){return r===10||r===13||r===9||r===32}function gf(r){return ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r)}function yf(r){let t=new Uint8Array(r.byteLength);return t.set(r),t.buffer}function zm(r){let t=r.reduce((s,i)=>s+i.length,0),e=new Uint8Array(t),n=0;for(let s of r)e.set(s,n),n+=s.length;return e}async function SL(r,t){let e,n={comments:[],elements:[]};return await lp(r,s=>{if(s=s.trim(),s==="end_header")return!0;if(s==="")return!1;let i=s.split(/\s+/),o=i.shift();switch(s=i.join(" "),o){case"ply":break;case"format":n.format=i[0],n.version=i[1];break;case"comment":n.comments.push(s);break;case"element":e&&n.elements.push(e),e={name:i[0],count:parseInt(i[1],10),properties:[]};break;case"property":let a=IL(i,t.propertyNameMapping);e?.properties.push(a);break;default:cp.log(0,"unhandled",o,i)()}return!1}),e&&n.elements.push(e),n}function IL(r,t){let e=r[0];return e==="list"?{type:e,name:r[3],countType:r[1],itemType:r[2]}:{type:e,name:r[1]}}async function BL(r,t){let e={indices:[],vertices:[],normals:[],uvs:[],colors:[]},n=0,s=0;for await(let i of r)if(i=i.trim(),i!==""){s>=t.elements[n].count&&(n++,s=0);let o=_L(t.elements[n].properties,i);LL(e,t.elements[n].name,o),s++}return e}function Rm(r,t){switch(t){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(r,10);case"float":case"double":case"float32":case"float64":return parseFloat(r);default:throw new Error(t)}}function _L(r,t){let e=t.split(/\s+/),n={};for(let s=0;s<r.length;s++)if(r[s].type==="list"){let i=[],o=Rm(e.shift(),r[s].countType);for(let a=0;a<o;a++)i.push(Rm(e.shift(),r[s].itemType));n[r[s].name]=i}else n[r[s].name]=Rm(e.shift(),r[s].type);return n}function LL(r,t,e={}){switch(t){case"vertex":r.vertices.push(e.x,e.y,e.z),"nx"in e&&"ny"in e&&"nz"in e&&r.normals.push(e.nx,e.ny,e.nz),"s"in e&&"t"in e&&r.uvs.push(e.s,e.t),"red"in e&&"green"in e&&"blue"in e&&r.colors.push(e.red,e.green,e.blue);break;case"face":let n=e.vertex_indices||e.vertex_index;n.length===3?r.indices.push(n[0],n[1],n[2]):n.length===4&&(r.indices.push(n[0],n[1],n[3]),r.indices.push(n[1],n[2],n[3]));break;default:break}}var lL,uL,px=d(()=>{"use strict";no();no();Mm();df();Um();lL=65536,uL="end_header"});var mx,yx=d(()=>{"use strict";mx={name:"PLY",id:"ply",module:"pointclouds",encoding:"text",format:"ply",extensions:["ply"],mimeTypes:["text/plain","application/octet-stream"],text:!0,binary:!0,tests:["ply"]}});async function ML(){let{PLYLoaderWithParser:r}=await Promise.resolve().then(()=>(Gm(),Vm));return r}var TL,gx,bx=d(()=>{"use strict";yx();js();TL="5.0.0-beta.8";gx={dataType:null,batchType:null,...mx,version:TL,worker:!0,workerInBatches:!0,serializeWorkerResult:re,options:{ply:{shape:"arrow-table",colorFormat:"uint8norm"}},preload:ML}});function wx(r,t){let e=Oe(r,"arrow-table");return bf(e,t,r.loaderData)}function $m(r,t){if(t?.ply?._useLegacyParser)return wx(X1(r,t?.ply),t);let e=K1(r,t?.ply);if(e)return bf(e,t,Gn(r,t?.ply));let n=Sc(r,t?.ply);return bf(Ic(n),t,n.header)}function bf(r,t,e){let n=e||r.loaderData||{comments:[],elements:[]},s=t?.ply?.shape==="arrow-table"?{...r,loader:"ply",loaderData:n}:{...ee(r),loader:"ply",loaderData:n},i=t?.ply?.colorFormat||"uint8norm";if(i==="uint8norm")return s;let o=s,a=FL(jm(o)?ee(o):o,i);return t?.ply?.shape==="arrow-table"?{...Oe(a,"arrow-table"),loader:"ply",loaderData:n}:a}function FL(r,t){let e=r.attributes.COLOR_0;if(!e)return r;let n=e.value instanceof Uint16Array?65535:255,s=t==="float16"?si(e.value,n):ua(e.value,n),i={...r.attributes};for(let[o,a]of Object.entries(i))a.value===e.value&&(i[o]={...a,value:s,normalized:!1,...t==="float16"?{componentType:"float16"}:{}});return{...r,attributes:i,schema:Wi(i,r.schema.metadata)}}function jm(r){return"shape"in r&&r.shape==="arrow-table"}function xx(r,t){let e=$o(r);return t?.ply?.shape==="mesh"?{...ee(e),loader:"ply",loaderData:e.loaderData}:e}function EL(r,t){return xx(r,t)}var lz,DL,CL,Ax=d(()=>{"use strict";no();$s();js();or();df();Um();px();bx();({preload:lz,...DL}=gx);CL={...DL,parse:async(r,t)=>$m(r,t),parseTextSync:(r,t)=>$m(r,t),parseSync:(r,t)=>$m(r,t),parseInBatches:async function*(r,t){let e={...t?.ply,batchSize:t?.batchSize??t?.core?.batchSize};for await(let n of hx(r,e)){let s=jm(n)?bf(n,t):wx(n,t);yield jm(s)?wc(s):s}},serializeWorkerResult:re,deserializeWorkerResult:xx,serializeWorkerBatch:re,deserializeWorkerBatch:EL}});var Vm={};Re(Vm,{PLYLoaderWithParser:()=>CL});var Gm=d(()=>{"use strict";Ax()});var GL={};Re(GL,{LASFormat:()=>Go,LASLoader:()=>mm,LASWorkerLoader:()=>w1,LASWriter:()=>S1,PCDFormat:()=>ia,PCDLoader:()=>Lm,PCDWorkerLoader:()=>$1,PCDWriter:()=>q1,PLYFormat:()=>aa,PLYLoader:()=>qm,PLYWorkerLoader:()=>vx,PLYWriter:()=>Ix});var Go={name:"LAS",id:"las",module:"pointclouds",encoding:"binary",format:"las",extensions:["las","laz"],mimeTypes:["application/octet-stream"],text:!1,binary:!0,tests:["LASF"]};var fS=typeof __VERSION__<"u"?__VERSION__:"latest",hS="arrow-table";var fb={...Go,dataType:null,batchType:null,version:fS,worker:!1,options:{las:{shape:hS,fp64:!1,colorDepth:8,colorFormat:"uint8norm",columns:void 0,extraBytes:"raw",recoverMissingChunkTable:!1,compatibilityMode:"auto"}}};async function o_(){let{LASLoaderWithParser:r}=await Promise.resolve().then(()=>(b1(),g1));return r}var mm={...fb,worker:!0,workerInBatches:!0,preload:o_},w1=mm;no();or();var a_=typeof __VERSION__<"u"?__VERSION__:"latest",c_=227,l_=375,u_=393,af=54,wm=192,f_=5e4,h_=4294967295,xm=15,d_={0:20,1:28,2:26,3:34,4:57,5:63,6:30,7:36,8:38,9:59,10:67},S1={...Go,dataType:null,batchType:null,version:a_,extensions:["las","laz"],options:{las:{}},encode:async(r,t)=>ym(r,t),encodeSync:ym,encodeInBatches:async function*(r,t){let e=[];for await(let n of r)e.push(n);yield ym(__(e),t)}};function ym(r,t={}){let e=t.las?.format||"las",n=t.las?.colorDepth;if(n!==void 0&&n!=="auto"&&n!==8&&n!==16)throw new Error("LASWriter: invalid source color depth");let s=I_(r),i=_1(s,"POSITION");T_(i);let o=i.value.length/i.size;D_(s,o);let a=s.attributes.COLOR_0,c=s.attributes.intensity,l=s.attributes.classification,u=s.attributes.nir,f=g_(s,t,o),h=s.attributes.gpsTime,m=s.attributes.scanAngle,y=s.attributes.userData,g=s.attributes.pointSourceId,x=s.attributes.returnNumber,I=s.attributes.numberOfReturns,j=s.attributes.scannerChannel,T=s.attributes.scanDirectionFlag,b=s.attributes.edgeOfFlightLine,C=s.attributes.synthetic,_=s.attributes.keyPoint,q=s.attributes.withheld,X=s.attributes.overlap,ft=s.attributes.wavePacketDescriptorIndex,dt=s.attributes.wavePacketOffset,It=s.attributes.wavePacketSize,se=s.attributes.wavePacketReturnPoint,rt=s.attributes.wavePacketVector,tt=$_(i,o),Ye=z_(x,o),Ue=j_(s,t),Ze=q_(s,t,tt);M_(i,o,Ue,Ze);let xt=t.las?.pointDataRecordFormat??R_(t,a);C_(s,o,xt);let jn=d_[xt];if(!jn)throw new Error(`LASWriter: unsupported point data record format ${xt}`);let ni=jn+f.reduce((hn,co)=>hn+co.byteLength,0);if(ni>65535)throw new Error(`LASWriter: point data record length ${ni} exceeds the LAS limit`);v_(f);let wt=t.las?.version||(xt>=6?"1.4":"1.2"),pt=wt==="1.5"?u_:wt==="1.4"?l_:c_;m_(wt,xt,t);let un=A_(h,o);if(wt==="1.5"&&t.las?.timeOffset&&!h)throw new Error("LASWriter: LAS 1.5 timeOffset requires a GPS time attribute");e==="laz"&&S_(wt,xt,t.las?.chunkSize),p_(wt,xt);let Wr=new Uint8Array(o*ni),fn=new DataView(Wr.buffer);for(let hn=0;hn<o;hn++){let co=hn*ni;fn.setInt32(co,Math.round((qr(i,hn,0)-Ze[0])/Ue[0]),!0),fn.setInt32(co+4,Math.round((qr(i,hn,1)-Ze[1])/Ue[1]),!0),fn.setInt32(co+8,Math.round((qr(i,hn,2)-Ze[2])/Ue[2]),!0),F_(fn,co,hn,xt,jn,{intensityAttribute:c,classificationAttribute:l,nirAttribute:u,colorAttribute:a,colorDepth:n,gpsTimeAttribute:h,scanAngleAttribute:m,userDataAttribute:y,pointSourceIdAttribute:g,returnNumberAttribute:x,numberOfReturnsAttribute:I,scannerChannelAttribute:j,scanDirectionFlagAttribute:T,edgeOfFlightLineAttribute:b,syntheticAttribute:C,keyPointAttribute:_,withheldAttribute:q,overlapAttribute:X,waveformDescriptorAttribute:ft,waveformOffsetAttribute:dt,waveformSizeAttribute:It,waveformReturnPointAttribute:se,waveformVectorAttribute:rt,extraByteFields:f})}let Sr={vertexCount:o,boundingBox:tt,scale:Ue,offset:Ze,version:wt,headerLength:pt,pointDataRecordFormat:xt,pointDataRecordLength:ni,returnCounts:Ye,maxGpsTime:un.maximum,minGpsTime:un.minimum,timeOffset:t.las?.timeOffset||0,hasGpsTime:!!h,hasWkt:!!t.las?.wkt};if(e==="laz")return y_(Wr,Sr,t.las?.chunkSize,t.las?.variableChunkTable,f,t);let Ir=I1(f,t),ao=pt+Ir.byteLength,wf=new ArrayBuffer(ao+Wr.byteLength);T1(new DataView(wf),{...Sr,pointDataOffset:ao,vlrCount:B1(f,t)});let Ym=new Uint8Array(wf);return Ym.set(Ir,pt),Ym.set(Wr,ao),wf}function p_(r,t){let n={0:"1.0",1:"1.1",2:"1.2",3:"1.2"}[t];if(n&&r<n)throw new Error(`LASWriter: point data record format ${t} requires LAS ${n} or newer; received ${r}`);if(t>=4&&t<=5&&!["1.3","1.4","1.5"].includes(r))throw new Error(`LASWriter: point data record format ${t} requires LAS 1.3; received ${r}`);if(t>=6&&!["1.4","1.5"].includes(r))throw new Error(`LASWriter: point data record format ${t} requires LAS 1.4; received ${r}`)}function m_(r,t,e){if(r==="1.5"){if(t<6||t>10)throw new Error("LASWriter: LAS 1.5 output requires point data record format 6-10");if(!e.las?.wkt?.trim())throw new Error("LASWriter: LAS 1.5 output requires las.wkt");let n=e.las?.timeOffset??0;if(!Number.isInteger(n)||n<0||n>65535)throw new Error("LASWriter: LAS 1.5 timeOffset must be an unsigned 16-bit integer")}}function y_(r,t,e,n=!1,s=[],i={}){let o=e||f_,a=Jp({pointDataRecordFormat:t.pointDataRecordFormat,pointDataRecordLength:t.pointDataRecordLength,chunkSize:n?h_:o}),c=I1(s,i),l=t.headerLength+c.byteLength+a.byteLength,u=[],f=[];for(let T=0;T<t.vertexCount;T+=o){let b=Math.min(o,t.vertexCount-T),C=T*t.pointDataRecordLength,_=Xp(r.subarray(C,C+b*t.pointDataRecordLength),{pointDataRecordFormat:t.pointDataRecordFormat,pointDataRecordLength:t.pointDataRecordLength,pointCount:b,point14ItemVersion:3,rgb14ItemVersion:3,byte14ItemVersion:3});u.push(_),f.push({pointCount:b,byteLength:_.byteLength})}let h=u.reduce((T,b)=>T+b.byteLength,0),m=Kp(f,{variable:n}),y=l+8+h,g=new ArrayBuffer(y+8+m.byteLength),x=new Uint8Array(g),I=new DataView(g);T1(I,{...t,pointDataOffset:l,vlrCount:B1(s,i)+1,compressed:!0}),x.set(c,t.headerLength),x.set(a,t.headerLength+c.byteLength),Am(I,l,y);let j=l+8;for(let T of u)x.set(T,j),j+=T.byteLength;return I.setUint32(y,0,!0),I.setUint32(y+4,f.length,!0),x.set(m,y+8),g}function g_(r,t,e){let n=t.las?.extraBytes||[],s=new Set;return n.map(i=>{if(s.has(i.attribute))throw new Error(`LASWriter: duplicate Extra Bytes attribute ${i.attribute}`);s.add(i.attribute);let o=r.attributes[i.attribute];if(!o)throw new Error(`LASWriter: Extra Bytes attribute ${i.attribute} is missing`);if(![1,3].includes(o.size))throw new Error(`LASWriter: Extra Bytes attribute ${i.attribute} must have size 1 or 3`);if(o.value.length<e*o.size)throw new Error(`LASWriter: Extra Bytes attribute ${i.attribute} is too short`);L1(i.attribute,o);let a=b_(o.value,o.size);return{...i,meshAttribute:o,dataType:a,byteLength:w_(a,o.size),componentCount:o.size}})}function b_(r,t){let e=0;if(r instanceof Uint8Array?e=1:r instanceof Int8Array?e=2:r instanceof Uint16Array?e=3:r instanceof Int16Array?e=4:r instanceof Uint32Array?e=5:r instanceof Int32Array?e=6:r instanceof BigUint64Array?e=7:r instanceof BigInt64Array?e=8:r instanceof Float32Array?e=9:r instanceof Float64Array&&(e=10),e)return e+(t===3?20:0);throw new Error("LASWriter: Extra Bytes attributes require a supported typed array")}function w_(r,t){let e=r>20?r-20:r>10?r-10:r;return(e<=2?1:e<=4?2:e<=6||e===9?4:8)*t}function x_(r){if(r.length===0)return new Uint8Array(0);let t=new Uint8Array(r.length*wm),e=new DataView(t.buffer),n=0;for(let o of r)e.setUint8(n+2,o.dataType),Vn(e,n+4,o.name||o.attribute,32),Vn(e,n+160,o.description||"",32),n+=wm;let s=new Uint8Array(af+t.byteLength),i=new DataView(s.buffer);return Vn(i,2,"LASF_Spec",16),i.setUint16(18,4,!0),i.setUint16(20,t.byteLength,!0),Vn(i,22,"Extra Bytes",32),s.set(t,af),s}function I1(r,t){let e=[];t.las?.wktMathTransform&&e.push(x1(2111,"WKT Math Transform",t.las.wktMathTransform)),t.las?.wkt&&e.push(x1(2112,"WKT Coordinate System",t.las.wkt));let n=x_(r);n.byteLength&&e.push(n);let s=e.reduce((a,c)=>a+c.byteLength,0),i=new Uint8Array(s),o=0;for(let a of e)i.set(a,o),o+=a.byteLength;return i}function x1(r,t,e){let n=new TextEncoder().encode(`${e}\0`);if(n.byteLength>65535)throw new Error(`LASWriter: WKT VLR ${r} exceeds the LAS VLR size limit`);let s=new Uint8Array(af+n.byteLength),i=new DataView(s.buffer);return Vn(i,2,"LASF_Projection",16),i.setUint16(18,r,!0),i.setUint16(20,n.byteLength,!0),Vn(i,22,t,32),s.set(n,af),s}function B1(r,t){return(t.las?.wktMathTransform?1:0)+(t.las?.wkt?1:0)+(r.length?1:0)}function A_(r,t){if(!r)return{minimum:0,maximum:0};let e=Number(r.value[0]),n=e;for(let s=1;s<t;s++){let i=Number(r.value[s*r.size]);e=Math.min(e,i),n=Math.max(n,i)}return{minimum:e,maximum:n}}function v_(r){let t=r.length*wm;if(t>65535)throw new Error(`LASWriter: Extra Bytes VLR payload ${t} exceeds the LAS limit`)}function S_(r,t,e){if(t===1&&!["1.1","1.2","1.3","1.4","1.5"].includes(r))throw new Error(`LASWriter: LAZ PDRF 1 output requires LAS 1.1 or newer; received ${r}`);if(t>=2&&t<=3&&!["1.2","1.3","1.4","1.5"].includes(r))throw new Error(`LASWriter: LAZ PDRF ${t} output requires LAS 1.2 or newer; received ${r}`);if(t>=4&&t<=5&&!["1.3","1.4","1.5"].includes(r))throw new Error(`LASWriter: LAZ PDRF ${t} requires LAS 1.3 or newer; received ${r}`);if(t>=6&&!["1.4","1.5"].includes(r))throw new Error(`LASWriter: LAZ output requires LAS 1.4; received ${r}`);if(![0,1,2,3,4,5,6,7,8,9,10].includes(t))throw new Error(`LASWriter: LAZ output currently supports point data record formats 0-10; received ${t}`);if(e!==void 0&&(!Number.isInteger(e)||e<=0||e>4294967295))throw new Error(`LASWriter: invalid LAZ chunk size ${e}`)}function I_(r){return"shape"in r&&r.shape==="arrow-table"?ee(r):r}function B_(r){return"shape"in r&&r.shape==="arrow-table"?r:Oe(r,"arrow-table")}function __(r){if(r.length===0)throw new Error("LASWriter: at least one input batch is required");if(r.length===1)return r[0];let t=r.map(s=>ee(B_(s))),e=t[0],n={};L_(t);for(let s of Object.keys(e.attributes)){let i=e.attributes[s],o=t.map(f=>f.attributes[s]?.value);if(o.some(f=>!f))continue;let a=o.reduce((f,h)=>f+h.length,0),c=i.value.constructor,l=new c(a),u=0;for(let f of o)l.set(f,u),u+=f.length;n[s]={...i,value:l}}return{...e,attributes:n,header:{...e.header,vertexCount:_1({...e,attributes:n},"POSITION").value.length/3}}}function L_(r){let t=Object.keys(r[0].attributes);for(let e of r.slice(1)){if(Object.keys(e.attributes).length!==t.length||t.some(s=>!e.attributes[s]))throw new Error("LASWriter: encodeInBatches requires consistent attribute names");for(let s of t){let i=r[0].attributes[s],o=e.attributes[s];if(o.size!==i.size||o.value.constructor!==i.value.constructor)throw new Error(`LASWriter: encodeInBatches requires a consistent ${s} layout`)}}}function _1(r,t){let e=r.attributes[t];if(!e)throw new Error(`LASWriter: ${t} attribute is required`);return e}function T_(r){if(r.size!==3)throw new Error("LASWriter: POSITION attribute must have size 3");if(r.value.length%r.size!==0)throw new Error("LASWriter: POSITION attribute length must be divisible by its size")}function M_(r,t,e,n){for(let s=0;s<3;s++){if(!Number.isFinite(e[s])||e[s]<=0)throw new Error("LASWriter: coordinate scale must be finite and positive");if(!Number.isFinite(n[s]))throw new Error("LASWriter: coordinate offset must be finite")}for(let s=0;s<t;s++)for(let i=0;i<3;i++){let o=r.value[s*r.size+i];if(!Number.isFinite(o))throw new Error("LASWriter: POSITION values must be finite");let a=Math.round((o-n[i])/e[i]);if(a<-2147483648||a>2147483647)throw new Error("LASWriter: encoded coordinate exceeds the signed 32-bit LAS range")}}function D_(r,t){let e=["intensity","classification","gpsTime","scanAngle","userData","pointSourceId","returnNumber","numberOfReturns","scannerChannel","scanDirectionFlag","edgeOfFlightLine","synthetic","keyPoint","withheld","overlap","nir","wavePacketDescriptorIndex","wavePacketOffset","wavePacketSize","wavePacketReturnPoint"];for(let i of e){let o=r.attributes[i];o&&gm(i,o,t,1)}let n=r.attributes.COLOR_0;n&&gm("COLOR_0",n,t,3,!1);let s=r.attributes.wavePacketVector;s&&gm("wavePacketVector",s,t,3)}function C_(r,t,e){let n=e>=6?15:5,s=r.attributes.returnNumber,i=r.attributes.numberOfReturns;for(let o=0;o<t;o++){let a=cr(s,o,1),c=cr(i,o,1);if(a<1||a>n)throw new Error(`LASWriter: returnNumber must be between 1 and ${n} for point data record format ${e}`);if(c<1||c>n)throw new Error(`LASWriter: numberOfReturns must be between 1 and ${n} for point data record format ${e}`);if(a>c)throw new Error("LASWriter: returnNumber cannot exceed numberOfReturns")}}function gm(r,t,e,n,s=!0){if(n===1?t.size!==1:t.size<n)throw new Error(`LASWriter: ${r} attribute must have size ${n}`);if(L1(r,t),s&&t.value.length<e*t.size)throw new Error(`LASWriter: ${r} attribute is too short`);if(!s&&t.value.length<t.size)throw new Error(`LASWriter: ${r} attribute is too short`)}function L1(r,t){for(let e of t.value)if(!Number.isFinite(Number(e)))throw new Error(`LASWriter: ${r} attribute must contain finite values`)}function T1(r,t){let[e,n]=t.version.split(".").map(Number);Vn(r,0,"LASF",4),r.setUint8(24,e),r.setUint8(25,n),Vn(r,26,"loaders.gl",32),Vn(r,58,"loaders.gl",32),r.setUint16(94,t.headerLength,!0),r.setUint32(96,t.pointDataOffset,!0),r.setUint32(100,t.vlrCount||0,!0),r.setUint8(104,t.pointDataRecordFormat|(t.compressed?128:0)),r.setUint16(105,t.pointDataRecordLength,!0);let s=t.version==="1.4"||t.version==="1.5";r.setUint32(107,s?0:t.vertexCount,!0);for(let i=0;i<5;i++)r.setUint32(111+i*4,s?0:t.returnCounts[i],!0);if(t.version==="1.5"?r.setUint16(6,16|(t.hasGpsTime?1:0)|(t.timeOffset?64:0),!0):t.version==="1.4"&&t.hasWkt&&r.setUint16(6,16,!0),r.setFloat64(131,t.scale[0],!0),r.setFloat64(139,t.scale[1],!0),r.setFloat64(147,t.scale[2],!0),r.setFloat64(155,t.offset[0],!0),r.setFloat64(163,t.offset[1],!0),r.setFloat64(171,t.offset[2],!0),r.setFloat64(179,t.boundingBox[1][0],!0),r.setFloat64(187,t.boundingBox[0][0],!0),r.setFloat64(195,t.boundingBox[1][1],!0),r.setFloat64(203,t.boundingBox[0][1],!0),r.setFloat64(211,t.boundingBox[1][2],!0),r.setFloat64(219,t.boundingBox[0][2],!0),s){Am(r,247,t.vertexCount);for(let i=0;i<xm;i++)Am(r,255+i*8,t.returnCounts[i])}t.version==="1.5"&&(r.setFloat64(375,t.maxGpsTime,!0),r.setFloat64(383,t.minGpsTime,!0),r.setUint16(391,t.timeOffset,!0))}function F_(r,t,e,n,s,i){if(r.setUint16(t+12,of(i.intensityAttribute,e),!0),n<=5){let o=cr(i.returnNumberAttribute,e,1)&7,a=cr(i.numberOfReturnsAttribute,e,1)&7;r.setUint8(t+14,o|a<<3),r.setUint8(t+15,cr(i.classificationAttribute,e)&31),r.setInt8(t+16,v1(i.scanAngleAttribute,e)),r.setUint8(t+17,cr(i.userDataAttribute,e)),r.setUint16(t+18,of(i.pointSourceIdAttribute,e),!0),(n===1||n===3||n>=4)&&r.setFloat64(t+20,cf(i.gpsTimeAttribute,e),!0),(n===4||n===5)&&A1(r,t+(n===4?28:34),e,i)}else{let o=cr(i.returnNumberAttribute,e,1)&15,a=cr(i.numberOfReturnsAttribute,e,1)&15,c=cr(i.scannerChannelAttribute,e)&3,l=o|a<<4,u=(na(i.syntheticAttribute,e)?1:0)|(na(i.keyPointAttribute,e)?2:0)|(na(i.withheldAttribute,e)?4:0)|(na(i.overlapAttribute,e)?8:0)|c<<4|(na(i.scanDirectionFlagAttribute,e)?64:0)|(na(i.edgeOfFlightLineAttribute,e)?128:0);r.setUint8(t+14,l),r.setUint8(t+15,u),r.setUint8(t+16,cr(i.classificationAttribute,e)),r.setUint8(t+17,cr(i.userDataAttribute,e)),r.setInt16(t+18,v1(i.scanAngleAttribute,e),!0),r.setUint16(t+20,of(i.pointSourceIdAttribute,e),!0),r.setFloat64(t+22,cf(i.gpsTimeAttribute,e),!0),(n===9||n===10)&&A1(r,t+(n===9?30:38),e,i)}N_(r,t,e,n,i.colorAttribute,i.colorDepth),(n===8||n===10)&&r.setUint16(t+36,of(i.nirAttribute,e),!0),E_(r,t,e,s,i.extraByteFields)}function A1(r,t,e,n){r.setUint8(t,cr(n.waveformDescriptorAttribute,e)),r.setBigUint64(t+1,k_(n.waveformOffsetAttribute,e),!0),r.setUint32(t+9,P_(n.waveformSizeAttribute,e),!0),r.setFloat32(t+13,cf(n.waveformReturnPointAttribute,e),!0);for(let s=0;s<3;s++)r.setFloat32(t+17+s*4,qr(n.waveformVectorAttribute,e,s),!0)}function E_(r,t,e,n,s){let i=t+n;for(let o of s)for(let a=0;a<o.componentCount;a++)O_(r,i,e,a,o),i+=o.byteLength/o.componentCount}function O_(r,t,e,n,s){let i=s.meshAttribute.value[e*s.componentCount+n];switch(s.dataType>20?s.dataType-20:s.dataType>10?s.dataType-10:s.dataType){case 1:r.setUint8(t,Number(i));break;case 2:r.setInt8(t,Number(i));break;case 3:r.setUint16(t,Number(i),!0);break;case 4:r.setInt16(t,Number(i),!0);break;case 5:r.setUint32(t,Number(i),!0);break;case 6:r.setInt32(t,Number(i),!0);break;case 7:r.setBigUint64(t,BigInt(i),!0);break;case 8:r.setBigInt64(t,BigInt(i),!0);break;case 9:r.setFloat32(t,Number(i),!0);break;case 10:r.setFloat64(t,Number(i),!0);break;default:throw new Error(`LASWriter: unsupported Extra Bytes data type ${s.dataType}`)}}function N_(r,t,e,n,s,i){let o=U_(n);o<0||!s||(r.setUint16(t+o,bm(s,e,0,i),!0),r.setUint16(t+o+2,bm(s,e,1,i),!0),r.setUint16(t+o+4,bm(s,e,2,i),!0))}function U_(r){switch(r){case 2:return 20;case 3:return 28;case 5:return 57;case 7:case 8:case 10:return 30;default:return-1}}function R_(r,t){return r.las?.format==="laz"||r.las?.version==="1.4"?t?7:6:t?2:0}function Am(r,t,e){r.setUint32(t,e>>>0,!0),r.setUint32(t+4,Math.floor(e/2**32),!0)}function Vn(r,t,e,n){if(/[^\x00-\x7f]/.test(e))throw new Error("LASWriter fixed-width text must be ASCII");for(let s=0;s<n;s++)r.setUint8(t+s,e.charCodeAt(s)||0)}function qr(r,t,e){return r&&r.value[t*r.size+e]||0}function of(r,t){return r?Math.max(0,Math.min(65535,Math.round(qr(r,t,0)))):0}function P_(r,t){return r?Math.max(0,Math.min(4294967295,Math.round(qr(r,t,0)))):0}function k_(r,t){if(!r)return 0n;let e=r.value[t*r.size];return typeof e=="bigint"?e:BigInt(Math.max(0,Math.round(Number(e))))}function cr(r,t,e=0){return r?Math.max(0,Math.min(255,Math.round(qr(r,t,0)))):e}function v1(r,t){return r?Math.max(-32768,Math.min(32767,Math.round(qr(r,t,0)))):0}function cf(r,t){return r?qr(r,t,0):0}function na(r,t){return!!cf(r,t)}function z_(r,t){let e=new Array(xm).fill(0);for(let n=0;n<t;n++){let s=cr(r,n,1)&15;s>=1&&s<=xm&&e[s-1]++}return e}function bm(r,t,e,n){let s=qr(r,t,e);return r.normalized?V_(r,s):n===8?sa(s*257):n===16?sa(s):s<=1?sa(s*65535):s<=255?sa(s*257):sa(s)}function V_(r,t){let e=G_(r.value);return sa(t/e*65535)}function G_(r){return r instanceof Uint8Array||r instanceof Uint8ClampedArray?255:r instanceof Uint16Array?65535:1}function sa(r){return Math.max(0,Math.min(65535,Math.round(r)))}function $_(r,t){if(t===0)return[[0,0,0],[0,0,0]];let e=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],n=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(let s=0;s<t;s++)for(let i=0;i<3;i++){let o=qr(r,s,i);e[i]=Math.min(e[i],o),n[i]=Math.max(n[i],o)}return[e,n]}function j_(r,t){return t.las?.scale||M1(r.schema.metadata?.las_scale)||[.001,.001,.001]}function q_(r,t,e){return t.las?.offset||M1(r.schema.metadata?.las_offset)||e[0]}function M1(r){if(typeof r=="string")try{let t=JSON.parse(r);return Array.isArray(t)&&t.length===3&&t.every(e=>typeof e=="number")?[t[0],t[1],t[2]]:void 0}catch{return}}var ia={name:"PCD (Point Cloud Data)",id:"pcd",module:"pointclouds",encoding:"text",format:"pcd",extensions:["pcd"],mimeTypes:["text/plain"],category:"pointcloud",text:!0,binary:!0};js();var i2=typeof __VERSION__<"u"?__VERSION__:"latest";async function o2(){let{PCDLoaderWithParser:r}=await Promise.resolve().then(()=>(Im(),Sm));return r}var Lm={...ia,dataType:null,batchType:null,version:i2,worker:!0,workerInBatches:!0,serializeWorkerResult:re,options:{pcd:{shape:"arrow-table",colorFormat:"uint8norm"}},preload:o2},$1=Lm;or();var a2=typeof __VERSION__<"u"?__VERSION__:"latest",q1={...ia,dataType:null,batchType:null,version:a2,options:{pcd:{}},text:!0,encode:async(r,t)=>j1(r,t),encodeSync:j1,encodeTextSync:W1};function j1(r,t){let e=W1(r,t);return new TextEncoder().encode(e).buffer}function W1(r,t){let e=ee(c2(r)),n=l2(e,"POSITION"),s=e.attributes.NORMAL,i=e.attributes.COLOR_0,o=n.value.length/n.size,a=["x","y","z"],c=["4","4","4"],l=["F","F","F"],u=["1","1","1"];s&&(a.push("normal_x","normal_y","normal_z"),c.push("4","4","4"),l.push("F","F","F"),u.push("1","1","1")),i&&(a.push("rgb"),c.push("4"),l.push("F"),u.push("1"));let f=["# .PCD v0.7 - Point Cloud Data file generated by loaders.gl","VERSION 0.7",`FIELDS ${a.join(" ")}`,`SIZE ${c.join(" ")}`,`TYPE ${l.join(" ")}`,`COUNT ${u.join(" ")}`,`WIDTH ${o}`,"HEIGHT 1","VIEWPOINT 0 0 0 1 0 0 0",`POINTS ${o}`,"DATA ascii"];for(let h=0;h<o;h++){let m=[oo(n,h,0),oo(n,h,1),oo(n,h,2)];s&&m.push(oo(s,h,0),oo(s,h,1),oo(s,h,2)),i&&m.push(u2(i,h)),f.push(m.join(" "))}return`${f.join(`
|
|
42
42
|
`)}
|
|
43
|
-
`}function
|
|
43
|
+
`}function c2(r){return"shape"in r&&r.shape==="arrow-table"?r:Oe(r,"arrow-table")}function l2(r,t){let e=r.attributes[t];if(!e)throw new Error(`PCDWriter: ${t} attribute is required`);return e}function oo(r,t,e){return r.value[t*r.size+e]||0}function u2(r,t){let e=new Uint8Array(4);return e[0]=Tm(r,t,0),e[1]=Tm(r,t,1),e[2]=Tm(r,t,2),new DataView(e.buffer).getFloat32(0,!0)}function Tm(r,t,e){let n=oo(r,t,e),s=r.normalized||n<=1?n*255:n;return Math.max(0,Math.min(255,Math.round(s)))}var aa={name:"PLY",id:"ply",module:"pointclouds",encoding:"text",format:"ply",extensions:["ply"],mimeTypes:["text/plain","application/octet-stream"],text:!0,binary:!0,tests:["ply"]};js();var OL=typeof __VERSION__<"u"?__VERSION__:"latest";async function NL(){let{PLYLoaderWithParser:r}=await Promise.resolve().then(()=>(Gm(),Vm));return r}var qm={dataType:null,batchType:null,...aa,version:OL,worker:!0,workerInBatches:!0,serializeWorkerResult:re,options:{ply:{shape:"arrow-table",colorFormat:"uint8norm"}},preload:NL},vx=qm;or();var UL=typeof __VERSION__<"u"?__VERSION__:"latest",Ix={...aa,dataType:null,batchType:null,version:UL,options:{ply:{}},text:!0,encode:async(r,t)=>Sx(r,t),encodeSync:Sx,encodeTextSync:Bx};function Sx(r,t){let e=Bx(r,t);return new TextEncoder().encode(e).buffer}function Bx(r,t){let e=ee(RL(r)),n=PL(e,"POSITION"),s=e.attributes.NORMAL,i=e.attributes.TEXCOORD_0,o=e.attributes.COLOR_0,a=zL(e),c=n.value.length/n.size,l=VL(e,c),u=kL(c,l.length/3,!!s,!!i,!!o,a),f=[];for(let h=0;h<c;h++){let m=[ln(n,h,0),ln(n,h,1),ln(n,h,2)];s&&m.push(ln(s,h,0),ln(s,h,1),ln(s,h,2)),i&&m.push(ln(i,h,0),ln(i,h,1)),o&&m.push(Wm(o,h,0),Wm(o,h,1),Wm(o,h,2));for(let[,y]of a)m.push(ln(y,h,0));f.push(m.join(" "))}for(let h=0;h<l.length;h+=3)f.push(`3 ${l[h]} ${l[h+1]} ${l[h+2]}`);return`${u.concat(f).join(`
|
|
44
44
|
`)}
|
|
45
|
-
`}function
|
|
45
|
+
`}function RL(r){return"shape"in r&&r.shape==="arrow-table"?r:Oe(r,"arrow-table")}function PL(r,t){let e=r.attributes[t];if(!e)throw new Error(`PLYWriter: ${t} attribute is required`);return e}function kL(r,t,e,n,s,i){let o=["ply","format ascii 1.0","comment generated by loaders.gl",`element vertex ${r}`,"property float x","property float y","property float z"];e&&o.push("property float nx","property float ny","property float nz"),n&&o.push("property float s","property float t"),s&&o.push("property uchar red","property uchar green","property uchar blue");for(let[a]of i)o.push(`property float ${a}`);return t>0&&o.push(`element face ${t}`,"property list uchar int vertex_indices"),o.push("end_header"),o}function zL(r){let t=new Set(["POSITION","NORMAL","TEXCOORD_0","COLOR_0"]);return Object.entries(r.attributes).filter(([e,n])=>!t.has(e)&&n.size===1)}function ln(r,t,e){return r.value[t*r.size+e]||0}function Wm(r,t,e){let n=ln(r,t,e),s=r.normalized||n<=1?n*255:n;return Math.max(0,Math.min(255,Math.round(s)))}function VL(r,t){if(r.indices?.value?.length)return Array.from(r.indices.value);if(r.mode!==4&&r.topology!=="triangle-list")return[];let e=[];for(let n=0;n+2<t;n+=3)e.push(n,n+1,n+2);return e}return Dx(GL);})();
|
|
46
46
|
/** Parse compressed PCD data in in binary_compressed form ( https://pointclouds.org/documentation/tutorials/pcd_file_format.html)
|
|
47
47
|
* from https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/PCDLoader.js
|
|
48
48
|
* @license MIT (http://opensource.org/licenses/MIT)
|