var rl=Object.defineProperty;var zo=n=>{throw TypeError(n)};var il=(n,t,e)=>t in n?rl(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var vt=(n,t,e)=>il(n,typeof t!="symbol"?t+"":t,e),qo=(n,t,e)=>t.has(n)||zo("Cannot "+e);var h=(n,t,e)=>(qo(n,t,"read from private field"),e?e.call(n):t.get(n)),W=(n,t,e)=>t.has(n)?zo("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),it=(n,t,e,r)=>(qo(n,t,"write to private field"),r?r.call(n,e):t.set(n,e),e);var Wo=(n,t,e,r)=>({set _(i){it(n,t,i,e)},get _(){return h(n,t,r)}});import{d as sl}from"./index.rV6zwFgL.js";import{w as ir,b as ol,r as al,d as cl}from"./entry.CFTpQVQ7.js";import{at as Js,p as Da,W as Zs,T as ul}from"./scheduler.DvKrEcvj.js";import{_ as ti}from"./preload-helper.D7HrI6pR.js";function Q(n,t,e,r){function i(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(d){try{u(r.next(d))}catch(w){o(w)}}function c(d){try{u(r.throw(d))}catch(w){o(w)}}function u(d){d.done?s(d.value):i(d.value).then(a,c)}u((r=r.apply(n,t||[])).next())})}function Go(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function K(n){return this instanceof K?(this.v=n,this):new K(n)}function Te(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(n,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(v){return function(N){return Promise.resolve(N).then(v,w)}}function a(v,N){r[v]&&(i[v]=function(dt){return new Promise(function(D,B){s.push([v,dt,D,B])>1||c(v,dt)})},N&&(i[v]=N(i[v])))}function c(v,N){try{u(r[v](N))}catch(dt){F(s[0][3],dt)}}function u(v){v.value instanceof K?Promise.resolve(v.value.v).then(d,w):F(s[0][2],v)}function d(v){c("next",v)}function w(v){c("throw",v)}function F(v,N){v(N),s.shift(),s.length&&c(s[0][0],s[0][1])}}function oi(n){var t,e;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,s){t[i]=n[i]?function(o){return(e=!e)?{value:K(n[i](o)),done:!1}:s?s(o):o}:s}}function En(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof Go=="function"?Go(n):n[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(s){e[s]=n[s]&&function(o){return new Promise(function(a,c){o=n[s](o),i(a,c,o.done,o.value)})}}function i(s,o,a,c){Promise.resolve(c).then(function(u){s({value:u,done:a})},o)}}const ll=new TextDecoder("utf-8"),Ms=n=>ll.decode(n),hl=new TextEncoder,Xs=n=>hl.encode(n),dl=n=>typeof n=="number",Ba=n=>typeof n=="boolean",Bt=n=>typeof n=="function",Kt=n=>n!=null&&Object(n)===n,nn=n=>Kt(n)&&Bt(n.then),Gr=n=>Kt(n)&&Bt(n[Symbol.iterator]),sr=n=>Kt(n)&&Bt(n[Symbol.asyncIterator]),Ls=n=>Kt(n)&&Kt(n.schema),Ma=n=>Kt(n)&&"done"in n&&"value"in n,La=n=>Kt(n)&&Bt(n.stat)&&dl(n.fd),Ca=n=>Kt(n)&&to(n.body),os=n=>"_getDOMStream"in n&&"_getNodeStream"in n,fl=n=>Kt(n)&&Bt(n.abort)&&Bt(n.getWriter)&&!os(n),to=n=>Kt(n)&&Bt(n.cancel)&&Bt(n.getReader)&&!os(n),pl=n=>Kt(n)&&Bt(n.end)&&Bt(n.write)&&Ba(n.writable)&&!os(n),Ua=n=>Kt(n)&&Bt(n.read)&&Bt(n.pipe)&&Ba(n.readable)&&!os(n),yl=n=>Kt(n)&&Bt(n.clear)&&Bt(n.bytes)&&Bt(n.position)&&Bt(n.setPosition)&&Bt(n.capacity)&&Bt(n.getBufferIdentifier)&&Bt(n.createLong),eo=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function ml(n){const t=n[0]?[n[0]]:[];let e,r,i,s;for(let o,a,c=0,u=0,d=n.length;++cd+w.byteLength,0);let i,s,o,a=0,c=-1;const u=Math.min(t||Number.POSITIVE_INFINITY,r);for(const d=e.length;++cyt(Int32Array,n),Qo=n=>yt(BigInt64Array,n),st=n=>yt(Uint8Array,n),Cs=n=>(n.next(),n);function*gl(n,t){const e=function*(i){yield i},r=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof eo?e(t):Gr(t)?t:e(t);return yield*Cs((function*(i){let s=null;do s=i.next(yield yt(n,s));while(!s.done)})(r[Symbol.iterator]())),new n}const bl=n=>gl(Uint8Array,n);function xa(n,t){return Te(this,arguments,function*(){if(nn(t))return yield K(yield K(yield*oi(En(xa(n,yield K(t))))));const r=function(o){return Te(this,arguments,function*(){yield yield K(yield K(o))})},i=function(o){return Te(this,arguments,function*(){yield K(yield*oi(En(Cs((function*(a){let c=null;do c=a.next(yield c==null?void 0:c.value);while(!c.done)})(o[Symbol.iterator]())))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof eo?r(t):Gr(t)?i(t):sr(t)?t:r(t);return yield K(yield*oi(En(Cs((function(o){return Te(this,arguments,function*(){let a=null;do a=yield K(o.next(yield yield K(yt(n,a))));while(!a.done)})})(s[Symbol.asyncIterator]()))))),yield K(new n)})}const _l=n=>xa(Uint8Array,n);function $a(n,t,e){if(n!==0){e=e.slice(0,t);for(let r=-1,i=e.length;++r0)do if(n[e]!==t[e])return!1;while(++e(n.next(),n);function*Sl(n){let t,e=!1,r=[],i,s,o,a=0;function c(){return s==="peek"?Oe(r,o)[0]:([i,r,a]=Oe(r,o),i)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});const u=bl(n)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(o-a)?u.next():u.next(o-a),!t&&i.byteLength>0&&(r.push(i),a+=i.byteLength),t||o<=a)do({cmd:s,size:o}=yield c());while(o0&&(i.push(s),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield K(u()));while(a0&&(i.push(st(s)),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield K(u()));while(a{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return Q(this,void 0,void 0,function*(){const{reader:e,source:r}=this;e&&(yield e.cancel(t).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(t){return Q(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};const e=yield this.reader.read();return!e.done&&(e.value=st(e)),e})}}const ys=(n,t)=>{const e=i=>r([t,i]);let r;return[t,e,new Promise(i=>(r=i)&&n.once(t,e))]};function Tl(n){return Te(this,arguments,function*(){const e=[];let r="error",i=!1,s=null,o,a,c=0,u=[],d;function w(){return o==="peek"?Oe(u,a)[0]:([d,u,c]=Oe(u,a),d)}if({cmd:o,size:a}=(yield yield K(null))||{cmd:"read",size:0},n.isTTY)return yield yield K(new Uint8Array(0)),yield K(null);try{e[0]=ys(n,"end"),e[1]=ys(n,"error");do{if(e[2]=ys(n,"readable"),[r,s]=yield K(Promise.race(e.map(v=>v[2]))),r==="error")break;if((i=r==="end")||(Number.isFinite(a-c)?(d=st(n.read(a-c)),d.byteLength0&&(u.push(d),c+=d.byteLength)),i||a<=c)do({cmd:o,size:a}=yield yield K(w()));while(a{for(const[B,nt]of v)n.off(B,nt);try{const B=n.destroy;B&&B.call(n,N),N=void 0}catch(B){N=B||N}finally{N!=null?D(N):dt()}})}})}var Rt;(function(n){n[n.V1=0]="V1",n[n.V2=1]="V2",n[n.V3=2]="V3",n[n.V4=3]="V4",n[n.V5=4]="V5"})(Rt||(Rt={}));var kt;(function(n){n[n.Sparse=0]="Sparse",n[n.Dense=1]="Dense"})(kt||(kt={}));var Pt;(function(n){n[n.HALF=0]="HALF",n[n.SINGLE=1]="SINGLE",n[n.DOUBLE=2]="DOUBLE"})(Pt||(Pt={}));var ue;(function(n){n[n.DAY=0]="DAY",n[n.MILLISECOND=1]="MILLISECOND"})(ue||(ue={}));var j;(function(n){n[n.SECOND=0]="SECOND",n[n.MILLISECOND=1]="MILLISECOND",n[n.MICROSECOND=2]="MICROSECOND",n[n.NANOSECOND=3]="NANOSECOND"})(j||(j={}));var Fe;(function(n){n[n.YEAR_MONTH=0]="YEAR_MONTH",n[n.DAY_TIME=1]="DAY_TIME",n[n.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(Fe||(Fe={}));const ms=2,Ie=4,Pe=4,ht=4,He=new Int32Array(2),Ho=new Float32Array(He.buffer),Ko=new Float64Array(He.buffer),ni=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Us;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Us||(Us={}));let Xn=class Pa{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new Pa(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))<>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){Ho[0]=e,this.writeInt32(t,He[0])}writeFloat64(t,e){Ko[0]=e,this.writeInt32(t,He[ni?0:1]),this.writeInt32(t+4,He[ni?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=t);const r=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space=0&&this.vtable[e]==0;e--);const r=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);const i=2;this.addInt16(t-this.object_start);const s=(r+i)*ms;this.addInt16(s);let o=0;const a=this.space;t:for(e=0;e=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,Ie+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const r=this.bb.capacity()-t,i=r-this.bb.readInt32(r);if(!(e=0;r--)t.addInt32(e[r]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,r){return Qt.startUnion(t),Qt.addMode(t,e),Qt.addTypeIds(t,r),Qt.endUnion(t)}}let ra=class wr{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 wr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+ht),(e||new wr).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return wr.startUtf8(t),wr.endUtf8(t)}};var _t;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.FloatingPoint=3]="FloatingPoint",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct_=13]="Struct_",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.LargeList=21]="LargeList",n[n.RunEndEncoded=22]="RunEndEncoded"})(_t||(_t={}));let re=class di{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 di).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+ht),(e||new di).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}nullable(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):_t.NONE}type(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){const e=this.bb.__offset(this.bb_pos,12);return e?(t||new ke).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){const r=this.bb.__offset(this.bb_pos,14);return r?(e||new di).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}childrenLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const r=this.bb.__offset(this.bb_pos,16);return r?(e||new Mt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,e){t.addFieldOffset(0,e,0)}static addNullable(t,e){t.addFieldInt8(1,+e,0)}static addTypeType(t,e){t.addFieldInt8(2,e,_t.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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endField(t){return t.endObject()}},we=class Be{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 Be).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+ht),(e||new Be).__init(t.readInt32(t.position())+t.position(),t)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):tr.Little}fields(t,e){const r=this.bb.__offset(this.bb_pos,6);return r?(e||new re).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}fieldsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const r=this.bb.__offset(this.bb_pos,8);return r?(e||new Mt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+t*8):BigInt(0)}featuresLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,e){t.addFieldInt16(0,e,tr.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addInt64(e[r]);return t.endVector()}static startFeaturesVector(t,e){t.startVector(8,e,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,e){t.finish(e)}static finishSizePrefixedSchemaBuffer(t,e){t.finish(e,void 0,!0)}static createSchema(t,e,r,i,s){return Be.startSchema(t),Be.addEndianness(t,e),Be.addFields(t,r),Be.addCustomMetadata(t,i),Be.addFeatures(t,s),Be.endSchema(t)}};var ct;(function(n){n[n.NONE=0]="NONE",n[n.Schema=1]="Schema",n[n.DictionaryBatch=2]="DictionaryBatch",n[n.RecordBatch=3]="RecordBatch",n[n.Tensor=4]="Tensor",n[n.SparseTensor=5]="SparseTensor"})(ct||(ct={}));var l;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth",n[n.DurationSecond=-27]="DurationSecond",n[n.DurationMillisecond=-28]="DurationMillisecond",n[n.DurationMicrosecond=-29]="DurationMicrosecond",n[n.DurationNanosecond=-30]="DurationNanosecond"})(l||(l={}));var Le;(function(n){n[n.OFFSET=0]="OFFSET",n[n.DATA=1]="DATA",n[n.VALIDITY=2]="VALIDITY",n[n.TYPE=3]="TYPE"})(Le||(Le={}));const Al=void 0;function Or(n){if(n===null)return"null";if(n===Al)return"undefined";switch(typeof n){case"number":return`${n}`;case"bigint":return`${n}`;case"string":return`"${n}"`}return typeof n[Symbol.toPrimitive]=="function"?n[Symbol.toPrimitive]("string"):ArrayBuffer.isView(n)?n instanceof BigInt64Array||n instanceof BigUint64Array?`[${[...n].map(t=>Or(t))}]`:`[${n}]`:ArrayBuffer.isView(n)?`[${n}]`:JSON.stringify(n,(t,e)=>typeof e=="bigint"?`${e}`:e)}function gt(n){if(typeof n=="bigint"&&(nNumber.MAX_SAFE_INTEGER))throw new TypeError(`${n} is not safe to convert to a number.`);return Number(n)}function qa(n,t){return gt(n/t)+gt(n%t)/gt(t)}const Ol=Symbol.for("isArrowBigNum");function be(n,...t){return t.length===0?Object.setPrototypeOf(yt(this.TypedArray,n),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(n,...t),this.constructor.prototype)}be.prototype[Ol]=!0;be.prototype.toJSON=function(){return`"${Nr(this)}"`};be.prototype.valueOf=function(n){return Wa(this,n)};be.prototype.toString=function(){return Nr(this)};be.prototype[Symbol.toPrimitive]=function(n="default"){switch(n){case"number":return Wa(this);case"string":return Nr(this);case"default":return Rl(this)}return Nr(this)};function Vn(...n){return be.apply(this,n)}function zn(...n){return be.apply(this,n)}function Fr(...n){return be.apply(this,n)}Object.setPrototypeOf(Vn.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(zn.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Fr.prototype,Object.create(Uint32Array.prototype));Object.assign(Vn.prototype,be.prototype,{constructor:Vn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(zn.prototype,be.prototype,{constructor:zn,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Fr.prototype,be.prototype,{constructor:Fr,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Fl=BigInt(4294967296)*BigInt(4294967296),Nl=Fl-BigInt(1);function Wa(n,t){const{buffer:e,byteOffset:r,byteLength:i,signed:s}=n,o=new BigUint64Array(e,r,i/8),a=s&&o.at(-1)&BigInt(1)<=0)return gs(n);t=t.slice();let r=1;for(let s=0;s(n.children=null,n.ArrayType=Array,n.OffsetArrayType=Int32Array,n[Symbol.toStringTag]="DataType"))(L.prototype);class rn extends L{constructor(){super(l.Null)}toString(){return"Null"}}Ya=Symbol.toStringTag;rn[Ya]=(n=>n[Symbol.toStringTag]="Null")(rn.prototype);class On extends L{constructor(t,e){super(l.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}`}}Qa=Symbol.toStringTag;On[Qa]=(n=>(n.isSigned=null,n.bitWidth=null,n[Symbol.toStringTag]="Int"))(On.prototype);class Rr extends On{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Rr.prototype,"ArrayType",{value:Int32Array});class Si extends L{constructor(t){super(l.Float),this.precision=t}get ArrayType(){switch(this.precision){case Pt.HALF:return Uint16Array;case Pt.SINGLE:return Float32Array;case Pt.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Ha=Symbol.toStringTag;Si[Ha]=(n=>(n.precision=null,n[Symbol.toStringTag]="Float"))(Si.prototype);class Ii extends L{constructor(){super(l.Binary)}toString(){return"Binary"}}Ka=Symbol.toStringTag;Ii[Ka]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Binary"))(Ii.prototype);class vi extends L{constructor(){super(l.LargeBinary)}toString(){return"LargeBinary"}}Ja=Symbol.toStringTag;vi[Ja]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeBinary"))(vi.prototype);class Ei extends L{constructor(){super(l.Utf8)}toString(){return"Utf8"}}Za=Symbol.toStringTag;Ei[Za]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Utf8"))(Ei.prototype);class Ti extends L{constructor(){super(l.LargeUtf8)}toString(){return"LargeUtf8"}}Xa=Symbol.toStringTag;Ti[Xa]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeUtf8"))(Ti.prototype);class Ai extends L{constructor(){super(l.Bool)}toString(){return"Bool"}}tc=Symbol.toStringTag;Ai[tc]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Bool"))(Ai.prototype);class Oi extends L{constructor(t,e,r=128){super(l.Decimal),this.scale=t,this.precision=e,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}ec=Symbol.toStringTag;Oi[ec]=(n=>(n.scale=null,n.precision=null,n.ArrayType=Uint32Array,n[Symbol.toStringTag]="Decimal"))(Oi.prototype);class Fi extends L{constructor(t){super(l.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${ue[this.unit]}>`}get ArrayType(){return this.unit===ue.DAY?Int32Array:BigInt64Array}}nc=Symbol.toStringTag;Fi[nc]=(n=>(n.unit=null,n[Symbol.toStringTag]="Date"))(Fi.prototype);class Ni extends L{constructor(t,e){super(l.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${j[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}rc=Symbol.toStringTag;Ni[rc]=(n=>(n.unit=null,n.bitWidth=null,n[Symbol.toStringTag]="Time"))(Ni.prototype);class Ri extends L{constructor(t,e){super(l.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${j[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}ic=Symbol.toStringTag;Ri[ic]=(n=>(n.unit=null,n.timezone=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Timestamp"))(Ri.prototype);class Di extends L{constructor(t){super(l.Interval),this.unit=t}toString(){return`Interval<${Fe[this.unit]}>`}}sc=Symbol.toStringTag;Di[sc]=(n=>(n.unit=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Interval"))(Di.prototype);class Bi extends L{constructor(t){super(l.Duration),this.unit=t}toString(){return`Duration<${j[this.unit]}>`}}oc=Symbol.toStringTag;Bi[oc]=(n=>(n.unit=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Duration"))(Bi.prototype);class Mi extends L{constructor(t){super(l.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}}ac=Symbol.toStringTag;Mi[ac]=(n=>(n.children=null,n[Symbol.toStringTag]="List"))(Mi.prototype);class zt extends L{constructor(t){super(l.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}cc=Symbol.toStringTag;zt[cc]=(n=>(n.children=null,n[Symbol.toStringTag]="Struct"))(zt.prototype);class Li extends L{constructor(t,e,r){super(l.Union),this.mode=t,this.children=r,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}uc=Symbol.toStringTag;Li[uc]=(n=>(n.mode=null,n.typeIds=null,n.children=null,n.typeIdToChildIndex=null,n.ArrayType=Int8Array,n[Symbol.toStringTag]="Union"))(Li.prototype);class Ci extends L{constructor(t){super(l.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}lc=Symbol.toStringTag;Ci[lc]=(n=>(n.byteWidth=null,n.ArrayType=Uint8Array,n[Symbol.toStringTag]="FixedSizeBinary"))(Ci.prototype);class Ui extends L{constructor(t,e){super(l.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}>`}}hc=Symbol.toStringTag;Ui[hc]=(n=>(n.children=null,n.listSize=null,n[Symbol.toStringTag]="FixedSizeList"))(Ui.prototype);class xi extends L{constructor(t,e=!1){var r,i,s;if(super(l.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((r=t==null?void 0:t.type)===null||r===void 0)&&r.children)){const o=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");const a=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}dc=Symbol.toStringTag;xi[dc]=(n=>(n.children=null,n.keysSorted=null,n[Symbol.toStringTag]="Map_"))(xi.prototype);const Dl=(n=>()=>++n)(-1);class er extends L{constructor(t,e,r,i){super(l.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=r==null?Dl():gt(r)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}fc=Symbol.toStringTag;er[fc]=(n=>(n.id=null,n.indices=null,n.isOrdered=null,n.dictionary=null,n[Symbol.toStringTag]="Dictionary"))(er.prototype);function Ce(n){const t=n;switch(n.typeId){case l.Decimal:return n.bitWidth/32;case l.Interval:return 1+t.unit;case l.FixedSizeList:return t.listSize;case l.FixedSizeBinary:return t.byteWidth;default:return 1}}class X{visitMany(t,...e){return t.map((r,i)=>this.visit(r,...e.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return Bl(this,t,e)}getVisitFnByTypeId(t,e=!0){return xn(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitLargeUtf8(t,...e){return null}visitBinary(t,...e){return null}visitLargeBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitDuration(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}}function Bl(n,t,e=!0){return typeof t=="number"?xn(n,t,e):typeof t=="string"&&t in l?xn(n,l[t],e):t&&t instanceof L?xn(n,ia(t),e):t!=null&&t.type&&t.type instanceof L?xn(n,ia(t.type),e):xn(n,l.NONE,e)}function xn(n,t,e=!0){let r=null;switch(t){case l.Null:r=n.visitNull;break;case l.Bool:r=n.visitBool;break;case l.Int:r=n.visitInt;break;case l.Int8:r=n.visitInt8||n.visitInt;break;case l.Int16:r=n.visitInt16||n.visitInt;break;case l.Int32:r=n.visitInt32||n.visitInt;break;case l.Int64:r=n.visitInt64||n.visitInt;break;case l.Uint8:r=n.visitUint8||n.visitInt;break;case l.Uint16:r=n.visitUint16||n.visitInt;break;case l.Uint32:r=n.visitUint32||n.visitInt;break;case l.Uint64:r=n.visitUint64||n.visitInt;break;case l.Float:r=n.visitFloat;break;case l.Float16:r=n.visitFloat16||n.visitFloat;break;case l.Float32:r=n.visitFloat32||n.visitFloat;break;case l.Float64:r=n.visitFloat64||n.visitFloat;break;case l.Utf8:r=n.visitUtf8;break;case l.LargeUtf8:r=n.visitLargeUtf8;break;case l.Binary:r=n.visitBinary;break;case l.LargeBinary:r=n.visitLargeBinary;break;case l.FixedSizeBinary:r=n.visitFixedSizeBinary;break;case l.Date:r=n.visitDate;break;case l.DateDay:r=n.visitDateDay||n.visitDate;break;case l.DateMillisecond:r=n.visitDateMillisecond||n.visitDate;break;case l.Timestamp:r=n.visitTimestamp;break;case l.TimestampSecond:r=n.visitTimestampSecond||n.visitTimestamp;break;case l.TimestampMillisecond:r=n.visitTimestampMillisecond||n.visitTimestamp;break;case l.TimestampMicrosecond:r=n.visitTimestampMicrosecond||n.visitTimestamp;break;case l.TimestampNanosecond:r=n.visitTimestampNanosecond||n.visitTimestamp;break;case l.Time:r=n.visitTime;break;case l.TimeSecond:r=n.visitTimeSecond||n.visitTime;break;case l.TimeMillisecond:r=n.visitTimeMillisecond||n.visitTime;break;case l.TimeMicrosecond:r=n.visitTimeMicrosecond||n.visitTime;break;case l.TimeNanosecond:r=n.visitTimeNanosecond||n.visitTime;break;case l.Decimal:r=n.visitDecimal;break;case l.List:r=n.visitList;break;case l.Struct:r=n.visitStruct;break;case l.Union:r=n.visitUnion;break;case l.DenseUnion:r=n.visitDenseUnion||n.visitUnion;break;case l.SparseUnion:r=n.visitSparseUnion||n.visitUnion;break;case l.Dictionary:r=n.visitDictionary;break;case l.Interval:r=n.visitInterval;break;case l.IntervalDayTime:r=n.visitIntervalDayTime||n.visitInterval;break;case l.IntervalYearMonth:r=n.visitIntervalYearMonth||n.visitInterval;break;case l.Duration:r=n.visitDuration;break;case l.DurationSecond:r=n.visitDurationSecond||n.visitDuration;break;case l.DurationMillisecond:r=n.visitDurationMillisecond||n.visitDuration;break;case l.DurationMicrosecond:r=n.visitDurationMicrosecond||n.visitDuration;break;case l.DurationNanosecond:r=n.visitDurationNanosecond||n.visitDuration;break;case l.FixedSizeList:r=n.visitFixedSizeList;break;case l.Map:r=n.visitMap;break}if(typeof r=="function")return r;if(!e)return()=>null;throw new Error(`Unrecognized type '${l[t]}'`)}function ia(n){switch(n.typeId){case l.Null:return l.Null;case l.Int:{const{bitWidth:t,isSigned:e}=n;switch(t){case 8:return e?l.Int8:l.Uint8;case 16:return e?l.Int16:l.Uint16;case 32:return e?l.Int32:l.Uint32;case 64:return e?l.Int64:l.Uint64}return l.Int}case l.Float:switch(n.precision){case Pt.HALF:return l.Float16;case Pt.SINGLE:return l.Float32;case Pt.DOUBLE:return l.Float64}return l.Float;case l.Binary:return l.Binary;case l.LargeBinary:return l.LargeBinary;case l.Utf8:return l.Utf8;case l.LargeUtf8:return l.LargeUtf8;case l.Bool:return l.Bool;case l.Decimal:return l.Decimal;case l.Time:switch(n.unit){case j.SECOND:return l.TimeSecond;case j.MILLISECOND:return l.TimeMillisecond;case j.MICROSECOND:return l.TimeMicrosecond;case j.NANOSECOND:return l.TimeNanosecond}return l.Time;case l.Timestamp:switch(n.unit){case j.SECOND:return l.TimestampSecond;case j.MILLISECOND:return l.TimestampMillisecond;case j.MICROSECOND:return l.TimestampMicrosecond;case j.NANOSECOND:return l.TimestampNanosecond}return l.Timestamp;case l.Date:switch(n.unit){case ue.DAY:return l.DateDay;case ue.MILLISECOND:return l.DateMillisecond}return l.Date;case l.Interval:switch(n.unit){case Fe.DAY_TIME:return l.IntervalDayTime;case Fe.YEAR_MONTH:return l.IntervalYearMonth}return l.Interval;case l.Duration:switch(n.unit){case j.SECOND:return l.DurationSecond;case j.MILLISECOND:return l.DurationMillisecond;case j.MICROSECOND:return l.DurationMicrosecond;case j.NANOSECOND:return l.DurationNanosecond}return l.Duration;case l.Map:return l.Map;case l.List:return l.List;case l.Struct:return l.Struct;case l.Union:switch(n.mode){case kt.Dense:return l.DenseUnion;case kt.Sparse:return l.SparseUnion}return l.Union;case l.FixedSizeBinary:return l.FixedSizeBinary;case l.FixedSizeList:return l.FixedSizeList;case l.Dictionary:return l.Dictionary}throw new Error(`Unrecognized type '${l[n.typeId]}'`)}X.prototype.visitInt8=null;X.prototype.visitInt16=null;X.prototype.visitInt32=null;X.prototype.visitInt64=null;X.prototype.visitUint8=null;X.prototype.visitUint16=null;X.prototype.visitUint32=null;X.prototype.visitUint64=null;X.prototype.visitFloat16=null;X.prototype.visitFloat32=null;X.prototype.visitFloat64=null;X.prototype.visitDateDay=null;X.prototype.visitDateMillisecond=null;X.prototype.visitTimestampSecond=null;X.prototype.visitTimestampMillisecond=null;X.prototype.visitTimestampMicrosecond=null;X.prototype.visitTimestampNanosecond=null;X.prototype.visitTimeSecond=null;X.prototype.visitTimeMillisecond=null;X.prototype.visitTimeMicrosecond=null;X.prototype.visitTimeNanosecond=null;X.prototype.visitDenseUnion=null;X.prototype.visitSparseUnion=null;X.prototype.visitIntervalDayTime=null;X.prototype.visitIntervalYearMonth=null;X.prototype.visitDuration=null;X.prototype.visitDurationSecond=null;X.prototype.visitDurationMillisecond=null;X.prototype.visitDurationMicrosecond=null;X.prototype.visitDurationNanosecond=null;const pc=new Float64Array(1),Nn=new Uint32Array(pc.buffer);function yc(n){const t=(n&31744)>>10,e=(n&1023)/1024,r=Math.pow(-1,(n&32768)>>15);switch(t){case 31:return r*(e?Number.NaN:1/0);case 0:return r*(e?6103515625e-14*e:0)}return r*Math.pow(2,t-15)*(1+e)}function Ml(n){if(n!==n)return 32256;pc[0]=n;const t=(Nn[1]&2147483648)>>16&65535;let e=Nn[1]&2146435072,r=0;return e>=1089470464?Nn[0]>0?e=31744:(e=(e&2080374784)>>16,r=(Nn[1]&1048575)>>10):e<=1056964608?(r=1048576+(Nn[1]&1048575),r=1048576+(r<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,r=(Nn[1]&1048575)+512>>10),t|e|r&65535}class V extends X{}function G(n){return(t,e,r)=>{if(t.setValid(e,r!=null))return n(t,e,r)}}const Ll=(n,t,e)=>{n[t]=Math.floor(e/864e5)},mc=(n,t,e,r)=>{if(e+1{const i=n+e;r?t[i>>3]|=1<>3]&=~(1<{n[t]=e},ro=({values:n},t,e)=>{n[t]=e},gc=({values:n},t,e)=>{n[t]=Ml(e)},Ul=(n,t,e)=>{switch(n.type.precision){case Pt.HALF:return gc(n,t,e);case Pt.SINGLE:case Pt.DOUBLE:return ro(n,t,e)}},bc=({values:n},t,e)=>{Ll(n,t,e.valueOf())},_c=({values:n},t,e)=>{n[t]=BigInt(e)},xl=({stride:n,values:t},e,r)=>{t.set(r.subarray(0,n),n*e)},wc=({values:n,valueOffsets:t},e,r)=>mc(n,t,e,r),Sc=({values:n,valueOffsets:t},e,r)=>mc(n,t,e,Xs(r)),$l=(n,t,e)=>{n.type.unit===ue.DAY?bc(n,t,e):_c(n,t,e)},Ic=({values:n},t,e)=>{n[t]=BigInt(e/1e3)},vc=({values:n},t,e)=>{n[t]=BigInt(e)},Ec=({values:n},t,e)=>{n[t]=BigInt(e*1e3)},Tc=({values:n},t,e)=>{n[t]=BigInt(e*1e6)},Pl=(n,t,e)=>{switch(n.type.unit){case j.SECOND:return Ic(n,t,e);case j.MILLISECOND:return vc(n,t,e);case j.MICROSECOND:return Ec(n,t,e);case j.NANOSECOND:return Tc(n,t,e)}},Ac=({values:n},t,e)=>{n[t]=e},Oc=({values:n},t,e)=>{n[t]=e},Fc=({values:n},t,e)=>{n[t]=e},Nc=({values:n},t,e)=>{n[t]=e},kl=(n,t,e)=>{switch(n.type.unit){case j.SECOND:return Ac(n,t,e);case j.MILLISECOND:return Oc(n,t,e);case j.MICROSECOND:return Fc(n,t,e);case j.NANOSECOND:return Nc(n,t,e)}},jl=({values:n,stride:t},e,r)=>{n.set(r.subarray(0,t),t*e)},Vl=(n,t,e)=>{const r=n.children[0],i=n.valueOffsets,s=le.getVisitFn(r);if(Array.isArray(e))for(let o=-1,a=i[t],c=i[t+1];a{const r=n.children[0],{valueOffsets:i}=n,s=le.getVisitFn(r);let{[t]:o,[t+1]:a}=i;const c=e instanceof Map?e.entries():Object.entries(e);for(const u of c)if(s(r,o,u),++o>=a)break},ql=(n,t)=>(e,r,i,s)=>r&&e(r,n,t[s]),Wl=(n,t)=>(e,r,i,s)=>r&&e(r,n,t.get(s)),Gl=(n,t)=>(e,r,i,s)=>r&&e(r,n,t.get(i.name)),Yl=(n,t)=>(e,r,i,s)=>r&&e(r,n,t[i.name]),Ql=(n,t,e)=>{const r=n.type.children.map(s=>le.getVisitFn(s.type)),i=e instanceof Map?Gl(t,e):e instanceof ut?Wl(t,e):Array.isArray(e)?ql(t,e):Yl(t,e);n.type.children.forEach((s,o)=>i(r[o],n.children[o],s,o))},Hl=(n,t,e)=>{n.type.mode===kt.Dense?Rc(n,t,e):Dc(n,t,e)},Rc=(n,t,e)=>{const r=n.type.typeIdToChildIndex[n.typeIds[t]],i=n.children[r];le.visit(i,n.valueOffsets[t],e)},Dc=(n,t,e)=>{const r=n.type.typeIdToChildIndex[n.typeIds[t]],i=n.children[r];le.visit(i,t,e)},Kl=(n,t,e)=>{var r;(r=n.dictionary)===null||r===void 0||r.set(n.values[t],e)},Jl=(n,t,e)=>{n.type.unit===Fe.DAY_TIME?Bc(n,t,e):Mc(n,t,e)},Bc=({values:n},t,e)=>{n.set(e.subarray(0,2),2*t)},Mc=({values:n},t,e)=>{n[t]=e[0]*12+e[1]%12},Lc=({values:n},t,e)=>{n[t]=e},Cc=({values:n},t,e)=>{n[t]=e},Uc=({values:n},t,e)=>{n[t]=e},xc=({values:n},t,e)=>{n[t]=e},Zl=(n,t,e)=>{switch(n.type.unit){case j.SECOND:return Lc(n,t,e);case j.MILLISECOND:return Cc(n,t,e);case j.MICROSECOND:return Uc(n,t,e);case j.NANOSECOND:return xc(n,t,e)}},Xl=(n,t,e)=>{const{stride:r}=n,i=n.children[0],s=le.getVisitFn(i);if(Array.isArray(e))for(let o=-1,a=t*r;++o`${Or(t)}: ${Or(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new th(this[ye],this[qn])}}class th{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return te.name)}has(t,e){return t[ye].type.children.findIndex(r=>r.name===e)!==-1}getOwnPropertyDescriptor(t,e){if(t[ye].type.children.findIndex(r=>r.name===e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const r=t[ye].type.children.findIndex(i=>i.name===e);if(r!==-1){const i=Jt.visit(t[ye].children[r],t[qn]);return Reflect.set(t,e,i),i}}set(t,e,r){const i=t[ye].type.children.findIndex(s=>s.name===e);return i!==-1?(le.visit(t[ye].children[i],t[qn],r),Reflect.set(t,e,r)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,r):!1}}class x extends X{}function z(n){return(t,e)=>t.getValid(e)?n(t,e):null}const nh=(n,t)=>864e5*n[t],rh=(n,t)=>null,$c=(n,t,e)=>{if(e+1>=t.length)return null;const r=gt(t[e]),i=gt(t[e+1]);return n.subarray(r,i)},ih=({offset:n,values:t},e)=>{const r=n+e;return(t[r>>3]&1<nh(n,t),kc=({values:n},t)=>gt(n[t]),cn=({stride:n,values:t},e)=>t[n*e],sh=({stride:n,values:t},e)=>yc(t[n*e]),jc=({values:n},t)=>n[t],oh=({stride:n,values:t},e)=>t.subarray(n*e,n*(e+1)),Vc=({values:n,valueOffsets:t},e)=>$c(n,t,e),zc=({values:n,valueOffsets:t},e)=>{const r=$c(n,t,e);return r!==null?Ms(r):null},ah=({values:n},t)=>n[t],ch=({type:n,values:t},e)=>n.precision!==Pt.HALF?t[e]:yc(t[e]),uh=(n,t)=>n.type.unit===ue.DAY?Pc(n,t):kc(n,t),qc=({values:n},t)=>1e3*gt(n[t]),Wc=({values:n},t)=>gt(n[t]),Gc=({values:n},t)=>qa(n[t],BigInt(1e3)),Yc=({values:n},t)=>qa(n[t],BigInt(1e6)),lh=(n,t)=>{switch(n.type.unit){case j.SECOND:return qc(n,t);case j.MILLISECOND:return Wc(n,t);case j.MICROSECOND:return Gc(n,t);case j.NANOSECOND:return Yc(n,t)}},Qc=({values:n},t)=>n[t],Hc=({values:n},t)=>n[t],Kc=({values:n},t)=>n[t],Jc=({values:n},t)=>n[t],hh=(n,t)=>{switch(n.type.unit){case j.SECOND:return Qc(n,t);case j.MILLISECOND:return Hc(n,t);case j.MICROSECOND:return Kc(n,t);case j.NANOSECOND:return Jc(n,t)}},dh=({values:n,stride:t},e)=>no.decimal(n.subarray(t*e,t*(e+1))),fh=(n,t)=>{const{valueOffsets:e,stride:r,children:i}=n,{[t*r]:s,[t*r+1]:o}=e,c=i[0].slice(s,o-s);return new ut([c])},ph=(n,t)=>{const{valueOffsets:e,children:r}=n,{[t]:i,[t+1]:s}=e,o=r[0];return new so(o.slice(i,s-i))},yh=(n,t)=>new io(n,t),mh=(n,t)=>n.type.mode===kt.Dense?Zc(n,t):Xc(n,t),Zc=(n,t)=>{const e=n.type.typeIdToChildIndex[n.typeIds[t]],r=n.children[e];return Jt.visit(r,n.valueOffsets[t])},Xc=(n,t)=>{const e=n.type.typeIdToChildIndex[n.typeIds[t]],r=n.children[e];return Jt.visit(r,t)},gh=(n,t)=>{var e;return(e=n.dictionary)===null||e===void 0?void 0:e.get(n.values[t])},bh=(n,t)=>n.type.unit===Fe.DAY_TIME?tu(n,t):eu(n,t),tu=({values:n},t)=>n.subarray(2*t,2*(t+1)),eu=({values:n},t)=>{const e=n[t],r=new Int32Array(2);return r[0]=Math.trunc(e/12),r[1]=Math.trunc(e%12),r},nu=({values:n},t)=>n[t],ru=({values:n},t)=>n[t],iu=({values:n},t)=>n[t],su=({values:n},t)=>n[t],_h=(n,t)=>{switch(n.type.unit){case j.SECOND:return nu(n,t);case j.MILLISECOND:return ru(n,t);case j.MICROSECOND:return iu(n,t);case j.NANOSECOND:return su(n,t)}},wh=(n,t)=>{const{stride:e,children:r}=n,s=r[0].slice(t*e,e);return new ut([s])};x.prototype.visitNull=z(rh);x.prototype.visitBool=z(ih);x.prototype.visitInt=z(ah);x.prototype.visitInt8=z(cn);x.prototype.visitInt16=z(cn);x.prototype.visitInt32=z(cn);x.prototype.visitInt64=z(jc);x.prototype.visitUint8=z(cn);x.prototype.visitUint16=z(cn);x.prototype.visitUint32=z(cn);x.prototype.visitUint64=z(jc);x.prototype.visitFloat=z(ch);x.prototype.visitFloat16=z(sh);x.prototype.visitFloat32=z(cn);x.prototype.visitFloat64=z(cn);x.prototype.visitUtf8=z(zc);x.prototype.visitLargeUtf8=z(zc);x.prototype.visitBinary=z(Vc);x.prototype.visitLargeBinary=z(Vc);x.prototype.visitFixedSizeBinary=z(oh);x.prototype.visitDate=z(uh);x.prototype.visitDateDay=z(Pc);x.prototype.visitDateMillisecond=z(kc);x.prototype.visitTimestamp=z(lh);x.prototype.visitTimestampSecond=z(qc);x.prototype.visitTimestampMillisecond=z(Wc);x.prototype.visitTimestampMicrosecond=z(Gc);x.prototype.visitTimestampNanosecond=z(Yc);x.prototype.visitTime=z(hh);x.prototype.visitTimeSecond=z(Qc);x.prototype.visitTimeMillisecond=z(Hc);x.prototype.visitTimeMicrosecond=z(Kc);x.prototype.visitTimeNanosecond=z(Jc);x.prototype.visitDecimal=z(dh);x.prototype.visitList=z(fh);x.prototype.visitStruct=z(yh);x.prototype.visitUnion=z(mh);x.prototype.visitDenseUnion=z(Zc);x.prototype.visitSparseUnion=z(Xc);x.prototype.visitDictionary=z(gh);x.prototype.visitInterval=z(bh);x.prototype.visitIntervalDayTime=z(tu);x.prototype.visitIntervalYearMonth=z(eu);x.prototype.visitDuration=z(_h);x.prototype.visitDurationSecond=z(nu);x.prototype.visitDurationMillisecond=z(ru);x.prototype.visitDurationMicrosecond=z(iu);x.prototype.visitDurationNanosecond=z(su);x.prototype.visitFixedSizeList=z(wh);x.prototype.visitMap=z(ph);const Jt=new x,$n=Symbol.for("keys"),Wn=Symbol.for("vals"),Pn=Symbol.for("kKeysAsStrings"),Ps=Symbol.for("_kKeysAsStrings");class so{constructor(t){return this[$n]=new ut([t.children[0]]).memoize(),this[Wn]=t.children[1],new Proxy(this,new Ih)}get[Pn](){return this[Ps]||(this[Ps]=Array.from(this[$n].toArray(),String))}[Symbol.iterator](){return new Sh(this[$n],this[Wn])}get size(){return this[$n].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[$n],e=this[Wn],r={};for(let i=-1,s=t.length;++i`${Or(t)}: ${Or(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Sh{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),Jt.visit(this.vals,t)]})}}class Ih{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Pn]}has(t,e){return t[Pn].includes(e)}getOwnPropertyDescriptor(t,e){if(t[Pn].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const r=t[Pn].indexOf(e);if(r!==-1){const i=Jt.visit(Reflect.get(t,Wn),r);return Reflect.set(t,e,i),i}}set(t,e,r){const i=t[Pn].indexOf(e);return i!==-1?(le.visit(Reflect.get(t,Wn),i,r),Reflect.set(t,e,r)):Reflect.has(t,e)?Reflect.set(t,e,r):!1}}Object.defineProperties(so.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[$n]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Wn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ps]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let sa;function ou(n,t,e,r){const{length:i=0}=n;let s=typeof t!="number"?0:t,o=typeof e!="number"?i:e;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),oi&&(o=i),r?r(n,s,o):[s,o]}const oo=(n,t)=>n<0?t+n:n,oa=n=>n!==n;function or(n){if(typeof n!=="object"||n===null)return oa(n)?oa:e=>e===n;if(n instanceof Date){const e=n.valueOf();return r=>r instanceof Date?r.valueOf()===e:!1}return ArrayBuffer.isView(n)?e=>e?wl(n,e):!1:n instanceof Map?Eh(n):Array.isArray(n)?vh(n):n instanceof ut?Th(n):Ah(n,!0)}function vh(n){const t=[];for(let e=-1,r=n.length;++e!1;const r=[];for(let i=-1,s=e.length;++i{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return Oh(n,e);case Map:return aa(n,e,e.keys());case so:case io:case Object:case void 0:return aa(n,e,t||Object.keys(e))}return e instanceof ut?Fh(n,e):!1}}function Oh(n,t){const e=n.length;if(t.length!==e)return!1;for(let r=-1;++r>r}function $i(n,t,e){const r=e.byteLength+7&-8;if(n>0||e.byteLength>3):Pi(new ao(e,n,t,null,au)).subarray(0,r)),i}return e}function Pi(n){const t=[];let e=0,r=0,i=0;for(const o of n)o&&(i|=1<0)&&(t[e++]=i);const s=new Uint8Array(t.length+7&-8);return s.set(t),s}class ao{constructor(t,e,r,i,s){this.bytes=t,this.length=r,this.context=i,this.get=s,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=t+(t%8===0?0:8-t%8);return ks(n,t,i)+ks(n,r,e)+Rh(n,i>>3,r-i>>3)}function Rh(n,t,e){let r=0,i=Math.trunc(t);const s=new DataView(n.buffer,n.byteOffset,n.byteLength),o=e===void 0?n.byteLength:i+e;for(;o-i>=4;)r+=bs(s.getUint32(i)),i+=4;for(;o-i>=2;)r+=bs(s.getUint16(i)),i+=2;for(;o-i>=1;)r+=bs(s.getUint8(i)),i+=1;return r}function bs(n){let t=Math.trunc(n);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const Dh=-1;class ft{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:t}=this;return L.isSparseUnion(t)?this.children.some(e=>e.nullable):L.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:e,values:r,nullBitmap:i,typeIds:s}=this;return e&&(t+=e.byteLength),r&&(t+=r.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,t)}get nullCount(){if(L.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let t=this._nullCount,e;return t<=Dh&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-ks(e,this.offset,this.offset+this.length)),t}constructor(t,e,r,i,s,o=[],a){this.type=t,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let c;s instanceof ft?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Ce(t),s&&((c=s[0])&&(this.valueOffsets=c),(c=s[1])&&(this.values=c),(c=s[2])&&(this.nullBitmap=c),(c=s[3])&&(this.typeIds=c)))}getValid(t){const{type:e}=this;if(L.isUnion(e)){const r=e,i=this.children[r.typeIdToChildIndex[this.typeIds[t]]],s=r.mode===kt.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){const r=this.offset+t;return(this.nullBitmap[r>>3]&1<>3;(!s||s.byteLength<=d)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set($i(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const w=s[d];r=(w&u)!==0,s[d]=e?w|u:w&~u}return r!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,r=this.length,i=this._nullCount,s=this,o=this.children){return new ft(t,e,r,i,s,o,this.dictionary)}slice(t,e){const{stride:r,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,a=i===16?r:1,c=this._sliceBuffers(t,e,r,i);return this.clone(this.type,this.offset+t,e,o,c,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*t,a*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===l.Null)return this.clone(this.type,0,t,0);const{length:e,nullCount:r}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);i[e>>3]=(1<0&&i.set($i(this.offset,e,this.nullBitmap),0);const s=this.buffers;return s[Le.VALIDITY]=i,this.clone(this.type,0,t,r+(t-e),s)}_sliceBuffers(t,e,r,i){let s;const{buffers:o}=this;return(s=o[Le.TYPE])&&(o[Le.TYPE]=s.subarray(t,t+e)),(s=o[Le.OFFSET])&&(o[Le.OFFSET]=s.subarray(t,t+e+1))||(s=o[Le.DATA])&&(o[Le.DATA]=i===6?s:s.subarray(r*t,r*(t+e))),o}_sliceChildren(t,e,r){return t.map(i=>i.slice(e,r))}}ft.prototype.children=Object.freeze([]);class Tr extends X{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:e,["offset"]:r=0,["length"]:i=0}=t;return new ft(e,r,i,i)}visitBool(t){const{["type"]:e,["offset"]:r=0}=t,i=st(t.nullBitmap),s=yt(e.ArrayType,t.data),{["length"]:o=s.length>>3,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ft(e,r,o,a,[void 0,s,i])}visitInt(t){const{["type"]:e,["offset"]:r=0}=t,i=st(t.nullBitmap),s=yt(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ft(e,r,o,a,[void 0,s,i])}visitFloat(t){const{["type"]:e,["offset"]:r=0}=t,i=st(t.nullBitmap),s=yt(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ft(e,r,o,a,[void 0,s,i])}visitUtf8(t){const{["type"]:e,["offset"]:r=0}=t,i=st(t.data),s=st(t.nullBitmap),o=fr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new ft(e,r,a,c,[o,i,s])}visitLargeUtf8(t){const{["type"]:e,["offset"]:r=0}=t,i=st(t.data),s=st(t.nullBitmap),o=Qo(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new ft(e,r,a,c,[o,i,s])}visitBinary(t){const{["type"]:e,["offset"]:r=0}=t,i=st(t.data),s=st(t.nullBitmap),o=fr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new ft(e,r,a,c,[o,i,s])}visitLargeBinary(t){const{["type"]:e,["offset"]:r=0}=t,i=st(t.data),s=st(t.nullBitmap),o=Qo(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new ft(e,r,a,c,[o,i,s])}visitFixedSizeBinary(t){const{["type"]:e,["offset"]:r=0}=t,i=st(t.nullBitmap),s=yt(e.ArrayType,t.data),{["length"]:o=s.length/Ce(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ft(e,r,o,a,[void 0,s,i])}visitDate(t){const{["type"]:e,["offset"]:r=0}=t,i=st(t.nullBitmap),s=yt(e.ArrayType,t.data),{["length"]:o=s.length/Ce(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ft(e,r,o,a,[void 0,s,i])}visitTimestamp(t){const{["type"]:e,["offset"]:r=0}=t,i=st(t.nullBitmap),s=yt(e.ArrayType,t.data),{["length"]:o=s.length/Ce(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ft(e,r,o,a,[void 0,s,i])}visitTime(t){const{["type"]:e,["offset"]:r=0}=t,i=st(t.nullBitmap),s=yt(e.ArrayType,t.data),{["length"]:o=s.length/Ce(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ft(e,r,o,a,[void 0,s,i])}visitDecimal(t){const{["type"]:e,["offset"]:r=0}=t,i=st(t.nullBitmap),s=yt(e.ArrayType,t.data),{["length"]:o=s.length/Ce(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ft(e,r,o,a,[void 0,s,i])}visitList(t){const{["type"]:e,["offset"]:r=0,["child"]:i}=t,s=st(t.nullBitmap),o=fr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new ft(e,r,a,c,[o,void 0,s],[i])}visitStruct(t){const{["type"]:e,["offset"]:r=0,["children"]:i=[]}=t,s=st(t.nullBitmap),{length:o=i.reduce((c,{length:u})=>Math.max(c,u),0),nullCount:a=t.nullBitmap?-1:0}=t;return new ft(e,r,o,a,[void 0,void 0,s],i)}visitUnion(t){const{["type"]:e,["offset"]:r=0,["children"]:i=[]}=t,s=yt(e.ArrayType,t.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=t;if(L.isSparseUnion(e))return new ft(e,r,o,a,[void 0,void 0,void 0,s],i);const c=fr(t.valueOffsets);return new ft(e,r,o,a,[c,void 0,void 0,s],i)}visitDictionary(t){const{["type"]:e,["offset"]:r=0}=t,i=st(t.nullBitmap),s=yt(e.indices.ArrayType,t.data),{["dictionary"]:o=new ut([new Tr().visit({type:e.dictionary})])}=t,{["length"]:a=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new ft(e,r,a,c,[void 0,s,i],[],o)}visitInterval(t){const{["type"]:e,["offset"]:r=0}=t,i=st(t.nullBitmap),s=yt(e.ArrayType,t.data),{["length"]:o=s.length/Ce(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ft(e,r,o,a,[void 0,s,i])}visitDuration(t){const{["type"]:e,["offset"]:r=0}=t,i=st(t.nullBitmap),s=yt(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ft(e,r,o,a,[void 0,s,i])}visitFixedSizeList(t){const{["type"]:e,["offset"]:r=0,["child"]:i=new Tr().visit({type:e.valueType})}=t,s=st(t.nullBitmap),{["length"]:o=i.length/Ce(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ft(e,r,o,a,[void 0,void 0,s],[i])}visitMap(t){const{["type"]:e,["offset"]:r=0,["child"]:i=new Tr().visit({type:e.childType})}=t,s=st(t.nullBitmap),o=fr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new ft(e,r,a,c,[o,void 0,s],[i])}}const Bh=new Tr;function et(n){return Bh.visit(n)}class ca{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndext.nullable)}function cu(n){return n.reduce((t,e)=>t+e.nullCount,0)}function uu(n){return n.reduce((t,e,r)=>(t[r+1]=t[r]+e.length,t),new Uint32Array(n.length+1))}function lu(n,t,e,r){const i=[];for(let s=-1,o=n.length;++s=r)break;if(e>=c+u)continue;if(c>=e&&c+u<=r){i.push(a);continue}const d=Math.max(0,e-c),w=Math.min(r-c,u);i.push(a.slice(d,w-d))}return i.length===0&&i.push(n[0].slice(0,0)),i}function co(n,t,e,r){let i=0,s=0,o=t.length-1;do{if(i>=o-1)return e0?0:-1}function Ch(n,t){const{nullBitmap:e}=n;if(!e||n.nullCount<=0)return-1;let r=0;for(const i of new ao(e,n.offset+(t||0),n.length,e,au)){if(!i)return r;++r}return-1}function Y(n,t,e){if(t===void 0)return-1;if(t===null)switch(n.typeId){case l.Union:break;case l.Dictionary:break;default:return Ch(n,e)}const r=Jt.getVisitFn(n),i=or(t);for(let s=(e||0)-1,o=n.length;++s{const i=n.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let e=0;return new ca(n.data.length,r=>{const s=n.data[r].length,o=n.slice(e,e+s);return e+=s,new Uh(o)})}class Uh{constructor(t){this.vector=t,this.index=0}next(){return this.indexa.data):t;if(s.length===0||s.some(a=>!(a instanceof ft)))throw new TypeError("Vector constructor expects an Array of Data instances.");const o=(e=s[0])===null||e===void 0?void 0:e.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:a,set:c,indexOf:u}=yu[o.typeId],d=s[0];this.isValid=w=>uo(d,w),this.get=w=>a(d,w),this.set=(w,F)=>c(d,w,F),this.indexOf=w=>u(d,w),this._offsets=[0,d.length];break}default:Object.setPrototypeOf(this,mu[o.typeId]),this._offsets=uu(s);break}this.data=s,this.type=o,this.stride=Ce(o),this.numChildren=(i=(r=o.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,e)=>t+e.byteLength,0)}get nullable(){return Mh(this.data)}get nullCount(){return cu(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${l[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(oo(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return lo.visit(this)}concat(...t){return new ut(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new ut(ou(this,t,e,({data:r,_offsets:i},s,o)=>lu(r,i,s,o)))}toJSON(){return[...this]}toArray(){const{type:t,data:e,length:r,stride:i,ArrayType:s}=this;switch(t.typeId){case l.Int:case l.Float:case l.Decimal:case l.Time:case l.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,r*i);default:return e.reduce((o,{values:a,length:c})=>(o.array.set(a.subarray(0,c*i),o.offset),o.offset+=c*i,o),{array:new s(r*i),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(r=>r.name===t))}getChildAt(t){return t>-1&&te[t])):null}get isMemoized(){return L.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(L.isDictionary(this.type)){const t=new Vi(this.data[0].dictionary),e=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new ut(e)}return new Vi(this)}unmemoize(){if(L.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),e=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new ut(e)}return this}}pu=Symbol.toStringTag;ut[pu]=(n=>{n.type=L.prototype,n.data=[],n.length=0,n.stride=1,n.numChildren=0,n._offsets=new Uint32Array([0]),n[Symbol.isConcatSpreadable]=!0;const t=Object.keys(l).map(e=>l[e]).filter(e=>typeof e=="number"&&e!==l.NONE);for(const e of t){const r=Jt.getVisitFnByTypeId(e),i=le.getVisitFnByTypeId(e),s=ji.getVisitFnByTypeId(e);yu[e]={get:r,set:i,indexOf:s},mu[e]=Object.create(n,{isValid:{value:ki(uo)},get:{value:ki(Jt.getVisitFnByTypeId(e))},set:{value:hu(le.getVisitFnByTypeId(e))},indexOf:{value:du(ji.getVisitFnByTypeId(e))}})}return"Vector"})(ut.prototype);class Vi extends ut{constructor(t){super(t.data);const e=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){const a=s[o];if(a!==void 0)return a;const c=e.call(this,o);return s[o]=c,c}}),Object.defineProperty(this,"set",{value(o,a){r.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new Vi(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new ut(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class js{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,r,i){return t.prep(8,24),t.writeInt64(BigInt(i??0)),t.pad(4),t.writeInt32(r),t.writeInt64(BigInt(e??0)),t.offset()}}class Xt{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 Xt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+ht),(e||new Xt).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Rt.V1}schema(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new we).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){const r=this.bb.__offset(this.bb_pos,8);return r?(e||new js).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}dictionariesLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,e){const r=this.bb.__offset(this.bb_pos,10);return r?(e||new js).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}recordBatchesLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const r=this.bb.__offset(this.bb_pos,12);return r?(e||new Mt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,Rt.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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}}class lt{constructor(t=[],e,r,i=Rt.V5){this.fields=t||[],this.metadata=e||new Map,r||(r=Vs(this.fields)),this.dictionaries=r,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,e)=>`${e}: ${t}`).join(", ")} }>`}select(t){const e=new Set(t),r=this.fields.filter(i=>e.has(i.name));return new lt(r,this.metadata)}selectAt(t){const e=t.map(r=>this.fields[r]).filter(Boolean);return new lt(e,this.metadata)}assign(...t){const e=t[0]instanceof lt?t[0]:Array.isArray(t[0])?new lt(t[0]):new lt(t),r=[...this.fields],i=ri(ri(new Map,this.metadata),e.metadata),s=e.fields.filter(a=>{const c=r.findIndex(u=>u.name===a.name);return~c?(r[c]=a.clone({metadata:ri(ri(new Map,r[c].metadata),a.metadata)}))&&!1:!0}),o=Vs(s,new Map);return new lt([...r,...s],i,new Map([...this.dictionaries,...o]))}}lt.prototype.fields=null;lt.prototype.metadata=null;lt.prototype.dictionaries=null;class St{static new(...t){let[e,r,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:e}=t[0],r===void 0&&(r=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new St(`${e}`,r,i,s)}constructor(t,e,r=!1,i){this.name=t,this.type=e,this.nullable=r,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,r,i,s]=t;return!t[0]||typeof t[0]!="object"?[e=this.name,r=this.type,i=this.nullable,s=this.metadata]=t:{name:e=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],St.new(e,r,i,s)}}St.prototype.type=null;St.prototype.name=null;St.prototype.nullable=null;St.prototype.metadata=null;function ri(n,t){return new Map([...n||new Map,...t||new Map])}function Vs(n,t=new Map){for(let e=-1,r=n.length;++e0&&Vs(s.children,t)}return t}var xh=ka,$h=Xn;class Dr{static decode(t){t=new $h(st(t));const e=Xt.getRootAsFooter(t),r=lt.decode(e.schema(),new Map,e.version());return new Ph(r,e)}static encode(t){const e=new xh,r=lt.encode(e,t.schema);Xt.startRecordBatchesVector(e,t.numRecordBatches);for(const o of[...t.recordBatches()].slice().reverse())sn.encode(e,o);const i=e.endVector();Xt.startDictionariesVector(e,t.numDictionaries);for(const o of[...t.dictionaryBatches()].slice().reverse())sn.encode(e,o);const s=e.endVector();return Xt.startFooter(e),Xt.addSchema(e,r),Xt.addVersion(e,Rt.V5),Xt.addRecordBatches(e,i),Xt.addDictionaries(e,s),Xt.finishFooterBuffer(e,Xt.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=Rt.V5,r,i){this.schema=t,this.version=e,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,e=-1,r=this.numRecordBatches;++e=0&&t=0&&t=0&&t=0&&tthis._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return Q(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){const{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(At);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return oe.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return oe.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return Q(this,void 0,void 0,function*(){return yield this.abort(t),At})}return(t){return Q(this,void 0,void 0,function*(){return yield this.close(),At})}read(t){return Q(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Q(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,r)=>{this.resolvers.push({resolve:e,reject:r})}):Promise.resolve(At)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class fi extends kh{write(t){if((t=st(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Ms(this.toUint8Array(!0)):this.toUint8Array(!1).then(Ms)}toUint8Array(t=!1){return t?Oe(this._values)[0]:Q(this,void 0,void 0,function*(){var e,r,i,s;const o=[];let a=0;try{for(var c=!0,u=En(this),d;d=yield u.next(),e=d.done,!e;c=!0){s=d.value,c=!1;const w=s;o.push(w),a+=w.byteLength}}catch(w){r={error:w}}finally{try{!c&&!e&&(i=u.return)&&(yield i.call(u))}finally{if(r)throw r.error}}return Oe(o,a)[0]})}}class zi{constructor(t){t&&(this.source=new jh(oe.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class nr{constructor(t){t instanceof nr?this.source=t.source:t instanceof fi?this.source=new hn(oe.fromAsyncIterable(t)):Ua(t)?this.source=new hn(oe.fromNodeStream(t)):to(t)?this.source=new hn(oe.fromDOMStream(t)):Ca(t)?this.source=new hn(oe.fromDOMStream(t.body)):Gr(t)?this.source=new hn(oe.fromIterable(t)):nn(t)?this.source=new hn(oe.fromAsyncIterable(t)):sr(t)&&(this.source=new hn(oe.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class jh{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)}}class hn{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return Q(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return Q(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Q(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return Q(this,arguments,void 0,function*(e,r="read"){return yield this.source.next({cmd:r,size:e})})}throw(t){return Q(this,void 0,void 0,function*(){const 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 Q(this,void 0,void 0,function*(){const e=this.source.return&&(yield this.source.return(t))||At;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}}class la extends zi{constructor(t,e){super(),this.position=0,this.buffer=st(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){const{buffer:e,byteOffset:r}=this.readAt(t,4);return new DataView(e,r).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let i=e[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=e[2]*r[3],s+=i,i=e[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0>>16,this.buffer[1]+=e[1]*r[3]+e[2]*r[2]+e[3]*r[1],this.buffer[1]+=e[0]*r[3]+e[1]*r[2]+e[2]*r[1]+e[3]*r[0]<<16,this}_plus(t){const e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]>>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]>>0&&++e[1],e[1]>>0&&++e[2],e[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`${jn(this.buffer[3])} ${jn(this.buffer[2])} ${jn(this.buffer[1])} ${jn(this.buffer[0])}`}static multiply(t,e){return new Se(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new Se(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return Se.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return Se.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){const r=t.startsWith("-"),i=t.length,s=new Se(e);for(let o=r?1:0;o0&&this.readData(t,r)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+e)}readDictionary(t){return this.dictionaries.get(t.id)}}class zh extends bu{constructor(t,e,r,i,s){super(new Uint8Array(0),e,r,i,s),this.sources=t}readNullBitmap(t,e,{offset:r}=this.nextBufferRange()){return e<=0?new Uint8Array(0):Pi(this.sources[r])}readOffsets(t,{offset:e}=this.nextBufferRange()){return yt(Uint8Array,yt(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return yt(Uint8Array,yt(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){const{sources:r}=this;return L.isTimestamp(t)||(L.isInt(t)||L.isTime(t))&&t.bitWidth===64||L.isDuration(t)||L.isDate(t)&&t.unit===ue.MILLISECOND?yt(Uint8Array,Yt.convertArray(r[e])):L.isDecimal(t)?yt(Uint8Array,Se.convertArray(r[e])):L.isBinary(t)||L.isLargeBinary(t)||L.isFixedSizeBinary(t)?qh(r[e]):L.isBool(t)?Pi(r[e]):L.isUtf8(t)||L.isLargeUtf8(t)?Xs(r[e].join("")):yt(Uint8Array,yt(t.ArrayType,r[e].map(i=>+i)))}}function qh(n){const t=n.join(""),e=new Uint8Array(t.length/2);for(let r=0;r>1]=Number.parseInt(t.slice(r,r+2),16);return e}class k extends X{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((r,i)=>this.compareFields(r,e[i]))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}}function Wt(n,t){return t instanceof n.constructor}function Fn(n,t){return n===t||Wt(n,t)}function Ve(n,t){return n===t||Wt(n,t)&&n.bitWidth===t.bitWidth&&n.isSigned===t.isSigned}function cs(n,t){return n===t||Wt(n,t)&&n.precision===t.precision}function Wh(n,t){return n===t||Wt(n,t)&&n.byteWidth===t.byteWidth}function po(n,t){return n===t||Wt(n,t)&&n.unit===t.unit}function Yr(n,t){return n===t||Wt(n,t)&&n.unit===t.unit&&n.timezone===t.timezone}function Qr(n,t){return n===t||Wt(n,t)&&n.unit===t.unit&&n.bitWidth===t.bitWidth}function Gh(n,t){return n===t||Wt(n,t)&&n.children.length===t.children.length&&on.compareManyFields(n.children,t.children)}function Yh(n,t){return n===t||Wt(n,t)&&n.children.length===t.children.length&&on.compareManyFields(n.children,t.children)}function yo(n,t){return n===t||Wt(n,t)&&n.mode===t.mode&&n.typeIds.every((e,r)=>e===t.typeIds[r])&&on.compareManyFields(n.children,t.children)}function Qh(n,t){return n===t||Wt(n,t)&&n.id===t.id&&n.isOrdered===t.isOrdered&&on.visit(n.indices,t.indices)&&on.visit(n.dictionary,t.dictionary)}function mo(n,t){return n===t||Wt(n,t)&&n.unit===t.unit}function Hr(n,t){return n===t||Wt(n,t)&&n.unit===t.unit}function Hh(n,t){return n===t||Wt(n,t)&&n.listSize===t.listSize&&n.children.length===t.children.length&&on.compareManyFields(n.children,t.children)}function Kh(n,t){return n===t||Wt(n,t)&&n.keysSorted===t.keysSorted&&n.children.length===t.children.length&&on.compareManyFields(n.children,t.children)}k.prototype.visitNull=Fn;k.prototype.visitBool=Fn;k.prototype.visitInt=Ve;k.prototype.visitInt8=Ve;k.prototype.visitInt16=Ve;k.prototype.visitInt32=Ve;k.prototype.visitInt64=Ve;k.prototype.visitUint8=Ve;k.prototype.visitUint16=Ve;k.prototype.visitUint32=Ve;k.prototype.visitUint64=Ve;k.prototype.visitFloat=cs;k.prototype.visitFloat16=cs;k.prototype.visitFloat32=cs;k.prototype.visitFloat64=cs;k.prototype.visitUtf8=Fn;k.prototype.visitLargeUtf8=Fn;k.prototype.visitBinary=Fn;k.prototype.visitLargeBinary=Fn;k.prototype.visitFixedSizeBinary=Wh;k.prototype.visitDate=po;k.prototype.visitDateDay=po;k.prototype.visitDateMillisecond=po;k.prototype.visitTimestamp=Yr;k.prototype.visitTimestampSecond=Yr;k.prototype.visitTimestampMillisecond=Yr;k.prototype.visitTimestampMicrosecond=Yr;k.prototype.visitTimestampNanosecond=Yr;k.prototype.visitTime=Qr;k.prototype.visitTimeSecond=Qr;k.prototype.visitTimeMillisecond=Qr;k.prototype.visitTimeMicrosecond=Qr;k.prototype.visitTimeNanosecond=Qr;k.prototype.visitDecimal=Fn;k.prototype.visitList=Gh;k.prototype.visitStruct=Yh;k.prototype.visitUnion=yo;k.prototype.visitDenseUnion=yo;k.prototype.visitSparseUnion=yo;k.prototype.visitDictionary=Qh;k.prototype.visitInterval=mo;k.prototype.visitIntervalDayTime=mo;k.prototype.visitIntervalYearMonth=mo;k.prototype.visitDuration=Hr;k.prototype.visitDurationSecond=Hr;k.prototype.visitDurationMillisecond=Hr;k.prototype.visitDurationMicrosecond=Hr;k.prototype.visitDurationNanosecond=Hr;k.prototype.visitFixedSizeList=Hh;k.prototype.visitMap=Kh;const on=new k;function zs(n,t){return on.compareSchemas(n,t)}function _s(n,t){return Jh(n,t.map(e=>e.data.concat()))}function Jh(n,t){const e=[...n.fields],r=[],i={numBatches:t.reduce((w,F)=>Math.max(w,F.length),0)};let s=0,o=0,a=-1;const c=t.length;let u,d=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a0&&(r[s++]=et({type:new zt(e),length:o,nullCount:0,children:d.slice()})))}return[n=n.assign(e),r.map(w=>new Ht(n,w))]}function Zh(n,t,e,r,i){var s;const o=(t+63&-64)>>3;for(let a=-1,c=r.length;++a=t)d===t?e[a]=u:(e[a]=u.slice(0,t),i.numBatches=Math.max(i.numBatches,r[a].unshift(u.slice(t,d-t))));else{const w=n[a];n[a]=w.clone({nullable:!0}),e[a]=(s=u==null?void 0:u._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:et({type:w.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var _u;class Ut{constructor(...t){var e,r;if(t.length===0)return this.batches=[],this.schema=new lt([]),this._offsets=[0],this;let i,s;t[0]instanceof lt&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());const o=c=>{if(c){if(c instanceof Ht)return[c];if(c instanceof Ut)return c.batches;if(c instanceof ft){if(c.type instanceof zt)return[new Ht(new lt(c.type.children),c)]}else{if(Array.isArray(c))return c.flatMap(u=>o(u));if(typeof c[Symbol.iterator]=="function")return[...c].flatMap(u=>o(u));if(typeof c=="object"){const u=Object.keys(c),d=u.map(v=>new ut([c[v]])),w=i??new lt(u.map((v,N)=>new St(String(v),d[N].type,d[N].nullable))),[,F]=_s(w,d);return F.length===0?[new Ht(c)]:F}}}return[]},a=t.flatMap(c=>o(c));if(i=(r=i??((e=a[0])===null||e===void 0?void 0:e.schema))!==null&&r!==void 0?r:new lt([]),!(i instanceof lt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const c of a){if(!(c instanceof Ht))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!zs(i,c.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??uu(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=cu(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(oo(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?lo.visit(new ut(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ ${this.toArray().join(`, `)} ]`}concat(...t){const e=this.schema,r=this.data.concat(t.flatMap(({data:i})=>i));return new Ut(e,r.map(i=>new Ht(e,i)))}slice(t,e){const r=this.schema;[t,e]=ou({length:this.numRows},t,e);const i=lu(this.data,this._offsets,t,e);return new Ut(r,i.map(s=>new Ht(r,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&tr.children[t]);if(e.length===0){const{type:r}=this.schema.fields[t],i=et({type:r,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new ut(e)}return null}setChild(t,e){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),e)}setChildAt(t,e){let r=this.schema,i=[...this.batches];if(t>-1&&tthis.getChildAt(u));[s[t],a[t]]=[o,e],[r,i]=_s(r,a)}return new Ut(r,i)}select(t){const e=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(t.map(r=>e.get(r)).filter(r=>r>-1))}selectAt(t){const e=this.schema.selectAt(t),r=this.batches.map(i=>i.selectAt(t));return new Ut(e,r)}assign(t){const e=this.schema.fields,[r,i]=t.schema.fields.reduce((a,c,u)=>{const[d,w]=a,F=e.findIndex(v=>v.name===c.name);return~F?w[F]=u:d.push(u),a},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((a,c)=>[c,i[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...r.map(a=>t.getChildAt(a))].filter(Boolean);return new Ut(..._s(s,o))}}_u=Symbol.toStringTag;Ut[_u]=(n=>(n.schema=null,n.batches=[],n._offsets=new Uint32Array([0]),n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,n.isValid=ki(uo),n.get=ki(Jt.getVisitFn(l.Struct)),n.set=hu(le.getVisitFn(l.Struct)),n.indexOf=du(ji.getVisitFn(l.Struct)),"Table"))(Ut.prototype);var wu;let Ht=class Sr{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof lt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=et({nullCount:0,type:new zt(this.schema.fields),children:this.schema.fields.map(e=>et({type:e.type,nullCount:0}))})]=t,!(this.data instanceof ft))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=ha(this.schema,this.data.children);break}case 1:{const[e]=t,{fields:r,children:i,length:s}=Object.keys(e).reduce((c,u,d)=>(c.children[d]=e[u],c.length=Math.max(c.length,e[u].length),c.fields[d]=St.new({name:u,type:e[u].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new lt(r),a=et({type:new zt(r),length:s,children:i,nullCount:0});[this.schema,this.data]=ha(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=Su(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 Jt.visit(this.data,t)}at(t){return this.get(oo(t,this.numRows))}set(t,e){return le.visit(this.data,t,e)}indexOf(t,e){return ji.visit(this.data,t,e)}[Symbol.iterator](){return lo.visit(new ut([this.data]))}toArray(){return[...this]}concat(...t){return new Ut(this.schema,[this,...t])}slice(t,e){const[r]=new ut([this.data]).slice(t,e).data;return new Sr(this.schema,r)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&ti.name===t),e)}setChildAt(t,e){let r=this.schema,i=this.data;if(t>-1&&ta.name===s);~o&&(i[o]=this.data.children[o])}return new Sr(e,et({type:r,length:this.numRows,children:i}))}selectAt(t){const e=this.schema.selectAt(t),r=t.map(s=>this.data.children[s]).filter(Boolean),i=et({type:new zt(e.fields),length:this.numRows,children:r});return new Sr(e,i)}};wu=Symbol.toStringTag;Ht[wu]=(n=>(n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Ht.prototype);function ha(n,t,e=t.reduce((r,i)=>Math.max(r,i.length),0)){var r;const i=[...n.fields],s=[...t],o=(e+63&-64)>>3;for(const[a,c]of n.fields.entries()){const u=t[a];(!u||u.length!==e)&&(i[a]=c.clone({nullable:!0}),s[a]=(r=u==null?void 0:u._changeLengthAndBackfillNullBitmap(e))!==null&&r!==void 0?r:et({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[n.assign(i),et({type:new zt(i),length:e,children:s})]}function Su(n,t,e=new Map){var r,i;if(((r=n==null?void 0:n.length)!==null&&r!==void 0?r:0)>0&&(n==null?void 0:n.length)===(t==null?void 0:t.length))for(let s=-1,o=n.length;++set({type:i.type})),r=et({type:new zt(t.fields),nullCount:0,children:e});super(t,r)}}let We=class _e{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new _e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+ht),(e||new _e).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Rt.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):ct.NONE}header(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){const r=this.bb.__offset(this.bb_pos,12);return r?(e||new Mt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,Rt.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,ct.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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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,r,i,s,o){return _e.startMessage(t),_e.addVersion(t,e),_e.addHeaderType(t,r),_e.addHeader(t,i),_e.addBodyLength(t,s),_e.addCustomMetadata(t,o),_e.endMessage(t)}};class Xh extends X{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return na.startNull(e),na.endNull(e)}visitInt(t,e){return te.startInt(e),te.addBitWidth(e,t.bitWidth),te.addIsSigned(e,t.isSigned),te.endInt(e)}visitFloat(t,e){return ve.startFloatingPoint(e),ve.addPrecision(e,t.precision),ve.endFloatingPoint(e)}visitBinary(t,e){return Jo.startBinary(e),Jo.endBinary(e)}visitLargeBinary(t,e){return Xo.startLargeBinary(e),Xo.endLargeBinary(e)}visitBool(t,e){return Zo.startBool(e),Zo.endBool(e)}visitUtf8(t,e){return ra.startUtf8(e),ra.endUtf8(e)}visitLargeUtf8(t,e){return ta.startLargeUtf8(e),ta.endLargeUtf8(e)}visitDecimal(t,e){return Bn.startDecimal(e),Bn.addScale(e,t.scale),Bn.addPrecision(e,t.precision),Bn.addBitWidth(e,t.bitWidth),Bn.endDecimal(e)}visitDate(t,e){return ai.startDate(e),ai.addUnit(e,t.unit),ai.endDate(e)}visitTime(t,e){return ae.startTime(e),ae.addUnit(e,t.unit),ae.addBitWidth(e,t.bitWidth),ae.endTime(e)}visitTimestamp(t,e){const r=t.timezone&&e.createString(t.timezone)||void 0;return ce.startTimestamp(e),ce.addUnit(e,t.unit),r!==void 0&&ce.addTimezone(e,r),ce.endTimestamp(e)}visitInterval(t,e){return Ee.startInterval(e),Ee.addUnit(e,t.unit),Ee.endInterval(e)}visitDuration(t,e){return ci.startDuration(e),ci.addUnit(e,t.unit),ci.endDuration(e)}visitList(t,e){return ea.startList(e),ea.endList(e)}visitStruct(t,e){return mn.startStruct_(e),mn.endStruct_(e)}visitUnion(t,e){Qt.startTypeIdsVector(e,t.typeIds.length);const r=Qt.createTypeIdsVector(e,t.typeIds);return Qt.startUnion(e),Qt.addMode(e,t.mode),Qt.addTypeIds(e,r),Qt.endUnion(e)}visitDictionary(t,e){const r=this.visit(t.indices,e);return ke.startDictionaryEncoding(e),ke.addId(e,BigInt(t.id)),ke.addIsOrdered(e,t.isOrdered),r!==void 0&&ke.addIndexType(e,r),ke.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return ui.startFixedSizeBinary(e),ui.addByteWidth(e,t.byteWidth),ui.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return li.startFixedSizeList(e),li.addListSize(e,t.listSize),li.endFixedSizeList(e)}visitMap(t,e){return hi.startMap(e),hi.addKeysSorted(e,t.keysSorted),hi.endMap(e)}}const ws=new Xh;function td(n,t=new Map){return new lt(nd(n,t),pi(n.metadata),t)}function Iu(n){return new ne(n.count,vu(n.columns),Eu(n.columns))}function ed(n){return new Ne(Iu(n.data),n.id,n.isDelta)}function nd(n,t){return(n.fields||[]).filter(Boolean).map(e=>St.fromJSON(e,t))}function da(n,t){return(n.children||[]).filter(Boolean).map(e=>St.fromJSON(e,t))}function vu(n){return(n||[]).reduce((t,e)=>[...t,new an(e.count,rd(e.VALIDITY)),...vu(e.children)],[])}function Eu(n,t=[]){for(let e=-1,r=(n||[]).length;++et+ +(e===0),0)}function id(n,t){let e,r,i,s,o,a;return!t||!(s=n.dictionary)?(o=pa(n,da(n,t)),i=new St(n.name,o,n.nullable,pi(n.metadata))):t.has(e=s.id)?(r=(r=s.indexType)?fa(r):new Rr,a=new er(t.get(e),r,e,s.isOrdered),i=new St(n.name,a,n.nullable,pi(n.metadata))):(r=(r=s.indexType)?fa(r):new Rr,t.set(e,o=pa(n,da(n,t))),a=new er(o,r,e,s.isOrdered),i=new St(n.name,a,n.nullable,pi(n.metadata))),i||null}function pi(n=[]){return new Map(n.map(({key:t,value:e})=>[t,e]))}function fa(n){return new On(n.isSigned,n.bitWidth)}function pa(n,t){const e=n.type.name;switch(e){case"NONE":return new rn;case"null":return new rn;case"binary":return new Ii;case"largebinary":return new vi;case"utf8":return new Ei;case"largeutf8":return new Ti;case"bool":return new Ai;case"list":return new Mi((t||[])[0]);case"struct":return new zt(t||[]);case"struct_":return new zt(t||[])}switch(e){case"int":{const r=n.type;return new On(r.isSigned,r.bitWidth)}case"floatingpoint":{const r=n.type;return new Si(Pt[r.precision])}case"decimal":{const r=n.type;return new Oi(r.scale,r.precision,r.bitWidth)}case"date":{const r=n.type;return new Fi(ue[r.unit])}case"time":{const r=n.type;return new Ni(j[r.unit],r.bitWidth)}case"timestamp":{const r=n.type;return new Ri(j[r.unit],r.timezone)}case"interval":{const r=n.type;return new Di(Fe[r.unit])}case"duration":{const r=n.type;return new Bi(j[r.unit])}case"union":{const r=n.type,[i,...s]=(r.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new Li(kt[o],r.typeIds||[],t||[])}case"fixedsizebinary":{const r=n.type;return new Ci(r.byteWidth)}case"fixedsizelist":{const r=n.type;return new Ui(r.listSize,(t||[])[0])}case"map":{const r=n.type;return new xi((t||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var sd=ka,od=Xn;class qt{static fromJSON(t,e){const r=new qt(0,Rt.V5,e);return r._createHeader=ad(t,e),r}static decode(t){t=new od(st(t));const e=We.getRootAsMessage(t),r=e.bodyLength(),i=e.version(),s=e.headerType(),o=new qt(r,i,s);return o._createHeader=cd(e,s),o}static encode(t){const e=new sd;let r=-1;return t.isSchema()?r=lt.encode(e,t.header()):t.isRecordBatch()?r=ne.encode(e,t.header()):t.isDictionaryBatch()&&(r=Ne.encode(e,t.header())),We.startMessage(e),We.addVersion(e,Rt.V5),We.addHeader(e,r),We.addHeaderType(e,t.headerType),We.addBodyLength(e,BigInt(t.bodyLength)),We.finishMessageBuffer(e,We.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof lt)return new qt(0,Rt.V5,ct.Schema,t);if(t instanceof ne)return new qt(e,Rt.V5,ct.RecordBatch,t);if(t instanceof Ne)return new qt(e,Rt.V5,ct.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===ct.Schema}isRecordBatch(){return this.headerType===ct.RecordBatch}isDictionaryBatch(){return this.headerType===ct.DictionaryBatch}constructor(t,e,r,i){this._version=e,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=gt(t)}}class ne{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,r){this._nodes=e,this._buffers=r,this._length=gt(t)}}class Ne{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,r=!1){this._data=t,this._isDelta=r,this._id=gt(e)}}class Ae{constructor(t,e){this.offset=gt(t),this.length=gt(e)}}class an{constructor(t,e){this.length=gt(t),this.nullCount=gt(e)}}function ad(n,t){return(()=>{switch(t){case ct.Schema:return lt.fromJSON(n);case ct.RecordBatch:return ne.fromJSON(n);case ct.DictionaryBatch:return Ne.fromJSON(n)}throw new Error(`Unrecognized Message type: { name: ${ct[t]}, type: ${t} }`)})}function cd(n,t){return(()=>{switch(t){case ct.Schema:return lt.decode(n.header(new we),new Map,n.version());case ct.RecordBatch:return ne.decode(n.header(new Me),n.version());case ct.DictionaryBatch:return Ne.decode(n.header(new Rn),n.version())}throw new Error(`Unrecognized Message type: { name: ${ct[t]}, type: ${t} }`)})}St.encode=_d;St.decode=gd;St.fromJSON=id;lt.encode=bd;lt.decode=ud;lt.fromJSON=td;ne.encode=wd;ne.decode=ld;ne.fromJSON=Iu;Ne.encode=Sd;Ne.decode=hd;Ne.fromJSON=ed;an.encode=Id;an.decode=fd;Ae.encode=vd;Ae.decode=dd;function ud(n,t=new Map,e=Rt.V5){const r=md(n,t);return new lt(r,yi(n),t,e)}function ld(n,t=Rt.V5){if(n.compression()!==null)throw new Error("Record batch compression not implemented");return new ne(n.length(),pd(n),yd(n,t))}function hd(n,t=Rt.V5){return new Ne(ne.decode(n.data(),t),n.id(),n.isDelta())}function dd(n){return new Ae(n.offset(),n.length())}function fd(n){return new an(n.length(),n.nullCount())}function pd(n){const t=[];for(let e,r=-1,i=-1,s=n.nodesLength();++rSt.encode(n,s));we.startFieldsVector(n,e.length);const r=we.createFieldsVector(n,e),i=t.metadata&&t.metadata.size>0?we.createCustomMetadataVector(n,[...t.metadata].map(([s,o])=>{const a=n.createString(`${s}`),c=n.createString(`${o}`);return Mt.startKeyValue(n),Mt.addKey(n,a),Mt.addValue(n,c),Mt.endKeyValue(n)})):-1;return we.startSchema(n),we.addFields(n,r),we.addEndianness(n,Ed?tr.Little:tr.Big),i!==-1&&we.addCustomMetadata(n,i),we.endSchema(n)}function _d(n,t){let e=-1,r=-1,i=-1;const s=t.type;let o=t.typeId;L.isDictionary(s)?(o=s.dictionary.typeId,i=ws.visit(s,n),r=ws.visit(s.dictionary,n)):r=ws.visit(s,n);const a=(s.children||[]).map(d=>St.encode(n,d)),c=re.createChildrenVector(n,a),u=t.metadata&&t.metadata.size>0?re.createCustomMetadataVector(n,[...t.metadata].map(([d,w])=>{const F=n.createString(`${d}`),v=n.createString(`${w}`);return Mt.startKeyValue(n),Mt.addKey(n,F),Mt.addValue(n,v),Mt.endKeyValue(n)})):-1;return t.name&&(e=n.createString(t.name)),re.startField(n),re.addType(n,r),re.addTypeType(n,o),re.addChildren(n,c),re.addNullable(n,!!t.nullable),e!==-1&&re.addName(n,e),i!==-1&&re.addDictionary(n,i),u!==-1&&re.addCustomMetadata(n,u),re.endField(n)}function wd(n,t){const e=t.nodes||[],r=t.buffers||[];Me.startNodesVector(n,e.length);for(const o of e.slice().reverse())an.encode(n,o);const i=n.endVector();Me.startBuffersVector(n,r.length);for(const o of r.slice().reverse())Ae.encode(n,o);const s=n.endVector();return Me.startRecordBatch(n),Me.addLength(n,BigInt(t.length)),Me.addNodes(n,i),Me.addBuffers(n,s),Me.endRecordBatch(n)}function Sd(n,t){const e=ne.encode(n,t.data);return Rn.startDictionaryBatch(n),Rn.addId(n,BigInt(t.id)),Rn.addIsDelta(n,t.isDelta),Rn.addData(n,e),Rn.endDictionaryBatch(n)}function Id(n,t){return za.createFieldNode(n,BigInt(t.length),BigInt(t.nullCount))}function vd(n,t){return Va.createBuffer(n,BigInt(t.offset),BigInt(t.length))}const Ed=(()=>{const n=new ArrayBuffer(2);return new DataView(n).setInt16(0,256,!0),new Int16Array(n)[0]===256})(),bo=n=>`Expected ${ct[n]} Message in stream, but was null or length 0.`,_o=n=>`Header pointer of flatbuffer-encoded ${ct[n]} Message is null or length 0.`,Tu=(n,t)=>`Expected to read ${n} metadata bytes, but only read ${t}.`,Au=(n,t)=>`Expected to read ${n} bytes for message body, but only read ${t}.`;class Ou{constructor(t){this.source=t instanceof zi?t:new zi(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done||t.value===-1&&(t=this.readMetadataLength()).done||(t=this.readMetadata(t.value)).done?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(bo(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const e=st(this.source.read(t));if(e.byteLength[...i,...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(bo(t));return e.value}readSchema(){const t=ct.Schema,e=this.readMessage(t),r=e==null?void 0:e.header();if(!e||!r)throw new Error(_o(t));return r}}const us=4,qs="ARROW1",Br=new Uint8Array(qs.length);for(let n=0;nthis):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 oe.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return oe.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 ee?t:Ls(t)?Dd(t):La(t)?Ld(t):nn(t)?Q(this,void 0,void 0,function*(){return yield ee.from(yield t)}):Ca(t)||to(t)||Ua(t)||sr(t)?Md(new nr(t)):Bd(new zi(t))}static readAll(t){return t instanceof ee?t.isSync()?ba(t):_a(t):Ls(t)||ArrayBuffer.isView(t)||Gr(t)||Ma(t)?ba(t):_a(t)}}class Wi extends ee{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Te(this,arguments,function*(){yield K(yield*oi(En(this[Symbol.iterator]())))})}}class Gi extends ee{constructor(t){super(t),this._impl=t}readAll(){return Q(this,void 0,void 0,function*(){var t,e,r,i;const s=new Array;try{for(var o=!0,a=En(this),c;c=yield a.next(),t=c.done,!t;o=!0){i=c.value,o=!1;const u=i;s.push(u)}}catch(u){e={error:u}}finally{try{!o&&!t&&(r=a.return)&&(yield r.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]()}}class Nu extends Wi{constructor(t){super(t),this._impl=t}}class Fd extends Gi{constructor(t){super(t),this._impl=t}}class Ru{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){const r=this._loadVectors(t,e,this.schema.fields),i=et({type:new zt(this.schema.fields),length:t.length,children:r});return new Ht(this.schema,i)}_loadDictionaryBatch(t,e){const{id:r,isDelta:i}=t,{dictionaries:s,schema:o}=this,a=s.get(r),c=o.dictionaries.get(r),u=this._loadVectors(t.data,e,[c]);return(a&&i?a.concat(new ut(u)):new ut(u)).memoize()}_loadVectors(t,e,r){return new bu(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}class Yi extends Ru{constructor(t,e){super(e),this._reader=Ls(t)?new Ad(this._handle=t):new Ou(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=Bu(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;const{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new go(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class Qi extends Ru{constructor(t,e){super(e),this._reader=new Td(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Q(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 Q(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Bu(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return Q(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):At})}return(t){return Q(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):At})}next(){return Q(this,void 0,void 0,function*(){if(this.closed)return At;let t;const{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new go(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return Q(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class Du extends Yi{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,e){super(t instanceof la?t:new la(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();const r=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(ct.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;const r=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(ct.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){const{_handle:t}=this,e=t.size-Fu,r=t.readInt32(e),i=t.readAt(e-r,r);return Dr.decode(i)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Q(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return Q(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());const r=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(ct.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return Q(this,void 0,void 0,function*(){var e;const r=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(ct.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return Q(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const e=t.size-Fu,r=yield t.readInt32(e),i=yield t.readAt(e-r,r);return Dr.decode(i)})}_readNextMessageAndValidate(t){return Q(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?wo(t)?new Nu(new Du(n.read())):new Wi(new Yi(n)):new Wi(new Yi((function*(){})()))}function Md(n){return Q(this,void 0,void 0,function*(){const t=yield n.peek(Kr+7&-8);return t&&t.byteLength>=4?wo(t)?new Nu(new Du(yield n.read())):new Gi(new Qi(n)):new Gi(new Qi((function(){return Te(this,arguments,function*(){})})()))})}function Ld(n){return Q(this,void 0,void 0,function*(){const{size:t}=yield n.stat(),e=new qi(n,t);return t>=Od&&wo(yield e.readAt(0,Kr+7&-8))?new Fd(new Nd(e)):new Gi(new Qi(e))})}class Ot extends X{static assemble(...t){const e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof Ht?s.data.children:s.data),r=new Ot;return r.visitMany(e(t)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof ut)return this.visitMany(t.data),this;const{type:e}=t;if(!L.isDictionary(e)){const{length:r}=t;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(L.isUnion(e))this.nodes.push(new an(r,0));else{const{nullCount:i}=t;L.isNull(e)||ge.call(this,i<=0?new Uint8Array(0):$i(t.offset,r,t.nullBitmap)),this.nodes.push(new an(r,i))}}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 ge(n){const t=n.byteLength+7&-8;return this.buffers.push(n),this.bufferRegions.push(new Ae(this._byteLength,t)),this._byteLength+=t,this}function Cd(n){var t;const{type:e,length:r,typeIds:i,valueOffsets:s}=n;if(ge.call(this,i),e.mode===kt.Sparse)return Ws.call(this,n);if(e.mode===kt.Dense){if(n.offset<=0)return ge.call(this,s),Ws.call(this,n);{const o=new Int32Array(r),a=Object.create(null),c=Object.create(null);for(let u,d,w=-1;++w{const w=e.typeIds[d],F=a[w],v=c[w];return u.slice(F,Math.min(r,v))}))}}return this}function Ud(n){let t;return n.nullCount>=n.length?ge.call(this,new Uint8Array(0)):(t=n.values)instanceof Uint8Array?ge.call(this,$i(n.offset,n.length,t)):ge.call(this,Pi(n.values))}function ze(n){return ge.call(this,n.values.subarray(0,n.length*n.stride))}function ls(n){const{length:t,values:e,valueOffsets:r}=n,i=gt(r[0]),s=gt(r[t]),o=Math.min(s-i,e.byteLength-i);return ge.call(this,$a(-i,t+1,r)),ge.call(this,e.subarray(i,i+o)),this}function So(n){const{length:t,valueOffsets:e}=n;if(e){const{[0]:r,[t]:i}=e;return ge.call(this,$a(-r,t+1,e)),this.visit(n.children[0].slice(r,i-r))}return this.visit(n.children[0])}function Ws(n){return this.visitMany(n.type.children.map((t,e)=>n.children[e]).filter(Boolean))[0]}Ot.prototype.visitBool=Ud;Ot.prototype.visitInt=ze;Ot.prototype.visitFloat=ze;Ot.prototype.visitUtf8=ls;Ot.prototype.visitLargeUtf8=ls;Ot.prototype.visitBinary=ls;Ot.prototype.visitLargeBinary=ls;Ot.prototype.visitFixedSizeBinary=ze;Ot.prototype.visitDate=ze;Ot.prototype.visitTimestamp=ze;Ot.prototype.visitTime=ze;Ot.prototype.visitDecimal=ze;Ot.prototype.visitList=So;Ot.prototype.visitStruct=Ws;Ot.prototype.visitUnion=Cd;Ot.prototype.visitInterval=ze;Ot.prototype.visitDuration=ze;Ot.prototype.visitFixedSizeList=So;Ot.prototype.visitMap=So;class Mu extends ho{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 fi,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Kt(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 nn(t)?t.then(e=>this.writeAll(e)):sr(t)?To(this,t):Eo(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 fi?this._sink=t:(this._sink=new fi,t&&fl(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&pl(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||!zs(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 Ut&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof Ht&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!zs(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof Ht?t instanceof go||this._writeRecordBatch(t):t instanceof Ut?this.writeAll(t.batches):Gr(t)&&this.writeAll(t)}_writeMessage(t,e=8){const r=e-1,i=qt.encode(t),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+r&~r,c=a-s-o;return t.headerType===ct.RecordBatch?this._recordBatchBlocks.push(new sn(a,t.bodyLength,this._position)):t.headerType===ct.DictionaryBatch&&this._dictionaryBlocks.push(new sn(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(c)}_write(t){if(this._started){const e=st(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(qt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Br)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:e,nodes:r,bufferRegions:i,buffers:s}=Ot.assemble(t),o=new ne(t.numRows,r,i),a=qt.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,r=!1){const{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=Ot.assemble(new ut([t])),c=new ne(t.length,s,o),u=new Ne(c,e,r),d=qt.from(u,i);return this._writeMessage(d)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,r,i;for(let s=-1,o=t.length;++s0&&(this._write(e),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(t){var e,r;for(const[i,s]of t.dictionaries){const o=(e=s==null?void 0:s.data)!==null&&e!==void 0?e:[],a=this._seenDictionaries.get(i),c=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!a||a.data[0]!==o[0])for(const[u,d]of o.entries())this._writeDictionaryBatch(d,i,u>0);else if(cr.writeAll(i)):sr(t)?To(r,t):Eo(r,t)}}class vo extends Mu{static writeAll(t){const e=new vo;return nn(t)?t.then(r=>e.writeAll(r)):sr(t)?To(e,t):Eo(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,r=!1){if(!r&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,r)}_writeFooter(t){const e=Dr.encode(new Dr(t,Rt.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}}function Eo(n,t){let e=t;t instanceof Ut&&(e=t.batches,n.reset(void 0,t.schema));for(const r of e)n.write(r);return n.finish()}function To(n,t){return Q(this,void 0,void 0,function*(){var e,r,i,s,o,a,c;try{for(e=!0,r=En(t);i=yield r.next(),s=i.done,!s;e=!0){c=i.value,e=!1;const u=c;n.write(u)}}catch(u){o={error:u}}finally{try{!e&&!s&&(a=r.return)&&(yield a.call(r))}finally{if(o)throw o.error}}return n.finish()})}function xd(n){const t=ee.from(n);return nn(t)?t.then(e=>xd(e)):t.isAsync()?t.readAll().then(e=>new Ut(e)):new Ut(t.readAll())}function $d(n,t="stream"){return(t==="stream"?Io:vo).writeAll(n).toUint8Array(!0)}function Pd(n){switch(n.typeId){case l.Date:return"date";case l.Float:case l.Int:return"number";case l.Bool:return"boolean";case l.Dictionary:default:return"string"}}function kd(n){if(n==null)return[];const t=n.toArray();Object.defineProperty(t,"_evidenceColumnTypes",{enumerable:!1,value:n.schema.fields.map(i=>({name:i.name,evidenceType:Pd(i.type),typeFidelity:"precise"}))});const e=n.schema.fields.filter(i=>i.type.typeId===l.Date),r=n.schema.fields.filter(i=>i.type.typeId===l.List);for(const i of t){for(const s of e)i[s.name]=new Date(i[s.name]);for(const s of r)i[s.name]=Lu(i[s.name])}return t}function Lu(n){var i,s,o,a;if(n==null)return[];const t=n.toArray(),e=((s=(i=n.type)==null?void 0:i.children)==null?void 0:s.filter(c=>c.type.typeId===l.Date))??[],r=((a=(o=n.type)==null?void 0:o.children)==null?void 0:a.filter(c=>c.type.typeId===l.List))??[];for(const c of t){for(const u of e)c[u.name]=new Date(c[u.name]);for(const u of r)c[u.name]=Lu(c[u.name])}return t}function Cu(){let n,t,e=new Promise((r,i)=>{n=r,t=i});return{resolve:n,reject:t,promise:e}}function Uu(n){return Promise.race([n,new Promise((t,e)=>setTimeout(()=>e(new Error("Timeout while initializing database")),5e3))])}var jd=Object.create,xu=Object.defineProperty,Vd=Object.getOwnPropertyDescriptor,zd=Object.getOwnPropertyNames,qd=Object.getPrototypeOf,Wd=Object.prototype.hasOwnProperty,Gd=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),Yd=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of zd(t))!Wd.call(n,i)&&i!==e&&xu(n,i,{get:()=>t[i],enumerable:!(r=Vd(t,i))||r.enumerable});return n},Qd=(n,t,e)=>(e=n!=null?jd(qd(n)):{},Yd(!n||!n.__esModule?xu(e,"default",{value:n,enumerable:!0}):e,n)),Hd=Gd((n,t)=>{t.exports=Worker}),Kd=(n=>(n[n.UNDEFINED=0]="UNDEFINED",n[n.AUTOMATIC=1]="AUTOMATIC",n[n.READ_ONLY=2]="READ_ONLY",n[n.READ_WRITE=3]="READ_WRITE",n))(Kd||{}),Jd=(n=>(n[n.IDENTIFIER=0]="IDENTIFIER",n[n.NUMERIC_CONSTANT=1]="NUMERIC_CONSTANT",n[n.STRING_CONSTANT=2]="STRING_CONSTANT",n[n.OPERATOR=3]="OPERATOR",n[n.KEYWORD=4]="KEYWORD",n[n.COMMENT=5]="COMMENT",n))(Jd||{}),Zd=(n=>(n[n.NONE=0]="NONE",n[n.DEBUG=1]="DEBUG",n[n.INFO=2]="INFO",n[n.WARNING=3]="WARNING",n[n.ERROR=4]="ERROR",n))(Zd||{}),Xd=(n=>(n[n.NONE=0]="NONE",n[n.CONNECT=1]="CONNECT",n[n.DISCONNECT=2]="DISCONNECT",n[n.OPEN=3]="OPEN",n[n.QUERY=4]="QUERY",n[n.INSTANTIATE=5]="INSTANTIATE",n))(Xd||{}),tf=(n=>(n[n.NONE=0]="NONE",n[n.OK=1]="OK",n[n.ERROR=2]="ERROR",n[n.START=3]="START",n[n.RUN=4]="RUN",n[n.CAPTURE=5]="CAPTURE",n))(tf||{}),ef=(n=>(n[n.NONE=0]="NONE",n[n.WEB_WORKER=1]="WEB_WORKER",n[n.NODE_WORKER=2]="NODE_WORKER",n[n.BINDINGS=3]="BINDINGS",n[n.ASYNC_DUCKDB=4]="ASYNC_DUCKDB",n))(ef||{}),nf=class{log(n){}};var rf=(n=>(n[n.SUCCESS=0]="SUCCESS",n[n.MAX_ARROW_ERROR=255]="MAX_ARROW_ERROR",n[n.DUCKDB_WASM_RETRY=256]="DUCKDB_WASM_RETRY",n))(rf||{}),sf=class{constructor(n,t){this._bindings=n,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(n){return n(this._bindings,this._conn)}async query(n){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:n});let t=await this._bindings.runQuery(this._conn,n),e=ee.from(t);return console.assert(e.isSync(),"Reader is not sync"),console.assert(e.isFile(),"Reader is not file"),new Ut(e)}async send(n,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:n});let e=await this._bindings.startPendingQuery(this._conn,n,t);for(;e==null;){if(this._bindings.isDetached()){console.error("cannot send a message since the worker is not set!");return}e=await this._bindings.pollPendingQuery(this._conn)}let r=new $u(this._bindings,this._conn,e),i=await ee.from(r);return console.assert(i.isAsync()),console.assert(i.isStream()),i}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(n){return await this._bindings.getTableNames(this._conn,n)}async prepare(n){let t=await this._bindings.createPrepared(this._conn,n);return new of(this._bindings,this._conn,t)}async insertArrowTable(n,t){let e=$d(n,"stream");await this.insertArrowFromIPCStream(e,t)}async insertArrowFromIPCStream(n,t){await this._bindings.insertArrowFromIPCStream(this._conn,n,t)}async insertCSVFromPath(n,t){await this._bindings.insertCSVFromPath(this._conn,n,t)}async insertJSONFromPath(n,t){await this._bindings.insertJSONFromPath(this._conn,n,t)}},$u=class{constructor(n,t,e){this.db=n,this.conn=t,this.header=e,this._first=!0,this._depleted=!1,this._inFlight=null}async next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let n=null;for(this._inFlight!=null&&(n=await this._inFlight,this._inFlight=null);n==null;)n=await this.db.fetchQueryResults(this.conn);return this._depleted=n.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:n}}[Symbol.asyncIterator](){return this}},of=class{constructor(n,t,e){this.bindings=n,this.connectionId=t,this.statementId=e}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...n){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,n),e=ee.from(t);return console.assert(e.isSync()),console.assert(e.isFile()),new Ut(e)}async send(...n){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,n),e=new $u(this.bindings,this.connectionId,t),r=await ee.from(e);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},af=(n=>(n.CANCEL_PENDING_QUERY="CANCEL_PENDING_QUERY",n.CLOSE_PREPARED="CLOSE_PREPARED",n.COLLECT_FILE_STATISTICS="COLLECT_FILE_STATISTICS",n.REGISTER_OPFS_FILE_NAME="REGISTER_OPFS_FILE_NAME",n.CONNECT="CONNECT",n.COPY_FILE_TO_BUFFER="COPY_FILE_TO_BUFFER",n.COPY_FILE_TO_PATH="COPY_FILE_TO_PATH",n.CREATE_PREPARED="CREATE_PREPARED",n.DISCONNECT="DISCONNECT",n.DROP_FILE="DROP_FILE",n.DROP_FILES="DROP_FILES",n.EXPORT_FILE_STATISTICS="EXPORT_FILE_STATISTICS",n.FETCH_QUERY_RESULTS="FETCH_QUERY_RESULTS",n.FLUSH_FILES="FLUSH_FILES",n.GET_FEATURE_FLAGS="GET_FEATURE_FLAGS",n.GET_TABLE_NAMES="GET_TABLE_NAMES",n.GET_VERSION="GET_VERSION",n.GLOB_FILE_INFOS="GLOB_FILE_INFOS",n.INSERT_ARROW_FROM_IPC_STREAM="INSERT_ARROW_FROM_IPC_STREAM",n.INSERT_CSV_FROM_PATH="IMPORT_CSV_FROM_PATH",n.INSERT_JSON_FROM_PATH="IMPORT_JSON_FROM_PATH",n.INSTANTIATE="INSTANTIATE",n.OPEN="OPEN",n.PING="PING",n.POLL_PENDING_QUERY="POLL_PENDING_QUERY",n.REGISTER_FILE_BUFFER="REGISTER_FILE_BUFFER",n.REGISTER_FILE_HANDLE="REGISTER_FILE_HANDLE",n.REGISTER_FILE_URL="REGISTER_FILE_URL",n.RESET="RESET",n.RUN_PREPARED="RUN_PREPARED",n.RUN_QUERY="RUN_QUERY",n.SEND_PREPARED="SEND_PREPARED",n.START_PENDING_QUERY="START_PENDING_QUERY",n.TOKENIZE="TOKENIZE",n))(af||{}),cf=(n=>(n.CONNECTION_INFO="CONNECTION_INFO",n.ERROR="ERROR",n.FEATURE_FLAGS="FEATURE_FLAGS",n.FILE_BUFFER="FILE_BUFFER",n.FILE_INFOS="FILE_INFOS",n.FILE_SIZE="FILE_SIZE",n.FILE_STATISTICS="FILE_STATISTICS",n.INSTANTIATE_PROGRESS="INSTANTIATE_PROGRESS",n.LOG="LOG",n.PROGRESS_UPDATE="PROGRESS_UPDATE",n.OK="OK",n.PREPARED_STATEMENT_ID="PREPARED_STATEMENT_ID",n.QUERY_PLAN="QUERY_PLAN",n.QUERY_RESULT="QUERY_RESULT",n.QUERY_RESULT_CHUNK="QUERY_RESULT_CHUNK",n.QUERY_RESULT_HEADER="QUERY_RESULT_HEADER",n.QUERY_RESULT_HEADER_OR_NULL="QUERY_RESULT_HEADER_OR_NULL",n.REGISTERED_FILE="REGISTERED_FILE",n.SCRIPT_TOKENS="SCRIPT_TOKENS",n.SUCCESS="SUCCESS",n.TABLE_NAMES="TABLE_NAMES",n.VERSION_STRING="VERSION_STRING",n))(cf||{}),ot=class{constructor(n,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=n,this.data=t,this.promise=new Promise((e,r)=>{this.promiseResolver=e,this.promiseRejecter=r})}};function mi(n){switch(n.typeId){case l.Binary:return{sqlType:"binary"};case l.Bool:return{sqlType:"bool"};case l.Date:return{sqlType:"date"};case l.DateDay:return{sqlType:"date32[d]"};case l.DateMillisecond:return{sqlType:"date64[ms]"};case l.Decimal:{let t=n;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case l.Float:return{sqlType:"float"};case l.Float16:return{sqlType:"float16"};case l.Float32:return{sqlType:"float32"};case l.Float64:return{sqlType:"float64"};case l.Int:return{sqlType:"int32"};case l.Int16:return{sqlType:"int16"};case l.Int32:return{sqlType:"int32"};case l.Int64:return{sqlType:"int64"};case l.Uint16:return{sqlType:"uint16"};case l.Uint32:return{sqlType:"uint32"};case l.Uint64:return{sqlType:"uint64"};case l.Uint8:return{sqlType:"uint8"};case l.IntervalDayTime:return{sqlType:"interval[dt]"};case l.IntervalYearMonth:return{sqlType:"interval[m]"};case l.List:return{sqlType:"list",valueType:mi(n.valueType)};case l.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:n.byteWidth};case l.Null:return{sqlType:"null"};case l.Utf8:return{sqlType:"utf8"};case l.Struct:return{sqlType:"struct",fields:n.children.map(t=>Gs(t.name,t.type))};case l.Map:{let t=n;return{sqlType:"map",keyType:mi(t.keyType),valueType:mi(t.valueType)}}case l.Time:return{sqlType:"time[s]"};case l.TimeMicrosecond:return{sqlType:"time[us]"};case l.TimeMillisecond:return{sqlType:"time[ms]"};case l.TimeNanosecond:return{sqlType:"time[ns]"};case l.TimeSecond:return{sqlType:"time[s]"};case l.Timestamp:return{sqlType:"timestamp",timezone:n.timezone||void 0};case l.TimestampSecond:return{sqlType:"timestamp[s]",timezone:n.timezone||void 0};case l.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:n.timezone||void 0};case l.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:n.timezone||void 0};case l.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:n.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(n.toString()))}function Gs(n,t){let e=mi(t);return e.name=n,e}var uf=/'(opfs:\/\/\S*?)'/g,lf=/(opfs:\/\/\S*?)/g;function hf(n){return n.search(lf)>-1}function df(n){return[...n.matchAll(uf)].map(t=>t[1])}var ff=new TextEncoder,pf=class{constructor(n,t=null){this._onInstantiationProgress=[],this._onExecutionProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._config={},this._logger=n,this._onMessageHandler=this.onMessage.bind(this),this._onErrorHandler=this.onError.bind(this),this._onCloseHandler=this.onClose.bind(this),t!=null&&this.attach(t)}get logger(){return this._logger}get config(){return this._config}attach(n){this._worker=n,this._worker.addEventListener("message",this._onMessageHandler),this._worker.addEventListener("error",this._onErrorHandler),this._worker.addEventListener("close",this._onCloseHandler),this._workerShutdownPromise=new Promise((t,e)=>{this._workerShutdownResolver=t})}detach(){this._worker&&(this._worker.removeEventListener("message",this._onMessageHandler),this._worker.removeEventListener("error",this._onErrorHandler),this._worker.removeEventListener("close",this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(n,t=[]){if(!this._worker){console.error("cannot send a message since the worker is not set!:"+n.type+","+n.data);return}let e=this._nextMessageId++;return this._pendingRequests.set(e,n),this._worker.postMessage({messageId:e,type:n.type,data:n.data},t),await n.promise}onMessage(n){var t;let e=n.data;switch(e.type){case"PROGRESS_UPDATE":{for(let i of this._onExecutionProgress)i(e.data);return}case"LOG":{this._logger.log(e.data);return}case"INSTANTIATE_PROGRESS":{for(let i of this._onInstantiationProgress)i(e.data);return}}let r=this._pendingRequests.get(e.requestId);if(!r){console.warn("unassociated response: [".concat(e.requestId,", ").concat(e.type.toString(),"]"));return}if(this._pendingRequests.delete(e.requestId),e.type=="ERROR"){let i=new Error(e.data.message);i.name=e.data.name,(t=Object.getOwnPropertyDescriptor(i,"stack"))!=null&&t.writable&&(i.stack=e.data.stack),r.promiseRejecter(i);return}switch(r.type){case"CLOSE_PREPARED":case"COLLECT_FILE_STATISTICS":case"REGISTER_OPFS_FILE_NAME":case"COPY_FILE_TO_PATH":case"DISCONNECT":case"DROP_FILE":case"DROP_FILES":case"FLUSH_FILES":case"INSERT_ARROW_FROM_IPC_STREAM":case"IMPORT_CSV_FROM_PATH":case"IMPORT_JSON_FROM_PATH":case"OPEN":case"PING":case"REGISTER_FILE_BUFFER":case"REGISTER_FILE_HANDLE":case"REGISTER_FILE_URL":case"RESET":if(e.type=="OK"){r.promiseResolver(e.data);return}break;case"INSTANTIATE":if(this._onInstantiationProgress=[],e.type=="OK"){r.promiseResolver(e.data);return}break;case"GLOB_FILE_INFOS":if(e.type=="FILE_INFOS"){r.promiseResolver(e.data);return}break;case"GET_VERSION":if(e.type=="VERSION_STRING"){r.promiseResolver(e.data);return}break;case"GET_FEATURE_FLAGS":if(e.type=="FEATURE_FLAGS"){r.promiseResolver(e.data);return}break;case"GET_TABLE_NAMES":if(e.type=="TABLE_NAMES"){r.promiseResolver(e.data);return}break;case"TOKENIZE":if(e.type=="SCRIPT_TOKENS"){r.promiseResolver(e.data);return}break;case"COPY_FILE_TO_BUFFER":if(e.type=="FILE_BUFFER"){r.promiseResolver(e.data);return}break;case"EXPORT_FILE_STATISTICS":if(e.type=="FILE_STATISTICS"){r.promiseResolver(e.data);return}break;case"CONNECT":if(e.type=="CONNECTION_INFO"){r.promiseResolver(e.data);return}break;case"RUN_PREPARED":case"RUN_QUERY":if(e.type=="QUERY_RESULT"){r.promiseResolver(e.data);return}break;case"SEND_PREPARED":if(e.type=="QUERY_RESULT_HEADER"){r.promiseResolver(e.data);return}break;case"START_PENDING_QUERY":if(e.type=="QUERY_RESULT_HEADER_OR_NULL"){r.promiseResolver(e.data);return}break;case"POLL_PENDING_QUERY":if(e.type=="QUERY_RESULT_HEADER_OR_NULL"){r.promiseResolver(e.data);return}break;case"CANCEL_PENDING_QUERY":if(this._onInstantiationProgress=[],e.type=="SUCCESS"){r.promiseResolver(e.data);return}break;case"FETCH_QUERY_RESULTS":if(e.type=="QUERY_RESULT_CHUNK"){r.promiseResolver(e.data);return}break;case"CREATE_PREPARED":if(e.type=="PREPARED_STATEMENT_ID"){r.promiseResolver(e.data);return}break}r.promiseRejecter(new Error("unexpected response type: ".concat(e.type.toString())))}onError(n){console.error(n),console.error("error in duckdb worker: ".concat(n.message)),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn("worker terminated with ".concat(this._pendingRequests.size," pending requests"));return}this._pendingRequests.clear()}isDetached(){return!this._worker}async reset(){let n=new ot("RESET",null);return await this.postTask(n)}async ping(){let n=new ot("PING",null);await this.postTask(n)}async dropFile(n){let t=new ot("DROP_FILE",n);return await this.postTask(t)}async dropFiles(n){let t=new ot("DROP_FILES",n);return await this.postTask(t)}async flushFiles(){let n=new ot("FLUSH_FILES",null);return await this.postTask(n)}async instantiate(n,t=null,e=r=>{}){this._onInstantiationProgress.push(e);let r=new ot("INSTANTIATE",[n,t]);return await this.postTask(r)}async getVersion(){let n=new ot("GET_VERSION",null);return await this.postTask(n)}async getFeatureFlags(){let n=new ot("GET_FEATURE_FLAGS",null);return await this.postTask(n)}async open(n){this._config=n;let t=new ot("OPEN",n);await this.postTask(t)}async tokenize(n){let t=new ot("TOKENIZE",n);return await this.postTask(t)}async connectInternal(){let n=new ot("CONNECT",null);return await this.postTask(n)}async connect(){let n=await this.connectInternal();return new sf(this,n)}async disconnect(n){let t=new ot("DISCONNECT",n);await this.postTask(t)}async runQuery(n,t){if(this.shouldOPFSFileHandling()){let e=await this.registerOPFSFileFromSQL(t);try{return await this._runQueryAsync(n,t)}finally{e.length>0&&await this.dropFiles(e)}}else return await this._runQueryAsync(n,t)}async _runQueryAsync(n,t){let e=new ot("RUN_QUERY",[n,t]);return await this.postTask(e)}async startPendingQuery(n,t,e=!1){if(this.shouldOPFSFileHandling()){let r=await this.registerOPFSFileFromSQL(t);try{return await this._startPendingQueryAsync(n,t,e)}finally{r.length>0&&await this.dropFiles(r)}}else return await this._startPendingQueryAsync(n,t,e)}async _startPendingQueryAsync(n,t,e=!1){let r=new ot("START_PENDING_QUERY",[n,t,e]);return await this.postTask(r)}async pollPendingQuery(n){let t=new ot("POLL_PENDING_QUERY",n);return await this.postTask(t)}async cancelPendingQuery(n){let t=new ot("CANCEL_PENDING_QUERY",n);return await this.postTask(t)}async fetchQueryResults(n){let t=new ot("FETCH_QUERY_RESULTS",n);return await this.postTask(t)}async getTableNames(n,t){let e=new ot("GET_TABLE_NAMES",[n,t]);return await this.postTask(e)}async createPrepared(n,t){let e=new ot("CREATE_PREPARED",[n,t]);return await this.postTask(e)}async closePrepared(n,t){let e=new ot("CLOSE_PREPARED",[n,t]);await this.postTask(e)}async runPrepared(n,t,e){let r=new ot("RUN_PREPARED",[n,t,e]);return await this.postTask(r)}async sendPrepared(n,t,e){let r=new ot("SEND_PREPARED",[n,t,e]);return await this.postTask(r)}async globFiles(n){let t=new ot("GLOB_FILE_INFOS",n);return await this.postTask(t)}async registerFileText(n,t){let e=ff.encode(t);await this.registerFileBuffer(n,e)}async registerFileURL(n,t,e,r){t===void 0&&(t=n);let i=new ot("REGISTER_FILE_URL",[n,t,e,r]);await this.postTask(i)}async registerEmptyFileBuffer(n){}async registerFileBuffer(n,t){let e=new ot("REGISTER_FILE_BUFFER",[n,t]);await this.postTask(e,[t.buffer])}async registerFileHandle(n,t,e,r){let i=new ot("REGISTER_FILE_HANDLE",[n,t,e,r]);await this.postTask(i,[])}async registerOPFSFileName(n){let t=new ot("REGISTER_OPFS_FILE_NAME",[n]);await this.postTask(t,[])}async collectFileStatistics(n,t){let e=new ot("COLLECT_FILE_STATISTICS",[n,t]);await this.postTask(e,[])}async exportFileStatistics(n){let t=new ot("EXPORT_FILE_STATISTICS",n);return await this.postTask(t,[])}async copyFileToBuffer(n){let t=new ot("COPY_FILE_TO_BUFFER",n);return await this.postTask(t)}async copyFileToPath(n,t){let e=new ot("COPY_FILE_TO_PATH",[n,t]);await this.postTask(e)}async insertArrowFromIPCStream(n,t,e){if(t.length==0)return;let r=new ot("INSERT_ARROW_FROM_IPC_STREAM",[n,t,e]);await this.postTask(r,[t.buffer])}async insertCSVFromPath(n,t,e){if(e.columns!==void 0){let i=[];for(let s in e.columns){let o=e.columns[s];i.push(Gs(s,o))}e.columnsFlat=i,delete e.columns}let r=new ot("IMPORT_CSV_FROM_PATH",[n,t,e]);await this.postTask(r)}async insertJSONFromPath(n,t,e){if(e.columns!==void 0){let i=[];for(let s in e.columns){let o=e.columns[s];i.push(Gs(s,o))}e.columnsFlat=i,delete e.columns}let r=new ot("IMPORT_JSON_FROM_PATH",[n,t,e]);await this.postTask(r)}shouldOPFSFileHandling(){var n,t;return hf((n=this.config.path)!=null?n:"")?((t=this.config.opfs)==null?void 0:t.fileHandling)=="auto":!1}async registerOPFSFileFromSQL(n){let t=df(n),e=[];for(let r of t)try{await this.registerOPFSFileName(r),e.push(r)}catch(i){throw console.error(i),new Error("File Not found:"+r)}return e}};function yf(){let n=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),n.decode(t))}yf();var Pu=(n=>(n[n.BUFFER=0]="BUFFER",n[n.NODE_FS=1]="NODE_FS",n[n.BROWSER_FILEREADER=2]="BROWSER_FILEREADER",n[n.BROWSER_FSACCESS=3]="BROWSER_FSACCESS",n[n.HTTP=4]="HTTP",n[n.S3=5]="S3",n))(Pu||{}),mf=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),gf=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),bf=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),_f=()=>(async n=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(n)}catch{return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),wf={version:"1.32.0"},Ao=wf.version.split(".");Ao[0];Ao[1];Ao[2];var Sf=()=>typeof navigator>"u",Ss=null,Is=null,vs=null,Es=null,Ts=null;async function If(){return Ss==null&&(Ss=typeof BigInt64Array<"u"),Is==null&&(Is=await gf()),vs==null&&(vs=await _f()),Es==null&&(Es=await bf()),Ts==null&&(Ts=await mf()),{bigInt64Array:Ss,crossOriginIsolated:Sf()||globalThis.crossOriginIsolated||!1,wasmExceptions:Is,wasmSIMD:Es,wasmThreads:vs,wasmBulkMemory:Ts}}Qd(Hd());let me,Tn;const{resolve:vf,reject:Ef,promise:Tf}=Cu(),{resolve:Af,reject:Of,promise:Ff}=Cu();let wa=!1;async function Oo(){if(!me){if(wa)return Uu(Tf);wa=!0;try{const t=await If().then(s=>s.wasmExceptions)?{mainModule:(await ti(async()=>{const{default:s}=await import("./duckdb-eh.Dx9q7Mt5.js");return{default:s}},[])).default,mainWorker:(await ti(async()=>{const{default:s}=await import("./duckdb-browser-eh.worker.CoUR8I_Y.js");return{default:s}},[])).default}:{mainModule:(await ti(async()=>{const{default:s}=await import("./duckdb-mvp.B6BNNcYV.js");return{default:s}},[])).default,mainWorker:(await ti(async()=>{const{default:s}=await import("./duckdb-browser-mvp.worker.D4vYBldB.js");return{default:s}},[])).default},e=new nf,r=new t.mainWorker,i=new pf(e,r);window[Symbol.for("EVIDENCE_QUERY_ENGINE")]=i,await i.instantiate(t.mainModule),me=i,await me.open({query:{castBigIntToDouble:!0,castTimestampToDate:!0,castDecimalToDouble:!0,castDurationToTime64:!0}}),Tn=await me.connect(),await Tn.query("SET ieee_floating_point_ops = false;"),await Tn.query("SET old_implicit_casting = true;"),vf()}catch(n){throw Ef(n),n}}}async function jp(n){me||await Oo(),await Tn.query(`PRAGMA search_path='${n.join(",")}'`)}async function As(n){await me.flushFiles();for(const t of await me.globFiles(n))await me.dropFile(t.fileName)}async function Vp(n,{append:t,addBasePath:e=r=>r}={}){me||await Oo(),t||await As("*");try{for(const r in n){await Tn.query(`CREATE SCHEMA IF NOT EXISTS "${r}";`);for(const i of n[r]){const s=i.split(/[\\/]/).at(-1).slice(0,-8),o=`${r}_${s}.parquet`;let a=i;!i.startsWith("http")&&!i.startsWith("/")&&(a=`/${i}`),a.startsWith("/static")&&(a=a.substring(7)),t&&(await As(o),await As(i)),await me.registerFileURL(o,e(a),Pu.HTTP,!1),await Tn.query(`CREATE OR REPLACE VIEW "${r}"."${s}" AS (SELECT * FROM read_parquet('${o}'));`)}}Af()}catch(r){throw Of(r),console.error("Error encountered while updating Parquet URLs",r),r}}async function Nf(n){return me||await Oo(),await Uu(Ff),await Tn.query(n).then(kd)}const zp=ir(!0),qp=ir("");function Rf(){const{subscribe:n,update:t}=ir([]),e=new Map,r=i=>{t(s=>s.filter(o=>o.id!==i))};return{subscribe:n,add:(i,s=2e3)=>{if(i.id=i.id??Math.random().toString(),t(o=>{const a=o.find(c=>c.id===i.id);return a?(Object.assign(a,i),e.has(i.id)&&(clearTimeout(e.get(i.id)),e.delete(i.id))):o.push(i),o}),s){const o=setTimeout(()=>{r(i.id),e.delete(i.id)},s);e.set(i.id,o)}},dismiss:i=>{r(i),e.has(i)&&(clearTimeout(e.get(i)),e.delete[i])}}}const Wp=Rf(),Sa=n=>{let t;return n.subscribe(e=>t=e)(),t},Df=(n,t,e)=>{const r=(e==null?void 0:e.serialize)??JSON.stringify,i=(e==null?void 0:e.deserialize)??JSON.parse,s=ir(i(localStorage.getItem(n))??t),{subscribe:o,set:a}=s,c=u=>{typeof u>"u"||u===null?localStorage.removeItem(n):localStorage.setItem(n,r(u))};return c(Sa(s)),{subscribe:o,set:u=>{a(u),c(u)},update:u=>{const d=u(Sa(s));a(d),c(d)}}},Gp=Df("showQueries",sl);let Bf=(n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((t,e)=>(e&=63,e<36?t+=e.toString(36):e<62?t+=(e-26).toString(36).toUpperCase():e>62?t+="-":t+="_",t),"");const Mf={};var Ia={};const Lf=new Set,Yp=n=>{Ir()?n():Lf.add(n)},Ir=()=>{if(typeof process<"u")return!!(Ia.EVIDENCE_DEBUG||Ia.VITE_PUBLIC_EVIDENCE_DEBUG);if(typeof Mf<"u")return!1};let Mr=class{constructor(t,e){t&&(this.table=String(t)),e&&(this.column=e)}get columns(){return this.column?[this.column]:[]}toString(){const{table:t,column:e}=this;if(e){const r=e.startsWith("*")?e:`"${e}"`;return`${t?`${va(t)}.`:""}${r}`}else return t?va(t):"NULL"}};function va(n){return n.split(".").map(e=>`"${e}"`).join(".")}function Cf(n,t){return n instanceof Mr&&n.column===t}function tn(n){return typeof n=="string"?xf(n):n}function Os(n){return typeof n=="string"?Uf(n):n}function Uf(n){return new Mr(n)}function xf(n,t=null){return arguments.length===1&&(t=n,n=null),new Mr(n,t)}function Fo(n){switch(typeof n){case"boolean":return n?"TRUE":"FALSE";case"string":return`'${n.replace("'","''")}'`;case"number":return Number.isFinite(n)?String(n):"NULL";default:if(n==null)return"NULL";if(n instanceof Date){const t=+n;if(Number.isNaN(t))return"NULL";const e=n.getUTCFullYear(),r=n.getUTCMonth(),i=n.getUTCDate();return t===Date.UTC(e,r,i)?`MAKE_DATE(${e}, ${r+1}, ${i})`:`EPOCH_MS(${t})`}else return n instanceof RegExp?`'${n.source}'`:String(n)}}const Lr=n=>typeof(n==null?void 0:n.addEventListener)=="function";function ku(n){return n instanceof hs}let hs=class{constructor(t,e,r){this._expr=Array.isArray(t)?t:[t],this._deps=e||[],this.annotate(r);const i=this._expr.filter(s=>Lr(s));i.length>0?(this._params=Array.from(new Set(i)),this._params.forEach(s=>{s.addEventListener("value",()=>{var o;return $f(this,(o=this.map)==null?void 0:o.get("value"))})})):this.addEventListener=void 0}get value(){return this}get columns(){const{_params:t,_deps:e}=this;if(t){const r=new Set(t.flatMap(i=>{var o;const s=(o=i.value)==null?void 0:o.columns;return Array.isArray(s)?s:[]}));if(r.size){const i=new Set(e);return r.forEach(s=>i.add(s)),Array.from(i)}}return e}get column(){return this._deps.length?this._deps[0]:this.columns[0]}annotate(...t){return Object.assign(this,...t)}toString(){return this._expr.map(t=>Lr(t)&&!ku(t)?Fo(t.value):t).join("")}addEventListener(t,e){const r=this.map||(this.map=new Map);(r.get(t)||(r.set(t,new Set),r.get(t))).add(e)}};function $f(n,t){if(t!=null&&t.size)return Promise.allSettled(Array.from(t,e=>e(n)))}function ju(n,t){const e=[n[0]],r=new Set,i=t.length;for(let s=0,o=0;sr.add(u)),e[o]+=typeof a=="string"?a:Fo(a));const c=n[++s];Lr(e[o])?e[++o]=c:e[o]+=c}return{spans:e,cols:Array.from(r)}}function Lt(n,...t){const{spans:e,cols:r}=ju(n,t);return new hs(e,r)}function Ys(n,t){return Array.from({length:n},()=>t)}class yn extends hs{constructor(t,e,r,i,s="",o="",a=""){let c;if(i&&!(s||o||a))c=i?Lt`${e} OVER "${i}"`:Lt`${e} OVER ()`;else{const F=s&&o?" ":"",v=(s||o)&&a?" ":"";c=Lt`${e} OVER (${i?`"${i}" `:""}${s}${F}${o}${v}${a})`}r&&(c=Lt`(${c})::${r}`);const{_expr:d,_deps:w}=c;super(d,w),this.window=t,this.func=e,this.type=r,this.name=i,this.group=s,this.order=o,this.frame=a}get basis(){return this.column}get label(){const{func:t}=this;return t.label??t.toString()}over(t){const{window:e,func:r,type:i,group:s,order:o,frame:a}=this;return new yn(e,r,i,t,s,o,a)}partitionby(...t){const e=t.flat().filter(d=>d).map(tn),r=Lt(["PARTITION BY ",Ys(e.length-1,", "),""],...e),{window:i,func:s,type:o,name:a,order:c,frame:u}=this;return new yn(i,s,o,a,r,c,u)}orderby(...t){const e=t.flat().filter(d=>d).map(tn),r=Lt(["ORDER BY ",Ys(e.length-1,", "),""],...e),{window:i,func:s,type:o,name:a,group:c,frame:u}=this;return new yn(i,s,o,a,c,r,u)}rows(t){const e=Ea("ROWS",t),{window:r,func:i,type:s,name:o,group:a,order:c}=this;return new yn(r,i,s,o,a,c,e)}range(t){const e=Ea("RANGE",t),{window:r,func:i,type:s,name:o,group:a,order:c}=this;return new yn(r,i,s,o,a,c,e)}}function Ea(n,t){if(Lr(t)){const e=Lt`${t}`;return e.toString=()=>`${n} ${Ta(t.value)}`,e}return`${n} ${Ta(t)}`}function Ta(n){const[t,e]=n,r=t===0?"CURRENT ROW":Number.isFinite(t)?`${Math.abs(t)} PRECEDING`:"UNBOUNDED PRECEDING",i=e===0?"CURRENT ROW":Number.isFinite(e)?`${Math.abs(e)} FOLLOWING`:"UNBOUNDED FOLLOWING";return`BETWEEN ${r} AND ${i}`}class Ar extends hs{constructor(t,e,r,i,s){e=(e||[]).map(tn);const{strings:o,exprs:a}=Pf(t,e,r,i,s),{spans:c,cols:u}=ju(o,a);super(c,u),this.aggregate=t,this.args=e,this.type=r,this.isDistinct=i,this.filter=s}get basis(){return this.column}get label(){const{aggregate:t,args:e,isDistinct:r}=this,i=r?"DISTINCT"+(e.length?" ":""):"",s=e.length?`(${i}${e.map(kf).join(", ")})`:"";return`${t.toLowerCase()}${s}`}distinct(){const{aggregate:t,args:e,type:r,filter:i}=this;return new Ar(t,e,r,!0,i)}where(t){const{aggregate:e,args:r,type:i,isDistinct:s}=this;return new Ar(e,r,i,s,t)}window(){const{aggregate:t,args:e,type:r,isDistinct:i}=this,s=new Ar(t,e,null,i);return new yn(t,s,r)}partitionby(...t){return this.window().partitionby(...t)}orderby(...t){return this.window().orderby(...t)}rows(t){return this.window().rows(t)}range(t){return this.window().range(t)}}function Pf(n,t,e,r,i){const s=`)${e?`::${e}`:""}`;let o=[`${n}(${r?"DISTINCT ":""}`],a=[];return t.length?(o=o.concat([...Ys(t.length-1,", "),`${s}${i?" FILTER (WHERE ":""}`,...i?[")"]:[]]),a=[...t,...i?[i]:[]]):o[0]+="*"+s,{exprs:a,strings:o}}function kf(n){const t=Fo(n);return t&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function ar(n,t){return(...e)=>new Ar(n,e,t)}const jf=ar("COUNT","INTEGER"),Vf=ar("AVG"),zf=ar("MAX"),qf=ar("MIN"),Wf=ar("SUM","DOUBLE"),Gf=ar("MEDIAN");let gi=class kn{static select(...t){return new kn().select(...t)}static from(...t){return new kn().from(...t)}static with(...t){return new kn().with(...t)}static union(...t){return new vr("UNION",t.flat())}static unionAll(...t){return new vr("UNION ALL",t.flat())}static intersect(...t){return new vr("INTERSECT",t.flat())}static except(...t){return new vr("EXCEPT",t.flat())}static describe(t){const e=t.clone(),{clone:r,toString:i}=e;return Object.assign(e,{describe:!0,clone:()=>kn.describe(r.call(e)),toString:()=>`DESCRIBE ${i.call(e)}`})}constructor(){this.query={with:[],select:[],from:[],where:[],groupby:[],having:[],window:[],qualify:[],orderby:[]},this.cteFor=null}clone(){const t=new kn;return t.query={...this.query},t}with(...t){const{query:e}=this;if(t.length===0)return e.with;{const r=[],i=(s,o)=>{const a=o.clone();a.cteFor=this,r.push({as:s,query:a})};return t.flat().forEach(s=>{if(s!=null)if(s.as&&s.query)i(s.as,s.query);else for(const o in s)i(o,s[o])}),e.with=e.with.concat(r),this}}select(...t){const{query:e}=this;if(t.length===0)return e.select;{const r=[];for(const s of t.flat())if(s!=null)if(typeof s=="string")r.push({as:s,expr:tn(s)});else if(s instanceof Mr)r.push({as:s.column,expr:s});else if(Array.isArray(s))r.push({as:s[0],expr:s[1]});else for(const o in s)r.push({as:ii(o),expr:tn(s[o])});const i=new Set(r.map(s=>s.as));return e.select=e.select.filter(s=>!i.has(s.as)).concat(r.filter(s=>s.expr)),this}}$select(...t){return this.query.select=[],this.select(...t)}distinct(t=!0){return this.query.distinct=!!t,this}from(...t){const{query:e}=this;if(t.length===0)return e.from;{const r=[];return t.flat().forEach(i=>{if(i!=null)if(typeof i=="string")r.push({as:i,from:Os(i)});else if(i instanceof Mr)r.push({as:i.table,from:i});else if(Fs(i)||ku(i))r.push({from:i});else if(Array.isArray(i))r.push({as:ii(i[0]),from:Os(i[1])});else for(const s in i)r.push({as:ii(s),from:Os(i[s])})}),e.from=e.from.concat(r),this}}$from(...t){return this.query.from=[],this.from(...t)}sample(t,e){const{query:r}=this;if(arguments.length===0)return r.sample;{let i=t;return typeof t=="number"&&(i=t>0&&t<1?{perc:100*t,method:e}:{rows:Math.round(t),method:e}),r.sample=i,this}}where(...t){const{query:e}=this;return t.length===0?e.where:(e.where=e.where.concat(t.flat().filter(r=>r)),this)}$where(...t){return this.query.where=[],this.where(...t)}groupby(...t){const{query:e}=this;return t.length===0?e.groupby:(e.groupby=e.groupby.concat(t.flat().filter(r=>r).map(tn)),this)}$groupby(...t){return this.query.groupby=[],this.groupby(...t)}having(...t){const{query:e}=this;return t.length===0?e.having:(e.having=e.having.concat(t.flat().filter(r=>r)),this)}window(...t){const{query:e}=this;if(t.length===0)return e.window;{const r=[];return t.flat().forEach(i=>{if(i!=null)for(const s in i)r.push({as:ii(s),expr:i[s]})}),e.window=e.window.concat(r),this}}qualify(...t){const{query:e}=this;return t.length===0?e.qualify:(e.qualify=e.qualify.concat(t.flat().filter(r=>r)),this)}orderby(...t){const{query:e}=this;return t.length===0?e.orderby:(e.orderby=e.orderby.concat(t.flat().filter(r=>r).map(tn)),this)}limit(t){const{query:e}=this;return arguments.length===0?e.limit:(e.limit=Number.isFinite(t)?t:void 0,this)}offset(t){const{query:e}=this;return arguments.length===0?e.offset:(e.offset=Number.isFinite(t)?t:void 0,this)}get subqueries(){const{query:t,cteFor:e}=this,r=((e==null?void 0:e.query)||t).with,i=r==null?void 0:r.reduce((o,{as:a,query:c})=>(o[a]=c,o),{}),s=[];return t.from.forEach(({from:o})=>{if(Fs(o))s.push(o);else if(i[o.table]){const a=i[o.table];s.push(a)}}),s}toString(){const{with:t,select:e,distinct:r,from:i,sample:s,where:o,groupby:a,having:c,window:u,qualify:d,orderby:w,limit:F,offset:v}=this.query,N=[];if(t.length){const D=t.map(({as:B,query:nt})=>`"${B}" AS (${nt})`);N.push(`WITH ${D.join(", ")}`)}const dt=e.map(({as:D,expr:B})=>Cf(B,D)&&!B.table?`${B}`:`${B} AS "${D}"`);if(N.push(`SELECT${r?" DISTINCT":""} ${dt.join(", ")}`),i.length){const D=i.map(({as:B,from:nt})=>{const mt=Fs(nt)?`(${nt})`:`${nt}`;return!B||B===nt.table?mt:`${mt} AS "${B}"`});N.push(`FROM ${D.join(", ")}`)}if(o.length){const D=o.map(String).filter(B=>B).join(" AND ");D&&N.push(`WHERE ${D}`)}if(s){const{rows:D,perc:B,method:nt,seed:mt}=s,M=D?`${D} ROWS`:`${B} PERCENT`,Ct=nt?` (${nt}${mt!=null?`, ${mt}`:""})`:"";N.push(`USING SAMPLE ${M}${Ct}`)}if(a.length&&N.push(`GROUP BY ${a.join(", ")}`),c.length){const D=c.map(String).filter(B=>B).join(" AND ");D&&N.push(`HAVING ${D}`)}if(u.length){const D=u.map(({as:B,expr:nt})=>`"${B}" AS (${nt})`);N.push(`WINDOW ${D.join(", ")}`)}if(d.length){const D=d.map(String).filter(B=>B).join(" AND ");D&&N.push(`QUALIFY ${D}`)}return w.length&&N.push(`ORDER BY ${w.join(", ")}`),Number.isFinite(F)&&N.push(`LIMIT ${F}`),Number.isFinite(v)&&N.push(`OFFSET ${v}`),N.join(" ")}},vr=class Vu{constructor(t,e){this.op=t,this.queries=e.map(r=>r.clone()),this.query={orderby:[]},this.cteFor=null}clone(){const t=new Vu(this.op,this.queries);return t.query={...this.query},t}orderby(...t){const{query:e}=this;return t.length===0?e.orderby:(e.orderby=e.orderby.concat(t.flat().filter(r=>r).map(tn)),this)}limit(t){const{query:e}=this;return arguments.length===0?e.limit:(e.limit=Number.isFinite(t)?t:void 0,this)}offset(t){const{query:e}=this;return arguments.length===0?e.offset:(e.offset=Number.isFinite(t)?t:void 0,this)}get subqueries(){const{queries:t,cteFor:e}=this;return e&&t.forEach(r=>r.cteFor=e),t}toString(){const{op:t,queries:e,query:{orderby:r,limit:i,offset:s}}=this,o=[e.join(` ${t} `)];return r.length&&o.push(`ORDER BY ${r.join(", ")}`),Number.isFinite(i)&&o.push(`LIMIT ${i}`),Number.isFinite(s)&&o.push(`OFFSET ${s}`),o.join(" ")}};function Fs(n){return n instanceof gi||n instanceof vr}function ii(n){return Yf(n)?n.slice(1,-1):n}function Yf(n){return n[0]==='"'&&n[n.length-1]==='"'}const Ns=n=>{let t=null,e=null;const r=new Promise((o,a)=>{t=o,e=a});let i="init",s=null;if(!t||!e)throw new Error;return{promise:r,resolve:o=>{if(t)(i==="loading"||i==="init")&&(i="resolved",s=o,t(o),n==null||n());else throw new Error("SharedPromise encountered an error: res not defined")},reject:o=>{if(e)(i==="loading"||i==="init")&&(i="rejected",r.catch(()=>{}),e(o),n==null||n());else throw new Error("SharedPromise encountered an error: rej not defined")},get state(){return i},get value(){return s},start(){i="loading",n==null||n()}}},fe=(n,t,e)=>{try{const r=typeof t=="function"?t():t;return r instanceof Promise?r.then(i=>n(i,!0)).catch(i=>{const s=i instanceof Error?i:new Error("Unknown Error",{cause:i});if(e)return e(s,!0);throw s}):n(r,!1)}catch(r){const i=r instanceof Error?r:new Error("Unknown Error",{cause:r});if(e)return e(i,!1);throw i}},Aa=(n,t)=>{const e=t.reduce((r,i)=>r+Kf(i.column_type),t.length*4);return Math.abs(e*n)};function Qf(n){return n.startsWith("STRUCT")||n.endsWith("[]")}function Hf(n){return n.startsWith("DECIMAL")}function Kf(n){const t={string:30,number:12,boolean:4,date:48};if(Qf(n))return console.warn(`[!] Evidence does not support DuckDB Struct or Array If you need to use one, convert it to JSON in your query, and then manually parse it in your project`),t.string;if(Hf(n))return t.number;switch(n){case"BOOLEAN":return t.boolean;case"BIGINT":case"DOUBLE":case"FLOAT":case"INTEGER":case"SMALLINT":case"TINYINT":case"UBIGINT":case"UINTEGER":case"USMALLINT":case"UTINYINT":case"HUGEINT":return t.number;case"UUID":case"VARCHAR":return t.string;case"DATE":case"TIMESTAMP":case"TIMESTAMP_S":case"TIMESTAMP_MS":case"TIMESTAMP_NS":case"TIMESTAMP WITH TIME ZONE":return t.date;case"INTERVAL":case"TIME":case"TIME WITH TIME ZONE":case"BLOB":case"BIT":return t.string;default:return console.error(`Column type ${n} is not supported`),t.string}}const Jf=/--([^']|'.*')+$/,Zf=/(\/\*.*\*\/)/g,Xf=n=>{const t=n.split(` `);let e=!1;for(let r=t.length;r>0;r--){let i=t[r-1],s="";const o=Array.from(i.matchAll(Zf));for(const c of o){const u=i.slice(0,c.index),d=i.slice(c.index+c[0].length);i=`${u}${d}`}if(e&&i.includes("/*")){e=!1;const c=i.split("/*");i=c.slice(0,-1).join("/*"),s+="/*"+c.slice(-1)}if(i.trim().endsWith("*/")){e=!0;continue}const a=Jf.exec(i);if(a){const c=i.slice(0,a.index),u=c.trimEnd();if(u.endsWith(";")){const d=i.slice(a.index),w=c.slice(u.length,c.length);i=`${c.slice(0,-1+-1*(c.length-u.length))}${w}${d}`}}else if(i.trimEnd().endsWith(";")){const u=i.lastIndexOf(";");i=i.slice(0,u)+i.slice(u+1)}for(const c of o){const u=i.slice(0,c.index),d=i.slice(c.index);i=`${u}${c[0]}${d}`}if(i!==t[r-1]){t[r-1]=i+s;break}}return t.push(""),t.join(` `)};var wn,xt,xr,Je,$r,jt,Pr,kr,jr,wt,Ye,pn,Vt,Gn,O,Ue,Xi,Yn,Sn,Vr,ie,ts,Et,In,Tt,vn,Dt,Qn,es,se,ns,rs,zr,Qs,Hs,xe,Ks,Gt,Hn,Kn,pe,$e,Ze,Qe,$t,qr,Jn,is,Zn,Xe,Wr,ss;let zu=(O=class{constructor(t,e,r={}){W(this,wt);W(this,wn);W(this,xt,[]);W(this,xr,-1);W(this,Je,0);W(this,$r,-1);W(this,jt,[]);W(this,Pr);W(this,kr,-1);W(this,jr);W(this,Vt);W(this,Gn);W(this,ie,-1);W(this,ts,()=>{this.lengthLoaded&&this.columnsLoaded?(it(this,ie,Aa(this.length,this.columns)),h(this,ie)>h(O,Vr)&&h(this,Xe).call(this,"highScore",h(this,ie))):Promise.allSettled([h(this,Tt).promise,h(this,Dt).promise]).then(([t,e])=>{if(t.status==="rejected"||e.status==="rejected"){it(this,ie,-1);return}if(!h(this,Je)||!h(this,jt)){it(this,ie,-1);return}it(this,ie,Aa(this.length,this.columns)),h(this,ie)>h(O,Vr)&&h(this,Xe).call(this,"highScore",h(this,ie))}).catch(t=>{console.error(`${this.id} | Failed to calculate Query score ${t}`)})});W(this,Et,Ns(()=>this.publish(`data promise (${h(this,Et).state})`)));W(this,In,()=>{var s;if(h(this,Et).state!=="init")return h(this,Et).promise;if(h(this,wt,Ye))return h(this,Gt).call(this,"data error","Refusing to execute data query, store has an error state"),h(this,Et).promise;if(h(this,Et).state!=="init"||this.opts.noResolve)return h(this,Et).promise;h(this,Et).start();const t=` ---- Data ${h(this,pe)} ${h(this,$e)} ${this.text.trim()} `.trim()+` `;h(this,Hn).call(this,"data query text",` `+t,"font-family: monospace;");const e=h(this,$t);h(s=O,Xi).call(s,this);const r=performance.now();return fe((o,a)=>{it(this,xt,o);const c=performance.now();return r-c>5e3&&(h(this,Xe).call(this,"longRun",r-c),h(this,Gt).call(this,"long-running",`Query took ${r-c}ms to execute`)),it(this,xr,c-r),h(this,vn).call(this),h(this,Et).resolve(this),h(this,Xe).call(this,"dataReady",void 0),a?h(this,Et).promise:this},()=>e(t,`${h(this,pe)}_data`),(o,a)=>(it(this,wt,o,pn),h(this,Et).reject(o),a?h(this,Et).promise:this))});vt(this,"fetch",()=>h(this,Qn).call(this)instanceof Promise&&!this.opts.noResolve?Promise.allSettled([h(this,Qn).call(this),h(this,In).call(this)]).then(()=>this.value):(h(this,In).call(this),this.value));vt(this,"backgroundFetch",()=>{if(typeof window>"u"){h(this,Gt).call(this,"background fetch skip","Did not execute backgroundFetch in SSR");return}h(this,Gt).call(this,"background fetch","Executed backgroundFetch"),fe(()=>{},async()=>(await new Promise(t=>setTimeout(t,0)),h(this,$t).call(this,`--data ${this.text.trim()}`,this.id)),()=>{})});W(this,Tt,Ns(()=>this.publish(`length promise (${h(this,Tt).state})`)));W(this,vn,()=>{if(h(this,xt)&&h(this,Et).state==="resolved"&&h(this,Tt).state==="init")return h(this,Gt).call(this,"length inferred","Inferred length from already-resolved data promise",h(this,xt)),it(this,Je,h(this,xt).length),h(this,Tt).resolve(this),h(this,Tt).promise;if(h(this,wt,Ye))return h(this,Gt).call(this,"length error","Refusing to execute length query, store has an error state",h(this,wt,Ye)),h(this,Tt).reject(h(this,wt,Ye)),h(this,Tt).value??h(this,Tt).promise;if(h(this,Tt).state!=="init"||this.opts.noResolve)return h(this,Tt).promise;h(this,Tt).start();const t=` ---- Length ${h(this,pe)} (${h(this,$e)}) SELECT COUNT(*) as rowCount FROM (${this.text.trim()}) `.trim()+` `,e=h(this,$t);h(this,Hn).call(this,"length query text",` `+t,"font-family: monospace;");const r=performance.now();return fe((s,o)=>{const a=performance.now();return it(this,$r,a-r),it(this,Je,s[0].rowCount),h(this,Tt).resolve(this),o?h(this,Tt).promise:this},()=>e(t,`${h(this,pe)}_length`),(s,o)=>(it(this,wt,s,pn),h(this,Tt).reject(s),o?h(this,Tt).promise:this))});W(this,Dt,Ns(()=>this.publish(`columns promise (${h(this,Dt).state})`)));W(this,Qn,()=>{if(h(this,wt,Ye))return h(this,Gt).call(this,"cols query error","Refusing to execute columns query, store has an error state",h(this,wt,Ye)),h(this,Dt).value??h(this,Dt).promise;if(h(this,Dt).state!=="init"||this.opts.noResolve)return h(this,Dt).promise;h(this,Dt).start();const t=` ---- Columns ${h(this,pe)} (${h(this,$e)}) DESCRIBE ${this.text.trim()} `.trim()+` `;h(this,Hn).call(this,"columns query text",` `+t,"font-family: monospace;");const e=h(this,$t),r=performance.now();return fe((s,o)=>{const a=performance.now();return it(this,kr,a-r),it(this,jt,s),h(this,Dt).resolve(this),it(this,Pr,Object.fromEntries(s.map(c=>[c.column_name,void 0]))),o?h(this,Dt).promise:this},()=>e(t,`${h(this,pe)}_columns`),(s,o)=>(it(this,wt,s,pn),h(this,Dt).reject(s),o?h(this,Dt).promise:this))});W(this,es,()=>new Proxy([],{getPrototypeOf:()=>Object.getPrototypeOf(h(this,xt)),has:(e,r)=>r in h(this,xt)||r in this,get:(e,r)=>{let i=r;if(typeof i=="string"&&/^[\d.]+$/.exec(i)&&(i=parseInt(i)),(typeof i=="number"||O.ProxyFetchTriggers.includes(i.toString()))&&h(this,Et).state==="init"&&(h(this,Gt).call(this,"implicit fetch",`Implicit query fetch triggered by ${i.toString()}`),h(this,In).call(this)),i==="length"&&h(this,vn).call(this),i==="constructor")return h(this,xt).constructor;if(i==="toString")return h(this,xt).toString.bind(h(this,xt));const s=i in this?this:h(this,xt)&&i in h(this,xt)?h(this,xt):null;if(s===null)return typeof i!="number"||this.lengthLoaded&&i>h(this,Je)?void 0:h(this,Pr)??{};const o=s[i];return typeof o=="function"?o.bind(s):o}}));W(this,Gt,Ir()?(t,...e)=>{const r=`${(performance.now()/1e3).toFixed(3)} | ${this.id} (${this.hash}) | ${t}`;console.groupCollapsed(r);for(const i of e)console.debug(typeof i=="function"?i():i);console.groupEnd()}:()=>{});W(this,Hn,Ir()?(t,e,r)=>{const i=`${(performance.now()/1e3).toFixed(3)} | ${this.id} (${this.hash}) | ${t}`;console.groupCollapsed(i),console.debug(`%c${e}`,r),console.groupEnd()}:()=>{});W(this,pe);W(this,$e);W(this,Ze);W(this,$t);vt(this,"opts");W(this,qr);W(this,Jn,new Set);vt(this,"subscribe",t=>(h(this,Jn).add(t),t(h(this,wn)),()=>h(this,Jn).delete(t)));W(this,is,0);vt(this,"publish",t=>{if(Wo(this,is)._++>1e5)throw new Error("Query published too many times.");h(this,Gt).call(this,"publish",`Publishing triggered by ${t}`),h(this,Jn).forEach(e=>e(h(this,wn)))});W(this,Zn,{dataReady:new Set,error:new Set,highScore:new Set,longRun:new Set});W(this,Xe,(t,e)=>{h(this,Zn)[t].forEach(r=>r(e,t))});vt(this,"on",(t,e)=>{h(this,Zn)[t].add(e)});vt(this,"off",(t,e)=>{h(this,Zn)[t].delete(e)});vt(this,"addEventListener",this.on);vt(this,"removeEventListener",this.off);vt(this,"where",t=>O.create(h(this,Vt).clone().where(Lt`${t}`),h(this,$t),{knownColumns:h(this,jt),noResolve:h(this,Ze).noResolve}));vt(this,"withOrdinal",t=>{const e=h(this,Vt).clone();return e.select({ordinal:Lt`row_number() over (${t})`}),O.create(e,h(this,$t),{...h(this,wt,Qe),knownColumns:h(this,jt)})});vt(this,"search",(t,e,r)=>{(typeof r>"u"||r<0||r>1)&&(r=1-1/t.length);const i=[...h(this,jt),{column_name:"similarity",column_type:"INTEGER",nullable:"NO"}],s=O.create,o=t.replaceAll("'","''"),c=(Array.isArray(e)?e:[e]).map(d=>{const w=Lt`CASE WHEN lower("${d.trim()}") = lower('${o}') THEN 2 ELSE 0 END`,F=Lt`jaccard(lower('${o}'), lower("${d}"))`,v=o.length>=1?Lt`CASE WHEN lower("${d.trim()}") LIKE lower('%${o.split(" ").join("%")}%') THEN 1 ELSE 0 END`:Lt`0`;return Lt`GREATEST((${w}), (${F}), (${v}))`}).join(",");return s(h(this,Vt).clone().$select({similarity:Lt`GREATEST(${c})`},"*").where(Lt`"similarity" > ${r} `).orderby(Lt`"similarity" DESC`),h(this,$t),{knownColumns:i,...h(this,wt,Qe)})});vt(this,"limit",t=>O.create(h(this,Vt).clone().limit(t),h(this,$t),{knownColumns:h(this,jt),...h(this,wt,Qe)}));vt(this,"offset",t=>O.create(h(this,Vt).clone().offset(t),h(this,$t),{knownColumns:h(this,jt),...h(this,wt,Qe)}));vt(this,"paginate",(t,e)=>O.create(h(this,Vt).clone().offset(t).limit(e),h(this,$t),{knownColumns:h(this,jt),...h(this,wt,Qe)}));vt(this,"groupBy",(t,e)=>{const r=h(this,Vt).clone();return r.$select(t),e&&r.select({rows:jf("*")}),r.$groupby(t),O.create(r,h(this,$t),{knownColumns:h(this,jt),...h(this,wt,Qe)})});vt(this,"agg",t=>{var r;const e=h(this,Vt).clone();for(const[i,s]of Object.entries(t)){if(!h(r=O,ss).call(r,i))throw new Error(`Unknown agg function: ${i}`);const o=h(O,Wr)[i],a=Array.isArray(s)?s:[s];for(const c of a){const u=typeof c=="object"?c.as:`${i}_${c}`,d=typeof c=="object"?c.col:c;e.select({[u]:o(d)})}}return O.create(e,h(this,$t),{knownColumns:h(this,jt),...h(this,wt,Qe)})});var c;it(this,qr,(c=new Error().stack)==null?void 0:c.split(` `).slice(2).map(u=>u.slice(7)).join(` `));const{id:i,initialData:s=void 0,knownColumns:o=void 0,initialError:a=void 0}=r;if(this.opts=r,it(this,$t,e),typeof t!="string"&&!(t instanceof gi)&&(console.warn(`Query ${i} has no query text`),r.noResolve=!0),h(O,Kn)||console.warn("Directly using new Query() is not a recommended use-case. Please use Query.create()"),it(O,Kn,!1),it(this,wn,h(this,es).call(this)),it(this,Gn,(t==null?void 0:t.toString())??"SELECT 'Empty Query' WHERE 0"),it(this,$e,dn(h(this,Gn))),it(this,pe,i??h(this,$e)),it(this,Ze,r),t&&typeof t!="string")it(this,Vt,t);else if(t){const u=new gi().from({[`inputQuery-${Bf(2)}`]:Lt`(${Xf(t)})`}).select("*");it(this,Vt,u)}else{it(this,Vt,new gi),it(this,wt,new Error("Refusing to create Query: No Query Text provided"),pn);return}if(a){it(this,wt,a,pn);return}if(s)h(this,Gt).call(this,"initial data","Created with initial data",s),fe(u=>{it(this,xt,u),r.initialDataDirty?(this.publish("dataDirty"),h(this,In).call(this)):(h(this,Et).resolve(this),h(this,vn).call(this))},s,u=>{it(this,wt,u,pn)});else if(r.noResolve)return h(this,Et).start(),h(this,Tt).start(),h(this,Dt).start(),this;if(o){if(!Array.isArray(o))throw new Error("Expected knownColumns to be an array",{cause:o});h(this,Gt).call(this,"known columns","Created with known columns",o),it(this,jt,o),h(this,Dt).resolve(this)}else fe(()=>{},h(this,Qn).call(this),(u,d)=>{if(!d)throw u});fe(()=>{},h(this,vn).call(this),(u,d)=>{if(!d)throw u}),r.autoScore&&h(this,ts).call(this)}get value(){return h(this,wn)}get dataLoaded(){return["resolved","rejected"].includes(h(this,Et).state)}get dataLoading(){return h(this,Et).state==="loading"}get dataQueryTime(){return h(this,xr)}get length(){return h(this,Je)}get lengthLoaded(){return["resolved","rejected"].includes(h(this,Tt).state)}get lengthLoading(){return h(this,Tt).state==="loading"}get lengthQueryTime(){return h(this,$r)}get columns(){return h(this,jt)}get columnsLoaded(){return["resolved","rejected"].includes(h(this,Dt).state)}get columnsLoading(){return h(this,Dt).state==="loading"}get columnsQueryTime(){return h(this,kr)}get ready(){return h(this,Tt).state==="resolved"&&h(this,Dt).state==="resolved"&&h(this,Et).state==="resolved"}get loading(){return h(this,Tt).state==="loading"||h(this,Dt).state==="loading"||h(this,Et).state==="loading"}get error(){return h(this,wt,Ye)}get originalText(){return h(this,Gn)}get text(){var t;return((t=h(this,Vt))==null?void 0:t.toString())??"SELECT 'Empty Query' WHERE 0"}static get queriesInFlight(){return h(O,Ue).size>0}static resetInFlightQueries(){it(O,Ue,new Set)}static addEventListener(t,e){h(this,Yn)[t].add(e)}static removeEventListener(t,e){h(this,Yn)[t].delete(e)}get score(){return h(this,ie)}get isQuery(){return!0}static[Symbol.hasInstance](t){return O.isQuery(t)}static get ProxyFetchTriggers(){return["at"]}static get cacheSize(){return h(this,se).size}get id(){return h(this,pe)}get hash(){return h(this,$e)}get createdStack(){return h(this,qr)}},wn=new WeakMap,xt=new WeakMap,xr=new WeakMap,Je=new WeakMap,$r=new WeakMap,jt=new WeakMap,Pr=new WeakMap,kr=new WeakMap,jr=new WeakMap,wt=new WeakSet,Ye=function(){return h(this,jr)},pn=function(t){t&&(console.error(`${this.id} | Error in Query!`,t==null?void 0:t.message),h(this,Xe).call(this,"error",t),it(this,jr,t))},Vt=new WeakMap,Gn=new WeakMap,Ue=new WeakMap,Xi=new WeakMap,Yn=new WeakMap,Sn=new WeakMap,Vr=new WeakMap,ie=new WeakMap,ts=new WeakMap,Et=new WeakMap,In=new WeakMap,Tt=new WeakMap,vn=new WeakMap,Dt=new WeakMap,Qn=new WeakMap,es=new WeakMap,se=new WeakMap,ns=new WeakMap,rs=new WeakMap,zr=new WeakMap,Qs=new WeakMap,Hs=new WeakMap,xe=new WeakMap,Ks=new WeakMap,Gt=new WeakMap,Hn=new WeakMap,Kn=new WeakMap,pe=new WeakMap,$e=new WeakMap,Ze=new WeakMap,Qe=function(){return{autoScore:h(this,Ze).autoScore,noResolve:h(this,Ze).noResolve,disableCache:h(this,Ze).disableCache}},$t=new WeakMap,qr=new WeakMap,Jn=new WeakMap,is=new WeakMap,Zn=new WeakMap,Xe=new WeakMap,Wr=new WeakMap,ss=new WeakMap,W(O,Ue,new Set),W(O,Xi,t=>{var e;h(O,Ue).size===0&&h(e=O,Sn).call(e,"inFlightQueryStart",void 0),h(O,Ue).add(t),h(t,Et).promise.finally(()=>{var r;h(O,Ue).delete(t),h(O,Ue).size===0&&h(r=O,Sn).call(r,"inFlightQueryEnd",void 0)})}),W(O,Yn,{inFlightQueryStart:new Set,inFlightQueryEnd:new Set,queryCreated:new Set,cacheCleared:new Set}),W(O,Sn,(t,e)=>{h(O,Yn)[t].forEach(r=>r(e,t))}),W(O,Vr,10*1024*1024),vt(O,"isQuery",t=>typeof t!="object"||!t?!1:"isQuery"in t&&t.isQuery===!0),vt(O,"CacheMaxScore",50*1024),W(O,se,new Map),vt(O,"emptyCache",()=>{var t;h(O,se).clear(),h(t=O,Sn).call(t,"cacheCleared",void 0)}),W(O,ns,t=>{var e;h(O,se).set(t.hash,{query:t,added:Date.now()}),h(e=O,xe).call(e,"cache",`Added to cache: ${t.hash}`,{cacheSize:h(O,se).size,cacheScore:Array.from(h(O,se).values()).reduce((r,i)=>r+i.query.score,0)})}),W(O,rs,t=>{const e=h(O,se).get(t);return e?e.query:null}),W(O,zr,()=>{let t=Array.from(h(O,se).values()).reduce((r,i)=>r+i.query.score,0);const e=Array.from(h(O,se).values()).sort((r,i)=>r.added-i.added);for(;t>O.CacheMaxScore;){const r=e.shift();if(!r)break;h(O,se).delete(r.query.hash),t-=r.query.score}}),vt(O,"createReactive",(t,e,r)=>{const{loadGracePeriod:i=250,callback:s=()=>{},execFn:o}=t,a=O.create;let c=r,u=0,d;const w=((v,N)=>{var mt;if(!c)throw new Error;u+=1;const dt=u;h(mt=O,xe).call(mt,`${c.id} (${dn(v)}) | Reactive Updating`,v,{changeIdx:u,targetChangeIdx:dt,hash:dn(v)},{initialOpts:e,newOpts:N});const D=O.isQuery(v)?v:a(v,o,Object.assign({},e,{initialData:void 0,initialError:void 0},N)),B=D.fetch();let nt=B;B instanceof Promise&&(nt=Promise.race([new Promise(M=>setTimeout(M,i)),D.fetch()])),fe(()=>{var M;if(u!==dt){h(M=O,xe).call(M,"changeIdx does not match, results are discarded");return}d==null||d(),c=D.value,d=c.subscribe(s)},nt,M=>{throw console.warn(`Error while attempting to update reactive query: ${M.message}`),M})});function F(){e={...e,initialData:void 0,initialError:void 0}}return(v,N)=>{if(c){fe(()=>{},w(v,N),D=>{console.warn(`Error while attempting to update reactive query: ${D.message}`)});return}c=a(v,o,Object.assign({},e,N));const dt=c.fetch();fe(F,dt),d=c.subscribe(s),s(c)}}),W(O,Qs,!1),W(O,Hs,()=>{}),vt(O,"create",(t,e,r,i)=>{var c,u,d,w,F,v,N,dt;const s=dn(t);let o;if(typeof r=="string"?o={...i,id:r}:r?(o=r,o.id||(o.id=s+"-"+Math.random().toString(36).substring(0,4))):o={id:s+"-"+Math.random().toString(36).substring(0,4)},"autoScore"in o||(o.autoScore=!0),o.disableCache)h(F=O,xe).call(F,`${o.id??"[query id missing]"} (${s}) | cache disabled`,`Cache is disabled for ${o.id??"[query id missing]"}`,{opts:o,query:t,hash:dn(t)});else{const D=h(c=O,rs).call(c,s);if(h(u=O,zr).call(u),D)return h(d=O,xe).call(d,`${o.id??"[query id missing]"} (${s}) | Using cached query`,{opts:o,hash:dn(t)},t,D),D.value;h(w=O,xe).call(w,`${o.id??"[query id missing]"} (${s}) | Cached query not found`,{opts:o,hash:dn(t)},t)}it(O,Kn,!0);const a=new O(t,e,o);return h(v=O,Sn).call(v,"queryCreated",{raw:a,proxied:a.value}),o.disableCache||(h(N=O,ns).call(N,a),h(dt=O,zr).call(dt)),a.value}),W(O,xe,Ir()?(t,...e)=>{const r=`${(performance.now()/1e3).toFixed(3)} | Query | ${t}`;console.groupCollapsed(r);for(const i of e)console.debug(typeof i=="function"?i():i);console.groupEnd()}:()=>{}),W(O,Ks,Ir()?(t,e,r)=>{const i=`${(performance.now()/1e3).toFixed(3)} | Query | ${t}`;console.groupCollapsed(i),console.debug(`%c${e}`,r),console.groupEnd()}:()=>{}),W(O,Kn,!1),W(O,Wr,{sum:Wf,avg:Vf,min:qf,max:zf,median:Gf}),W(O,ss,t=>t in h(O,Wr)),O);const dn=(...n)=>(e=>{let r=0;for(let i=0;itypeof n!="object"||n===null?!1:"subscribe"in n,tp=n=>qu(n)?"set"in n&&"update"in n:!1,Kp=n=>{if(!tp(n))throw console.error({InputStoreValue:n}),new Error("InputStore must be a writable store");if(Js().has(An)){const t=Zs(An);return t.set(ul(n)),t}else return Da(An,n),n},Jp=()=>Js().has(An)?Zs(An):(console.warn("InputStoreKey not found in context. Did you forget to call ensureInputContext?"),ir({})),Zp=()=>{if(!Js().has(An))return console.warn("InputStoreKey not found in context. Did you forget to call ensureInputContext?"),ol({});const n=Zs(An);if(qu(n))return al(n);throw new Error(`InputStoreKey is not a readable store: ${n}`)},ep=(n,t)=>{let e;if(n instanceof String)e=n.toString();else{if(typeof n!="string")return n;e=n}if(e.startsWith("http")||e.startsWith("#")||/^[^/]*:/.test(e))return e;let r=t.deployment.basePath;return r?(r!=null&&r.startsWith("/")||(r=`/${r}`),r.endsWith("/")&&(r=r.slice(0,-1)),e.startsWith(r)?e:(e.startsWith("/")||(e=`/${e}`),`${r}${e}`)):e},np={deployment:{basePath:""}},Xp=n=>ep(n,np);var ty=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function rp(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}class Cr{constructor(t,e){t&&(this.table=String(t)),e&&(this.column=e)}get columns(){return this.column?[this.column]:[]}toString(){const{table:t,column:e}=this;if(e){const r=e.startsWith("*")?e:`"${e}"`;return`${t?`${Oa(t)}.`:""}${r}`}else return t?Oa(t):"NULL"}}function Oa(n){return n.split(".").map(e=>`"${e}"`).join(".")}function ip(n,t){return n instanceof Cr&&n.column===t}function Er(n){return typeof n=="string"?op(n):n}function Rs(n){return typeof n=="string"?sp(n):n}function sp(n){return new Cr(n)}function op(n,t){return arguments.length===1&&(t=n,n=null),new Cr(n,t)}function Wu(n){switch(typeof n){case"boolean":return n?"TRUE":"FALSE";case"string":return`'${n}'`;case"number":return Number.isFinite(n)?String(n):"NULL";default:if(n==null)return"NULL";if(n instanceof Date){const t=+n;if(Number.isNaN(t))return"NULL";const e=n.getUTCFullYear(),r=n.getUTCMonth(),i=n.getUTCDate();return t===Date.UTC(e,r,i)?`MAKE_DATE(${e}, ${r+1}, ${i})`:`EPOCH_MS(${t})`}else return n instanceof RegExp?`'${n.source}'`:String(n)}}const Hi=n=>typeof(n==null?void 0:n.addEventListener)=="function";function Gu(n){return n instanceof Yu}class Yu{constructor(t,e,r){this._expr=Array.isArray(t)?t:[t],this._deps=e||[],this.annotate(r);const i=this._expr.filter(s=>Hi(s));i.length>0?(this._params=Array.from(new Set(i)),this._params.forEach(s=>{s.addEventListener("value",()=>{var o;return ap(this,(o=this.map)==null?void 0:o.get("value"))})})):this.addEventListener=void 0}get value(){return this}get columns(){const{_params:t,_deps:e}=this;if(t){const r=new Set(t.flatMap(i=>{var o;const s=(o=i.value)==null?void 0:o.columns;return Array.isArray(s)?s:[]}));if(r.size){const i=new Set(e);return r.forEach(s=>i.add(s)),Array.from(i)}}return e}get column(){return this._deps.length?this._deps[0]:this.columns[0]}annotate(...t){return Object.assign(this,...t)}toString(){return this._expr.map(t=>Hi(t)&&!Gu(t)?Wu(t.value):t).join("")}addEventListener(t,e){const r=this.map||(this.map=new Map);(r.get(t)||(r.set(t,new Set),r.get(t))).add(e)}}function ap(n,t){if(t!=null&&t.size)return Promise.allSettled(Array.from(t,e=>e(n)))}function cp(n,t){const e=[n[0]],r=new Set,i=t.length;for(let s=0,o=0;sr.add(u)),e[o]+=typeof a=="string"?a:Wu(a));const c=n[++s];Hi(e[o])?e[++o]=c:e[o]+=c}return{spans:e,cols:Array.from(r)}}function fn(n,...t){const{spans:e,cols:r}=cp(n,t);return new Yu(e,r)}class gn{static select(...t){return new gn().select(...t)}static from(...t){return new gn().from(...t)}static with(...t){return new gn().with(...t)}static union(...t){return new bn("UNION",t.flat())}static unionAll(...t){return new bn("UNION ALL",t.flat())}static intersect(...t){return new bn("INTERSECT",t.flat())}static except(...t){return new bn("EXCEPT",t.flat())}constructor(){this.query={with:[],select:[],from:[],where:[],groupby:[],having:[],window:[],qualify:[],orderby:[]}}clone(){const t=new gn;return t.query={...this.query},t}with(...t){const{query:e}=this;if(t.length===0)return e.with;{const r=[],i=(s,o)=>{const a=o.clone();a.cteFor=this,r.push({as:s,query:a})};return t.flat().forEach(s=>{if(s!=null)if(s.as&&s.query)i(s.as,s.query);else for(const o in s)i(o,s[o])}),e.with=e.with.concat(r),this}}select(...t){const{query:e}=this;if(t.length===0)return e.select;{const r=[];for(const i of t.flat())if(i!=null)if(typeof i=="string")r.push({as:i,expr:Er(i)});else if(i instanceof Cr)r.push({as:i.column,expr:i});else if(Array.isArray(i))r.push({as:i[0],expr:i[1]});else for(const s in i)r.push({as:si(s),expr:Er(i[s])});return e.select=e.select.concat(r),this}}$select(...t){return this.query.select=[],this.select(...t)}distinct(t=!0){return this.query.distinct=!!t,this}from(...t){const{query:e}=this;if(t.length===0)return e.from;{const r=[];return t.flat().forEach(i=>{if(i!=null)if(typeof i=="string")r.push({as:i,from:Rs(i)});else if(i instanceof Cr)r.push({as:i.table,from:i});else if(Ds(i)||Gu(i))r.push({from:i});else if(Array.isArray(i))r.push({as:si(i[0]),from:Rs(i[1])});else for(const s in i)r.push({as:si(s),from:Rs(i[s])})}),e.from=e.from.concat(r),this}}$from(...t){return this.query.from=[],this.from(...t)}sample(t,e){const{query:r}=this;if(arguments.length===0)return r.sample;{let i=t;return typeof t=="number"&&(i=t>0&&t<1?{perc:100*t,method:e}:{rows:Math.round(t),method:e}),r.sample=i,this}}where(...t){const{query:e}=this;return t.length===0?e.where:(e.where=e.where.concat(t.flat().filter(r=>r)),this)}$where(...t){return this.query.where=[],this.where(...t)}groupby(...t){const{query:e}=this;return t.length===0?e.groupby:(e.groupby=e.groupby.concat(t.flat().filter(r=>r).map(Er)),this)}$groupby(...t){return this.query.groupby=[],this.groupby(...t)}having(...t){const{query:e}=this;return t.length===0?e.having:(e.having=e.having.concat(t.flat().filter(r=>r)),this)}window(...t){const{query:e}=this;if(t.length===0)return e.window;{const r=[];return t.flat().forEach(i=>{if(i!=null)for(const s in i)r.push({as:si(s),expr:i[s]})}),e.window=e.window.concat(r),this}}qualify(...t){const{query:e}=this;return t.length===0?e.qualify:(e.qualify=e.qualify.concat(t.flat().filter(r=>r)),this)}orderby(...t){const{query:e}=this;return t.length===0?e.orderby:(e.orderby=e.orderby.concat(t.flat().filter(r=>r).map(Er)),this)}limit(t){const{query:e}=this;return arguments.length===0?e.limit:(e.limit=Number.isFinite(t)?t:void 0,this)}offset(t){const{query:e}=this;return arguments.length===0?e.offset:(e.offset=Number.isFinite(t)?t:void 0,this)}get subqueries(){const{query:t,cteFor:e}=this,r=((e==null?void 0:e.query)||t).with,i=r==null?void 0:r.reduce((o,{as:a,query:c})=>(o[a]=c,o),{}),s=[];return t.from.forEach(({from:o})=>{if(Ds(o))s.push(o);else if(i[o.table]){const a=i[o.table];s.push(a)}}),s}toString(){const{select:t,distinct:e,from:r,sample:i,where:s,groupby:o,having:a,window:c,qualify:u,orderby:d,limit:w,offset:F,with:v}=this.query,N=[];if(v.length){const D=v.map(({as:B,query:nt})=>`"${B}" AS (${nt})`);N.push(`WITH ${D.join(", ")}`)}const dt=t.map(({as:D,expr:B})=>ip(B,D)&&!B.table?`${B}`:`${B} AS "${D}"`);if(N.push(`SELECT${e?" DISTINCT":""} ${dt.join(", ")}`),r.length){const D=r.map(({as:B,from:nt})=>{const mt=Ds(nt)?`(${nt})`:`${nt}`;return!B||B===nt.table?mt:`${mt} AS "${B}"`});N.push(`FROM ${D.join(", ")}`)}if(s.length){const D=s.map(String).filter(B=>B).join(" AND ");D&&N.push(`WHERE ${D}`)}if(i){const{rows:D,perc:B,method:nt,seed:mt}=i,M=D?`${D} ROWS`:`${B} PERCENT`,Ct=nt?` (${nt}${mt!=null?`, ${mt}`:""})`:"";N.push(`USING SAMPLE ${M}${Ct}`)}if(o.length&&N.push(`GROUP BY ${o.join(", ")}`),a.length){const D=a.map(String).filter(B=>B).join(" AND ");D&&N.push(`HAVING ${D}`)}if(c.length){const D=c.map(({as:B,expr:nt})=>`"${B}" AS (${nt})`);N.push(`WINDOW ${D.join(", ")}`)}if(u.length){const D=u.map(String).filter(B=>B).join(" AND ");D&&N.push(`QUALIFY ${D}`)}return d.length&&N.push(`ORDER BY ${d.join(", ")}`),Number.isFinite(w)&&N.push(`LIMIT ${w}`),Number.isFinite(F)&&N.push(`OFFSET ${F}`),N.join(" ")}}class bn{constructor(t,e){this.op=t,this.queries=e.map(r=>r.clone()),this.query={orderby:[]}}clone(){const t=new bn(this.op,this.queries);return t.query={...this.query},t}orderby(...t){const{query:e}=this;return t.length===0?e.orderby:(e.orderby=e.orderby.concat(t.flat().filter(r=>r).map(Er)),this)}limit(t){const{query:e}=this;return arguments.length===0?e.limit:(e.limit=Number.isFinite(t)?t:void 0,this)}offset(t){const{query:e}=this;return arguments.length===0?e.offset:(e.offset=Number.isFinite(t)?t:void 0,this)}get subqueries(){const{queries:t,cteFor:e}=this;return e&&t.forEach(r=>r.cteFor=e),t}toString(){const{op:t,queries:e,query:{orderby:r,limit:i,offset:s}}=this,o=[e.join(` ${t} `)];return r.length&&o.push(`ORDER BY ${r.join(", ")}`),Number.isFinite(i)&&o.push(`LIMIT ${i}`),Number.isFinite(s)&&o.push(`OFFSET ${s}`),o.join(" ")}}function Ds(n){return n instanceof gn||n instanceof bn}function si(n){return up(n)?n.slice(1,-1):n}function up(n){return n[0]==='"'&&n[n.length-1]==='"'}const lp="___usql_query";let Qu=Nf;const ey=n=>{Da(lp,n),Qu=n},ny=(n,t,e)=>{const r=ir(Fa(n,t,e));let i;return{results:cl(r,s=>s),update:async s=>{const{hasQuery:o,query:a}=Fa(s,t);o?fe(()=>{a.hash!==(i==null?void 0:i.hash)&&(i=a,r.set({hasQuery:o,query:a}))},a.fetch()):r.set({hasQuery:!1})}}},Fa=({value:n,label:t,select:e,data:r,where:i,order:s},o,a)=>{if(!r||!(n||e))return{hasQuery:!1};let c=!1;const u=new gn().distinct();if(n&&u.select({value:fn`${n}`}),t?u.select({label:fn`${t}`}):u.select({label:fn`${n}`}),e&&u.select(e),typeof r=="string")r.trim().match(/^[\w]+$/)?u.from(r.trim()):u.from(fn(r.trim()));else if(zu.isQuery(r))u.from(fn`(${r.text})`),c=r.opts.noResolve??!1;else return{hasQuery:!1};i&&u.where(i),s&&(u.orderby(fn`${s}`),u.select({ordinal:fn`row_number() over (ORDER BY ${s})`}));const d=hp(u.toString(),o,a,{noResolve:c});return d.fetch(),{hasQuery:!0,query:d}},hp=(n,t,e,r)=>zu.create(n,Qu,t,{...r,initialData:e});var Hu={exports:{}};(function(n){var t={},e=function(i){i.version="0.11.2";function s(p){for(var f="",y=p.length-1;y>=0;)f+=p.charAt(y--);return f}function o(p,f){for(var y="";y.length=f?y:o("0",f-y.length)+y}function c(p,f){var y=""+p;return y.length>=f?y:o(" ",f-y.length)+y}function u(p,f){var y=""+p;return y.length>=f?y:y+o(" ",f-y.length)}function d(p,f){var y=""+Math.round(p);return y.length>=f?y:o("0",f-y.length)+y}function w(p,f){var y=""+p;return y.length>=f?y:o("0",f-y.length)+y}var F=Math.pow(2,32);function v(p,f){if(p>F||p<-F)return d(p,f);var y=Math.round(p);return w(y,f)}function N(p,f){return f=f||0,p.length>=7+f&&(p.charCodeAt(f)|32)===103&&(p.charCodeAt(f+1)|32)===101&&(p.charCodeAt(f+2)|32)===110&&(p.charCodeAt(f+3)|32)===101&&(p.charCodeAt(f+4)|32)===114&&(p.charCodeAt(f+5)|32)===97&&(p.charCodeAt(f+6)|32)===108}var dt=[["Sun","Sunday"],["Mon","Monday"],["Tue","Tuesday"],["Wed","Wednesday"],["Thu","Thursday"],["Fri","Friday"],["Sat","Saturday"]],D=[["J","Jan","January"],["F","Feb","February"],["M","Mar","March"],["A","Apr","April"],["M","May","May"],["J","Jun","June"],["J","Jul","July"],["A","Aug","August"],["S","Sep","September"],["O","Oct","October"],["N","Nov","November"],["D","Dec","December"]];function B(p){p[0]="General",p[1]="0",p[2]="0.00",p[3]="#,##0",p[4]="#,##0.00",p[9]="0%",p[10]="0.00%",p[11]="0.00E+00",p[12]="# ?/?",p[13]="# ??/??",p[14]="m/d/yy",p[15]="d-mmm-yy",p[16]="d-mmm",p[17]="mmm-yy",p[18]="h:mm AM/PM",p[19]="h:mm:ss AM/PM",p[20]="h:mm",p[21]="h:mm:ss",p[22]="m/d/yy h:mm",p[37]="#,##0 ;(#,##0)",p[38]="#,##0 ;[Red](#,##0)",p[39]="#,##0.00;(#,##0.00)",p[40]="#,##0.00;[Red](#,##0.00)",p[45]="mm:ss",p[46]="[h]:mm:ss",p[47]="mmss.0",p[48]="##0.0E+0",p[49]="@",p[56]='"上午/下午 "hh"時"mm"分"ss"秒 "'}var nt={};B(nt);var mt=[],M=0;for(M=5;M<=8;++M)mt[M]=32+M;for(M=23;M<=26;++M)mt[M]=0;for(M=27;M<=31;++M)mt[M]=14;for(M=50;M<=58;++M)mt[M]=14;for(M=59;M<=62;++M)mt[M]=M-58;for(M=67;M<=68;++M)mt[M]=M-58;for(M=72;M<=75;++M)mt[M]=M-58;for(M=67;M<=68;++M)mt[M]=M-57;for(M=76;M<=78;++M)mt[M]=M-56;for(M=79;M<=81;++M)mt[M]=M-34;var Ct=[];Ct[5]=Ct[63]='"$"#,##0_);\\("$"#,##0\\)',Ct[6]=Ct[64]='"$"#,##0_);[Red]\\("$"#,##0\\)',Ct[7]=Ct[65]='"$"#,##0.00_);\\("$"#,##0.00\\)',Ct[8]=Ct[66]='"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',Ct[41]='_(* #,##0_);_(* \\(#,##0\\);_(* "-"_);_(@_)',Ct[42]='_("$"* #,##0_);_("$"* \\(#,##0\\);_("$"* "-"_);_(@_)',Ct[43]='_(* #,##0.00_);_(* \\(#,##0.00\\);_(* "-"??_);_(@_)',Ct[44]='_("$"* #,##0.00_);_("$"* \\(#,##0.00\\);_("$"* "-"??_);_(@_)';function Jr(p,f,y){for(var R=p<0?-1:1,g=p*R,C=0,b=1,T=0,J=1,A=0,Z=0,rt=Math.floor(g);Af&&(A>f?(Z=J,T=C):(Z=A,T=b)),!y)return[0,R*T,Z];var he=Math.floor(R*T/Z);return[he,R*T-he*Z,Z]}function cr(p,f,y){if(p>2958465||p<0)return null;var R=p|0,g=Math.floor(86400*(p-R)),C=0,b=[],T={D:R,T:g,u:86400*(p-R)-g,y:0,m:0,d:0,H:0,M:0,S:0,q:0};if(Math.abs(T.u)<1e-6&&(T.u=0),f&&f.date1904&&(R+=1462),T.u>.9999&&(T.u=0,++g==86400&&(T.T=g=0,++R,++T.D)),R===60)b=y?[1317,10,29]:[1900,2,29],C=3;else if(R===0)b=y?[1317,8,29]:[1900,1,0],C=6;else{R>60&&--R;var J=new Date(1900,0,1);J.setDate(J.getDate()+R-1),b=[J.getFullYear(),J.getMonth()+1,J.getDate()],C=J.getDay(),R<60&&(C=(C+6)%7),y&&(C=tl(J,b))}return T.y=b[0],T.m=b[1],T.d=b[2],T.S=g%60,g=Math.floor(g/60),T.M=g%60,g=Math.floor(g/60),T.H=g,T.q=C,T}i.parse_date_code=cr;var Do=new Date(1899,11,31,0,0,0),Ju=Do.getTime(),Zu=new Date(1900,2,1,0,0,0);function Bo(p,f){var y=p.getTime();return f?y-=1262304e5:p>=Zu&&(y+=864e5),(y-(Ju+(p.getTimezoneOffset()-Do.getTimezoneOffset())*6e4))/864e5}function Xu(p){return p.toString(10)}i._general_int=Xu;var Mo=(function(){var f=/(?:\.0*|(\.\d*[1-9])0+)$/;function y(A){return A.indexOf(".")==-1?A:A.replace(f,"$1")}var R=/(?:\.0*|(\.\d*[1-9])0+)[Ee]/,g=/(E[+-])(\d)$/;function C(A){return A.indexOf("E")==-1?A:A.replace(R,"$1E").replace(g,"$10$2")}function b(A){var Z=A<0?12:11,rt=y(A.toFixed(12));return rt.length<=Z||(rt=A.toPrecision(10),rt.length<=Z)?rt:A.toExponential(5)}function T(A){var Z=y(A.toFixed(11));return Z.length>(A<0?12:11)||Z==="0"||Z==="-0"?A.toPrecision(6):Z}function J(A){var Z=Math.floor(Math.log(Math.abs(A))*Math.LOG10E),rt;return Z>=-4&&Z<=-1?rt=A.toPrecision(10+Z):Math.abs(Z)<=9?rt=b(A):Z===10?rt=A.toFixed(10).substr(0,12):rt=T(A),y(C(rt.toUpperCase()))}return J})();i._general_num=Mo;function Zr(p,f){switch(typeof p){case"string":return p;case"boolean":return p?"TRUE":"FALSE";case"number":return(p|0)===p?p.toString(10):Mo(p);case"undefined":return"";case"object":if(p==null)return"";if(p instanceof Date)return jo(14,Bo(p,f&&f.date1904),f)}throw new Error("unsupported value in General format: "+p)}i._general=Zr;function tl(p,f){f[0]-=581;var y=p.getDay();return p<60&&(y=(y+6)%7),y}function el(p,f,y,R){var g="",C=0,b=0,T=y.y,J,A=0;switch(p){case 98:T=y.y+543;case 121:switch(f.length){case 1:case 2:J=T%100,A=2;break;default:J=T%1e4,A=4;break}break;case 109:switch(f.length){case 1:case 2:J=y.m,A=f.length;break;case 3:return D[y.m-1][1];case 5:return D[y.m-1][0];default:return D[y.m-1][2]}break;case 100:switch(f.length){case 1:case 2:J=y.d,A=f.length;break;case 3:return dt[y.q][0];default:return dt[y.q][1]}break;case 104:switch(f.length){case 1:case 2:J=1+(y.H+11)%12,A=f.length;break;default:throw"bad hour format: "+f}break;case 72:switch(f.length){case 1:case 2:J=y.H,A=f.length;break;default:throw"bad hour format: "+f}break;case 77:switch(f.length){case 1:case 2:J=y.M,A=f.length;break;default:throw"bad minute format: "+f}break;case 115:if(f!="s"&&f!="ss"&&f!=".0"&&f!=".00"&&f!=".000")throw"bad second format: "+f;return y.u===0&&(f=="s"||f=="ss")?a(y.S,f.length):(R>=2?b=R===3?1e3:100:b=R===1?10:1,C=Math.round(b*(y.S+y.u)),C>=60*b&&(C=0),f==="s"?C===0?"0":""+C/b:(g=a(C,2+R),f==="ss"?g.substr(0,2):"."+g.substr(2,f.length-1)));case 90:switch(f){case"[h]":case"[hh]":J=y.D*24+y.H;break;case"[m]":case"[mm]":J=(y.D*24+y.H)*60+y.M;break;case"[s]":case"[ss]":J=((y.D*24+y.H)*60+y.M)*60+Math.round(y.S+y.u);break;default:throw"bad abstime format: "+f}A=f.length===3?1:2;break;case 101:J=T,A=1;break}var Z=A>0?a(J,A):"";return Z}function qe(p){var f=3;if(p.length<=f)return p;for(var y=p.length%f,R=p.substr(0,y);y!=p.length;y+=f)R+=(R.length>0?",":"")+p.substr(y,f);return R}var Re=(function(){var f=/%/g;function y(E,m,_){var U=m.replace(f,""),S=m.length-U.length;return Re(E,U,_*Math.pow(10,2*S))+o("%",S)}function R(E,m,_){for(var U=m.length-1;m.charCodeAt(U-1)===44;)--U;return Re(E,m.substr(0,U),_/Math.pow(10,3*(m.length-U)))}function g(E,m){var _,U=E.indexOf("E")-E.indexOf(".")-1;if(E.match(/^#+0.0E\+0$/)){if(m==0)return"0.0E+0";if(m<0)return"-"+g(E,-m);var S=E.indexOf(".");S===-1&&(S=E.indexOf("E"));var I=Math.floor(Math.log(m)*Math.LOG10E)%S;if(I<0&&(I+=S),_=(m/Math.pow(10,I)).toPrecision(U+1+(S+I)%S),_.indexOf("e")===-1){var tt=Math.floor(Math.log(m)*Math.LOG10E);for(_.indexOf(".")===-1?_=_.charAt(0)+"."+_.substr(1)+"E+"+(tt-_.length+I):_+="E+"+(tt-I);_.substr(0,2)==="0.";)_=_.charAt(0)+_.substr(2,S)+"."+_.substr(2+S),_=_.replace(/^0+([1-9])/,"$1").replace(/^0+\./,"0.");_=_.replace(/\+-/,"-")}_=_.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function(It,Ft,Nt,at){return Ft+Nt+at.substr(0,(S+I)%S)+"."+at.substr(I)+"E"})}else _=m.toExponential(U);return E.match(/E\+00$/)&&_.match(/e[+-]\d$/)&&(_=_.substr(0,_.length-1)+"0"+_.charAt(_.length-1)),E.match(/E\-/)&&_.match(/e\+/)&&(_=_.replace(/e\+/,"e")),_.replace("e","E")}var C=/# (\?+)( ?)\/( ?)(\d+)/;function b(E,m,_){var U=parseInt(E[4],10),S=Math.round(m*U),I=Math.floor(S/U),tt=S-I*U,It=U;return _+(I===0?"":""+I)+" "+(tt===0?o(" ",E[1].length+1+E[4].length):c(tt,E[1].length)+E[2]+"/"+E[3]+a(It,E[4].length))}function T(E,m,_){return _+(m===0?"":""+m)+o(" ",E[1].length+2+E[4].length)}var J=/^#*0*\.([0#]+)/,A=/\).*[0#]/,Z=/\(###\) ###\\?-####/;function rt(E){for(var m="",_,U=0;U!=E.length;++U)switch(_=E.charCodeAt(U)){case 35:break;case 63:m+=" ";break;case 48:m+="0";break;default:m+=String.fromCharCode(_)}return m}function he(E,m){var _=Math.pow(10,m);return""+Math.round(E*_)/_}function ln(E,m){var _=E-Math.floor(E),U=Math.pow(10,m);return m<(""+Math.round(_*U)).length?0:Math.round(_*U)}function fs(E,m){return m<(""+Math.round((E-Math.floor(E))*Math.pow(10,m))).length?1:0}function de(E){return E<2147483647&&E>-2147483648?""+(E>=0?E|0:E-1|0):""+Math.floor(E)}function bt(E,m,_){if(E.charCodeAt(0)===40&&!m.match(A)){var U=m.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return _>=0?bt("n",U,_):"("+bt("n",U,-_)+")"}if(m.charCodeAt(m.length-1)===44)return R(E,m,_);if(m.indexOf("%")!==-1)return y(E,m,_);if(m.indexOf("E")!==-1)return g(m,_);if(m.charCodeAt(0)===36)return"$"+bt(E,m.substr(m.charAt(1)==" "?2:1),_);var S,I,tt,It,Ft=Math.abs(_),Nt=_<0?"-":"";if(m.match(/^00+$/))return Nt+v(Ft,m.length);if(m.match(/^[#?]+$/))return S=v(_,0),S==="0"&&(S=""),S.length>m.length?S:rt(m.substr(0,m.length-S.length))+S;if(I=m.match(C))return b(I,Ft,Nt);if(m.match(/^#+0+$/))return Nt+v(Ft,m.length-m.indexOf("0"));if(I=m.match(J))return S=he(_,I[1].length).replace(/^([^\.]+)$/,"$1."+rt(I[1])).replace(/\.$/,"."+rt(I[1])).replace(/\.(\d*)$/,function(Zt,dr){return"."+dr+o("0",rt(I[1]).length-dr.length)}),m.indexOf("0.")!==-1?S:S.replace(/^0\./,".");if(m=m.replace(/^#+([0.])/,"$1"),I=m.match(/^(0*)\.(#*)$/))return Nt+he(Ft,I[2].length).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,I[1].length?"0.":".");if(I=m.match(/^#{1,3},##0(\.?)$/))return Nt+qe(v(Ft,0));if(I=m.match(/^#,##0\.([#0]*0)$/))return _<0?"-"+bt(E,m,-_):qe(""+(Math.floor(_)+fs(_,I[1].length)))+"."+a(ln(_,I[1].length),I[1].length);if(I=m.match(/^#,#*,#0/))return bt(E,m.replace(/^#,#*,/,""),_);if(I=m.match(/^([0#]+)(\\?-([0#]+))+$/))return S=s(bt(E,m.replace(/[\\-]/g,""),_)),tt=0,s(s(m.replace(/\\/g,"")).replace(/[0#]/g,function(Zt){return tt=0?H("n",U,_):"("+H("n",U,-_)+")"}if(m.charCodeAt(m.length-1)===44)return ur(E,m,_);if(m.indexOf("%")!==-1)return Xr(E,m,_);if(m.indexOf("E")!==-1)return De(m,_);if(m.charCodeAt(0)===36)return"$"+H(E,m.substr(m.charAt(1)==" "?2:1),_);var S,I,tt,It,Ft=Math.abs(_),Nt=_<0?"-":"";if(m.match(/^00+$/))return Nt+a(Ft,m.length);if(m.match(/^[#?]+$/))return S=""+_,_===0&&(S=""),S.length>m.length?S:rt(m.substr(0,m.length-S.length))+S;if(I=m.match(C))return T(I,Ft,Nt);if(m.match(/^#+0+$/))return Nt+a(Ft,m.length-m.indexOf("0"));if(I=m.match(J))return S=(""+_).replace(/^([^\.]+)$/,"$1."+rt(I[1])).replace(/\.$/,"."+rt(I[1])),S=S.replace(/\.(\d*)$/,function(Zt,dr){return"."+dr+o("0",rt(I[1]).length-dr.length)}),m.indexOf("0.")!==-1?S:S.replace(/^0\./,".");if(m=m.replace(/^#+([0.])/,"$1"),I=m.match(/^(0*)\.(#*)$/))return Nt+(""+Ft).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,I[1].length?"0.":".");if(I=m.match(/^#{1,3},##0(\.?)$/))return Nt+qe(""+Ft);if(I=m.match(/^#,##0\.([#0]*0)$/))return _<0?"-"+H(E,m,-_):qe(""+_)+"."+o("0",I[1].length);if(I=m.match(/^#,#*,#0/))return H(E,m.replace(/^#,#*,/,""),_);if(I=m.match(/^([0#]+)(\\?-([0#]+))+$/))return S=s(H(E,m.replace(/[\\-]/g,""),_)),tt=0,s(s(m.replace(/\\/g,"")).replace(/[0#]/g,function(Zt){return tt-1||y=="\\"&&p.charAt(f+1)=="-"&&"0#".indexOf(p.charAt(f+2))>-1););break;case"?":for(;p.charAt(++f)===y;);break;case"*":++f,(p.charAt(f)==" "||p.charAt(f)=="*")&&++f;break;case"(":case")":++f;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(;f-1;);break;case" ":++f;break;default:++f;break}return!1}i.is_date=Uo;function xo(p,f,y,R){for(var g=[],C="",b=0,T="",J="t",A,Z,rt,he="H";b=12?"P":"A"),de.t="T",he="h",b+=3):p.substr(b,5).toUpperCase()==="AM/PM"?(A!=null&&(de.v=A.H>=12?"PM":"AM"),de.t="T",b+=5,he="h"):p.substr(b,5).toUpperCase()==="上午/下午"?(A!=null&&(de.v=A.H>=12?"下午":"上午"),de.t="T",b+=5,he="h"):(de.t="t",++b),A==null&&de.t==="T")return"";g[g.length]=de,J=T;break;case"[":for(C=T;p.charAt(b++)!=="]"&&b-1&&(C=(C.match(/\$([^-\[\]]*)/)||[])[1]||"$",Uo(p)||(g[g.length]={t:"t",v:C}));break;case".":if(A!=null){for(C=T;++b-1;)C+=T;g[g.length]={t:"n",v:C};break;case"?":for(C=T;p.charAt(++b)===T;)C+=T;g[g.length]={t:T,v:C},J=T;break;case"*":++b,(p.charAt(b)==" "||p.charAt(b)=="*")&&++b;break;case"(":case")":g[g.length]={t:R===1?"t":T,v:T},++b;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(C=T;b-1;)C+=p.charAt(b);g[g.length]={t:"D",v:C};break;case" ":g[g.length]={t:T,v:T},++b;break;case"$":g[g.length]={t:"t",v:"$"},++b;break;default:if(",$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(T)===-1)throw new Error("unrecognized character "+T+" in "+p);g[g.length]={t:"t",v:T},++b;break}var bt=0,ur=0,Xr;for(b=g.length-1,J="t";b>=0;--b)switch(g[b].t){case"h":case"H":g[b].t=he,J="h",bt<1&&(bt=1);break;case"s":(Xr=g[b].v.match(/\.0+$/))&&(ur=Math.max(ur,Xr[0].length-1)),bt<3&&(bt=3);case"d":case"y":case"M":case"e":J=g[b].t;break;case"m":J==="s"&&(g[b].t="M",bt<2&&(bt=2));break;case"X":break;case"Z":bt<1&&g[b].v.match(/[Hh]/)&&(bt=1),bt<2&&g[b].v.match(/[Mm]/)&&(bt=2),bt<3&&g[b].v.match(/[Ss]/)&&(bt=3)}switch(bt){case 0:break;case 1:A.u>=.5&&(A.u=0,++A.S),A.S>=60&&(A.S=0,++A.M),A.M>=60&&(A.M=0,++A.H);break;case 2:A.u>=.5&&(A.u=0,++A.S),A.S>=60&&(A.S=0,++A.M);break}var De="",H;for(b=0;b0){De.charCodeAt(0)==40?(m=f<0&&De.charCodeAt(0)===45?-f:f,_=Re("n",De,m)):(m=f<0&&R>1?-f:f,_=Re("n",De,m),m<0&&g[0]&&g[0].t=="t"&&(_=_.substr(1),g[0].v="-"+g[0].v)),H=_.length-1;var U=g.length;for(b=0;b-1){U=b;break}var S=g.length;if(U===g.length&&_.indexOf("E")===-1){for(b=g.length-1;b>=0;--b)g[b]==null||"n?".indexOf(g[b].t)===-1||(H>=g[b].v.length-1?(H-=g[b].v.length,g[b].v=_.substr(H+1,g[b].v.length)):H<0?g[b].v="":(g[b].v=_.substr(0,H+1),H=-1),g[b].t="t",S=b);H>=0&&S=0;--b)if(!(g[b]==null||"n?".indexOf(g[b].t)===-1)){for(Z=g[b].v.indexOf(".")>-1&&b===U?g[b].v.indexOf(".")-1:g[b].v.length-1,E=g[b].v.substr(Z+1);Z>=0;--Z)H>=0&&(g[b].v.charAt(Z)==="0"||g[b].v.charAt(Z)==="#")&&(E=_.charAt(H--)+E);g[b].v=E,g[b].t="t",S=b}for(H>=0&&S-1&&b===U?g[b].v.indexOf(".")+1:0,E=g[b].v.substr(0,Z);Z-1&&(m=R>1&&f<0&&b>0&&g[b-1].v==="-"?-f:f,g[b].v=Re(g[b].t,g[b].v,m),g[b].t="t");var I="";for(b=0;b!==g.length;++b)g[b]!=null&&(I+=g[b].v);return I}i._eval=xo;var $o=/\[[=<>]/,Po=/\[(=|>[=]?|<[>=]?)(-?\d+(?:\.\d*)?)\]/;function ko(p,f){if(f==null)return!1;var y=parseFloat(f[2]);switch(f[1]){case"=":if(p==y)return!0;break;case">":if(p>y)return!0;break;case"<":if(p":if(p!=y)return!0;break;case">=":if(p>=y)return!0;break;case"<=":if(p<=y)return!0;break}return!1}function nl(p,f){var y=Lo(p),R=y.length,g=y[R-1].indexOf("@");if(R<4&&g>-1&&--R,y.length>4)throw new Error("cannot find right format for |"+y.join("|")+"|");if(typeof f!="number")return[4,y.length===4||g>-1?y[y.length-1]:"@"];switch(y.length){case 1:y=g>-1?["General","General","General",y[0]]:[y[0],y[0],y[0],"@"];break;case 2:y=g>-1?[y[0],y[0],y[0],y[1]]:[y[0],y[1],y[0],"@"];break;case 3:y=g>-1?[y[0],y[1],y[0],y[2]]:[y[0],y[1],y[2],"@"];break}var C=f>0?y[0]:f<0?y[1]:y[2];if(y[0].indexOf("[")===-1&&y[1].indexOf("[")===-1)return[R,C];if(y[0].match($o)!=null||y[1].match($o)!=null){var b=y[0].match(Po),T=y[1].match(Po);return ko(f,b)?[R,y[0]]:ko(f,T)?[R,y[1]]:[R,y[b!=null&&T!=null?2:1]]}return[R,C]}function jo(p,f,y){y==null&&(y={});var R="";switch(typeof p){case"string":p=="m/d/yy"&&y.dateNF?R=y.dateNF:R=p;break;case"number":p==14&&y.dateNF?R=y.dateNF:R=(y.table!=null?y.table:nt)[p],R==null&&(R=y.table&&y.table[mt[p]]||nt[mt[p]]),R==null&&(R=Ct[p]||"General");break}if(N(R,0))return Zr(f,y);f instanceof Date&&(f=Bo(f,y.date1904));var g=nl(R,f);if(N(g[1]))return Zr(f,y);if(f===!0)f="TRUE";else if(f===!1)f="FALSE";else if(f===""||f==null)return"";return xo(g[1],f,y,g[0])}function Vo(p,f){if(typeof f!="number"){f=+f||-1;for(var y=0;y<392;++y){if(nt[y]==null){f<0&&(f=y);continue}if(nt[y]==p){f=y;break}}f<0&&(f=391)}return nt[f]=p,f}i.load=Vo,i._table=nt,i.get_table=function(){return nt},i.load_table=function(f){for(var y=0;y!=392;++y)f[y]!==void 0&&Vo(f[y],y)},i.init_table=B,i.format=jo};e(t),typeof DO_NOT_EXPORT_SSF>"u"&&(n.exports=t)})(Hu);var dp=Hu.exports;const Ur=rp(dp),ry="customFormattingSettings",en="auto",fp=3,pp=[{name:"year",description:'When lowerCase(columnName)="year" with the column having numeric values will result in no formatting',matchingFunction:(n,t,e)=>n&&t?n.toLowerCase()==="year"&&((t==null?void 0:t.evidenceType)==="number"||(e==null?void 0:e.unitType)==="number"):!1,format:{formatCode:en,valueType:"number",exampleInput:2013,_autoFormat:{autoFormatCode:"@",truncateUnits:!1}}},{name:"id",description:'When lowerCase(columnName)="id" with the column having numeric values, then values will have no formatting',matchingFunction:(n,t,e)=>n&&t?n.toLowerCase()==="id"&&((t==null?void 0:t.evidenceType)==="number"||(e==null?void 0:e.unitType)==="number"):!1,format:{formatCode:en,valueType:"number",exampleInput:93120121,_autoFormat:{autoFormatFunction:n=>n!=null&&!isNaN(n)?n.toLocaleString("fullwide",{useGrouping:!1}):n}}},{name:"defaultDate",description:"Formatting for Default Date",matchingFunction:(n,t,e)=>t?(t==null?void 0:t.evidenceType)==="date"||(e==null?void 0:e.unitType)==="date":!1,format:{formatCode:en,valueType:"date",exampleInput:"Sat Jan 01 2022 03:15:00 GMT-0500",_autoFormat:{autoFormatCode:"YYYY-MM-DD",truncateUnits:!1}}}],No=(n,t)=>{switch(t){case"T":return n/1e12;case"B":return n/1e9;case"M":return n/1e6;case"k":return n/1e3;default:return n}},iy=(n,t)=>{var i,s,o;let e=((i=t||n.formatCode)==null?void 0:i.toLowerCase())===en,r=((s=n._autoFormat)==null?void 0:s.autoFormatFunction)||((o=n._autoFormat)==null?void 0:o.autoFormatCode);return!!(e&&r!==void 0)},Ro=(n,t=7)=>{let e,r="",i=n==null?void 0:n.median,s;if(i!==void 0){let o;r=Ku(i),r?(o=No(i,r),s=!0):(o=i,s=!1),n.maxDecimals===0&&!s?e="#,##0":e=yp(o,t)}else e="#,##0",s=!1;return{formatCode:en,valueType:"number",_autoFormat:{autoFormatCode:e,truncateUnits:s,columnUnits:r}}},sy=(n,t,e)=>{let r=pp.find(i=>i.matchingFunction(n,t,e));if(r)return r.format;if((e==null?void 0:e.unitType)==="number")return Ro(e)},oy=(n,t,e=void 0)=>{var r,i,s;if((r=t._autoFormat)!=null&&r.autoFormatFunction)return t._autoFormat.autoFormatFunction(n,t,e);if(t._autoFormat.autoFormatCode){let o=(i=t==null?void 0:t._autoFormat)==null?void 0:i.autoFormatCode;if(t.valueType==="number"){let c=(s=t==null?void 0:t._autoFormat)==null?void 0:s.truncateUnits,u=n,d="";return c&&(e==null?void 0:e.median)!==void 0&&(d=Ku(e.median),u=No(n,d)),Ur.format(o,u)+d}else return Ur.format(o,n)}else console.warn("autoFormat called without a formatCode or function");return n},ay=n=>typeof n=="number"?n.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):n!=null?n==null?void 0:n.toString():"-";function yp(n,t=7,e=fp){let r="#,##0",i=mp(n),s=0;return i-e<0&&(s=Math.min(Math.max(Math.abs(i-e+1),0),t)),s>0&&(r+=".",r+="0".repeat(s)),r}function Ku(n){let t=Math.abs(n);return t>=5e12?"T":t>=5e9?"B":t>=5e6?"M":t>=5e3?"k":""}function mp(n){return n===0?0:Math.floor(Math.log10(n))}const gp=[{primaryCode:"usd",currencySymbol:"$",displayName:"USD - United States Dollar"},{primaryCode:"aud",currencySymbol:"A$",displayName:"AUD - Australian Dollar",escapeCurrencySymbol:!0},{primaryCode:"brl",currencySymbol:"R$",displayName:"BRL - Brazilian Real",escapeCurrencySymbol:!0},{primaryCode:"cad",currencySymbol:"C$",displayName:"CAD - Canadian Dollar",escapeCurrencySymbol:!0},{primaryCode:"cny",currencySymbol:"¥",displayName:"CNY - Renminbi",escapeCurrencySymbol:!0},{primaryCode:"eur",currencySymbol:"€",displayName:"EUR - Euro"},{primaryCode:"gbp",currencySymbol:"£",displayName:"GBP - Pound Sterling",escapeCurrencySymbol:!0},{primaryCode:"jpy",currencySymbol:"¥",displayName:"JPY - Japanese Yen",escapeCurrencySymbol:!0},{primaryCode:"inr",currencySymbol:"₹",displayName:"INR - Indian Rupee",escapeCurrencySymbol:!0},{primaryCode:"krw",currencySymbol:"₩",displayName:"KRW - South Korean won",escapeCurrencySymbol:!0},{primaryCode:"ngn",currencySymbol:"₦",displayName:"NGN - Nigerian Naira",escapeCurrencySymbol:!0},{primaryCode:"rub",currencySymbol:"rub",displayName:"RUB - Russian Ruble",escapeCurrencySymbol:!0},{primaryCode:"sek",currencySymbol:"kr",displayName:"SEK - Swedish Krona",escapeCurrencySymbol:!0}],bp=[{derivedSuffix:"",valueFormatCode:"#,##0",exampleInput:412.17,auto:!0},{derivedSuffix:"0",valueFormatCode:"#,##0",exampleInput:7043.123},{derivedSuffix:"1",valueFormatCode:"#,##0.0",exampleInput:7043.123},{derivedSuffix:"2",valueFormatCode:"#,##0.00",exampleInput:7043.123},{derivedSuffix:"0k",valueFormatCode:'#,##0,"k"',exampleInput:64301.12},{derivedSuffix:"1k",valueFormatCode:'#,##0.0,"k"',exampleInput:64301.12},{derivedSuffix:"2k",valueFormatCode:'#,##0.00,"k"',exampleInput:64301.12},{derivedSuffix:"0m",valueFormatCode:'#,##0,,"M"',exampleInput:456430112e-2},{derivedSuffix:"1m",valueFormatCode:'#,##0.0,,"M"',exampleInput:456430112e-2},{derivedSuffix:"2m",valueFormatCode:'#,##0.00,,"M"',exampleInput:456430112e-2},{derivedSuffix:"0b",valueFormatCode:'#,##0,,,"B"',exampleInput:978456430112e-2},{derivedSuffix:"1b",valueFormatCode:'#,##0.0,,,"B"',exampleInput:978456430112e-2},{derivedSuffix:"2b",valueFormatCode:'#,##0.00,,,"B"',exampleInput:978456430112e-2}],_p=gp.map(n=>{let t=[];return bp.forEach(e=>{let r={formatTag:n.primaryCode+e.derivedSuffix,parentFormat:n.primaryCode,formatCategory:"currency",valueType:"number",exampleInput:e.exampleInput,titleTagReplacement:` (${n.currencySymbol})`},i=n.escapeCurrencySymbol?`"${n.currencySymbol}"`:n.currencySymbol;e.auto||en===e.formatCode?(r.formatCode=en,r._autoFormat={autoFormatFunction:(s,o,a)=>{let c=Ro(a,2),u=`${i}${c._autoFormat.autoFormatCode}`,d="",w=s;return c._autoFormat.truncateUnits&&c._autoFormat.columnUnits?(d=c._autoFormat.columnUnits,w=No(s,c._autoFormat.columnUnits)):u.endsWith(".0")&&(u=u+"0"),Ur.format(u,w)+d}}):r.formatCode=`${i}${e.valueFormatCode}`,e.axisValueFormatCode&&(r.axisFormatCode=e.axisValueFormatCode),t.push(r)}),t}).flat(),cy=[..._p,{formatTag:"ddd",formatCode:"ddd",formatCategory:"date",valueType:"date",exampleInput:"2022-01-09 12:45"},{formatTag:"dddd",formatCode:"dddd",formatCategory:"date",valueType:"date",exampleInput:"2022-01-09 12:45"},{formatTag:"mmm",formatCode:"mmm",formatCategory:"date",valueType:"date",exampleInput:"2022-01-09 12:45"},{formatTag:"mmmm",formatCode:"mmmm",formatCategory:"date",valueType:"date",exampleInput:"2022-01-09 12:45"},{formatTag:"yyyy",formatCode:"yyyy",formatCategory:"date",valueType:"date",exampleInput:"2022-01-09 12:45"},{formatTag:"shortdate",formatCode:"mmm d/yy",formatCategory:"date",valueType:"date",exampleInput:"2022-01-09 12:45"},{formatTag:"longdate",formatCode:"mmmm d, yyyy",formatCategory:"date",valueType:"date",exampleInput:"2022-01-09 12:45"},{formatTag:"fulldate",formatCode:"dddd mmmm d, yyyy",formatCategory:"date",valueType:"date",exampleInput:"2022-01-09 12:45"},{formatTag:"mdy",formatCode:"m/d/y",formatCategory:"date",valueType:"date",exampleInput:"2022-01-09 12:45"},{formatTag:"dmy",formatCode:"d/m/y",formatCategory:"date",valueType:"date",exampleInput:"2022-01-09 12:45"},{formatTag:"hms",formatCode:"H:MM:SS AM/PM",formatCategory:"date",valueType:"date",exampleInput:"2022-01-09T11:45:03"},{formatTag:"num0",formatCode:"#,##0",formatCategory:"number",valueType:"number",exampleInput:11.23168},{formatTag:"num1",formatCode:"#,##0.0",formatCategory:"number",valueType:"number",exampleInput:11.23168},{formatTag:"num2",formatCode:"#,##0.00",formatCategory:"number",valueType:"number",exampleInput:11.23168},{formatTag:"num3",formatCode:"#,##0.000",formatCategory:"number",valueType:"number",exampleInput:11.23168},{formatTag:"num4",formatCode:"#,##0.0000",formatCategory:"number",valueType:"number",exampleInput:11.23168},{formatTag:"num0k",formatCode:'#,##0,"k"',formatCategory:"number",valueType:"number",exampleInput:64201},{formatTag:"num1k",formatCode:'#,##0.0,"k"',formatCategory:"number",valueType:"number",exampleInput:64201},{formatTag:"num2k",formatCode:'#,##0.00,"k"',formatCategory:"number",valueType:"number",exampleInput:64201},{formatTag:"num0m",formatCode:'#,##0,,"M"',formatCategory:"number",valueType:"number",exampleInput:42539483},{formatTag:"num1m",formatCode:'#,##0.0,,"M"',formatCategory:"number",valueType:"number",exampleInput:42539483},{formatTag:"num2m",formatCode:'#,##0.00,,"M"',formatCategory:"number",valueType:"number",exampleInput:42539483},{formatTag:"num0b",formatCode:'#,##0,,,"B"',formatCategory:"number",valueType:"number",exampleInput:1384937584},{formatTag:"num1b",formatCode:'#,##0.0,,,"B"',formatCategory:"number",valueType:"number",exampleInput:1384937584},{formatTag:"num2b",formatCode:'#,##0.00,,,"B"',formatCategory:"number",valueType:"number",exampleInput:1384937584},{formatTag:"id",formatCode:"0",formatCategory:"number",valueType:"number",exampleInput:"921594675",titleTagReplacement:" id"},{formatTag:"fract",formatCode:"# ?/?",formatCategory:"number",valueType:"number",exampleInput:"0.25"},{formatTag:"mult",formatCode:'#,##0.0"x"',formatCategory:"number",valueType:"number",exampleInput:"5.32"},{formatTag:"mult0",formatCode:'#,##0"x"',formatCategory:"number",valueType:"number",exampleInput:"5.32"},{formatTag:"mult1",formatCode:'#,##0.0"x"',formatCategory:"number",valueType:"number",exampleInput:"5.32"},{formatTag:"mult2",formatCode:'#,##0.00"x"',formatCategory:"number",valueType:"number",exampleInput:"5.32"},{formatTag:"sci",formatCode:"0.00E+0",formatCategory:"number",valueType:"number",exampleInput:"16546.1561"},{formatTag:"pct",formatCode:en,formatCategory:"percent",valueType:"number",exampleInput:.731,titleTagReplacement:"",_autoFormat:{autoFormatFunction:(n,t,e)=>{if((e==null?void 0:e.unitType)==="number"){let r={min:e.min*100,max:e.max*100,median:e.median*100,maxDecimals:Math.max(e.maxDecimals-2,0),unitType:e.unitType},i=Ro(r);return Ur.format(i._autoFormat.autoFormatCode,n*100)+"%"}else return Ur.format("#,##0%",n)}}},{formatTag:"pct0",formatCode:"#,##0%",formatCategory:"percent",valueType:"number",exampleInput:.731,titleTagReplacement:""},{formatTag:"pct1",formatCode:"#,##0.0%",formatCategory:"percent",valueType:"number",exampleInput:.731,titleTagReplacement:""},{formatTag:"pct2",formatCode:"#,##0.00%",formatCategory:"percent",valueType:"number",exampleInput:.731,titleTagReplacement:""},{formatTag:"pct3",formatCode:"#,##0.000%",formatCategory:"percent",valueType:"number",exampleInput:.731,titleTagReplacement:""}];function wp(n){return n==null?[]:Array.isArray(n)?n:[n]}class Sp extends Map{constructor(t,e=Ep){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),t!=null)for(const[r,i]of t)this.set(r,i)}get(t){return super.get(Na(this,t))}has(t){return super.has(Na(this,t))}set(t,e){return super.set(Ip(this,t),e)}delete(t){return super.delete(vp(this,t))}}function Na({_intern:n,_key:t},e){const r=t(e);return n.has(r)?n.get(r):e}function Ip({_intern:n,_key:t},e){const r=t(e);return n.has(r)?n.get(r):(n.set(r,e),e)}function vp({_intern:n,_key:t},e){const r=t(e);return n.has(r)&&(e=n.get(e),n.delete(r)),e}function Ep(n){return n!==null&&typeof n=="object"?n.valueOf():n}function Ra(n){return n}function Tp(n,...t){return Ap(n,Ra,Ra,t)}function Ap(n,t,e,r){return(function i(s,o){if(o>=r.length)return e(s);const a=new Sp,c=r[o++];let u=-1;for(const d of s){const w=c(d,++u,s),F=a.get(w);F?F.push(d):a.set(w,[d])}for(const[d,w]of a)a.set(d,i(w,o));return t(a)})(n,0)}function Ki(n,t){if(n==null||typeof n!="object"||Array.isArray(n))return n;const e=Object.fromEntries(t.filter(r=>typeof r[0]!="function"&&r[0]!=null));return Object.assign(e,n)}function ds(n,t,e,r,i,s=0){for(const[o,a]of n.entries()){const c=[...e,o];if(a instanceof Map){const u=r(t,c,s);ds(a,u,c,r,i,s+1)}else i(t,c,a,s)}return t}function Op(n,t,e=r=>r[r.length-1]){function r(o,a){const c=new Map;return o.set(e(a),c),c}function i(o,a,c){o.set(e(a),t(c,a))}const s=new Map;return ds(n,s,[],r,i),s}const Ji=n=>n;function Fp(n){const t=typeof n;return n!=null&&(t==="object"||t==="function")}function un(n,t,e){return typeof t=="function"?t=[t]:arguments.length===2&&t!=null&&!Array.isArray(t)&&(e=t),i=>{const s=Rp(i,n),o=Np(s,t,e==null?void 0:e.addGroupKeys);if(e!=null&&e.export)switch(e.export){case"grouped":return o;case"levels":return Bs(o,e);case"entries-obj":case"entriesObject":return Bs(o,{...e,levels:["entries-object"]});default:return Bs(o,{...e,levels:[e.export]})}return Dp(o,e==null?void 0:e.addGroupKeys)}}un.grouped=n=>({...n,export:"grouped"});un.entries=n=>({...n,export:"entries"});un.entriesObject=n=>({...n,export:"entries-object"});un.object=n=>({...n,export:"object"});un.map=n=>({...n,export:"map"});un.keys=n=>({...n,export:"keys"});un.values=n=>({...n,export:"values"});un.levels=n=>({...n,export:"levels"});function Np(n,t,e){let r=n;if(!(t!=null&&t.length))return r;for(const i of t)i&&(r=Op(r,(s,o)=>{let c=i(s,{groupKeys:o});return e!==!1&&(c=c.map(u=>Ki(u,o))),c}));return r}function Rp(n,t){const e=wp(t).map((i,s)=>{const o=typeof i=="function"?i:c=>c[i],a=new Map;return c=>{const u=o(c),d=Fp(u)?u.valueOf():u;if(a.has(d))return a.get(d);const w=[i,u];return a.set(d,w),w}});return Tp(n,...e)}function Dp(n,t){const e=[];return ds(n,e,[],Ji,(r,i,s)=>{let o=s;t!==!1&&(o=s.map(a=>Ki(a,i))),r.push(...o)}),e}const Bp=n=>n.join("/");function Mp(n){var t;const{flat:e,single:r,mapLeaf:i=Ji,mapLeaves:s=Ji,addGroupKeys:o}=n;let a;return n.flat&&(a=(t=n.compositeKey)!=null?t:Bp),{groupFn:(d,w)=>r?i(o===!1?d[0]:Ki(d[0],w)):s(d.map(F=>i(o===!1?F:Ki(F,w)))),keyFn:e?d=>a(d.map(w=>w[1])):d=>d[d.length-1][1]}}function Bs(n,t){const{groupFn:e,keyFn:r}=Mp(t);let{mapEntry:i=Ji}=t;const{levels:s=["entries"]}=t,o=[];for(const d of s)switch(d){case"entries":case"entries-object":case"entries-obj":case"entriesObject":{const w=(d==="entries-object"||d==="entries-obj"||d==="entriesObject")&&t.mapEntry==null?([F,v])=>({key:F,values:v}):i;o.push({id:"entries",createEmptySubgroup:()=>[],addSubgroup:(F,v,N,dt)=>{F.push(w([N,v],dt))},addLeaf:(F,v,N,dt)=>{F.push(w([v,N],dt))}});break}case"map":o.push({id:"map",createEmptySubgroup:()=>new Map,addSubgroup:(w,F,v)=>{w.set(v,F)},addLeaf:(w,F,v)=>{w.set(F,v)}});break;case"object":o.push({id:"object",createEmptySubgroup:()=>({}),addSubgroup:(w,F,v)=>{w[v]=F},addLeaf:(w,F,v)=>{w[F]=v}});break;case"keys":o.push({id:"keys",createEmptySubgroup:()=>[],addSubgroup:(w,F,v)=>{w.push([v,F])},addLeaf:(w,F)=>{w.push(F)}});break;case"values":o.push({id:"values",createEmptySubgroup:()=>[],addSubgroup:(w,F)=>{w.push(F)},addLeaf:(w,F,v)=>{w.push(v)}});break;default:typeof d=="object"&&o.push(d)}const a=(d,w,F)=>{var v,N;if(t.flat)return d;const dt=(v=o[F])!=null?v:o[o.length-1],B=((N=o[F+1])!=null?N:dt).createEmptySubgroup();return dt.addSubgroup(d,B,r(w),F),B},c=(d,w,F,v)=>{var N;((N=o[v])!=null?N:o[o.length-1]).addLeaf(d,r(w),e(F,w),v)},u=o[0].createEmptySubgroup();return ds(n,u,[],a,c)}var _n;(function(n){n.BOOLEAN="boolean",n.NUMBER="number",n.STRING="string",n.DATE="date"})(_n||(_n={}));var Zi;(function(n){n.INFERRED="inferred",n.PRECISE="precise"})(Zi||(Zi={}));const Lp=function(n){return typeof n=="number"?_n.NUMBER:typeof n=="boolean"?_n.BOOLEAN:n instanceof Date?_n.DATE:_n.STRING};function uy(n){if(n!=null&&n._evidenceColumnTypes)return n._evidenceColumnTypes;if(n&&n.length>0){let t=Object.keys(n[0]);return t==null?void 0:t.map(r=>{let i=n.find(s=>s[r]!=null);if(i){let s=Lp(i[r]);return{name:r,evidenceType:s,typeFidelity:Zi.INFERRED}}else return{name:r,evidenceType:_n.STRING,typeFidelity:Zi.INFERRED}})}return[]}export{jp as A,cy as B,ry as C,Wp as D,np as E,Zp as F,Ir as G,qu as H,Yp as I,wp as J,Lp as K,sy as L,iy as M,oy as N,ay as O,uy as P,zu as Q,_n as R,gp as S,Zi as T,Xp as a,hp as b,rp as c,ty as d,Kp as e,un as f,Jp as g,ny as h,Gp as i,tn as j,Lt as k,Df as l,Fo as m,Bf as n,gi as o,zp as p,fe as q,qp as r,ey as s,Ns as t,Ur as u,Vp as v,xd as w,kd as x,Nf as y,Oo as z};