diff --git "a/assets/Scenes-CrlwmqUB.js" "b/assets/Scenes-CrlwmqUB.js" new file mode 100644--- /dev/null +++ "b/assets/Scenes-CrlwmqUB.js" @@ -0,0 +1,10 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-BQofMJ7W.js","assets/index-DncLnVUZ.js","assets/index-BxFO96Af.css","assets/default-node-CHzFd3wA.js","assets/import-url-browser-agSP1LkN.js","assets/import-url-browser-CQxpIBxI.js","assets/duckdb-mvp-DkPAVKN8.js","assets/import-url-node-D5qRa4nQ.js"])))=>i.map(i=>d[i]); +import{L as e,M as t,P as n,Q as r,R as i,S as a,T as o,U as s,V as c,a4 as l,a6 as u,a7 as d,aC as ee,aE as te,aF as ne,aI as re,bO as ie,bP as ae,bQ as oe,bZ as se,c as ce,cc as le,eA as ue,eB as de,eC as fe,eD as pe,eH as me,eM as he,eP as ge,eQ as _e,eR as ve,eX as ye,eZ as be,f2 as xe,f4 as Se,f7 as Ce,fe as we,fh as Te}from"./index-DncLnVUZ.js";import{b as Ee}from"./dist-CKxIRgld.js";import{b as De,d as Oe,f as ke}from"./src-DUOeGTAR.js";import{b as Ae}from"./import-url-browser-CQxpIBxI.js";import{b as je}from"./llmmarkerParser-LVQFIzY_.js";import{c as Me,d as Ne}from"./index-CAcLDIRJ-C2VJt_ik.js";import{$ as Pe,A as Fe,B as Ie,C as Le,D as Re,E as ze,F as Be,G as Ve,H as He,I as Ue,J as We,K as Ge,L as Ke,M as qe,N as Je,O as Ye,P as Xe,Q as Ze,R as Qe,S as $e,T as et,U as tt,V as nt,W as rt,X as it,Y as at,Z as ot,_ as st,a1 as ct,a2 as lt,a3 as ut,a4 as dt,a6 as ft,a8 as pt,a9 as mt,aA as ht,aB as gt,aC as _t,aE as vt,aF as yt,aG as bt,aH as xt,aI as St,aJ as Ct,aK as wt,aL as Tt,aM as Et,aN as Dt,aO as Ot,aP as kt,aQ as At,aR as jt,aS as Mt,aa as Nt,ab as Pt,ac as Ft,ad as It,ae as Lt,af as Rt,ag as zt,ah as Bt,ai as Vt,aj as Ht,ak as Ut,al as Wt,am as Gt,an as Kt,ao as qt,ap as Jt,aq as Yt,ar as Xt,as as Zt,at as Qt,au as $t,av as en,aw as tn,ax as nn,ay as rn,az as an,bA as on,bB as sn,bC as cn,bD as ln,bE as un,bF as dn,bG as fn,bH as pn,bI as mn,bK as hn,bL as f,bc as gn,bd as _n,be as vn,bf as yn,bg as bn,bh as xn,bi as Sn,bj as Cn,bk as wn,bl as Tn,bm as En,bn as Dn,bq as On,bs as kn,bt as An,bu as jn,bv as Mn,bw as Nn,bx as Pn,by as Fn,bz as In,d as Ln,e as Rn,f as zn,g as Bn,i as Vn,j as Hn,k as Un,l as Wn,m as Gn,n as Kn,o as qn,p as Jn,q as Yn,r as Xn,s as Zn,t as Qn,u as $n,v as er,w as tr,x as nr,y as rr,z as ir}from"./core-CG5R5vKY.js";import{b as ar}from"./airi-card-BqEhfuaQ.js";async function*or(e){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}}function p(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function sr(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function m(e){return this instanceof m?(this.v=e,this):new m(e)}function cr(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){ee(a[0][3],e)}}function l(e){e.value instanceof m?Promise.resolve(e.value.v).then(u,d):ee(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function ee(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function lr(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:m(e[r](t)),done:!1}:i?i(t):t}:i}}function ur(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof sr==`function`?sr(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}const dr=new TextDecoder(`utf-8`),fr=e=>dr.decode(e),pr=new TextEncoder,mr=e=>pr.encode(e),hr=e=>typeof e==`number`,gr=e=>typeof e==`boolean`,_r=e=>typeof e==`function`,vr=e=>e!=null&&Object(e)===e,yr=e=>vr(e)&&_r(e.then),br=e=>vr(e)&&_r(e[Symbol.iterator]),xr=e=>vr(e)&&_r(e[Symbol.asyncIterator]),Sr=e=>vr(e)&&vr(e.schema),Cr=e=>vr(e)&&`done`in e&&`value`in e,wr=e=>vr(e)&&_r(e.stat)&&hr(e.fd),Tr=e=>vr(e)&&Or(e.body),Er=e=>`_getDOMStream`in e&&`_getNodeStream`in e,Dr=e=>vr(e)&&_r(e.abort)&&_r(e.getWriter)&&!Er(e),Or=e=>vr(e)&&_r(e.cancel)&&_r(e.getReader)&&!Er(e),kr=e=>vr(e)&&_r(e.end)&&_r(e.write)&&gr(e.writable)&&!Er(e),Ar=e=>vr(e)&&_r(e.read)&&_r(e.pipe)&&gr(e.readable)&&!Er(e),jr=e=>vr(e)&&_r(e.clear)&&_r(e.bytes)&&_r(e.position)&&_r(e.setPosition)&&_r(e.capacity)&&_r(e.getBufferIdentifier)&&_r(e.createLong),Mr=typeof SharedArrayBuffer<`u`?SharedArrayBuffer:ArrayBuffer;function Nr(e){let t=e[0]?[e[0]]:[],n,r,i,a;for(let o,s,c=0,l=0,u=e.length;++ce+t.byteLength,0),i,a,o,s=0,c=-1,l=Math.min(t||1/0,r);for(let e=n.length;++ch(Int32Array,e),Lr=e=>h(BigInt64Array,e),g=e=>h(Uint8Array,e),Rr=e=>(e.next(),e);function*zr(e,t){let n=function*(e){yield e},r=typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Mr?n(t):br(t)?t:n(t);return yield*Rr((function*(t){let n=null;do n=t.next(yield h(e,n));while(!n.done)})(r[Symbol.iterator]())),new e}const Br=e=>zr(Uint8Array,e);function Vr(e,t){return cr(this,arguments,function*(){if(yr(t))return yield m(yield m(yield*lr(ur(Vr(e,yield m(t))))));let n=function(e){return cr(this,arguments,function*(){yield yield m(yield m(e))})},r=function(e){return cr(this,arguments,function*(){yield m(yield*lr(ur(Rr((function*(e){let t=null;do t=e.next(yield t?.value);while(!t.done)})(e[Symbol.iterator]())))))})},i=typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Mr?n(t):br(t)?r(t):xr(t)?t:n(t);return yield m(yield*lr(ur(Rr((function(t){return cr(this,arguments,function*(){let n=null;do n=yield m(t.next(yield yield m(h(e,n))));while(!n.done)})})(i[Symbol.asyncIterator]()))))),yield m(new e)})}const Hr=e=>Vr(Uint8Array,e);function Ur(e,t,n){if(e!==0){n=n.slice(0,t);for(let t=-1,r=n.length;++t0)do if(e[n]!==t[n])return!1;while(++n(e.next(),e);function*qr(e){let t,n=!1,r=[],i,a,o,s=0;function c(){return a===`peek`?Fr(r,o)[0]:([i,r,s]=Fr(r,o),i)}({cmd:a,size:o}=(yield(()=>null)())||{cmd:`read`,size:0});let l=Br(e)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(o-s)?l.next():l.next(o-s),!t&&i.byteLength>0&&(r.push(i),s+=i.byteLength),t||o<=s)do({cmd:a,size:o}=yield c());while(onull)()))||{cmd:`read`,size:0});let l=Hr(e)[Symbol.asyncIterator]();try{do if({done:t,value:i}=Number.isNaN(o-s)?yield m(l.next()):yield m(l.next(o-s)),!t&&i.byteLength>0&&(r.push(i),s+=i.byteLength),t||o<=s)do({cmd:a,size:o}=yield yield m(c()));while(onull)()))||{cmd:`read`,size:0});let l=new Xr(e);try{do if({done:t,value:i}=Number.isNaN(o-s)?yield m(l.read()):yield m(l.read(o-s)),!t&&i.byteLength>0&&(r.push(g(i)),s+=i.byteLength),t||o<=s)do({cmd:a,size:o}=yield yield m(c()));while(o{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return p(this,void 0,void 0,function*(){let{reader:t,source:n}=this;t&&(yield t.cancel(e).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(e){return p(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array};let t=yield this.reader.read();return!t.done&&(t.value=g(t)),t})}};const Zr=(e,t)=>{let n=e=>r([t,e]),r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function Qr(e){return cr(this,arguments,function*(){let t=[],n=`error`,r=!1,i=null,a,o,s=0,c=[],l;function u(){return a===`peek`?Fr(c,o)[0]:([l,c,s]=Fr(c,o),l)}if({cmd:a,size:o}=(yield yield m((()=>null)()))||{cmd:`read`,size:0},e.isTTY)return yield yield m(new Uint8Array),yield m(null);try{t[0]=Zr(e,`end`),t[1]=Zr(e,`error`);do{if(t[2]=Zr(e,`readable`),[n,i]=yield m(Promise.race(t.map(e=>e[2]))),n===`error`)break;if((r=n===`end`)||(Number.isFinite(o-s)?(l=g(e.read(o-s)),l.byteLength0&&(c.push(l),s+=l.byteLength)),r||o<=s)do({cmd:a,size:o}=yield yield m(u()));while(o{for(let[n,r]of t)e.off(n,r);try{let t=e.destroy;t&&t.call(e,n),n=void 0}catch(e){n=e||n}finally{n==null?r():i(n)}})}})}var $r;(function(e){e[e.V1=0]=`V1`,e[e.V2=1]=`V2`,e[e.V3=2]=`V3`,e[e.V4=3]=`V4`,e[e.V5=4]=`V5`})($r||={});var ei;(function(e){e[e.Sparse=0]=`Sparse`,e[e.Dense=1]=`Dense`})(ei||={});var ti;(function(e){e[e.HALF=0]=`HALF`,e[e.SINGLE=1]=`SINGLE`,e[e.DOUBLE=2]=`DOUBLE`})(ti||={});var ni;(function(e){e[e.DAY=0]=`DAY`,e[e.MILLISECOND=1]=`MILLISECOND`})(ni||={});var _;(function(e){e[e.SECOND=0]=`SECOND`,e[e.MILLISECOND=1]=`MILLISECOND`,e[e.MICROSECOND=2]=`MICROSECOND`,e[e.NANOSECOND=3]=`NANOSECOND`})(_||={});var ri;(function(e){e[e.YEAR_MONTH=0]=`YEAR_MONTH`,e[e.DAY_TIME=1]=`DAY_TIME`,e[e.MONTH_DAY_NANO=2]=`MONTH_DAY_NANO`})(ri||={});const ii=new Int32Array(2),ai=new Float32Array(ii.buffer),oi=new Float64Array(ii.buffer),si=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var ci;(function(e){e[e.UTF8_BYTES=1]=`UTF8_BYTES`,e[e.UTF16_STRING=2]=`UTF16_STRING`})(ci||={});var li=class e{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new e(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){ai[0]=t,this.writeInt32(e,ii[0])}writeFloat64(e,t){oi[0]=t,this.writeInt32(e,ii[si?0:1]),this.writeInt32(e+4,ii[si?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=t);let r=~(this.bb.capacity()-this.space+n)+1&t-1;for(;this.space=0&&this.vtable[t]==0;t--);let n=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]==0?0:e-this.vtable[t]);this.addInt16(e-this.object_start);let r=(n+2)*2;this.addInt16(r);let i=0,a=this.space;outer_loop:for(t=0;t=0;t--)this.writeInt8(e.charCodeAt(t))}this.prep(this.minalign,4+r),this.addOffset(e),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){let n=this.bb.capacity()-e,r=n-this.bb.readInt32(n),i=t=0;n--)e.addInt32(t[n]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){let t=e.endObject();return t}static createUnion(t,n,r){return e.startUnion(t),e.addMode(t,n),e.addTypeIds(t,r),e.endUnion(t)}},Vi=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(e){e.startObject(0)}static endUtf8(e){let t=e.endObject();return t}static createUtf8(t){return e.startUtf8(t),e.endUtf8(t)}},Hi;(function(e){e[e.NONE=0]=`NONE`,e[e.Null=1]=`Null`,e[e.Int=2]=`Int`,e[e.FloatingPoint=3]=`FloatingPoint`,e[e.Binary=4]=`Binary`,e[e.Utf8=5]=`Utf8`,e[e.Bool=6]=`Bool`,e[e.Decimal=7]=`Decimal`,e[e.Date=8]=`Date`,e[e.Time=9]=`Time`,e[e.Timestamp=10]=`Timestamp`,e[e.Interval=11]=`Interval`,e[e.List=12]=`List`,e[e.Struct_=13]=`Struct_`,e[e.Union=14]=`Union`,e[e.FixedSizeBinary=15]=`FixedSizeBinary`,e[e.FixedSizeList=16]=`FixedSizeList`,e[e.Map=17]=`Map`,e[e.Duration=18]=`Duration`,e[e.LargeBinary=19]=`LargeBinary`,e[e.LargeUtf8=20]=`LargeUtf8`,e[e.LargeList=21]=`LargeList`,e[e.RunEndEncoded=22]=`RunEndEncoded`})(Hi||={});var Ui=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}name(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){let e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):Hi.NONE}type(e){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){let t=this.bb.__offset(this.bb_pos,12);return t?(e||new xi).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(t,n){let r=this.bb.__offset(this.bb_pos,14);return r?(n||new e).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}childrenLength(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,16);return n?(t||new Si).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,Hi.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){let t=e.endObject();return t}},Wi=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}endianness(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):vi.Little}fields(e,t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new Ui).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}fieldsLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,8);return n?(t||new Si).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,vi.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let n=t.length-1;n>=0;n--)e.addInt64(t[n]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){let t=e.endObject();return t}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(t,n,r,i,a){return e.startSchema(t),e.addEndianness(t,n),e.addFields(t,r),e.addCustomMetadata(t,i),e.addFeatures(t,a),e.endSchema(t)}},v;(function(e){e[e.NONE=0]=`NONE`,e[e.Schema=1]=`Schema`,e[e.DictionaryBatch=2]=`DictionaryBatch`,e[e.RecordBatch=3]=`RecordBatch`,e[e.Tensor=4]=`Tensor`,e[e.SparseTensor=5]=`SparseTensor`})(v||={});var y;(function(e){e[e.NONE=0]=`NONE`,e[e.Null=1]=`Null`,e[e.Int=2]=`Int`,e[e.Float=3]=`Float`,e[e.Binary=4]=`Binary`,e[e.Utf8=5]=`Utf8`,e[e.Bool=6]=`Bool`,e[e.Decimal=7]=`Decimal`,e[e.Date=8]=`Date`,e[e.Time=9]=`Time`,e[e.Timestamp=10]=`Timestamp`,e[e.Interval=11]=`Interval`,e[e.List=12]=`List`,e[e.Struct=13]=`Struct`,e[e.Union=14]=`Union`,e[e.FixedSizeBinary=15]=`FixedSizeBinary`,e[e.FixedSizeList=16]=`FixedSizeList`,e[e.Map=17]=`Map`,e[e.Duration=18]=`Duration`,e[e.LargeBinary=19]=`LargeBinary`,e[e.LargeUtf8=20]=`LargeUtf8`,e[e.Dictionary=-1]=`Dictionary`,e[e.Int8=-2]=`Int8`,e[e.Int16=-3]=`Int16`,e[e.Int32=-4]=`Int32`,e[e.Int64=-5]=`Int64`,e[e.Uint8=-6]=`Uint8`,e[e.Uint16=-7]=`Uint16`,e[e.Uint32=-8]=`Uint32`,e[e.Uint64=-9]=`Uint64`,e[e.Float16=-10]=`Float16`,e[e.Float32=-11]=`Float32`,e[e.Float64=-12]=`Float64`,e[e.DateDay=-13]=`DateDay`,e[e.DateMillisecond=-14]=`DateMillisecond`,e[e.TimestampSecond=-15]=`TimestampSecond`,e[e.TimestampMillisecond=-16]=`TimestampMillisecond`,e[e.TimestampMicrosecond=-17]=`TimestampMicrosecond`,e[e.TimestampNanosecond=-18]=`TimestampNanosecond`,e[e.TimeSecond=-19]=`TimeSecond`,e[e.TimeMillisecond=-20]=`TimeMillisecond`,e[e.TimeMicrosecond=-21]=`TimeMicrosecond`,e[e.TimeNanosecond=-22]=`TimeNanosecond`,e[e.DenseUnion=-23]=`DenseUnion`,e[e.SparseUnion=-24]=`SparseUnion`,e[e.IntervalDayTime=-25]=`IntervalDayTime`,e[e.IntervalYearMonth=-26]=`IntervalYearMonth`,e[e.DurationSecond=-27]=`DurationSecond`,e[e.DurationMillisecond=-28]=`DurationMillisecond`,e[e.DurationMicrosecond=-29]=`DurationMicrosecond`,e[e.DurationNanosecond=-30]=`DurationNanosecond`})(y||={});var Gi;(function(e){e[e.OFFSET=0]=`OFFSET`,e[e.DATA=1]=`DATA`,e[e.VALIDITY=2]=`VALIDITY`,e[e.TYPE=3]=`TYPE`})(Gi||={});function Ki(e){if(e===null)return`null`;if(e===void 0)return`undefined`;switch(typeof e){case`number`:return`${e}`;case`bigint`:return`${e}`;case`string`:return`"${e}"`}return typeof e[Symbol.toPrimitive]==`function`?e[Symbol.toPrimitive](`string`):ArrayBuffer.isView(e)?e instanceof BigInt64Array||e instanceof BigUint64Array?`[${[...e].map(e=>Ki(e))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(e,t)=>typeof t==`bigint`?`${t}`:t)}function b(e){if(typeof e==`bigint`&&(e<-(2**53-1)||e>2**53-1))throw TypeError(`${e} is not safe to convert to a number.`);return Number(e)}function qi(e,t){return b(e/t)+b(e%t)/b(t)}const Ji=Symbol.for(`isArrowBigNum`);function Yi(e,...t){return t.length===0?Object.setPrototypeOf(h(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}Yi.prototype[Ji]=!0,Yi.prototype.toJSON=function(){return`"${na(this)}"`},Yi.prototype.valueOf=function(e){return ta(this,e)},Yi.prototype.toString=function(){return na(this)},Yi.prototype[Symbol.toPrimitive]=function(e=`default`){switch(e){case`number`:return ta(this);case`string`:return na(this);case`default`:return ra(this)}return na(this)};function Xi(...e){return Yi.apply(this,e)}function Zi(...e){return Yi.apply(this,e)}function Qi(...e){return Yi.apply(this,e)}Object.setPrototypeOf(Xi.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(Zi.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(Qi.prototype,Object.create(Uint32Array.prototype)),Object.assign(Xi.prototype,Yi.prototype,{constructor:Xi,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(Zi.prototype,Yi.prototype,{constructor:Zi,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(Qi.prototype,Yi.prototype,{constructor:Qi,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const $i=BigInt(4294967296)*BigInt(4294967296),ea=$i-BigInt(1);function ta(e,t){let{buffer:n,byteOffset:r,byteLength:i,signed:a}=e,o=new BigUint64Array(n,r,i/8),s=a&&o.at(-1)&BigInt(1)<=0)return ia(e);t=t.slice();let r=1;for(let e=0;e(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]=`DataType`))(x.prototype);var Oa=class extends x{constructor(){super(y.Null)}toString(){return`Null`}};sa=Symbol.toStringTag,Oa[sa]=(e=>e[Symbol.toStringTag]=`Null`)(Oa.prototype);var ka=class extends x{constructor(e,t){super(y.Int),this.isSigned=e,this.bitWidth=t}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 Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?`I`:`Ui`}nt${this.bitWidth}`}};ca=Symbol.toStringTag,ka[ca]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]=`Int`))(ka.prototype);var Aa=class extends ka{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},ja=class extends ka{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},Ma=class extends ka{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Na=class extends ka{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},Pa=class extends ka{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},Fa=class extends ka{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},Ia=class extends ka{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},La=class extends ka{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(Aa.prototype,`ArrayType`,{value:Int8Array}),Object.defineProperty(ja.prototype,`ArrayType`,{value:Int16Array}),Object.defineProperty(Ma.prototype,`ArrayType`,{value:Int32Array}),Object.defineProperty(Na.prototype,`ArrayType`,{value:BigInt64Array}),Object.defineProperty(Pa.prototype,`ArrayType`,{value:Uint8Array}),Object.defineProperty(Fa.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(Ia.prototype,`ArrayType`,{value:Uint32Array}),Object.defineProperty(La.prototype,`ArrayType`,{value:BigUint64Array});var Ra=class extends x{constructor(e){super(y.Float),this.precision=e}get ArrayType(){switch(this.precision){case ti.HALF:return Uint16Array;case ti.SINGLE:return Float32Array;case ti.DOUBLE:return Float64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};la=Symbol.toStringTag,Ra[la]=(e=>(e.precision=null,e[Symbol.toStringTag]=`Float`))(Ra.prototype);var za=class extends Ra{constructor(){super(ti.HALF)}},Ba=class extends Ra{constructor(){super(ti.SINGLE)}},Va=class extends Ra{constructor(){super(ti.DOUBLE)}};Object.defineProperty(za.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(Ba.prototype,`ArrayType`,{value:Float32Array}),Object.defineProperty(Va.prototype,`ArrayType`,{value:Float64Array});var Ha=class extends x{constructor(){super(y.Binary)}toString(){return`Binary`}};ua=Symbol.toStringTag,Ha[ua]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Binary`))(Ha.prototype);var Ua=class extends x{constructor(){super(y.LargeBinary)}toString(){return`LargeBinary`}};da=Symbol.toStringTag,Ua[da]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeBinary`))(Ua.prototype);var Wa=class extends x{constructor(){super(y.Utf8)}toString(){return`Utf8`}};fa=Symbol.toStringTag,Wa[fa]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Utf8`))(Wa.prototype);var Ga=class extends x{constructor(){super(y.LargeUtf8)}toString(){return`LargeUtf8`}};pa=Symbol.toStringTag,Ga[pa]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeUtf8`))(Ga.prototype);var Ka=class extends x{constructor(){super(y.Bool)}toString(){return`Bool`}};ma=Symbol.toStringTag,Ka[ma]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Bool`))(Ka.prototype);var qa=class extends x{constructor(e,t,n=128){super(y.Decimal),this.scale=e,this.precision=t,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?`+`:``}${this.scale}]`}};ha=Symbol.toStringTag,qa[ha]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]=`Decimal`))(qa.prototype);var Ja=class extends x{constructor(e){super(y.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${ni[this.unit]}>`}get ArrayType(){return this.unit===ni.DAY?Int32Array:BigInt64Array}};ga=Symbol.toStringTag,Ja[ga]=(e=>(e.unit=null,e[Symbol.toStringTag]=`Date`))(Ja.prototype);var Ya=class extends x{constructor(e,t){super(y.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${_[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};_a=Symbol.toStringTag,Ya[_a]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]=`Time`))(Ya.prototype);var Xa=class extends x{constructor(e,t){super(y.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${_[this.unit]}${this.timezone?`, ${this.timezone}`:``}>`}};va=Symbol.toStringTag,Xa[va]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Timestamp`))(Xa.prototype);var Za=class extends x{constructor(e){super(y.Interval),this.unit=e}toString(){return`Interval<${ri[this.unit]}>`}};ya=Symbol.toStringTag,Za[ya]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]=`Interval`))(Za.prototype);var Qa=class extends x{constructor(e){super(y.Duration),this.unit=e}toString(){return`Duration<${_[this.unit]}>`}};ba=Symbol.toStringTag,Qa[ba]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Duration`))(Qa.prototype);var $a=class extends x{constructor(e){super(y.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};xa=Symbol.toStringTag,$a[xa]=(e=>(e.children=null,e[Symbol.toStringTag]=`List`))($a.prototype);var eo=class extends x{constructor(e){super(y.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};Sa=Symbol.toStringTag,eo[Sa]=(e=>(e.children=null,e[Symbol.toStringTag]=`Struct`))(eo.prototype);var to=class extends x{constructor(e,t,n){super(y.Union),this.mode=e,this.children=n,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((e,t,n)=>(e[t]=n)&&e||e,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(` | `)}>`}};Ca=Symbol.toStringTag,to[Ca]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]=`Union`))(to.prototype);var no=class extends x{constructor(e){super(y.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};wa=Symbol.toStringTag,no[wa]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`FixedSizeBinary`))(no.prototype);var ro=class extends x{constructor(e,t){super(y.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};Ta=Symbol.toStringTag,ro[Ta]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]=`FixedSizeList`))(ro.prototype);var io=class extends x{constructor(e,t=!1){var n,r,i;if(super(y.Map),this.children=[e],this.keysSorted=t,e&&(e.name=`entries`,(n=e?.type)?.children)){let t=(r=e?.type)?.children[0];t&&(t.name=`key`);let n=(i=e?.type)?.children[1];n&&(n.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(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};Ea=Symbol.toStringTag,io[Ea]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]=`Map_`))(io.prototype);const ao=(e=>()=>++e)(-1);var oo=class extends x{constructor(e,t,n,r){super(y.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=r||!1,this.id=n==null?ao():b(n)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};Da=Symbol.toStringTag,oo[Da]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]=`Dictionary`))(oo.prototype);function so(e){let t=e;switch(e.typeId){case y.Decimal:return e.bitWidth/32;case y.Interval:return 1+t.unit;case y.FixedSizeList:return t.listSize;case y.FixedSizeBinary:return t.byteWidth;default:return 1}}var S=class{visitMany(e,...t){return e.map((e,n)=>this.visit(e,...t.map(e=>e[n])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return co(this,e,t)}getVisitFnByTypeId(e,t=!0){return lo(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}};function co(e,t,n=!0){return typeof t==`number`?lo(e,t,n):typeof t==`string`&&t in y?lo(e,y[t],n):t&&t instanceof x?lo(e,uo(t),n):t?.type&&t.type instanceof x?lo(e,uo(t.type),n):lo(e,y.NONE,n)}function lo(e,t,n=!0){let r=null;switch(t){case y.Null:r=e.visitNull;break;case y.Bool:r=e.visitBool;break;case y.Int:r=e.visitInt;break;case y.Int8:r=e.visitInt8||e.visitInt;break;case y.Int16:r=e.visitInt16||e.visitInt;break;case y.Int32:r=e.visitInt32||e.visitInt;break;case y.Int64:r=e.visitInt64||e.visitInt;break;case y.Uint8:r=e.visitUint8||e.visitInt;break;case y.Uint16:r=e.visitUint16||e.visitInt;break;case y.Uint32:r=e.visitUint32||e.visitInt;break;case y.Uint64:r=e.visitUint64||e.visitInt;break;case y.Float:r=e.visitFloat;break;case y.Float16:r=e.visitFloat16||e.visitFloat;break;case y.Float32:r=e.visitFloat32||e.visitFloat;break;case y.Float64:r=e.visitFloat64||e.visitFloat;break;case y.Utf8:r=e.visitUtf8;break;case y.LargeUtf8:r=e.visitLargeUtf8;break;case y.Binary:r=e.visitBinary;break;case y.LargeBinary:r=e.visitLargeBinary;break;case y.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case y.Date:r=e.visitDate;break;case y.DateDay:r=e.visitDateDay||e.visitDate;break;case y.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case y.Timestamp:r=e.visitTimestamp;break;case y.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case y.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case y.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case y.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case y.Time:r=e.visitTime;break;case y.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case y.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case y.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case y.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case y.Decimal:r=e.visitDecimal;break;case y.List:r=e.visitList;break;case y.Struct:r=e.visitStruct;break;case y.Union:r=e.visitUnion;break;case y.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case y.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case y.Dictionary:r=e.visitDictionary;break;case y.Interval:r=e.visitInterval;break;case y.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case y.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case y.Duration:r=e.visitDuration;break;case y.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case y.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case y.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case y.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case y.FixedSizeList:r=e.visitFixedSizeList;break;case y.Map:r=e.visitMap;break}if(typeof r==`function`)return r;if(!n)return()=>null;throw Error(`Unrecognized type '${y[t]}'`)}function uo(e){switch(e.typeId){case y.Null:return y.Null;case y.Int:{let{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?y.Int8:y.Uint8;case 16:return n?y.Int16:y.Uint16;case 32:return n?y.Int32:y.Uint32;case 64:return n?y.Int64:y.Uint64}return y.Int}case y.Float:switch(e.precision){case ti.HALF:return y.Float16;case ti.SINGLE:return y.Float32;case ti.DOUBLE:return y.Float64}return y.Float;case y.Binary:return y.Binary;case y.LargeBinary:return y.LargeBinary;case y.Utf8:return y.Utf8;case y.LargeUtf8:return y.LargeUtf8;case y.Bool:return y.Bool;case y.Decimal:return y.Decimal;case y.Time:switch(e.unit){case _.SECOND:return y.TimeSecond;case _.MILLISECOND:return y.TimeMillisecond;case _.MICROSECOND:return y.TimeMicrosecond;case _.NANOSECOND:return y.TimeNanosecond}return y.Time;case y.Timestamp:switch(e.unit){case _.SECOND:return y.TimestampSecond;case _.MILLISECOND:return y.TimestampMillisecond;case _.MICROSECOND:return y.TimestampMicrosecond;case _.NANOSECOND:return y.TimestampNanosecond}return y.Timestamp;case y.Date:switch(e.unit){case ni.DAY:return y.DateDay;case ni.MILLISECOND:return y.DateMillisecond}return y.Date;case y.Interval:switch(e.unit){case ri.DAY_TIME:return y.IntervalDayTime;case ri.YEAR_MONTH:return y.IntervalYearMonth}return y.Interval;case y.Duration:switch(e.unit){case _.SECOND:return y.DurationSecond;case _.MILLISECOND:return y.DurationMillisecond;case _.MICROSECOND:return y.DurationMicrosecond;case _.NANOSECOND:return y.DurationNanosecond}return y.Duration;case y.Map:return y.Map;case y.List:return y.List;case y.Struct:return y.Struct;case y.Union:switch(e.mode){case ei.Dense:return y.DenseUnion;case ei.Sparse:return y.SparseUnion}return y.Union;case y.FixedSizeBinary:return y.FixedSizeBinary;case y.FixedSizeList:return y.FixedSizeList;case y.Dictionary:return y.Dictionary}throw Error(`Unrecognized type '${y[e.typeId]}'`)}S.prototype.visitInt8=null,S.prototype.visitInt16=null,S.prototype.visitInt32=null,S.prototype.visitInt64=null,S.prototype.visitUint8=null,S.prototype.visitUint16=null,S.prototype.visitUint32=null,S.prototype.visitUint64=null,S.prototype.visitFloat16=null,S.prototype.visitFloat32=null,S.prototype.visitFloat64=null,S.prototype.visitDateDay=null,S.prototype.visitDateMillisecond=null,S.prototype.visitTimestampSecond=null,S.prototype.visitTimestampMillisecond=null,S.prototype.visitTimestampMicrosecond=null,S.prototype.visitTimestampNanosecond=null,S.prototype.visitTimeSecond=null,S.prototype.visitTimeMillisecond=null,S.prototype.visitTimeMicrosecond=null,S.prototype.visitTimeNanosecond=null,S.prototype.visitDenseUnion=null,S.prototype.visitSparseUnion=null,S.prototype.visitIntervalDayTime=null,S.prototype.visitIntervalYearMonth=null,S.prototype.visitDuration=null,S.prototype.visitDurationSecond=null,S.prototype.visitDurationMillisecond=null,S.prototype.visitDurationMicrosecond=null,S.prototype.visitDurationNanosecond=null;const fo=new Float64Array(1),po=new Uint32Array(fo.buffer);function mo(e){let t=(e&31744)>>10,n=(e&1023)/1024,r=(-1)**((e&32768)>>15);switch(t){case 31:return r*(n?NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*2**(t-15)*(1+n)}function ho(e){if(e!==e)return 32256;fo[0]=e;let t=(po[1]&2147483648)>>16&65535,n=po[1]&2146435072,r=0;return n>=1089470464?po[0]>0?n=31744:(n=(n&2080374784)>>16,r=(po[1]&1048575)>>10):n<=1056964608?(r=1048576+(po[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(po[1]&1048575)+512>>10),t|n|r&65535}var C=class extends S{};function w(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const go=(e,t,n)=>{e[t]=Math.floor(n/864e5)},_o=(e,t,n,r)=>{if(n+1{let i=e+n;r?t[i>>3]|=1<>3]&=~(1<{e[t]=n},bo=({values:e},t,n)=>{e[t]=n},xo=({values:e},t,n)=>{e[t]=ho(n)},So=(e,t,n)=>{switch(e.type.precision){case ti.HALF:return xo(e,t,n);case ti.SINGLE:case ti.DOUBLE:return bo(e,t,n)}},Co=({values:e},t,n)=>{go(e,t,n.valueOf())},wo=({values:e},t,n)=>{e[t]=BigInt(n)},To=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},Eo=({values:e,valueOffsets:t},n,r)=>_o(e,t,n,r),Do=({values:e,valueOffsets:t},n,r)=>_o(e,t,n,mr(r)),Oo=(e,t,n)=>{e.type.unit===ni.DAY?Co(e,t,n):wo(e,t,n)},ko=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},Ao=({values:e},t,n)=>{e[t]=BigInt(n)},jo=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},Mo=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},No=(e,t,n)=>{switch(e.type.unit){case _.SECOND:return ko(e,t,n);case _.MILLISECOND:return Ao(e,t,n);case _.MICROSECOND:return jo(e,t,n);case _.NANOSECOND:return Mo(e,t,n)}},Po=({values:e},t,n)=>{e[t]=n},Fo=({values:e},t,n)=>{e[t]=n},Io=({values:e},t,n)=>{e[t]=n},Lo=({values:e},t,n)=>{e[t]=n},Ro=(e,t,n)=>{switch(e.type.unit){case _.SECOND:return Po(e,t,n);case _.MILLISECOND:return Fo(e,t,n);case _.MICROSECOND:return Io(e,t,n);case _.NANOSECOND:return Lo(e,t,n)}},zo=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},Bo=(e,t,n)=>{let r=e.children[0],i=e.valueOffsets,a=cs.getVisitFn(r);if(Array.isArray(n))for(let e=-1,o=i[t],s=i[t+1];o{let r=e.children[0],{valueOffsets:i}=e,a=cs.getVisitFn(r),{[t]:o,[t+1]:s}=i,c=n instanceof Map?n.entries():Object.entries(n);for(let e of c)if(a(r,o,e),++o>=s)break},Ho=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[a]),Uo=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(a)),Wo=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(i.name)),Go=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[i.name]),Ko=(e,t,n)=>{let r=e.type.children.map(e=>cs.getVisitFn(e.type)),i=n instanceof Map?Wo(t,n):n instanceof $c?Uo(t,n):Array.isArray(n)?Ho(t,n):Go(t,n);e.type.children.forEach((t,n)=>i(r[n],e.children[n],t,n))},qo=(e,t,n)=>{e.type.mode===ei.Dense?Jo(e,t,n):Yo(e,t,n)},Jo=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];cs.visit(i,e.valueOffsets[t],n)},Yo=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];cs.visit(i,t,n)},Xo=(e,t,n)=>{var r;(r=e.dictionary)==null||r.set(e.values[t],n)},Zo=(e,t,n)=>{e.type.unit===ri.DAY_TIME?Qo(e,t,n):$o(e,t,n)},Qo=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},$o=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},es=({values:e},t,n)=>{e[t]=n},ts=({values:e},t,n)=>{e[t]=n},ns=({values:e},t,n)=>{e[t]=n},rs=({values:e},t,n)=>{e[t]=n},os=(e,t,n)=>{switch(e.type.unit){case _.SECOND:return es(e,t,n);case _.MILLISECOND:return ts(e,t,n);case _.MICROSECOND:return ns(e,t,n);case _.NANOSECOND:return rs(e,t,n)}},ss=(e,t,n)=>{let{stride:r}=e,i=e.children[0],a=cs.getVisitFn(i);if(Array.isArray(n))for(let e=-1,o=t*r;++e`${Ki(e)}: ${Ki(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}[Symbol.iterator](){return new fs(this[ls],this[us])}},fs=class{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let e=this.childIndex;return ee.name)}has(e,t){return e[ls].type.children.findIndex(e=>e.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[ls].type.children.findIndex(e=>e.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let n=e[ls].type.children.findIndex(e=>e.name===t);if(n!==-1){let r=nc.visit(e[ls].children[n],e[us]);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[ls].type.children.findIndex(e=>e.name===t);return r===-1?Reflect.has(e,t)||typeof t==`symbol`?Reflect.set(e,t,n):!1:(cs.visit(e[ls].children[r],e[us],n),Reflect.set(e,t,n))}},T=class extends S{};function E(e){return(t,n)=>t.getValid(n)?e(t,n):null}const ms=(e,t)=>864e5*e[t],hs=(e,t)=>null,gs=(e,t,n)=>{if(n+1>=t.length)return null;let r=b(t[n]),i=b(t[n+1]);return e.subarray(r,i)},_s=({offset:e,values:t},n)=>{let r=e+n,i=t[r>>3];return(i&1<ms(e,t),ys=({values:e},t)=>b(e[t]),bs=({stride:e,values:t},n)=>t[e*n],xs=({stride:e,values:t},n)=>mo(t[e*n]),Ss=({values:e},t)=>e[t],Cs=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),ws=({values:e,valueOffsets:t},n)=>gs(e,t,n),Ts=({values:e,valueOffsets:t},n)=>{let r=gs(e,t,n);return r===null?null:fr(r)},Es=({values:e},t)=>e[t],Ds=({type:e,values:t},n)=>e.precision===ti.HALF?mo(t[n]):t[n],Os=(e,t)=>e.type.unit===ni.DAY?vs(e,t):ys(e,t),ks=({values:e},t)=>1e3*b(e[t]),As=({values:e},t)=>b(e[t]),js=({values:e},t)=>qi(e[t],BigInt(1e3)),Ms=({values:e},t)=>qi(e[t],BigInt(1e6)),Ns=(e,t)=>{switch(e.type.unit){case _.SECOND:return ks(e,t);case _.MILLISECOND:return As(e,t);case _.MICROSECOND:return js(e,t);case _.NANOSECOND:return Ms(e,t)}},Ps=({values:e},t)=>e[t],Fs=({values:e},t)=>e[t],Is=({values:e},t)=>e[t],Ls=({values:e},t)=>e[t],Rs=(e,t)=>{switch(e.type.unit){case _.SECOND:return Ps(e,t);case _.MILLISECOND:return Fs(e,t);case _.MICROSECOND:return Is(e,t);case _.NANOSECOND:return Ls(e,t)}},zs=({values:e,stride:t},n)=>aa.decimal(e.subarray(t*n,t*(n+1))),Bs=(e,t)=>{let{valueOffsets:n,stride:r,children:i}=e,{[t*r]:a,[t*r+1]:o}=n,s=i[0],c=s.slice(a,o-a);return new $c([c])},Vs=(e,t)=>{let{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:a}=n,o=r[0];return new sc(o.slice(i,a-i))},Hs=(e,t)=>new ds(e,t),Us=(e,t)=>e.type.mode===ei.Dense?Ws(e,t):Gs(e,t),Ws=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return nc.visit(r,e.valueOffsets[t])},Gs=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return nc.visit(r,t)},Ks=(e,t)=>{var n;return(n=e.dictionary)?.get(e.values[t])},qs=(e,t)=>e.type.unit===ri.DAY_TIME?Js(e,t):Ys(e,t),Js=({values:e},t)=>e.subarray(2*t,2*(t+1)),Ys=({values:e},t)=>{let n=e[t],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},Xs=({values:e},t)=>e[t],Zs=({values:e},t)=>e[t],Qs=({values:e},t)=>e[t],$s=({values:e},t)=>e[t],ec=(e,t)=>{switch(e.type.unit){case _.SECOND:return Xs(e,t);case _.MILLISECOND:return Zs(e,t);case _.MICROSECOND:return Qs(e,t);case _.NANOSECOND:return $s(e,t)}},tc=(e,t)=>{let{stride:n,children:r}=e,i=r[0],a=i.slice(t*n,n);return new $c([a])};T.prototype.visitNull=E(hs),T.prototype.visitBool=E(_s),T.prototype.visitInt=E(Es),T.prototype.visitInt8=E(bs),T.prototype.visitInt16=E(bs),T.prototype.visitInt32=E(bs),T.prototype.visitInt64=E(Ss),T.prototype.visitUint8=E(bs),T.prototype.visitUint16=E(bs),T.prototype.visitUint32=E(bs),T.prototype.visitUint64=E(Ss),T.prototype.visitFloat=E(Ds),T.prototype.visitFloat16=E(xs),T.prototype.visitFloat32=E(bs),T.prototype.visitFloat64=E(bs),T.prototype.visitUtf8=E(Ts),T.prototype.visitLargeUtf8=E(Ts),T.prototype.visitBinary=E(ws),T.prototype.visitLargeBinary=E(ws),T.prototype.visitFixedSizeBinary=E(Cs),T.prototype.visitDate=E(Os),T.prototype.visitDateDay=E(vs),T.prototype.visitDateMillisecond=E(ys),T.prototype.visitTimestamp=E(Ns),T.prototype.visitTimestampSecond=E(ks),T.prototype.visitTimestampMillisecond=E(As),T.prototype.visitTimestampMicrosecond=E(js),T.prototype.visitTimestampNanosecond=E(Ms),T.prototype.visitTime=E(Rs),T.prototype.visitTimeSecond=E(Ps),T.prototype.visitTimeMillisecond=E(Fs),T.prototype.visitTimeMicrosecond=E(Is),T.prototype.visitTimeNanosecond=E(Ls),T.prototype.visitDecimal=E(zs),T.prototype.visitList=E(Bs),T.prototype.visitStruct=E(Hs),T.prototype.visitUnion=E(Us),T.prototype.visitDenseUnion=E(Ws),T.prototype.visitSparseUnion=E(Gs),T.prototype.visitDictionary=E(Ks),T.prototype.visitInterval=E(qs),T.prototype.visitIntervalDayTime=E(Js),T.prototype.visitIntervalYearMonth=E(Ys),T.prototype.visitDuration=E(ec),T.prototype.visitDurationSecond=E(Xs),T.prototype.visitDurationMillisecond=E(Zs),T.prototype.visitDurationMicrosecond=E(Qs),T.prototype.visitDurationNanosecond=E($s),T.prototype.visitFixedSizeList=E(tc),T.prototype.visitMap=E(Vs);const nc=new T,rc=Symbol.for(`keys`),ic=Symbol.for(`vals`),ac=Symbol.for(`kKeysAsStrings`),oc=Symbol.for(`_kKeysAsStrings`);var sc=class{constructor(e){return this[rc]=new $c([e.children[0]]).memoize(),this[ic]=e.children[1],new Proxy(this,new lc)}get[ac](){return this[oc]||(this[oc]=Array.from(this[rc].toArray(),String))}[Symbol.iterator](){return new cc(this[rc],this[ic])}get size(){return this[rc].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[rc],t=this[ic],n={};for(let r=-1,i=e.length;++r`${Ki(e)}: ${Ki(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}},cc=class{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){let e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),nc.visit(this.vals,e)]})}},lc=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[ac]}has(e,t){return e[ac].includes(t)}getOwnPropertyDescriptor(e,t){let n=e[ac].indexOf(t);if(n!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let n=e[ac].indexOf(t);if(n!==-1){let r=nc.visit(Reflect.get(e,ic),n);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[ac].indexOf(t);return r===-1?Reflect.has(e,t)?Reflect.set(e,t,n):!1:(cs.visit(Reflect.get(e,ic),r,n),Reflect.set(e,t,n))}};Object.defineProperties(sc.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[rc]:{writable:!0,enumerable:!1,configurable:!1,value:null},[ic]:{writable:!0,enumerable:!1,configurable:!1,value:null},[oc]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let uc;function dc(e,t,n,r){let{length:i=0}=e,a=typeof t==`number`?t:0,o=typeof n==`number`?n:i;return a<0&&(a=(a%i+i)%i),o<0&&(o=(o%i+i)%i),oi&&(o=i),r?r(e,a,o):[a,o]}const fc=(e,t)=>e<0?t+e:e,pc=e=>e!==e;function mc(e){let t=typeof e;if(t!==`object`||e===null)return pc(e)?pc:t=>t===e;if(e instanceof Date){let t=e.valueOf();return e=>e instanceof Date?e.valueOf()===t:!1}return ArrayBuffer.isView(e)?t=>t?Wr(e,t):!1:e instanceof Map?gc(e):Array.isArray(e)?hc(e):e instanceof $c?_c(e):vc(e,!0)}function hc(e){let t=[];for(let n=-1,r=e.length;++n!1;let r=[];for(let t=-1,i=n.length;++t{if(!n||typeof n!=`object`)return!1;switch(n.constructor){case Array:return bc(e,n);case Map:return Sc(e,n,n.keys());case sc:case ds:case Object:case void 0:return Sc(e,n,t||Object.keys(n))}return n instanceof $c?xc(e,n):!1}}function bc(e,t){let n=e.length;if(t.length!==n)return!1;for(let r=-1;++r>r}function Tc(e,t,n){let r=n.byteLength+7&-8;if(e>0||n.byteLength>3):Ec(new Dc(n,e,t,null,Cc)).subarray(0,r)),i}return n}function Ec(e){let t=[],n=0,r=0,i=0;for(let a of e)a&&(i|=1<0)&&(t[n++]=i);let a=new Uint8Array(t.length+7&-8);return a.set(t),a}var Dc=class{constructor(e,t,n,r,i){this.bytes=e,this.length=n,this.context=r,this.get=i,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=t+(t%8==0?0:8-t%8);return Oc(e,t,i)+Oc(e,r,n)+kc(e,i>>3,r-i>>3)}function kc(e,t,n){let r=0,i=Math.trunc(t),a=new DataView(e.buffer,e.byteOffset,e.byteLength),o=n===void 0?e.byteLength:i+n;for(;o-i>=4;)r+=Ac(a.getUint32(i)),i+=4;for(;o-i>=2;)r+=Ac(a.getUint16(i)),i+=2;for(;o-i>=1;)r+=Ac(a.getUint8(i)),i+=1;return r}function Ac(e){let t=Math.trunc(e);return t-=t>>>1&1431655765,t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var jc=class e{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:e}=this;return x.isSparseUnion(e)||x.isDenseUnion(e)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0,{valueOffsets:t,values:n,nullBitmap:r,typeIds:i}=this;return t&&(e+=t.byteLength),n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),this.children.reduce((e,t)=>e+t.byteLength,e)}get nullCount(){if(x.isUnion(this.type))return this.children.reduce((e,t)=>e+t.nullCount,0);let e=this._nullCount,t;return e<=-1&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-Oc(t,this.offset,this.offset+this.length)),e}constructor(t,n,r,i,a,o=[],s){this.type=t,this.children=o,this.dictionary=s,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let c;a instanceof e?(this.stride=a.stride,this.values=a.values,this.typeIds=a.typeIds,this.nullBitmap=a.nullBitmap,this.valueOffsets=a.valueOffsets):(this.stride=so(t),a&&((c=a[0])&&(this.valueOffsets=c),(c=a[1])&&(this.values=c),(c=a[2])&&(this.nullBitmap=c),(c=a[3])&&(this.typeIds=c)))}getValid(e){let{type:t}=this;if(x.isUnion(t)){let n=t,r=this.children[n.typeIdToChildIndex[this.typeIds[e]]],i=n.mode===ei.Dense?this.valueOffsets[e]:e;return r.getValid(i)}if(this.nullable&&this.nullCount>0){let t=this.offset+e,n=this.nullBitmap[t>>3];return(n&1<>3;(!r||r.byteLength<=c)&&(r=new Uint8Array((i+a+63&-64)>>3).fill(255),this.nullCount>0?(r.set(Tc(i,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:r})):Object.assign(this,{nullBitmap:r,_nullCount:0}));let l=r[c];n=(l&s)!==0,r[c]=t?l|s:l&~s}return n!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(t=this.type,n=this.offset,r=this.length,i=this._nullCount,a=this,o=this.children){return new e(t,n,r,i,a,o,this.dictionary)}slice(e,t){let{stride:n,typeId:r,children:i}=this,a=(this._nullCount===0)-1,o=r===16?n:1,s=this._sliceBuffers(e,t,n,r);return this.clone(this.type,this.offset+e,t,a,s,i.length===0||this.valueOffsets?i:this._sliceChildren(i,o*e,o*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===y.Null)return this.clone(this.type,0,e,0);let{length:t,nullCount:n}=this,r=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);r[t>>3]=(1<0&&r.set(Tc(this.offset,t,this.nullBitmap),0);let i=this.buffers;return i[Gi.VALIDITY]=r,this.clone(this.type,0,e,n+(e-t),i)}_sliceBuffers(e,t,n,r){let i,{buffers:a}=this;return(i=a[Gi.TYPE])&&(a[Gi.TYPE]=i.subarray(e,e+t)),(i=a[Gi.OFFSET])&&(a[Gi.OFFSET]=i.subarray(e,e+t+1))||(i=a[Gi.DATA])&&(a[Gi.DATA]=r===6?i:i.subarray(n*e,n*(e+t))),a}_sliceChildren(e,t,n){return e.map(e=>e.slice(t,n))}};jc.prototype.children=Object.freeze([]);var Mc=class e extends S{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{type:t,offset:n=0,length:r=0}=e;return new jc(t,n,r,r)}visitBool(e){let{type:t,offset:n=0}=e,r=g(e.nullBitmap),i=h(t.ArrayType,e.data),{length:a=i.length>>3,nullCount:o=e.nullBitmap?-1:0}=e;return new jc(t,n,a,o,[void 0,i,r])}visitInt(e){let{type:t,offset:n=0}=e,r=g(e.nullBitmap),i=h(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new jc(t,n,a,o,[void 0,i,r])}visitFloat(e){let{type:t,offset:n=0}=e,r=g(e.nullBitmap),i=h(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new jc(t,n,a,o,[void 0,i,r])}visitUtf8(e){let{type:t,offset:n=0}=e,r=g(e.data),i=g(e.nullBitmap),a=Ir(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new jc(t,n,o,s,[a,r,i])}visitLargeUtf8(e){let{type:t,offset:n=0}=e,r=g(e.data),i=g(e.nullBitmap),a=Lr(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new jc(t,n,o,s,[a,r,i])}visitBinary(e){let{type:t,offset:n=0}=e,r=g(e.data),i=g(e.nullBitmap),a=Ir(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new jc(t,n,o,s,[a,r,i])}visitLargeBinary(e){let{type:t,offset:n=0}=e,r=g(e.data),i=g(e.nullBitmap),a=Lr(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new jc(t,n,o,s,[a,r,i])}visitFixedSizeBinary(e){let{type:t,offset:n=0}=e,r=g(e.nullBitmap),i=h(t.ArrayType,e.data),{length:a=i.length/so(t),nullCount:o=e.nullBitmap?-1:0}=e;return new jc(t,n,a,o,[void 0,i,r])}visitDate(e){let{type:t,offset:n=0}=e,r=g(e.nullBitmap),i=h(t.ArrayType,e.data),{length:a=i.length/so(t),nullCount:o=e.nullBitmap?-1:0}=e;return new jc(t,n,a,o,[void 0,i,r])}visitTimestamp(e){let{type:t,offset:n=0}=e,r=g(e.nullBitmap),i=h(t.ArrayType,e.data),{length:a=i.length/so(t),nullCount:o=e.nullBitmap?-1:0}=e;return new jc(t,n,a,o,[void 0,i,r])}visitTime(e){let{type:t,offset:n=0}=e,r=g(e.nullBitmap),i=h(t.ArrayType,e.data),{length:a=i.length/so(t),nullCount:o=e.nullBitmap?-1:0}=e;return new jc(t,n,a,o,[void 0,i,r])}visitDecimal(e){let{type:t,offset:n=0}=e,r=g(e.nullBitmap),i=h(t.ArrayType,e.data),{length:a=i.length/so(t),nullCount:o=e.nullBitmap?-1:0}=e;return new jc(t,n,a,o,[void 0,i,r])}visitList(e){let{type:t,offset:n=0,child:r}=e,i=g(e.nullBitmap),a=Ir(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new jc(t,n,o,s,[a,void 0,i],[r])}visitStruct(e){let{type:t,offset:n=0,children:r=[]}=e,i=g(e.nullBitmap),{length:a=r.reduce((e,{length:t})=>Math.max(e,t),0),nullCount:o=e.nullBitmap?-1:0}=e;return new jc(t,n,a,o,[void 0,void 0,i],r)}visitUnion(e){let{type:t,offset:n=0,children:r=[]}=e,i=h(t.ArrayType,e.typeIds),{length:a=i.length,nullCount:o=-1}=e;if(x.isSparseUnion(t))return new jc(t,n,a,o,[void 0,void 0,void 0,i],r);let s=Ir(e.valueOffsets);return new jc(t,n,a,o,[s,void 0,void 0,i],r)}visitDictionary(t){let{type:n,offset:r=0}=t,i=g(t.nullBitmap),a=h(n.indices.ArrayType,t.data),{dictionary:o=new $c([new e().visit({type:n.dictionary})])}=t,{length:s=a.length,nullCount:c=t.nullBitmap?-1:0}=t;return new jc(n,r,s,c,[void 0,a,i],[],o)}visitInterval(e){let{type:t,offset:n=0}=e,r=g(e.nullBitmap),i=h(t.ArrayType,e.data),{length:a=i.length/so(t),nullCount:o=e.nullBitmap?-1:0}=e;return new jc(t,n,a,o,[void 0,i,r])}visitDuration(e){let{type:t,offset:n=0}=e,r=g(e.nullBitmap),i=h(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new jc(t,n,a,o,[void 0,i,r])}visitFixedSizeList(t){let{type:n,offset:r=0,child:i=new e().visit({type:n.valueType})}=t,a=g(t.nullBitmap),{length:o=i.length/so(n),nullCount:s=t.nullBitmap?-1:0}=t;return new jc(n,r,o,s,[void 0,void 0,a],[i])}visitMap(t){let{type:n,offset:r=0,child:i=new e().visit({type:n.childType})}=t,a=g(t.nullBitmap),o=Ir(t.valueOffsets),{length:s=o.length-1,nullCount:c=t.nullBitmap?-1:0}=t;return new jc(n,r,s,c,[o,void 0,a],[i])}};const Nc=new Mc;function D(e){return Nc.visit(e)}var Pc=class{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function Ic(e){return e.reduce((e,t)=>e+t.nullCount,0)}function Lc(e){return e.reduce((e,t,n)=>(e[n+1]=e[n]+t.length,e),new Uint32Array(e.length+1))}function Rc(e,t,n,r){let i=[];for(let a=-1,o=e.length;++a=r)break;if(n>=s+c)continue;if(s>=n&&s+c<=r){i.push(o);continue}let l=Math.max(0,n-s),u=Math.min(r-s,c);i.push(o.slice(l,u-l))}return i.length===0&&i.push(e[0].slice(0,0)),i}function zc(e,t,n,r){let i=0,a=0,o=t.length-1;do{if(i>=o-1)return n0?0:-1}function Gc(e,t){let{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(let i of new Dc(n,e.offset+(t||0),e.length,n,Cc)){if(!i)return r;++r}return-1}function k(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case y.Union:break;case y.Dictionary:break;default:return Gc(e,n)}let r=nc.getVisitFn(e),i=mc(t);for(let t=(n||0)-1,a=e.length;++t{let n=e.data[t];return n.values.subarray(0,n.length)[Symbol.iterator]()});let n=0;return new Pc(e.data.length,t=>{let r=e.data[t],i=r.length,a=e.slice(n,n+i);return n+=i,new Jc(a)})}var Jc=class{constructor(e){this.vector=e,this.index=0}next(){return this.indexe.data):t;if(a.length===0||a.some(e=>!(e instanceof jc)))throw TypeError(`Vector constructor expects an Array of Data instances.`);let o=(n=a[0])?.type;switch(a.length){case 0:this._offsets=[0];break;case 1:{let{get:e,set:t,indexOf:n}=Zc[o.typeId],r=a[0];this.isValid=e=>Bc(r,e),this.get=t=>e(r,t),this.set=(e,n)=>t(r,e,n),this.indexOf=e=>n(r,e),this._offsets=[0,r.length];break}default:Object.setPrototypeOf(this,Qc[o.typeId]),this._offsets=Lc(a);break}this.data=a,this.type=o,this.stride=so(o),this.numChildren=(i=(r=o.children)?.length)??0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return Fc(this.data)}get nullCount(){return Ic(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${y[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(fc(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return Yc.visit(this)}concat(...t){return new e(this.data.concat(t.flatMap(e=>e.data).flat(1/0)))}slice(t,n){return new e(dc(this,t,n,({data:e,_offsets:t},n,r)=>Rc(e,t,n,r)))}toJSON(){return[...this]}toArray(){let{type:e,data:t,length:n,stride:r,ArrayType:i}=this;switch(e.typeId){case y.Int:case y.Float:case y.Decimal:case y.Time:case y.Timestamp:switch(t.length){case 0:return new i;case 1:return t[0].values.subarray(0,n*r);default:return t.reduce((e,{values:t,length:n})=>(e.array.set(t.subarray(0,n*r),e.offset),e.offset+=n*r,e),{array:new i(n*r),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(`,`)}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)?.findIndex(t=>t.name===e))}getChildAt(t){return t>-1&&te[t])):null}get isMemoized(){return x.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(x.isDictionary(this.type)){let t=new el(this.data[0].dictionary),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return new el(this)}unmemoize(){if(x.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return this}};Xc=Symbol.toStringTag,$c[Xc]=(e=>{e.type=x.prototype,e.data=[],e.length=0,e.stride=1,e.numChildren=0,e._offsets=new Uint32Array([0]),e[Symbol.isConcatSpreadable]=!0;let t=Object.keys(y).map(e=>y[e]).filter(e=>typeof e==`number`&&e!==y.NONE);for(let n of t){let t=nc.getVisitFnByTypeId(n),r=cs.getVisitFnByTypeId(n),i=qc.getVisitFnByTypeId(n);Zc[n]={get:t,set:r,indexOf:i},Qc[n]=Object.create(e,{isValid:{value:Vc(Bc)},get:{value:Vc(nc.getVisitFnByTypeId(n))},set:{value:Hc(cs.getVisitFnByTypeId(n))},indexOf:{value:Uc(qc.getVisitFnByTypeId(n))}})}return`Vector`})($c.prototype);var el=class e extends $c{constructor(t){super(t.data);let n=this.get,r=this.set,i=this.slice,a=Array(this.length);Object.defineProperty(this,`get`,{value(e){let t=a[e];if(t!==void 0)return t;let r=n.call(this,e);return a[e]=r,r}}),Object.defineProperty(this,`set`,{value(e,t){r.call(this,e,t),a[e]=t}}),Object.defineProperty(this,`slice`,{value:(t,n)=>new e(i.call(this,t,n))}),Object.defineProperty(this,`isMemoized`,{value:!0}),Object.defineProperty(this,`unmemoize`,{value:()=>new $c(this.data)}),Object.defineProperty(this,`memoize`,{value:()=>this})}},tl=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,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(e,t,n,r){return e.prep(8,24),e.writeInt64(BigInt(r??0)),e.pad(4),e.writeInt32(n),e.writeInt64(BigInt(t??0)),e.offset()}},nl=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):$r.V1}schema(e){let t=this.bb.__offset(this.bb_pos,6);return t?(e||new Wi).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){let n=this.bb.__offset(this.bb_pos,8);return n?(t||new tl).__init(this.bb.__vector(this.bb_pos+n)+e*24,this.bb):null}dictionariesLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){let n=this.bb.__offset(this.bb_pos,10);return n?(t||new tl).__init(this.bb.__vector(this.bb_pos+n)+e*24,this.bb):null}recordBatchesLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,12);return n?(t||new Si).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,$r.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){let t=e.endObject();return t}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}},rl=class e{constructor(e=[],t,n,r=$r.V5){this.fields=e||[],this.metadata=t||new Map,n||=ol(this.fields),this.dictionaries=n,this.metadataVersion=r}get[Symbol.toStringTag](){return`Schema`}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(`, `)} }>`}select(t){let n=new Set(t),r=this.fields.filter(e=>n.has(e.name));return new e(r,this.metadata)}selectAt(t){let n=t.map(e=>this.fields[e]).filter(Boolean);return new e(n,this.metadata)}assign(...t){let n=t[0]instanceof e?t[0]:Array.isArray(t[0])?new e(t[0]):new e(t),r=[...this.fields],i=al(al(new Map,this.metadata),n.metadata),a=n.fields.filter(e=>{let t=r.findIndex(t=>t.name===e.name);return~t?(r[t]=e.clone({metadata:al(al(new Map,r[t].metadata),e.metadata)}))&&!1:!0}),o=ol(a,new Map);return new e([...r,...a],i,new Map([...this.dictionaries,...o]))}};rl.prototype.fields=null,rl.prototype.metadata=null,rl.prototype.dictionaries=null;var il=class e{static new(...t){let[n,r,i,a]=t;return t[0]&&typeof t[0]==`object`&&({name:n}=t[0],r===void 0&&(r=t[0].type),i===void 0&&(i=t[0].nullable),a===void 0&&(a=t[0].metadata)),new e(`${n}`,r,i,a)}constructor(e,t,n=!1,r){this.name=e,this.type=t,this.nullable=n,this.metadata=r||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return`Field`}toString(){return`${this.name}: ${this.type}`}clone(...t){let[n,r,i,a]=t;return!t[0]||typeof t[0]!=`object`?[n=this.name,r=this.type,i=this.nullable,a=this.metadata]=t:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:a=this.metadata}=t[0],e.new(n,r,i,a)}};il.prototype.type=null,il.prototype.name=null,il.prototype.nullable=null,il.prototype.metadata=null;function al(e,t){return new Map([...e||new Map,...t||new Map])}function ol(e,t=new Map){for(let n=-1,r=e.length;++n0&&ol(i.children,t)}return t}var sl=ui,cl=li,ll=class{static decode(e){e=new cl(g(e));let t=nl.getRootAsFooter(e),n=rl.decode(t.schema(),new Map,t.version());return new ul(n,t)}static encode(e){let t=new sl,n=rl.encode(t,e.schema);nl.startRecordBatchesVector(t,e.numRecordBatches);for(let n of[...e.recordBatches()].slice().reverse())dl.encode(t,n);let r=t.endVector();nl.startDictionariesVector(t,e.numDictionaries);for(let n of[...e.dictionaryBatches()].slice().reverse())dl.encode(t,n);let i=t.endVector();return nl.startFooter(t),nl.addSchema(t,n),nl.addVersion(t,$r.V5),nl.addRecordBatches(t,r),nl.addDictionaries(t,i),nl.finishFooterBuffer(t,nl.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=$r.V5,n,r){this.schema=e,this.version=t,n&&(this._recordBatches=n),r&&(this._dictionaryBatches=r)}*recordBatches(){for(let e,t=-1,n=this.numRecordBatches;++t=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return p(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){let{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(fl);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return Gr.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return Gr.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return p(this,void 0,void 0,function*(){return yield this.abort(e),fl})}return(e){return p(this,void 0,void 0,function*(){return yield this.close(),fl})}read(e){return p(this,void 0,void 0,function*(){return(yield this.next(e,`read`)).value})}peek(e){return p(this,void 0,void 0,function*(){return(yield this.next(e,`peek`)).value})}next(...e){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,t)=>{this.resolvers.push({resolve:e,reject:t})}):Promise.resolve(fl)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw Error(`AsyncQueue is closed`)}},gl=class extends hl{write(e){if((e=g(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?fr(this.toUint8Array(!0)):this.toUint8Array(!1).then(fr)}toUint8Array(e=!1){return e?Fr(this._values)[0]:(()=>p(this,void 0,void 0,function*(){var e,t,n,r;let i=[],a=0;try{for(var o=!0,s=ur(this),c;c=yield s.next(),e=c.done,!e;o=!0){r=c.value,o=!1;let e=r;i.push(e),a+=e.byteLength}}catch(e){t={error:e}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(t)throw t.error}}return Fr(i,a)[0]}))()}},_l=class{constructor(e){e&&(this.source=new yl(Gr.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},vl=class e{constructor(t){t instanceof e?this.source=t.source:t instanceof gl?this.source=new bl(Gr.fromAsyncIterable(t)):Ar(t)?this.source=new bl(Gr.fromNodeStream(t)):Or(t)?this.source=new bl(Gr.fromDOMStream(t)):Tr(t)?this.source=new bl(Gr.fromDOMStream(t.body)):br(t)?this.source=new bl(Gr.fromIterable(t)):(yr(t)||xr(t))&&(this.source=new bl(Gr.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},yl=class{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,`peek`).value}read(e){return this.next(e,`read`).value}next(e,t=`read`){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||fl)}return(e){return Object.create(this.source.return&&this.source.return(e)||fl)}},bl=class{constructor(e){this.source=e,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(e){return p(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return p(this,void 0,void 0,function*(){return(yield this.next(e,`read`)).value})}peek(e){return p(this,void 0,void 0,function*(){return(yield this.next(e,`peek`)).value})}next(e){return p(this,arguments,void 0,function*(e,t=`read`){return yield this.source.next({cmd:t,size:e})})}throw(e){return p(this,void 0,void 0,function*(){let t=this.source.throw&&(yield this.source.throw(e))||fl;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return p(this,void 0,void 0,function*(){let t=this.source.return&&(yield this.source.return(e))||fl;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}},xl=class extends _l{constructor(e,t){super(),this.position=0,this.buffer=g(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){let{buffer:t,byteOffset:n}=this.readAt(e,4);return new DataView(t,n).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),ep(this,void 0,void 0,function*(){this.size=(yield e.stat()).size,delete this._pending}))()}readInt32(e){return p(this,void 0,void 0,function*(){let{buffer:t,byteOffset:n}=yield this.readAt(e,4);return new DataView(t,n).getInt32(0,!0)})}seek(e){return p(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]),r=t[3]*n[3];this.buffer[0]=r&65535;let i=r>>>16;return r=t[2]*n[3],i+=r,r=t[3]*n[2]>>>0,i+=r,this.buffer[0]+=i<<16,this.buffer[1]=i>>>0>>16,this.buffer[1]+=t[1]*n[3]+t[2]*n[2]+t[3]*n[1],this.buffer[1]+=t[0]*n[3]+t[1]*n[2]+t[2]*n[1]+t[3]*n[0]<<16,this}_plus(e){let t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${Cl(this.buffer[3])} ${Cl(this.buffer[2])} ${Cl(this.buffer[1])} ${Cl(this.buffer[0])}`}static multiply(t,n){let r=new e(new Uint32Array(t.buffer));return r.times(n)}static add(t,n){let r=new e(new Uint32Array(t.buffer));return r.plus(n)}static from(t,n=new Uint32Array(4)){return e.fromString(typeof t==`string`?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return e.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){let r=t.startsWith(`-`),i=t.length,a=new e(n);for(let n=r?1:0;n0&&this.readData(e,n)||new Uint8Array}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+t)}readDictionary(e){return this.dictionaries.get(e.id)}},Al=class extends kl{constructor(e,t,n,r,i){super(new Uint8Array,t,n,r,i),this.sources=e}readNullBitmap(e,t,{offset:n}=this.nextBufferRange()){return t<=0?new Uint8Array:Ec(this.sources[n])}readOffsets(e,{offset:t}=this.nextBufferRange()){return h(Uint8Array,h(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return h(Uint8Array,h(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){let{sources:n}=this;return x.isTimestamp(e)||(x.isInt(e)||x.isTime(e))&&e.bitWidth===64||x.isDuration(e)||x.isDate(e)&&e.unit===ni.MILLISECOND?h(Uint8Array,Dl.convertArray(n[t])):x.isDecimal(e)?h(Uint8Array,Ol.convertArray(n[t])):x.isBinary(e)||x.isLargeBinary(e)||x.isFixedSizeBinary(e)?jl(n[t]):x.isBool(e)?Ec(n[t]):x.isUtf8(e)||x.isLargeUtf8(e)?mr(n[t].join(``)):h(Uint8Array,h(e.ArrayType,n[t].map(e=>+e)))}};function jl(e){let t=e.join(``),n=new Uint8Array(t.length/2);for(let e=0;e>1]=Number.parseInt(t.slice(e,e+2),16);return n}var M=class extends S{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>this.compareFields(e,t[n]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}};function Ml(e,t){return t instanceof e.constructor}function Nl(e,t){return e===t||Ml(e,t)}function Pl(e,t){return e===t||Ml(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function Fl(e,t){return e===t||Ml(e,t)&&e.precision===t.precision}function Il(e,t){return e===t||Ml(e,t)&&e.byteWidth===t.byteWidth}function Ll(e,t){return e===t||Ml(e,t)&&e.unit===t.unit}function Rl(e,t){return e===t||Ml(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function zl(e,t){return e===t||Ml(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function Bl(e,t){return e===t||Ml(e,t)&&e.children.length===t.children.length&&Jl.compareManyFields(e.children,t.children)}function Vl(e,t){return e===t||Ml(e,t)&&e.children.length===t.children.length&&Jl.compareManyFields(e.children,t.children)}function Hl(e,t){return e===t||Ml(e,t)&&e.mode===t.mode&&e.typeIds.every((e,n)=>e===t.typeIds[n])&&Jl.compareManyFields(e.children,t.children)}function Ul(e,t){return e===t||Ml(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&Jl.visit(e.indices,t.indices)&&Jl.visit(e.dictionary,t.dictionary)}function Wl(e,t){return e===t||Ml(e,t)&&e.unit===t.unit}function Gl(e,t){return e===t||Ml(e,t)&&e.unit===t.unit}function Kl(e,t){return e===t||Ml(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&Jl.compareManyFields(e.children,t.children)}function ql(e,t){return e===t||Ml(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&Jl.compareManyFields(e.children,t.children)}M.prototype.visitNull=Nl,M.prototype.visitBool=Nl,M.prototype.visitInt=Pl,M.prototype.visitInt8=Pl,M.prototype.visitInt16=Pl,M.prototype.visitInt32=Pl,M.prototype.visitInt64=Pl,M.prototype.visitUint8=Pl,M.prototype.visitUint16=Pl,M.prototype.visitUint32=Pl,M.prototype.visitUint64=Pl,M.prototype.visitFloat=Fl,M.prototype.visitFloat16=Fl,M.prototype.visitFloat32=Fl,M.prototype.visitFloat64=Fl,M.prototype.visitUtf8=Nl,M.prototype.visitLargeUtf8=Nl,M.prototype.visitBinary=Nl,M.prototype.visitLargeBinary=Nl,M.prototype.visitFixedSizeBinary=Il,M.prototype.visitDate=Ll,M.prototype.visitDateDay=Ll,M.prototype.visitDateMillisecond=Ll,M.prototype.visitTimestamp=Rl,M.prototype.visitTimestampSecond=Rl,M.prototype.visitTimestampMillisecond=Rl,M.prototype.visitTimestampMicrosecond=Rl,M.prototype.visitTimestampNanosecond=Rl,M.prototype.visitTime=zl,M.prototype.visitTimeSecond=zl,M.prototype.visitTimeMillisecond=zl,M.prototype.visitTimeMicrosecond=zl,M.prototype.visitTimeNanosecond=zl,M.prototype.visitDecimal=Nl,M.prototype.visitList=Bl,M.prototype.visitStruct=Vl,M.prototype.visitUnion=Hl,M.prototype.visitDenseUnion=Hl,M.prototype.visitSparseUnion=Hl,M.prototype.visitDictionary=Ul,M.prototype.visitInterval=Wl,M.prototype.visitIntervalDayTime=Wl,M.prototype.visitIntervalYearMonth=Wl,M.prototype.visitDuration=Gl,M.prototype.visitDurationSecond=Gl,M.prototype.visitDurationMillisecond=Gl,M.prototype.visitDurationMicrosecond=Gl,M.prototype.visitDurationNanosecond=Gl,M.prototype.visitFixedSizeList=Kl,M.prototype.visitMap=ql;const Jl=new M;function Yl(e,t){return Jl.compareSchemas(e,t)}function Xl(e,t){return Zl(e,t.map(e=>e.data.concat()))}function Zl(e,t){let n=[...e.fields],r=[],i={numBatches:t.reduce((e,t)=>Math.max(e,t.length),0)},a=0,o=0,s=-1,c=t.length,l,u=[];for(;i.numBatches-- >0;){for(o=1/0,s=-1;++s0&&(r[a++]=D({type:new eo(n),length:o,nullCount:0,children:u.slice()})))}return[e=e.assign(n),r.map(t=>new nu(e,t))]}function Ql(e,t,n,r,i){var a;let o=(t+63&-64)>>3;for(let s=-1,c=r.length;++s=t)l===t?n[s]=c:(n[s]=c.slice(0,t),i.numBatches=Math.max(i.numBatches,r[s].unshift(c.slice(t,l-t))));else{let r=e[s];e[s]=r.clone({nullable:!0}),n[s]=(a=c?._changeLengthAndBackfillNullBitmap(t))??D({type:r.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return n}var $l,eu=class e{constructor(...t){var n,r;if(t.length===0)return this.batches=[],this.schema=new rl([]),this._offsets=[0],this;let i,a;t[0]instanceof rl&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(a=t.pop());let o=t=>{if(t){if(t instanceof nu)return[t];if(t instanceof e)return t.batches;if(t instanceof jc){if(t.type instanceof eo)return[new nu(new rl(t.type.children),t)]}else if(Array.isArray(t))return t.flatMap(e=>o(e));else if(typeof t[Symbol.iterator]==`function`)return[...t].flatMap(e=>o(e));else if(typeof t==`object`){let e=Object.keys(t),n=e.map(e=>new $c([t[e]])),r=i??new rl(e.map((e,t)=>new il(String(e),n[t].type,n[t].nullable))),[,a]=Xl(r,n);return a.length===0?[new nu(t)]:a}}return[]},s=t.flatMap(e=>o(e));if(i=(r=i??(n=s[0])?.schema)??new rl([]),!(i instanceof rl))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);for(let e of s){if(!(e instanceof nu))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);if(!Yl(i,e.schema))throw TypeError(`Table and inner RecordBatch schemas must be equivalent.`)}this.schema=i,this.batches=s,this._offsets=a??Lc(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=Ic(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(fc(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?Yc.visit(new $c(this.data)):[][Symbol.iterator]()}toArray(){return[...this]}toString(){return`[\n ${this.toArray().join(`, + `)}\n]`}concat(...t){let n=this.schema,r=this.data.concat(t.flatMap(({data:e})=>e));return new e(n,r.map(e=>new nu(n,e)))}slice(t,n){let r=this.schema;[t,n]=dc({length:this.numRows},t,n);let i=Rc(this.data,this._offsets,t,n);return new e(r,i.map(e=>new nu(r,e)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(t=>t.name===e))}getChildAt(e){if(e>-1&&et.children[e]);if(t.length===0){let{type:n}=this.schema.fields[e],r=D({type:n,length:0,nullCount:0});t.push(r._changeLengthAndBackfillNullBitmap(this.numRows))}return new $c(t)}return null}setChild(e,t){var n;return this.setChildAt((n=this.schema.fields)?.findIndex(t=>t.name===e),t)}setChildAt(t,n){let r=this.schema,i=[...this.batches];if(t>-1&&tthis.getChildAt(t));[e[t],o[t]]=[a,n],[r,i]=Xl(r,o)}return new e(r,i)}select(e){let t=this.schema.fields.reduce((e,t,n)=>e.set(t.name,n),new Map);return this.selectAt(e.map(e=>t.get(e)).filter(e=>e>-1))}selectAt(t){let n=this.schema.selectAt(t),r=this.batches.map(e=>e.selectAt(t));return new e(n,r)}assign(t){let n=this.schema.fields,[r,i]=t.schema.fields.reduce((e,t,r)=>{let[i,a]=e,o=n.findIndex(e=>e.name===t.name);return~o?a[o]=r:i.push(r),e},[[],[]]),a=this.schema.assign(t.schema),o=[...n.map((e,t)=>[t,i[t]]).map(([e,n])=>n===void 0?this.getChildAt(e):t.getChildAt(n)),...r.map(e=>t.getChildAt(e))].filter(Boolean);return new e(...Xl(a,o))}};$l=Symbol.toStringTag,eu[$l]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=Vc(Bc),e.get=Vc(nc.getVisitFn(y.Struct)),e.set=Hc(cs.getVisitFn(y.Struct)),e.indexOf=Uc(qc.getVisitFn(y.Struct)),`Table`))(eu.prototype);var tu,nu=class e{constructor(...e){switch(e.length){case 2:if([this.schema]=e,!(this.schema instanceof rl)||([,this.data=D({nullCount:0,type:new eo(this.schema.fields),children:this.schema.fields.map(e=>D({type:e.type,nullCount:0}))})]=e,!(this.data instanceof jc)))throw TypeError(`RecordBatch constructor expects a [Schema, Data] pair.`);[this.schema,this.data]=ru(this.schema,this.data.children);break;case 1:{let[t]=e,{fields:n,children:r,length:i}=Object.keys(t).reduce((e,n,r)=>(e.children[r]=t[n],e.length=Math.max(e.length,t[n].length),e.fields[r]=il.new({name:n,type:t[n].type,nullable:!0}),e),{length:0,fields:[],children:[]}),a=new rl(n),o=D({type:new eo(n),length:i,children:r,nullCount:0});[this.schema,this.data]=ru(a,o.children,i);break}default:throw TypeError(`RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.`)}}get dictionaries(){return this._dictionaries||=iu(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(e){return this.data.getValid(e)}get(e){return nc.visit(this.data,e)}at(e){return this.get(fc(e,this.numRows))}set(e,t){return cs.visit(this.data,e,t)}indexOf(e,t){return qc.visit(this.data,e,t)}[Symbol.iterator](){return Yc.visit(new $c([this.data]))}toArray(){return[...this]}concat(...e){return new eu(this.schema,[this,...e])}slice(t,n){let[r]=new $c([this.data]).slice(t,n).data;return new e(this.schema,r)}getChild(e){var t;return this.getChildAt((t=this.schema.fields)?.findIndex(t=>t.name===e))}getChildAt(e){return e>-1&&et.name===e),t)}setChildAt(t,n){let r=this.schema,i=this.data;if(t>-1&&tt.name===e);~t&&(i[t]=this.data.children[t])}return new e(n,D({type:r,length:this.numRows,children:i}))}selectAt(t){let n=this.schema.selectAt(t),r=t.map(e=>this.data.children[e]).filter(Boolean),i=D({type:new eo(n.fields),length:this.numRows,children:r});return new e(n,i)}};tu=Symbol.toStringTag,nu[tu]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,`RecordBatch`))(nu.prototype);function ru(e,t,n=t.reduce((e,t)=>Math.max(e,t.length),0)){var r;let i=[...e.fields],a=[...t],o=(n+63&-64)>>3;for(let[s,c]of e.fields.entries()){let e=t[s];(!e||e.length!==n)&&(i[s]=c.clone({nullable:!0}),a[s]=(r=e?._changeLengthAndBackfillNullBitmap(n))??D({type:c.type,length:n,nullCount:n,nullBitmap:new Uint8Array(o)}))}return[e.assign(i),D({type:new eo(i),length:n,children:a})]}function iu(e,t,n=new Map){var r,i;if(((r=e?.length)??0)>0&&e?.length===t?.length)for(let r=-1,a=e.length;++rD({type:e.type})),n=D({type:new eo(e.fields),nullCount:0,children:t});super(e,n)}},ou=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMessage(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):$r.V1}headerType(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):v.NONE}header(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}bodyLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt(`0`)}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,12);return n?(t||new Si).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,$r.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,v.NONE)}static addHeader(e,t){e.addFieldOffset(2,t,0)}static addBodyLength(e,t){e.addFieldInt64(3,t,BigInt(`0`))}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endMessage(e){let t=e.endObject();return t}static finishMessageBuffer(e,t){e.finish(t)}static finishSizePrefixedMessageBuffer(e,t){e.finish(t,void 0,!0)}static createMessage(t,n,r,i,a,o){return e.startMessage(t),e.addVersion(t,n),e.addHeaderType(t,r),e.addHeader(t,i),e.addBodyLength(t,a),e.addCustomMetadata(t,o),e.endMessage(t)}},su=class extends S{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return Ii.startNull(t),Ii.endNull(t)}visitInt(e,t){return bi.startInt(t),bi.addBitWidth(t,e.bitWidth),bi.addIsSigned(t,e.isSigned),bi.endInt(t)}visitFloat(e,t){return Ai.startFloatingPoint(t),Ai.addPrecision(t,e.precision),Ai.endFloatingPoint(t)}visitBinary(e,t){return Ci.startBinary(t),Ci.endBinary(t)}visitLargeBinary(e,t){return Mi.startLargeBinary(t),Mi.endLargeBinary(t)}visitBool(e,t){return wi.startBool(t),wi.endBool(t)}visitUtf8(e,t){return Vi.startUtf8(t),Vi.endUtf8(t)}visitLargeUtf8(e,t){return Ni.startLargeUtf8(t),Ni.endLargeUtf8(t)}visitDecimal(e,t){return Ei.startDecimal(t),Ei.addScale(t,e.scale),Ei.addPrecision(t,e.precision),Ei.addBitWidth(t,e.bitWidth),Ei.endDecimal(t)}visitDate(e,t){return Ti.startDate(t),Ti.addUnit(t,e.unit),Ti.endDate(t)}visitTime(e,t){return Ri.startTime(t),Ri.addUnit(t,e.unit),Ri.addBitWidth(t,e.bitWidth),Ri.endTime(t)}visitTimestamp(e,t){let n=e.timezone&&t.createString(e.timezone)||void 0;return zi.startTimestamp(t),zi.addUnit(t,e.unit),n!==void 0&&zi.addTimezone(t,n),zi.endTimestamp(t)}visitInterval(e,t){return ji.startInterval(t),ji.addUnit(t,e.unit),ji.endInterval(t)}visitDuration(e,t){return Di.startDuration(t),Di.addUnit(t,e.unit),Di.endDuration(t)}visitList(e,t){return Pi.startList(t),Pi.endList(t)}visitStruct(e,t){return Li.startStruct_(t),Li.endStruct_(t)}visitUnion(e,t){Bi.startTypeIdsVector(t,e.typeIds.length);let n=Bi.createTypeIdsVector(t,e.typeIds);return Bi.startUnion(t),Bi.addMode(t,e.mode),Bi.addTypeIds(t,n),Bi.endUnion(t)}visitDictionary(e,t){let n=this.visit(e.indices,t);return xi.startDictionaryEncoding(t),xi.addId(t,BigInt(e.id)),xi.addIsOrdered(t,e.isOrdered),n!==void 0&&xi.addIndexType(t,n),xi.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return Oi.startFixedSizeBinary(t),Oi.addByteWidth(t,e.byteWidth),Oi.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return ki.startFixedSizeList(t),ki.addListSize(t,e.listSize),ki.endFixedSizeList(t)}visitMap(e,t){return Fi.startMap(t),Fi.addKeysSorted(t,e.keysSorted),Fi.endMap(t)}};const cu=new su;function lu(e,t=new Map){return new rl(fu(e,t),vu(e.metadata),t)}function uu(e){return new wu(e.count,mu(e.columns),hu(e.columns))}function du(e){return new Tu(uu(e.data),e.id,e.isDelta)}function fu(e,t){return(e.fields||[]).filter(Boolean).map(e=>il.fromJSON(e,t))}function pu(e,t){return(e.children||[]).filter(Boolean).map(e=>il.fromJSON(e,t))}function mu(e){return(e||[]).reduce((e,t)=>[...e,new Du(t.count,gu(t.VALIDITY)),...mu(t.children)],[])}function hu(e,t=[]){for(let n=-1,r=(e||[]).length;++ne+ +(t===0),0)}function _u(e,t){let n,r,i,a,o,s;return!t||!(a=e.dictionary)?(o=bu(e,pu(e,t)),i=new il(e.name,o,e.nullable,vu(e.metadata))):t.has(n=a.id)?(r=(r=a.indexType)?yu(r):new Ma,s=new oo(t.get(n),r,n,a.isOrdered),i=new il(e.name,s,e.nullable,vu(e.metadata))):(r=(r=a.indexType)?yu(r):new Ma,t.set(n,o=bu(e,pu(e,t))),s=new oo(o,r,n,a.isOrdered),i=new il(e.name,s,e.nullable,vu(e.metadata))),i||null}function vu(e=[]){return new Map(e.map(({key:e,value:t})=>[e,t]))}function yu(e){return new ka(e.isSigned,e.bitWidth)}function bu(e,t){let n=e.type.name;switch(n){case`NONE`:return new Oa;case`null`:return new Oa;case`binary`:return new Ha;case`largebinary`:return new Ua;case`utf8`:return new Wa;case`largeutf8`:return new Ga;case`bool`:return new Ka;case`list`:return new $a((t||[])[0]);case`struct`:return new eo(t||[]);case`struct_`:return new eo(t||[])}switch(n){case`int`:{let t=e.type;return new ka(t.isSigned,t.bitWidth)}case`floatingpoint`:{let t=e.type;return new Ra(ti[t.precision])}case`decimal`:{let t=e.type;return new qa(t.scale,t.precision,t.bitWidth)}case`date`:{let t=e.type;return new Ja(ni[t.unit])}case`time`:{let t=e.type;return new Ya(_[t.unit],t.bitWidth)}case`timestamp`:{let t=e.type;return new Xa(_[t.unit],t.timezone)}case`interval`:{let t=e.type;return new Za(ri[t.unit])}case`duration`:{let t=e.type;return new Qa(_[t.unit])}case`union`:{let n=e.type,[r,...i]=(n.mode+``).toLowerCase(),a=r.toUpperCase()+i.join(``);return new to(ei[a],n.typeIds||[],t||[])}case`fixedsizebinary`:{let t=e.type;return new no(t.byteWidth)}case`fixedsizelist`:{let n=e.type;return new ro(n.listSize,(t||[])[0])}case`map`:{let n=e.type;return new io((t||[])[0],n.keysSorted)}}throw Error(`Unrecognized type: "${n}"`)}var xu=ui,Su=li,Cu=class e{static fromJSON(t,n){let r=new e(0,$r.V5,n);return r._createHeader=Ou(t,n),r}static decode(t){t=new Su(g(t));let n=ou.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),a=n.headerType(),o=new e(r,i,a);return o._createHeader=ku(n,a),o}static encode(e){let t=new xu,n=-1;return e.isSchema()?n=rl.encode(t,e.header()):e.isRecordBatch()?n=wu.encode(t,e.header()):e.isDictionaryBatch()&&(n=Tu.encode(t,e.header())),ou.startMessage(t),ou.addVersion(t,$r.V5),ou.addHeader(t,n),ou.addHeaderType(t,e.headerType),ou.addBodyLength(t,BigInt(e.bodyLength)),ou.finishMessageBuffer(t,ou.endMessage(t)),t.asUint8Array()}static from(t,n=0){if(t instanceof rl)return new e(0,$r.V5,v.Schema,t);if(t instanceof wu)return new e(n,$r.V5,v.RecordBatch,t);if(t instanceof Tu)return new e(n,$r.V5,v.DictionaryBatch,t);throw 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===v.Schema}isRecordBatch(){return this.headerType===v.RecordBatch}isDictionaryBatch(){return this.headerType===v.DictionaryBatch}constructor(e,t,n,r){this._version=t,this._headerType=n,this.body=new Uint8Array,r&&(this._createHeader=()=>r),this._bodyLength=b(e)}},wu=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,n){this._nodes=t,this._buffers=n,this._length=b(e)}},Tu=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,t,n=!1){this._data=e,this._isDelta=n,this._id=b(t)}},Eu=class{constructor(e,t){this.offset=b(e),this.length=b(t)}},Du=class{constructor(e,t){this.length=b(e),this.nullCount=b(t)}};function Ou(e,t){return(()=>{switch(t){case v.Schema:return rl.fromJSON(e);case v.RecordBatch:return wu.fromJSON(e);case v.DictionaryBatch:return Tu.fromJSON(e)}throw Error(`Unrecognized Message type: { name: ${v[t]}, type: ${t} }`)})}function ku(e,t){return(()=>{switch(t){case v.Schema:return rl.decode(e.header(new Wi),new Map,e.version());case v.RecordBatch:return wu.decode(e.header(new gi),e.version());case v.DictionaryBatch:return Tu.decode(e.header(new _i),e.version())}throw Error(`Unrecognized Message type: { name: ${v[t]}, type: ${t} }`)})}il.encode=Wu,il.decode=zu,il.fromJSON=_u,rl.encode=Uu,rl.decode=Au,rl.fromJSON=lu,wu.encode=Gu,wu.decode=ju,wu.fromJSON=uu,Tu.encode=Ku,Tu.decode=Mu,Tu.fromJSON=du,Du.encode=qu,Du.decode=Pu,Eu.encode=Ju,Eu.decode=Nu;function Au(e,t=new Map,n=$r.V5){let r=Lu(e,t);return new rl(r,Bu(e),t,n)}function ju(e,t=$r.V5){if(e.compression()!==null)throw Error(`Record batch compression not implemented`);return new wu(e.length(),Fu(e),Iu(e,t))}function Mu(e,t=$r.V5){return new Tu(wu.decode(e.data(),t),e.id(),e.isDelta())}function Nu(e){return new Eu(e.offset(),e.length())}function Pu(e){return new Du(e.length(),e.nullCount())}function Fu(e){let t=[];for(let n,r=-1,i=-1,a=e.nodesLength();++ril.encode(e,t));Wi.startFieldsVector(e,n.length);let r=Wi.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?Wi.createCustomMetadataVector(e,[...t.metadata].map(([t,n])=>{let r=e.createString(`${t}`),i=e.createString(`${n}`);return Si.startKeyValue(e),Si.addKey(e,r),Si.addValue(e,i),Si.endKeyValue(e)})):-1;return Wi.startSchema(e),Wi.addFields(e,r),Wi.addEndianness(e,Yu?vi.Little:vi.Big),i!==-1&&Wi.addCustomMetadata(e,i),Wi.endSchema(e)}function Wu(e,t){let n=-1,r=-1,i=-1,a=t.type,o=t.typeId;x.isDictionary(a)?(o=a.dictionary.typeId,i=cu.visit(a,e),r=cu.visit(a.dictionary,e)):r=cu.visit(a,e);let s=(a.children||[]).map(t=>il.encode(e,t)),c=Ui.createChildrenVector(e,s),l=t.metadata&&t.metadata.size>0?Ui.createCustomMetadataVector(e,[...t.metadata].map(([t,n])=>{let r=e.createString(`${t}`),i=e.createString(`${n}`);return Si.startKeyValue(e),Si.addKey(e,r),Si.addValue(e,i),Si.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),Ui.startField(e),Ui.addType(e,r),Ui.addTypeType(e,o),Ui.addChildren(e,c),Ui.addNullable(e,!!t.nullable),n!==-1&&Ui.addName(e,n),i!==-1&&Ui.addDictionary(e,i),l!==-1&&Ui.addCustomMetadata(e,l),Ui.endField(e)}function Gu(e,t){let n=t.nodes||[],r=t.buffers||[];gi.startNodesVector(e,n.length);for(let t of n.slice().reverse())Du.encode(e,t);let i=e.endVector();gi.startBuffersVector(e,r.length);for(let t of r.slice().reverse())Eu.encode(e,t);let a=e.endVector();return gi.startRecordBatch(e),gi.addLength(e,BigInt(t.length)),gi.addNodes(e,i),gi.addBuffers(e,a),gi.endRecordBatch(e)}function Ku(e,t){let n=wu.encode(e,t.data);return _i.startDictionaryBatch(e),_i.addId(e,BigInt(t.id)),_i.addIsDelta(e,t.isDelta),_i.addData(e,n),_i.endDictionaryBatch(e)}function qu(e,t){return hi.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function Ju(e,t){return mi.createBuffer(e,BigInt(t.offset),BigInt(t.length))}const Yu=(()=>{let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),Xu=e=>`Expected ${v[e]} Message in stream, but was null or length 0.`,Zu=e=>`Header pointer of flatbuffer-encoded ${v[e]} Message is null or length 0.`,Qu=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,$u=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;var ed=class{constructor(e){this.source=e instanceof _l?e:new _l(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?fl:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw Error(Xu(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array;let t=g(this.source.read(e));if(t.byteLength[...e,...n.VALIDITY&&[n.VALIDITY]||[],...n.TYPE_ID&&[n.TYPE_ID]||[],...n.OFFSET&&[n.OFFSET]||[],...n.DATA&&[n.DATA]||[],...t(n.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw Error(Xu(e));return t.value}readSchema(){let e=v.Schema,t=this.readMessage(e),n=t?.header();if(!t||!n)throw Error(Zu(e));return n}};const rd=4,id=new Uint8Array(6);for(let e=0;e<6;e+=1)id[e]=`ARROW1`.codePointAt(e);function ad(e,t=0){for(let n=-1,r=id.length;++nthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Gr.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Gr.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw Error(`"throughNode" not available in this environment`)}static throughDOM(e,t){throw Error(`"throughDOM" not available in this environment`)}static from(t){return t instanceof e?t:Sr(t)?Cd(t):wr(t)?Ed(t):yr(t)?(()=>p(this,void 0,void 0,function*(){return yield e.from(yield t)}))():Tr(t)||Or(t)||Ar(t)||xr(t)?Td(new vl(t)):wd(new _l(t))}static readAll(t){return t instanceof e?t.isSync()?xd(t):Sd(t):Sr(t)||ArrayBuffer.isView(t)||br(t)||Cr(t)?xd(t):Sd(t)}},ud=class extends ld{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return cr(this,arguments,function*(){yield m(yield*lr(ur(this[Symbol.iterator]())))})}},dd=class extends ld{constructor(e){super(e),this._impl=e}readAll(){return p(this,void 0,void 0,function*(){var e,t,n,r;let i=[];try{for(var a=!0,o=ur(this),s;s=yield o.next(),e=s.done,!e;a=!0){r=s.value,a=!1;let e=r;i.push(e)}}catch(e){t={error:e}}finally{try{!a&&!e&&(n=o.return)&&(yield n.call(o))}finally{if(t)throw t.error}}return i})}[Symbol.iterator](){throw Error(`AsyncRecordBatchStreamReader is not Iterable`)}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},fd=class extends ud{constructor(e){super(e),this._impl=e}},pd=class extends dd{constructor(e){super(e),this._impl=e}},md=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){let n=this._loadVectors(e,t,this.schema.fields),r=D({type:new eo(this.schema.fields),length:e.length,children:n});return new nu(this.schema,r)}_loadDictionaryBatch(e,t){let{id:n,isDelta:r}=e,{dictionaries:i,schema:a}=this,o=i.get(n),s=a.dictionaries.get(n),c=this._loadVectors(e.data,t,[s]);return(o&&r?o.concat(new $c(c)):new $c(c)).memoize()}_loadVectors(e,t,n){return new kl(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},hd=class extends md{constructor(e,t){super(t),this._reader=Sr(e)?new nd(this._handle=e):new ed(this._handle=e)}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(e){return this.closed||(this.autoDestroy=bd(this,e),(this.schema||=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):fl}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):fl}next(){if(this.closed)return fl;let e,{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let n=e.header(),r=t.readMessageBody(e.bodyLength),i=this._loadRecordBatch(n,r);return{done:!1,value:i}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let n=e.header(),r=t.readMessageBody(e.bodyLength),i=this._loadDictionaryBatch(n,r);this.dictionaries.set(n.id,i)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new au(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}},gd=class extends md{constructor(e,t){super(t),this._reader=new td(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return p(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return p(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=bd(this,e),(this.schema||=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return p(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):fl})}return(e){return p(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):fl})}next(){return p(this,void 0,void 0,function*(){if(this.closed)return fl;let e,{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let n=e.header(),r=yield t.readMessageBody(e.bodyLength),i=this._loadRecordBatch(n,r);return{done:!1,value:i}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let n=e.header(),r=yield t.readMessageBody(e.bodyLength),i=this._loadDictionaryBatch(n,r);this.dictionaries.set(n.id,i)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new au(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return p(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}},_d=class extends hd{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof xl?e:new xl(e),t)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var t;if(this.closed)return null;this._footer||this.open();let n=(t=this._footer)?.getRecordBatch(e);if(n&&this._handle.seek(n.offset)){let e=this._reader.readMessage(v.RecordBatch);if(e?.isRecordBatch()){let t=e.header(),n=this._reader.readMessageBody(e.bodyLength),r=this._loadRecordBatch(t,n);return r}}return null}_readDictionaryBatch(e){var t;let n=(t=this._footer)?.getDictionaryBatch(e);if(n&&this._handle.seek(n.offset)){let e=this._reader.readMessage(v.DictionaryBatch);if(e?.isDictionaryBatch()){let t=e.header(),n=this._reader.readMessageBody(e.bodyLength),r=this._loadDictionaryBatch(t,n);this.dictionaries.set(t.id,r)}}}_readFooter(){let{_handle:e}=this,t=e.size-sd,n=e.readInt32(t),r=e.readAt(t-n,n);return ll.decode(r)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return p(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield t.open.call(this,e)})}readRecordBatch(e){return p(this,void 0,void 0,function*(){var t;if(this.closed)return null;this._footer||(yield this.open());let n=(t=this._footer)?.getRecordBatch(e);if(n&&(yield this._handle.seek(n.offset))){let e=yield this._reader.readMessage(v.RecordBatch);if(e?.isRecordBatch()){let t=e.header(),n=yield this._reader.readMessageBody(e.bodyLength),r=this._loadRecordBatch(t,n);return r}}return null})}_readDictionaryBatch(e){return p(this,void 0,void 0,function*(){var t;let n=(t=this._footer)?.getDictionaryBatch(e);if(n&&(yield this._handle.seek(n.offset))){let e=yield this._reader.readMessage(v.DictionaryBatch);if(e?.isDictionaryBatch()){let t=e.header(),n=yield this._reader.readMessageBody(e.bodyLength),r=this._loadDictionaryBatch(t,n);this.dictionaries.set(t.id,r)}}})}_readFooter(){return p(this,void 0,void 0,function*(){let{_handle:e}=this;e._pending&&(yield e._pending);let t=e.size-sd,n=yield e.readInt32(t),r=yield e.readAt(t-n,n);return ll.decode(r)})}_readNextMessageAndValidate(e){return p(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?ad(t)?new fd(new _d(e.read())):new ud(new hd(e)):new ud(new hd(function*(){}()))}function Td(e){return p(this,void 0,void 0,function*(){let t=yield e.peek(od+7&-8);return t&&t.byteLength>=4?ad(t)?new fd(new _d(yield e.read())):new dd(new gd(e)):new dd(new gd(function(){return cr(this,arguments,function*(){})}()))})}function Ed(e){return p(this,void 0,void 0,function*(){let{size:t}=yield e.stat(),n=new Sl(e,t);return t>=cd&&ad(yield n.readAt(0,od+7&-8))?new pd(new vd(n)):new dd(new gd(n))})}var Dd=class e extends S{static assemble(...t){let n=e=>e.flatMap(e=>Array.isArray(e)?n(e):e instanceof nu?e.data.children:e.data),r=new e;return r.visitMany(n(t)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(e){if(e instanceof $c)return this.visitMany(e.data),this;let{type:t}=e;if(!x.isDictionary(t)){let{length:n}=e;if(n>2147483647)throw RangeError(`Cannot write arrays larger than 2^31 - 1 in length`);if(x.isUnion(t))this.nodes.push(new Du(n,0));else{let{nullCount:r}=e;x.isNull(t)||Od.call(this,r<=0?new Uint8Array:Tc(e.offset,n,e.nullBitmap)),this.nodes.push(new Du(n,r))}}return super.visit(e)}visitNull(e){return this}visitDictionary(e){return this.visit(e.clone(e.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function Od(e){let t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new Eu(this._byteLength,t)),this._byteLength+=t,this}function kd(e){var t;let{type:n,length:r,typeIds:i,valueOffsets:a}=e;if(Od.call(this,i),n.mode===ei.Sparse)return Pd.call(this,e);if(n.mode===ei.Dense){if(e.offset<=0)return Od.call(this,a),Pd.call(this,e);{let o=new Int32Array(r),s=Object.create(null),c=Object.create(null);for(let e,n,l=-1;++l{let i=n.typeIds[t],a=s[i],o=c[i];return e.slice(a,Math.min(r,o))}))}}return this}function Ad(e){let t;return e.nullCount>=e.length?Od.call(this,new Uint8Array):(t=e.values)instanceof Uint8Array?Od.call(this,Tc(e.offset,e.length,t)):Od.call(this,Ec(e.values))}function jd(e){return Od.call(this,e.values.subarray(0,e.length*e.stride))}function Md(e){let{length:t,values:n,valueOffsets:r}=e,i=b(r[0]),a=b(r[t]),o=Math.min(a-i,n.byteLength-i);return Od.call(this,Ur(-i,t+1,r)),Od.call(this,n.subarray(i,i+o)),this}function Nd(e){let{length:t,valueOffsets:n}=e;if(n){let{0:r,[t]:i}=n;return Od.call(this,Ur(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function Pd(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}Dd.prototype.visitBool=Ad,Dd.prototype.visitInt=jd,Dd.prototype.visitFloat=jd,Dd.prototype.visitUtf8=Md,Dd.prototype.visitLargeUtf8=Md,Dd.prototype.visitBinary=Md,Dd.prototype.visitLargeBinary=Md,Dd.prototype.visitFixedSizeBinary=jd,Dd.prototype.visitDate=jd,Dd.prototype.visitTimestamp=jd,Dd.prototype.visitTime=jd,Dd.prototype.visitDecimal=jd,Dd.prototype.visitList=Nd,Dd.prototype.visitStruct=Pd,Dd.prototype.visitUnion=kd,Dd.prototype.visitInterval=jd,Dd.prototype.visitDuration=jd,Dd.prototype.visitFixedSizeList=Nd,Dd.prototype.visitMap=Nd;var Fd=class extends ml{static throughNode(e){throw Error(`"throughNode" not available in this environment`)}static throughDOM(e,t){throw Error(`"throughDOM" not available in this environment`)}constructor(e){super(),this._position=0,this._started=!1,this._sink=new gl,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,vr(e)||(e={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof e.autoDestroy==`boolean`?e.autoDestroy:!0,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat==`boolean`?e.writeLegacyIpcFormat:!1}toString(e=!1){return this._sink.toString(e)}toUint8Array(e=!1){return this._sink.toUint8Array(e)}writeAll(e){return yr(e)?e.then(e=>this.writeAll(e)):xr(e)?zd(this,e):Rd(this,e)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(e){return this._sink.toDOMStream(e)}toNodeStream(e){return this._sink.toNodeStream(e)}close(){return this.reset()._sink.close()}abort(e){return this.reset()._sink.abort(e)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(e=this._sink,t=null){return e===this._sink||e instanceof gl?this._sink=e:(this._sink=new gl,e&&Dr(e)?this.toDOMStream({type:`bytes`}).pipeTo(e):e&&kr(e)&&this.toNodeStream({objectMode:!1}).pipe(e)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!t||!Yl(t,this._schema))&&(t==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=t,this._writeSchema(t))),this}write(e){let t=null;if(this._sink){if(e==null||e instanceof eu&&!(t=e.schema)||e instanceof nu&&!(t=e.schema))return this.finish()&&void 0}else throw Error(`RecordBatchWriter is closed`);if(t&&!Yl(t,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,t)}e instanceof nu?e instanceof au||this._writeRecordBatch(e):e instanceof eu?this.writeAll(e.batches):br(e)&&this.writeAll(e)}_writeMessage(e,t=8){let n=t-1,r=Cu.encode(e),i=r.byteLength,a=this._writeLegacyIpcFormat?4:8,o=i+a+n&~n,s=o-i-a;return e.headerType===v.RecordBatch?this._recordBatchBlocks.push(new dl(o,e.bodyLength,this._position)):e.headerType===v.DictionaryBatch&&this._dictionaryBlocks.push(new dl(o,e.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(o-a)),i>0&&this._write(r),this._writePadding(s)}_write(e){if(this._started){let t=g(e);t&&t.byteLength>0&&(this._sink.write(t),this._position+=t.byteLength)}return this}_writeSchema(e){return this._writeMessage(Cu.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(id)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:t,nodes:n,bufferRegions:r,buffers:i}=Dd.assemble(e),a=new wu(e.numRows,n,r),o=Cu.from(a,t);return this._writeDictionaries(e)._writeMessage(o)._writeBodyBuffers(i)}_writeDictionaryBatch(e,t,n=!1){let{byteLength:r,nodes:i,bufferRegions:a,buffers:o}=Dd.assemble(new $c([e])),s=new wu(e.length,i,a),c=new Tu(s,t,n),l=Cu.from(c,r);return this._writeMessage(l)._writeBodyBuffers(o)}_writeBodyBuffers(e){let t,n,r;for(let i=-1,a=e.length;++i0&&(this._write(t),(r=(n+7&-8)-n)>0&&this._writePadding(r));return this}_writeDictionaries(e){var t,n;for(let[r,i]of e.dictionaries){let e=(t=i?.data)??[],a=this._seenDictionaries.get(r),o=(n=this._dictionaryDeltaOffsets.get(r))??0;if(!a||a.data[0]!==e[0])for(let[t,n]of e.entries())this._writeDictionaryBatch(n,r,t>0);else if(or.writeAll(e)):xr(t)?zd(r,t):Rd(r,t)}},Ld=class e extends Fd{static writeAll(t){let n=new e;return yr(t)?t.then(e=>n.writeAll(e)):xr(t)?zd(n,t):Rd(n,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(e){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(e,t,n=!1){if(!n&&this._seenDictionaries.has(t))throw Error(`The Arrow File format does not support replacement dictionaries. `);return super._writeDictionaryBatch(e,t,n)}_writeFooter(e){let t=ll.encode(new ll(e,$r.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(t)._write(Int32Array.of(t.byteLength))._writeMagic()}};function Rd(e,t){let n=t;t instanceof eu&&(n=t.batches,e.reset(void 0,t.schema));for(let t of n)e.write(t);return e.finish()}function zd(e,t){return p(this,void 0,void 0,function*(){var n,r,i,a,o,s,c;try{for(n=!0,r=ur(t);i=yield r.next(),a=i.done,!a;n=!0){c=i.value,n=!1;let t=c;e.write(t)}}catch(e){o={error:e}}finally{try{!n&&!a&&(s=r.return)&&(yield s.call(r))}finally{if(o)throw o.error}}return e.finish()})}function Bd(e,t=`stream`){return(t===`stream`?Id:Ld).writeAll(e).toUint8Array(!0)}var Vd=Object.create,Hd=Object.defineProperty,Ud=Object.getOwnPropertyDescriptor,Wd=Object.getOwnPropertyNames,Gd=Object.getPrototypeOf,Kd=Object.prototype.hasOwnProperty,qd=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Jd=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of Wd(t))!Kd.call(e,i)&&i!==n&&Hd(e,i,{get:()=>t[i],enumerable:!(r=Ud(t,i))||r.enumerable});return e},Yd=(e,t,n)=>(n=e==null?{}:Vd(Gd(e)),Jd(t||!e||!e.__esModule?Hd(n,`default`,{value:e,enumerable:!0}):n,e)),Xd=qd((e,t)=>{t.exports=Worker}),Zd=(e=>(e[e.UNDEFINED=0]=`UNDEFINED`,e[e.AUTOMATIC=1]=`AUTOMATIC`,e[e.READ_ONLY=2]=`READ_ONLY`,e[e.READ_WRITE=3]=`READ_WRITE`,e))(Zd||{}),Qd=(e=>(e[e.IDENTIFIER=0]=`IDENTIFIER`,e[e.NUMERIC_CONSTANT=1]=`NUMERIC_CONSTANT`,e[e.STRING_CONSTANT=2]=`STRING_CONSTANT`,e[e.OPERATOR=3]=`OPERATOR`,e[e.KEYWORD=4]=`KEYWORD`,e[e.COMMENT=5]=`COMMENT`,e))(Qd||{}),$d=(e=>(e[e.NONE=0]=`NONE`,e[e.DEBUG=1]=`DEBUG`,e[e.INFO=2]=`INFO`,e[e.WARNING=3]=`WARNING`,e[e.ERROR=4]=`ERROR`,e))($d||{}),ef=(e=>(e[e.NONE=0]=`NONE`,e[e.CONNECT=1]=`CONNECT`,e[e.DISCONNECT=2]=`DISCONNECT`,e[e.OPEN=3]=`OPEN`,e[e.QUERY=4]=`QUERY`,e[e.INSTANTIATE=5]=`INSTANTIATE`,e))(ef||{}),tf=(e=>(e[e.NONE=0]=`NONE`,e[e.OK=1]=`OK`,e[e.ERROR=2]=`ERROR`,e[e.START=3]=`START`,e[e.RUN=4]=`RUN`,e[e.CAPTURE=5]=`CAPTURE`,e))(tf||{}),nf=(e=>(e[e.NONE=0]=`NONE`,e[e.WEB_WORKER=1]=`WEB_WORKER`,e[e.NODE_WORKER=2]=`NODE_WORKER`,e[e.BINDINGS=3]=`BINDINGS`,e[e.ASYNC_DUCKDB=4]=`ASYNC_DUCKDB`,e))(nf||{}),rf=class{log(e){}},af=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}},sf=(e=>(e[e.SUCCESS=0]=`SUCCESS`,e))(sf||{}),cf=class{constructor(e,t){this._bindings=e,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}async query(e){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let t=await this._bindings.runQuery(this._conn,e),n=ld.from(t);return console.assert(n.isSync(),`Reader is not sync`),console.assert(n.isFile(),`Reader is not file`),new eu(n)}async send(e,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let n=await this._bindings.startPendingQuery(this._conn,e,t);for(;n==null;)n=await this._bindings.pollPendingQuery(this._conn);let r=new lf(this._bindings,this._conn,n),i=await ld.from(r);return console.assert(i.isAsync()),console.assert(i.isStream()),i}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(e){return await this._bindings.getTableNames(this._conn,e)}async prepare(e){let t=await this._bindings.createPrepared(this._conn,e);return new uf(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=Bd(e,`stream`);await this.insertArrowFromIPCStream(n,t)}async insertArrowFromIPCStream(e,t){await this._bindings.insertArrowFromIPCStream(this._conn,e,t)}async insertCSVFromPath(e,t){await this._bindings.insertCSVFromPath(this._conn,e,t)}async insertJSONFromPath(e,t){await this._bindings.insertJSONFromPath(this._conn,e,t)}},lf=class{constructor(e,t,n){this.db=e,this.conn=t,this.header=n,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 e;return this._inFlight==null?e=await this.db.fetchQueryResults(this.conn):(e=await this._inFlight,this._inFlight=null),this._depleted=e.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:e}}[Symbol.asyncIterator](){return this}},uf=class{constructor(e,t,n){this.bindings=e,this.connectionId=t,this.statementId=n}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...e){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,e),n=ld.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new eu(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new lf(this.bindings,this.connectionId,t),r=await ld.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},df=(e=>(e.CANCEL_PENDING_QUERY=`CANCEL_PENDING_QUERY`,e.CLOSE_PREPARED=`CLOSE_PREPARED`,e.COLLECT_FILE_STATISTICS=`COLLECT_FILE_STATISTICS`,e.REGISTER_OPFS_FILE_NAME=`REGISTER_OPFS_FILE_NAME`,e.CONNECT=`CONNECT`,e.COPY_FILE_TO_BUFFER=`COPY_FILE_TO_BUFFER`,e.COPY_FILE_TO_PATH=`COPY_FILE_TO_PATH`,e.CREATE_PREPARED=`CREATE_PREPARED`,e.DISCONNECT=`DISCONNECT`,e.DROP_FILE=`DROP_FILE`,e.DROP_FILES=`DROP_FILES`,e.EXPORT_FILE_STATISTICS=`EXPORT_FILE_STATISTICS`,e.FETCH_QUERY_RESULTS=`FETCH_QUERY_RESULTS`,e.FLUSH_FILES=`FLUSH_FILES`,e.GET_FEATURE_FLAGS=`GET_FEATURE_FLAGS`,e.GET_TABLE_NAMES=`GET_TABLE_NAMES`,e.GET_VERSION=`GET_VERSION`,e.GLOB_FILE_INFOS=`GLOB_FILE_INFOS`,e.INSERT_ARROW_FROM_IPC_STREAM=`INSERT_ARROW_FROM_IPC_STREAM`,e.INSERT_CSV_FROM_PATH=`IMPORT_CSV_FROM_PATH`,e.INSERT_JSON_FROM_PATH=`IMPORT_JSON_FROM_PATH`,e.INSTANTIATE=`INSTANTIATE`,e.OPEN=`OPEN`,e.PING=`PING`,e.POLL_PENDING_QUERY=`POLL_PENDING_QUERY`,e.REGISTER_FILE_BUFFER=`REGISTER_FILE_BUFFER`,e.REGISTER_FILE_HANDLE=`REGISTER_FILE_HANDLE`,e.REGISTER_FILE_URL=`REGISTER_FILE_URL`,e.RESET=`RESET`,e.RUN_PREPARED=`RUN_PREPARED`,e.RUN_QUERY=`RUN_QUERY`,e.SEND_PREPARED=`SEND_PREPARED`,e.START_PENDING_QUERY=`START_PENDING_QUERY`,e.TOKENIZE=`TOKENIZE`,e))(df||{}),ff=(e=>(e.CONNECTION_INFO=`CONNECTION_INFO`,e.ERROR=`ERROR`,e.FEATURE_FLAGS=`FEATURE_FLAGS`,e.FILE_BUFFER=`FILE_BUFFER`,e.FILE_INFOS=`FILE_INFOS`,e.FILE_SIZE=`FILE_SIZE`,e.FILE_STATISTICS=`FILE_STATISTICS`,e.INSTANTIATE_PROGRESS=`INSTANTIATE_PROGRESS`,e.LOG=`LOG`,e.OK=`OK`,e.PREPARED_STATEMENT_ID=`PREPARED_STATEMENT_ID`,e.QUERY_PLAN=`QUERY_PLAN`,e.QUERY_RESULT=`QUERY_RESULT`,e.QUERY_RESULT_CHUNK=`QUERY_RESULT_CHUNK`,e.QUERY_RESULT_HEADER=`QUERY_RESULT_HEADER`,e.QUERY_RESULT_HEADER_OR_NULL=`QUERY_RESULT_HEADER_OR_NULL`,e.REGISTERED_FILE=`REGISTERED_FILE`,e.SCRIPT_TOKENS=`SCRIPT_TOKENS`,e.SUCCESS=`SUCCESS`,e.TABLE_NAMES=`TABLE_NAMES`,e.VERSION_STRING=`VERSION_STRING`,e))(ff||{}),N=class{constructor(e,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=e,this.data=t,this.promise=new Promise((e,t)=>{this.promiseResolver=e,this.promiseRejecter=t})}};function pf(e){switch(e.typeId){case y.Binary:return{sqlType:`binary`};case y.Bool:return{sqlType:`bool`};case y.Date:return{sqlType:`date`};case y.DateDay:return{sqlType:`date32[d]`};case y.DateMillisecond:return{sqlType:`date64[ms]`};case y.Decimal:{let t=e;return{sqlType:`decimal`,precision:t.precision,scale:t.scale}}case y.Float:return{sqlType:`float`};case y.Float16:return{sqlType:`float16`};case y.Float32:return{sqlType:`float32`};case y.Float64:return{sqlType:`float64`};case y.Int:return{sqlType:`int32`};case y.Int16:return{sqlType:`int16`};case y.Int32:return{sqlType:`int32`};case y.Int64:return{sqlType:`int64`};case y.Uint16:return{sqlType:`uint16`};case y.Uint32:return{sqlType:`uint32`};case y.Uint64:return{sqlType:`uint64`};case y.Uint8:return{sqlType:`uint8`};case y.IntervalDayTime:return{sqlType:`interval[dt]`};case y.IntervalYearMonth:return{sqlType:`interval[m]`};case y.List:return{sqlType:`list`,valueType:pf(e.valueType)};case y.FixedSizeBinary:return{sqlType:`fixedsizebinary`,byteWidth:e.byteWidth};case y.Null:return{sqlType:`null`};case y.Utf8:return{sqlType:`utf8`};case y.Struct:return{sqlType:`struct`,fields:e.children.map(e=>mf(e.name,e.type))};case y.Map:{let t=e;return{sqlType:`map`,keyType:pf(t.keyType),valueType:pf(t.valueType)}}case y.Time:return{sqlType:`time[s]`};case y.TimeMicrosecond:return{sqlType:`time[us]`};case y.TimeMillisecond:return{sqlType:`time[ms]`};case y.TimeNanosecond:return{sqlType:`time[ns]`};case y.TimeSecond:return{sqlType:`time[s]`};case y.Timestamp:return{sqlType:`timestamp`,timezone:e.timezone||void 0};case y.TimestampSecond:return{sqlType:`timestamp[s]`,timezone:e.timezone||void 0};case y.TimestampMicrosecond:return{sqlType:`timestamp[us]`,timezone:e.timezone||void 0};case y.TimestampNanosecond:return{sqlType:`timestamp[ns]`,timezone:e.timezone||void 0};case y.TimestampMillisecond:return{sqlType:`timestamp[ms]`,timezone:e.timezone||void 0}}throw Error(`unsupported arrow type: ${e.toString()}`)}function mf(e,t){let n=pf(t);return n.name=e,n}var hf=new TextEncoder,gf=class{constructor(e,t=null){this._onInstantiationProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._logger=e,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}attach(e){this._worker=e,this._worker.addEventListener(`message`,this._onMessageHandler),this._worker.addEventListener(`error`,this._onErrorHandler),this._worker.addEventListener(`close`,this._onCloseHandler),this._workerShutdownPromise=new Promise((e,t)=>{this._workerShutdownResolver=e})}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(e,t=[]){if(!this._worker){console.error(`cannot send a message since the worker is not set!`);return}let n=this._nextMessageId++;return this._pendingRequests.set(n,e),this._worker.postMessage({messageId:n,type:e.type,data:e.data},t),await e.promise}onMessage(e){var t;let n=e.data;switch(n.type){case`LOG`:this._logger.log(n.data);return;case`INSTANTIATE_PROGRESS`:for(let e of this._onInstantiationProgress)e(n.data);return}let r=this._pendingRequests.get(n.requestId);if(!r){console.warn(`unassociated response: [${n.requestId}, ${n.type.toString()}]`);return}if(this._pendingRequests.delete(n.requestId),n.type==`ERROR`){let e=Error(n.data.message);e.name=n.data.name,(t=Object.getOwnPropertyDescriptor(e,`stack`))!=null&&t.writable&&(e.stack=n.data.stack),r.promiseRejecter(e);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(n.type==`OK`){r.promiseResolver(n.data);return}break;case`INSTANTIATE`:if(this._onInstantiationProgress=[],n.type==`OK`){r.promiseResolver(n.data);return}break;case`GLOB_FILE_INFOS`:if(n.type==`FILE_INFOS`){r.promiseResolver(n.data);return}break;case`GET_VERSION`:if(n.type==`VERSION_STRING`){r.promiseResolver(n.data);return}break;case`GET_FEATURE_FLAGS`:if(n.type==`FEATURE_FLAGS`){r.promiseResolver(n.data);return}break;case`GET_TABLE_NAMES`:if(n.type==`TABLE_NAMES`){r.promiseResolver(n.data);return}break;case`TOKENIZE`:if(n.type==`SCRIPT_TOKENS`){r.promiseResolver(n.data);return}break;case`COPY_FILE_TO_BUFFER`:if(n.type==`FILE_BUFFER`){r.promiseResolver(n.data);return}break;case`EXPORT_FILE_STATISTICS`:if(n.type==`FILE_STATISTICS`){r.promiseResolver(n.data);return}break;case`CONNECT`:if(n.type==`CONNECTION_INFO`){r.promiseResolver(n.data);return}break;case`RUN_PREPARED`:case`RUN_QUERY`:if(n.type==`QUERY_RESULT`){r.promiseResolver(n.data);return}break;case`SEND_PREPARED`:if(n.type==`QUERY_RESULT_HEADER`){r.promiseResolver(n.data);return}break;case`START_PENDING_QUERY`:if(n.type==`QUERY_RESULT_HEADER_OR_NULL`){r.promiseResolver(n.data);return}break;case`POLL_PENDING_QUERY`:if(n.type==`QUERY_RESULT_HEADER_OR_NULL`){r.promiseResolver(n.data);return}break;case`CANCEL_PENDING_QUERY`:if(this._onInstantiationProgress=[],n.type==`SUCCESS`){r.promiseResolver(n.data);return}break;case`FETCH_QUERY_RESULTS`:if(n.type==`QUERY_RESULT_CHUNK`){r.promiseResolver(n.data);return}break;case`CREATE_PREPARED`:if(n.type==`PREPARED_STATEMENT_ID`){r.promiseResolver(n.data);return}break}r.promiseRejecter(Error(`unexpected response type: ${n.type.toString()}`))}onError(e){console.error(e),console.error(`error in duckdb worker: ${e.message}`),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn(`worker terminated with ${this._pendingRequests.size} pending requests`);return}this._pendingRequests.clear()}async reset(){let e=new N(`RESET`,null);return await this.postTask(e)}async ping(){let e=new N(`PING`,null);await this.postTask(e)}async dropFile(e){let t=new N(`DROP_FILE`,e);return await this.postTask(t)}async dropFiles(){let e=new N(`DROP_FILES`,null);return await this.postTask(e)}async flushFiles(){let e=new N(`FLUSH_FILES`,null);return await this.postTask(e)}async instantiate(e,t=null,n=e=>{}){this._onInstantiationProgress.push(n);let r=new N(`INSTANTIATE`,[e,t]);return await this.postTask(r)}async getVersion(){let e=new N(`GET_VERSION`,null);return await this.postTask(e)}async getFeatureFlags(){let e=new N(`GET_FEATURE_FLAGS`,null);return await this.postTask(e)}async open(e){let t=new N(`OPEN`,e);await this.postTask(t)}async tokenize(e){let t=new N(`TOKENIZE`,e);return await this.postTask(t)}async connectInternal(){let e=new N(`CONNECT`,null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new cf(this,e)}async disconnect(e){let t=new N(`DISCONNECT`,e);await this.postTask(t)}async runQuery(e,t){let n=new N(`RUN_QUERY`,[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){let r=new N(`START_PENDING_QUERY`,[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new N(`POLL_PENDING_QUERY`,e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new N(`CANCEL_PENDING_QUERY`,e);return await this.postTask(t)}async fetchQueryResults(e){let t=new N(`FETCH_QUERY_RESULTS`,e);return await this.postTask(t)}async getTableNames(e,t){let n=new N(`GET_TABLE_NAMES`,[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new N(`CREATE_PREPARED`,[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new N(`CLOSE_PREPARED`,[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new N(`RUN_PREPARED`,[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new N(`SEND_PREPARED`,[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new N(`GLOB_FILE_INFOS`,e);return await this.postTask(t)}async registerFileText(e,t){let n=hf.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new N(`REGISTER_FILE_URL`,[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new N(`REGISTER_FILE_BUFFER`,[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new N(`REGISTER_FILE_HANDLE`,[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new N(`REGISTER_OPFS_FILE_NAME`,[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new N(`COLLECT_FILE_STATISTICS`,[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new N(`EXPORT_FILE_STATISTICS`,e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new N(`COPY_FILE_TO_BUFFER`,e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new N(`COPY_FILE_TO_PATH`,[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new N(`INSERT_ARROW_FROM_IPC_STREAM`,[e,t,n]);await this.postTask(r,[t.buffer])}async insertCSVFromPath(e,t,n){if(n.columns!==void 0){let e=[];for(let t in n.columns){let r=n.columns[t];e.push(mf(t,r))}n.columnsFlat=e,delete n.columns}let r=new N(`IMPORT_CSV_FROM_PATH`,[e,t,n]);await this.postTask(r)}async insertJSONFromPath(e,t,n){if(n.columns!==void 0){let e=[];for(let t in n.columns){let r=n.columns[t];e.push(mf(t,r))}n.columnsFlat=e,delete n.columns}let r=new N(`IMPORT_JSON_FROM_PATH`,[e,t,n]);await this.postTask(r)}};function _f(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<`u`&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}_f();var vf=(e=>(e[e.BUFFER=0]=`BUFFER`,e[e.NODE_FS=1]=`NODE_FS`,e[e.BROWSER_FILEREADER=2]=`BROWSER_FILEREADER`,e[e.BROWSER_FSACCESS=3]=`BROWSER_FSACCESS`,e[e.HTTP=4]=`HTTP`,e[e.S3=5]=`S3`,e))(vf||{}),yf=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])),bf=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])),xf=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])),Sf=()=>(async e=>{try{return typeof MessageChannel<`u`&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}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])),Cf={name:`@duckdb/duckdb-wasm`,version:`1.29.1-dev68.0`,description:`DuckDB powered by WebAssembly`,license:`MIT`,repository:{type:`git`,url:`https://github.com/duckdb/duckdb-wasm.git`},keywords:[`sql`,`duckdb`,`relational`,`database`,`data`,`query`,`wasm`,`analytics`,`olap`,`arrow`,`parquet`,`json`,`csv`],dependencies:{"apache-arrow":`^17.0.0`},devDependencies:{"@types/emscripten":`^1.39.10`,"@types/jasmine":`^5.1.4`,"@typescript-eslint/eslint-plugin":`^6.21.0`,"@typescript-eslint/parser":`^6.21.0`,esbuild:`^0.20.2`,eslint:`^8.57.0`,"eslint-plugin-jasmine":`^4.1.3`,"eslint-plugin-react":`^7.34.0`,"fast-glob":`^3.3.2`,jasmine:`^5.1.0`,"jasmine-core":`^5.1.2`,"jasmine-spec-reporter":`^7.0.0`,"js-sha256":`^0.11.0`,karma:`^6.4.2`,"karma-chrome-launcher":`^3.2.0`,"karma-coverage":`^2.2.1`,"karma-firefox-launcher":`^2.1.3`,"karma-jasmine":`^5.1.0`,"karma-jasmine-html-reporter":`^2.1.0`,"karma-sourcemap-loader":`^0.4.0`,"karma-spec-reporter":`^0.0.36`,"make-dir":`^4.0.0`,nyc:`^15.1.0`,prettier:`^3.2.5`,puppeteer:`^22.8.0`,rimraf:`^5.0.5`,s3rver:`^3.7.1`,typedoc:`^0.25.13`,typescript:`^5.3.3`,"wasm-feature-detect":`^1.6.1`,"web-worker":`^1.2.0`},scripts:{"build:debug":`node bundle.mjs debug && tsc --emitDeclarationOnly`,"build:release":`node bundle.mjs release && tsc --emitDeclarationOnly`,docs:`typedoc`,report:`node ./coverage.mjs`,"test:node":`node --enable-source-maps ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs`,"test:node:debug":`node --inspect-brk --enable-source-maps ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs`,"test:node:coverage":`nyc -r json --report-dir ./coverage/node node ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs`,"test:firefox":`karma start ./karma/tests-firefox.cjs`,"test:chrome":`karma start ./karma/tests-chrome.cjs`,"test:chrome:eh":`karma start ./karma/tests-chrome-eh.cjs`,"test:chrome:coverage":`karma start ./karma/tests-chrome-coverage.cjs`,"test:browser":`karma start ./karma/tests-all.cjs`,"test:browser:debug":`karma start ./karma/tests-debug.cjs`,test:`npm run test:chrome && npm run test:node`,"test:coverage":`npm run test:chrome:coverage && npm run test:node:coverage && npm run report`,lint:`eslint src test`},files:[`dist`,`!dist/tests-*`,`!dist/duckdb-browser-mvp.worker.js.map`,`!dist/types/test`],main:`dist/duckdb-browser.cjs`,module:`dist/duckdb-browser.mjs`,types:`dist/duckdb-browser.d.ts`,jsdelivr:`dist/duckdb-browser.cjs`,unpkg:`dist/duckdb-browser.mjs`,sideEffects:!1,browser:{fs:!1,path:!1,perf_hooks:!1,os:!1,worker_threads:!1},exports:{"./dist/duckdb-mvp.wasm":`./dist/duckdb-mvp.wasm`,"./dist/duckdb-eh.wasm":`./dist/duckdb-eh.wasm`,"./dist/duckdb-coi.wasm":`./dist/duckdb-coi.wasm`,"./dist/duckdb-browser":`./dist/duckdb-browser.mjs`,"./dist/duckdb-browser.cjs":`./dist/duckdb-browser.cjs`,"./dist/duckdb-browser.mjs":`./dist/duckdb-browser.mjs`,"./dist/duckdb-browser-coi.pthread.worker.js":`./dist/duckdb-browser-coi.pthread.worker.js`,"./dist/duckdb-browser-coi.worker.js":`./dist/duckdb-browser-coi.worker.js`,"./dist/duckdb-browser-eh.worker.js":`./dist/duckdb-browser-eh.worker.js`,"./dist/duckdb-browser-mvp.worker.js":`./dist/duckdb-browser-mvp.worker.js`,"./dist/duckdb-node":`./dist/duckdb-node.cjs`,"./dist/duckdb-node.cjs":`./dist/duckdb-node.cjs`,"./dist/duckdb-node-blocking":`./dist/duckdb-node-blocking.cjs`,"./dist/duckdb-node-blocking.cjs":`./dist/duckdb-node-blocking.cjs`,"./dist/duckdb-node-eh.worker.cjs":`./dist/duckdb-node-eh.worker.cjs`,"./dist/duckdb-node-mvp.worker.cjs":`./dist/duckdb-node-mvp.worker.cjs`,"./blocking":{node:{types:`./dist/duckdb-node-blocking.d.ts`,require:`./dist/duckdb-node-blocking.cjs`,import:`./dist/duckdb-node-blocking.cjs`},types:`./dist/duckdb-node-blocking.d.ts`,import:`./dist/duckdb-node-blocking.mjs`,require:`./dist/duckdb-node-blocking.cjs`},".":{browser:{types:`./dist/duckdb-browser.d.ts`,import:`./dist/duckdb-browser.mjs`,require:`./dist/duckdb-browser.cjs`},node:{types:`./dist/duckdb-node.d.ts`,import:`./dist/duckdb-node.cjs`,require:`./dist/duckdb-node.cjs`},types:`./dist/duckdb-browser.d.ts`,import:`./dist/duckdb-browser.mjs`,require:`./dist/duckdb-browser.cjs`}}};Cf.name,Cf.version;var wf=Cf.version.split(`.`);wf[0],wf[1],wf[2];var Tf=()=>typeof navigator>`u`,Ef=null,Df=null,Of=null,kf=null,Af=null;async function jf(){return Ef??=typeof BigInt64Array<`u`,Df??=await bf(),Of??=await Sf(),kf??=await xf(),Af??=await yf(),{bigInt64Array:Ef,crossOriginIsolated:Tf()||globalThis.crossOriginIsolated||!1,wasmExceptions:Df,wasmSIMD:kf,wasmThreads:Of,wasmBulkMemory:Af}}async function Mf(e){let t=await jf();if(t.wasmExceptions){if(t.wasmSIMD&&t.wasmThreads&&t.crossOriginIsolated&&e.coi)return{mainModule:e.coi.mainModule,mainWorker:e.coi.mainWorker,pthreadWorker:e.coi.pthreadWorker};if(e.eh)return{mainModule:e.eh.mainModule,mainWorker:e.eh.mainWorker,pthreadWorker:null}}return{mainModule:e.mvp.mainModule,mainWorker:e.mvp.mainWorker,pthreadWorker:null}}Yd(Xd());const Nf={},Pf={};function Ff(e,t){try{let n=Nf[e]||=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`longOffset`}).format,r=n(t).split(`GMT`)[1];return r in Pf?Pf[r]:Lf(r,r.split(`:`))}catch{if(e in Pf)return Pf[e];let t=e?.match(If);return t?Lf(e,t.slice(1)):NaN}}const If=/([+-]\d\d):?(\d\d)?/;function Lf(e,t){let n=+(t[0]||0),r=+(t[1]||0),i=(t[2]||0)/60;return Pf[e]=n*60+r>0?n*60+r+i:n*60-r-i}var Rf=class e extends Date{constructor(...e){super(),e.length>1&&typeof e[e.length-1]==`string`&&(this.timeZone=e.pop()),this.internal=new Date,isNaN(Ff(this.timeZone,this))?this.setTime(NaN):e.length?typeof e[0]==`number`&&(e.length===1||e.length===2&&typeof e[1]!=`number`)?this.setTime(e[0]):typeof e[0]==`string`?this.setTime(+new Date(e[0])):e[0]instanceof Date?this.setTime(+e[0]):(this.setTime(+new Date(...e)),Hf(this,NaN),Bf(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}withTimeZone(t){return new e(+this,t)}getTimezoneOffset(){let e=-Ff(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),Bf(this),+this}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}};const zf=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!zf.test(e))return;let t=e.replace(zf,`$1UTC`);Rf.prototype[t]&&(e.startsWith(`get`)?Rf.prototype[e]=function(){return this.internal[t]()}:(Rf.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),Vf(this),+this},Rf.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),Bf(this),+this}))});function Bf(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-Ff(e.timeZone,e)*60))}function Vf(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),Hf(e)}function Hf(e){let t=Ff(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);let i=-new Date(+e).getTimezoneOffset(),a=-new Date(+r).getTimezoneOffset(),o=i-a,s=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();o&&s&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+o);let c=i-n;c&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+c);let l=new Date(+e);l.setUTCSeconds(0);let u=i>0?l.getSeconds():(l.getSeconds()-60)%60,d=Math.round(-(Ff(e.timeZone,e)*60))%60;(d||u)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+d),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+d+u));let ee=Ff(e.timeZone,e),te=ee>0?Math.floor(ee):Math.ceil(ee),ne=-new Date(+e).getTimezoneOffset(),re=ne-te,ie=te!==n,ae=re-c;if(ie&&ae){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+ae);let t=Ff(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=te-n;r&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+r),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+r))}}const Uf=new TextDecoder(`utf-8`),Wf=e=>Uf.decode(e),Gf=new TextEncoder,Kf=e=>Gf.encode(e),qf=e=>typeof e==`function`,Jf=e=>e!=null&&Object(e)===e,Yf=e=>Jf(e)&&qf(e.then),Xf=e=>Jf(e)&&qf(e[Symbol.iterator]),Zf=e=>Jf(e)&&qf(e[Symbol.asyncIterator]),Qf=e=>Jf(e)&&`done`in e&&`value`in e,$f=e=>Jf(e)&&qf(e.clear)&&qf(e.bytes)&&qf(e.position)&&qf(e.setPosition)&&qf(e.capacity)&&qf(e.getBufferIdentifier)&&qf(e.createLong);var ep={};we(ep,{compareArrayLike:()=>Rp,joinUint8Arrays:()=>ip,memcpy:()=>rp,rebaseValueOffsets:()=>Lp,toArrayBufferView:()=>P,toArrayBufferViewAsyncIterator:()=>Dp,toArrayBufferViewIterator:()=>_p,toBigInt64Array:()=>cp,toBigUint64Array:()=>fp,toFloat32Array:()=>pp,toFloat32ArrayAsyncIterator:()=>Pp,toFloat32ArrayIterator:()=>wp,toFloat64Array:()=>mp,toFloat64ArrayAsyncIterator:()=>Fp,toFloat64ArrayIterator:()=>Tp,toInt16Array:()=>op,toInt16ArrayAsyncIterator:()=>kp,toInt16ArrayIterator:()=>yp,toInt32Array:()=>sp,toInt32ArrayAsyncIterator:()=>Ap,toInt32ArrayIterator:()=>bp,toInt8Array:()=>ap,toInt8ArrayAsyncIterator:()=>Op,toInt8ArrayIterator:()=>vp,toUint16Array:()=>up,toUint16ArrayAsyncIterator:()=>Mp,toUint16ArrayIterator:()=>Sp,toUint32Array:()=>dp,toUint32ArrayAsyncIterator:()=>Np,toUint32ArrayIterator:()=>Cp,toUint8Array:()=>lp,toUint8ArrayAsyncIterator:()=>jp,toUint8ArrayIterator:()=>xp,toUint8ClampedArray:()=>hp,toUint8ClampedArrayAsyncIterator:()=>Ip,toUint8ClampedArrayIterator:()=>Ep});const tp=typeof SharedArrayBuffer<`u`?SharedArrayBuffer:ArrayBuffer;function np(e){let t=e[0]?[e[0]]:[],n,r,i,a;for(let o,s,c=0,l=0,u=e.length;++ce+t.byteLength,0),i,a,o,s=0,c=-1,l=Math.min(t||1/0,r);for(let e=n.length;++cP(Int8Array,e),op=e=>P(Int16Array,e),sp=e=>P(Int32Array,e),cp=e=>P(BigInt64Array,e),lp=e=>P(Uint8Array,e),up=e=>P(Uint16Array,e),dp=e=>P(Uint32Array,e),fp=e=>P(BigUint64Array,e),pp=e=>P(Float32Array,e),mp=e=>P(Float64Array,e),hp=e=>P(Uint8ClampedArray,e),gp=e=>(e.next(),e);function*_p(e,t){let n=function*(e){yield e},r=typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof tp?n(t):Xf(t)?t:n(t);return yield*gp((function*(t){let n=null;do n=t.next(yield P(e,n));while(!n.done)})(r[Symbol.iterator]())),new e}const vp=e=>_p(Int8Array,e),yp=e=>_p(Int16Array,e),bp=e=>_p(Int32Array,e),xp=e=>_p(Uint8Array,e),Sp=e=>_p(Uint16Array,e),Cp=e=>_p(Uint32Array,e),wp=e=>_p(Float32Array,e),Tp=e=>_p(Float64Array,e),Ep=e=>_p(Uint8ClampedArray,e);function Dp(e,t){return cr(this,arguments,function*(){if(Yf(t))return yield m(yield m(yield*lr(ur(Dp(e,yield m(t))))));let n=function(e){return cr(this,arguments,function*(){yield yield m(yield m(e))})},r=function(e){return cr(this,arguments,function*(){yield m(yield*lr(ur(gp((function*(e){let t=null;do t=e.next(yield t?.value);while(!t.done)})(e[Symbol.iterator]())))))})},i=typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof tp?n(t):Xf(t)?r(t):Zf(t)?t:n(t);return yield m(yield*lr(ur(gp((function(t){return cr(this,arguments,function*(){let n=null;do n=yield m(t.next(yield yield m(P(e,n))));while(!n.done)})})(i[Symbol.asyncIterator]()))))),yield m(new e)})}const Op=e=>Dp(Int8Array,e),kp=e=>Dp(Int16Array,e),Ap=e=>Dp(Int32Array,e),jp=e=>Dp(Uint8Array,e),Mp=e=>Dp(Uint16Array,e),Np=e=>Dp(Uint32Array,e),Pp=e=>Dp(Float32Array,e),Fp=e=>Dp(Float64Array,e),Ip=e=>Dp(Uint8ClampedArray,e);function Lp(e,t,n){if(e!==0){n=n.slice(0,t);for(let t=-1,r=n.length;++t0)do if(e[n]!==t[n])return!1;while(++nGp});function Gp(e){if(e===null)return`null`;if(e===void 0)return`undefined`;switch(typeof e){case`number`:return`${e}`;case`bigint`:return`${e}`;case`string`:return`"${e}"`}return typeof e[Symbol.toPrimitive]==`function`?e[Symbol.toPrimitive](`string`):ArrayBuffer.isView(e)?e instanceof BigInt64Array||e instanceof BigUint64Array?`[${[...e].map(e=>Gp(e))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(e,t)=>typeof t==`bigint`?`${t}`:t)}function Kp(e){if(typeof e==`bigint`&&(e<-(2**53-1)||e>2**53-1))throw TypeError(`${e} is not safe to convert to a number.`);return Number(e)}function qp(e,t){return Kp(e/t)+Kp(e%t)/Kp(t)}var Jp={};we(Jp,{BN:()=>om,bigNumToBigInt:()=>im,bigNumToNumber:()=>nm,bigNumToString:()=>rm,isArrowBigNumSymbol:()=>Yp});const Yp=Symbol.for(`isArrowBigNum`);function Xp(e,...t){return t.length===0?Object.setPrototypeOf(P(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}Xp.prototype[Yp]=!0,Xp.prototype.toJSON=function(){return`"${rm(this)}"`},Xp.prototype.valueOf=function(e){return nm(this,e)},Xp.prototype.toString=function(){return rm(this)},Xp.prototype[Symbol.toPrimitive]=function(e=`default`){switch(e){case`number`:return nm(this);case`string`:return rm(this);case`default`:return im(this)}return rm(this)};function Zp(...e){return Xp.apply(this,e)}function Qp(...e){return Xp.apply(this,e)}function $p(...e){return Xp.apply(this,e)}Object.setPrototypeOf(Zp.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(Qp.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf($p.prototype,Object.create(Uint32Array.prototype)),Object.assign(Zp.prototype,Xp.prototype,{constructor:Zp,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(Qp.prototype,Xp.prototype,{constructor:Qp,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign($p.prototype,Xp.prototype,{constructor:$p,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const em=BigInt(4294967296)*BigInt(4294967296),tm=em-BigInt(1);function nm(e,t){let{buffer:n,byteOffset:r,byteLength:i,signed:a}=e,o=new BigUint64Array(n,r,i/8),s=a&&o.at(-1)&BigInt(1)<0){let e=BigInt(`1`.padEnd(t+1,`0`)),n=c/e,r=s?-(c%e):c%e,i=Kp(n),a=`${r}`.padStart(t,`0`),o=s&&i===0?`-`:``;return+`${o}${i}.${a}`}return Kp(c)}function rm(e){if(e.byteLength===8){let t=new e.BigIntArray(e.buffer,e.byteOffset,1);return`${t[0]}`}if(!e.signed)return am(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),n=new Int16Array([t.at(-1)])[0];if(n>=0)return am(e);t=t.slice();let r=1;for(let e=0;e(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]=`DataType`))(L.prototype);var km=class extends L{constructor(){super(I.Null)}toString(){return`Null`}};cm=Symbol.toStringTag,km[cm]=(e=>e[Symbol.toStringTag]=`Null`)(km.prototype);var Am=class extends L{constructor(e,t){super(I.Int),this.isSigned=e,this.bitWidth=t}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 Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?`I`:`Ui`}nt${this.bitWidth}`}};lm=Symbol.toStringTag,Am[lm]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]=`Int`))(Am.prototype);var jm=class extends Am{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},Mm=class extends Am{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},Nm=class extends Am{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Pm=class extends Am{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},Fm=class extends Am{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},Im=class extends Am{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},Lm=class extends Am{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},Rm=class extends Am{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(jm.prototype,`ArrayType`,{value:Int8Array}),Object.defineProperty(Mm.prototype,`ArrayType`,{value:Int16Array}),Object.defineProperty(Nm.prototype,`ArrayType`,{value:Int32Array}),Object.defineProperty(Pm.prototype,`ArrayType`,{value:BigInt64Array}),Object.defineProperty(Fm.prototype,`ArrayType`,{value:Uint8Array}),Object.defineProperty(Im.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(Lm.prototype,`ArrayType`,{value:Uint32Array}),Object.defineProperty(Rm.prototype,`ArrayType`,{value:BigUint64Array});var zm=class extends L{constructor(e){super(I.Float),this.precision=e}get ArrayType(){switch(this.precision){case Bp.HALF:return Uint16Array;case Bp.SINGLE:return Float32Array;case Bp.DOUBLE:return Float64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};um=Symbol.toStringTag,zm[um]=(e=>(e.precision=null,e[Symbol.toStringTag]=`Float`))(zm.prototype);var Bm=class extends zm{constructor(){super(Bp.HALF)}},Vm=class extends zm{constructor(){super(Bp.SINGLE)}},Hm=class extends zm{constructor(){super(Bp.DOUBLE)}};Object.defineProperty(Bm.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(Vm.prototype,`ArrayType`,{value:Float32Array}),Object.defineProperty(Hm.prototype,`ArrayType`,{value:Float64Array});var Um=class extends L{constructor(){super(I.Binary)}toString(){return`Binary`}};dm=Symbol.toStringTag,Um[dm]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Binary`))(Um.prototype);var Wm=class extends L{constructor(){super(I.LargeBinary)}toString(){return`LargeBinary`}};fm=Symbol.toStringTag,Wm[fm]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeBinary`))(Wm.prototype);var Gm=class extends L{constructor(){super(I.Utf8)}toString(){return`Utf8`}};pm=Symbol.toStringTag,Gm[pm]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Utf8`))(Gm.prototype);var Km=class extends L{constructor(){super(I.LargeUtf8)}toString(){return`LargeUtf8`}};mm=Symbol.toStringTag,Km[mm]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeUtf8`))(Km.prototype);var qm=class extends L{constructor(){super(I.Bool)}toString(){return`Bool`}};hm=Symbol.toStringTag,qm[hm]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Bool`))(qm.prototype);var Jm=class extends L{constructor(e,t,n=128){super(I.Decimal),this.scale=e,this.precision=t,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?`+`:``}${this.scale}]`}};gm=Symbol.toStringTag,Jm[gm]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]=`Decimal`))(Jm.prototype);var Ym=class extends L{constructor(e){super(I.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${Vp[this.unit]}>`}get ArrayType(){return this.unit===Vp.DAY?Int32Array:BigInt64Array}};_m=Symbol.toStringTag,Ym[_m]=(e=>(e.unit=null,e[Symbol.toStringTag]=`Date`))(Ym.prototype);var Xm=class extends L{constructor(e,t){super(I.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${F[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};vm=Symbol.toStringTag,Xm[vm]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]=`Time`))(Xm.prototype);var Zm=class extends L{constructor(e,t){super(I.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${F[this.unit]}${this.timezone?`, ${this.timezone}`:``}>`}};ym=Symbol.toStringTag,Zm[ym]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Timestamp`))(Zm.prototype);var Qm=class extends L{constructor(e){super(I.Interval),this.unit=e}toString(){return`Interval<${Hp[this.unit]}>`}};bm=Symbol.toStringTag,Qm[bm]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]=`Interval`))(Qm.prototype);var $m=class extends L{constructor(e){super(I.Duration),this.unit=e}toString(){return`Duration<${F[this.unit]}>`}};xm=Symbol.toStringTag,$m[xm]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Duration`))($m.prototype);var eh=class extends L{constructor(e){super(I.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};Sm=Symbol.toStringTag,eh[Sm]=(e=>(e.children=null,e[Symbol.toStringTag]=`List`))(eh.prototype);var th=class extends L{constructor(e){super(I.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};Cm=Symbol.toStringTag,th[Cm]=(e=>(e.children=null,e[Symbol.toStringTag]=`Struct`))(th.prototype);var nh=class extends L{constructor(e,t,n){super(I.Union),this.mode=e,this.children=n,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((e,t,n)=>(e[t]=n)&&e||e,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(` | `)}>`}};wm=Symbol.toStringTag,nh[wm]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]=`Union`))(nh.prototype);var rh=class extends L{constructor(e){super(I.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};Tm=Symbol.toStringTag,rh[Tm]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`FixedSizeBinary`))(rh.prototype);var ih=class extends L{constructor(e,t){super(I.FixedSizeList),this.listSize=e,this.children=[t]}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}>`}};Em=Symbol.toStringTag,ih[Em]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]=`FixedSizeList`))(ih.prototype);var ah=class extends L{constructor(e,t=!1){var n,r,i;if(super(I.Map),this.children=[e],this.keysSorted=t,e&&(e.name=`entries`,(n=e?.type)?.children)){let t=(r=e?.type)?.children[0];t&&(t.name=`key`);let n=(i=e?.type)?.children[1];n&&(n.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(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};Dm=Symbol.toStringTag,ah[Dm]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]=`Map_`))(ah.prototype);const oh=(e=>()=>++e)(-1);var sh=class extends L{constructor(e,t,n,r){super(I.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=r||!1,this.id=n==null?oh():Kp(n)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};Om=Symbol.toStringTag,sh[Om]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]=`Dictionary`))(sh.prototype);function ch(e){let t=e;switch(e.typeId){case I.Decimal:return e.bitWidth/32;case I.Interval:return t.unit===Hp.MONTH_DAY_NANO?4:1+t.unit;case I.FixedSizeList:return t.listSize;case I.FixedSizeBinary:return t.byteWidth;default:return 1}}var R=class{visitMany(e,...t){return e.map((e,n)=>this.visit(e,...t.map(e=>e[n])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return lh(this,e,t)}getVisitFnByTypeId(e,t=!0){return uh(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}};function lh(e,t,n=!0){return typeof t==`number`?uh(e,t,n):typeof t==`string`&&t in I?uh(e,I[t],n):t&&t instanceof L?uh(e,dh(t),n):t?.type&&t.type instanceof L?uh(e,dh(t.type),n):uh(e,I.NONE,n)}function uh(e,t,n=!0){let r=null;switch(t){case I.Null:r=e.visitNull;break;case I.Bool:r=e.visitBool;break;case I.Int:r=e.visitInt;break;case I.Int8:r=e.visitInt8||e.visitInt;break;case I.Int16:r=e.visitInt16||e.visitInt;break;case I.Int32:r=e.visitInt32||e.visitInt;break;case I.Int64:r=e.visitInt64||e.visitInt;break;case I.Uint8:r=e.visitUint8||e.visitInt;break;case I.Uint16:r=e.visitUint16||e.visitInt;break;case I.Uint32:r=e.visitUint32||e.visitInt;break;case I.Uint64:r=e.visitUint64||e.visitInt;break;case I.Float:r=e.visitFloat;break;case I.Float16:r=e.visitFloat16||e.visitFloat;break;case I.Float32:r=e.visitFloat32||e.visitFloat;break;case I.Float64:r=e.visitFloat64||e.visitFloat;break;case I.Utf8:r=e.visitUtf8;break;case I.LargeUtf8:r=e.visitLargeUtf8;break;case I.Binary:r=e.visitBinary;break;case I.LargeBinary:r=e.visitLargeBinary;break;case I.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case I.Date:r=e.visitDate;break;case I.DateDay:r=e.visitDateDay||e.visitDate;break;case I.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case I.Timestamp:r=e.visitTimestamp;break;case I.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case I.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case I.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case I.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case I.Time:r=e.visitTime;break;case I.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case I.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case I.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case I.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case I.Decimal:r=e.visitDecimal;break;case I.List:r=e.visitList;break;case I.Struct:r=e.visitStruct;break;case I.Union:r=e.visitUnion;break;case I.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case I.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case I.Dictionary:r=e.visitDictionary;break;case I.Interval:r=e.visitInterval;break;case I.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case I.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case I.IntervalMonthDayNano:r=e.visitIntervalMonthDayNano||e.visitInterval;break;case I.Duration:r=e.visitDuration;break;case I.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case I.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case I.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case I.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case I.FixedSizeList:r=e.visitFixedSizeList;break;case I.Map:r=e.visitMap;break}if(typeof r==`function`)return r;if(!n)return()=>null;throw Error(`Unrecognized type '${I[t]}'`)}function dh(e){switch(e.typeId){case I.Null:return I.Null;case I.Int:{let{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?I.Int8:I.Uint8;case 16:return n?I.Int16:I.Uint16;case 32:return n?I.Int32:I.Uint32;case 64:return n?I.Int64:I.Uint64}return I.Int}case I.Float:switch(e.precision){case Bp.HALF:return I.Float16;case Bp.SINGLE:return I.Float32;case Bp.DOUBLE:return I.Float64}return I.Float;case I.Binary:return I.Binary;case I.LargeBinary:return I.LargeBinary;case I.Utf8:return I.Utf8;case I.LargeUtf8:return I.LargeUtf8;case I.Bool:return I.Bool;case I.Decimal:return I.Decimal;case I.Time:switch(e.unit){case F.SECOND:return I.TimeSecond;case F.MILLISECOND:return I.TimeMillisecond;case F.MICROSECOND:return I.TimeMicrosecond;case F.NANOSECOND:return I.TimeNanosecond}return I.Time;case I.Timestamp:switch(e.unit){case F.SECOND:return I.TimestampSecond;case F.MILLISECOND:return I.TimestampMillisecond;case F.MICROSECOND:return I.TimestampMicrosecond;case F.NANOSECOND:return I.TimestampNanosecond}return I.Timestamp;case I.Date:switch(e.unit){case Vp.DAY:return I.DateDay;case Vp.MILLISECOND:return I.DateMillisecond}return I.Date;case I.Interval:switch(e.unit){case Hp.DAY_TIME:return I.IntervalDayTime;case Hp.YEAR_MONTH:return I.IntervalYearMonth;case Hp.MONTH_DAY_NANO:return I.IntervalMonthDayNano}return I.Interval;case I.Duration:switch(e.unit){case F.SECOND:return I.DurationSecond;case F.MILLISECOND:return I.DurationMillisecond;case F.MICROSECOND:return I.DurationMicrosecond;case F.NANOSECOND:return I.DurationNanosecond}return I.Duration;case I.Map:return I.Map;case I.List:return I.List;case I.Struct:return I.Struct;case I.Union:switch(e.mode){case zp.Dense:return I.DenseUnion;case zp.Sparse:return I.SparseUnion}return I.Union;case I.FixedSizeBinary:return I.FixedSizeBinary;case I.FixedSizeList:return I.FixedSizeList;case I.Dictionary:return I.Dictionary}throw Error(`Unrecognized type '${I[e.typeId]}'`)}R.prototype.visitInt8=null,R.prototype.visitInt16=null,R.prototype.visitInt32=null,R.prototype.visitInt64=null,R.prototype.visitUint8=null,R.prototype.visitUint16=null,R.prototype.visitUint32=null,R.prototype.visitUint64=null,R.prototype.visitFloat16=null,R.prototype.visitFloat32=null,R.prototype.visitFloat64=null,R.prototype.visitDateDay=null,R.prototype.visitDateMillisecond=null,R.prototype.visitTimestampSecond=null,R.prototype.visitTimestampMillisecond=null,R.prototype.visitTimestampMicrosecond=null,R.prototype.visitTimestampNanosecond=null,R.prototype.visitTimeSecond=null,R.prototype.visitTimeMillisecond=null,R.prototype.visitTimeMicrosecond=null,R.prototype.visitTimeNanosecond=null,R.prototype.visitDenseUnion=null,R.prototype.visitSparseUnion=null,R.prototype.visitIntervalDayTime=null,R.prototype.visitIntervalYearMonth=null,R.prototype.visitIntervalMonthDayNano=null,R.prototype.visitDuration=null,R.prototype.visitDurationSecond=null,R.prototype.visitDurationMillisecond=null,R.prototype.visitDurationMicrosecond=null,R.prototype.visitDurationNanosecond=null;var fh={};we(fh,{float64ToUint16:()=>gh,uint16ToFloat64:()=>hh});const ph=new Float64Array(1),mh=new Uint32Array(ph.buffer);function hh(e){let t=(e&31744)>>10,n=(e&1023)/1024,r=(-1)**((e&32768)>>15);switch(t){case 31:return r*(n?NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*2**(t-15)*(1+n)}function gh(e){if(e!==e)return 32256;ph[0]=e;let t=(mh[1]&2147483648)>>16&65535,n=mh[1]&2146435072,r=0;return n>=1089470464?mh[0]>0?n=31744:(n=(n&2080374784)>>16,r=(mh[1]&1048575)>>10):n<=1056964608?(r=1048576+(mh[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(mh[1]&1048575)+512>>10),t|n|r&65535}var z=class extends R{};function B(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const _h=(e,t,n)=>{e[t]=Math.floor(n/864e5)},vh=(e,t,n,r)=>{if(n+1{let i=e+n;r?t[i>>3]|=1<>3]&=~(1<{e[t]=n},xh=({values:e},t,n)=>{e[t]=n},Sh=({values:e},t,n)=>{e[t]=gh(n)},Ch=(e,t,n)=>{switch(e.type.precision){case Bp.HALF:return Sh(e,t,n);case Bp.SINGLE:case Bp.DOUBLE:return xh(e,t,n)}},wh=({values:e},t,n)=>{_h(e,t,n.valueOf())},Th=({values:e},t,n)=>{e[t]=BigInt(n)},Eh=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},Dh=({values:e,valueOffsets:t},n,r)=>vh(e,t,n,r),Oh=({values:e,valueOffsets:t},n,r)=>vh(e,t,n,Kf(r)),kh=(e,t,n)=>{e.type.unit===Vp.DAY?wh(e,t,n):Th(e,t,n)},Ah=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},jh=({values:e},t,n)=>{e[t]=BigInt(n)},Mh=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},Nh=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},Ph=(e,t,n)=>{switch(e.type.unit){case F.SECOND:return Ah(e,t,n);case F.MILLISECOND:return jh(e,t,n);case F.MICROSECOND:return Mh(e,t,n);case F.NANOSECOND:return Nh(e,t,n)}},Fh=({values:e},t,n)=>{e[t]=n},Ih=({values:e},t,n)=>{e[t]=n},Lh=({values:e},t,n)=>{e[t]=n},Rh=({values:e},t,n)=>{e[t]=n},zh=(e,t,n)=>{switch(e.type.unit){case F.SECOND:return Fh(e,t,n);case F.MILLISECOND:return Ih(e,t,n);case F.MICROSECOND:return Lh(e,t,n);case F.NANOSECOND:return Rh(e,t,n)}},Bh=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},Vh=(e,t,n)=>{let r=e.children[0],i=e.valueOffsets,a=cg.getVisitFn(r);if(Array.isArray(n))for(let e=-1,o=i[t],s=i[t+1];o{let r=e.children[0],{valueOffsets:i}=e,a=cg.getVisitFn(r),{[t]:o,[t+1]:s}=i,c=n instanceof Map?n.entries():Object.entries(n);for(let e of c)if(a(r,o,e),++o>=s)break},Uh=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[a]),Wh=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(a)),Gh=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(i.name)),Kh=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[i.name]),qh=(e,t,n)=>{let r=e.type.children.map(e=>cg.getVisitFn(e.type)),i=n instanceof Map?Gh(t,n):n instanceof rv?Wh(t,n):Array.isArray(n)?Uh(t,n):Kh(t,n);e.type.children.forEach((t,n)=>i(r[n],e.children[n],t,n))},Jh=(e,t,n)=>{e.type.mode===zp.Dense?Yh(e,t,n):Xh(e,t,n)},Yh=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];cg.visit(i,e.valueOffsets[t],n)},Xh=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];cg.visit(i,t,n)},Zh=(e,t,n)=>{var r;(r=e.dictionary)==null||r.set(e.values[t],n)},Qh=(e,t,n)=>{switch(e.type.unit){case Hp.YEAR_MONTH:return eg(e,t,n);case Hp.DAY_TIME:return $h(e,t,n);case Hp.MONTH_DAY_NANO:return tg(e,t,n)}},$h=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},eg=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},tg=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},ng=({values:e},t,n)=>{e[t]=n},rg=({values:e},t,n)=>{e[t]=n},ig=({values:e},t,n)=>{e[t]=n},ag=({values:e},t,n)=>{e[t]=n},og=(e,t,n)=>{switch(e.type.unit){case F.SECOND:return ng(e,t,n);case F.MILLISECOND:return rg(e,t,n);case F.MICROSECOND:return ig(e,t,n);case F.NANOSECOND:return ag(e,t,n)}},sg=(e,t,n)=>{let{stride:r}=e,i=e.children[0],a=cg.getVisitFn(i);if(Array.isArray(n))for(let e=-1,o=t*r;++e`${Gp(e)}: ${Gp(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}[Symbol.iterator](){return new fg(this[lg],this[ug])}},fg=class{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let e=this.childIndex;return ee.name)}has(e,t){return e[lg].type.children.some(e=>e.name===t)}getOwnPropertyDescriptor(e,t){if(e[lg].type.children.some(e=>e.name===t))return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let n=e[lg].type.children.findIndex(e=>e.name===t);if(n!==-1){let r=i_.visit(e[lg].children[n],e[ug]);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[lg].type.children.findIndex(e=>e.name===t);return r===-1?Reflect.has(e,t)||typeof t==`symbol`?Reflect.set(e,t,n):!1:(cg.visit(e[lg].children[r],e[ug],n),Reflect.set(e,t,n))}};const mg=new pg;var V=class extends R{};function H(e){return(t,n)=>t.getValid(n)?e(t,n):null}const hg=(e,t)=>864e5*e[t],gg=(e,t)=>null,_g=(e,t,n)=>{if(n+1>=t.length)return null;let r=Kp(t[n]),i=Kp(t[n+1]);return e.subarray(r,i)},vg=({offset:e,values:t},n)=>{let r=e+n,i=t[r>>3];return(i&1<hg(e,t),bg=({values:e},t)=>Kp(e[t]),xg=({stride:e,values:t},n)=>t[e*n],Sg=({stride:e,values:t},n)=>hh(t[e*n]),Cg=({values:e},t)=>e[t],wg=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),Tg=({values:e,valueOffsets:t},n)=>_g(e,t,n),Eg=({values:e,valueOffsets:t},n)=>{let r=_g(e,t,n);return r===null?null:Wf(r)},Dg=({values:e},t)=>e[t],Og=({type:e,values:t},n)=>e.precision===Bp.HALF?hh(t[n]):t[n],kg=(e,t)=>e.type.unit===Vp.DAY?yg(e,t):bg(e,t),Ag=({values:e},t)=>1e3*Kp(e[t]),jg=({values:e},t)=>Kp(e[t]),Mg=({values:e},t)=>qp(e[t],BigInt(1e3)),Ng=({values:e},t)=>qp(e[t],BigInt(1e6)),Pg=(e,t)=>{switch(e.type.unit){case F.SECOND:return Ag(e,t);case F.MILLISECOND:return jg(e,t);case F.MICROSECOND:return Mg(e,t);case F.NANOSECOND:return Ng(e,t)}},Fg=({values:e},t)=>e[t],Ig=({values:e},t)=>e[t],Lg=({values:e},t)=>e[t],Rg=({values:e},t)=>e[t],zg=(e,t)=>{switch(e.type.unit){case F.SECOND:return Fg(e,t);case F.MILLISECOND:return Ig(e,t);case F.MICROSECOND:return Lg(e,t);case F.NANOSECOND:return Rg(e,t)}},Bg=({values:e,stride:t},n)=>om.decimal(e.subarray(t*n,t*(n+1))),Vg=(e,t)=>{let{valueOffsets:n,stride:r,children:i}=e,{[t*r]:a,[t*r+1]:o}=n,s=i[0],c=s.slice(a,o-a);return new rv([c])},Hg=(e,t)=>{let{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:a}=n,o=r[0];return new l_(o.slice(i,a-i))},Ug=(e,t)=>new dg(e,t),Wg=(e,t)=>e.type.mode===zp.Dense?Gg(e,t):Kg(e,t),Gg=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return i_.visit(r,e.valueOffsets[t])},Kg=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return i_.visit(r,t)},qg=(e,t)=>{var n;return(n=e.dictionary)?.get(e.values[t])},Jg=(e,t)=>e.type.unit===Hp.MONTH_DAY_NANO?Zg(e,t):e.type.unit===Hp.DAY_TIME?Yg(e,t):Xg(e,t),Yg=({values:e},t)=>e.subarray(2*t,2*(t+1)),Xg=({values:e},t)=>{let n=e[t],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},Zg=({values:e},t)=>e.subarray(4*t,4*(t+1)),Qg=({values:e},t)=>e[t],$g=({values:e},t)=>e[t],e_=({values:e},t)=>e[t],t_=({values:e},t)=>e[t],n_=(e,t)=>{switch(e.type.unit){case F.SECOND:return Qg(e,t);case F.MILLISECOND:return $g(e,t);case F.MICROSECOND:return e_(e,t);case F.NANOSECOND:return t_(e,t)}},r_=(e,t)=>{let{stride:n,children:r}=e,i=r[0],a=i.slice(t*n,n);return new rv([a])};V.prototype.visitNull=H(gg),V.prototype.visitBool=H(vg),V.prototype.visitInt=H(Dg),V.prototype.visitInt8=H(xg),V.prototype.visitInt16=H(xg),V.prototype.visitInt32=H(xg),V.prototype.visitInt64=H(Cg),V.prototype.visitUint8=H(xg),V.prototype.visitUint16=H(xg),V.prototype.visitUint32=H(xg),V.prototype.visitUint64=H(Cg),V.prototype.visitFloat=H(Og),V.prototype.visitFloat16=H(Sg),V.prototype.visitFloat32=H(xg),V.prototype.visitFloat64=H(xg),V.prototype.visitUtf8=H(Eg),V.prototype.visitLargeUtf8=H(Eg),V.prototype.visitBinary=H(Tg),V.prototype.visitLargeBinary=H(Tg),V.prototype.visitFixedSizeBinary=H(wg),V.prototype.visitDate=H(kg),V.prototype.visitDateDay=H(yg),V.prototype.visitDateMillisecond=H(bg),V.prototype.visitTimestamp=H(Pg),V.prototype.visitTimestampSecond=H(Ag),V.prototype.visitTimestampMillisecond=H(jg),V.prototype.visitTimestampMicrosecond=H(Mg),V.prototype.visitTimestampNanosecond=H(Ng),V.prototype.visitTime=H(zg),V.prototype.visitTimeSecond=H(Fg),V.prototype.visitTimeMillisecond=H(Ig),V.prototype.visitTimeMicrosecond=H(Lg),V.prototype.visitTimeNanosecond=H(Rg),V.prototype.visitDecimal=H(Bg),V.prototype.visitList=H(Vg),V.prototype.visitStruct=H(Ug),V.prototype.visitUnion=H(Wg),V.prototype.visitDenseUnion=H(Gg),V.prototype.visitSparseUnion=H(Kg),V.prototype.visitDictionary=H(qg),V.prototype.visitInterval=H(Jg),V.prototype.visitIntervalDayTime=H(Yg),V.prototype.visitIntervalYearMonth=H(Xg),V.prototype.visitIntervalMonthDayNano=H(Zg),V.prototype.visitDuration=H(n_),V.prototype.visitDurationSecond=H(Qg),V.prototype.visitDurationMillisecond=H($g),V.prototype.visitDurationMicrosecond=H(e_),V.prototype.visitDurationNanosecond=H(t_),V.prototype.visitFixedSizeList=H(r_),V.prototype.visitMap=H(Hg);const i_=new V,a_=Symbol.for(`keys`),o_=Symbol.for(`vals`),s_=Symbol.for(`kKeysAsStrings`),c_=Symbol.for(`_kKeysAsStrings`);var l_=class{constructor(e){return this[a_]=new rv([e.children[0]]).memoize(),this[o_]=e.children[1],new Proxy(this,new d_)}get[s_](){return this[c_]||(this[c_]=Array.from(this[a_].toArray(),String))}[Symbol.iterator](){return new u_(this[a_],this[o_])}get size(){return this[a_].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[a_],t=this[o_],n={};for(let r=-1,i=e.length;++r`${Gp(e)}: ${Gp(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}},u_=class{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){let e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),i_.visit(this.vals,e)]})}},d_=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[s_]}has(e,t){return e[s_].includes(t)}getOwnPropertyDescriptor(e,t){let n=e[s_].indexOf(t);if(n!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let n=e[s_].indexOf(t);if(n!==-1){let r=i_.visit(Reflect.get(e,o_),n);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[s_].indexOf(t);return r===-1?Reflect.has(e,t)?Reflect.set(e,t,n):!1:(cg.visit(Reflect.get(e,o_),r,n),Reflect.set(e,t,n))}};Object.defineProperties(l_.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[a_]:{writable:!0,enumerable:!1,configurable:!1,value:null},[o_]:{writable:!0,enumerable:!1,configurable:!1,value:null},[c_]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var f_={};we(f_,{clampRange:()=>m_,createElementComparator:()=>__,wrapIndex:()=>h_});let p_;function m_(e,t,n,r){let{length:i=0}=e,a=typeof t==`number`?t:0,o=typeof n==`number`?n:i;return a<0&&(a=(a%i+i)%i),o<0&&(o=(o%i+i)%i),oi&&(o=i),r?r(e,a,o):[a,o]}const h_=(e,t)=>e<0?t+e:e,g_=e=>e!==e;function __(e){let t=typeof e;if(t!==`object`||e===null)return g_(e)?g_:t=>t===e;if(e instanceof Date){let t=e.valueOf();return e=>e instanceof Date?e.valueOf()===t:!1}return ArrayBuffer.isView(e)?t=>t?Rp(e,t):!1:e instanceof Map?y_(e):Array.isArray(e)?v_(e):e instanceof rv?b_(e):x_(e,!0)}function v_(e){let t=[];for(let n=-1,r=e.length;++n!1;let r=[];for(let t=-1,i=n.length;++t{if(!n||typeof n!=`object`)return!1;switch(n.constructor){case Array:return C_(e,n);case Map:return T_(e,n,n.keys());case l_:case dg:case Object:case void 0:return T_(e,n,t||Object.keys(n))}return n instanceof rv?w_(e,n):!1}}function C_(e,t){let n=e.length;if(t.length!==n)return!1;for(let r=-1;++rM_,getBit:()=>O_,getBool:()=>D_,packBools:()=>j_,popcnt_array:()=>P_,popcnt_bit_range:()=>N_,popcnt_uint32:()=>F_,setBool:()=>k_,truncateBitmap:()=>A_});function D_(e,t,n,r){return(n&1<>r}function k_(e,t,n){return n?!!(e[t>>3]|=1<>3]&=~(1<0||n.byteLength>3):j_(new M_(n,e,t,null,D_)).subarray(0,r)),i}return n}function j_(e){let t=[],n=0,r=0,i=0;for(let a of e)a&&(i|=1<0)&&(t[n++]=i);let a=new Uint8Array(t.length+7&-8);return a.set(t),a}var M_=class{constructor(e,t,n,r,i){this.bytes=e,this.length=n,this.context=r,this.get=i,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=t+(t%8==0?0:8-t%8);return N_(e,t,i)+N_(e,r,n)+P_(e,i>>3,r-i>>3)}function P_(e,t,n){let r=0,i=Math.trunc(t),a=new DataView(e.buffer,e.byteOffset,e.byteLength),o=n===void 0?e.byteLength:i+n;for(;o-i>=4;)r+=F_(a.getUint32(i)),i+=4;for(;o-i>=2;)r+=F_(a.getUint16(i)),i+=2;for(;o-i>=1;)r+=F_(a.getUint8(i)),i+=1;return r}function F_(e){let t=Math.trunc(e);return t-=t>>>1&1431655765,t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var I_=class e{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:e}=this;return L.isSparseUnion(e)||L.isDenseUnion(e)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0,{valueOffsets:t,values:n,nullBitmap:r,typeIds:i}=this;return t&&(e+=t.byteLength),n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),this.children.reduce((e,t)=>e+t.byteLength,e)}get nullCount(){if(L.isUnion(this.type))return this.children.reduce((e,t)=>e+t.nullCount,0);let e=this._nullCount,t;return e<=-1&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-N_(t,this.offset,this.offset+this.length)),e}constructor(t,n,r,i,a,o=[],s){this.type=t,this.children=o,this.dictionary=s,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let c;a instanceof e?(this.stride=a.stride,this.values=a.values,this.typeIds=a.typeIds,this.nullBitmap=a.nullBitmap,this.valueOffsets=a.valueOffsets):(this.stride=ch(t),a&&((c=a[0])&&(this.valueOffsets=c),(c=a[1])&&(this.values=c),(c=a[2])&&(this.nullBitmap=c),(c=a[3])&&(this.typeIds=c)))}getValid(e){let{type:t}=this;if(L.isUnion(t)){let n=t,r=this.children[n.typeIdToChildIndex[this.typeIds[e]]],i=n.mode===zp.Dense?this.valueOffsets[e]:e;return r.getValid(i)}if(this.nullable&&this.nullCount>0){let t=this.offset+e,n=this.nullBitmap[t>>3];return(n&1<>3;(!r||r.byteLength<=c)&&(r=new Uint8Array((i+a+63&-64)>>3).fill(255),this.nullCount>0?(r.set(A_(i,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:r})):Object.assign(this,{nullBitmap:r,_nullCount:0}));let l=r[c];n=(l&s)!==0,r[c]=t?l|s:l&~s}return n!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(t=this.type,n=this.offset,r=this.length,i=this._nullCount,a=this,o=this.children){return new e(t,n,r,i,a,o,this.dictionary)}slice(e,t){let{stride:n,typeId:r,children:i}=this,a=(this._nullCount===0)-1,o=r===16?n:1,s=this._sliceBuffers(e,t,n,r);return this.clone(this.type,this.offset+e,t,a,s,i.length===0||this.valueOffsets?i:this._sliceChildren(i,o*e,o*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===I.Null)return this.clone(this.type,0,e,0);let{length:t,nullCount:n}=this,r=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);r[t>>3]=(1<0&&r.set(A_(this.offset,t,this.nullBitmap),0);let i=this.buffers;return i[Up.VALIDITY]=r,this.clone(this.type,0,e,n+(e-t),i)}_sliceBuffers(e,t,n,r){let i,{buffers:a}=this;return(i=a[Up.TYPE])&&(a[Up.TYPE]=i.subarray(e,e+t)),(i=a[Up.OFFSET])&&(a[Up.OFFSET]=i.subarray(e,e+t+1))||(i=a[Up.DATA])&&(a[Up.DATA]=r===6?i:i.subarray(n*e,n*(e+t))),a}_sliceChildren(e,t,n){return e.map(e=>e.slice(t,n))}};I_.prototype.children=Object.freeze([]);var L_=class e extends R{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{type:t,offset:n=0,length:r=0}=e;return new I_(t,n,r,r)}visitBool(e){let{type:t,offset:n=0}=e,r=lp(e.nullBitmap),i=P(t.ArrayType,e.data),{length:a=i.length>>3,nullCount:o=e.nullBitmap?-1:0}=e;return new I_(t,n,a,o,[void 0,i,r])}visitInt(e){let{type:t,offset:n=0}=e,r=lp(e.nullBitmap),i=P(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new I_(t,n,a,o,[void 0,i,r])}visitFloat(e){let{type:t,offset:n=0}=e,r=lp(e.nullBitmap),i=P(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new I_(t,n,a,o,[void 0,i,r])}visitUtf8(e){let{type:t,offset:n=0}=e,r=lp(e.data),i=lp(e.nullBitmap),a=sp(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new I_(t,n,o,s,[a,r,i])}visitLargeUtf8(e){let{type:t,offset:n=0}=e,r=lp(e.data),i=lp(e.nullBitmap),a=cp(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new I_(t,n,o,s,[a,r,i])}visitBinary(e){let{type:t,offset:n=0}=e,r=lp(e.data),i=lp(e.nullBitmap),a=sp(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new I_(t,n,o,s,[a,r,i])}visitLargeBinary(e){let{type:t,offset:n=0}=e,r=lp(e.data),i=lp(e.nullBitmap),a=cp(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new I_(t,n,o,s,[a,r,i])}visitFixedSizeBinary(e){let{type:t,offset:n=0}=e,r=lp(e.nullBitmap),i=P(t.ArrayType,e.data),{length:a=i.length/ch(t),nullCount:o=e.nullBitmap?-1:0}=e;return new I_(t,n,a,o,[void 0,i,r])}visitDate(e){let{type:t,offset:n=0}=e,r=lp(e.nullBitmap),i=P(t.ArrayType,e.data),{length:a=i.length/ch(t),nullCount:o=e.nullBitmap?-1:0}=e;return new I_(t,n,a,o,[void 0,i,r])}visitTimestamp(e){let{type:t,offset:n=0}=e,r=lp(e.nullBitmap),i=P(t.ArrayType,e.data),{length:a=i.length/ch(t),nullCount:o=e.nullBitmap?-1:0}=e;return new I_(t,n,a,o,[void 0,i,r])}visitTime(e){let{type:t,offset:n=0}=e,r=lp(e.nullBitmap),i=P(t.ArrayType,e.data),{length:a=i.length/ch(t),nullCount:o=e.nullBitmap?-1:0}=e;return new I_(t,n,a,o,[void 0,i,r])}visitDecimal(e){let{type:t,offset:n=0}=e,r=lp(e.nullBitmap),i=P(t.ArrayType,e.data),{length:a=i.length/ch(t),nullCount:o=e.nullBitmap?-1:0}=e;return new I_(t,n,a,o,[void 0,i,r])}visitList(e){let{type:t,offset:n=0,child:r}=e,i=lp(e.nullBitmap),a=sp(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new I_(t,n,o,s,[a,void 0,i],[r])}visitStruct(e){let{type:t,offset:n=0,children:r=[]}=e,i=lp(e.nullBitmap),{length:a=r.reduce((e,{length:t})=>Math.max(e,t),0),nullCount:o=e.nullBitmap?-1:0}=e;return new I_(t,n,a,o,[void 0,void 0,i],r)}visitUnion(e){let{type:t,offset:n=0,children:r=[]}=e,i=P(t.ArrayType,e.typeIds),{length:a=i.length,nullCount:o=-1}=e;if(L.isSparseUnion(t))return new I_(t,n,a,o,[void 0,void 0,void 0,i],r);let s=sp(e.valueOffsets);return new I_(t,n,a,o,[s,void 0,void 0,i],r)}visitDictionary(t){let{type:n,offset:r=0}=t,i=lp(t.nullBitmap),a=P(n.indices.ArrayType,t.data),{dictionary:o=new rv([new e().visit({type:n.dictionary})])}=t,{length:s=a.length,nullCount:c=t.nullBitmap?-1:0}=t;return new I_(n,r,s,c,[void 0,a,i],[],o)}visitInterval(e){let{type:t,offset:n=0}=e,r=lp(e.nullBitmap),i=P(t.ArrayType,e.data),{length:a=i.length/ch(t),nullCount:o=e.nullBitmap?-1:0}=e;return new I_(t,n,a,o,[void 0,i,r])}visitDuration(e){let{type:t,offset:n=0}=e,r=lp(e.nullBitmap),i=P(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new I_(t,n,a,o,[void 0,i,r])}visitFixedSizeList(t){let{type:n,offset:r=0,child:i=new e().visit({type:n.valueType})}=t,a=lp(t.nullBitmap),{length:o=i.length/ch(n),nullCount:s=t.nullBitmap?-1:0}=t;return new I_(n,r,o,s,[void 0,void 0,a],[i])}visitMap(t){let{type:n,offset:r=0,child:i=new e().visit({type:n.childType})}=t,a=lp(t.nullBitmap),o=sp(t.valueOffsets),{length:s=o.length-1,nullCount:c=t.nullBitmap?-1:0}=t;return new I_(n,r,s,c,[o,void 0,a],[i])}};new L_;var R_=class{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function B_(e){return e.reduce((e,t)=>e+t.nullCount,0)}function V_(e){return e.reduce((e,t,n)=>(e[n+1]=e[n]+t.length,e),new Uint32Array(e.length+1))}function H_(e,t,n,r){let i=[];for(let a=-1,o=e.length;++a=r)break;if(n>=s+c)continue;if(s>=n&&s+c<=r){i.push(o);continue}let l=Math.max(0,n-s),u=Math.min(r-s,c);i.push(o.slice(l,u-l))}return i.length===0&&i.push(e[0].slice(0,0)),i}function U_(e,t,n,r){let i=0,a=0,o=t.length-1;do{if(i>=o-1)return n0?0:-1}function Y_(e,t){let{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(let i of new M_(n,e.offset+(t||0),e.length,n,D_)){if(!i)return r;++r}return-1}function W(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case I.Union:break;case I.Dictionary:break;default:return Y_(e,n)}let r=i_.getVisitFn(e),i=__(t);for(let t=(n||0)-1,a=e.length;++t{let n=e.data[t];return n.values.subarray(0,n.length)[Symbol.iterator]()});let n=0;return new R_(e.data.length,t=>{let r=e.data[t],i=r.length,a=e.slice(n,n+i);return n+=i,new Q_(a)})}var Q_=class{constructor(e){this.vector=e,this.index=0}next(){return this.indexe.data):t;if(a.length===0||a.some(e=>!(e instanceof I_)))throw TypeError(`Vector constructor expects an Array of Data instances.`);let o=(n=a[0])?.type;switch(a.length){case 0:this._offsets=[0];break;case 1:{let{get:e,set:t,indexOf:n}=tv[o.typeId],r=a[0];this.isValid=e=>W_(r,e),this.get=t=>e(r,t),this.set=(e,n)=>t(r,e,n),this.indexOf=e=>n(r,e),this._offsets=[0,r.length];break}default:Object.setPrototypeOf(this,nv[o.typeId]),this._offsets=V_(a);break}this.data=a,this.type=o,this.stride=ch(o),this.numChildren=(i=(r=o.children)?.length)??0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return z_(this.data)}get nullCount(){return B_(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${I[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(h_(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return $_.visit(this)}concat(...t){return new e(this.data.concat(t.flatMap(e=>e.data).flat(1/0)))}slice(t,n){return new e(m_(this,t,n,({data:e,_offsets:t},n,r)=>H_(e,t,n,r)))}toJSON(){return[...this]}toArray(){let{type:e,data:t,length:n,stride:r,ArrayType:i}=this;switch(e.typeId){case I.Int:case I.Float:case I.Decimal:case I.Time:case I.Timestamp:switch(t.length){case 0:return new i;case 1:return t[0].values.subarray(0,n*r);default:return t.reduce((e,{values:t,length:n})=>(e.array.set(t.subarray(0,n*r),e.offset),e.offset+=n*r,e),{array:new i(n*r),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(`,`)}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)?.findIndex(t=>t.name===e))}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)){let t=new iv(this.data[0].dictionary),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return new iv(this)}unmemoize(){if(L.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return this}};ev=Symbol.toStringTag,rv[ev]=(e=>{e.type=L.prototype,e.data=[],e.length=0,e.stride=1,e.numChildren=0,e._offsets=new Uint32Array([0]),e[Symbol.isConcatSpreadable]=!0;let t=Object.keys(I).map(e=>I[e]).filter(e=>typeof e==`number`&&e!==I.NONE);for(let n of t){let t=i_.getVisitFnByTypeId(n),r=cg.getVisitFnByTypeId(n),i=Z_.getVisitFnByTypeId(n);tv[n]={get:t,set:r,indexOf:i},nv[n]=Object.create(e,{isValid:{value:G_(W_)},get:{value:G_(i_.getVisitFnByTypeId(n))},set:{value:K_(cg.getVisitFnByTypeId(n))},indexOf:{value:q_(Z_.getVisitFnByTypeId(n))}})}return`Vector`})(rv.prototype);var iv=class e extends rv{constructor(t){super(t.data);let n=this.get,r=this.set,i=this.slice,a=Array(this.length);Object.defineProperty(this,`get`,{value(e){let t=a[e];if(t!==void 0)return t;let r=n.call(this,e);return a[e]=r,r}}),Object.defineProperty(this,`set`,{value(e,t){r.call(this,e,t),a[e]=t}}),Object.defineProperty(this,`slice`,{value:(t,n)=>new e(i.call(this,t,n))}),Object.defineProperty(this,`isMemoized`,{value:!0}),Object.defineProperty(this,`unmemoize`,{value:()=>new rv(this.data)}),Object.defineProperty(this,`memoize`,{value:()=>this})}},av={};we(av,{BaseInt64:()=>cv,Int128:()=>dv,Int64:()=>uv,Uint64:()=>lv});function ov(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}const sv=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];var cv=class{constructor(e){this.buffer=e}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(e){let t=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]),r=t[3]*n[3];this.buffer[0]=r&65535;let i=r>>>16;return r=t[2]*n[3],i+=r,r=t[3]*n[2]>>>0,i+=r,this.buffer[0]+=i<<16,this.buffer[1]=i>>>0>>16,this.buffer[1]+=t[1]*n[3]+t[2]*n[2]+t[3]*n[1],this.buffer[1]+=t[0]*n[3]+t[1]*n[2]+t[2]*n[1]+t[3]*n[0]<<16,this}_plus(e){let t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${ov(this.buffer[3])} ${ov(this.buffer[2])} ${ov(this.buffer[1])} ${ov(this.buffer[0])}`}static multiply(t,n){let r=new e(new Uint32Array(t.buffer));return r.times(n)}static add(t,n){let r=new e(new Uint32Array(t.buffer));return r.plus(n)}static from(t,n=new Uint32Array(4)){return e.fromString(typeof t==`string`?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return e.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){let r=t.startsWith(`-`),i=t.length,a=new e(n);for(let n=r?1:0;npv,toIntervalDayTimeObjects:()=>hv,toIntervalMonthDayNanoInt32Array:()=>mv,toIntervalMonthDayNanoObjects:()=>gv});function pv(e){var t,n;let r=e.length,i=new Int32Array(r*2);for(let a=0,o=0;a>BigInt(32))):o+=2}return i}function hv(e){let t=e.length,n=Array(t/2);for(let r=0,i=0;r>>0);r[a++]={months:e[i],days:e[i+1],nanoseconds:t?`${n}`:n}}return r}var q=class extends R{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>this.compareFields(e,t[n]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}};function _v(e,t){return t instanceof e.constructor}function vv(e,t){return e===t||_v(e,t)}function yv(e,t){return e===t||_v(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function bv(e,t){return e===t||_v(e,t)&&e.precision===t.precision}function xv(e,t){return e===t||_v(e,t)&&e.byteWidth===t.byteWidth}function Sv(e,t){return e===t||_v(e,t)&&e.unit===t.unit}function Cv(e,t){return e===t||_v(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function wv(e,t){return e===t||_v(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function Tv(e,t){return e===t||_v(e,t)&&e.children.length===t.children.length&&Nv.compareManyFields(e.children,t.children)}function Ev(e,t){return e===t||_v(e,t)&&e.children.length===t.children.length&&Nv.compareManyFields(e.children,t.children)}function Dv(e,t){return e===t||_v(e,t)&&e.mode===t.mode&&e.typeIds.every((e,n)=>e===t.typeIds[n])&&Nv.compareManyFields(e.children,t.children)}function Ov(e,t){return e===t||_v(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&Nv.visit(e.indices,t.indices)&&Nv.visit(e.dictionary,t.dictionary)}function kv(e,t){return e===t||_v(e,t)&&e.unit===t.unit}function Av(e,t){return e===t||_v(e,t)&&e.unit===t.unit}function jv(e,t){return e===t||_v(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&Nv.compareManyFields(e.children,t.children)}function Mv(e,t){return e===t||_v(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&Nv.compareManyFields(e.children,t.children)}q.prototype.visitNull=vv,q.prototype.visitBool=vv,q.prototype.visitInt=yv,q.prototype.visitInt8=yv,q.prototype.visitInt16=yv,q.prototype.visitInt32=yv,q.prototype.visitInt64=yv,q.prototype.visitUint8=yv,q.prototype.visitUint16=yv,q.prototype.visitUint32=yv,q.prototype.visitUint64=yv,q.prototype.visitFloat=bv,q.prototype.visitFloat16=bv,q.prototype.visitFloat32=bv,q.prototype.visitFloat64=bv,q.prototype.visitUtf8=vv,q.prototype.visitLargeUtf8=vv,q.prototype.visitBinary=vv,q.prototype.visitLargeBinary=vv,q.prototype.visitFixedSizeBinary=xv,q.prototype.visitDate=Sv,q.prototype.visitDateDay=Sv,q.prototype.visitDateMillisecond=Sv,q.prototype.visitTimestamp=Cv,q.prototype.visitTimestampSecond=Cv,q.prototype.visitTimestampMillisecond=Cv,q.prototype.visitTimestampMicrosecond=Cv,q.prototype.visitTimestampNanosecond=Cv,q.prototype.visitTime=wv,q.prototype.visitTimeSecond=wv,q.prototype.visitTimeMillisecond=wv,q.prototype.visitTimeMicrosecond=wv,q.prototype.visitTimeNanosecond=wv,q.prototype.visitDecimal=vv,q.prototype.visitList=Tv,q.prototype.visitStruct=Ev,q.prototype.visitUnion=Dv,q.prototype.visitDenseUnion=Dv,q.prototype.visitSparseUnion=Dv,q.prototype.visitDictionary=Ov,q.prototype.visitInterval=kv,q.prototype.visitIntervalDayTime=kv,q.prototype.visitIntervalYearMonth=kv,q.prototype.visitIntervalMonthDayNano=kv,q.prototype.visitDuration=Av,q.prototype.visitDurationSecond=Av,q.prototype.visitDurationMillisecond=Av,q.prototype.visitDurationMicrosecond=Av,q.prototype.visitDurationNanosecond=Av,q.prototype.visitFixedSizeList=jv,q.prototype.visitMap=Mv;const Nv=new q;function Pv(e,t){return Nv.compareSchemas(e,t)}function Fv(e,t){return Nv.compareFields(e,t)}function Iv(e,t){return Nv.visit(e,t)}const Lv=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Jp),av),E_),fh),ep),f_),Wp),fv),{compareSchemas:Pv,compareFields:Fv,compareTypes:Iv}),Rv=6048e5,zv=3600*24;zv*7,zv*365.2425;const Bv=Symbol.for(`constructDateFrom`);function Vv(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&Bv in e?e[Bv](t):e instanceof Date?new e.constructor(t):new Date(t)}function Hv(e,t){return Vv(t||e,e)}let Uv={};function Wv(){return Uv}function Gv(e,t){let n=Wv(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Hv(e,t?.in),a=i.getDay(),o=(a=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function Jv(e){let t=Hv(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function Yv(e,...t){let n=Vv.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function Xv(e,t){let n=Hv(e,t?.in);return n.setHours(0,0,0,0),n}function Zv(e,t,n){let[r,i]=Yv(n?.in,e,t),a=Xv(r),o=Xv(i),s=+a-Jv(a),c=+o-Jv(o);return Math.round((s-c)/864e5)}function Qv(e,t){let n=qv(e,t),r=Vv(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),Kv(r)}function $v(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function ey(e){return!(!$v(e)&&typeof e!=`number`||isNaN(+Hv(e)))}function ty(e,t){let n=Hv(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const ny={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},ry=(e,t,n)=>{let r,i=ny[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r};function iy(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth,r=e.formats[n]||e.formats[e.defaultWidth];return r}}const ay={full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},oy={full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},sy={full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},cy={date:iy({formats:ay,defaultWidth:`full`}),time:iy({formats:oy,defaultWidth:`full`}),dateTime:iy({formats:sy,defaultWidth:`full`})},ly={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},uy=(e,t,n,r)=>ly[e];function dy(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}const fy={narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},py={narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},my={narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},hy={narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},gy={narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},_y={narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},vy=(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},yy={ordinalNumber:vy,era:dy({values:fy,defaultWidth:`wide`}),quarter:dy({values:py,defaultWidth:`wide`,argumentCallback:e=>e-1}),month:dy({values:my,defaultWidth:`wide`}),day:dy({values:hy,defaultWidth:`wide`}),dayPeriod:dy({values:gy,defaultWidth:`wide`,formattingValues:_y,defaultFormattingWidth:`wide`})};function by(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?Sy(s,e=>e.test(o)):xy(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function xy(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function Sy(e,t){for(let n=0;n{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}const wy=/^(\d+)(th|st|nd|rd)?/i,Ty=/\d+/i,Ey={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Dy={any:[/^b/i,/^(a|c)/i]},Oy={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ky={any:[/1/i,/2/i,/3/i,/4/i]},Ay={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},jy={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},My={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Ny={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Py={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Fy={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Iy={ordinalNumber:Cy({matchPattern:wy,parsePattern:Ty,valueCallback:e=>parseInt(e,10)}),era:by({matchPatterns:Ey,defaultMatchWidth:`wide`,parsePatterns:Dy,defaultParseWidth:`any`}),quarter:by({matchPatterns:Oy,defaultMatchWidth:`wide`,parsePatterns:ky,defaultParseWidth:`any`,valueCallback:e=>e+1}),month:by({matchPatterns:Ay,defaultMatchWidth:`wide`,parsePatterns:jy,defaultParseWidth:`any`}),day:by({matchPatterns:My,defaultMatchWidth:`wide`,parsePatterns:Ny,defaultParseWidth:`any`}),dayPeriod:by({matchPatterns:Py,defaultMatchWidth:`any`,parsePatterns:Fy,defaultParseWidth:`any`})},Ly={code:`en-US`,formatDistance:ry,formatLong:cy,formatRelative:uy,localize:yy,match:Iy,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Ry(e,t){let n=Hv(e,t?.in),r=Zv(n,ty(n)),i=r+1;return i}function zy(e,t){let n=Hv(e,t?.in),r=Kv(n)-+Qv(n);return Math.round(r/Rv)+1}function By(e,t){let n=Hv(e,t?.in),r=n.getFullYear(),i=Wv(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=Vv(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=Gv(o,t),c=Vv(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=Gv(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function Vy(e,t){let n=Wv(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=By(e,t),a=Vv(t?.in||e,0);a.setFullYear(i,0,r),a.setHours(0,0,0,0);let o=Gv(a,t);return o}function Hy(e,t){let n=Hv(e,t?.in),r=Gv(n,t)-+Vy(n,t);return Math.round(r/Rv)+1}function J(e,t){let n=e<0?`-`:``,r=Math.abs(e).toString().padStart(t,`0`);return n+r}const Uy={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return J(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):J(n+1,2)},d(e,t){return J(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];case`aaaa`:default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return J(e.getHours()%12||12,t.length)},H(e,t){return J(e.getHours(),t.length)},m(e,t){return J(e.getMinutes(),t.length)},s(e,t){return J(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*10**(n-3));return J(i,t.length)}},Wy={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},Gy={G:function(e,t,n){let r=e.getFullYear()>0?1:0;switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});case`GGGG`:default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return Uy.y(e,t)},Y:function(e,t,n,r){let i=By(e,r),a=i>0?i:1-i;if(t===`YY`){let e=a%100;return J(e,2)}return t===`Yo`?n.ordinalNumber(a,{unit:`year`}):J(a,t.length)},R:function(e,t){let n=qv(e);return J(n,t.length)},u:function(e,t){let n=e.getFullYear();return J(n,t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return J(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});case`QQQQ`:default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return J(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});case`qqqq`:default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return Uy.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});case`MMMM`:default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return J(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});case`LLLL`:default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=Hy(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):J(i,t.length)},I:function(e,t,n){let r=zy(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):J(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):Uy.d(e,t)},D:function(e,t,n){let r=Ry(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):J(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});case`EEEE`:default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return J(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});case`eeee`:default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return J(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});case`cccc`:default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return J(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});case`iiii`:default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours(),i=r/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});case`aaaa`:default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?Wy.noon:r===0?Wy.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});case`bbbb`:default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?Wy.evening:r>=12?Wy.afternoon:r>=4?Wy.morning:Wy.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});case`BBBB`:default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return Uy.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):Uy.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):J(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):J(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):Uy.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):Uy.s(e,t)},S:function(e,t){return Uy.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return qy(r);case`XXXX`:case`XX`:return Jy(r);case`XXXXX`:case`XXX`:default:return Jy(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return qy(r);case`xxxx`:case`xx`:return Jy(r);case`xxxxx`:case`xxx`:default:return Jy(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+Ky(r,`:`);case`OOOO`:default:return`GMT`+Jy(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+Ky(r,`:`);case`zzzz`:default:return`GMT`+Jy(r,`:`)}},t:function(e,t,n){let r=Math.trunc(e/1e3);return J(r,t.length)},T:function(e,t,n){return J(+e,t.length)}};function Ky(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+J(a,2)}function qy(e,t){if(e%60==0){let t=e>0?`-`:`+`;return t+J(Math.abs(e)/60,2)}return Jy(e,t)}function Jy(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=J(Math.trunc(r/60),2),a=J(r%60,2);return n+i+t+a}const Yy=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});case`PPPP`:default:return t.date({width:`full`})}},Xy=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});case`pppp`:default:return t.time({width:`full`})}},Zy=(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return Yy(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;case`PPPP`:default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,Yy(r,t)).replace(`{{time}}`,Xy(i,t))},Qy={p:Xy,P:Zy},$y=/^D+$/,eb=/^Y+$/,tb=[`D`,`DD`,`YY`,`YYYY`];function nb(e){return $y.test(e)}function rb(e){return eb.test(e)}function ib(e,t,n){let r=ab(e,t,n);if(console.warn(r),tb.includes(e))throw RangeError(r)}function ab(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const ob=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,sb=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,cb=/^'([^]*?)'?$/,lb=/''/g,ub=/[a-zA-Z]/;function db(e,t,n){let r=Wv(),i=n?.locale??r.locale??Ly,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=Hv(e,n?.in);if(!ey(s))throw RangeError(`Invalid time value`);let c=t.match(sb).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=Qy[t];return n(e,i.formatLong)}return e}).join(``).match(ob).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:fb(e)};if(Gy[t])return{isToken:!0,value:e};if(t.match(ub))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&rb(a)||!n?.useAdditionalDayOfYearTokens&&nb(a))&&ib(a,t,String(e));let o=Gy[a[0]];return o(s,a,i.localize,l)}).join(``)}function fb(e){let t=e.match(cb);return t?t[1].replace(lb,`'`):e}function pb(e,t){return Hv(e*1e3,t?.in)}function mb(e,t){let n=hb(t)?new t(0):Vv(t,0);return n.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),n.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),n}function hb(e){return typeof e==`function`&&e.prototype?.constructor===e}function gb(e,t){if(t===void 0)return e.trimEnd();let n=e.length;switch(typeof t){case`string`:if(t.length!==1)throw Error(`The 'chars' parameter should be a single character string.`);for(;n>0&&e[n-1]===t;)n--;break;case`object`:for(;n>0&&t.includes(e[n-1]);)n--}return e.substring(0,n)}function _b(e){return e==null}function vb(e){return e!=null}async function yb(){if(typeof window<`u`&&window!==null)return`browser`;try{let e=await ie(()=>import(`./__vite-browser-external-BQofMJ7W.js`).then(Te(1)),__vite__mapDeps([0,1,2]));return e!==void 0&&e.versions!=null&&e.versions.node!=null?`node`:`unknown`}catch{return`unknown`}}function bb(e){return _b(e)?!1:L.isInt(e.type)&&!Eb(e)||xb(e)}function xb(e){return _b(e)?!1:L.isInt(e.type)&&e.type.isSigned===!1}function Sb(e){return _b(e)?!1:L.isFloat(e.type)??!1}function Cb(e){return _b(e)?!1:L.isDecimal(e.type)}function wb(e){return _b(e)?!1:L.isBool(e.type)}function Tb(e){return _b(e)?!1:L.isDuration(e.type)}function Eb(e){return _b(e)?!1:L.isInt(e.type)&&e.metadata.get(`ARROW:extension:name`)===`period`}function Db(e){return _b(e)?!1:L.isTimestamp(e.type)}function Ob(e){return _b(e)?!1:L.isDate(e.type)}function kb(e){return _b(e)?!1:L.isTime(e.type)}function Ab(e){return _b(e)?!1:L.isList(e.type)||L.isFixedSizeList(e.type)}function jb(e){return _b(e)?!1:L.isStruct(e.type)||L.isMap(e.type)}function Mb(e){return _b(e)?!1:L.isStruct(e.type)&&e.metadata.get(`ARROW:extension:name`)===`interval`||L.isInterval(e.type)}function Nb(e,t){let n;if(t===F.MILLISECOND)n=1e3;else if(t===F.MICROSECOND)n=1e3*1e3;else if(t===F.NANOSECOND)n=1e3*1e3*1e3;else return Number(e);return typeof e==`bigint`&&!Number.isSafeInteger(Number(e))?Number(e/BigInt(n)):Number(e)/n}function Pb(e,t){let n=Nb(e,t?.type?.unit??F.SECOND);return pb(n)}function Fb(e,t){let n=Pb(e,t);return db(n,n.getMilliseconds()===0?`HH:mm:ss`:`HH:mm:ss.SSS`)}function Ib(e){return e instanceof Date||typeof e==`number`&&Number.isFinite(e)?db(e,`yyyy-MM-dd`):(console.warn(`Unsupported date value: ${e}`),String(e))}function Lb(e,t){if(!(e instanceof Date||typeof e==`number`&&Number.isFinite(e)))return console.warn(`Unsupported datetime value: ${e}`),null;let n,r=t?.type?.timezone;return n=r?new Rf(e,r):new Rf(e),mb(n,Date)}function Rb(e,t){let n=t?.type?.scale||0,r=Lv.bigNumToString(new Lv.BN(e)).padStart(n,`0`);if(n===0)return r;let i=``;r.startsWith(`-`)&&(i=`-`,r=r.slice(1));let a=r.slice(0,-n)||`0`,o=gb(r.slice(-n),`0`)||``;return`${i}${a}${o?`.${o}`:``}`}new Intl.NumberFormat(`en-US`,{style:`decimal`,maximumFractionDigits:4,minimumFractionDigits:4,useGrouping:!0});function zb(e){let t=e[0],n=e[1],r=[];return t!==0&&r.push(`${t} year${t>1?`s`:``}`),n!==0&&r.push(`${n} month${n>1?`s`:``}`),r.length?r.join(` `):`0 months`}function Bb(e,t){if(L.isInterval(t?.type))return zb(e);let n=t&&t.metadata.get(`ARROW:extension:name`);if(n&&n===`pandas.interval`){let n=JSON.parse(t.metadata.get(`ARROW:extension:metadata`)),{closed:r}=n,i=e.toJSON(),a=r===`both`||r===`left`?`[`:`(`,o=r===`both`||r===`right`?`]`:`)`,s=Hb(i.left,t.type?.children?.[0]),c=Hb(i.right,t.type?.children?.[1]);return`${a+s}, ${c+o}`}return String(e)}function Vb(e,t){return t?.type instanceof th?JSON.parse(JSON.stringify(e,(e,t)=>{if(vb(t))return typeof t==`bigint`?Number(t):t})):JSON.parse(JSON.stringify(e,(e,t)=>typeof t==`bigint`?Number(t):t))}function Hb(e,t){if(_b(e))return null;let n=e instanceof Date||Number.isFinite(e);if(n&&Ob(t))return Ib(e);if(typeof e==`bigint`&&kb(t))return Fb(Number(e),t);if(n&&Db(t))return Lb(e,t);if(Eb(t))throw Error(`Period type is not supported yet`);if(Mb(t))return Bb(e,t);if(Tb(t))throw Error(`Duration type is not supported yet`);return Cb(t)?Rb(e,t):Sb(t)&&Number.isFinite(e)||bb(t)?e:jb(t)||Ab(t)?Vb(e,t):wb(t)?!!e:String(e)}function Ub(e){let t=(e.toArray()||[]).map(e=>e.toJSON())||[],n=t.map(t=>(e.schema.fields.forEach(e=>t[e.name]=Hb(t[e.name],e)),t));return n}let Wb=function(e){return e.ORIGIN_PRIVATE_FS=`origin-private-fs`,e.NODE_FS=`node-fs`,e}({});async function Gb(e){let t=le(e,{logger:!1}),n,r,i=await yb();if(i===`browser`){if(t.bundles===void 0){let{getBundles:e}=await ie(async()=>{let{getBundles:e}=await import(`./default-browser-89XgBdWi.js`);return{getBundles:e}},[]);t.bundles=await e()}r=await Mf(await t.bundles),n=new Worker(r.mainWorker)}else if(i===`node`){if(t.bundles===void 0){let{getBundles:e}=await ie(async()=>{let{getBundles:e}=await import(`./default-node-CHzFd3wA.js`);return{getBundles:e}},__vite__mapDeps([3,1,2]));t.bundles=await e()}r=await Mf(await t.bundles);let e=r.mainWorker;e.startsWith(`/@fs/`)&&(e=e.replace(`/@fs/`,`file://`));let i=await ie(()=>import(`./browser-B7xBCPa9.js`),[]);n=new i.default(e,{type:`module`})}else throw Error(`Unsupported environment: ${i}`);let a;a=t.logger===!0?new af:t.logger===!1?new rf:t.logger;let o=new gf(a,n);if(await o.instantiate(r.mainModule,r.pthreadWorker),t.storage)switch(t.storage.type){case Wb.ORIGIN_PRIVATE_FS:try{let e=t.storage.path;e.startsWith(`/`)&&(e=e.slice(1)),await o.open({path:`opfs://${e}`,accessMode:t.storage.accessMode})}catch(e){throw await o.terminate(),await n.terminate(),e}break;case Wb.NODE_FS:try{await o.open({path:t.storage.path,accessMode:t.storage.accessMode,useDirectIO:!0})}catch(e){throw await o.terminate(),await n.terminate(),e}break}let s=await o.connect();async function c(e,t=[]){if(!t||t.length===0){let t=await s.query(e);return{_results:t,_schema:t.schema,columns:t.schema.fields,rows:Ub(t)}}let n=await s.prepare(e),r=await n.query(...t);return n.close(),{_results:r,_schema:r.schema,columns:r.schema.fields,rows:Ub(r)}}return{worker:n,db:o,conn:s,query:async(e,t=[])=>c(e,t).then(e=>e.rows),queryWithColumns:async(e,t=[])=>c(e,t),close:async()=>{await s.close(),await o.terminate(),await n.terminate()}}}async function Kb(e,t){await(await e).conn.send(`BEGIN TRANSACTION`);try{let n=await t(e);return await(await e).conn.send(`COMMIT`),n}catch(t){throw await(await e).conn.send(`ROLLBACK`),t}}async function qb(e,t,n){await(await e).conn.send(`SAVEPOINT ${t}`);try{let r=await n(e);return await(await e).conn.send(`RELEASE SAVEPOINT ${t}`),r}catch(n){throw await(await e).conn.send(`ROLLBACK TO SAVEPOINT ${t}`),n}}const Y=Symbol.for(`drizzle:entityKind`);function X(e,t){if(!e||typeof e!=`object`)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,Y))throw Error(`Class "${t.name??``}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let n=Object.getPrototypeOf(e).constructor;if(n)for(;n;){if(Y in n&&n[Y]===t[Y])return!0;n=Object.getPrototypeOf(n)}return!1}var Jb=class{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static[Y]=`Column`;name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!==`byDefault`}},Yb=class{static[Y]=`ColumnBuilder`;config;constructor(e,t,n){this.config={name:e,keyAsName:e===``,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){this.config.name===``&&(this.config.name=e)}};const Xb=Symbol.for(`drizzle:Name`);var Zb=class{static[Y]=`PgForeignKeyBuilder`;reference;_onUpdate=`no action`;_onDelete=`no action`;constructor(e,t){this.reference=()=>{let{name:t,columns:n,foreignColumns:r}=e();return{name:t,columns:n,foreignTable:r[0].table,foreignColumns:r}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=e===void 0?`no action`:e,this}onDelete(e){return this._onDelete=e===void 0?`no action`:e,this}build(e){return new Qb(e,this)}},Qb=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[Y]=`PgForeignKey`;reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),r=t.map(e=>e.name),i=n.map(e=>e.name),a=[this.table[Xb],...r,n[0].table[Xb],...i];return e??`${a.join(`_`)}_fk`}};function $b(e,...t){return e(...t)}function ex(e,t){return`${e[Xb]}_${t.join(`_`)}_unique`}function tx(e,t,n){for(let r=t;rArray.isArray(e)?ix(e):typeof e==`string`?`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`:`${e}`).join(`,`)}}`}var ax=class extends Yb{foreignKeyConfigs=[];static[Y]=`PgColumnBuilder`;array(e){return new cx(this.config.name,this,e)}references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e,t){return this.config.isUnique=!0,this.config.uniqueName=e,this.config.uniqueType=t?.nulls,this}generatedAlwaysAs(e){return this.config.generated={as:e,type:`always`,mode:`stored`},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:r})=>$b((n,r)=>{let i=new Zb(()=>{let t=n();return{columns:[e],foreignColumns:[t]}});return r.onUpdate&&i.onUpdate(r.onUpdate),r.onDelete&&i.onDelete(r.onDelete),i.build(t)},n,r))}buildExtraConfigColumn(e){return new sx(e,this.config)}},ox=class extends Jb{constructor(e,t){t.uniqueName||=ex(e,[t.name]),super(e,t),this.table=e}static[Y]=`PgColumn`},sx=class extends ox{static[Y]=`ExtraConfigColumn`;getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??`asc`,nulls:this.config.nulls??`last`,opClass:this.config.opClass};defaultConfig={order:`asc`,nulls:`last`,opClass:void 0};asc(){return this.indexConfig.order=`asc`,this}desc(){return this.indexConfig.order=`desc`,this}nullsFirst(){return this.indexConfig.nulls=`first`,this}nullsLast(){return this.indexConfig.nulls=`last`,this}op(e){return this.indexConfig.opClass=e,this}},cx=class extends ax{static[Y]=`PgArrayBuilder`;constructor(e,t,n){super(e,`array`,`PgArray`),this.config.baseBuilder=t,this.config.size=n}build(e){let t=this.config.baseBuilder.build(e);return new lx(e,this.config,t)}},lx=class e extends ox{constructor(e,t,n,r){super(e,t),this.baseColumn=n,this.range=r,this.size=t.size}size;static[Y]=`PgArray`;getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==`number`?this.size:``}]`}mapFromDriverValue(e){return typeof e==`string`&&(e=rx(e)),e.map(e=>this.baseColumn.mapFromDriverValue(e))}mapToDriverValue(t,n=!1){let r=t.map(t=>t===null?null:X(this.baseColumn,e)?this.baseColumn.mapToDriverValue(t,!0):this.baseColumn.mapToDriverValue(t));return n?r:ix(r)}};const ux=Symbol.for(`drizzle:isPgEnum`);function dx(e){return!!e&&typeof e==`function`&&ux in e&&e[ux]===!0}var fx=class{static[Y]=`Subquery`;constructor(e,t,n,r=!1,i=[]){this._={brand:`Subquery`,sql:e,selectedFields:t,alias:n,isWith:r,usedTables:i}}},px=class extends fx{static[Y]=`WithSubquery`};const mx={startActiveSpan(e,t){return t()}},hx=Symbol.for(`drizzle:ViewBaseConfig`),gx=Symbol.for(`drizzle:Schema`),_x=Symbol.for(`drizzle:Columns`),vx=Symbol.for(`drizzle:ExtraConfigColumns`),yx=Symbol.for(`drizzle:OriginalName`),bx=Symbol.for(`drizzle:BaseName`),xx=Symbol.for(`drizzle:IsAlias`),Sx=Symbol.for(`drizzle:ExtraConfigBuilder`),Cx=Symbol.for(`drizzle:IsDrizzleTable`);var Z=class{static[Y]=`Table`;static Symbol={Name:Xb,Schema:gx,OriginalName:yx,Columns:_x,ExtraConfigColumns:vx,BaseName:bx,IsAlias:xx,ExtraConfigBuilder:Sx};[Xb];[yx];[gx];[_x];[vx];[bx];[xx]=!1;[Cx]=!0;[Sx]=void 0;constructor(e,t,n){this[Xb]=this[yx]=e,this[gx]=t,this[bx]=n}};function wx(e){return e[Xb]}function Tx(e){return`${e[gx]??`public`}.${e[Xb]}`}function Ex(e){return e!=null&&typeof e.getSQL==`function`}function Dx(e){let t={sql:``,params:[]};for(let n of e)t.sql+=n.sql,t.params.push(...n.params),n.typings?.length&&(t.typings||=[],t.typings.push(...n.typings));return t}var Ox=class{static[Y]=`StringChunk`;value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new Q([this])}},Q=class e{constructor(e){this.queryChunks=e;for(let t of e)if(X(t,Z)){let e=t[Z.Symbol.Schema];this.usedTables.push(e===void 0?t[Z.Symbol.Name]:e+`.`+t[Z.Symbol.Name])}}static[Y]=`SQL`;decoder=jx;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return mx.startActiveSpan(`drizzle.buildSQL`,t=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(t,n){let r=Object.assign({},n,{inlineParams:n.inlineParams||this.shouldInlineParams,paramStartIndex:n.paramStartIndex||{value:0}}),{casing:i,escapeName:a,escapeParam:o,prepareTyping:s,inlineParams:c,paramStartIndex:l}=r;return Dx(t.map(t=>{if(X(t,Ox))return{sql:t.value.join(``),params:[]};if(X(t,kx))return{sql:a(t.value),params:[]};if(t===void 0)return{sql:``,params:[]};if(Array.isArray(t)){let e=[new Ox(`(`)];for(let[n,r]of t.entries())e.push(r),ne},Mx={mapToDriverValue:e=>e};({...jx,...Mx});var Nx=class{constructor(e,t=Mx){this.value=e,this.encoder=t}static[Y]=`Param`;brand;getSQL(){return new Q([this])}};function $(e,...t){let n=[];(t.length>0||e.length>0&&e[0]!==``)&&n.push(new Ox(e[0]));for(let[r,i]of t.entries())n.push(i,new Ox(e[r+1]));return new Q(n)}(e=>{function t(){return new Q([])}e.empty=t;function n(e){return new Q(e)}e.fromList=n;function r(e){return new Q([new Ox(e)])}e.raw=r;function i(e,t){let n=[];for(let[r,i]of e.entries())r>0&&t!==void 0&&n.push(t),n.push(i);return new Q(n)}e.join=i;function a(e){return new kx(e)}e.identifier=a;function o(e){return new Px(e)}e.placeholder=o;function s(e,t){return new Nx(e,t)}e.param=s})($||={}),(e=>{class t{constructor(e,t){this.sql=e,this.fieldAlias=t}static[Y]=`SQL.Aliased`;isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(Q||={});var Px=class{constructor(e){this.name=e}static[Y]=`Placeholder`;getSQL(){return new Q([this])}};function Fx(e,t){return e.map(e=>{if(X(e,Px)){if(!(e.name in t))throw Error(`No value for placeholder "${e.name}" was provided`);return t[e.name]}if(X(e,Nx)&&X(e.value,Px)){if(!(e.value.name in t))throw Error(`No value for placeholder "${e.value.name}" was provided`);return e.encoder.mapToDriverValue(t[e.value.name])}return e})}const Ix=Symbol.for(`drizzle:IsDrizzleView`);var Lx=class{static[Y]=`View`;[hx];[Ix]=!0;constructor({name:e,schema:t,selectedFields:n,query:r}){this[hx]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new Q([this])}};Jb.prototype.getSQL=function(){return new Q([this])},Z.prototype.getSQL=function(){return new Q([this])},fx.prototype.getSQL=function(){return new Q([this])};var Rx=class{constructor(e){this.table=e}static[Y]=`ColumnAliasProxyHandler`;get(e,t){return t===`table`?this.table:e[t]}},zx=class{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static[Y]=`TableAliasProxyHandler`;get(e,t){if(t===Z.Symbol.IsAlias)return!0;if(t===Z.Symbol.Name||this.replaceOriginalName&&t===Z.Symbol.OriginalName)return this.alias;if(t===hx)return{...e[hx],name:this.alias,isAlias:!0};if(t===Z.Symbol.Columns){let t=e[Z.Symbol.Columns];if(!t)return t;let n={};return Object.keys(t).map(r=>{n[r]=new Proxy(t[r],new Rx(new Proxy(e,this)))}),n}let n=e[t];return X(n,Jb)?new Proxy(n,new Rx(new Proxy(e,this))):n}};function Bx(e,t){return new Proxy(e,new zx(t,!1))}function Vx(e,t){return new Proxy(e,new Rx(new Proxy(e.table,new zx(t,!1))))}function Hx(e,t){return new Q.Aliased(Ux(e.sql,t),e.fieldAlias)}function Ux(e,t){return $.join(e.queryChunks.map(e=>X(e,Jb)?Vx(e,t):X(e,Q)?Ux(e,t):X(e,Q.Aliased)?Hx(e,t):e))}var Wx=class extends Error{static[Y]=`DrizzleError`;constructor({message:e,cause:t}){super(e),this.name=`DrizzleError`,this.cause=t}},Gx=class e extends Error{constructor(t,n,r){super(`Failed query: ${t} +params: ${n}`),this.query=t,this.params=n,this.cause=r,Error.captureStackTrace(this,e),r&&(this.cause=r)}},Kx=class extends Wx{static[Y]=`TransactionRollbackError`;constructor(){super({message:`Rollback`})}},qx=class{static[Y]=`ConsoleLogWriter`;write(e){console.log(e)}},Jx=class{static[Y]=`DefaultLogger`;writer;constructor(e){this.writer=e?.writer??new qx}logQuery(e,t){let n=t.map(e=>{try{return JSON.stringify(e)}catch{return String(e)}}),r=n.length?` -- params: [${n.join(`, `)}]`:``;this.writer.write(`Query: ${e}${r}`)}},Yx=class{static[Y]=`NoopLogger`;logQuery(){}},Xx=class{static[Y]=`QueryPromise`;[Symbol.toStringTag]=`QueryPromise`;catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}};function Zx(e,t){return Object.entries(e).reduce((e,[n,r])=>{if(typeof n!=`string`)return e;let i=t?[...t,n]:[n];return X(r,Jb)||X(r,Q)||X(r,Q.Aliased)?e.push({path:i,field:r}):X(r,Z)?e.push(...Zx(r[Z.Symbol.Columns],i)):e.push(...Zx(r,i)),e},[])}function Qx(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let[e,t]of n.entries())if(t!==r[e])return!1;return!0}function $x(e,t){let n=Object.entries(t).filter(([,e])=>e!==void 0).map(([t,n])=>X(n,Q)||X(n,Jb)?[t,n]:[t,new Nx(n,e[Z.Symbol.Columns][t])]);if(n.length===0)throw Error(`No values to set`);return Object.fromEntries(n)}function eS(e,t){for(let n of t)for(let t of Object.getOwnPropertyNames(n.prototype)){if(t===`constructor`)continue;Object.defineProperty(e.prototype,t,Object.getOwnPropertyDescriptor(n.prototype,t)||Object.create(null))}}function tS(e){return e[Z.Symbol.Columns]}function nS(e){return X(e,fx)?e._.alias:X(e,Lx)?e[hx].name:X(e,Q)?void 0:e[Z.Symbol.IsAlias]?e[Z.Symbol.Name]:e[Z.Symbol.BaseName]}function rS(e){if(typeof e!=`object`||!e||e.constructor.name!==`Object`)return!1;if(`logger`in e){let t=typeof e.logger;return!(t!==`boolean`&&(t!==`object`||typeof e.logger.logQuery!=`function`)&&t!==`undefined`)}if(`schema`in e){let t=typeof e.schema;return!(t!==`object`&&t!==`undefined`)}if(`casing`in e){let t=typeof e.casing;return!(t!==`string`&&t!==`undefined`)}if(`mode`in e)return!(e.mode!==`default`||e.mode!==`planetscale`||e.mode!==void 0);if(`connection`in e){let t=typeof e.connection;return!(t!==`string`&&t!==`object`&&t!==`undefined`)}if(`client`in e){let t=typeof e.client;return!(t!==`object`&&t!==`function`&&t!==`undefined`)}return Object.keys(e).length===0}typeof TextDecoder>`u`||new TextDecoder;var iS=class extends ox{static[Y]=`PgDate`;getSQLType(){return`date`}mapFromDriverValue(e){return new Date(e)}mapToDriverValue(e){return e.toISOString()}},aS=class extends ox{static[Y]=`PgDateString`;getSQLType(){return`date`}},oS=class extends ox{static[Y]=`PgJson`;constructor(e,t){super(e,t)}getSQLType(){return`json`}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}},sS=class extends ox{static[Y]=`PgJsonb`;constructor(e,t){super(e,t)}getSQLType(){return`jsonb`}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}},cS=class extends ox{static[Y]=`PgNumeric`;precision;scale;constructor(e,t){super(e,t),this.precision=t.precision,this.scale=t.scale}mapFromDriverValue(e){return typeof e==`string`?e:String(e)}getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?`numeric`:`numeric(${this.precision})`}},lS=class extends ox{static[Y]=`PgTime`;withTimezone;precision;constructor(e,t){super(e,t),this.withTimezone=t.withTimezone,this.precision=t.precision}getSQLType(){let e=this.precision===void 0?``:`(${this.precision})`;return`time${e}${this.withTimezone?` with time zone`:``}`}},uS=class extends ox{static[Y]=`PgTimestamp`;withTimezone;precision;constructor(e,t){super(e,t),this.withTimezone=t.withTimezone,this.precision=t.precision}getSQLType(){let e=this.precision===void 0?``:` (${this.precision})`;return`timestamp${e}${this.withTimezone?` with time zone`:``}`}mapFromDriverValue=e=>new Date(this.withTimezone?e:e+`+0000`);mapToDriverValue=e=>e.toISOString()},dS=class extends ox{static[Y]=`PgTimestampString`;withTimezone;precision;constructor(e,t){super(e,t),this.withTimezone=t.withTimezone,this.precision=t.precision}getSQLType(){let e=this.precision===void 0?``:`(${this.precision})`;return`timestamp${e}${this.withTimezone?` with time zone`:``}`}},fS=class extends ox{static[Y]=`PgUUID`;getSQLType(){return`uuid`}};const pS=Symbol.for(`drizzle:PgInlineForeignKeys`),mS=Symbol.for(`drizzle:EnableRLS`);var hS=class extends Z{static[Y]=`PgTable`;static Symbol=Object.assign({},Z.Symbol,{InlineForeignKeys:pS,EnableRLS:mS});[pS]=[];[mS]=!1;[Z.Symbol.ExtraConfigBuilder]=void 0;[Z.Symbol.ExtraConfigColumns]={}},gS=class{static[Y]=`PgPrimaryKeyBuilder`;columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new _S(e,this.columns,this.name)}},_S=class{constructor(e,t,n){this.table=e,this.columns=t,this.name=n}static[Y]=`PgPrimaryKey`;columns;name;getName(){return this.name??`${this.table[hS.Symbol.Name]}_${this.columns.map(e=>e.name).join(`_`)}_pk`}};function vS(e,t){return Ax(t)&&!Ex(e)&&!X(e,Nx)&&!X(e,Px)&&!X(e,Jb)&&!X(e,Z)&&!X(e,Lx)?new Nx(e,t):e}const yS=(e,t)=>$`${e} = ${vS(t,e)}`,bS=(e,t)=>$`${e} <> ${vS(t,e)}`;function xS(...e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new Q(t):new Q([new Ox(`(`),$.join(t,new Ox(` and `)),new Ox(`)`)])}function SS(...e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new Q(t):new Q([new Ox(`(`),$.join(t,new Ox(` or `)),new Ox(`)`)])}function CS(e){return $`not ${e}`}const wS=(e,t)=>$`${e} > ${vS(t,e)}`,TS=(e,t)=>$`${e} >= ${vS(t,e)}`,ES=(e,t)=>$`${e} < ${vS(t,e)}`,DS=(e,t)=>$`${e} <= ${vS(t,e)}`;function OS(e,t){return Array.isArray(t)?t.length===0?$`false`:$`${e} in ${t.map(t=>vS(t,e))}`:$`${e} in ${vS(t,e)}`}function kS(e,t){return Array.isArray(t)?t.length===0?$`true`:$`${e} not in ${t.map(t=>vS(t,e))}`:$`${e} not in ${vS(t,e)}`}function AS(e){return $`${e} is null`}function jS(e){return $`${e} is not null`}function MS(e){return $`exists ${e}`}function NS(e){return $`not exists ${e}`}function PS(e,t,n){return $`${e} between ${vS(t,e)} and ${vS(n,e)}`}function FS(e,t,n){return $`${e} not between ${vS(t,e)} and ${vS(n,e)}`}function IS(e,t){return $`${e} like ${t}`}function LS(e,t){return $`${e} not like ${t}`}function RS(e,t){return $`${e} ilike ${t}`}function zS(e,t){return $`${e} not ilike ${t}`}function BS(e){return $`${e} asc`}function VS(e){return $`${e} desc`}var HS=class{constructor(e,t,n){this.sourceTable=e,this.referencedTable=t,this.relationName=n,this.referencedTableName=t[Z.Symbol.Name]}static[Y]=`Relation`;referencedTableName;fieldName},US=class{constructor(e,t){this.table=e,this.config=t}static[Y]=`Relations`},WS=class e extends HS{constructor(e,t,n,r){super(e,t,n?.relationName),this.config=n,this.isNullable=r}static[Y]=`One`;withFieldName(t){let n=new e(this.sourceTable,this.referencedTable,this.config,this.isNullable);return n.fieldName=t,n}},GS=class e extends HS{constructor(e,t,n){super(e,t,n?.relationName),this.config=n}static[Y]=`Many`;withFieldName(t){let n=new e(this.sourceTable,this.referencedTable,this.config);return n.fieldName=t,n}};function KS(){return{and:xS,between:PS,eq:yS,exists:MS,gt:wS,gte:TS,ilike:RS,inArray:OS,isNull:AS,isNotNull:jS,like:IS,lt:ES,lte:DS,ne:bS,not:CS,notBetween:FS,notExists:NS,notLike:LS,notIlike:zS,notInArray:kS,or:SS,sql:$}}function qS(){return{sql:$,asc:BS,desc:VS}}function JS(e,t){Object.keys(e).length===1&&`default`in e&&!X(e.default,Z)&&(e=e.default);let n={},r={},i={};for(let[a,o]of Object.entries(e))if(X(o,Z)){let e=Tx(o),t=r[e];n[e]=a,i[a]={tsName:a,dbName:o[Z.Symbol.Name],schema:o[Z.Symbol.Schema],columns:o[Z.Symbol.Columns],relations:t?.relations??{},primaryKey:t?.primaryKey??[]};for(let e of Object.values(o[Z.Symbol.Columns]))e.primary&&i[a].primaryKey.push(e);let s=o[Z.Symbol.ExtraConfigBuilder]?.(o[Z.Symbol.ExtraConfigColumns]);if(s)for(let e of Object.values(s))X(e,gS)&&i[a].primaryKey.push(...e.columns)}else if(X(o,US)){let e=Tx(o.table),a=n[e],s=o.config(t(o.table));for(let[t,n]of Object.entries(s))if(a){let e=i[a];e.relations[t]=n}else e in r||(r[e]={relations:{},primaryKey:void 0}),r[e].relations[t]=n}return{tables:i,tableNamesMap:n}}function YS(e){return function(t,n){return new WS(e,t,n,n?.fields.reduce((e,t)=>e&&t.notNull,!0)??!1)}}function XS(e){return function(t,n){return new GS(e,t,n)}}function ZS(e,t,n){if(X(n,WS)&&n.config)return{fields:n.config.fields,references:n.config.references};let r=t[Tx(n.referencedTable)];if(!r)throw Error(`Table "${n.referencedTable[Z.Symbol.Name]}" not found in schema`);let i=e[r];if(!i)throw Error(`Table "${r}" not found in schema`);let a=n.sourceTable,o=t[Tx(a)];if(!o)throw Error(`Table "${a[Z.Symbol.Name]}" not found in schema`);let s=[];for(let e of Object.values(i.relations))(n.relationName&&n!==e&&e.relationName===n.relationName||!n.relationName&&e.referencedTable===n.sourceTable)&&s.push(e);if(s.length>1)throw n.relationName?Error(`There are multiple relations with name "${n.relationName}" in table "${r}"`):Error(`There are multiple relations between "${r}" and "${n.sourceTable[Z.Symbol.Name]}". Please specify relation name`);if(s[0]&&X(s[0],WS)&&s[0].config)return{fields:s[0].config.references,references:s[0].config.fields};throw Error(`There is not enough information to infer relation "${o}.${n.fieldName}"`)}function QS(e){return{one:YS(e),many:XS(e)}}function $S(e,t,n,r,i=e=>e){let a={};for(let[o,s]of r.entries())if(s.isJson){let r=t.relations[s.tsKey],c=n[o],l=typeof c==`string`?JSON.parse(c):c;a[s.tsKey]=X(r,WS)?l&&$S(e,e[s.relationTableTsKey],l,s.selection,i):l.map(t=>$S(e,e[s.relationTableTsKey],t,s.selection,i))}else{let e=i(n[o]),t=s.field,r;r=X(t,Jb)?t:X(t,Q)?t.decoder:t.sql.decoder,a[s.tsKey]=e===null?null:r.mapFromDriverValue(e)}return a}var eC=class e{static[Y]=`SelectionProxyHandler`;config;constructor(e){this.config={...e}}get(t,n){if(n===`_`)return{...t._,selectedFields:new Proxy(t._.selectedFields,this)};if(n===hx)return{...t[hx],selectedFields:new Proxy(t[hx].selectedFields,this)};if(typeof n==`symbol`)return t[n];let r=X(t,fx)?t._.selectedFields:X(t,Lx)?t[hx].selectedFields:t,i=r[n];if(X(i,Q.Aliased)){if(this.config.sqlAliasedBehavior===`sql`&&!i.isSelectionField)return i.sql;let e=i.clone();return e.isSelectionField=!0,e}if(X(i,Q)){if(this.config.sqlBehavior===`sql`)return i;throw Error(`You tried to reference "${n}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return X(i,Jb)?this.config.alias?new Proxy(i,new Rx(new Proxy(i.table,new zx(this.config.alias,this.config.replaceOriginalName??!1)))):i:typeof i!=`object`||!i?i:new Proxy(i,new e(this.config))}};function tC(e){let t=e.replace(/['\u2019]/g,``).match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[];return t.map(e=>e.toLowerCase()).join(`_`)}function nC(e){let t=e.replace(/['\u2019]/g,``).match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[];return t.reduce((e,t,n)=>{let r=n===0?t.toLowerCase():`${t[0].toUpperCase()}${t.slice(1)}`;return e+r},``)}function rC(e){return e}var iC=class{static[Y]=`CasingCache`;cache={};cachedTables={};convert;constructor(e){this.convert=e===`snake_case`?tC:e===`camelCase`?nC:rC}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[Z.Symbol.Schema]??`public`,n=e.table[Z.Symbol.OriginalName],r=`${t}.${n}.${e.name}`;return this.cache[r]||this.cacheTable(e.table),this.cache[r]}cacheTable(e){let t=e[Z.Symbol.Schema]??`public`,n=e[Z.Symbol.OriginalName],r=`${t}.${n}`;if(!this.cachedTables[r]){for(let t of Object.values(e[Z.Symbol.Columns])){let e=`${r}.${t.name}`;this.cache[e]=this.convert(t.name)}this.cachedTables[r]=!0}}clearCache(){this.cache={},this.cachedTables={}}},aC=class extends Lx{static[Y]=`PgViewBase`},oC=class{static[Y]=`PgDialect`;casing;constructor(e){this.casing=new iC(e?.casing)}async migrate(e,t,n){let r=typeof n==`string`?`__drizzle_migrations`:n.migrationsTable??`__drizzle_migrations`,i=typeof n==`string`?`drizzle`:n.migrationsSchema??`drizzle`,a=$` + CREATE TABLE IF NOT EXISTS ${$.identifier(i)}.${$.identifier(r)} ( + id SERIAL PRIMARY KEY, + hash text NOT NULL, + created_at bigint + ) + `;await t.execute($`CREATE SCHEMA IF NOT EXISTS ${$.identifier(i)}`),await t.execute(a);let o=await t.all($`select id, hash, created_at from ${$.identifier(i)}.${$.identifier(r)} order by created_at desc limit 1`),s=o[0];await t.transaction(async t=>{for await(let n of e)if(!s||Number(s.created_at)t[e]!==void 0||n[e]?.onUpdateFn!==void 0),i=r.length;return $.join(r.flatMap((e,r)=>{let a=n[e],o=t[e]??$.param(a.onUpdateFn(),a),s=$`${$.identifier(this.casing.getColumnCasing(a))} = ${o}`;return r{let i=[];if(X(e,Q.Aliased)&&e.isSelectionField)i.push($.identifier(e.fieldAlias));else if(X(e,Q.Aliased)||X(e,Q)){let n=X(e,Q.Aliased)?e.sql:e;t?i.push(new Q(n.queryChunks.map(e=>X(e,ox)?$.identifier(this.casing.getColumnCasing(e)):e))):i.push(n),X(e,Q.Aliased)&&i.push($` as ${$.identifier(e.fieldAlias)}`)}else X(e,Jb)&&(t?i.push($.identifier(this.casing.getColumnCasing(e))):i.push(e));return ro?.some(({alias:t})=>t===(e[Z.Symbol.IsAlias]?wx(e):e[Z.Symbol.BaseName])))(e.field.table)){let t=wx(e.field.table);throw Error(`Your "${e.path.join(`->`)}" field references a column "${t}"."${e.field.name}", but the table "${t}" is not part of the query! Did you forget to join it?`)}let re=!o||o.length===0,ie=this.buildWithCTE(e),ae;ee&&(ae=ee===!0?$` distinct`:$` distinct on (${$.join(ee.on,$`, `)})`);let oe=this.buildSelection(ne,{isSingleTable:re}),se=this.buildFromTable(a),ce=this.buildJoins(o),le=r?$` where ${r}`:void 0,ue=i?$` having ${i}`:void 0,de;s&&s.length>0&&(de=$` order by ${$.join(s,$`, `)}`);let fe;c&&c.length>0&&(fe=$` group by ${$.join(c,$`, `)}`);let pe=typeof l==`object`||typeof l==`number`&&l>=0?$` limit ${l}`:void 0,me=u?$` offset ${u}`:void 0,he=$.empty();if(d){let e=$` for ${$.raw(d.strength)}`;d.config.of&&e.append($` of ${$.join(Array.isArray(d.config.of)?d.config.of:[d.config.of],$`, `)}`),d.config.noWait?e.append($` nowait`):d.config.skipLocked&&e.append($` skip locked`),he.append(e)}let ge=$`${ie}select${ae} ${oe} from ${se}${ce}${le}${fe}${ue}${de}${pe}${me}${he}`;return te.length>0?this.buildSetOperations(ge,te):ge}buildSetOperations(e,t){let[n,...r]=t;if(!n)throw Error(`Cannot pass undefined values to any set operator`);return r.length===0?this.buildSetOperationQuery({leftSelect:e,setOperator:n}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:n}),r)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:n,rightSelect:r,limit:i,orderBy:a,offset:o}}){let s=$`(${e.getSQL()}) `,c=$`(${r.getSQL()})`,l;if(a&&a.length>0){let e=[];for(let t of a)if(X(t,ox))e.push($.identifier(t.name));else if(X(t,Q)){for(let e=0;e=0?$` limit ${i}`:void 0,d=$.raw(`${t} ${n?`all `:``}`),ee=o?$` offset ${o}`:void 0;return $`${s}${d}${c}${l}${u}${ee}`}buildInsertQuery({table:e,values:t,onConflict:n,returning:r,withList:i,select:a,overridingSystemValue_:o}){let s=[],c=e[Z.Symbol.Columns],l=Object.entries(c).filter(([e,t])=>!t.shouldDisableInsert()),u=l.map(([,e])=>$.identifier(this.casing.getColumnCasing(e)));if(a){let e=t;X(e,Q)?s.push(e):s.push(e.getSQL())}else{let e=t;s.push($.raw(`values `));for(let[t,n]of e.entries()){let r=[];for(let[e,t]of l){let i=n[e];if(i===void 0||X(i,Nx)&&i.value===void 0)if(t.defaultFn!==void 0){let e=t.defaultFn(),n=X(e,Q)?e:$.param(e,t);r.push(n)}else if(!t.default&&t.onUpdateFn!==void 0){let e=t.onUpdateFn(),n=X(e,Q)?e:$.param(e,t);r.push(n)}else r.push($`default`);else r.push(i)}s.push(r),t({dbKey:t.name,tsKey:e,field:Vx(t,o),relationTableTsKey:void 0,isJson:!1,selection:[]}))}else{let r=Object.fromEntries(Object.entries(i.columns).map(([e,t])=>[e,Vx(t,o)]));if(a.where){let e=typeof a.where==`function`?a.where(r,KS()):a.where;te=e&&Ux(e,o)}let s=[],c=[];if(a.columns){let e=!1;for(let[t,n]of Object.entries(a.columns)){if(n===void 0)continue;t in i.columns&&(!e&&n===!0&&(e=!0),c.push(t))}c.length>0&&(c=e?c.filter(e=>a.columns?.[e]===!0):Object.keys(i.columns).filter(e=>!c.includes(e)))}else c=Object.keys(i.columns);for(let e of c){let t=i.columns[e];s.push({tsKey:e,value:t})}let re=[];a.with&&(re=Object.entries(a.with).filter(e=>!!e[1]).map(([e,t])=>({tsKey:e,queryConfig:t,relation:i.relations[e]})));let ie;if(a.extras){ie=typeof a.extras==`function`?a.extras(r,{sql:$}):a.extras;for(let[e,t]of Object.entries(ie))s.push({tsKey:e,value:Hx(t,o)})}for(let{tsKey:e,value:t}of s)l.push({dbKey:X(t,Q.Aliased)?t.fieldAlias:i.columns[e].name,tsKey:e,field:X(t,Jb)?Vx(t,o):t,relationTableTsKey:void 0,isJson:!1,selection:[]});let ae=typeof a.orderBy==`function`?a.orderBy(r,qS()):a.orderBy??[];Array.isArray(ae)||(ae=[ae]),ee=ae.map(e=>X(e,Jb)?Vx(e,o):Ux(e,o)),u=a.limit,d=a.offset;for(let{tsKey:r,queryConfig:i,relation:a}of re){let s=ZS(t,n,a),c=Tx(a.referencedTable),u=n[c],d=`${o}_${r}`,ee=xS(...s.fields.map((e,t)=>yS(Vx(s.references[t],d),Vx(e,o)))),te=this.buildRelationalQueryWithoutPK({fullSchema:e,schema:t,tableNamesMap:n,table:e[u],tableConfig:t[u],queryConfig:X(a,WS)?i===!0?{limit:1}:{...i,limit:1}:i,tableAlias:d,joinOn:ee,nestedQueryRelation:a}),re=$`${$.identifier(d)}.${$.identifier(`data`)}`.as(r);ne.push({on:$`true`,table:new fx(te.sql,{},d),alias:d,joinType:`left`,lateral:!0}),l.push({dbKey:r,tsKey:r,field:re,relationTableTsKey:u,isJson:!0,selection:te.selection})}}if(l.length===0)throw new Wx({message:`No fields selected for table "${i.tsName}" ("${o}")`});let re;if(te=xS(c,te),s){let e=$`json_build_array(${$.join(l.map(({field:e,tsKey:t,isJson:n})=>n?$`${$.identifier(`${o}_${t}`)}.${$.identifier(`data`)}`:X(e,Q.Aliased)?e.sql:e),$`, `)})`;X(s,GS)&&(e=$`coalesce(json_agg(${e}${ee.length>0?$` order by ${$.join(ee,$`, `)}`:void 0}), '[]'::json)`);let t=[{dbKey:`data`,tsKey:`data`,field:e.as(`data`),isJson:!0,relationTableTsKey:i.tsName,selection:l}],n=u!==void 0||d!==void 0||ee.length>0;n?(re=this.buildSelectQuery({table:Bx(r,o),fields:{},fieldsFlat:[{path:[],field:$.raw(`*`)}],where:te,limit:u,offset:d,orderBy:ee,setOperators:[]}),te=void 0,u=void 0,d=void 0,ee=[]):re=Bx(r,o),re=this.buildSelectQuery({table:X(re,hS)?re:new fx(re,{},o),fields:{},fieldsFlat:t.map(({field:e})=>({path:[],field:X(e,Jb)?Vx(e,o):e})),joins:ne,where:te,limit:u,offset:d,orderBy:ee,setOperators:[]})}else re=this.buildSelectQuery({table:Bx(r,o),fields:{},fieldsFlat:l.map(({field:e})=>({path:[],field:X(e,Jb)?Vx(e,o):e})),joins:ne,where:te,limit:u,offset:d,orderBy:ee,setOperators:[]});return{tableTsKey:i.tsName,sql:re,selection:l}}},sC=class{static[Y]=`TypedQueryBuilder`;getSelectedFields(){return this._.selectedFields}},cC=class{static[Y]=`PgSelectBuilder`;fields;session;dialect;withList=[];distinct;constructor(e){this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,e.withList&&(this.withList=e.withList),this.distinct=e.distinct}authToken;setToken(e){return this.authToken=e,this}from(e){let t=!!this.fields,n=e,r;return r=this.fields?this.fields:X(n,fx)?Object.fromEntries(Object.keys(n._.selectedFields).map(e=>[e,n[e]])):X(n,aC)?n[hx].selectedFields:X(n,Q)?{}:tS(n),new uC({table:n,fields:r,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}},lC=class extends sC{static[Y]=`PgSelectQueryBuilder`;_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:n,session:r,dialect:i,withList:a,distinct:o}){super(),this.config={withList:a,table:e,fields:{...t},distinct:o,setOperators:[]},this.isPartialSelect=n,this.session=r,this.dialect=i,this._={selectedFields:t,config:this.config},this.tableName=nS(e),this.joinsNotNullableMap=typeof this.tableName==`string`?{[this.tableName]:!0}:{};for(let t of bC(e))this.usedTables.add(t)}getUsedTables(){return[...this.usedTables]}createJoin(e,t){return(n,r)=>{let i=this.tableName,a=nS(n);for(let e of bC(n))this.usedTables.add(e);if(typeof a==`string`&&this.config.joins?.some(e=>e.alias===a))throw Error(`Alias "${a}" is already used in this query`);if(!this.isPartialSelect&&(Object.keys(this.joinsNotNullableMap).length===1&&typeof i==`string`&&(this.config.fields={[i]:this.config.fields}),typeof a==`string`&&!X(n,Q))){let e=X(n,fx)?n._.selectedFields:X(n,Lx)?n[hx].selectedFields:n[Z.Symbol.Columns];this.config.fields[a]=e}if(typeof r==`function`&&(r=r(new Proxy(this.config.fields,new eC({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:r,table:n,joinType:e,alias:a,lateral:t}),typeof a==`string`)switch(e){case`left`:this.joinsNotNullableMap[a]=!1;break;case`right`:this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[a]=!0;break;case`cross`:case`inner`:this.joinsNotNullableMap[a]=!0;break;case`full`:this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[a]=!1;break}return this}}leftJoin=this.createJoin(`left`,!1);leftJoinLateral=this.createJoin(`left`,!0);rightJoin=this.createJoin(`right`,!1);innerJoin=this.createJoin(`inner`,!1);innerJoinLateral=this.createJoin(`inner`,!0);fullJoin=this.createJoin(`full`,!1);crossJoin=this.createJoin(`cross`,!1);crossJoinLateral=this.createJoin(`cross`,!0);createSetOperator(e,t){return n=>{let r=typeof n==`function`?n(fC()):n;if(!Qx(this.getSelectedFields(),r.getSelectedFields()))throw Error(`Set operator error (union / intersect / except): selected fields are not the same or are in a different order`);return this.config.setOperators.push({type:e,isAll:t,rightSelect:r}),this}}union=this.createSetOperator(`union`,!1);unionAll=this.createSetOperator(`union`,!0);intersect=this.createSetOperator(`intersect`,!1);intersectAll=this.createSetOperator(`intersect`,!0);except=this.createSetOperator(`except`,!1);exceptAll=this.createSetOperator(`except`,!0);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return typeof e==`function`&&(e=e(new Proxy(this.config.fields,new eC({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))),this.config.where=e,this}having(e){return typeof e==`function`&&(e=e(new Proxy(this.config.fields,new eC({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))),this.config.having=e,this}groupBy(...e){if(typeof e[0]==`function`){let t=e[0](new Proxy(this.config.fields,new eC({sqlAliasedBehavior:`alias`,sqlBehavior:`sql`})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if(typeof e[0]==`function`){let t=e[0](new Proxy(this.config.fields,new eC({sqlAliasedBehavior:`alias`,sqlBehavior:`sql`}))),n=Array.isArray(t)?t:[t];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=n:this.config.orderBy=n}else{let t=e;this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=t:this.config.orderBy=t}return this}limit(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=e:this.config.limit=e,this}offset(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=e:this.config.offset=e,this}for(e,t={}){return this.config.lockingClause={strength:e,config:t},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}as(e){let t=[];if(t.push(...bC(this.config.table)),this.config.joins)for(let e of this.config.joins)t.push(...bC(e.table));return new Proxy(new fx(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new eC({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`}))}getSelectedFields(){return new Proxy(this.config.fields,new eC({alias:this.tableName,sqlAliasedBehavior:`alias`,sqlBehavior:`error`}))}$dynamic(){return this}$withCache(e){return this.cacheConfig=e===void 0?{config:{},enable:!0,autoInvalidate:!0}:e===!1?{enable:!1}:{enable:!0,autoInvalidate:!0,...e},this}},uC=class extends lC{static[Y]=`PgSelect`;_prepare(e){let{session:t,config:n,dialect:r,joinsNotNullableMap:i,authToken:a,cacheConfig:o,usedTables:s}=this;if(!t)throw Error(`Cannot execute a query on a query builder. Please use a database instance instead.`);let{fields:c}=n;return mx.startActiveSpan(`drizzle.prepareQuery`,()=>{let n=Zx(c),l=t.prepareQuery(r.sqlToQuery(this.getSQL()),n,e,!0,void 0,{type:`select`,tables:[...s]},o);return l.joinsNotNullableMap=i,l.setToken(a)})}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>mx.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken))};eS(uC,[Xx]);function dC(e,t){return(n,r,...i)=>{let a=[r,...i].map(n=>({type:e,isAll:t,rightSelect:n}));for(let e of a)if(!Qx(n.getSelectedFields(),e.rightSelect.getSelectedFields()))throw Error(`Set operator error (union / intersect / except): selected fields are not the same or are in a different order`);return n.addSetOperators(a)}}const fC=()=>({union:pC,unionAll:mC,intersect:hC,intersectAll:gC,except:_C,exceptAll:vC}),pC=dC(`union`,!1),mC=dC(`union`,!0),hC=dC(`intersect`,!1),gC=dC(`intersect`,!0),_C=dC(`except`,!1),vC=dC(`except`,!0);var yC=class{static[Y]=`PgQueryBuilder`;dialect;dialectConfig;constructor(e){this.dialect=X(e,oC)?e:void 0,this.dialectConfig=X(e,oC)?void 0:e}$with=(e,t)=>{let n=this,r=r=>(typeof r==`function`&&(r=r(n)),new Proxy(new px(r.getSQL(),t??(`getSelectedFields`in r?r.getSelectedFields()??{}:{}),e,!0),new eC({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`})));return{as:r}};with(...e){let t=this;function n(n){return new cC({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function r(e){return new cC({fields:e??void 0,session:void 0,dialect:t.getDialect(),distinct:!0})}function i(e,n){return new cC({fields:n??void 0,session:void 0,dialect:t.getDialect(),distinct:{on:e}})}return{select:n,selectDistinct:r,selectDistinctOn:i}}select(e){return new cC({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new cC({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn(e,t){return new cC({fields:t??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:e}})}getDialect(){return this.dialect||=new oC(this.dialectConfig),this.dialect}};function bC(e){return X(e,hS)?[e[gx]?`${e[gx]}.${e[Z.Symbol.BaseName]}`:e[Z.Symbol.BaseName]]:X(e,fx)?e._.usedTables??[]:X(e,Q)?e.usedTables??[]:[]}var xC=class extends Xx{constructor(e,t,n,r){super(),this.session=t,this.dialect=n,this.config={table:e,withList:r}}static[Y]=`PgDelete`;config;cacheConfig;where(e){return this.config.where=e,this}returning(e=this.config.table[Z.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=Zx(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return mx.startActiveSpan(`drizzle.prepareQuery`,()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:`delete`,tables:bC(this.config.table)},this.cacheConfig))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>mx.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken));getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new eC({alias:wx(this.config.table),sqlAliasedBehavior:`alias`,sqlBehavior:`error`})):void 0}$dynamic(){return this}},SC=class{constructor(e,t,n,r,i){this.table=e,this.session=t,this.dialect=n,this.withList=r,this.overridingSystemValue_=i}static[Y]=`PgInsertBuilder`;authToken;setToken(e){return this.authToken=e,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values(e){if(e=Array.isArray(e)?e:[e],e.length===0)throw Error(`values() must be called with at least one value`);let t=e.map(e=>{let t={},n=this.table[Z.Symbol.Columns];for(let r of Object.keys(e)){let i=e[r];t[r]=X(i,Q)?i:new Nx(i,n[r])}return t});return new CC(this.table,t,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select(e){let t=typeof e==`function`?e(new yC):e;if(!X(t,Q)&&!Qx(this.table[_x],t._.selectedFields))throw Error(`Insert select error: selected fields are not the same or are in a different order compared to the table definition`);return new CC(this.table,t,this.session,this.dialect,this.withList,!0)}},CC=class extends Xx{constructor(e,t,n,r,i,a,o){super(),this.session=n,this.dialect=r,this.config={table:e,values:t,withList:i,select:a,overridingSystemValue_:o}}static[Y]=`PgInsert`;config;cacheConfig;returning(e=this.config.table[Z.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=Zx(e),this}onConflictDoNothing(e={}){if(e.target===void 0)this.config.onConflict=$`do nothing`;else{let t=``;t=Array.isArray(e.target)?e.target.map(e=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(e))).join(`,`):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target));let n=e.where?$` where ${e.where}`:void 0;this.config.onConflict=$`(${$.raw(t)})${n} do nothing`}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw Error(`You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.`);let t=e.where?$` where ${e.where}`:void 0,n=e.targetWhere?$` where ${e.targetWhere}`:void 0,r=e.setWhere?$` where ${e.setWhere}`:void 0,i=this.dialect.buildUpdateSet(this.config.table,$x(this.config.table,e.set)),a=``;return a=Array.isArray(e.target)?e.target.map(e=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(e))).join(`,`):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target)),this.config.onConflict=$`(${$.raw(a)})${n} do update set ${i}${t}${r}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return mx.startActiveSpan(`drizzle.prepareQuery`,()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:`insert`,tables:bC(this.config.table)},this.cacheConfig))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>mx.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken));getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new eC({alias:wx(this.config.table),sqlAliasedBehavior:`alias`,sqlBehavior:`error`})):void 0}$dynamic(){return this}},wC=class extends Xx{constructor(e,t,n){super(),this.session=t,this.dialect=n,this.config={view:e}}static[Y]=`PgRefreshMaterializedView`;config;concurrently(){if(this.config.withNoData!==void 0)throw Error(`Cannot use concurrently and withNoData together`);return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw Error(`Cannot use concurrently and withNoData together`);return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return mx.startActiveSpan(`drizzle.prepareQuery`,()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,e,!0))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>mx.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken))},TC=class{constructor(e,t,n,r){this.table=e,this.session=t,this.dialect=n,this.withList=r}static[Y]=`PgUpdateBuilder`;authToken;setToken(e){return this.authToken=e,this}set(e){return new EC(this.table,$x(this.table,e),this.session,this.dialect,this.withList).setToken(this.authToken)}},EC=class extends Xx{constructor(e,t,n,r,i){super(),this.session=n,this.dialect=r,this.config={set:t,table:e,withList:i,joins:[]},this.tableName=nS(e),this.joinsNotNullableMap=typeof this.tableName==`string`?{[this.tableName]:!0}:{}}static[Y]=`PgUpdate`;config;tableName;joinsNotNullableMap;cacheConfig;from(e){let t=e,n=nS(t);return typeof n==`string`&&(this.joinsNotNullableMap[n]=!0),this.config.from=t,this}getTableLikeFields(e){return X(e,hS)?e[Z.Symbol.Columns]:X(e,fx)?e._.selectedFields:e[hx].selectedFields}createJoin(e){return(t,n)=>{let r=nS(t);if(typeof r==`string`&&this.config.joins.some(e=>e.alias===r))throw Error(`Alias "${r}" is already used in this query`);if(typeof n==`function`){let e=this.config.from&&!X(this.config.from,Q)?this.getTableLikeFields(this.config.from):void 0;n=n(new Proxy(this.config.table[Z.Symbol.Columns],new eC({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})),e&&new Proxy(e,new eC({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))}if(this.config.joins.push({on:n,table:t,joinType:e,alias:r}),typeof r==`string`)switch(e){case`left`:this.joinsNotNullableMap[r]=!1;break;case`right`:this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[r]=!0;break;case`inner`:this.joinsNotNullableMap[r]=!0;break;case`full`:this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[r]=!1;break}return this}}leftJoin=this.createJoin(`left`);rightJoin=this.createJoin(`right`);innerJoin=this.createJoin(`inner`);fullJoin=this.createJoin(`full`);where(e){return this.config.where=e,this}returning(e){if(!e&&(e=Object.assign({},this.config.table[Z.Symbol.Columns]),this.config.from)){let t=nS(this.config.from);if(typeof t==`string`&&this.config.from&&!X(this.config.from,Q)){let n=this.getTableLikeFields(this.config.from);e[t]=n}for(let t of this.config.joins){let n=nS(t.table);if(typeof n==`string`&&!X(t.table,Q)){let r=this.getTableLikeFields(t.table);e[n]=r}}}return this.config.returningFields=e,this.config.returning=Zx(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){let t=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:`insert`,tables:bC(this.config.table)},this.cacheConfig);return t.joinsNotNullableMap=this.joinsNotNullableMap,t}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>this._prepare().execute(e,this.authToken);getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new eC({alias:wx(this.config.table),sqlAliasedBehavior:`alias`,sqlBehavior:`error`})):void 0}$dynamic(){return this}},DC=class e extends Q{constructor(t){super(e.buildEmbeddedCount(t.source,t.filters).queryChunks),this.params=t,this.mapWith(Number),this.session=t.session,this.sql=e.buildCount(t.source,t.filters)}sql;token;static[Y]=`PgCountBuilder`;[Symbol.toStringTag]=`PgCountBuilder`;session;static buildEmbeddedCount(e,t){return $`(select count(*) from ${e}${$.raw(` where `).if(t)}${t})`}static buildCount(e,t){return $`select count(*) as count from ${e}${$.raw(` where `).if(t)}${t};`}setToken(e){return this.token=e,this}then(e,t){return Promise.resolve(this.session.count(this.sql,this.token)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}},OC=class{constructor(e,t,n,r,i,a,o){this.fullSchema=e,this.schema=t,this.tableNamesMap=n,this.table=r,this.tableConfig=i,this.dialect=a,this.session=o}static[Y]=`PgRelationalQueryBuilder`;findMany(e){return new kC(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},`many`)}findFirst(e){return new kC(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},`first`)}},kC=class extends Xx{constructor(e,t,n,r,i,a,o,s,c){super(),this.fullSchema=e,this.schema=t,this.tableNamesMap=n,this.table=r,this.tableConfig=i,this.dialect=a,this.session=o,this.config=s,this.mode=c}static[Y]=`PgRelationalQuery`;_prepare(e){return mx.startActiveSpan(`drizzle.prepareQuery`,()=>{let{query:t,builtQuery:n}=this._toSQL();return this.session.prepareQuery(n,void 0,e,!0,(e,n)=>{let r=e.map(e=>$S(this.schema,this.tableConfig,e,t.selection,n));return this.mode===`first`?r[0]:r})})}prepare(e){return this._prepare(e)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){let e=this._getQuery(),t=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:t}}toSQL(){return this._toSQL().builtQuery}authToken;setToken(e){return this.authToken=e,this}execute(){return mx.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(void 0,this.authToken))}},AC=class extends Xx{constructor(e,t,n,r){super(),this.execute=e,this.sql=t,this.query=n,this.mapBatchResult=r}static[Y]=`PgRaw`;getSQL(){return this.sql}getQuery(){return this.query}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}},jC=class{constructor(e,t,n){if(this.dialect=e,this.session=t,this._=n?{schema:n.schema,fullSchema:n.fullSchema,tableNamesMap:n.tableNamesMap,session:t}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:t},this.query={},this._.schema)for(let[r,i]of Object.entries(this._.schema))this.query[r]=new OC(n.fullSchema,this._.schema,this._.tableNamesMap,n.fullSchema[r],i,e,t);this.$cache={invalidate:async e=>{}}}static[Y]=`PgDatabase`;query;$with=(e,t)=>{let n=this,r=r=>(typeof r==`function`&&(r=r(new yC(n.dialect))),new Proxy(new px(r.getSQL(),t??(`getSelectedFields`in r?r.getSelectedFields()??{}:{}),e,!0),new eC({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`})));return{as:r}};$count(e,t){return new DC({source:e,filters:t,session:this.session})}$cache;with(...e){let t=this;function n(n){return new cC({fields:n??void 0,session:t.session,dialect:t.dialect,withList:e})}function r(n){return new cC({fields:n??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})}function i(n,r){return new cC({fields:r??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:{on:n}})}function a(n){return new TC(n,t.session,t.dialect,e)}function o(n){return new SC(n,t.session,t.dialect,e)}function s(n){return new xC(n,t.session,t.dialect,e)}return{select:n,selectDistinct:r,selectDistinctOn:i,update:a,insert:o,delete:s}}select(e){return new cC({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new cC({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn(e,t){return new cC({fields:t??void 0,session:this.session,dialect:this.dialect,distinct:{on:e}})}update(e){return new TC(e,this.session,this.dialect)}insert(e){return new SC(e,this.session,this.dialect)}delete(e){return new xC(e,this.session,this.dialect)}refreshMaterializedView(e){return new wC(e,this.session,this.dialect)}authToken;execute(e){let t=typeof e==`string`?$.raw(e):e.getSQL(),n=this.dialect.sqlToQuery(t),r=this.session.prepareQuery(n,void 0,void 0,!1);return new AC(()=>r.execute(void 0,this.authToken),t,n,e=>r.mapResult(e,!0))}transaction(e,t){return this.session.transaction(e,t)}},MC=class{static[Y]=`Cache`},NC=class extends MC{strategy(){return`all`}static[Y]=`NoopCache`;async get(e){}async put(e,t,n,r){}async onMutate(e){}};async function PC(e,t){let n=`${e}-${JSON.stringify(t)}`,r=new TextEncoder,i=r.encode(n),a=await crypto.subtle.digest(`SHA-256`,i),o=[...new Uint8Array(a)],s=o.map(e=>e.toString(16).padStart(2,`0`)).join(``);return s}var FC=class{constructor(e,t,n,r){this.query=e,this.cache=t,this.queryMetadata=n,this.cacheConfig=r,t&&t.strategy()===`all`&&r===void 0&&(this.cacheConfig={enable:!0,autoInvalidate:!0}),this.cacheConfig?.enable||(this.cacheConfig=void 0)}authToken;getQuery(){return this.query}mapResult(e,t){return e}setToken(e){return this.authToken=e,this}static[Y]=`PgPreparedQuery`;joinsNotNullableMap;async queryWithCache(e,t,n){if(this.cache===void 0||X(this.cache,NC)||this.queryMetadata===void 0)try{return await n()}catch(n){throw new Gx(e,t,n)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await n()}catch(n){throw new Gx(e,t,n)}if((this.queryMetadata.type===`insert`||this.queryMetadata.type===`update`||this.queryMetadata.type===`delete`)&&this.queryMetadata.tables.length>0)try{let[e]=await Promise.all([n(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return e}catch(n){throw new Gx(e,t,n)}if(!this.cacheConfig)try{return await n()}catch(n){throw new Gx(e,t,n)}if(this.queryMetadata.type===`select`){let r=await this.cache.get(this.cacheConfig.tag??await PC(e,t),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if(r===void 0){let r;try{r=await n()}catch(n){throw new Gx(e,t,n)}return await this.cache.put(this.cacheConfig.tag??await PC(e,t),r,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),r}return r}try{return await n()}catch(n){throw new Gx(e,t,n)}}},IC=class{constructor(e){this.dialect=e}static[Y]=`PgSession`;execute(e,t){return mx.startActiveSpan(`drizzle.operation`,()=>{let n=mx.startActiveSpan(`drizzle.prepareQuery`,()=>this.prepareQuery(this.dialect.sqlToQuery(e),void 0,void 0,!1));return n.setToken(t).execute(void 0,t)})}all(e){return this.prepareQuery(this.dialect.sqlToQuery(e),void 0,void 0,!1).all()}async count(e,t){let n=await this.execute(e,t);return Number(n[0].count)}},LC=class extends jC{constructor(e,t,n,r=0){super(e,t,n),this.schema=n,this.nestedIndex=r}static[Y]=`PgTransaction`;rollback(){throw new Kx}getTransactionConfigSQL(e){let t=[];return e.isolationLevel&&t.push(`isolation level ${e.isolationLevel}`),e.accessMode&&t.push(e.accessMode),typeof e.deferrable==`boolean`&&t.push(e.deferrable?`deferrable`:`not deferrable`),$.raw(t.join(` `))}setTransaction(e){return this.session.execute($`set transaction ${this.getTransactionConfigSQL(e)}`)}};function RC(e){return typeof e==`string`&&/^true$/i.test(e)}function zC(e){let t={scheme:`duckdb-wasm:`},n=new URL(e);if(!n.protocol.startsWith(`duckdb-wasm:`))throw Error(`Expected scheme to be "duckdb-wasm:" but got "${n.protocol}"`);n.searchParams.get(`bundles`)===`import-url`&&(t.bundles=`import-url`);let r=n.searchParams.get(`logger`);r&&RC(r)&&(t.logger=!0);let i=n.searchParams.get(`storage`);switch(i){case Wb.ORIGIN_PRIVATE_FS:{n.host.length>0&&console.warn(`Host "${n.host}" will be ignored while using Origin Private FS`);let e=n.searchParams.get(`write`);t.storage={type:Wb.ORIGIN_PRIVATE_FS,path:n.pathname.startsWith(`/`)?n.pathname.slice(1):n.pathname,...e&&RC(e)&&{accessMode:Zd.READ_WRITE}};break}case null:break;default:console.warn(`Unknown storage type "${i}"`);break}return t}var BC=class extends FC{static[Y]=`DuckDBWasmPreparedQuery`;constructor(e,t,n,r,i,a){super({sql:t,params:n}),this.client=e,this.queryString=t,this.params=n,this.logger=r,this.fields=i,this.customResultMapper=a}async execute(e={}){let t=Fx(this.params,e);this.logger.logQuery(this.queryString,t);let{fields:n,queryString:r,client:i,customResultMapper:a}=this,o=await i;return o.query(r,t)}async all(e={}){let t=Fx(this.params,e);this.logger.logQuery(this.queryString,t);let n=await this.client;return n.query(this.queryString,t)}},VC=class e extends IC{static[Y]=`DuckDBWasmSession`;logger;constructor(e,t,n,r={}){super(t),this.client=e,this.schema=n,this.options=r,this.logger=r.logger??new Yx}prepareQuery(e,t,n,r,i){return new BC(this.client,e.sql,e.params,this.logger,t,i)}async query(e,t){this.logger.logQuery(e,t);let n=await this.client;return n.query(e,t)}async queryObjects(e,t){this.logger.logQuery(e,t);let n=await this.client;return n.query(e,t)}transaction(t,n){return Kb(this.client,async r=>{let i=new e(r,this.dialect,this.schema,this.options),a=new HC(this.dialect,i,this.schema);return n&&await a.setTransaction(n),t(a)})}},HC=class e extends LC{static[Y]=`DuckDBWasmTransaction`;dialect;session;constructor(e,t,n,r=0){super(e,t,n,r),this.dialect=e,this.session=t}async transaction(t){return qb(this.session.client,``,async n=>{let r=new VC(n,this.dialect,this.schema,this.session.options),i=new e(this.dialect,r,this.schema);return t(i)})}},UC=class extends jC{static[Y]=`DuckDBWasmDatabase`};function WC(e,t={}){let n=new oC({casing:t.casing}),r;t.logger===!0?r=new Jx:t.logger!==!1&&(r=t.logger);let i;if(t.schema){let e=JS(t.schema,QS);i={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let a=new VC(e,n,i,{logger:r}),o=new UC(n,a,i);return o.$client=e,o}function GC(e,t){let n=zC(e),r;if(n.bundles===`import-url`){let e=async()=>{let e=await yb();switch(e){case`browser`:return(await ie(async()=>{let{getImportUrlBundles:e}=await import(`./import-url-browser-agSP1LkN.js`);return{getImportUrlBundles:e}},__vite__mapDeps([4,5,6]))).getImportUrlBundles();case`node`:return await(await ie(async()=>{let{getImportUrlBundles:e}=await import(`./import-url-node-D5qRa4nQ.js`);return{getImportUrlBundles:e}},__vite__mapDeps([7,6]))).getImportUrlBundles();default:throw Error(`Unsupported environment: "${e}"`)}};r=e()}else{let e=async()=>{let e=await yb();switch(e){case`browser`:return(await ie(async()=>{let{getBundles:e}=await import(`./default-browser-89XgBdWi.js`);return{getBundles:e}},[])).getBundles();case`node`:return await(await ie(async()=>{let{getBundles:e}=await import(`./default-node-CHzFd3wA.js`);return{getBundles:e}},__vite__mapDeps([3,1,2]))).getBundles();default:throw Error(`Unsupported environment: "${e}"`)}};r=e()}return WC(Gb({bundles:r,logger:n.logger?new af:void 0,storage:n.storage}),t)}function KC(...e){if(typeof e[0]==`string`)return GC(e[0],e[1]);if(rS(e[0])){let{connection:t,client:n,...r}=e[0];if(n)return WC(n,r);if(typeof t==`string`)return GC(t,r);if(t===void 0)throw Error(`connection option is required`);return WC(Gb({bundles:t.bundles,logger:t.logger,storage:t.storage}),r)}return WC(e[0],e[1])}(function(e){function t(e){return WC({options:{parsers:{},serializers:{}}},e)}e.mock=t})(KC||={});const qC=async({description:e,execute:t,name:n,parameters:r,strict:i})=>{let a=await Ne(r);return{execute:t,function:{description:e,name:n,parameters:i===!1?a:Me(a),strict:i??!0},type:`function`}},JC=f(`ZodISODateTime`,(e,t)=>{Xt.init(e,t),bw.init(e,t)});function YC(e){return rr(JC,e)}const XC=f(`ZodISODate`,(e,t)=>{Yt.init(e,t),bw.init(e,t)});function ZC(e){return nr(XC,e)}const QC=f(`ZodISOTime`,(e,t)=>{Qt.init(e,t),bw.init(e,t)});function $C(e){return Fe(QC,e)}const ew=f(`ZodISODuration`,(e,t)=>{Zt.init(e,t),bw.init(e,t)});function tw(e){return ir(ew,e)}const nw=(e,t)=>{On.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>An(e,t)},flatten:{value:t=>kn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,In,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,In,2)}},isEmpty:{get(){return e.issues.length===0}}})};f(`ZodError`,nw);const rw=f(`ZodError`,nw,{Parent:Error}),iw=bn(rw),aw=xn(rw),ow=En(rw),sw=Dn(rw),cw=vn(rw),lw=gn(rw),uw=yn(rw),dw=_n(rw),fw=wn(rw),pw=Sn(rw),mw=Tn(rw),hw=Cn(rw),gw=f(`ZodType`,(e,t)=>(Et.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>Mn(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>iw(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ow(e,t,n),e.parseAsync=async(t,n)=>aw(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>sw(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>cw(e,t,n),e.decode=(t,n)=>lw(e,t,n),e.encodeAsync=async(t,n)=>uw(e,t,n),e.decodeAsync=async(t,n)=>dw(e,t,n),e.safeEncode=(t,n)=>fw(e,t,n),e.safeDecode=(t,n)=>pw(e,t,n),e.safeEncodeAsync=async(t,n)=>mw(e,t,n),e.safeDecodeAsync=async(t,n)=>hw(e,t,n),e.refine=(t,n)=>e.check(TT(t,n)),e.superRefine=t=>e.check(ET(t)),e.overwrite=t=>e.check(Ye(t)),e.optional=()=>lT(e),e.nullable=()=>dT(e),e.nullish=()=>lT(dT(e)),e.nonoptional=t=>_T(e,t),e.array=()=>Zw(e),e.or=t=>tT([e,t]),e.and=t=>rT(e,t),e.transform=t=>xT(e,sT(t)),e.default=t=>pT(e,t),e.prefault=t=>hT(e,t),e.catch=t=>yT(e,t),e.pipe=t=>xT(e,t),e.readonly=()=>CT(e),e.describe=t=>{let n=e.clone();return ft.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return ft.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return ft.get(e);let n=e.clone();return ft.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),_w=f(`_ZodString`,(e,t)=>{Ct.init(e,t),gw.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Ze(...t)),e.includes=(...t)=>e.check(Qn(...t)),e.startsWith=(...t)=>e.check(Qe(...t)),e.endsWith=(...t)=>e.check(Jn(...t)),e.min=(...t)=>e.check(Ue(...t)),e.max=(...t)=>e.check(He(...t)),e.length=(...t)=>e.check(Re(...t)),e.nonempty=(...t)=>e.check(Ue(1,...t)),e.lowercase=t=>e.check(ze(t)),e.uppercase=t=>e.check(ot(t)),e.trim=()=>e.check(rt()),e.normalize=(...t)=>e.check(qe(...t)),e.toLowerCase=()=>e.check(tt()),e.toUpperCase=()=>e.check(nt())}),vw=f(`ZodString`,(e,t)=>{Ct.init(e,t),_w.init(e,t),e.email=t=>e.check(Kn(xw,t)),e.url=t=>e.check(st(ww,t)),e.jwt=t=>e.check(Ie(zw,t)),e.emoji=t=>e.check(qn(Tw,t)),e.guid=t=>e.check(Zn(Sw,t)),e.uuid=t=>e.check(Pe(Cw,t)),e.uuidv4=t=>e.check(ct(Cw,t)),e.uuidv6=t=>e.check(lt(Cw,t)),e.uuidv7=t=>e.check(ut(Cw,t)),e.nanoid=t=>e.check(Ge(Ew,t)),e.guid=t=>e.check(Zn(Sw,t)),e.cuid=t=>e.check(Un(Dw,t)),e.cuid2=t=>e.check(Wn(Ow,t)),e.ulid=t=>e.check(it(kw,t)),e.base64=t=>e.check(Rn(Iw,t)),e.base64url=t=>e.check(zn(Lw,t)),e.xid=t=>e.check(dt(Aw,t)),e.ksuid=t=>e.check(Le(jw,t)),e.ipv4=t=>e.check(er(Mw,t)),e.ipv6=t=>e.check(tr(Nw,t)),e.cidrv4=t=>e.check(Vn(Pw,t)),e.cidrv6=t=>e.check(Hn(Fw,t)),e.e164=t=>e.check(Gn(Rw,t)),e.datetime=t=>e.check(YC(t)),e.date=t=>e.check(ZC(t)),e.time=t=>e.check($C(t)),e.duration=t=>e.check(tw(t))});function yw(e){return $e(vw,e)}const bw=f(`ZodStringFormat`,(e,t)=>{wt.init(e,t),_w.init(e,t)}),xw=f(`ZodEmail`,(e,t)=>{Ut.init(e,t),bw.init(e,t)}),Sw=f(`ZodGUID`,(e,t)=>{Kt.init(e,t),bw.init(e,t)}),Cw=f(`ZodUUID`,(e,t)=>{kt.init(e,t),bw.init(e,t)}),ww=f(`ZodURL`,(e,t)=>{Ot.init(e,t),bw.init(e,t)}),Tw=f(`ZodEmoji`,(e,t)=>{Wt.init(e,t),bw.init(e,t)}),Ew=f(`ZodNanoID`,(e,t)=>{nn.init(e,t),bw.init(e,t)}),Dw=f(`ZodCUID`,(e,t)=>{Lt.init(e,t),bw.init(e,t)}),Ow=f(`ZodCUID2`,(e,t)=>{Rt.init(e,t),bw.init(e,t)}),kw=f(`ZodULID`,(e,t)=>{Dt.init(e,t),bw.init(e,t)}),Aw=f(`ZodXID`,(e,t)=>{Mt.init(e,t),bw.init(e,t)}),jw=f(`ZodKSUID`,(e,t)=>{tn.init(e,t),bw.init(e,t)}),Mw=f(`ZodIPv4`,(e,t)=>{qt.init(e,t),bw.init(e,t)}),Nw=f(`ZodIPv6`,(e,t)=>{Jt.init(e,t),bw.init(e,t)}),Pw=f(`ZodCIDRv4`,(e,t)=>{Ft.init(e,t),bw.init(e,t)}),Fw=f(`ZodCIDRv6`,(e,t)=>{It.init(e,t),bw.init(e,t)}),Iw=f(`ZodBase64`,(e,t)=>{mt.init(e,t),bw.init(e,t)}),Lw=f(`ZodBase64URL`,(e,t)=>{Nt.init(e,t),bw.init(e,t)}),Rw=f(`ZodE164`,(e,t)=>{Ht.init(e,t),bw.init(e,t)}),zw=f(`ZodJWT`,(e,t)=>{en.init(e,t),bw.init(e,t)}),Bw=f(`ZodNumber`,(e,t)=>{gt.init(e,t),gw.init(e,t),e.gt=(t,n)=>e.check(Yn(t,n)),e.gte=(t,n)=>e.check(Xn(t,n)),e.min=(t,n)=>e.check(Xn(t,n)),e.lt=(t,n)=>e.check(Be(t,n)),e.lte=(t,n)=>e.check(Ve(t,n)),e.max=(t,n)=>e.check(Ve(t,n)),e.int=t=>e.check(Uw(t)),e.safe=t=>e.check(Uw(t)),e.positive=t=>e.check(Yn(0,t)),e.nonnegative=t=>e.check(Xn(0,t)),e.negative=t=>e.check(Be(0,t)),e.nonpositive=t=>e.check(Ve(0,t)),e.multipleOf=(t,n)=>e.check(We(t,n)),e.step=(t,n)=>e.check(We(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Vw(e){return Je(Bw,e)}const Hw=f(`ZodNumberFormat`,(e,t)=>{_t.init(e,t),Bw.init(e,t)});function Uw(e){return $n(Hw,e)}const Ww=f(`ZodBoolean`,(e,t)=>{Pt.init(e,t),gw.init(e,t)});function Gw(e){return Bn(Ww,e)}const Kw=f(`ZodUnknown`,(e,t)=>{jt.init(e,t),gw.init(e,t)});function qw(){return at(Kw)}const Jw=f(`ZodNever`,(e,t)=>{rn.init(e,t),gw.init(e,t)});function Yw(e){return Ke(Jw,e)}const Xw=f(`ZodArray`,(e,t)=>{pt.init(e,t),gw.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(Ue(t,n)),e.nonempty=t=>e.check(Ue(1,t)),e.max=(t,n)=>e.check(He(t,n)),e.length=(t,n)=>e.check(Re(t,n)),e.unwrap=()=>e.element});function Zw(e,t){return Ln(Xw,e,t)}const Qw=f(`ZodObject`,(e,t)=>{vt.init(e,t),gw.init(e,t),Nn(e,`shape`,()=>t.shape),e.keyof=()=>aT(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:qw()}),e.loose=()=>e.clone({...e._zod.def,catchall:qw()}),e.strict=()=>e.clone({...e._zod.def,catchall:Yw()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Pn(e,t),e.safeExtend=t=>pn(e,t),e.merge=t=>on(e,t),e.pick=t=>dn(e,t),e.omit=t=>ln(e,t),e.partial=(...t)=>un(cT,e,t[0]),e.required=(...t)=>fn(gT,e,t[0])});function $w(e,t){let n={type:`object`,get shape(){return jn(this,`shape`,e?cn(e):{}),this.shape},...sn(t)};return new Qw(n)}const eT=f(`ZodUnion`,(e,t)=>{At.init(e,t),gw.init(e,t),e.options=t.options});function tT(e,t){return new eT({type:`union`,options:e,...sn(t)})}const nT=f(`ZodIntersection`,(e,t)=>{$t.init(e,t),gw.init(e,t)});function rT(e,t){return new nT({type:`intersection`,left:e,right:t})}const iT=f(`ZodEnum`,(e,t)=>{Gt.init(e,t),gw.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new iT({...t,checks:[],...sn(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new iT({...t,checks:[],...sn(r),entries:i})}});function aT(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new iT({type:`enum`,entries:n,...sn(t)})}const oT=f(`ZodTransform`,(e,t)=>{Tt.init(e,t),gw.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new hn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Fn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Fn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function sT(e){return new oT({type:`transform`,transform:e})}const cT=f(`ZodOptional`,(e,t)=>{yt.init(e,t),gw.init(e,t),e.unwrap=()=>e._zod.def.innerType});function lT(e){return new cT({type:`optional`,innerType:e})}const uT=f(`ZodNullable`,(e,t)=>{ht.init(e,t),gw.init(e,t),e.unwrap=()=>e._zod.def.innerType});function dT(e){return new uT({type:`nullable`,innerType:e})}const fT=f(`ZodDefault`,(e,t)=>{Vt.init(e,t),gw.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function pT(e,t){return new fT({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():mn(t)}})}const mT=f(`ZodPrefault`,(e,t)=>{xt.init(e,t),gw.init(e,t),e.unwrap=()=>e._zod.def.innerType});function hT(e,t){return new mT({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():mn(t)}})}const gT=f(`ZodNonOptional`,(e,t)=>{an.init(e,t),gw.init(e,t),e.unwrap=()=>e._zod.def.innerType});function _T(e,t){return new gT({type:`nonoptional`,innerType:e,...sn(t)})}const vT=f(`ZodCatch`,(e,t)=>{zt.init(e,t),gw.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function yT(e,t){return new vT({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const bT=f(`ZodPipe`,(e,t)=>{bt.init(e,t),gw.init(e,t),e.in=t.in,e.out=t.out});function xT(e,t){return new bT({type:`pipe`,in:e,out:t})}const ST=f(`ZodReadonly`,(e,t)=>{St.init(e,t),gw.init(e,t),e.unwrap=()=>e._zod.def.innerType});function CT(e){return new ST({type:`readonly`,innerType:e})}const wT=f(`ZodCustom`,(e,t)=>{Bt.init(e,t),gw.init(e,t)});function TT(e,t={}){return Xe(wT,e,t)}function ET(e){return et(e)}const DT=[qC({name:`debug_random_number`,description:`Generate a random number between 0 and 1`,execute:async()=>new Promise(e=>{setTimeout(()=>{e(Math.random().toString())},1e3)}),parameters:$w({})})],OT=async()=>Promise.all(DT);var kT,AT,jT,MT,NT;kT=new WeakMap,AT=new WeakMap,jT=new WeakMap,MT=new WeakMap;async function PT(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}NT=new WeakMap;async function FT(e,t){await PT(`plugin:mcp|connect_server`,{command:e,args:t})}async function IT(){await PT(`plugin:mcp|disconnect_server`)}async function LT(){return await PT(`plugin:mcp|list_tools`)}async function RT(e,t){return await PT(`plugin:mcp|call_tool`,{name:e,args:t})}const zT=[qC({name:`mcp_list_tools`,description:`List all tools available on the MCP server`,execute:async(e,t)=>await LT(),parameters:$w({})}),qC({name:`mcp_connect_server`,description:`Connect to the MCP server. If "success", the connection to the MCP server is successful. Otherwise, the connection fails.`,execute:async({command:e,args:t})=>(await FT(e,t),`success`),parameters:$w({command:yw().describe(`The command to connect to the MCP server`),args:Zw(yw()).describe(`The arguments to pass to the MCP server`)})}),qC({name:`mcp_disconnect_server`,description:`Disconnect from the MCP server. If "success", the disconnection from the MCP server is successful. Otherwise, the disconnection fails.`,execute:async()=>(await IT(),`success`),parameters:$w({})}),qC({name:`mcp_call_tool`,description:`Call a tool on the MCP server. The result is a list of content and a boolean indicating whether the tool call is an error.`,execute:async({name:e,parameters:t})=>{let n=Object.fromEntries(t.map(({name:e,value:t})=>[e,t])),r=await RT(e,n);return r},parameters:$w({name:yw().describe(`The name of the tool to call`),parameters:Zw($w({name:yw().describe(`The name of the parameter`),value:tT([yw(),Vw(),Gw(),$w({})]).describe(`The value of the parameter, it can be a string, a number, a boolean, or an object`)})).describe(`The parameters to pass to the tool`)})})],BT=async()=>Promise.all(zT);function VT(e,t,n,r,i=new Map){return!!(r?.supportsTools||i.get(`${t.chat(e).baseURL}-${e}`))}async function HT(e,t,n,r){let i=r?.headers;return await Ee({...t.chat(e),maxSteps:10,messages:n.map(e=>({...e,content:e.role===`error`?`User encountered error: ${e.content}`:e.content,role:e.role===`error`?`user`:e.role})),headers:i,tools:VT(e,t,n,r)?[...await BT(),...await OT()]:void 0,onEvent(e){r?.onStreamEvent?.(e)}})}async function UT(e,t,n,r){async function i(n){try{let i=await HT(e,t,[{role:`user`,content:`Hello, world!`}],{...r,supportsTools:n});for await(let e of or(i.textStream));return!0}catch(e){if(e instanceof Error&&e.name===new d(``).name&&(String(e).includes(`does not support tools`)||String(e).includes(`No endpoints found that support tool use.`)))return!1;throw e}}function a(e,t){return new Promise(n=>{let r=[],i=0;e.forEach((a,o)=>{setTimeout(()=>{a().then(e=>{r[o]={result:e}}).catch(e=>{r[o]={error:e}}).finally(()=>{i++,i===e.length&&n(r)})},o*t)})})}let o=[()=>i(!0),()=>i(!1)],s=await a(o,1e3);if(s.some(e=>e.error)){let t=Error(`Error during tools compatibility discovery for model: ${e}. Errors: ${s.map(e=>e.error).filter(Boolean).join(`, `)}`);throw t.cause=s.map(e=>e.error).filter(Boolean),t}return s[0].result===!0&&s[1].result===!0}const WT=ae(`llm`,()=>{let e=xe(new Map);async function t(t,n,r,i){if(e.value.has(`${n.chat(t).baseURL}-${t}`))return;let a=await UT(t,n,r,{...i,toolsCompatibility:e.value});e.value.set(`${n.chat(t).baseURL}-${t}`,a)}function n(t,n,r,i){return HT(t,n,r,{...i,toolsCompatibility:e.value})}async function r(e,t){if(e===``)return[];try{return await u({baseURL:e.endsWith(`/`)?e:`${e}/`,apiKey:t})}catch(e){if(String(e).includes(`Failed to construct 'URL': Invalid URL`))return[];throw e}}return{models:r,stream:n,discoverToolsCompatibility:t}}),GT=ae(`chat`,()=>{let{stream:e,discoverToolsCompatibility:t}=WT(),{systemPrompt:n}=oe(ar()),r=xe(!1),i=xe([]),a=xe([]),o=xe([]),l=xe([]),u=xe([]),d=xe([]),ee=xe([]),te=xe([]);function ne(e){i.value.push(e)}function re(e){a.value.push(e)}function ie(e){o.value.push(e)}function ae(e){l.value.push(e)}function ce(e){u.value.push(e)}function le(e){d.value.push(e)}function ue(e){ee.value.push(e)}function de(e){te.value.push(e)}function fe(){return{role:`system`,content:"- For any programming code block, always specify the programming language that supported on @shikijs/rehype on the rendered markdown, eg. ```python ... ```\n- For any math equation, use LaTeX format, eg: $ x^3 $, always escape dollar sign outside math equation\n"+n.value}}let pe=se(`chat/messages`,[fe()]);function me(){pe.value=[fe()]}be(n,()=>{pe.value.length>0&&pe.value[0].role===`system`&&(pe.value[0]=fe())},{immediate:!0});let he=xe({role:`assistant`,content:``,slices:[],tool_results:[]});async function ge(t,n){try{if(r.value=!0,!t&&!n.attachments?.length)return;for(let e of i.value)await e(t);let ne=[{type:`text`,text:t}];if(n.attachments)for(let e of n.attachments)e.type===`image`&&ne.push({type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}});let re=ne.length>1?ne:t;pe.value.push({role:`user`,content:re});let ie=je({onLiteral:async e=>{for(let t of u.value)await t(e);he.value.content+=e;let t=he.value.slices.at(-1);if(t?.type===`text`){t.text+=e;return}he.value.slices.push({type:`text`,text:e})},onSpecial:async e=>{for(let t of d.value)await t(e)},minLiteralEmitLength:24}),ae=c({handlers:[async e=>{if(e.data.type===`tool-call`){he.value.slices.push(e.data);return}e.data.type===`tool-call-result`&&he.value.tool_results.push(e.data)}]});he.value={role:`assistant`,content:``,slices:[],tool_results:[]};let oe=pe.value.map(e=>{if(e.role===`assistant`){let{slices:t,...n}=e;return n.tool_results=Se(n.tool_results),Se(n)}return Se(e)});for(let e of a.value)await e(t);for(let e of o.value)await e(t);let se=``,ce=n.providerConfig?.headers||{};await e(n.model,n.chatProvider,oe,{headers:ce,async onStreamEvent(e){if(e.type===`tool-call`)ae.enqueue({type:`tool-call`,toolCall:e});else if(e.type===`tool-result`)ae.enqueue({type:`tool-call-result`,id:e.toolCallId,result:e.result});else if(e.type===`text-delta`)se+=e.text,await ie.consume(e.text);else if(e.type===`finish`){await ie.end(),he.value.slices.length>0&&pe.value.push(Se(he.value)),he.value={role:`assistant`,content:``,slices:[],tool_results:[]};let e=`${s}${s}`;for(let t of u.value)await t(e);for(let e of ee.value)await e();for(let e of te.value)await e(se);console.debug(`LLM output:`,se)}}});for(let e of l.value)await e(t)}catch(e){throw console.error(`Error sending message:`,e),e}finally{r.value=!1}}return{sending:r,messages:pe,streamingMessage:he,discoverToolsCompatibility:t,send:ge,cleanupMessages:me,onBeforeMessageComposed:ne,onAfterMessageComposed:re,onBeforeSend:ie,onAfterSend:ae,onTokenLiteral:ce,onTokenSpecial:le,onStreamEnd:ue,onAssistantResponseEnd:de}}),KT={relative:``},qT={"h-full":``,"w-full":``};var JT=me({__name:`Stage`,props:he({paused:{type:Boolean,default:!1},focusAt:{},xOffset:{},yOffset:{},scale:{default:1}},{state:{default:`pending`},stateModifiers:{}}),emits:[`update:state`],setup(s,{expose:u}){let d=ye(s,`state`),ie=xe(),ae=xe(),se=xe(),le=ce(),{stageModelRenderer:me,stageViewControlsEnabled:he,live2dDisableFocus:be,stageModelSelectedUrl:Se}=oe(le),{mouthOpenSize:we}=oe(r()),{audioContext:Te,calculateVolume:Ee}=n(),{onBeforeMessageComposed:je,onBeforeSend:Me,onTokenLiteral:Ne,onTokenSpecial:Pe,onStreamEnd:Fe,onAssistantResponseEnd:Ie}=GT(),Le=l(),Re=ke(),ze=xe(!0);Re.onShouldUpdateView(async()=>{ze.value=!1,await le.updateStageModel(),setTimeout(()=>{ze.value=!0},100)});let Be=xe(),Ve=xe(!1),He=xe(!1),Ue=null,We=c({handlers:[e=>new Promise(t=>{if(Ue){try{Ue.stop(),Ue.disconnect()}catch{}Ue=null}let n=Te.createBufferSource();n.buffer=e.data.audioBuffer,n.connect(Te.destination),n.connect(Be.value),Ve.value=!0,Ue=n,n.start(0),n.onended=()=>{Ve.value=!1,Ue===n&&(Ue=null),t()}})]}),Ge=e(),{ssmlEnabled:Ke,activeSpeechProvider:qe,activeSpeechModel:Je,activeSpeechVoice:Ye,pitch:Xe}=oe(Ge);async function Ze(e){try{if(!qe.value){console.warn(`No active speech provider configured`);return}if(!Ye.value){console.warn(`No active speech voice configured`);return}let n=await Le.getProviderInstance(qe.value);if(!n){console.error(`Failed to initialize speech provider`);return}let r=Le.getProviderConfig(qe.value),i=Ke.value?Ge.generateSSML(e.data,Ye.value,{...r,pitch:Xe.value}):e.data,a=await t({...n.speech(Je.value,r),input:i,voice:Ye.value.id}),o=await Te.decodeAudioData(a);We.enqueue({audioBuffer:o,text:e.data})}catch(e){console.error(`Speech generation failed:`,e)}}let Qe=c({handlers:[Ze]}),$e=o(Qe),{currentMotion:et}=oe(ke()),tt=c({handlers:[async e=>{if(me.value===`vrm`){let t=ne[e.data];if(!t)return;await ae.value.setExpression(t)}else me.value===`live2d`&&(et.value={group:te[e.data]})}]}),nt=a(tt);nt.onHandlerEvent(`emotion`,e=>{console.debug(`emotion detected`,e)});let rt=i();rt.onHandlerEvent(`delay`,e=>{console.debug(`delay detected`,e)});function it(){requestAnimationFrame(it),Ve.value&&(we.value=Ee(Be.value,`linear`))}function at(){He.value||=(it(),Te.resume(),!0)}function ot(){Be.value||=Te.createAnalyser()}je(async()=>{if(Ue){try{Ue.stop(),Ue.disconnect()}catch{}Ue=null}We.clear(),ot(),at()}),Me(async()=>{et.value={group:re}}),Ne(async e=>{$e.enqueue(e)}),Pe(async e=>{rt.enqueue(e),nt.enqueue(e)}),Fe(async()=>{rt.enqueue(ee)}),Ie(async e=>{}),_e(()=>{He.value=!1}),ge(async()=>{ie.value=KC({connection:{bundles:Ae()}}),await ie.value.execute(`CREATE TABLE memory_test (vec FLOAT[768]);`)});function st(){if(me.value===`live2d`)return se.value?.canvasElement();if(me.value===`vrm`)return ae.value?.canvasElement()}return u({canvasElement:st}),(e,t)=>(ve(),pe(`div`,KT,[ue(`div`,qT,[Ce(me)===`live2d`&&ze.value?(ve(),de(Oe,{key:0,ref_key:`live2dSceneRef`,ref:se,state:d.value,"onUpdate:state":t[0]||=e=>d.value=e,"min-w":`50%