@loaders.gl/ply 4.4.0-alpha.10 → 4.4.0-alpha.12

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.min.js CHANGED
@@ -16,6 +16,6 @@ return true;`)}function $u(r){return typeof r!="bigint"?pe(r):`${pe(r)}n`}functi
16
16
  ]`}concat(...t){let e=this.schema,i=this.data.concat(t.flatMap(({data:n})=>n));return new et(e,i.map(n=>new Y(e,n)))}slice(t,e){let i=this.schema;[t,e]=Ni({length:this.numRows},t,e);let n=ts(this.data,this._offsets,t,e);return new et(i,n.map(s=>new Y(i,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){let e=this.data.map(i=>i.children[t]);if(e.length===0){let{type:i}=this.schema.fields[t],n=D({type:i,length:0,nullCount:0});e.push(n._changeLengthAndBackfillNullBitmap(this.numRows))}return new F(e)}return null}setChild(t,e){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(n=>n.name===t),e)}setChildAt(t,e){let i=this.schema,n=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new F([D({type:new ft,length:this.numRows})]));let s=i.fields.slice(),o=s[t].clone({type:e.type}),a=this.schema.fields.map((c,l)=>this.getChildAt(l));[s[t],a[t]]=[o,e],[i,n]=Ds(i,a)}return new et(i,n)}select(t){let e=this.schema.fields.reduce((i,n,s)=>i.set(n.name,s),new Map);return this.selectAt(t.map(i=>e.get(i)).filter(i=>i>-1))}selectAt(t){let e=this.schema.selectAt(t),i=this.batches.map(n=>n.selectAt(t));return new et(e,i)}assign(t){let e=this.schema.fields,[i,n]=t.schema.fields.reduce((a,c,l)=>{let[d,f]=a,k=e.findIndex(R=>R.name===c.name);return~k?f[k]=l:d.push(l),a},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((a,c)=>[c,n[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...i.map(a=>t.getChildAt(a))].filter(Boolean);return new et(...Ds(s,o))}};Bc=Symbol.toStringTag;et[Bc]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=ai(Ri),r.get=ai(st.getVisitFn(u.Struct)),r.set=es(mt.getVisitFn(u.Struct)),r.indexOf=rs(vr.getVisitFn(u.Struct)),"Table"))(et.prototype);var Dc,Y=class{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof U))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=D({nullCount:0,type:new j(this.schema.fields),children:this.schema.fields.map(e=>D({type:e.type,nullCount:0}))})]=t,!(this.data instanceof N))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Ac(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:i,children:n,length:s}=Object.keys(e).reduce((c,l,d)=>(c.children[d]=e[l],c.length=Math.max(c.length,e[l].length),c.fields[d]=T.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new U(i),a=D({type:new j(i),length:s,children:n,nullCount:0});[this.schema,this.data]=Ac(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=Tc(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 st.visit(this.data,t)}at(t){return this.get(yr(t,this.numRows))}set(t,e){return mt.visit(this.data,t,e)}indexOf(t,e){return vr.visit(this.data,t,e)}[Symbol.iterator](){return ci.visit(new F([this.data]))}toArray(){return[...this]}concat(...t){return new et(this.schema,[this,...t])}slice(t,e){let[i]=new F([this.data]).slice(t,e).data;return new Y(this.schema,i)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(i=>i.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new F([this.data.children[t]]):null}setChild(t,e){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(n=>n.name===t),e)}setChildAt(t,e){let i=this.schema,n=this.data;if(t>-1&&t<this.numCols){e||(e=new F([D({type:new ft,length:this.numRows})]));let s=i.fields.slice(),o=n.children.slice(),a=s[t].clone({type:e.type});[s[t],o[t]]=[a,e.data[0]],i=new U(s,new Map(this.schema.metadata)),n=D({type:new j(s),children:o})}return new Y(i,n)}select(t){let e=this.schema.select(t),i=new j(e.fields),n=[];for(let s of t){let o=this.schema.fields.findIndex(a=>a.name===s);~o&&(n[o]=this.data.children[o])}return new Y(e,D({type:i,length:this.numRows,children:n}))}selectAt(t){let e=this.schema.selectAt(t),i=t.map(s=>this.data.children[s]).filter(Boolean),n=D({type:new j(e.fields),length:this.numRows,children:i});return new Y(e,n)}};Dc=Symbol.toStringTag;Y[Dc]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Y.prototype);function Ac(r,t,e=t.reduce((i,n)=>Math.max(i,n.length),0)){var i;let n=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(let[a,c]of r.fields.entries()){let l=t[a];(!l||l.length!==e)&&(n[a]=c.clone({nullable:!0}),s[a]=(i=l?._changeLengthAndBackfillNullBitmap(e))!==null&&i!==void 0?i:D({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(n),D({type:new j(n),length:e,children:s})]}function Tc(r,t,e=new Map){var i,n;if(((i=r?.length)!==null&&i!==void 0?i:0)>0&&r?.length===t?.length)for(let s=-1,o=r.length;++s<o;){let{type:a}=r[s],c=t[s];for(let l of[c,...((n=c?.dictionary)===null||n===void 0?void 0:n.data)||[]])Tc(a.children,l?.children,e);if(h.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 Fr=class extends Y{constructor(t){let e=t.fields.map(n=>D({type:n.type})),i=D({type:new j(t.fields),nullCount:0,children:e});super(t,i)}};var rt=class{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 rt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new rt).__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):P.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):E.NONE}header(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){let i=this.bb.__offset(this.bb_pos,12);return i?(e||new J).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,P.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,E.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,i,n,s,o){return rt.startMessage(t),rt.addVersion(t,e),rt.addHeaderType(t,i),rt.addHeader(t,n),rt.addBodyLength(t,s),rt.addCustomMetadata(t,o),rt.endMessage(t)}};var Oo=class extends g{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return Te.startNull(e),Te.endNull(e)}visitInt(t,e){return lt.startInt(e),lt.addBitWidth(e,t.bitWidth),lt.addIsSigned(e,t.isSigned),lt.endInt(e)}visitFloat(t,e){return Lt.startFloatingPoint(e),Lt.addPrecision(e,t.precision),Lt.endFloatingPoint(e)}visitBinary(t,e){return Se.startBinary(e),Se.endBinary(e)}visitLargeBinary(t,e){return Be.startLargeBinary(e),Be.endLargeBinary(e)}visitBool(t,e){return xe.startBool(e),xe.endBool(e)}visitUtf8(t,e){return Fe.startUtf8(e),Fe.endUtf8(e)}visitLargeUtf8(t,e){return Ae.startLargeUtf8(e),Ae.endLargeUtf8(e)}visitDecimal(t,e){return ut.startDecimal(e),ut.addScale(e,t.scale),ut.addPrecision(e,t.precision),ut.addBitWidth(e,t.bitWidth),ut.endDecimal(e)}visitDate(t,e){return Tt.startDate(e),Tt.addUnit(e,t.unit),Tt.endDate(e)}visitTime(t,e){return bt.startTime(e),bt.addUnit(e,t.unit),bt.addBitWidth(e,t.bitWidth),bt.endTime(e)}visitTimestamp(t,e){let i=t.timezone&&e.createString(t.timezone)||void 0;return _t.startTimestamp(e),_t.addUnit(e,t.unit),i!==void 0&&_t.addTimezone(e,i),_t.endTimestamp(e)}visitInterval(t,e){return Nt.startInterval(e),Nt.addUnit(e,t.unit),Nt.endInterval(e)}visitDuration(t,e){return Ot.startDuration(e),Ot.addUnit(e,t.unit),Ot.endDuration(e)}visitList(t,e){return De.startList(e),De.endList(e)}visitStruct(t,e){return Oe.startStruct_(e),Oe.endStruct_(e)}visitUnion(t,e){dt.startTypeIdsVector(e,t.typeIds.length);let i=dt.createTypeIdsVector(e,t.typeIds);return dt.startUnion(e),dt.addMode(e,t.mode),dt.addTypeIds(e,i),dt.endUnion(e)}visitDictionary(t,e){let i=this.visit(t.indices,e);return Jt.startDictionaryEncoding(e),Jt.addId(e,BigInt(t.id)),Jt.addIsOrdered(e,t.isOrdered),i!==void 0&&Jt.addIndexType(e,i),Jt.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Ft.startFixedSizeBinary(e),Ft.addByteWidth(e,t.byteWidth),Ft.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Mt.startFixedSizeList(e),Mt.addListSize(e,t.listSize),Mt.endFixedSizeList(e)}visitMap(t,e){return Ut.startMap(e),Ut.addKeysSorted(e,t.keysSorted),Ut.endMap(e)}},Ts=new Oo;function Lc(r,t=new Map){return new U(nd(r,t),Os(r.metadata),t)}function Fo(r){return new yt(r.count,Uc(r.columns),Ec(r.columns))}function Nc(r){return new Yt(Fo(r.data),r.id,r.isDelta)}function nd(r,t){return(r.fields||[]).filter(Boolean).map(e=>T.fromJSON(e,t))}function Oc(r,t){return(r.children||[]).filter(Boolean).map(e=>T.fromJSON(e,t))}function Uc(r){return(r||[]).reduce((t,e)=>[...t,new ae(e.count,sd(e.VALIDITY)),...Uc(e.children)],[])}function Ec(r,t=[]){for(let e=-1,i=(r||[]).length;++e<i;){let n=r[e];n.VALIDITY&&t.push(new Wt(t.length,n.VALIDITY.length)),n.TYPE_ID&&t.push(new Wt(t.length,n.TYPE_ID.length)),n.OFFSET&&t.push(new Wt(t.length,n.OFFSET.length)),n.DATA&&t.push(new Wt(t.length,n.DATA.length)),t=Ec(n.children,t)}return t}function sd(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function Rc(r,t){let e,i,n,s,o,a;return!t||!(s=r.dictionary)?(o=Mc(r,Oc(r,t)),n=new T(r.name,o,r.nullable,Os(r.metadata))):t.has(e=s.id)?(i=(i=s.indexType)?Fc(i):new Gt,a=new kt(t.get(e),i,e,s.isOrdered),n=new T(r.name,a,r.nullable,Os(r.metadata))):(i=(i=s.indexType)?Fc(i):new Gt,t.set(e,o=Mc(r,Oc(r,t))),a=new kt(o,i,e,s.isOrdered),n=new T(r.name,a,r.nullable,Os(r.metadata))),n||null}function Os(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function Fc(r){return new tt(r.isSigned,r.bitWidth)}function Mc(r,t){let e=r.type.name;switch(e){case"NONE":return new ft;case"null":return new ft;case"binary":return new ee;case"largebinary":return new Me;case"utf8":return new re;case"largeutf8":return new Le;case"bool":return new ie;case"list":return new Vt((t||[])[0]);case"struct":return new j(t||[]);case"struct_":return new j(t||[])}switch(e){case"int":{let i=r.type;return new tt(i.isSigned,i.bitWidth)}case"floatingpoint":{let i=r.type;return new Rt(W[i.precision])}case"decimal":{let i=r.type;return new ne(i.scale,i.precision,i.bitWidth)}case"date":{let i=r.type;return new Zt(K[i.unit])}case"time":{let i=r.type;return new xt(p[i.unit],i.bitWidth)}case"timestamp":{let i=r.type;return new Bt(p[i.unit],i.timezone)}case"interval":{let i=r.type;return new Kt(Q[i.unit])}case"duration":{let i=r.type;return new Ne(p[i.unit])}case"union":{let i=r.type,[n,...s]=(i.mode+"").toLowerCase(),o=n.toUpperCase()+s.join("");return new se($[o],i.typeIds||[],t||[])}case"fixedsizebinary":{let i=r.type;return new Ue(i.byteWidth)}case"fixedsizelist":{let i=r.type;return new wt(i.listSize,(t||[])[0])}case"map":{let i=r.type;return new Ct((t||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var od=ke,ad=St,at=class{static fromJSON(t,e){let i=new at(0,P.V5,e);return i._createHeader=cd(t,e),i}static decode(t){t=new ad(S(t));let e=rt.getRootAsMessage(t),i=e.bodyLength(),n=e.version(),s=e.headerType(),o=new at(i,n,s);return o._createHeader=ld(e,s),o}static encode(t){let e=new od,i=-1;return t.isSchema()?i=U.encode(e,t.header()):t.isRecordBatch()?i=yt.encode(e,t.header()):t.isDictionaryBatch()&&(i=Yt.encode(e,t.header())),rt.startMessage(e),rt.addVersion(e,P.V5),rt.addHeader(e,i),rt.addHeaderType(e,t.headerType),rt.addBodyLength(e,BigInt(t.bodyLength)),rt.finishMessageBuffer(e,rt.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof U)return new at(0,P.V5,E.Schema,t);if(t instanceof yt)return new at(e,P.V5,E.RecordBatch,t);if(t instanceof Yt)return new at(e,P.V5,E.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===E.Schema}isRecordBatch(){return this.headerType===E.RecordBatch}isDictionaryBatch(){return this.headerType===E.DictionaryBatch}constructor(t,e,i,n){this._version=e,this._headerType=i,this.body=new Uint8Array(0),n&&(this._createHeader=()=>n),this._bodyLength=V(t)}},yt=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,i){this._nodes=e,this._buffers=i,this._length=V(t)}},Yt=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,e,i=!1){this._data=t,this._isDelta=i,this._id=V(e)}},Wt=class{constructor(t,e){this.offset=V(t),this.length=V(e)}},ae=class{constructor(t,e){this.length=V(t),this.nullCount=V(e)}};function cd(r,t){return()=>{switch(t){case E.Schema:return U.fromJSON(r);case E.RecordBatch:return yt.fromJSON(r);case E.DictionaryBatch:return Yt.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${E[t]}, type: ${t} }`)}}function ld(r,t){return()=>{switch(t){case E.Schema:return U.decode(r.header(new q),new Map,r.version());case E.RecordBatch:return yt.decode(r.header(new gt),r.version());case E.DictionaryBatch:return Yt.decode(r.header(new te),r.version())}throw new Error(`Unrecognized Message type: { name: ${E[t]}, type: ${t} }`)}}T.encode=wd;T.decode=bd;T.fromJSON=Rc;U.encode=_d;U.decode=ud;U.fromJSON=Lc;yt.encode=vd;yt.decode=dd;yt.fromJSON=Fo;Yt.encode=Id;Yt.decode=fd;Yt.fromJSON=Nc;ae.encode=Sd;ae.decode=pd;Wt.encode=xd;Wt.decode=hd;function ud(r,t=new Map,e=P.V5){let i=gd(r,t);return new U(i,Fs(r),t,e)}function dd(r,t=P.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new yt(r.length(),md(r),yd(r,t))}function fd(r,t=P.V5){return new Yt(yt.decode(r.data(),t),r.id(),r.isDelta())}function hd(r){return new Wt(r.offset(),r.length())}function pd(r){return new ae(r.length(),r.nullCount())}function md(r){let t=[];for(let e,i=-1,n=-1,s=r.nodesLength();++i<s;)(e=r.nodes(i))&&(t[++n]=ae.decode(e));return t}function yd(r,t){let e=[];for(let i,n=-1,s=-1,o=r.buffersLength();++n<o;)(i=r.buffers(n))&&(t<P.V4&&(i.bb_pos+=8*(n+1)),e[++s]=Wt.decode(i));return e}function gd(r,t){let e=[];for(let i,n=-1,s=-1,o=r.fieldsLength();++n<o;)(i=r.fields(n))&&(e[++s]=T.decode(i,t));return e}function Vc(r,t){let e=[];for(let i,n=-1,s=-1,o=r.childrenLength();++n<o;)(i=r.children(n))&&(e[++s]=T.decode(i,t));return e}function bd(r,t){let e,i,n,s,o,a;return!t||!(a=r.dictionary())?(n=kc(r,Vc(r,t)),i=new T(r.name(),n,r.nullable(),Fs(r))):t.has(e=V(a.id()))?(s=(s=a.indexType())?Cc(s):new Gt,o=new kt(t.get(e),s,e,a.isOrdered()),i=new T(r.name(),o,r.nullable(),Fs(r))):(s=(s=a.indexType())?Cc(s):new Gt,t.set(e,n=kc(r,Vc(r,t))),o=new kt(n,s,e,a.isOrdered()),i=new T(r.name(),o,r.nullable(),Fs(r))),i||null}function Fs(r){let t=new Map;if(r)for(let e,i,n=-1,s=Math.trunc(r.customMetadataLength());++n<s;)(e=r.customMetadata(n))&&(i=e.key())!=null&&t.set(i,e.value());return t}function Cc(r){return new tt(r.isSigned(),r.bitWidth())}function kc(r,t){let e=r.typeType();switch(e){case H.NONE:return new ft;case H.Null:return new ft;case H.Binary:return new ee;case H.LargeBinary:return new Me;case H.Utf8:return new re;case H.LargeUtf8:return new Le;case H.Bool:return new ie;case H.List:return new Vt((t||[])[0]);case H.Struct_:return new j(t||[])}switch(e){case H.Int:{let i=r.type(new lt);return new tt(i.isSigned(),i.bitWidth())}case H.FloatingPoint:{let i=r.type(new Lt);return new Rt(i.precision())}case H.Decimal:{let i=r.type(new ut);return new ne(i.scale(),i.precision(),i.bitWidth())}case H.Date:{let i=r.type(new Tt);return new Zt(i.unit())}case H.Time:{let i=r.type(new bt);return new xt(i.unit(),i.bitWidth())}case H.Timestamp:{let i=r.type(new _t);return new Bt(i.unit(),i.timezone())}case H.Interval:{let i=r.type(new Nt);return new Kt(i.unit())}case H.Duration:{let i=r.type(new Ot);return new Ne(i.unit())}case H.Union:{let i=r.type(new dt);return new se(i.mode(),i.typeIdsArray()||[],t||[])}case H.FixedSizeBinary:{let i=r.type(new Ft);return new Ue(i.byteWidth())}case H.FixedSizeList:{let i=r.type(new Mt);return new wt(i.listSize(),(t||[])[0])}case H.Map:{let i=r.type(new Ut);return new Ct((t||[])[0],i.keysSorted())}}throw new Error(`Unrecognized type: "${H[e]}" (${e})`)}function _d(r,t){let e=t.fields.map(s=>T.encode(r,s));q.startFieldsVector(r,e.length);let i=q.createFieldsVector(r,e),n=t.metadata&&t.metadata.size>0?q.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let a=r.createString(`${s}`),c=r.createString(`${o}`);return J.startKeyValue(r),J.addKey(r,a),J.addValue(r,c),J.endKeyValue(r)})):-1;return q.startSchema(r),q.addFields(r,i),q.addEndianness(r,Bd?qe.Little:qe.Big),n!==-1&&q.addCustomMetadata(r,n),q.endSchema(r)}function wd(r,t){let e=-1,i=-1,n=-1,s=t.type,o=t.typeId;h.isDictionary(s)?(o=s.dictionary.typeId,n=Ts.visit(s,r),i=Ts.visit(s.dictionary,r)):i=Ts.visit(s,r);let a=(s.children||[]).map(d=>T.encode(r,d)),c=nt.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?nt.createCustomMetadataVector(r,[...t.metadata].map(([d,f])=>{let k=r.createString(`${d}`),R=r.createString(`${f}`);return J.startKeyValue(r),J.addKey(r,k),J.addValue(r,R),J.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),nt.startField(r),nt.addType(r,i),nt.addTypeType(r,o),nt.addChildren(r,c),nt.addNullable(r,!!t.nullable),e!==-1&&nt.addName(r,e),n!==-1&&nt.addDictionary(r,n),l!==-1&&nt.addCustomMetadata(r,l),nt.endField(r)}function vd(r,t){let e=t.nodes||[],i=t.buffers||[];gt.startNodesVector(r,e.length);for(let o of e.slice().reverse())ae.encode(r,o);let n=r.endVector();gt.startBuffersVector(r,i.length);for(let o of i.slice().reverse())Wt.encode(r,o);let s=r.endVector();return gt.startRecordBatch(r),gt.addLength(r,BigInt(t.length)),gt.addNodes(r,n),gt.addBuffers(r,s),gt.endRecordBatch(r)}function Id(r,t){let e=yt.encode(r,t.data);return te.startDictionaryBatch(r),te.addId(r,BigInt(t.id)),te.addIsDelta(r,t.isDelta),te.addData(r,e),te.endDictionaryBatch(r)}function Sd(r,t){return Pr.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function xd(r,t){return kr.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var Bd=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var Lo=r=>`Expected ${E[r]} Message in stream, but was null or length 0.`,No=r=>`Header pointer of flatbuffer-encoded ${E[r]} Message is null or length 0.`,Pc=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,zc=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,gi=class{constructor(t){this.source=t instanceof Ve?t:new Ve(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?G:t.value===-1&&(t=this.readMetadataLength()).done?G:(t=this.readMetadata(t.value)).done?G: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(Lo(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=S(this.source.read(t));if(e.byteLength<t)throw new Error(zc(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=E.Schema,i=this.readMessage(e),n=i?.header();if(t&&!n)throw new Error(No(e));return n}readMetadataLength(){let t=this.source.read(Ms),e=t&&new St(t),i=e?.readInt32(0)||0;return{done:i===0,value:i}}readMetadata(t){let e=this.source.read(t);if(!e)return G;if(e.byteLength<t)throw new Error(Pc(t,e.byteLength));return{done:!1,value:at.decode(e)}}},dn=class{constructor(t,e){this.source=t instanceof zt?t:In(t)?new ir(t,e):new zt(t)}[Symbol.asyncIterator](){return this}next(){return m(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?G:t.value===-1&&(t=yield this.readMetadataLength()).done?G:(t=yield this.readMetadata(t.value)).done?G:t})}throw(t){return m(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return m(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return m(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(Lo(t));return e.value})}readMessageBody(t){return m(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=S(yield this.source.read(t));if(e.byteLength<t)throw new Error(zc(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return m(this,arguments,void 0,function*(t=!1){let e=E.Schema,i=yield this.readMessage(e),n=i?.header();if(t&&!n)throw new Error(No(e));return n})}readMetadataLength(){return m(this,void 0,void 0,function*(){let t=yield this.source.read(Ms),e=t&&new St(t),i=e?.readInt32(0)||0;return{done:i===0,value:i}})}readMetadata(t){return m(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return G;if(e.byteLength<t)throw new Error(Pc(t,e.byteLength));return{done:!1,value:at.decode(e)}})}},fn=class extends gi{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Vi?t:new Vi(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:at.fromJSON(t.schema,E.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:at.fromJSON(e,E.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:at.fromJSON(e,E.RecordBatch)}}return this._body=[],G}readMessageBody(t){return e(this._body);function e(i){return(i||[]).reduce((n,s)=>[...n,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...e(s.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(Lo(t));return e.value}readSchema(){let t=E.Schema,e=this.readMessage(t),i=e?.header();if(!e||!i)throw new Error(No(t));return i}},Ms=4,Mo="ARROW1",bi=new Uint8Array(Mo.length);for(let r=0;r<Mo.length;r+=1)bi[r]=Mo.codePointAt(r);function Ls(r,t=0){for(let e=-1,i=bi.length;++e<i;)if(bi[e]!==r[t+e])return!1;return!0}var _i=bi.length,Uo=_i+Ms,jc=_i*2+Ms;var Dt=class extends Sr{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 le(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 pt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return pt.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 Dt?t:wn(t)?Dd(t):In(t)?Fd(t):le(t)?(()=>m(this,void 0,void 0,function*(){return yield Dt.from(yield t)}))():Sn(t)||Bi(t)||Bn(t)||qt(t)?Od(new zt(t)):Td(new Ve(t))}static readAll(t){return t instanceof Dt?t.isSync()?Wc(t):Yc(t):wn(t)||ArrayBuffer.isView(t)||ue(t)||vn(t)?Wc(t):Yc(t)}},Ge=class extends Dt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return $t(this,arguments,function*(){yield M(yield*Vr(ce(this[Symbol.iterator]())))})}},Mr=class extends Dt{constructor(t){super(t),this._impl=t}readAll(){return m(this,void 0,void 0,function*(){var t,e,i,n;let s=new Array;try{for(var o=!0,a=ce(this),c;c=yield a.next(),t=c.done,!t;o=!0){n=c.value,o=!1;let l=n;s.push(l)}}catch(l){e={error:l}}finally{try{!o&&!t&&(i=a.return)&&(yield i.call(a))}finally{if(e)throw e.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Lr=class extends Ge{constructor(t){super(t),this._impl=t}},Ns=class extends Mr{constructor(t){super(t),this._impl=t}},Us=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){let i=this._loadVectors(t,e,this.schema.fields),n=D({type:new j(this.schema.fields),length:t.length,children:i});return new Y(this.schema,n)}_loadDictionaryBatch(t,e){let{id:i,isDelta:n}=t,{dictionaries:s,schema:o}=this,a=s.get(i),c=o.dictionaries.get(i),l=this._loadVectors(t.data,e,[c]);return(a&&n?a.concat(new F(l)):new F(l)).memoize()}_loadVectors(t,e,i){return new Pi(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}},wi=class extends Us{constructor(t,e){super(e),this._reader=wn(t)?new fn(this._handle=t):new gi(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=$c(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):G}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):G}next(){if(this.closed)return G;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let i=t.header(),n=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let i=t.header(),n=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Fr(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},vi=class extends Us{constructor(t,e){super(e),this._reader=new dn(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return m(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 m(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=$c(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return m(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):G})}return(t){return m(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):G})}next(){return m(this,void 0,void 0,function*(){if(this.closed)return G;let t,{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let i=t.header(),n=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let i=t.header(),n=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Fr(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return m(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Es=class extends wi{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,e){super(t instanceof Ci?t:new Ci(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&this._handle.seek(i.offset)){let n=this._reader.readMessage(E.RecordBatch);if(n?.isRecordBatch()){let s=n.header(),o=this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;let i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&this._handle.seek(i.offset)){let n=this._reader.readMessage(E.DictionaryBatch);if(n?.isDictionaryBatch()){let s=n.header(),o=this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:t}=this,e=t.size-Uo,i=t.readInt32(e),n=t.readAt(e-i,i);return je.decode(n)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(i&&this._handle.seek(i.offset))return this._reader.readMessage(t)}return null}},Eo=class extends vi{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...e){let i=typeof e[0]!="number"?e.shift():void 0,n=e[0]instanceof Map?e.shift():void 0;super(t instanceof ir?t:new ir(t,i),n)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return m(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return m(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(E.RecordBatch);if(n?.isRecordBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return m(this,void 0,void 0,function*(){var e;let i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(E.DictionaryBatch);if(n?.isDictionaryBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return m(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-Uo,i=yield t.readInt32(e),n=yield t.readAt(e-i,i);return je.decode(n)})}_readNextMessageAndValidate(t){return m(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})}},Ro=class extends wi{constructor(t,e){super(t,e)}_loadVectors(t,e,i){return new ss(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}};function $c(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Wc(r){let t=Dt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Yc(r){return $t(this,arguments,function*(){let e=yield M(Dt.from(r));try{if(!(yield M(e.open({autoDestroy:!1}))).closed)do yield yield M(e);while(!(yield M(e.reset().open())).closed)}finally{yield M(e.cancel())}})}function Dd(r){return new Ge(new Ro(r))}function Td(r){let t=r.peek(_i+7&-8);return t&&t.byteLength>=4?Ls(t)?new Lr(new Es(r.read())):new Ge(new wi(r)):new Ge(new wi(function*(){}()))}function Od(r){return m(this,void 0,void 0,function*(){let t=yield r.peek(_i+7&-8);return t&&t.byteLength>=4?Ls(t)?new Lr(new Es(yield r.read())):new Mr(new vi(r)):new Mr(new vi(function(){return $t(this,arguments,function*(){})}()))})}function Fd(r){return m(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new ir(r,t);return t>=jc&&Ls(yield e.readAt(0,_i+7&-8))?new Ns(new Eo(e)):new Mr(new vi(e))})}var Z=class extends g{static assemble(...t){let e=n=>n.flatMap(s=>Array.isArray(s)?e(s):s instanceof Y?s.data.children:s.data),i=new Z;return i.visitMany(e(t)),i}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof F)return this.visitMany(t.data),this;let{type:e}=t;if(!h.isDictionary(e)){let{length:i}=t;if(i>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(h.isUnion(e))this.nodes.push(new ae(i,0));else{let{nullCount:n}=t;h.isNull(e)||_e.call(this,n<=0?new Uint8Array(0):br(t.offset,i,t.nullBitmap)),this.nodes.push(new ae(i,n))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function _e(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new Wt(this._byteLength,t)),this._byteLength+=t,this}function Md(r){var t;let{type:e,length:i,typeIds:n,valueOffsets:s}=r;if(_e.call(this,n),e.mode===$.Sparse)return Vo.call(this,r);if(e.mode===$.Dense){if(r.offset<=0)return _e.call(this,s),Vo.call(this,r);{let o=new Int32Array(i),a=Object.create(null),c=Object.create(null);for(let l,d,f=-1;++f<i;)(l=n[f])!==void 0&&((d=a[l])===void 0&&(d=a[l]=s[f]),o[f]=s[f]-d,c[l]=((t=c[l])!==null&&t!==void 0?t:0)+1);_e.call(this,o),this.visitMany(r.children.map((l,d)=>{let f=e.typeIds[d],k=a[f],R=c[f];return l.slice(k,Math.min(i,R))}))}}return this}function Ld(r){let t;return r.nullCount>=r.length?_e.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?_e.call(this,br(r.offset,r.length,t)):_e.call(this,_r(r.values))}function Ze(r){return _e.call(this,r.values.subarray(0,r.length*r.stride))}function Rs(r){let{length:t,values:e,valueOffsets:i}=r,n=V(i[0]),s=V(i[t]),o=Math.min(s-n,e.byteLength-n);return _e.call(this,Dn(-n,t+1,i)),_e.call(this,e.subarray(n,n+o)),this}function Co(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:i,[t]:n}=e;return _e.call(this,Dn(-i,t+1,e)),this.visit(r.children[0].slice(i,n-i))}return this.visit(r.children[0])}function Vo(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}Z.prototype.visitBool=Ld;Z.prototype.visitInt=Ze;Z.prototype.visitFloat=Ze;Z.prototype.visitUtf8=Rs;Z.prototype.visitLargeUtf8=Rs;Z.prototype.visitBinary=Rs;Z.prototype.visitLargeBinary=Rs;Z.prototype.visitFixedSizeBinary=Ze;Z.prototype.visitDate=Ze;Z.prototype.visitTimestamp=Ze;Z.prototype.visitTime=Ze;Z.prototype.visitDecimal=Ze;Z.prototype.visitList=Co;Z.prototype.visitStruct=Vo;Z.prototype.visitUnion=Md;Z.prototype.visitInterval=Ze;Z.prototype.visitDuration=Ze;Z.prototype.visitFixedSizeList=Co;Z.prototype.visitMap=Co;var Nr=class extends Sr{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new Re,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,It(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return le(t)?t.then(e=>this.writeAll(e)):qt(t)?Po(this,t):ko(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 Re?this._sink=t:(this._sink=new Re,t&&aa(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&ca(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||!Or(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 et&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof Y&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!Or(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof Y?t instanceof Fr||this._writeRecordBatch(t):t instanceof et?this.writeAll(t.batches):ue(t)&&this.writeAll(t)}_writeMessage(t,e=8){let i=e-1,n=at.encode(t),s=n.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+i&~i,c=a-s-o;return t.headerType===E.RecordBatch?this._recordBatchBlocks.push(new be(a,t.bodyLength,this._position)):t.headerType===E.DictionaryBatch&&this._dictionaryBlocks.push(new be(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(n),this._writePadding(c)}_write(t){if(this._started){let e=S(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(at.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(bi)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:i,bufferRegions:n,buffers:s}=Z.assemble(t),o=new yt(t.numRows,i,n),a=at.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,i=!1){let{byteLength:n,nodes:s,bufferRegions:o,buffers:a}=Z.assemble(new F([t])),c=new yt(t.length,s,o),l=new Yt(c,e,i),d=at.from(l,n);return this._writeMessage(d)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,i,n;for(let s=-1,o=t.length;++s<o;)(e=t[s])&&(i=e.byteLength)>0&&(this._write(e),(n=(i+7&-8)-i)>0&&this._writePadding(n));return this}_writeDictionaries(t){var e,i;for(let[n,s]of t.dictionaries){let o=(e=s?.data)!==null&&e!==void 0?e:[],a=this._seenDictionaries.get(n),c=(i=this._dictionaryDeltaOffsets.get(n))!==null&&i!==void 0?i:0;if(!a||a.data[0]!==o[0])for(let[l,d]of o.entries())this._writeDictionaryBatch(d,n,l>0);else if(c<o.length)for(let l of o.slice(c))this._writeDictionaryBatch(l,n,!0);this._seenDictionaries.set(n,s),this._dictionaryDeltaOffsets.set(n,o.length)}return this}},Ur=class extends Nr{static writeAll(t,e){let i=new Ur(e);return le(t)?t.then(n=>i.writeAll(n)):qt(t)?Po(i,t):ko(i,t)}},Er=class extends Nr{static writeAll(t){let e=new Er;return le(t)?t.then(i=>e.writeAll(i)):qt(t)?Po(e,t):ko(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,i=!1){if(!i&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,i)}_writeFooter(t){let e=je.encode(new je(t,P.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function ko(r,t){let e=t;t instanceof et&&(e=t.batches,r.reset(void 0,t.schema));for(let i of e)r.write(i);return r.finish()}function Po(r,t){return m(this,void 0,void 0,function*(){var e,i,n,s,o,a,c;try{for(e=!0,i=ce(t);n=yield i.next(),s=n.done,!s;e=!0){c=n.value,e=!1;let l=c;r.write(l)}}catch(l){o={error:l}}finally{try{!e&&!s&&(a=i.return)&&(yield a.call(i))}finally{if(o)throw o.error}}return r.finish()})}function Hc(r,t){if(qt(r))return Ud(r,t);if(ue(r))return Nd(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Nd(r,t){let e=null,i=t?.type==="bytes"||!1,n=t?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){s(o,e||(e=r[Symbol.iterator]()))},pull(o){e?s(o,e):o.close()},cancel(){(e?.return&&e.return()||!0)&&(e=null)}}),Object.assign({highWaterMark:i?n:void 0},t));function s(o,a){let c,l=null,d=o.desiredSize||null;for(;!(l=a.next(i?d:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=S(l.value))&&(d!=null&&i&&(d=d-c.byteLength+1),l.value=c),o.enqueue(l.value),d!=null&&--d<=0)return;o.close()}}function Ud(r,t){let e=null,i=t?.type==="bytes"||!1,n=t?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return m(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return m(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return m(this,void 0,void 0,function*(){(e?.return&&(yield e.return())||!0)&&(e=null)})}}),Object.assign({highWaterMark:i?n:void 0},t));function s(o,a){return m(this,void 0,void 0,function*(){let c,l=null,d=o.desiredSize||null;for(;!(l=yield a.next(i?d:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=S(l.value))&&(d!=null&&i&&(d=d-c.byteLength+1),l.value=c),o.enqueue(l.value),d!=null&&--d<=0)return;o.close()})}}function Zc(r){return new zo(r)}var zo=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:i,["queueingStrategy"]:n="count"}=t,s=sa(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=Br(s),this._getSize=n!=="bytes"?Jc:Gc;let{["highWaterMark"]:o=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:a=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},i);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:c=>{this._maybeFlush(this._builder,this._controller=c)},start:c=>{this._maybeFlush(this._builder,this._controller=c)}},{highWaterMark:o,size:n!=="bytes"?Jc:Gc}),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)}},Jc=r=>{var t;return(t=r?.length)!==null&&t!==void 0?t:0},Gc=r=>{var t;return(t=r?.byteLength)!==null&&t!==void 0?t:0};function Vs(r,t){let e=new Re,i=null,n=new ReadableStream({cancel(){return m(this,void 0,void 0,function*(){yield e.close()})},start(a){return m(this,void 0,void 0,function*(){yield o(a,i||(i=yield s()))})},pull(a){return m(this,void 0,void 0,function*(){i?yield o(a,i):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:n};function s(){return m(this,void 0,void 0,function*(){return yield(yield Dt.from(e)).open(t)})}function o(a,c){return m(this,void 0,void 0,function*(){let l=a.desiredSize,d=null;for(;!(d=yield c.next()).done;)if(a.enqueue(d.value),l!=null&&--l<=0)return;a.close()})}}function Cs(r,t){let e=new this(r),i=new zt(e),n=new ReadableStream({cancel(){return m(this,void 0,void 0,function*(){yield i.cancel()})},pull(o){return m(this,void 0,void 0,function*(){yield s(o)})},start(o){return m(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:n};function s(o){return m(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield i.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}var Wd=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Qs),xo),yo),to),Hs),mo),Zs),{compareSchemas:Or,compareFields:Sc,compareTypes:xc});pt.toDOMStream=Hc;X.throughDOM=Zc;Dt.throughDOM=Vs;Lr.throughDOM=Vs;Ge.throughDOM=Vs;Nr.throughDOM=Cs;Er.throughDOM=Cs;Ur.throughDOM=Cs;function Kc(r){return new U(r.fields.map(t=>hn(t)),Xc(r.metadata))}function Xc(r){return r?new Map(Object.entries(r)):new Map}function hn(r){return new T(r.name,Wo(r.type),r.nullable,Xc(r.metadata))}function Wo(r){if(typeof r=="object")switch(r.type){case"decimal":return new ne(r.precision,r.scale,r.bitWidth);case"map":let t=r.children.map(n=>hn(n));return new Ct(t,r.keysSorted);case"list":let e=hn(r.children[0]);return new Vt(e);case"fixed-size-list":let i=hn(r.children[0]);return new wt(r.listSize,i);case"struct":return t=r.children.map(n=>hn(n)),new j(t);default:throw new Error("array type not supported")}switch(r){case"null":return new ft;case"binary":return new ee;case"bool":return new ie;case"int8":return new or;case"int16":return new ar;case"int32":return new Gt;case"int64":return new cr;case"uint8":return new lr;case"uint16":return new ur;case"uint32":return new dr;case"uint64":return new fr;case"float16":return new hr;case"float32":return new pr;case"float64":return new mr;case"utf8":return new re;case"date-day":return new Yr;case"date-millisecond":return new $r;case"time-second":return new Hr;case"time-millisecond":return new Jr;case"time-microsecond":return new Gr;case"time-nanosecond":return new Zr;case"timestamp-second":return new Kr;case"timestamp-millisecond":return new Xr;case"timestamp-microsecond":return new qr;case"timestamp-nanosecond":return new Qr;case"interval-daytime":return new ti;case"interval-yearmonth":return new ei;default:throw new Error("array type not supported")}}function Yo(r){let t=1/0,e=1/0,i=1/0,n=-1/0,s=-1/0,o=-1/0,a=r.POSITION?r.POSITION.value:[],c=a&&a.length;for(let l=0;l<c;l+=3){let d=a[l],f=a[l+1],k=a[l+2];t=d<t?d:t,e=f<e?f:e,i=k<i?k:i,n=d>n?d:n,s=f>s?f:s,o=k>o?k:o}return[[t,e,i],[n,s,o]]}function qc(r,t){let e=Yd(r,t),i=e.children[0].type,n={[Et.DATA]:r},s=new N(i,0,r.length,0,n);return new N(e,0,r.length/t,0,void 0,[s])}function Yd(r,t){let{type:e}=ia(r),i=Wo(e);return new wt(t,new T("value",i))}function $o(r,t){switch(t){case"columnar-table":return $d(r);case"arrow-table":return Hd(r);default:throw new Error(t)}}function $d(r){let t={};for(let[e,i]of Object.entries(r.attributes))t[e]=i.value;return{shape:"columnar-table",schema:r.schema,data:t}}function Hd(r,t){let{schema:e}=r,i=Kc(e),n=[];for(let d in r.attributes){let f=r.attributes[d],{value:k,size:R=1}=f,it=qc(k,R);n.push(it)}let s=new j(i.fields),o=n[0].length,a=new N(s,0,o,0,void 0,n),c=new Y(i,a),l=new et([c]);return{shape:"arrow-table",schema:e,data:l}}function Ho(r,t={}){return{fields:Jd(r),metadata:t}}function Qc(r,t,e){let i=Ps(t.value),n=e||tl(t);return{name:r,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:i}]},nullable:!1,metadata:n}}function Jd(r){let t=[];for(let e in r){let i=r[e];t.push(Qc(e,i))}return t}function tl(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()),t}function el(r,t){let e=Gd(r);return Ho(t,e)}function Gd(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 pn(r,t,e){let i=Zd(t),n=Yo(i),s=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=el(r,i),d={loader:"ply",loaderData:r,header:{vertexCount:s,boundingBox:n},schema:l,attributes:i,indices:{value:new Uint32Array(0),size:0},mode:a,topology:c};return t.indices.length>0&&(d.indices={value:new Uint32Array(t.indices),size:1}),d}function Zd(r){let t={};for(let e of Object.keys(r))switch(e){case"vertices":r.vertices.length>0&&(t.POSITION={value:new Float32Array(r.vertices),size:3});break;case"normals":r.normals.length>0&&(t.NORMAL={value:new Float32Array(r.normals),size:3});break;case"uvs":r.uvs.length>0&&(t.TEXCOORD_0={value:new Float32Array(r.uvs),size:2});break;case"colors":r.colors.length>0&&(t.COLOR_0={value:new Uint8Array(r.colors),size:3,normalized:!0});break;case"indices":break;default:r[e].length>0&&(t[e]={value:new Float32Array(r[e]),size:1});break}return t}function Ii(r,t={}){let e,i;if(r instanceof ArrayBuffer){let n=new TextDecoder().decode(r);e=rl(n,t),i=e.format==="ascii"?il(n,e):tf(r,e)}else e=rl(r,t),i=il(r,e);return pn(e,i)}function rl(r,t){let e=/ply([\s\S]*)end_header\s/,i="",n=0,s=e.exec(r);s!==null&&(i=s[1],n=s[0].length);let o=i.split(`
17
17
  `);return Kd(o,n,t)}function Kd(r,t,e){let i={comments:[],elements:[],headerLength:t},n,s,o=null;for(let a=0;a<r.length;a++){let c=r[a];if(c=c.trim(),c!=="")switch(s=c.split(/\s+/),n=s.shift(),c=s.join(" "),n){case"format":i.format=s[0],i.version=s[1];break;case"comment":i.comments.push(c);break;case"element":o&&i.elements.push(o),o={name:s[0],count:parseInt(s[1],10),properties:[]};break;case"property":if(o){let l=Xd(s);e?.propertyNameMapping&&l.name in e?.propertyNameMapping&&(l.name=e?.propertyNameMapping[l.name]),o.properties.push(l)}break;default:console.log("unhandled",n,s)}}return o&&i.elements.push(o),i}function nl(r){let t={indices:[],vertices:[],normals:[],uvs:[],colors:[]};for(let e of r.elements)if(e.name==="vertex")for(let i of e.properties)switch(i.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[i.name]=[];break}return t}function Xd(r){let t=r[0];switch(t){case"list":return{type:t,name:r[3],countType:r[1],itemType:r[2]};default:return{type:t,name:r[1]}}}function Jo(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 qd(r,t){let e=t.split(/\s+/),i={};for(let n=0;n<r.length;n++)if(r[n].type==="list"){let s=[],o=Jo(e.shift(),r[n].countType);for(let a=0;a<o;a++)s.push(Jo(e.shift(),r[n].itemType));i[r[n].name]=s}else i[r[n].name]=Jo(e.shift(),r[n].type);return i}function il(r,t){let e=nl(t),i,n=/end_header\s([\s\S]*)$/,s="";(i=n.exec(r))!==null&&(s=i[1]);let o=s.split(`
18
18
  `),a=0,c=0;for(let l=0;l<o.length;l++){let d=o[l];if(d=d.trim(),d!==""){c>=t.elements[a].count&&(a++,c=0);let f=qd(t.elements[a].properties,d);sl(e,t.elements[a].name,f),c++}}return e}function sl(r,t,e={}){if(t==="vertex")for(let i of Object.keys(e))switch(i){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[i].push(e[i])}else if(t==="face"){let i=e.vertex_indices||e.vertex_index;i.length===3?r.indices.push(i[0],i[1],i[2]):i.length===4&&(r.indices.push(i[0],i[1],i[3]),r.indices.push(i[1],i[2],i[3]))}}function Go(r,t,e,i){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,i),2];case"uint16":case"ushort":return[r.getUint16(t,i),2];case"int32":case"int":return[r.getInt32(t,i),4];case"uint32":case"uint":return[r.getUint32(t,i),4];case"float32":case"float":return[r.getFloat32(t,i),4];case"float64":case"double":return[r.getFloat64(t,i),8];default:throw new Error(e)}}function Qd(r,t,e,i){let n={},s,o=0;for(let a=0;a<e.length;a++)if(e[a].type==="list"){let c=[];s=Go(r,t+o,e[a].countType,i);let l=s[0];o+=s[1];for(let d=0;d<l;d++)s=Go(r,t+o,e[a].itemType,i),c.push(s[0]),o+=s[1];n[e[a].name]=c}else s=Go(r,t+o,e[a].type,i),n[e[a].name]=s[0],o+=s[1];return[n,o]}function tf(r,t){let e=nl(t),i=t.format==="binary_little_endian",n=new DataView(r,t.headerLength),s,o=0;for(let a=0;a<t.elements.length;a++){let c=t.elements[a].count;for(let l=0;l<c;l++){s=Qd(n,o,t.elements[a].properties,i),o+=s[1];let d=s[0];sl(e,t.elements[a].name,d)}}return e}async function*Zo(r,t={}){let e=new TextDecoder(void 0,t);for await(let i of r)yield typeof i=="string"?i:e.decode(i,{stream:!0})}async function*Ko(r){let t="";for await(let e of r){t+=e;let i;for(;(i=t.indexOf(`
19
- `))>=0;){let n=t.slice(0,i+1);t=t.slice(i+1),yield n}}t.length>0&&(yield t)}async function Xo(r,t){let e=rf(r);for(;;){let{done:i,value:n}=await e.next();if(i){e.return&&e.return();return}if(t(n))return}}async function*qo(r){for await(let t of r)yield ef(t)}function ef(r){if(r instanceof ArrayBuffer)return r;if(ArrayBuffer.isView(r)){let{buffer:t,byteOffset:e,byteLength:i}=r;return ol(t,e,i)}return ol(r)}function ol(r,t=0,e=r.byteLength-t){let i=new Uint8Array(r,t,e),n=new Uint8Array(i.length);return n.set(i),n.buffer}function rf(r){if(typeof r[Symbol.asyncIterator]=="function")return r[Symbol.asyncIterator]();if(typeof r[Symbol.iterator]=="function"){let t=r[Symbol.iterator]();return nf(t)}return r}function nf(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 Si;async function*al(r,t){let e=Ko(Zo(qo(r))),i=await sf(e,t),n;switch(i.format){case"ascii":n=await af(e,i);break;default:throw new Error("Binary PLY can not yet be parsed in streaming mode")}yield pn(i,n,t)}async function sf(r,t){let e={comments:[],elements:[]};return await Xo(r,i=>{if(i=i.trim(),i==="end_header")return!0;if(i==="")return!1;let n=i.split(/\s+/),s=n.shift();switch(i=n.join(" "),s){case"ply":break;case"format":e.format=n[0],e.version=n[1];break;case"comment":e.comments.push(i);break;case"element":Si&&e.elements.push(Si),Si={name:n[0],count:parseInt(n[1],10),properties:[]};break;case"property":let o=of(n,t.propertyNameMapping);Si.properties.push(o);break;default:console.log("unhandled",s,n)}return!1}),Si&&e.elements.push(Si),e}function of(r,t){let e=r[0];switch(e){case"list":return{type:e,name:r[3],countType:r[1],itemType:r[2]};default:return{type:e,name:r[1]}}}async function af(r,t){let e={indices:[],vertices:[],normals:[],uvs:[],colors:[]},i=0,n=0;for await(let s of r)if(s=s.trim(),s!==""){n>=t.elements[i].count&&(i++,n=0);let o=cf(t.elements[i].properties,s);lf(e,t.elements[i].name,o),n++}return e}function Qo(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 cf(r,t){let e=t.split(/\s+/),i={};for(let n=0;n<r.length;n++)if(r[n].type==="list"){let s=[],o=Qo(e.shift(),r[n].countType);for(let a=0;a<o;a++)s.push(Qo(e.shift(),r[n].itemType));i[r[n].name]=s}else i[r[n].name]=Qo(e.shift(),r[n].type);return i}function lf(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/255,e.green/255,e.blue/255);break;case"face":let i=e.vertex_indices||e.vertex_index;i.length===3?r.indices.push(i[0],i[1],i[2]):i.length===4&&(r.indices.push(i[0],i[1],i[3]),r.indices.push(i[1],i[2],i[3]));break;default:break}}var uf="4.4.0-alpha.10",mn={dataType:null,batchType:null,name:"PLY",id:"ply",module:"ply",version:uf,worker:!0,extensions:["ply"],mimeTypes:["text/plain","application/octet-stream"],text:!0,binary:!0,tests:["ply"],options:{ply:{}}},cl={...mn,parse:async(r,t)=>Ii(r,t?.ply),parseTextSync:(r,t)=>Ii(r,t?.ply),parseSync:(r,t)=>Ii(r,t?.ply),parseInBatches:(r,t)=>al(r,t?.ply)};var ll={...mn,dataType:null,batchType:null,worker:!1,parse:async r=>{let t=Ii(r);return $o(t,"arrow-table")}};return bl(yn);})();
19
+ `))>=0;){let n=t.slice(0,i+1);t=t.slice(i+1),yield n}}t.length>0&&(yield t)}async function Xo(r,t){let e=rf(r);for(;;){let{done:i,value:n}=await e.next();if(i){e.return&&e.return();return}if(t(n))return}}async function*qo(r){for await(let t of r)yield ef(t)}function ef(r){if(r instanceof ArrayBuffer)return r;if(ArrayBuffer.isView(r)){let{buffer:t,byteOffset:e,byteLength:i}=r;return ol(t,e,i)}return ol(r)}function ol(r,t=0,e=r.byteLength-t){let i=new Uint8Array(r,t,e),n=new Uint8Array(i.length);return n.set(i),n.buffer}function rf(r){if(typeof r[Symbol.asyncIterator]=="function")return r[Symbol.asyncIterator]();if(typeof r[Symbol.iterator]=="function"){let t=r[Symbol.iterator]();return nf(t)}return r}function nf(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 Si;async function*al(r,t){let e=Ko(Zo(qo(r))),i=await sf(e,t),n;switch(i.format){case"ascii":n=await af(e,i);break;default:throw new Error("Binary PLY can not yet be parsed in streaming mode")}yield pn(i,n,t)}async function sf(r,t){let e={comments:[],elements:[]};return await Xo(r,i=>{if(i=i.trim(),i==="end_header")return!0;if(i==="")return!1;let n=i.split(/\s+/),s=n.shift();switch(i=n.join(" "),s){case"ply":break;case"format":e.format=n[0],e.version=n[1];break;case"comment":e.comments.push(i);break;case"element":Si&&e.elements.push(Si),Si={name:n[0],count:parseInt(n[1],10),properties:[]};break;case"property":let o=of(n,t.propertyNameMapping);Si.properties.push(o);break;default:console.log("unhandled",s,n)}return!1}),Si&&e.elements.push(Si),e}function of(r,t){let e=r[0];switch(e){case"list":return{type:e,name:r[3],countType:r[1],itemType:r[2]};default:return{type:e,name:r[1]}}}async function af(r,t){let e={indices:[],vertices:[],normals:[],uvs:[],colors:[]},i=0,n=0;for await(let s of r)if(s=s.trim(),s!==""){n>=t.elements[i].count&&(i++,n=0);let o=cf(t.elements[i].properties,s);lf(e,t.elements[i].name,o),n++}return e}function Qo(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 cf(r,t){let e=t.split(/\s+/),i={};for(let n=0;n<r.length;n++)if(r[n].type==="list"){let s=[],o=Qo(e.shift(),r[n].countType);for(let a=0;a<o;a++)s.push(Qo(e.shift(),r[n].itemType));i[r[n].name]=s}else i[r[n].name]=Qo(e.shift(),r[n].type);return i}function lf(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/255,e.green/255,e.blue/255);break;case"face":let i=e.vertex_indices||e.vertex_index;i.length===3?r.indices.push(i[0],i[1],i[2]):i.length===4&&(r.indices.push(i[0],i[1],i[3]),r.indices.push(i[1],i[2],i[3]));break;default:break}}var uf="4.4.0-alpha.12",mn={dataType:null,batchType:null,name:"PLY",id:"ply",module:"ply",version:uf,worker:!0,extensions:["ply"],mimeTypes:["text/plain","application/octet-stream"],text:!0,binary:!0,tests:["ply"],options:{ply:{}}},cl={...mn,parse:async(r,t)=>Ii(r,t?.ply),parseTextSync:(r,t)=>Ii(r,t?.ply),parseSync:(r,t)=>Ii(r,t?.ply),parseInBatches:(r,t)=>al(r,t?.ply)};var ll={...mn,dataType:null,batchType:null,worker:!1,parse:async r=>{let t=Ii(r);return $o(t,"arrow-table")}};return bl(yn);})();
20
20
  return __exports__;
21
21
  });
package/dist/index.cjs CHANGED
@@ -624,7 +624,7 @@ function handleElement2(buffer, elementName, element = {}) {
624
624
  }
625
625
 
626
626
  // dist/ply-loader.js
627
- var VERSION = true ? "4.4.0-alpha.10" : "latest";
627
+ var VERSION = true ? "4.4.0-alpha.12" : "latest";
628
628
  var PLYWorkerLoader = {
629
629
  dataType: null,
630
630
  batchType: null,
@@ -5,7 +5,7 @@ import { parsePLY } from "./lib/parse-ply.js";
5
5
  import { parsePLYInBatches } from "./lib/parse-ply-in-batches.js";
6
6
  // __VERSION__ is injected by babel-plugin-version-inline
7
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
- const VERSION = typeof "4.4.0-alpha.10" !== 'undefined' ? "4.4.0-alpha.10" : 'latest';
8
+ const VERSION = typeof "4.4.0-alpha.12" !== 'undefined' ? "4.4.0-alpha.12" : 'latest';
9
9
  /**
10
10
  * Worker loader for PLY - Polygon File Format (aka Stanford Triangle Format)'
11
11
  * links: ['http://paulbourke.net/dataformats/ply/',
@@ -966,7 +966,7 @@
966
966
  }
967
967
 
968
968
  // src/ply-loader.ts
969
- var VERSION = true ? "4.4.0-alpha.10" : "latest";
969
+ var VERSION = true ? "4.4.0-alpha.12" : "latest";
970
970
  var PLYWorkerLoader = {
971
971
  dataType: null,
972
972
  batchType: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/ply",
3
- "version": "4.4.0-alpha.10",
3
+ "version": "4.4.0-alpha.12",
4
4
  "description": "Framework-independent loader for the PLY format",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -45,12 +45,12 @@
45
45
  "build-worker": "esbuild src/workers/ply-worker.ts --bundle --outfile=dist/ply-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
46
46
  },
47
47
  "dependencies": {
48
- "@loaders.gl/loader-utils": "4.4.0-alpha.10",
49
- "@loaders.gl/schema": "4.4.0-alpha.10",
50
- "@loaders.gl/schema-utils": "4.4.0-alpha.10"
48
+ "@loaders.gl/loader-utils": "4.4.0-alpha.12",
49
+ "@loaders.gl/schema": "4.4.0-alpha.12",
50
+ "@loaders.gl/schema-utils": "4.4.0-alpha.12"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@loaders.gl/core": "4.4.0-alpha.1"
54
54
  },
55
- "gitHead": "7b4dc3fdbaed20a2597c70c57efdcda5c404147f"
55
+ "gitHead": "35205e786cbbcf4bd91b74abe210f6c8e378b4cf"
56
56
  }