diff --git "a/assets/Scenes-DoqkIk4S.js" "b/assets/Scenes-DoqkIk4S.js" deleted file mode 100644--- "a/assets/Scenes-DoqkIk4S.js" +++ /dev/null @@ -1,2488 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-Bi5T_TG6.js","assets/index-DSeFf4fC.js","assets/index-BxFO96Af.css","assets/default-node-DcE314Tg.js","assets/import-url-browser-agSP1LkN.js","assets/import-url-browser-CQxpIBxI.js","assets/duckdb-mvp-DkPAVKN8.js","assets/import-url-node-Cmtz-q5h.js"])))=>i.map(i=>d[i]); -import{A as e,L as t,M as n,P as r,Q as i,R as a,S as o,T as s,U as c,V as l,a4 as u,a6 as d,a7 as f,aC as p,aE as m,aF as h,aG as ee,aH as te,aI as ne,aP as re,am as ie,bO as ae,bP as oe,bQ as se,bR as ce,bS as le,bT as ue,bV as de,bX as fe,bZ as pe,c as me,c0 as he,cA as ge,cB as _e,cC as ve,cE as ye,cF as be,cG as xe,cH as Se,cI as Ce,cJ as we,cK as Te,cL as Ee,cM as De,cN as Oe,cP as ke,cR as Ae,cS as je,cT as Me,cV as Ne,cW as Pe,cX as Fe,c_ as Ie,ca as Le,cb as Re,cc as ze,cd as Be,ce as Ve,cf as He,cg as Ue,ch as We,ci as Ge,cm as Ke,co as qe,cp as Je,cq as Ye,cs as Xe,cu as Ze,cv as Qe,cy as $e,cz as et,d$ as tt,d8 as nt,dA as rt,dB as it,dC as at,dF as ot,dG as st,dH as ct,dM as lt,dO as ut,dP as dt,dQ as ft,dR as pt,dS as mt,dT as ht,dU as gt,dV as _t,dW as vt,dX as yt,dY as bt,dZ as xt,d_ as St,dd as Ct,de as wt,dg as Tt,dh as Et,dk as Dt,dl as Ot,dm as kt,dn as At,dq as jt,dr as Mt,ds as Nt,dt as Pt,du as Ft,dv as It,dx as Lt,e$ as Rt,e3 as zt,e4 as Bt,e6 as Vt,e8 as Ht,eA as Ut,eB as Wt,eC as Gt,eD as Kt,eG as qt,eH as Jt,eI as Yt,eK as Xt,eM as Zt,eO as Qt,eP as $t,eQ as en,eR as tn,eS as nn,eU as rn,eX as an,eZ as on,e_ as sn,ed as cn,ee as ln,ef as un,eg as dn,eh as fn,ei as pn,ej as mn,ek as hn,el as gn,em as _n,en as vn,eo as yn,et as bn,ew as xn,ey as Sn,ez as Cn,f0 as wn,f2 as g,f3 as Tn,f4 as En,f5 as Dn,f7 as On,f9 as kn,fe as An,fh as jn,g as Mn,h as Nn,i as Pn,k as Fn,l as _,m as In,n as Ln,o as Rn,p as zn,q as Bn,r as Vn,s as Hn,t as Un,u as Wn,v as Gn,w as Kn,x as qn,y as Jn,z as Yn}from"./index-DSeFf4fC.js";import{b as Xn}from"./dist-C8qSkDKz.js";import{b as Zn,c as Qn,d as $n,e as er,f as tr,g as nr,h as rr,i as ir,j as ar,k as or,l as sr,m as cr,n as lr,o as ur,p as dr}from"./ibl-BnxAT56Q.js";import{b as fr}from"./import-url-browser-CQxpIBxI.js";import{c as pr,d as mr}from"./index-CAcLDIRJ-jCq6B4vh.js";import{$ as hr,A as gr,B as _r,C as vr,D as yr,E as br,F as xr,G as Sr,H as Cr,I as wr,J as Tr,K as Er,L as Dr,M as Or,N as kr,O as Ar,P as jr,Q as Mr,R as Nr,S as Pr,T as Fr,U as Ir,V as Lr,W as Rr,X as zr,Y as Br,Z as Vr,_ as Hr,a1 as Ur,a2 as Wr,a3 as Gr,a4 as Kr,a6 as qr,a8 as Jr,a9 as Yr,aA as Xr,aB as Zr,aC as Qr,aE as $r,aF as ei,aG as ti,aH as ni,aI as ri,aJ as ii,aK as ai,aL as oi,aM as si,aN as ci,aO as li,aP as ui,aQ as di,aR as fi,aS as pi,aa as mi,ab as hi,ac as gi,ad as _i,ae as vi,af as yi,ag as bi,ah as xi,ai as Si,aj as Ci,ak as wi,al as Ti,am as Ei,an as Di,ao as Oi,ap as ki,aq as Ai,ar as ji,as as Mi,at as Ni,au as Pi,av as Fi,aw as Ii,ax as Li,ay as Ri,az as zi,bA as Bi,bB as Vi,bC as Hi,bD as Ui,bE as Wi,bF as Gi,bG as Ki,bH as qi,bI as Ji,bK as Yi,bL as v,bc as Xi,bd as Zi,be as Qi,bf as $i,bg as ea,bh as ta,bi as na,bj as ra,bk as ia,bl as aa,bm as oa,bn as sa,bq as ca,bs as la,bt as ua,bu as da,bv as fa,bw as pa,bx as ma,by as ha,bz as ga,d as _a,e as va,f as ya,g as ba,i as xa,j as Sa,k as Ca,l as wa,m as Ta,n as Ea,o as Da,p as Oa,q as ka,r as Aa,s as ja,t as Ma,u as Na,v as Pa,w as Fa,x as Ia,y as La,z as Ra}from"./core-C5TqIlxQ.js";import{b as za}from"./airi-card-B-x_ytIA.js";async function*Ba(e){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}}var Va=Jt({__name:`Canvas`,props:Zt({width:{},height:{},resolution:{default:2}},{state:{default:`pending`},stateModifiers:{}}),emits:[`update:state`],setup(e,{expose:t}){let n=e,r=an(e,`state`),i=g(),a=g(!1),o=g(),s=g();async function c(e){r.value=`loading`,a.value=!1,Nn.registerTicker(Vn),Un.add(Hn),o.value=new Fn({width:n.width*n.resolution,height:n.height*n.resolution,backgroundAlpha:0,preserveDrawingBuffer:!0}),s.value=o.value.view,s.value.style.width=`100%`,s.value.style.height=`100%`,s.value.style.objectFit=`cover`,s.value.style.display=`block`,e.appendChild(o.value.view),a.value=!0,r.value=`mounted`}function l(){o.value&&o.value.renderer.resize(n.width,n.height)}on([()=>n.width,()=>n.height],()=>l()),on(()=>n.resolution,e=>{o.value&&e&&(o.value.renderer.resolution=e,l())}),$t(async()=>i.value&&await c(i.value)),en(()=>o.value?.destroy());async function u(){let e=new Promise(e=>{if(!s.value||!o.value)return e(null);o.value.render(),s.value.toBlob(e)});return e}function d(){return s.value}return t({captureFrame:u,canvasElement:d}),(e,t)=>(tn(),Kt(`div`,{ref_key:`containerRef`,ref:i,"h-full":``,"w-full":``},[a.value?rn(e.$slots,`default`,{key:0,app:o.value}):Gt(``,!0)],512))}}),Ha=Va,Ua=function(e,t){return Ua=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Ua(e,t)};function Wa(e,t){Ua(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Ga=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,Ka=`varying vec2 vTextureCoord; -uniform sampler2D uSampler; - -uniform float gamma; -uniform float contrast; -uniform float saturation; -uniform float brightness; -uniform float red; -uniform float green; -uniform float blue; -uniform float alpha; - -void main(void) -{ - vec4 c = texture2D(uSampler, vTextureCoord); - - if (c.a > 0.0) { - c.rgb /= c.a; - - vec3 rgb = pow(c.rgb, vec3(1. / gamma)); - rgb = mix(vec3(.5), mix(vec3(dot(vec3(.2125, .7154, .0721), rgb)), rgb, saturation), contrast); - rgb.r *= red; - rgb.g *= green; - rgb.b *= blue; - c.rgb = rgb * brightness; - - c.rgb *= c.a; - } - - gl_FragColor = c * alpha; -} -`;(function(e){Wa(t,e);function t(t){var n=e.call(this,Ga,Ka)||this;return n.gamma=1,n.saturation=1,n.contrast=1,n.brightness=1,n.red=1,n.green=1,n.blue=1,n.alpha=1,Object.assign(n,t),n}return t.prototype.apply=function(e,t,n,r){this.uniforms.gamma=Math.max(this.gamma,1e-4),this.uniforms.saturation=this.saturation,this.uniforms.contrast=this.contrast,this.uniforms.brightness=this.brightness,this.uniforms.red=this.red,this.uniforms.green=this.green,this.uniforms.blue=this.blue,this.uniforms.alpha=this.alpha,e.applyFilter(this,t,n,r)},t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var qa=function(e,t){return qa=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},qa(e,t)};function Ja(e,t){qa(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Ya=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,Xa=` -varying vec2 vTextureCoord; -uniform sampler2D uSampler; - -uniform vec2 uOffset; - -void main(void) -{ - vec4 color = vec4(0.0); - - // Sample top left pixel - color += texture2D(uSampler, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y)); - - // Sample top right pixel - color += texture2D(uSampler, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y)); - - // Sample bottom right pixel - color += texture2D(uSampler, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y)); - - // Sample bottom left pixel - color += texture2D(uSampler, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y)); - - // Average - color *= 0.25; - - gl_FragColor = color; -}`,Za=` -varying vec2 vTextureCoord; -uniform sampler2D uSampler; - -uniform vec2 uOffset; -uniform vec4 filterClamp; - -void main(void) -{ - vec4 color = vec4(0.0); - - // Sample top left pixel - color += texture2D(uSampler, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y), filterClamp.xy, filterClamp.zw)); - - // Sample top right pixel - color += texture2D(uSampler, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y), filterClamp.xy, filterClamp.zw)); - - // Sample bottom right pixel - color += texture2D(uSampler, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y), filterClamp.xy, filterClamp.zw)); - - // Sample bottom left pixel - color += texture2D(uSampler, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y), filterClamp.xy, filterClamp.zw)); - - // Average - color *= 0.25; - - gl_FragColor = color; -} -`,Qa=function(e){Ja(t,e);function t(t,n,r){t===void 0&&(t=4),n===void 0&&(n=3),r===void 0&&(r=!1);var i=e.call(this,Ya,r?Za:Xa)||this;return i._kernels=[],i._blur=4,i._quality=3,i.uniforms.uOffset=new Float32Array(2),i._pixelSize=new Bn,i.pixelSize=1,i._clamp=r,Array.isArray(t)?i.kernels=t:(i._blur=t,i.quality=n),i}return t.prototype.apply=function(e,t,n,r){var i=this._pixelSize.x/t._frame.width,a=this._pixelSize.y/t._frame.height,o;if(this._quality===1||this._blur===0)o=this._kernels[0]+.5,this.uniforms.uOffset[0]=o*i,this.uniforms.uOffset[1]=o*a,e.applyFilter(this,t,n,r);else{for(var s=e.getFilterTexture(),c=t,l=s,u=void 0,d=this._quality-1,f=0;f0)for(var r=e,i=e/t,a=1;a0?(this._kernels=e,this._quality=e.length,this._blur=Math.max.apply(Math,e)):(this._kernels=[0],this._quality=1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`clamp`,{get:function(){return this._clamp},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`pixelSize`,{get:function(){return this._pixelSize},set:function(e){typeof e==`number`?(this._pixelSize.x=e,this._pixelSize.y=e):Array.isArray(e)?(this._pixelSize.x=e[0],this._pixelSize.y=e[1]):e instanceof Bn?(this._pixelSize.x=e.x,this._pixelSize.y=e.y):(this._pixelSize.x=1,this._pixelSize.y=1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`quality`,{get:function(){return this._quality},set:function(e){this._quality=Math.max(1,Math.round(e)),this._generateKernels()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`blur`,{get:function(){return this._blur},set:function(e){this._blur=e,this._generateKernels()},enumerable:!1,configurable:!0}),t}(_),$a=function(e,t){return $a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},$a(e,t)};function eo(e,t){$a(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var to=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,no=` -uniform sampler2D uSampler; -varying vec2 vTextureCoord; - -uniform float threshold; - -void main() { - vec4 color = texture2D(uSampler, vTextureCoord); - - // A simple & fast algorithm for getting brightness. - // It's inaccuracy , but good enought for this feature. - float _max = max(max(color.r, color.g), color.b); - float _min = min(min(color.r, color.g), color.b); - float brightness = (_max + _min) * 0.5; - - if(brightness > threshold) { - gl_FragColor = color; - } else { - gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); - } -} -`,ro=function(e){eo(t,e);function t(t){t===void 0&&(t=.5);var n=e.call(this,to,no)||this;return n.threshold=t,n}return Object.defineProperty(t.prototype,`threshold`,{get:function(){return this.uniforms.threshold},set:function(e){this.uniforms.threshold=e},enumerable:!1,configurable:!0}),t}(_),io=`uniform sampler2D uSampler; -varying vec2 vTextureCoord; - -uniform sampler2D bloomTexture; -uniform float bloomScale; -uniform float brightness; - -void main() { - vec4 color = texture2D(uSampler, vTextureCoord); - color.rgb *= brightness; - vec4 bloomColor = vec4(texture2D(bloomTexture, vTextureCoord).rgb, 0.0); - bloomColor.rgb *= bloomScale; - gl_FragColor = color + bloomColor; -} -`;(function(e){eo(t,e);function t(n){var r=e.call(this,to,io)||this;r.bloomScale=1,r.brightness=1,r._resolution=Kn.FILTER_RESOLUTION,typeof n==`number`&&(n={threshold:n});var i=Object.assign(t.defaults,n);r.bloomScale=i.bloomScale,r.brightness=i.brightness;var a=i.kernels,o=i.blur,s=i.quality,c=i.pixelSize,l=i.resolution;return r._extractFilter=new ro(i.threshold),r._extractFilter.resolution=l,r._blurFilter=a?new Qa(a):new Qa(o,s),r.pixelSize=c,r.resolution=l,r}return t.prototype.apply=function(e,t,n,r,i){var a=e.getFilterTexture();this._extractFilter.apply(e,t,a,1,i);var o=e.getFilterTexture();this._blurFilter.apply(e,a,o,1),this.uniforms.bloomScale=this.bloomScale,this.uniforms.brightness=this.brightness,this.uniforms.bloomTexture=o,e.applyFilter(this,t,n,r),e.returnFilterTexture(o),e.returnFilterTexture(a)},Object.defineProperty(t.prototype,`resolution`,{get:function(){return this._resolution},set:function(e){this._resolution=e,this._extractFilter&&(this._extractFilter.resolution=e),this._blurFilter&&(this._blurFilter.resolution=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`threshold`,{get:function(){return this._extractFilter.threshold},set:function(e){this._extractFilter.threshold=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`kernels`,{get:function(){return this._blurFilter.kernels},set:function(e){this._blurFilter.kernels=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`blur`,{get:function(){return this._blurFilter.blur},set:function(e){this._blurFilter.blur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`quality`,{get:function(){return this._blurFilter.quality},set:function(e){this._blurFilter.quality=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`pixelSize`,{get:function(){return this._blurFilter.pixelSize},set:function(e){this._blurFilter.pixelSize=e},enumerable:!1,configurable:!0}),t.defaults={threshold:.5,bloomScale:1,brightness:1,kernels:null,blur:8,quality:4,pixelSize:1,resolution:Kn.FILTER_RESOLUTION},t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var ao=function(e,t){return ao=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},ao(e,t)};function oo(e,t){ao(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var so=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,co=`varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - - if (clamp(p.x, 0.0, 4.0) == p.x) - { - if (clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} -`;(function(e){oo(t,e);function t(t){t===void 0&&(t=8);var n=e.call(this,so,co)||this;return n.size=t,n}return Object.defineProperty(t.prototype,`size`,{get:function(){return this.uniforms.pixelSize},set:function(e){this.uniforms.pixelSize=e},enumerable:!1,configurable:!0}),t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var lo=function(e,t){return lo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},lo(e,t)};function uo(e,t){lo(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var fo=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,po=`precision mediump float; - -varying vec2 vTextureCoord; -uniform sampler2D uSampler; -uniform vec4 filterArea; - -uniform float transformX; -uniform float transformY; -uniform vec3 lightColor; -uniform float lightAlpha; -uniform vec3 shadowColor; -uniform float shadowAlpha; - -void main(void) { - vec2 transform = vec2(1.0 / filterArea) * vec2(transformX, transformY); - vec4 color = texture2D(uSampler, vTextureCoord); - float light = texture2D(uSampler, vTextureCoord - transform).a; - float shadow = texture2D(uSampler, vTextureCoord + transform).a; - - color.rgb = mix(color.rgb, lightColor, clamp((color.a - light) * lightAlpha, 0.0, 1.0)); - color.rgb = mix(color.rgb, shadowColor, clamp((color.a - shadow) * shadowAlpha, 0.0, 1.0)); - gl_FragColor = vec4(color.rgb * color.a, color.a); -} -`;(function(e){uo(t,e);function t(t){var n=e.call(this,fo,po)||this;return n._thickness=2,n._angle=0,n.uniforms.lightColor=new Float32Array(3),n.uniforms.shadowColor=new Float32Array(3),Object.assign(n,{rotation:45,thickness:2,lightColor:16777215,lightAlpha:.7,shadowColor:0,shadowAlpha:.7},t),n.padding=1,n}return t.prototype._updateTransform=function(){this.uniforms.transformX=this._thickness*Math.cos(this._angle),this.uniforms.transformY=this._thickness*Math.sin(this._angle)},Object.defineProperty(t.prototype,`rotation`,{get:function(){return this._angle/Rn},set:function(e){this._angle=e*Rn,this._updateTransform()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`thickness`,{get:function(){return this._thickness},set:function(e){this._thickness=e,this._updateTransform()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`lightColor`,{get:function(){return Gn(this.uniforms.lightColor)},set:function(e){Wn(e,this.uniforms.lightColor)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`lightAlpha`,{get:function(){return this.uniforms.lightAlpha},set:function(e){this.uniforms.lightAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`shadowColor`,{get:function(){return Gn(this.uniforms.shadowColor)},set:function(e){Wn(e,this.uniforms.shadowColor)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`shadowAlpha`,{get:function(){return this.uniforms.shadowAlpha},set:function(e){this.uniforms.shadowAlpha=e},enumerable:!1,configurable:!0}),t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var mo=function(e,t){return mo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},mo(e,t)};function ho(e,t){mo(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var go=`varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float uAlpha; - -void main(void) -{ - gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha; -} -`,_o=function(e){ho(t,e);function t(t){t===void 0&&(t=1);var n=e.call(this,Ln,go,{uAlpha:1})||this;return n.alpha=t,n}return Object.defineProperty(t.prototype,`alpha`,{get:function(){return this.uniforms.uAlpha},set:function(e){this.uniforms.uAlpha=e},enumerable:!1,configurable:!0}),t}(_),vo=function(e,t){return vo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},vo(e,t)};function yo(e,t){vo(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var bo=` - attribute vec2 aVertexPosition; - - uniform mat3 projectionMatrix; - - uniform float strength; - - varying vec2 vBlurTexCoords[%size%]; - - uniform vec4 inputSize; - uniform vec4 outputFrame; - - vec4 filterVertexPosition( void ) - { - vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; - - return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); - } - - vec2 filterTextureCoord( void ) - { - return aVertexPosition * (outputFrame.zw * inputSize.zw); - } - - void main(void) - { - gl_Position = filterVertexPosition(); - - vec2 textureCoord = filterTextureCoord(); - %blur% - }`;function xo(e,t){var n=Math.ceil(e/2),r=bo,i=``,a;a=t?`vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);`:`vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);`;for(var o=0;o=n&&(o=e-s-1),c=c.replace(`%value%`,t[o].toString()),i+=c,i+=` -`}return r=r.replace(`%blur%`,i),r=r.replace(`%size%`,e.toString()),r}var To=function(e){yo(t,e);function t(t,n,r,i,a){n===void 0&&(n=8),r===void 0&&(r=4),i===void 0&&(i=Kn.FILTER_RESOLUTION),a===void 0&&(a=5);var o=this,s=xo(a,t),c=wo(a);return o=e.call(this,s,c)||this,o.horizontal=t,o.resolution=i,o._quality=0,o.quality=r,o.blur=n,o}return t.prototype.apply=function(e,t,n,r){if(n?this.horizontal?this.uniforms.strength=1/n.width*(n.width/t.width):this.uniforms.strength=1/n.height*(n.height/t.height):this.horizontal?this.uniforms.strength=1/e.renderer.width*(e.renderer.width/t.width):this.uniforms.strength=1/e.renderer.height*(e.renderer.height/t.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)e.applyFilter(this,t,n,r);else{var i=e.getFilterTexture(),a=e.renderer,o=t,s=i;this.state.blend=!1,e.applyFilter(this,o,s,Jn.CLEAR);for(var c=1;c 0.0) { - coord *= mix(1.0, smoothstep(0.0, radius / distance, percent), strength * 0.75); - } else { - coord *= mix(1.0, pow(percent, 1.0 + strength * 0.75) * radius / distance, 1.0 - percent); - } - } - coord += center * dimensions.xy; - coord /= filterArea.xy; - vec2 clampedCoord = clamp(coord, filterClamp.xy, filterClamp.zw); - vec4 color = texture2D(uSampler, clampedCoord); - if (coord != clampedCoord) { - color *= max(0.0, 1.0 - length(coord - clampedCoord)); - } - - gl_FragColor = color; -} -`;(function(e){ko(t,e);function t(n){var r=e.call(this,Ao,jo)||this;return r.uniforms.dimensions=new Float32Array(2),Object.assign(r,t.defaults,n),r}return t.prototype.apply=function(e,t,n,r){var i=t.filterFrame,a=i.width,o=i.height;this.uniforms.dimensions[0]=a,this.uniforms.dimensions[1]=o,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`radius`,{get:function(){return this.uniforms.radius},set:function(e){this.uniforms.radius=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`strength`,{get:function(){return this.uniforms.strength},set:function(e){this.uniforms.strength=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`center`,{get:function(){return this.uniforms.center},set:function(e){this.uniforms.center=e},enumerable:!1,configurable:!0}),t.defaults={center:[.5,.5],radius:100,strength:1},t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var Mo=function(e,t){return Mo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Mo(e,t)};function No(e,t){Mo(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Po=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,Fo=`varying vec2 vTextureCoord; -uniform sampler2D uSampler; -uniform sampler2D colorMap; -uniform float _mix; -uniform float _size; -uniform float _sliceSize; -uniform float _slicePixelSize; -uniform float _sliceInnerSize; -void main() { - vec4 color = texture2D(uSampler, vTextureCoord.xy); - - vec4 adjusted; - if (color.a > 0.0) { - color.rgb /= color.a; - float innerWidth = _size - 1.0; - float zSlice0 = min(floor(color.b * innerWidth), innerWidth); - float zSlice1 = min(zSlice0 + 1.0, innerWidth); - float xOffset = _slicePixelSize * 0.5 + color.r * _sliceInnerSize; - float s0 = xOffset + (zSlice0 * _sliceSize); - float s1 = xOffset + (zSlice1 * _sliceSize); - float yOffset = _sliceSize * 0.5 + color.g * (1.0 - _sliceSize); - vec4 slice0Color = texture2D(colorMap, vec2(s0,yOffset)); - vec4 slice1Color = texture2D(colorMap, vec2(s1,yOffset)); - float zOffset = fract(color.b * innerWidth); - adjusted = mix(slice0Color, slice1Color, zOffset); - - color.rgb *= color.a; - } - gl_FragColor = vec4(mix(color, adjusted, _mix).rgb, color.a); - -}`;(function(t){No(n,t);function n(e,n,r){n===void 0&&(n=!1),r===void 0&&(r=1);var i=t.call(this,Po,Fo)||this;return i.mix=1,i._size=0,i._sliceSize=0,i._slicePixelSize=0,i._sliceInnerSize=0,i._nearest=!1,i._scaleMode=null,i._colorMap=null,i._scaleMode=null,i.nearest=n,i.mix=r,i.colorMap=e,i}return n.prototype.apply=function(e,t,n,r){this.uniforms._mix=this.mix,e.applyFilter(this,t,n,r)},Object.defineProperty(n.prototype,`colorSize`,{get:function(){return this._size},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,`colorMap`,{get:function(){return this._colorMap},set:function(e){var t;e&&(e instanceof In||(e=In.from(e)),(t=e)?.baseTexture&&(e.baseTexture.scaleMode=this._scaleMode,e.baseTexture.mipmap=Yn.OFF,this._size=e.height,this._sliceSize=1/this._size,this._slicePixelSize=this._sliceSize/this._size,this._sliceInnerSize=this._slicePixelSize*(this._size-1),this.uniforms._size=this._size,this.uniforms._sliceSize=this._sliceSize,this.uniforms._slicePixelSize=this._slicePixelSize,this.uniforms._sliceInnerSize=this._sliceInnerSize,this.uniforms.colorMap=e),this._colorMap=e)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,`nearest`,{get:function(){return this._nearest},set:function(t){this._nearest=t,this._scaleMode=t?e.NEAREST:e.LINEAR;var n=this._colorMap;n&&n.baseTexture&&(n.baseTexture._glTextures={},n.baseTexture.scaleMode=this._scaleMode,n.baseTexture.mipmap=Yn.OFF,n._updateID++,n.baseTexture.emit(`update`,n.baseTexture))},enumerable:!1,configurable:!0}),n.prototype.updateColorMap=function(){var e=this._colorMap;e&&e.baseTexture&&(e._updateID++,e.baseTexture.emit(`update`,e.baseTexture),this.colorMap=e)},n.prototype.destroy=function(e){e===void 0&&(e=!1),this._colorMap&&this._colorMap.destroy(e),t.prototype.destroy.call(this)},n})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var Io=function(e,t){return Io=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Io(e,t)};function Lo(e,t){Io(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Ro=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,zo=`varying vec2 vTextureCoord; -uniform sampler2D uSampler; -uniform vec3 color; -uniform float alpha; - -void main(void) { - vec4 currentColor = texture2D(uSampler, vTextureCoord); - gl_FragColor = vec4(mix(currentColor.rgb, color.rgb, currentColor.a * alpha), currentColor.a); -} -`;(function(e){Lo(t,e);function t(t,n){t===void 0&&(t=0),n===void 0&&(n=1);var r=e.call(this,Ro,zo)||this;return r._color=0,r._alpha=1,r.uniforms.color=new Float32Array(3),r.color=t,r.alpha=n,r}return Object.defineProperty(t.prototype,`color`,{get:function(){return this._color},set:function(e){var t=this.uniforms.color;typeof e==`number`?(Wn(e,t),this._color=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._color=Gn(t))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`alpha`,{get:function(){return this._alpha},set:function(e){this.uniforms.alpha=e,this._alpha=e},enumerable:!1,configurable:!0}),t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var Bo=function(e,t){return Bo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Bo(e,t)};function Vo(e,t){Bo(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Ho=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,Uo=`varying vec2 vTextureCoord; -uniform sampler2D uSampler; -uniform vec3 originalColor; -uniform vec3 newColor; -uniform float epsilon; -void main(void) { - vec4 currentColor = texture2D(uSampler, vTextureCoord); - vec3 colorDiff = originalColor - (currentColor.rgb / max(currentColor.a, 0.0000000001)); - float colorDistance = length(colorDiff); - float doReplace = step(colorDistance, epsilon); - gl_FragColor = vec4(mix(currentColor.rgb, (newColor + colorDiff) * currentColor.a, doReplace), currentColor.a); -} -`;(function(e){Vo(t,e);function t(t,n,r){t===void 0&&(t=16711680),n===void 0&&(n=0),r===void 0&&(r=.4);var i=e.call(this,Ho,Uo)||this;return i._originalColor=16711680,i._newColor=0,i.uniforms.originalColor=new Float32Array(3),i.uniforms.newColor=new Float32Array(3),i.originalColor=t,i.newColor=n,i.epsilon=r,i}return Object.defineProperty(t.prototype,`originalColor`,{get:function(){return this._originalColor},set:function(e){var t=this.uniforms.originalColor;typeof e==`number`?(Wn(e,t),this._originalColor=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._originalColor=Gn(t))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`newColor`,{get:function(){return this._newColor},set:function(e){var t=this.uniforms.newColor;typeof e==`number`?(Wn(e,t),this._newColor=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._newColor=Gn(t))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`epsilon`,{get:function(){return this.uniforms.epsilon},set:function(e){this.uniforms.epsilon=e},enumerable:!1,configurable:!0}),t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var Wo=function(e,t){return Wo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Wo(e,t)};function Go(e,t){Wo(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Ko=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,qo=`precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} -`;(function(e){Go(t,e);function t(t,n,r){n===void 0&&(n=200),r===void 0&&(r=200);var i=e.call(this,Ko,qo)||this;return i.uniforms.texelSize=new Float32Array(2),i.uniforms.matrix=new Float32Array(9),t!==void 0&&(i.matrix=t),i.width=n,i.height=r,i}return Object.defineProperty(t.prototype,`matrix`,{get:function(){return this.uniforms.matrix},set:function(e){var t=this;e.forEach(function(e,n){t.uniforms.matrix[n]=e})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`width`,{get:function(){return 1/this.uniforms.texelSize[0]},set:function(e){this.uniforms.texelSize[0]=1/e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`height`,{get:function(){return 1/this.uniforms.texelSize[1]},set:function(e){this.uniforms.texelSize[1]=1/e},enumerable:!1,configurable:!0}),t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var Jo=function(e,t){return Jo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Jo(e,t)};function Yo(e,t){Jo(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Xo=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,Zo=`precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} -`;(function(e){Yo(t,e);function t(){return e.call(this,Xo,Zo)||this}return t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var Qo=function(e,t){return Qo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Qo(e,t)};function $o(e,t){Qo(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var es=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,ts=`varying vec2 vTextureCoord; -uniform sampler2D uSampler; - -uniform vec4 filterArea; -uniform vec2 dimensions; - -const float SQRT_2 = 1.414213; - -const float light = 1.0; - -uniform float curvature; -uniform float lineWidth; -uniform float lineContrast; -uniform bool verticalLine; -uniform float noise; -uniform float noiseSize; - -uniform float vignetting; -uniform float vignettingAlpha; -uniform float vignettingBlur; - -uniform float seed; -uniform float time; - -float rand(vec2 co) { - return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); -} - -void main(void) -{ - vec2 pixelCoord = vTextureCoord.xy * filterArea.xy; - vec2 dir = vec2(vTextureCoord.xy * filterArea.xy / dimensions - vec2(0.5, 0.5)); - - gl_FragColor = texture2D(uSampler, vTextureCoord); - vec3 rgb = gl_FragColor.rgb; - - if (noise > 0.0 && noiseSize > 0.0) - { - pixelCoord.x = floor(pixelCoord.x / noiseSize); - pixelCoord.y = floor(pixelCoord.y / noiseSize); - float _noise = rand(pixelCoord * noiseSize * seed) - 0.5; - rgb += _noise * noise; - } - - if (lineWidth > 0.0) - { - float _c = curvature > 0. ? curvature : 1.; - float k = curvature > 0. ?(length(dir * dir) * 0.25 * _c * _c + 0.935 * _c) : 1.; - vec2 uv = dir * k; - - float v = (verticalLine ? uv.x * dimensions.x : uv.y * dimensions.y) * min(1.0, 2.0 / lineWidth ) / _c; - float j = 1. + cos(v * 1.2 - time) * 0.5 * lineContrast; - rgb *= j; - float segment = verticalLine ? mod((dir.x + .5) * dimensions.x, 4.) : mod((dir.y + .5) * dimensions.y, 4.); - rgb *= 0.99 + ceil(segment) * 0.015; - } - - if (vignetting > 0.0) - { - float outter = SQRT_2 - vignetting * SQRT_2; - float darker = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + vignettingBlur * SQRT_2), 0.0, 1.0); - rgb *= darker + (1.0 - darker) * (1.0 - vignettingAlpha); - } - - gl_FragColor.rgb = rgb; -} -`;(function(e){$o(t,e);function t(n){var r=e.call(this,es,ts)||this;return r.time=0,r.seed=0,r.uniforms.dimensions=new Float32Array(2),Object.assign(r,t.defaults,n),r}return t.prototype.apply=function(e,t,n,r){var i=t.filterFrame,a=i.width,o=i.height;this.uniforms.dimensions[0]=a,this.uniforms.dimensions[1]=o,this.uniforms.seed=this.seed,this.uniforms.time=this.time,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`curvature`,{get:function(){return this.uniforms.curvature},set:function(e){this.uniforms.curvature=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`lineWidth`,{get:function(){return this.uniforms.lineWidth},set:function(e){this.uniforms.lineWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`lineContrast`,{get:function(){return this.uniforms.lineContrast},set:function(e){this.uniforms.lineContrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`verticalLine`,{get:function(){return this.uniforms.verticalLine},set:function(e){this.uniforms.verticalLine=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`noise`,{get:function(){return this.uniforms.noise},set:function(e){this.uniforms.noise=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`noiseSize`,{get:function(){return this.uniforms.noiseSize},set:function(e){this.uniforms.noiseSize=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignetting`,{get:function(){return this.uniforms.vignetting},set:function(e){this.uniforms.vignetting=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignettingAlpha`,{get:function(){return this.uniforms.vignettingAlpha},set:function(e){this.uniforms.vignettingAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignettingBlur`,{get:function(){return this.uniforms.vignettingBlur},set:function(e){this.uniforms.vignettingBlur=e},enumerable:!1,configurable:!0}),t.defaults={curvature:1,lineWidth:1,lineContrast:.25,verticalLine:!1,noise:0,noiseSize:1,seed:0,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,time:0},t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var ns=function(e,t){return ns=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},ns(e,t)};function rs(e,t){ns(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var os=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,ss=`precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} -`;(function(e){rs(t,e);function t(t,n){t===void 0&&(t=1),n===void 0&&(n=5);var r=e.call(this,os,ss)||this;return r.scale=t,r.angle=n,r}return Object.defineProperty(t.prototype,`scale`,{get:function(){return this.uniforms.scale},set:function(e){this.uniforms.scale=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`angle`,{get:function(){return this.uniforms.angle},set:function(e){this.uniforms.angle=e},enumerable:!1,configurable:!0}),t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var cs=function(e,t){return cs=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},cs(e,t)};function ls(e,t){cs(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var us=function(){return us=Object.assign||function(e){for(var t=arguments,n,r=1,i=arguments.length;r 1.0 || coord.y > 1.0) { - return; - } - - float cx = coord.x - 0.5; - float cy = (coord.y - 0.5) * aspect; - float ny = (-sinDir * cx + cosDir * cy) / aspect + 0.5; - - // displacementMap: repeat - // ny = ny > 1.0 ? ny - 1.0 : (ny < 0.0 ? 1.0 + ny : ny); - - // displacementMap: mirror - ny = ny > 1.0 ? 2.0 - ny : (ny < 0.0 ? -ny : ny); - - vec4 dc = texture2D(displacementMap, vec2(0.5, ny)); - - float displacement = (dc.r - dc.g) * (offset / filterArea.x); - - coord = vTextureCoord + vec2(cosDir * displacement, sinDir * displacement * aspect); - - if (fillMode == CLAMP) { - coord = clamp(coord, filterClamp.xy, filterClamp.zw); - } else { - if( coord.x > filterClamp.z ) { - if (fillMode == TRANSPARENT) { - discard; - } else if (fillMode == LOOP) { - coord.x -= filterClamp.z; - } else if (fillMode == MIRROR) { - coord.x = filterClamp.z * 2.0 - coord.x; - } - } else if( coord.x < filterClamp.x ) { - if (fillMode == TRANSPARENT) { - discard; - } else if (fillMode == LOOP) { - coord.x += filterClamp.z; - } else if (fillMode == MIRROR) { - coord.x *= -filterClamp.z; - } - } - - if( coord.y > filterClamp.w ) { - if (fillMode == TRANSPARENT) { - discard; - } else if (fillMode == LOOP) { - coord.y -= filterClamp.w; - } else if (fillMode == MIRROR) { - coord.y = filterClamp.w * 2.0 - coord.y; - } - } else if( coord.y < filterClamp.y ) { - if (fillMode == TRANSPARENT) { - discard; - } else if (fillMode == LOOP) { - coord.y += filterClamp.w; - } else if (fillMode == MIRROR) { - coord.y *= -filterClamp.w; - } - } - } - - gl_FragColor.r = texture2D(uSampler, coord + red * (1.0 - seed * 0.4) / filterArea.xy).r; - gl_FragColor.g = texture2D(uSampler, coord + green * (1.0 - seed * 0.3) / filterArea.xy).g; - gl_FragColor.b = texture2D(uSampler, coord + blue * (1.0 - seed * 0.2) / filterArea.xy).b; - gl_FragColor.a = texture2D(uSampler, coord).a; -} -`;(function(t){ys(n,t);function n(r){var i=t.call(this,bs,xs)||this;return i.offset=100,i.fillMode=n.TRANSPARENT,i.average=!1,i.seed=0,i.minSize=8,i.sampleSize=512,i._slices=0,i._offsets=new Float32Array(1),i._sizes=new Float32Array(1),i._direction=-1,i.uniforms.dimensions=new Float32Array(2),i._canvas=document.createElement(`canvas`),i._canvas.width=4,i._canvas.height=i.sampleSize,i.texture=In.from(i._canvas,{scaleMode:e.NEAREST}),Object.assign(i,n.defaults,r),i}return n.prototype.apply=function(e,t,n,r){var i=t.filterFrame,a=i.width,o=i.height;this.uniforms.dimensions[0]=a,this.uniforms.dimensions[1]=o,this.uniforms.aspect=o/a,this.uniforms.seed=this.seed,this.uniforms.offset=this.offset,this.uniforms.fillMode=this.fillMode,e.applyFilter(this,t,n,r)},n.prototype._randomizeSizes=function(){var e=this._sizes,t=this._slices-1,n=this.sampleSize,r=Math.min(this.minSize/n,.9/this._slices);if(this.average){for(var i=this._slices,a=1,o=0;o0;n--){var r=Math.random()*n>>0,i=e[n];e[n]=e[r],e[r]=i}},n.prototype._randomizeOffsets=function(){for(var e=0;e0?r:0,c=r<0?-r:0;n.fillStyle=`rgba(`+s+`, `+c+`, 0, 1)`,n.fillRect(0,i>>0,e,o+1>>0),i+=o}t.baseTexture.update(),this.uniforms.displacementMap=t},Object.defineProperty(n.prototype,`sizes`,{get:function(){return this._sizes},set:function(e){for(var t=Math.min(this._slices,e.length),n=0;n>0)+1},Object.defineProperty(t.prototype,`offset`,{get:function(){return this.uniforms.uOffset},set:function(e){this.uniforms.uOffset=e},enumerable:!1,configurable:!0}),t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var Fs=function(e,t){return Fs=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Fs(e,t)};function Is(e,t){Fs(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Ls=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,Rs=`varying vec2 vTextureCoord; -uniform sampler2D uSampler; - -uniform float epsilon; - -const int MAX_COLORS = %maxColors%; - -uniform vec3 originalColors[MAX_COLORS]; -uniform vec3 targetColors[MAX_COLORS]; - -void main(void) -{ - gl_FragColor = texture2D(uSampler, vTextureCoord); - - float alpha = gl_FragColor.a; - if (alpha < 0.0001) - { - return; - } - - vec3 color = gl_FragColor.rgb / alpha; - - for(int i = 0; i < MAX_COLORS; i++) - { - vec3 origColor = originalColors[i]; - if (origColor.r < 0.0) - { - break; - } - vec3 colorDiff = origColor - color; - if (length(colorDiff) < epsilon) - { - vec3 targetColor = targetColors[i]; - gl_FragColor = vec4((targetColor + colorDiff) * alpha, alpha); - return; - } - } -} -`;(function(e){Is(t,e);function t(t,n,r){n===void 0&&(n=.05),r===void 0&&(r=t.length);var i=e.call(this,Ls,Rs.replace(/%maxColors%/g,r.toFixed(0)))||this;return i._replacements=[],i._maxColors=0,i.epsilon=n,i._maxColors=r,i.uniforms.originalColors=new Float32Array(r*3),i.uniforms.targetColors=new Float32Array(r*3),i.replacements=t,i}return Object.defineProperty(t.prototype,`replacements`,{get:function(){return this._replacements},set:function(e){var t=this.uniforms.originalColors,n=this.uniforms.targetColors,r=e.length;if(r>this._maxColors)throw Error(`Length of replacements (`+r+`) exceeds the maximum colors length (`+this._maxColors+`)`);t[r*3]=-1;for(var i=0;i 0.5) then: 1 - 2 * (1 - dst) * (1 - src) - return vec3((dst.x <= 0.5) ? (2.0 * src.x * dst.x) : (1.0 - 2.0 * (1.0 - dst.x) * (1.0 - src.x)), - (dst.y <= 0.5) ? (2.0 * src.y * dst.y) : (1.0 - 2.0 * (1.0 - dst.y) * (1.0 - src.y)), - (dst.z <= 0.5) ? (2.0 * src.z * dst.z) : (1.0 - 2.0 * (1.0 - dst.z) * (1.0 - src.z))); -} - - -void main() -{ - gl_FragColor = texture2D(uSampler, vTextureCoord); - vec3 color = gl_FragColor.rgb; - - if (sepia > 0.0) - { - float gray = (color.x + color.y + color.z) / 3.0; - vec3 grayscale = vec3(gray); - - color = Overlay(SEPIA_RGB, grayscale); - - color = grayscale + sepia * (color - grayscale); - } - - vec2 coord = vTextureCoord * filterArea.xy / dimensions.xy; - - if (vignetting > 0.0) - { - float outter = SQRT_2 - vignetting * SQRT_2; - vec2 dir = vec2(vec2(0.5, 0.5) - coord); - dir.y *= dimensions.y / dimensions.x; - float darker = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + vignettingBlur * SQRT_2), 0.0, 1.0); - color.rgb *= darker + (1.0 - darker) * (1.0 - vignettingAlpha); - } - - if (scratchDensity > seed && scratch != 0.0) - { - float phase = seed * 256.0; - float s = mod(floor(phase), 2.0); - float dist = 1.0 / scratchDensity; - float d = distance(coord, vec2(seed * dist, abs(s - seed * dist))); - if (d < seed * 0.6 + 0.4) - { - highp float period = scratchDensity * 10.0; - - float xx = coord.x * period + phase; - float aa = abs(mod(xx, 0.5) * 4.0); - float bb = mod(floor(xx / 0.5), 2.0); - float yy = (1.0 - bb) * aa + bb * (2.0 - aa); - - float kk = 2.0 * period; - float dw = scratchWidth / dimensions.x * (0.75 + seed); - float dh = dw * kk; - - float tine = (yy - (2.0 - dh)); - - if (tine > 0.0) { - float _sign = sign(scratch); - - tine = s * tine / period + scratch + 0.1; - tine = clamp(tine + 1.0, 0.5 + _sign * 0.5, 1.5 + _sign * 0.5); - - color.rgb *= tine; - } - } - } - - if (noise > 0.0 && noiseSize > 0.0) - { - vec2 pixelCoord = vTextureCoord.xy * filterArea.xy; - pixelCoord.x = floor(pixelCoord.x / noiseSize); - pixelCoord.y = floor(pixelCoord.y / noiseSize); - // vec2 d = pixelCoord * noiseSize * vec2(1024.0 + seed * 512.0, 1024.0 - seed * 512.0); - // float _noise = snoise(d) * 0.5; - float _noise = rand(pixelCoord * noiseSize * seed) - 0.5; - color += _noise * noise; - } - - gl_FragColor.rgb = color; -} -`;(function(e){Bs(t,e);function t(n,r){r===void 0&&(r=0);var i=e.call(this,Vs,Hs)||this;return i.seed=0,i.uniforms.dimensions=new Float32Array(2),typeof n==`number`?(i.seed=n,n=void 0):i.seed=r,Object.assign(i,t.defaults,n),i}return t.prototype.apply=function(e,t,n,r){var i,a;this.uniforms.dimensions[0]=(i=t.filterFrame)?.width,this.uniforms.dimensions[1]=(a=t.filterFrame)?.height,this.uniforms.seed=this.seed,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`sepia`,{get:function(){return this.uniforms.sepia},set:function(e){this.uniforms.sepia=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`noise`,{get:function(){return this.uniforms.noise},set:function(e){this.uniforms.noise=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`noiseSize`,{get:function(){return this.uniforms.noiseSize},set:function(e){this.uniforms.noiseSize=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`scratch`,{get:function(){return this.uniforms.scratch},set:function(e){this.uniforms.scratch=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`scratchDensity`,{get:function(){return this.uniforms.scratchDensity},set:function(e){this.uniforms.scratchDensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`scratchWidth`,{get:function(){return this.uniforms.scratchWidth},set:function(e){this.uniforms.scratchWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignetting`,{get:function(){return this.uniforms.vignetting},set:function(e){this.uniforms.vignetting=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignettingAlpha`,{get:function(){return this.uniforms.vignettingAlpha},set:function(e){this.uniforms.vignettingAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignettingBlur`,{get:function(){return this.uniforms.vignettingBlur},set:function(e){this.uniforms.vignettingBlur=e},enumerable:!1,configurable:!0}),t.defaults={sepia:.3,noise:.3,noiseSize:1,scratch:.5,scratchDensity:.3,scratchWidth:1,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3},t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var Us=function(e,t){return Us=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Us(e,t)};function Ws(e,t){Us(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Gs=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,Ks=`varying vec2 vTextureCoord; -uniform sampler2D uSampler; - -uniform vec2 thickness; -uniform vec4 outlineColor; -uniform vec4 filterClamp; - -const float DOUBLE_PI = 3.14159265358979323846264 * 2.; - -void main(void) { - vec4 ownColor = texture2D(uSampler, vTextureCoord); - vec4 curColor; - float maxAlpha = 0.; - vec2 displaced; - for (float angle = 0.; angle <= DOUBLE_PI; angle += \${angleStep}) { - displaced.x = vTextureCoord.x + thickness.x * cos(angle); - displaced.y = vTextureCoord.y + thickness.y * sin(angle); - curColor = texture2D(uSampler, clamp(displaced, filterClamp.xy, filterClamp.zw)); - maxAlpha = max(maxAlpha, curColor.a); - } - float resultAlpha = max(maxAlpha, ownColor.a); - gl_FragColor = vec4((ownColor.rgb + outlineColor.rgb * (1. - ownColor.a)) * resultAlpha, resultAlpha); -} -`;(function(e){Ws(t,e);function t(n,r,i){n===void 0&&(n=1),r===void 0&&(r=0),i===void 0&&(i=.1);var a=e.call(this,Gs,Ks.replace(/\$\{angleStep\}/,t.getAngleStep(i)))||this;return a._thickness=1,a.uniforms.thickness=new Float32Array([0,0]),a.uniforms.outlineColor=new Float32Array([0,0,0,1]),Object.assign(a,{thickness:n,color:r,quality:i}),a}return t.getAngleStep=function(e){var n=Math.max(e*t.MAX_SAMPLES,t.MIN_SAMPLES);return(Math.PI*2/n).toFixed(7)},t.prototype.apply=function(e,t,n,r){this.uniforms.thickness[0]=this._thickness/t._frame.width,this.uniforms.thickness[1]=this._thickness/t._frame.height,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`color`,{get:function(){return Gn(this.uniforms.outlineColor)},set:function(e){Wn(e,this.uniforms.outlineColor)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`thickness`,{get:function(){return this._thickness},set:function(e){this._thickness=e,this.padding=e},enumerable:!1,configurable:!0}),t.MIN_SAMPLES=1,t.MAX_SAMPLES=100,t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var qs=function(e,t){return qs=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},qs(e,t)};function Js(e,t){qs(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Ys=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,Xs=`precision mediump float; - -varying vec2 vTextureCoord; - -uniform vec2 size; -uniform sampler2D uSampler; - -uniform vec4 filterArea; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -void main(void) -{ - vec2 coord = mapCoord(vTextureCoord); - - coord = pixelate(coord, size); - - coord = unmapCoord(coord); - - gl_FragColor = texture2D(uSampler, coord); -} -`;(function(e){Js(t,e);function t(t){t===void 0&&(t=10);var n=e.call(this,Ys,Xs)||this;return n.size=t,n}return Object.defineProperty(t.prototype,`size`,{get:function(){return this.uniforms.size},set:function(e){typeof e==`number`&&(e=[e,e]),this.uniforms.size=e},enumerable:!1,configurable:!0}),t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var Zs=function(e,t){return Zs=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Zs(e,t)};function Qs(e,t){Zs(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var $s=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,ec=`varying vec2 vTextureCoord; -uniform sampler2D uSampler; -uniform vec4 filterArea; - -uniform float uRadian; -uniform vec2 uCenter; -uniform float uRadius; -uniform int uKernelSize; - -const int MAX_KERNEL_SIZE = 2048; - -void main(void) -{ - vec4 color = texture2D(uSampler, vTextureCoord); - - if (uKernelSize == 0) - { - gl_FragColor = color; - return; - } - - float aspect = filterArea.y / filterArea.x; - vec2 center = uCenter.xy / filterArea.xy; - float gradient = uRadius / filterArea.x * 0.3; - float radius = uRadius / filterArea.x - gradient * 0.5; - int k = uKernelSize - 1; - - vec2 coord = vTextureCoord; - vec2 dir = vec2(center - coord); - float dist = length(vec2(dir.x, dir.y * aspect)); - - float radianStep = uRadian; - if (radius >= 0.0 && dist > radius) { - float delta = dist - radius; - float gap = gradient; - float scale = 1.0 - abs(delta / gap); - if (scale <= 0.0) { - gl_FragColor = color; - return; - } - radianStep *= scale; - } - radianStep /= float(k); - - float s = sin(radianStep); - float c = cos(radianStep); - mat2 rotationMatrix = mat2(vec2(c, -s), vec2(s, c)); - - for(int i = 0; i < MAX_KERNEL_SIZE - 1; i++) { - if (i == k) { - break; - } - - coord -= center; - coord.y *= aspect; - coord = rotationMatrix * coord; - coord.y /= aspect; - coord += center; - - vec4 sample = texture2D(uSampler, coord); - - // switch to pre-multiplied alpha to correctly blur transparent images - // sample.rgb *= sample.a; - - color += sample; - } - - gl_FragColor = color / float(uKernelSize); -} -`;(function(e){Qs(t,e);function t(t,n,r,i){t===void 0&&(t=0),n===void 0&&(n=[0,0]),r===void 0&&(r=5),i===void 0&&(i=-1);var a=e.call(this,$s,ec)||this;return a._angle=0,a.angle=t,a.center=n,a.kernelSize=r,a.radius=i,a}return t.prototype.apply=function(e,t,n,r){this.uniforms.uKernelSize=this._angle===0?0:this.kernelSize,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`angle`,{get:function(){return this._angle},set:function(e){this._angle=e,this.uniforms.uRadian=e*Math.PI/180},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`center`,{get:function(){return this.uniforms.uCenter},set:function(e){this.uniforms.uCenter=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`radius`,{get:function(){return this.uniforms.uRadius},set:function(e){(e<0||e===1/0)&&(e=-1),this.uniforms.uRadius=e},enumerable:!1,configurable:!0}),t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var tc=function(e,t){return tc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},tc(e,t)};function nc(e,t){tc(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var rc=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,ic=`varying vec2 vTextureCoord; -uniform sampler2D uSampler; - -uniform vec4 filterArea; -uniform vec4 filterClamp; -uniform vec2 dimensions; - -uniform bool mirror; -uniform float boundary; -uniform vec2 amplitude; -uniform vec2 waveLength; -uniform vec2 alpha; -uniform float time; - -float rand(vec2 co) { - return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); -} - -void main(void) -{ - vec2 pixelCoord = vTextureCoord.xy * filterArea.xy; - vec2 coord = pixelCoord / dimensions; - - if (coord.y < boundary) { - gl_FragColor = texture2D(uSampler, vTextureCoord); - return; - } - - float k = (coord.y - boundary) / (1. - boundary + 0.0001); - float areaY = boundary * dimensions.y / filterArea.y; - float v = areaY + areaY - vTextureCoord.y; - float y = mirror ? v : vTextureCoord.y; - - float _amplitude = ((amplitude.y - amplitude.x) * k + amplitude.x ) / filterArea.x; - float _waveLength = ((waveLength.y - waveLength.x) * k + waveLength.x) / filterArea.y; - float _alpha = (alpha.y - alpha.x) * k + alpha.x; - - float x = vTextureCoord.x + cos(v * 6.28 / _waveLength - time) * _amplitude; - x = clamp(x, filterClamp.x, filterClamp.z); - - vec4 color = texture2D(uSampler, vec2(x, y)); - - gl_FragColor = color * _alpha; -} -`;(function(e){nc(t,e);function t(n){var r=e.call(this,rc,ic)||this;return r.time=0,r.uniforms.amplitude=new Float32Array(2),r.uniforms.waveLength=new Float32Array(2),r.uniforms.alpha=new Float32Array(2),r.uniforms.dimensions=new Float32Array(2),Object.assign(r,t.defaults,n),r}return t.prototype.apply=function(e,t,n,r){var i,a;this.uniforms.dimensions[0]=(i=t.filterFrame)?.width,this.uniforms.dimensions[1]=(a=t.filterFrame)?.height,this.uniforms.time=this.time,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`mirror`,{get:function(){return this.uniforms.mirror},set:function(e){this.uniforms.mirror=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`boundary`,{get:function(){return this.uniforms.boundary},set:function(e){this.uniforms.boundary=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`amplitude`,{get:function(){return this.uniforms.amplitude},set:function(e){this.uniforms.amplitude[0]=e[0],this.uniforms.amplitude[1]=e[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`waveLength`,{get:function(){return this.uniforms.waveLength},set:function(e){this.uniforms.waveLength[0]=e[0],this.uniforms.waveLength[1]=e[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`alpha`,{get:function(){return this.uniforms.alpha},set:function(e){this.uniforms.alpha[0]=e[0],this.uniforms.alpha[1]=e[1]},enumerable:!1,configurable:!0}),t.defaults={mirror:!0,boundary:.5,amplitude:[0,20],waveLength:[30,100],alpha:[1,1],time:0},t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var ac=function(e,t){return ac=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},ac(e,t)};function oc(e,t){ac(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var sc=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,cc=`precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec4 filterArea; -uniform vec2 red; -uniform vec2 green; -uniform vec2 blue; - -void main(void) -{ - gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r; - gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g; - gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b; - gl_FragColor.a = texture2D(uSampler, vTextureCoord).a; -} -`;(function(e){oc(t,e);function t(t,n,r){t===void 0&&(t=[-10,0]),n===void 0&&(n=[0,10]),r===void 0&&(r=[0,0]);var i=e.call(this,sc,cc)||this;return i.red=t,i.green=n,i.blue=r,i}return Object.defineProperty(t.prototype,`red`,{get:function(){return this.uniforms.red},set:function(e){this.uniforms.red=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`green`,{get:function(){return this.uniforms.green},set:function(e){this.uniforms.green=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`blue`,{get:function(){return this.uniforms.blue},set:function(e){this.uniforms.blue=e},enumerable:!1,configurable:!0}),t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var lc=function(e,t){return lc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},lc(e,t)};function uc(e,t){lc(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var dc=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,fc=`varying vec2 vTextureCoord; -uniform sampler2D uSampler; -uniform vec4 filterArea; -uniform vec4 filterClamp; - -uniform vec2 center; - -uniform float amplitude; -uniform float wavelength; -// uniform float power; -uniform float brightness; -uniform float speed; -uniform float radius; - -uniform float time; - -const float PI = 3.14159; - -void main() -{ - float halfWavelength = wavelength * 0.5 / filterArea.x; - float maxRadius = radius / filterArea.x; - float currentRadius = time * speed / filterArea.x; - - float fade = 1.0; - - if (maxRadius > 0.0) { - if (currentRadius > maxRadius) { - gl_FragColor = texture2D(uSampler, vTextureCoord); - return; - } - fade = 1.0 - pow(currentRadius / maxRadius, 2.0); - } - - vec2 dir = vec2(vTextureCoord - center / filterArea.xy); - dir.y *= filterArea.y / filterArea.x; - float dist = length(dir); - - if (dist <= 0.0 || dist < currentRadius - halfWavelength || dist > currentRadius + halfWavelength) { - gl_FragColor = texture2D(uSampler, vTextureCoord); - return; - } - - vec2 diffUV = normalize(dir); - - float diff = (dist - currentRadius) / halfWavelength; - - float p = 1.0 - pow(abs(diff), 2.0); - - // float powDiff = diff * pow(p, 2.0) * ( amplitude * fade ); - float powDiff = 1.25 * sin(diff * PI) * p * ( amplitude * fade ); - - vec2 offset = diffUV * powDiff / filterArea.xy; - - // Do clamp : - vec2 coord = vTextureCoord + offset; - vec2 clampedCoord = clamp(coord, filterClamp.xy, filterClamp.zw); - vec4 color = texture2D(uSampler, clampedCoord); - if (coord != clampedCoord) { - color *= max(0.0, 1.0 - length(coord - clampedCoord)); - } - - // No clamp : - // gl_FragColor = texture2D(uSampler, vTextureCoord + offset); - - color.rgb *= 1.0 + (brightness - 1.0) * p * fade; - - gl_FragColor = color; -} -`;(function(e){uc(t,e);function t(n,r,i){n===void 0&&(n=[0,0]),i===void 0&&(i=0);var a=e.call(this,dc,fc)||this;return a.center=n,Object.assign(a,t.defaults,r),a.time=i,a}return t.prototype.apply=function(e,t,n,r){this.uniforms.time=this.time,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`center`,{get:function(){return this.uniforms.center},set:function(e){this.uniforms.center=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`amplitude`,{get:function(){return this.uniforms.amplitude},set:function(e){this.uniforms.amplitude=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`wavelength`,{get:function(){return this.uniforms.wavelength},set:function(e){this.uniforms.wavelength=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`brightness`,{get:function(){return this.uniforms.brightness},set:function(e){this.uniforms.brightness=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`speed`,{get:function(){return this.uniforms.speed},set:function(e){this.uniforms.speed=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`radius`,{get:function(){return this.uniforms.radius},set:function(e){this.uniforms.radius=e},enumerable:!1,configurable:!0}),t.defaults={amplitude:30,wavelength:160,brightness:1,speed:500,radius:-1},t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var pc=function(e,t){return pc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},pc(e,t)};function mc(e,t){pc(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var hc=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,gc=`varying vec2 vTextureCoord; -uniform sampler2D uSampler; -uniform sampler2D uLightmap; -uniform vec4 filterArea; -uniform vec2 dimensions; -uniform vec4 ambientColor; -void main() { - vec4 diffuseColor = texture2D(uSampler, vTextureCoord); - vec2 lightCoord = (vTextureCoord * filterArea.xy) / dimensions; - vec4 light = texture2D(uLightmap, lightCoord); - vec3 ambient = ambientColor.rgb * ambientColor.a; - vec3 intensity = ambient + light.rgb; - vec3 finalColor = diffuseColor.rgb * intensity; - gl_FragColor = vec4(finalColor, diffuseColor.a); -} -`;(function(e){mc(t,e);function t(t,n,r){n===void 0&&(n=0),r===void 0&&(r=1);var i=e.call(this,hc,gc)||this;return i._color=0,i.uniforms.dimensions=new Float32Array(2),i.uniforms.ambientColor=new Float32Array([0,0,0,r]),i.texture=t,i.color=n,i}return t.prototype.apply=function(e,t,n,r){var i,a;this.uniforms.dimensions[0]=(i=t.filterFrame)?.width,this.uniforms.dimensions[1]=(a=t.filterFrame)?.height,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`texture`,{get:function(){return this.uniforms.uLightmap},set:function(e){this.uniforms.uLightmap=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`color`,{get:function(){return this._color},set:function(e){var t=this.uniforms.ambientColor;typeof e==`number`?(Wn(e,t),this._color=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],this._color=Gn(t))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`alpha`,{get:function(){return this.uniforms.ambientColor[3]},set:function(e){this.uniforms.ambientColor[3]=e},enumerable:!1,configurable:!0}),t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var _c=function(e,t){return _c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},_c(e,t)};function vc(e,t){_c(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var yc=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,bc=`varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float blur; -uniform float gradientBlur; -uniform vec2 start; -uniform vec2 end; -uniform vec2 delta; -uniform vec2 texSize; - -float random(vec3 scale, float seed) -{ - return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed); -} - -void main(void) -{ - vec4 color = vec4(0.0); - float total = 0.0; - - float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0); - vec2 normal = normalize(vec2(start.y - end.y, end.x - start.x)); - float radius = smoothstep(0.0, 1.0, abs(dot(vTextureCoord * texSize - start, normal)) / gradientBlur) * blur; - - for (float t = -30.0; t <= 30.0; t++) - { - float percent = (t + offset - 0.5) / 30.0; - float weight = 1.0 - abs(percent); - vec4 sample = texture2D(uSampler, vTextureCoord + delta / texSize * percent * radius); - sample.rgb *= sample.a; - color += sample * weight; - total += weight; - } - - color /= total; - color.rgb /= color.a + 0.00001; - - gl_FragColor = color; -} -`,xc=function(e){vc(t,e);function t(t,n,r,i){t===void 0&&(t=100),n===void 0&&(n=600);var a=e.call(this,yc,bc)||this;return a.uniforms.blur=t,a.uniforms.gradientBlur=n,a.uniforms.start=r||new Bn(0,window.innerHeight/2),a.uniforms.end=i||new Bn(600,window.innerHeight/2),a.uniforms.delta=new Bn(30,30),a.uniforms.texSize=new Bn(window.innerWidth,window.innerHeight),a.updateDelta(),a}return t.prototype.updateDelta=function(){this.uniforms.delta.x=0,this.uniforms.delta.y=0},Object.defineProperty(t.prototype,`blur`,{get:function(){return this.uniforms.blur},set:function(e){this.uniforms.blur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`gradientBlur`,{get:function(){return this.uniforms.gradientBlur},set:function(e){this.uniforms.gradientBlur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`start`,{get:function(){return this.uniforms.start},set:function(e){this.uniforms.start=e,this.updateDelta()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`end`,{get:function(){return this.uniforms.end},set:function(e){this.uniforms.end=e,this.updateDelta()},enumerable:!1,configurable:!0}),t}(_),Sc=function(e){vc(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.updateDelta=function(){var e=this.uniforms.end.x-this.uniforms.start.x,t=this.uniforms.end.y-this.uniforms.start.y,n=Math.sqrt(e*e+t*t);this.uniforms.delta.x=e/n,this.uniforms.delta.y=t/n},t}(xc),Cc=function(e){vc(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.updateDelta=function(){var e=this.uniforms.end.x-this.uniforms.start.x,t=this.uniforms.end.y-this.uniforms.start.y,n=Math.sqrt(e*e+t*t);this.uniforms.delta.x=-t/n,this.uniforms.delta.y=e/n},t}(xc);(function(e){vc(t,e);function t(t,n,r,i){t===void 0&&(t=100),n===void 0&&(n=600);var a=e.call(this)||this;return a.tiltShiftXFilter=new Sc(t,n,r,i),a.tiltShiftYFilter=new Cc(t,n,r,i),a}return t.prototype.apply=function(e,t,n,r){var i=e.getFilterTexture();this.tiltShiftXFilter.apply(e,t,i,1),this.tiltShiftYFilter.apply(e,i,n,r),e.returnFilterTexture(i)},Object.defineProperty(t.prototype,`blur`,{get:function(){return this.tiltShiftXFilter.blur},set:function(e){this.tiltShiftXFilter.blur=this.tiltShiftYFilter.blur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`gradientBlur`,{get:function(){return this.tiltShiftXFilter.gradientBlur},set:function(e){this.tiltShiftXFilter.gradientBlur=this.tiltShiftYFilter.gradientBlur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`start`,{get:function(){return this.tiltShiftXFilter.start},set:function(e){this.tiltShiftXFilter.start=this.tiltShiftYFilter.start=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`end`,{get:function(){return this.tiltShiftXFilter.end},set:function(e){this.tiltShiftXFilter.end=this.tiltShiftYFilter.end=e},enumerable:!1,configurable:!0}),t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var wc=function(e,t){return wc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},wc(e,t)};function Tc(e,t){wc(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Ec=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,Dc=`varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float radius; -uniform float angle; -uniform vec2 offset; -uniform vec4 filterArea; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 twist(vec2 coord) -{ - coord -= offset; - - float dist = length(coord); - - if (dist < radius) - { - float ratioDist = (radius - dist) / radius; - float angleMod = ratioDist * ratioDist * angle; - float s = sin(angleMod); - float c = cos(angleMod); - coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c); - } - - coord += offset; - - return coord; -} - -void main(void) -{ - - vec2 coord = mapCoord(vTextureCoord); - - coord = twist(coord); - - coord = unmapCoord(coord); - - gl_FragColor = texture2D(uSampler, coord ); - -} -`;(function(e){Tc(t,e);function t(n){var r=e.call(this,Ec,Dc)||this;return Object.assign(r,t.defaults,n),r}return Object.defineProperty(t.prototype,`offset`,{get:function(){return this.uniforms.offset},set:function(e){this.uniforms.offset=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`radius`,{get:function(){return this.uniforms.radius},set:function(e){this.uniforms.radius=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`angle`,{get:function(){return this.uniforms.angle},set:function(e){this.uniforms.angle=e},enumerable:!1,configurable:!0}),t.defaults={radius:200,angle:4,padding:20,offset:new Bn},t})(_); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var Oc=function(e,t){return Oc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Oc(e,t)};function kc(e,t){Oc(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Ac(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i= 0.0 && dist > radius) { // radius < 0 means it's infinity - delta = dist - radius; - gap = gradient; - } - - if (delta > 0.0) { - float normalCount = gap / filterArea.x; - delta = (normalCount - delta) / normalCount; - countLimit *= delta; - strength *= delta; - if (countLimit < 1.0) - { - gl_FragColor = texture2D(uSampler, vTextureCoord); - return; - } - } - - // randomize the lookup values to hide the fixed number of samples - float offset = rand(vTextureCoord, 0.0); - - float total = 0.0; - vec4 color = vec4(0.0); - - dir *= strength; - - for (float t = 0.0; t < MAX_KERNEL_SIZE; t++) { - float percent = (t + offset) / MAX_KERNEL_SIZE; - float weight = 4.0 * (percent - percent * percent); - vec2 p = vTextureCoord + dir * percent; - vec4 sample = texture2D(uSampler, p); - - // switch to pre-multiplied alpha to correctly blur transparent images - // sample.rgb *= sample.a; - - color += sample * weight; - total += weight; - - if (t > countLimit){ - break; - } - } - - color /= total; - // switch back from pre-multiplied alpha - // color.rgb /= color.a + 0.00001; - - gl_FragColor = color; -} -`;(function(e){kc(t,e);function t(n){var r=this,i=Object.assign(t.defaults,n),a=i.maxKernelSize,o=Ac(i,[`maxKernelSize`]);return r=e.call(this,jc,Mc.replace("${maxKernelSize}",a.toFixed(1)))||this,Object.assign(r,o),r}return Object.defineProperty(t.prototype,`center`,{get:function(){return this.uniforms.uCenter},set:function(e){this.uniforms.uCenter=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`strength`,{get:function(){return this.uniforms.uStrength},set:function(e){this.uniforms.uStrength=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`innerRadius`,{get:function(){return this.uniforms.uInnerRadius},set:function(e){this.uniforms.uInnerRadius=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`radius`,{get:function(){return this.uniforms.uRadius},set:function(e){(e<0||e===1/0)&&(e=-1),this.uniforms.uRadius=e},enumerable:!1,configurable:!0}),t.defaults={strength:.1,center:[0,0],innerRadius:0,radius:-1,maxKernelSize:32},t})(_);function Nc(){let e=-1,t,n=-1;function r(r,i){(i>=e||i{let{post:e,data:t}=ue({name:`airi-stores-live2d`}),n=g([]),r=e=>{n.value.push(e)};function i(){e({type:`should-update-view`}),n.value.forEach(e=>e())}on(t,e=>{e.type===`should-update-view`&&n.value.forEach(e=>e())});let a=pe(`settings/live2d/position`,{x:0,y:0}),o=Cn(()=>({x:`${a.value.x}%`,y:`${a.value.y}%`})),s=g({group:`Idle`,index:0}),c=g([]),l=pe(`settings/live2d/motion-map`,{}),u=pe(`settings/live2d/scale`,1);return{position:a,positionInPercentageString:o,currentMotion:s,availableMotions:c,motionMap:l,scale:u,onShouldUpdateView:r,shouldUpdateView:i}});var Fc=Jt({__name:`Model`,props:Zt({modelSrc:{},app:{},mouthOpenSize:{default:0},width:{},height:{},paused:{type:Boolean,default:!1},focusAt:{default:()=>({x:0,y:0})},disableFocusAt:{type:Boolean,default:!1},xOffset:{},yOffset:{},scale:{default:1}},{state:{default:`pending`},stateModifiers:{}}),emits:Zt([`modelLoaded`],[`update:state`]),setup(e,{expose:t,emit:n}){let r=e,i=n,a=an(e,`state`);function o(){let e=Number.parseFloat(String(r.xOffset))||0,t=Number.parseFloat(String(r.yOffset))||0;return String(r.xOffset).endsWith(`%`)&&(e=Number.parseFloat(String(r.xOffset).replace(`%`,``))/100*r.width),String(r.yOffset).endsWith(`%`)&&(t=Number.parseFloat(String(r.yOffset).replace(`%`,``))/100*r.height),{xOffset:e,yOffset:t}}let s=Dn(()=>r.modelSrc),c=g(!1),l=Cn(()=>o()),u=Dn(()=>r.app),d=Dn(()=>r.paused),f=Dn(()=>r.focusAt),p=g(),m=g(0),h=g(0),ne=Cn(()=>Math.max(0,Math.min(100,r.mouthOpenSize))),ie=g(0),ae=de(),oe=le(ce),ue=Cn(()=>oe.between(`sm`,`md`).value||oe.smaller(`sm`).value),fe=Nc(),pe=Tn(new ps({alpha:.2,blur:0,distance:20,rotation:45}));function he(){return p.value.internalModel.coreModel}function ge(){if(!p.value)return;let e=2.2;ue.value&&(e=2.2);let t=r.height*.95/h.value*e,n=r.width*.95/m.value*e,i=Math.min(t,n);p.value.scale.set(i*r.scale,i*r.scale),p.value.x=r.width/2+l.value.xOffset,p.value.y=r.height+l.value.yOffset}let{currentMotion:_e,availableMotions:ve,motionMap:ye}=se(Pc()),{themeColorsHue:be,themeColorsHueDynamic:xe}=se(me()),Se=g({group:`Idle`,index:0});async function Ce(){if(await Le(c).not.toBeTruthy(),c.value=!0,a.value=`loading`,!u.value){c.value=!1,a.value=`mounted`;return}if(p.value&&=(u.value.stage.removeChild(p.value),p.value.destroy(),void 0),!s.value){console.warn(`No Live2D model source provided.`),c.value=!1,a.value=`mounted`;return}try{let e=new Nn;if(s.value.startsWith(`blob:`)){let t=await fetch(s.value),n=await t.blob();await Mn.setupLive2DModel(e,[new File([n],`model.zip`)],{autoInteract:!1})}else await Mn.setupLive2DModel(e,s.value,{autoInteract:!1});ve.value.forEach(e=>{e.motionName in ee?ye.value[e.fileName]=e.motionName:ye.value[e.fileName]=te}),p.value=e,u.value.stage.addChild(p.value),m.value=p.value.width,h.value=p.value.height,p.value.anchor.set(.5,.5),ge(),p.value.on(`hit`,e=>{p.value&&e.includes(`body`)&&p.value.motion(`tap_body`)});let t=p.value.internalModel,n=t.coreModel,r=t.motionManager;n.setParameterValueById(`ParamMouthOpenY`,ne.value),ve.value=Object.entries(r.definitions).flatMap(([e,t])=>t?.map((t,n)=>({motionName:e,motionIndex:n,fileName:t.File}))||[]).filter(Boolean),r.groups.idle&&r.motionGroups[r.groups.idle]?.forEach(e=>{e._motionData.curves.forEach(e=>{(e.id===`ParamEyeBallX`||e.id===`ParamEyeBallY`)&&(e.id=`_${e.id}`)})});let a=r.update;r.update=function(e,n){return ie.value=n,a?.call(this,e,n),!r.state.currentGroup||r.state.currentGroup===r.groups.idle?(fe.update(t,n),t.eyeBlink!=null&&t.eyeBlink.updateParameters(e,(n-ie.value)/1e3),!0):!1},r.on(`motionStart`,(e,t)=>{Se.value={group:e,index:t}}),i(`modelLoaded`)}finally{c.value=!1,a.value=`mounted`}}async function we(e,t){await p.value?.motion(e,t,Pn.FORCE)}let Te=Re(ge,100),Ee=g(),De=g(0);function Oe(){if(p.value){let e=getComputedStyle(Ee.value).backgroundColor;pe.value.color=Number(re(e).replace(`#`,`0x`)),p.value.filters=[pe.value]}}on([()=>r.width,()=>r.height],()=>Te()),on(s,async()=>await Ce(),{immediate:!0}),on(ae,Oe,{immediate:!0}),on([p,be],Oe),on(l,ge),on(()=>r.scale,ge);function ke(){Oe(),De.value=requestAnimationFrame(ke)}on(xe,()=>{xe.value?De.value=requestAnimationFrame(ke):(cancelAnimationFrame(De.value),De.value=0)},{immediate:!0}),on(ne,e=>he().setParameterValueById(`ParamMouthOpenY`,e)),on(_e,e=>we(e.group,e.index)),on(d,e=>e?u.value?.stop():u.value?.start()),on(f,e=>{p.value&&(r.disableFocusAt||p.value.focus(e.x,e.y))}),$t(async()=>{Oe()});function Ae(){cancelAnimationFrame(De.value),p.value&&u.value?.stage.removeChild(p.value)}en(()=>{Ae()});function je(){return ve.value}return t({setMotion:we,listMotionGroups:je}),(e,t)=>(tn(),Kt(xn,null,[Ut(`div`,{ref_key:`dropShadowColorComputer`,ref:Ee,hidden:``,bg:`primary-400 dark:primary-500`},null,512),rn(e.$slots,`default`)],64))}}),Ic=Fc,Lc=Jt({__name:`Live2D`,props:Zt({modelSrc:{},paused:{type:Boolean,default:!1},mouthOpenSize:{default:0},focusAt:{default:()=>({x:0,y:0})},disableFocusAt:{type:Boolean},xOffset:{},yOffset:{},scale:{default:1}},{state:{default:`pending`},stateModifiers:{},canvasState:{default:`pending`},canvasStateModifiers:{},modelState:{default:`pending`},modelStateModifiers:{}}),emits:[`update:state`,`update:canvasState`,`update:modelState`],setup(e,{expose:t}){let n=an(e,`state`),r=an(e,`canvasState`),i=an(e,`modelState`),a=g();return on([i,r],()=>{n.value=i.value===`mounted`&&r.value===`mounted`?`mounted`:`loading`}),t({canvasElement:()=>a.value?.canvasElement()}),(e,t)=>(tn(),Wt(ie,{relative:``},{default:Rt(({width:n,height:o})=>[qt(Ha,{ref_key:`live2dCanvasRef`,ref:a,state:r.value,"onUpdate:state":t[1]||=e=>r.value=e,width:n,height:o,resolution:2,"max-h":`100dvh`},{default:Rt(({app:r})=>[qt(Ic,{state:i.value,"onUpdate:state":t[0]||=e=>i.value=e,"model-src":e.modelSrc,app:r,"mouth-open-size":e.mouthOpenSize,width:n,height:o,paused:e.paused,"focus-at":e.focusAt,"x-offset":e.xOffset,"y-offset":e.yOffset,scale:e.scale,"disable-focus-at":e.disableFocusAt},null,8,[`state`,`model-src`,`app`,`mouth-open-size`,`width`,`height`,`paused`,`focus-at`,`x-offset`,`y-offset`,`scale`,`disable-focus-at`])]),_:2},1032,[`state`,`width`,`height`])]),_:1}))}}),Rc=Lc;function y(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 zc(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 b(e){return this instanceof b?(this.v=e,this):new b(e)}function Bc(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){f(a[0][3],e)}}function l(e){e.value instanceof b?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function Vc(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:b(e[r](t)),done:!1}:i?i(t):t}:i}}function Hc(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof zc==`function`?zc(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 Uc=new TextDecoder(`utf-8`),Wc=e=>Uc.decode(e),Gc=new TextEncoder,Kc=e=>Gc.encode(e),qc=e=>typeof e==`number`,Jc=e=>typeof e==`boolean`,Yc=e=>typeof e==`function`,Xc=e=>e!=null&&Object(e)===e,Zc=e=>Xc(e)&&Yc(e.then),Qc=e=>Xc(e)&&Yc(e[Symbol.iterator]),$c=e=>Xc(e)&&Yc(e[Symbol.asyncIterator]),el=e=>Xc(e)&&Xc(e.schema),tl=e=>Xc(e)&&`done`in e&&`value`in e,nl=e=>Xc(e)&&Yc(e.stat)&&qc(e.fd),rl=e=>Xc(e)&&ol(e.body),il=e=>`_getDOMStream`in e&&`_getNodeStream`in e,al=e=>Xc(e)&&Yc(e.abort)&&Yc(e.getWriter)&&!il(e),ol=e=>Xc(e)&&Yc(e.cancel)&&Yc(e.getReader)&&!il(e),sl=e=>Xc(e)&&Yc(e.end)&&Yc(e.write)&&Jc(e.writable)&&!il(e),cl=e=>Xc(e)&&Yc(e.read)&&Yc(e.pipe)&&Jc(e.readable)&&!il(e),ll=e=>Xc(e)&&Yc(e.clear)&&Yc(e.bytes)&&Yc(e.position)&&Yc(e.setPosition)&&Yc(e.capacity)&&Yc(e.getBufferIdentifier)&&Yc(e.createLong),ul=typeof SharedArrayBuffer<`u`?SharedArrayBuffer:ArrayBuffer;function dl(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;++cml(Int32Array,e),gl=e=>ml(BigInt64Array,e),_l=e=>ml(Uint8Array,e),vl=e=>(e.next(),e);function*yl(e,t){let n=function*(e){yield e},r=typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof ul?n(t):Qc(t)?t:n(t);return yield*vl((function*(t){let n=null;do n=t.next(yield ml(e,n));while(!n.done)})(r[Symbol.iterator]())),new e}const bl=e=>yl(Uint8Array,e);function xl(e,t){return Bc(this,arguments,function*(){if(Zc(t))return yield b(yield b(yield*Vc(Hc(xl(e,yield b(t))))));let n=function(e){return Bc(this,arguments,function*(){yield yield b(yield b(e))})},r=function(e){return Bc(this,arguments,function*(){yield b(yield*Vc(Hc(vl((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 ul?n(t):Qc(t)?r(t):$c(t)?t:n(t);return yield b(yield*Vc(Hc(vl((function(t){return Bc(this,arguments,function*(){let n=null;do n=yield b(t.next(yield yield b(ml(e,n))));while(!n.done)})})(i[Symbol.asyncIterator]()))))),yield b(new e)})}const Sl=e=>xl(Uint8Array,e);function Cl(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*Dl(e){let t,n=!1,r=[],i,a,o,s=0;function c(){return a===`peek`?pl(r,o)[0]:([i,r,s]=pl(r,o),i)}({cmd:a,size:o}=(yield(()=>null)())||{cmd:`read`,size:0});let l=bl(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=Sl(e)[Symbol.asyncIterator]();try{do if({done:t,value:i}=Number.isNaN(o-s)?yield b(l.next()):yield b(l.next(o-s)),!t&&i.byteLength>0&&(r.push(i),s+=i.byteLength),t||o<=s)do({cmd:a,size:o}=yield yield b(c()));while(onull)()))||{cmd:`read`,size:0});let l=new Al(e);try{do if({done:t,value:i}=Number.isNaN(o-s)?yield b(l.read()):yield b(l.read(o-s)),!t&&i.byteLength>0&&(r.push(_l(i)),s+=i.byteLength),t||o<=s)do({cmd:a,size:o}=yield yield b(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 y(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 y(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=_l(t)),t})}};const jl=(e,t)=>{let n=e=>r([t,e]),r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function Ml(e){return Bc(this,arguments,function*(){let t=[],n=`error`,r=!1,i=null,a,o,s=0,c=[],l;function u(){return a===`peek`?pl(c,o)[0]:([l,c,s]=pl(c,o),l)}if({cmd:a,size:o}=(yield yield b((()=>null)()))||{cmd:`read`,size:0},e.isTTY)return yield yield b(new Uint8Array),yield b(null);try{t[0]=jl(e,`end`),t[1]=jl(e,`error`);do{if(t[2]=jl(e,`readable`),[n,i]=yield b(Promise.race(t.map(e=>e[2]))),n===`error`)break;if((r=n===`end`)||(Number.isFinite(o-s)?(l=_l(e.read(o-s)),l.byteLength0&&(c.push(l),s+=l.byteLength)),r||o<=s)do({cmd:a,size:o}=yield yield b(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 Nl;(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`})(Nl||={});var Pl;(function(e){e[e.Sparse=0]=`Sparse`,e[e.Dense=1]=`Dense`})(Pl||={});var Fl;(function(e){e[e.HALF=0]=`HALF`,e[e.SINGLE=1]=`SINGLE`,e[e.DOUBLE=2]=`DOUBLE`})(Fl||={});var Il;(function(e){e[e.DAY=0]=`DAY`,e[e.MILLISECOND=1]=`MILLISECOND`})(Il||={});var x;(function(e){e[e.SECOND=0]=`SECOND`,e[e.MILLISECOND=1]=`MILLISECOND`,e[e.MICROSECOND=2]=`MICROSECOND`,e[e.NANOSECOND=3]=`NANOSECOND`})(x||={});var Ll;(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`})(Ll||={});const Rl=new Int32Array(2),zl=new Float32Array(Rl.buffer),Bl=new Float64Array(Rl.buffer),Vl=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Hl;(function(e){e[e.UTF8_BYTES=1]=`UTF8_BYTES`,e[e.UTF16_STRING=2]=`UTF16_STRING`})(Hl||={});var Ul=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){zl[0]=t,this.writeInt32(e,Rl[0])}writeFloat64(e,t){Bl[0]=t,this.writeInt32(e,Rl[Vl?0:1]),this.writeInt32(e+4,Rl[Vl?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)}},xu=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)}},Su;(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`})(Su||={});var Cu=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):Su.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 tu).__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 nu).__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,Su.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}},wu=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):Ql.Little}fields(e,t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new Cu).__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 nu).__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,Ql.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)}},Tu;(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`})(Tu||={});var S;(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`})(S||={});var Eu;(function(e){e[e.OFFSET=0]=`OFFSET`,e[e.DATA=1]=`DATA`,e[e.VALIDITY=2]=`VALIDITY`,e[e.TYPE=3]=`TYPE`})(Eu||={});function Du(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=>Du(e))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(e,t)=>typeof t==`bigint`?`${t}`:t)}function Ou(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 ku(e,t){return Ou(e/t)+Ou(e%t)/Ou(t)}const Au=Symbol.for(`isArrowBigNum`);function ju(e,...t){return t.length===0?Object.setPrototypeOf(ml(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}ju.prototype[Au]=!0,ju.prototype.toJSON=function(){return`"${Ru(this)}"`},ju.prototype.valueOf=function(e){return Lu(this,e)},ju.prototype.toString=function(){return Ru(this)},ju.prototype[Symbol.toPrimitive]=function(e=`default`){switch(e){case`number`:return Lu(this);case`string`:return Ru(this);case`default`:return zu(this)}return Ru(this)};function Mu(...e){return ju.apply(this,e)}function Nu(...e){return ju.apply(this,e)}function Pu(...e){return ju.apply(this,e)}Object.setPrototypeOf(Mu.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(Nu.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(Pu.prototype,Object.create(Uint32Array.prototype)),Object.assign(Mu.prototype,ju.prototype,{constructor:Mu,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(Nu.prototype,ju.prototype,{constructor:Nu,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(Pu.prototype,ju.prototype,{constructor:Pu,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Fu=BigInt(4294967296)*BigInt(4294967296),Iu=Fu-BigInt(1);function Lu(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 Bu(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`))(C.prototype);var ud=class extends C{constructor(){super(S.Null)}toString(){return`Null`}};Uu=Symbol.toStringTag,ud[Uu]=(e=>e[Symbol.toStringTag]=`Null`)(ud.prototype);var dd=class extends C{constructor(e,t){super(S.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}`}};Wu=Symbol.toStringTag,dd[Wu]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]=`Int`))(dd.prototype);var fd=class extends dd{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},pd=class extends dd{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},md=class extends dd{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},hd=class extends dd{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},gd=class extends dd{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},_d=class extends dd{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},vd=class extends dd{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},yd=class extends dd{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(fd.prototype,`ArrayType`,{value:Int8Array}),Object.defineProperty(pd.prototype,`ArrayType`,{value:Int16Array}),Object.defineProperty(md.prototype,`ArrayType`,{value:Int32Array}),Object.defineProperty(hd.prototype,`ArrayType`,{value:BigInt64Array}),Object.defineProperty(gd.prototype,`ArrayType`,{value:Uint8Array}),Object.defineProperty(_d.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(vd.prototype,`ArrayType`,{value:Uint32Array}),Object.defineProperty(yd.prototype,`ArrayType`,{value:BigUint64Array});var bd=class extends C{constructor(e){super(S.Float),this.precision=e}get ArrayType(){switch(this.precision){case Fl.HALF:return Uint16Array;case Fl.SINGLE:return Float32Array;case Fl.DOUBLE:return Float64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};Gu=Symbol.toStringTag,bd[Gu]=(e=>(e.precision=null,e[Symbol.toStringTag]=`Float`))(bd.prototype);var xd=class extends bd{constructor(){super(Fl.HALF)}},Sd=class extends bd{constructor(){super(Fl.SINGLE)}},Cd=class extends bd{constructor(){super(Fl.DOUBLE)}};Object.defineProperty(xd.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(Sd.prototype,`ArrayType`,{value:Float32Array}),Object.defineProperty(Cd.prototype,`ArrayType`,{value:Float64Array});var wd=class extends C{constructor(){super(S.Binary)}toString(){return`Binary`}};Ku=Symbol.toStringTag,wd[Ku]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Binary`))(wd.prototype);var Td=class extends C{constructor(){super(S.LargeBinary)}toString(){return`LargeBinary`}};qu=Symbol.toStringTag,Td[qu]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeBinary`))(Td.prototype);var Ed=class extends C{constructor(){super(S.Utf8)}toString(){return`Utf8`}};Ju=Symbol.toStringTag,Ed[Ju]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Utf8`))(Ed.prototype);var Dd=class extends C{constructor(){super(S.LargeUtf8)}toString(){return`LargeUtf8`}};Yu=Symbol.toStringTag,Dd[Yu]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeUtf8`))(Dd.prototype);var Od=class extends C{constructor(){super(S.Bool)}toString(){return`Bool`}};Xu=Symbol.toStringTag,Od[Xu]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Bool`))(Od.prototype);var kd=class extends C{constructor(e,t,n=128){super(S.Decimal),this.scale=e,this.precision=t,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?`+`:``}${this.scale}]`}};Zu=Symbol.toStringTag,kd[Zu]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]=`Decimal`))(kd.prototype);var Ad=class extends C{constructor(e){super(S.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${Il[this.unit]}>`}get ArrayType(){return this.unit===Il.DAY?Int32Array:BigInt64Array}};Qu=Symbol.toStringTag,Ad[Qu]=(e=>(e.unit=null,e[Symbol.toStringTag]=`Date`))(Ad.prototype);var jd=class extends C{constructor(e,t){super(S.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${x[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};$u=Symbol.toStringTag,jd[$u]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]=`Time`))(jd.prototype);var Md=class extends C{constructor(e,t){super(S.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${x[this.unit]}${this.timezone?`, ${this.timezone}`:``}>`}};ed=Symbol.toStringTag,Md[ed]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Timestamp`))(Md.prototype);var Nd=class extends C{constructor(e){super(S.Interval),this.unit=e}toString(){return`Interval<${Ll[this.unit]}>`}};td=Symbol.toStringTag,Nd[td]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]=`Interval`))(Nd.prototype);var Pd=class extends C{constructor(e){super(S.Duration),this.unit=e}toString(){return`Duration<${x[this.unit]}>`}};nd=Symbol.toStringTag,Pd[nd]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Duration`))(Pd.prototype);var Fd=class extends C{constructor(e){super(S.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}};rd=Symbol.toStringTag,Fd[rd]=(e=>(e.children=null,e[Symbol.toStringTag]=`List`))(Fd.prototype);var Id=class extends C{constructor(e){super(S.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};id=Symbol.toStringTag,Id[id]=(e=>(e.children=null,e[Symbol.toStringTag]=`Struct`))(Id.prototype);var Ld=class extends C{constructor(e,t,n){super(S.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(` | `)}>`}};ad=Symbol.toStringTag,Ld[ad]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]=`Union`))(Ld.prototype);var Rd=class extends C{constructor(e){super(S.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};od=Symbol.toStringTag,Rd[od]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`FixedSizeBinary`))(Rd.prototype);var zd=class extends C{constructor(e,t){super(S.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}>`}};sd=Symbol.toStringTag,zd[sd]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]=`FixedSizeList`))(zd.prototype);var Bd=class extends C{constructor(e,t=!1){var n,r,i;if(super(S.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(`, `)}}>`}};cd=Symbol.toStringTag,Bd[cd]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]=`Map_`))(Bd.prototype);const Vd=(e=>()=>++e)(-1);var Hd=class extends C{constructor(e,t,n,r){super(S.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=r||!1,this.id=n==null?Vd():Ou(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}>`}};ld=Symbol.toStringTag,Hd[ld]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]=`Dictionary`))(Hd.prototype);function Ud(e){let t=e;switch(e.typeId){case S.Decimal:return e.bitWidth/32;case S.Interval:return 1+t.unit;case S.FixedSizeList:return t.listSize;case S.FixedSizeBinary:return t.byteWidth;default:return 1}}var w=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 Wd(this,e,t)}getVisitFnByTypeId(e,t=!0){return Gd(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 Wd(e,t,n=!0){return typeof t==`number`?Gd(e,t,n):typeof t==`string`&&t in S?Gd(e,S[t],n):t&&t instanceof C?Gd(e,Kd(t),n):t?.type&&t.type instanceof C?Gd(e,Kd(t.type),n):Gd(e,S.NONE,n)}function Gd(e,t,n=!0){let r=null;switch(t){case S.Null:r=e.visitNull;break;case S.Bool:r=e.visitBool;break;case S.Int:r=e.visitInt;break;case S.Int8:r=e.visitInt8||e.visitInt;break;case S.Int16:r=e.visitInt16||e.visitInt;break;case S.Int32:r=e.visitInt32||e.visitInt;break;case S.Int64:r=e.visitInt64||e.visitInt;break;case S.Uint8:r=e.visitUint8||e.visitInt;break;case S.Uint16:r=e.visitUint16||e.visitInt;break;case S.Uint32:r=e.visitUint32||e.visitInt;break;case S.Uint64:r=e.visitUint64||e.visitInt;break;case S.Float:r=e.visitFloat;break;case S.Float16:r=e.visitFloat16||e.visitFloat;break;case S.Float32:r=e.visitFloat32||e.visitFloat;break;case S.Float64:r=e.visitFloat64||e.visitFloat;break;case S.Utf8:r=e.visitUtf8;break;case S.LargeUtf8:r=e.visitLargeUtf8;break;case S.Binary:r=e.visitBinary;break;case S.LargeBinary:r=e.visitLargeBinary;break;case S.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case S.Date:r=e.visitDate;break;case S.DateDay:r=e.visitDateDay||e.visitDate;break;case S.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case S.Timestamp:r=e.visitTimestamp;break;case S.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case S.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case S.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case S.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case S.Time:r=e.visitTime;break;case S.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case S.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case S.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case S.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case S.Decimal:r=e.visitDecimal;break;case S.List:r=e.visitList;break;case S.Struct:r=e.visitStruct;break;case S.Union:r=e.visitUnion;break;case S.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case S.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case S.Dictionary:r=e.visitDictionary;break;case S.Interval:r=e.visitInterval;break;case S.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case S.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case S.Duration:r=e.visitDuration;break;case S.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case S.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case S.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case S.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case S.FixedSizeList:r=e.visitFixedSizeList;break;case S.Map:r=e.visitMap;break}if(typeof r==`function`)return r;if(!n)return()=>null;throw Error(`Unrecognized type '${S[t]}'`)}function Kd(e){switch(e.typeId){case S.Null:return S.Null;case S.Int:{let{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?S.Int8:S.Uint8;case 16:return n?S.Int16:S.Uint16;case 32:return n?S.Int32:S.Uint32;case 64:return n?S.Int64:S.Uint64}return S.Int}case S.Float:switch(e.precision){case Fl.HALF:return S.Float16;case Fl.SINGLE:return S.Float32;case Fl.DOUBLE:return S.Float64}return S.Float;case S.Binary:return S.Binary;case S.LargeBinary:return S.LargeBinary;case S.Utf8:return S.Utf8;case S.LargeUtf8:return S.LargeUtf8;case S.Bool:return S.Bool;case S.Decimal:return S.Decimal;case S.Time:switch(e.unit){case x.SECOND:return S.TimeSecond;case x.MILLISECOND:return S.TimeMillisecond;case x.MICROSECOND:return S.TimeMicrosecond;case x.NANOSECOND:return S.TimeNanosecond}return S.Time;case S.Timestamp:switch(e.unit){case x.SECOND:return S.TimestampSecond;case x.MILLISECOND:return S.TimestampMillisecond;case x.MICROSECOND:return S.TimestampMicrosecond;case x.NANOSECOND:return S.TimestampNanosecond}return S.Timestamp;case S.Date:switch(e.unit){case Il.DAY:return S.DateDay;case Il.MILLISECOND:return S.DateMillisecond}return S.Date;case S.Interval:switch(e.unit){case Ll.DAY_TIME:return S.IntervalDayTime;case Ll.YEAR_MONTH:return S.IntervalYearMonth}return S.Interval;case S.Duration:switch(e.unit){case x.SECOND:return S.DurationSecond;case x.MILLISECOND:return S.DurationMillisecond;case x.MICROSECOND:return S.DurationMicrosecond;case x.NANOSECOND:return S.DurationNanosecond}return S.Duration;case S.Map:return S.Map;case S.List:return S.List;case S.Struct:return S.Struct;case S.Union:switch(e.mode){case Pl.Dense:return S.DenseUnion;case Pl.Sparse:return S.SparseUnion}return S.Union;case S.FixedSizeBinary:return S.FixedSizeBinary;case S.FixedSizeList:return S.FixedSizeList;case S.Dictionary:return S.Dictionary}throw Error(`Unrecognized type '${S[e.typeId]}'`)}w.prototype.visitInt8=null,w.prototype.visitInt16=null,w.prototype.visitInt32=null,w.prototype.visitInt64=null,w.prototype.visitUint8=null,w.prototype.visitUint16=null,w.prototype.visitUint32=null,w.prototype.visitUint64=null,w.prototype.visitFloat16=null,w.prototype.visitFloat32=null,w.prototype.visitFloat64=null,w.prototype.visitDateDay=null,w.prototype.visitDateMillisecond=null,w.prototype.visitTimestampSecond=null,w.prototype.visitTimestampMillisecond=null,w.prototype.visitTimestampMicrosecond=null,w.prototype.visitTimestampNanosecond=null,w.prototype.visitTimeSecond=null,w.prototype.visitTimeMillisecond=null,w.prototype.visitTimeMicrosecond=null,w.prototype.visitTimeNanosecond=null,w.prototype.visitDenseUnion=null,w.prototype.visitSparseUnion=null,w.prototype.visitIntervalDayTime=null,w.prototype.visitIntervalYearMonth=null,w.prototype.visitDuration=null,w.prototype.visitDurationSecond=null,w.prototype.visitDurationMillisecond=null,w.prototype.visitDurationMicrosecond=null,w.prototype.visitDurationNanosecond=null;const qd=new Float64Array(1),Jd=new Uint32Array(qd.buffer);function Yd(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 Xd(e){if(e!==e)return 32256;qd[0]=e;let t=(Jd[1]&2147483648)>>16&65535,n=Jd[1]&2146435072,r=0;return n>=1089470464?Jd[0]>0?n=31744:(n=(n&2080374784)>>16,r=(Jd[1]&1048575)>>10):n<=1056964608?(r=1048576+(Jd[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(Jd[1]&1048575)+512>>10),t|n|r&65535}var T=class extends w{};function E(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const Zd=(e,t,n)=>{e[t]=Math.floor(n/864e5)},Qd=(e,t,n,r)=>{if(n+1{let i=e+n;r?t[i>>3]|=1<>3]&=~(1<{e[t]=n},tf=({values:e},t,n)=>{e[t]=n},nf=({values:e},t,n)=>{e[t]=Xd(n)},rf=(e,t,n)=>{switch(e.type.precision){case Fl.HALF:return nf(e,t,n);case Fl.SINGLE:case Fl.DOUBLE:return tf(e,t,n)}},af=({values:e},t,n)=>{Zd(e,t,n.valueOf())},sf=({values:e},t,n)=>{e[t]=BigInt(n)},cf=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},lf=({values:e,valueOffsets:t},n,r)=>Qd(e,t,n,r),uf=({values:e,valueOffsets:t},n,r)=>Qd(e,t,n,Kc(r)),df=(e,t,n)=>{e.type.unit===Il.DAY?af(e,t,n):sf(e,t,n)},ff=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},pf=({values:e},t,n)=>{e[t]=BigInt(n)},mf=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},hf=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},gf=(e,t,n)=>{switch(e.type.unit){case x.SECOND:return ff(e,t,n);case x.MILLISECOND:return pf(e,t,n);case x.MICROSECOND:return mf(e,t,n);case x.NANOSECOND:return hf(e,t,n)}},_f=({values:e},t,n)=>{e[t]=n},vf=({values:e},t,n)=>{e[t]=n},yf=({values:e},t,n)=>{e[t]=n},bf=({values:e},t,n)=>{e[t]=n},xf=(e,t,n)=>{switch(e.type.unit){case x.SECOND:return _f(e,t,n);case x.MILLISECOND:return vf(e,t,n);case x.MICROSECOND:return yf(e,t,n);case x.NANOSECOND:return bf(e,t,n)}},Sf=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},Cf=(e,t,n)=>{let r=e.children[0],i=e.valueOffsets,a=Uf.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=Uf.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},Tf=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[a]),Ef=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(a)),Df=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(i.name)),Of=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[i.name]),kf=(e,t,n)=>{let r=e.type.children.map(e=>Uf.getVisitFn(e.type)),i=n instanceof Map?Df(t,n):n instanceof Pm?Ef(t,n):Array.isArray(n)?Tf(t,n):Of(t,n);e.type.children.forEach((t,n)=>i(r[n],e.children[n],t,n))},Af=(e,t,n)=>{e.type.mode===Pl.Dense?jf(e,t,n):Mf(e,t,n)},jf=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Uf.visit(i,e.valueOffsets[t],n)},Mf=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Uf.visit(i,t,n)},Nf=(e,t,n)=>{var r;(r=e.dictionary)==null||r.set(e.values[t],n)},Pf=(e,t,n)=>{e.type.unit===Ll.DAY_TIME?Ff(e,t,n):If(e,t,n)},Ff=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},If=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},Lf=({values:e},t,n)=>{e[t]=n},Rf=({values:e},t,n)=>{e[t]=n},zf=({values:e},t,n)=>{e[t]=n},Bf=({values:e},t,n)=>{e[t]=n},Vf=(e,t,n)=>{switch(e.type.unit){case x.SECOND:return Lf(e,t,n);case x.MILLISECOND:return Rf(e,t,n);case x.MICROSECOND:return zf(e,t,n);case x.NANOSECOND:return Bf(e,t,n)}},Hf=(e,t,n)=>{let{stride:r}=e,i=e.children[0],a=Uf.getVisitFn(i);if(Array.isArray(n))for(let e=-1,o=t*r;++e`${Du(e)}: ${Du(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}[Symbol.iterator](){return new qf(this[Wf],this[Gf])}},qf=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[Wf].type.children.findIndex(e=>e.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[Wf].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[Wf].type.children.findIndex(e=>e.name===t);if(n!==-1){let r=Lp.visit(e[Wf].children[n],e[Gf]);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[Wf].type.children.findIndex(e=>e.name===t);return r===-1?Reflect.has(e,t)||typeof t==`symbol`?Reflect.set(e,t,n):!1:(Uf.visit(e[Wf].children[r],e[Gf],n),Reflect.set(e,t,n))}},D=class extends w{};function O(e){return(t,n)=>t.getValid(n)?e(t,n):null}const Yf=(e,t)=>864e5*e[t],Xf=(e,t)=>null,Zf=(e,t,n)=>{if(n+1>=t.length)return null;let r=Ou(t[n]),i=Ou(t[n+1]);return e.subarray(r,i)},Qf=({offset:e,values:t},n)=>{let r=e+n,i=t[r>>3];return(i&1<Yf(e,t),ep=({values:e},t)=>Ou(e[t]),tp=({stride:e,values:t},n)=>t[e*n],np=({stride:e,values:t},n)=>Yd(t[e*n]),rp=({values:e},t)=>e[t],ip=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),ap=({values:e,valueOffsets:t},n)=>Zf(e,t,n),op=({values:e,valueOffsets:t},n)=>{let r=Zf(e,t,n);return r===null?null:Wc(r)},sp=({values:e},t)=>e[t],cp=({type:e,values:t},n)=>e.precision===Fl.HALF?Yd(t[n]):t[n],lp=(e,t)=>e.type.unit===Il.DAY?$f(e,t):ep(e,t),up=({values:e},t)=>1e3*Ou(e[t]),dp=({values:e},t)=>Ou(e[t]),fp=({values:e},t)=>ku(e[t],BigInt(1e3)),pp=({values:e},t)=>ku(e[t],BigInt(1e6)),mp=(e,t)=>{switch(e.type.unit){case x.SECOND:return up(e,t);case x.MILLISECOND:return dp(e,t);case x.MICROSECOND:return fp(e,t);case x.NANOSECOND:return pp(e,t)}},hp=({values:e},t)=>e[t],gp=({values:e},t)=>e[t],_p=({values:e},t)=>e[t],vp=({values:e},t)=>e[t],yp=(e,t)=>{switch(e.type.unit){case x.SECOND:return hp(e,t);case x.MILLISECOND:return gp(e,t);case x.MICROSECOND:return _p(e,t);case x.NANOSECOND:return vp(e,t)}},bp=({values:e,stride:t},n)=>Vu.decimal(e.subarray(t*n,t*(n+1))),xp=(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 Pm([c])},Sp=(e,t)=>{let{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:a}=n,o=r[0];return new Hp(o.slice(i,a-i))},Cp=(e,t)=>new Kf(e,t),wp=(e,t)=>e.type.mode===Pl.Dense?Tp(e,t):Ep(e,t),Tp=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return Lp.visit(r,e.valueOffsets[t])},Ep=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return Lp.visit(r,t)},Dp=(e,t)=>{var n;return(n=e.dictionary)?.get(e.values[t])},Op=(e,t)=>e.type.unit===Ll.DAY_TIME?kp(e,t):Ap(e,t),kp=({values:e},t)=>e.subarray(2*t,2*(t+1)),Ap=({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},jp=({values:e},t)=>e[t],Mp=({values:e},t)=>e[t],Np=({values:e},t)=>e[t],Pp=({values:e},t)=>e[t],Fp=(e,t)=>{switch(e.type.unit){case x.SECOND:return jp(e,t);case x.MILLISECOND:return Mp(e,t);case x.MICROSECOND:return Np(e,t);case x.NANOSECOND:return Pp(e,t)}},Ip=(e,t)=>{let{stride:n,children:r}=e,i=r[0],a=i.slice(t*n,n);return new Pm([a])};D.prototype.visitNull=O(Xf),D.prototype.visitBool=O(Qf),D.prototype.visitInt=O(sp),D.prototype.visitInt8=O(tp),D.prototype.visitInt16=O(tp),D.prototype.visitInt32=O(tp),D.prototype.visitInt64=O(rp),D.prototype.visitUint8=O(tp),D.prototype.visitUint16=O(tp),D.prototype.visitUint32=O(tp),D.prototype.visitUint64=O(rp),D.prototype.visitFloat=O(cp),D.prototype.visitFloat16=O(np),D.prototype.visitFloat32=O(tp),D.prototype.visitFloat64=O(tp),D.prototype.visitUtf8=O(op),D.prototype.visitLargeUtf8=O(op),D.prototype.visitBinary=O(ap),D.prototype.visitLargeBinary=O(ap),D.prototype.visitFixedSizeBinary=O(ip),D.prototype.visitDate=O(lp),D.prototype.visitDateDay=O($f),D.prototype.visitDateMillisecond=O(ep),D.prototype.visitTimestamp=O(mp),D.prototype.visitTimestampSecond=O(up),D.prototype.visitTimestampMillisecond=O(dp),D.prototype.visitTimestampMicrosecond=O(fp),D.prototype.visitTimestampNanosecond=O(pp),D.prototype.visitTime=O(yp),D.prototype.visitTimeSecond=O(hp),D.prototype.visitTimeMillisecond=O(gp),D.prototype.visitTimeMicrosecond=O(_p),D.prototype.visitTimeNanosecond=O(vp),D.prototype.visitDecimal=O(bp),D.prototype.visitList=O(xp),D.prototype.visitStruct=O(Cp),D.prototype.visitUnion=O(wp),D.prototype.visitDenseUnion=O(Tp),D.prototype.visitSparseUnion=O(Ep),D.prototype.visitDictionary=O(Dp),D.prototype.visitInterval=O(Op),D.prototype.visitIntervalDayTime=O(kp),D.prototype.visitIntervalYearMonth=O(Ap),D.prototype.visitDuration=O(Fp),D.prototype.visitDurationSecond=O(jp),D.prototype.visitDurationMillisecond=O(Mp),D.prototype.visitDurationMicrosecond=O(Np),D.prototype.visitDurationNanosecond=O(Pp),D.prototype.visitFixedSizeList=O(Ip),D.prototype.visitMap=O(Sp);const Lp=new D,Rp=Symbol.for(`keys`),zp=Symbol.for(`vals`),Bp=Symbol.for(`kKeysAsStrings`),Vp=Symbol.for(`_kKeysAsStrings`);var Hp=class{constructor(e){return this[Rp]=new Pm([e.children[0]]).memoize(),this[zp]=e.children[1],new Proxy(this,new Wp)}get[Bp](){return this[Vp]||(this[Vp]=Array.from(this[Rp].toArray(),String))}[Symbol.iterator](){return new Up(this[Rp],this[zp])}get size(){return this[Rp].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[Rp],t=this[zp],n={};for(let r=-1,i=e.length;++r`${Du(e)}: ${Du(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}},Up=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),Lp.visit(this.vals,e)]})}},Wp=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[Bp]}has(e,t){return e[Bp].includes(t)}getOwnPropertyDescriptor(e,t){let n=e[Bp].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[Bp].indexOf(t);if(n!==-1){let r=Lp.visit(Reflect.get(e,zp),n);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[Bp].indexOf(t);return r===-1?Reflect.has(e,t)?Reflect.set(e,t,n):!1:(Uf.visit(Reflect.get(e,zp),r,n),Reflect.set(e,t,n))}};Object.defineProperties(Hp.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[Rp]:{writable:!0,enumerable:!1,configurable:!1,value:null},[zp]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Vp]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Gp;function Kp(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 qp=(e,t)=>e<0?t+e:e,Jp=e=>e!==e;function Yp(e){let t=typeof e;if(t!==`object`||e===null)return Jp(e)?Jp: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?wl(e,t):!1:e instanceof Map?Zp(e):Array.isArray(e)?Xp(e):e instanceof Pm?Qp(e):$p(e,!0)}function Xp(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 tm(e,n);case Map:return rm(e,n,n.keys());case Hp:case Kf:case Object:case void 0:return rm(e,n,t||Object.keys(n))}return n instanceof Pm?nm(e,n):!1}}function tm(e,t){let n=e.length;if(t.length!==n)return!1;for(let r=-1;++r>r}function om(e,t,n){let r=n.byteLength+7&-8;if(e>0||n.byteLength>3):sm(new cm(n,e,t,null,im)).subarray(0,r)),i}return n}function sm(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 cm=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 lm(e,t,i)+lm(e,r,n)+um(e,i>>3,r-i>>3)}function um(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+=dm(a.getUint32(i)),i+=4;for(;o-i>=2;)r+=dm(a.getUint16(i)),i+=2;for(;o-i>=1;)r+=dm(a.getUint8(i)),i+=1;return r}function dm(e){let t=Math.trunc(e);return t-=t>>>1&1431655765,t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var fm=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 C.isSparseUnion(e)||C.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(C.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-lm(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=Ud(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(C.isUnion(t)){let n=t,r=this.children[n.typeIdToChildIndex[this.typeIds[e]]],i=n.mode===Pl.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(om(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===S.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(om(this.offset,t,this.nullBitmap),0);let i=this.buffers;return i[Eu.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[Eu.TYPE])&&(a[Eu.TYPE]=i.subarray(e,e+t)),(i=a[Eu.OFFSET])&&(a[Eu.OFFSET]=i.subarray(e,e+t+1))||(i=a[Eu.DATA])&&(a[Eu.DATA]=r===6?i:i.subarray(n*e,n*(e+t))),a}_sliceChildren(e,t,n){return e.map(e=>e.slice(t,n))}};fm.prototype.children=Object.freeze([]);var pm=class e extends w{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{type:t,offset:n=0,length:r=0}=e;return new fm(t,n,r,r)}visitBool(e){let{type:t,offset:n=0}=e,r=_l(e.nullBitmap),i=ml(t.ArrayType,e.data),{length:a=i.length>>3,nullCount:o=e.nullBitmap?-1:0}=e;return new fm(t,n,a,o,[void 0,i,r])}visitInt(e){let{type:t,offset:n=0}=e,r=_l(e.nullBitmap),i=ml(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new fm(t,n,a,o,[void 0,i,r])}visitFloat(e){let{type:t,offset:n=0}=e,r=_l(e.nullBitmap),i=ml(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new fm(t,n,a,o,[void 0,i,r])}visitUtf8(e){let{type:t,offset:n=0}=e,r=_l(e.data),i=_l(e.nullBitmap),a=hl(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new fm(t,n,o,s,[a,r,i])}visitLargeUtf8(e){let{type:t,offset:n=0}=e,r=_l(e.data),i=_l(e.nullBitmap),a=gl(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new fm(t,n,o,s,[a,r,i])}visitBinary(e){let{type:t,offset:n=0}=e,r=_l(e.data),i=_l(e.nullBitmap),a=hl(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new fm(t,n,o,s,[a,r,i])}visitLargeBinary(e){let{type:t,offset:n=0}=e,r=_l(e.data),i=_l(e.nullBitmap),a=gl(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new fm(t,n,o,s,[a,r,i])}visitFixedSizeBinary(e){let{type:t,offset:n=0}=e,r=_l(e.nullBitmap),i=ml(t.ArrayType,e.data),{length:a=i.length/Ud(t),nullCount:o=e.nullBitmap?-1:0}=e;return new fm(t,n,a,o,[void 0,i,r])}visitDate(e){let{type:t,offset:n=0}=e,r=_l(e.nullBitmap),i=ml(t.ArrayType,e.data),{length:a=i.length/Ud(t),nullCount:o=e.nullBitmap?-1:0}=e;return new fm(t,n,a,o,[void 0,i,r])}visitTimestamp(e){let{type:t,offset:n=0}=e,r=_l(e.nullBitmap),i=ml(t.ArrayType,e.data),{length:a=i.length/Ud(t),nullCount:o=e.nullBitmap?-1:0}=e;return new fm(t,n,a,o,[void 0,i,r])}visitTime(e){let{type:t,offset:n=0}=e,r=_l(e.nullBitmap),i=ml(t.ArrayType,e.data),{length:a=i.length/Ud(t),nullCount:o=e.nullBitmap?-1:0}=e;return new fm(t,n,a,o,[void 0,i,r])}visitDecimal(e){let{type:t,offset:n=0}=e,r=_l(e.nullBitmap),i=ml(t.ArrayType,e.data),{length:a=i.length/Ud(t),nullCount:o=e.nullBitmap?-1:0}=e;return new fm(t,n,a,o,[void 0,i,r])}visitList(e){let{type:t,offset:n=0,child:r}=e,i=_l(e.nullBitmap),a=hl(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new fm(t,n,o,s,[a,void 0,i],[r])}visitStruct(e){let{type:t,offset:n=0,children:r=[]}=e,i=_l(e.nullBitmap),{length:a=r.reduce((e,{length:t})=>Math.max(e,t),0),nullCount:o=e.nullBitmap?-1:0}=e;return new fm(t,n,a,o,[void 0,void 0,i],r)}visitUnion(e){let{type:t,offset:n=0,children:r=[]}=e,i=ml(t.ArrayType,e.typeIds),{length:a=i.length,nullCount:o=-1}=e;if(C.isSparseUnion(t))return new fm(t,n,a,o,[void 0,void 0,void 0,i],r);let s=hl(e.valueOffsets);return new fm(t,n,a,o,[s,void 0,void 0,i],r)}visitDictionary(t){let{type:n,offset:r=0}=t,i=_l(t.nullBitmap),a=ml(n.indices.ArrayType,t.data),{dictionary:o=new Pm([new e().visit({type:n.dictionary})])}=t,{length:s=a.length,nullCount:c=t.nullBitmap?-1:0}=t;return new fm(n,r,s,c,[void 0,a,i],[],o)}visitInterval(e){let{type:t,offset:n=0}=e,r=_l(e.nullBitmap),i=ml(t.ArrayType,e.data),{length:a=i.length/Ud(t),nullCount:o=e.nullBitmap?-1:0}=e;return new fm(t,n,a,o,[void 0,i,r])}visitDuration(e){let{type:t,offset:n=0}=e,r=_l(e.nullBitmap),i=ml(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new fm(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=_l(t.nullBitmap),{length:o=i.length/Ud(n),nullCount:s=t.nullBitmap?-1:0}=t;return new fm(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=_l(t.nullBitmap),o=hl(t.valueOffsets),{length:s=o.length-1,nullCount:c=t.nullBitmap?-1:0}=t;return new fm(n,r,s,c,[o,void 0,a],[i])}};const mm=new pm;function k(e){return mm.visit(e)}var hm=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 _m(e){return e.reduce((e,t)=>e+t.nullCount,0)}function vm(e){return e.reduce((e,t,n)=>(e[n+1]=e[n]+t.length,e),new Uint32Array(e.length+1))}function ym(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 bm(e,t,n,r){let i=0,a=0,o=t.length-1;do{if(i>=o-1)return n0?0:-1}function Em(e,t){let{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(let i of new cm(n,e.offset+(t||0),e.length,n,im)){if(!i)return r;++r}return-1}function j(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case S.Union:break;case S.Dictionary:break;default:return Em(e,n)}let r=Lp.getVisitFn(e),i=Yp(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 hm(e.data.length,t=>{let r=e.data[t],i=r.length,a=e.slice(n,n+i);return n+=i,new km(a)})}var km=class{constructor(e){this.vector=e,this.index=0}next(){return this.indexe.data):t;if(a.length===0||a.some(e=>!(e instanceof fm)))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}=Mm[o.typeId],r=a[0];this.isValid=e=>xm(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,Nm[o.typeId]),this._offsets=vm(a);break}this.data=a,this.type=o,this.stride=Ud(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 gm(this.data)}get nullCount(){return _m(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${S[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(qp(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return Am.visit(this)}concat(...t){return new e(this.data.concat(t.flatMap(e=>e.data).flat(1/0)))}slice(t,n){return new e(Kp(this,t,n,({data:e,_offsets:t},n,r)=>ym(e,t,n,r)))}toJSON(){return[...this]}toArray(){let{type:e,data:t,length:n,stride:r,ArrayType:i}=this;switch(e.typeId){case S.Int:case S.Float:case S.Decimal:case S.Time:case S.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 C.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(C.isDictionary(this.type)){let t=new Fm(this.data[0].dictionary),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return new Fm(this)}unmemoize(){if(C.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}};jm=Symbol.toStringTag,Pm[jm]=(e=>{e.type=C.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(S).map(e=>S[e]).filter(e=>typeof e==`number`&&e!==S.NONE);for(let n of t){let t=Lp.getVisitFnByTypeId(n),r=Uf.getVisitFnByTypeId(n),i=Om.getVisitFnByTypeId(n);Mm[n]={get:t,set:r,indexOf:i},Nm[n]=Object.create(e,{isValid:{value:Sm(xm)},get:{value:Sm(Lp.getVisitFnByTypeId(n))},set:{value:Cm(Uf.getVisitFnByTypeId(n))},indexOf:{value:wm(Om.getVisitFnByTypeId(n))}})}return`Vector`})(Pm.prototype);var Fm=class e extends Pm{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 Pm(this.data)}),Object.defineProperty(this,`memoize`,{value:()=>this})}},Im=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()}},Lm=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):Nl.V1}schema(e){let t=this.bb.__offset(this.bb_pos,6);return t?(e||new wu).__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 Im).__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 Im).__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 nu).__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,Nl.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)}},Rm=class e{constructor(e=[],t,n,r=Nl.V5){this.fields=e||[],this.metadata=t||new Map,n||=Vm(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=Bm(Bm(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:Bm(Bm(new Map,r[t].metadata),e.metadata)}))&&!1:!0}),o=Vm(a,new Map);return new e([...r,...a],i,new Map([...this.dictionaries,...o]))}};Rm.prototype.fields=null,Rm.prototype.metadata=null,Rm.prototype.dictionaries=null;var zm=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)}};zm.prototype.type=null,zm.prototype.name=null,zm.prototype.nullable=null,zm.prototype.metadata=null;function Bm(e,t){return new Map([...e||new Map,...t||new Map])}function Vm(e,t=new Map){for(let n=-1,r=e.length;++n0&&Vm(i.children,t)}return t}var Hm=Wl,Um=Ul,Wm=class{static decode(e){e=new Um(_l(e));let t=Lm.getRootAsFooter(e),n=Rm.decode(t.schema(),new Map,t.version());return new Gm(n,t)}static encode(e){let t=new Hm,n=Rm.encode(t,e.schema);Lm.startRecordBatchesVector(t,e.numRecordBatches);for(let n of[...e.recordBatches()].slice().reverse())Km.encode(t,n);let r=t.endVector();Lm.startDictionariesVector(t,e.numDictionaries);for(let n of[...e.dictionaryBatches()].slice().reverse())Km.encode(t,n);let i=t.endVector();return Lm.startFooter(t),Lm.addSchema(t,n),Lm.addVersion(t,Nl.V5),Lm.addRecordBatches(t,r),Lm.addDictionaries(t,i),Lm.finishFooterBuffer(t,Lm.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=Nl.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 y(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(qm);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return Tl.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return Tl.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return y(this,void 0,void 0,function*(){return yield this.abort(e),qm})}return(e){return y(this,void 0,void 0,function*(){return yield this.close(),qm})}read(e){return y(this,void 0,void 0,function*(){return(yield this.next(e,`read`)).value})}peek(e){return y(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(qm)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw Error(`AsyncQueue is closed`)}},Zm=class extends Xm{write(e){if((e=_l(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?Wc(this.toUint8Array(!0)):this.toUint8Array(!1).then(Wc)}toUint8Array(e=!1){return e?pl(this._values)[0]:(()=>y(this,void 0,void 0,function*(){var e,t,n,r;let i=[],a=0;try{for(var o=!0,s=Hc(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 pl(i,a)[0]}))()}},Qm=class{constructor(e){e&&(this.source=new eh(Tl.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)}},$m=class e{constructor(t){t instanceof e?this.source=t.source:t instanceof Zm?this.source=new th(Tl.fromAsyncIterable(t)):cl(t)?this.source=new th(Tl.fromNodeStream(t)):ol(t)?this.source=new th(Tl.fromDOMStream(t)):rl(t)?this.source=new th(Tl.fromDOMStream(t.body)):Qc(t)?this.source=new th(Tl.fromIterable(t)):(Zc(t)||$c(t))&&(this.source=new th(Tl.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)}},eh=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)||qm)}return(e){return Object.create(this.source.return&&this.source.return(e)||qm)}},th=class{constructor(e){this.source=e,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(e){return y(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return y(this,void 0,void 0,function*(){return(yield this.next(e,`read`)).value})}peek(e){return y(this,void 0,void 0,function*(){return(yield this.next(e,`peek`)).value})}next(e){return y(this,arguments,void 0,function*(e,t=`read`){return yield this.source.next({cmd:t,size:e})})}throw(e){return y(this,void 0,void 0,function*(){let t=this.source.throw&&(yield this.source.throw(e))||qm;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return y(this,void 0,void 0,function*(){let t=this.source.return&&(yield this.source.return(e))||qm;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}},nh=class extends Qm{constructor(e,t){super(),this.position=0,this.buffer=_l(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),ey(this,void 0,void 0,function*(){this.size=(yield e.stat()).size,delete this._pending}))()}readInt32(e){return y(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 y(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`${ih(this.buffer[3])} ${ih(this.buffer[2])} ${ih(this.buffer[1])} ${ih(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)}},dh=class extends uh{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:sm(this.sources[n])}readOffsets(e,{offset:t}=this.nextBufferRange()){return ml(Uint8Array,ml(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return ml(Uint8Array,ml(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){let{sources:n}=this;return C.isTimestamp(e)||(C.isInt(e)||C.isTime(e))&&e.bitWidth===64||C.isDuration(e)||C.isDate(e)&&e.unit===Il.MILLISECOND?ml(Uint8Array,ch.convertArray(n[t])):C.isDecimal(e)?ml(Uint8Array,lh.convertArray(n[t])):C.isBinary(e)||C.isLargeBinary(e)||C.isFixedSizeBinary(e)?fh(n[t]):C.isBool(e)?sm(n[t]):C.isUtf8(e)||C.isLargeUtf8(e)?Kc(n[t].join(``)):ml(Uint8Array,ml(e.ArrayType,n[t].map(e=>+e)))}};function fh(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 P=class extends w{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 ph(e,t){return t instanceof e.constructor}function mh(e,t){return e===t||ph(e,t)}function hh(e,t){return e===t||ph(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function gh(e,t){return e===t||ph(e,t)&&e.precision===t.precision}function _h(e,t){return e===t||ph(e,t)&&e.byteWidth===t.byteWidth}function vh(e,t){return e===t||ph(e,t)&&e.unit===t.unit}function yh(e,t){return e===t||ph(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function bh(e,t){return e===t||ph(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function xh(e,t){return e===t||ph(e,t)&&e.children.length===t.children.length&&kh.compareManyFields(e.children,t.children)}function Sh(e,t){return e===t||ph(e,t)&&e.children.length===t.children.length&&kh.compareManyFields(e.children,t.children)}function Ch(e,t){return e===t||ph(e,t)&&e.mode===t.mode&&e.typeIds.every((e,n)=>e===t.typeIds[n])&&kh.compareManyFields(e.children,t.children)}function wh(e,t){return e===t||ph(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&kh.visit(e.indices,t.indices)&&kh.visit(e.dictionary,t.dictionary)}function Th(e,t){return e===t||ph(e,t)&&e.unit===t.unit}function Eh(e,t){return e===t||ph(e,t)&&e.unit===t.unit}function Dh(e,t){return e===t||ph(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&kh.compareManyFields(e.children,t.children)}function Oh(e,t){return e===t||ph(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&kh.compareManyFields(e.children,t.children)}P.prototype.visitNull=mh,P.prototype.visitBool=mh,P.prototype.visitInt=hh,P.prototype.visitInt8=hh,P.prototype.visitInt16=hh,P.prototype.visitInt32=hh,P.prototype.visitInt64=hh,P.prototype.visitUint8=hh,P.prototype.visitUint16=hh,P.prototype.visitUint32=hh,P.prototype.visitUint64=hh,P.prototype.visitFloat=gh,P.prototype.visitFloat16=gh,P.prototype.visitFloat32=gh,P.prototype.visitFloat64=gh,P.prototype.visitUtf8=mh,P.prototype.visitLargeUtf8=mh,P.prototype.visitBinary=mh,P.prototype.visitLargeBinary=mh,P.prototype.visitFixedSizeBinary=_h,P.prototype.visitDate=vh,P.prototype.visitDateDay=vh,P.prototype.visitDateMillisecond=vh,P.prototype.visitTimestamp=yh,P.prototype.visitTimestampSecond=yh,P.prototype.visitTimestampMillisecond=yh,P.prototype.visitTimestampMicrosecond=yh,P.prototype.visitTimestampNanosecond=yh,P.prototype.visitTime=bh,P.prototype.visitTimeSecond=bh,P.prototype.visitTimeMillisecond=bh,P.prototype.visitTimeMicrosecond=bh,P.prototype.visitTimeNanosecond=bh,P.prototype.visitDecimal=mh,P.prototype.visitList=xh,P.prototype.visitStruct=Sh,P.prototype.visitUnion=Ch,P.prototype.visitDenseUnion=Ch,P.prototype.visitSparseUnion=Ch,P.prototype.visitDictionary=wh,P.prototype.visitInterval=Th,P.prototype.visitIntervalDayTime=Th,P.prototype.visitIntervalYearMonth=Th,P.prototype.visitDuration=Eh,P.prototype.visitDurationSecond=Eh,P.prototype.visitDurationMillisecond=Eh,P.prototype.visitDurationMicrosecond=Eh,P.prototype.visitDurationNanosecond=Eh,P.prototype.visitFixedSizeList=Dh,P.prototype.visitMap=Oh;const kh=new P;function Ah(e,t){return kh.compareSchemas(e,t)}function jh(e,t){return Mh(e,t.map(e=>e.data.concat()))}function Mh(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++]=k({type:new Id(n),length:o,nullCount:0,children:u.slice()})))}return[e=e.assign(n),r.map(t=>new Lh(e,t))]}function Nh(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))??k({type:r.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return n}var Ph,Fh=class e{constructor(...t){var n,r;if(t.length===0)return this.batches=[],this.schema=new Rm([]),this._offsets=[0],this;let i,a;t[0]instanceof Rm&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(a=t.pop());let o=t=>{if(t){if(t instanceof Lh)return[t];if(t instanceof e)return t.batches;if(t instanceof fm){if(t.type instanceof Id)return[new Lh(new Rm(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 Pm([t[e]])),r=i??new Rm(e.map((e,t)=>new zm(String(e),n[t].type,n[t].nullable))),[,a]=jh(r,n);return a.length===0?[new Lh(t)]:a}}return[]},s=t.flatMap(e=>o(e));if(i=(r=i??(n=s[0])?.schema)??new Rm([]),!(i instanceof Rm))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);for(let e of s){if(!(e instanceof Lh))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);if(!Ah(i,e.schema))throw TypeError(`Table and inner RecordBatch schemas must be equivalent.`)}this.schema=i,this.batches=s,this._offsets=a??vm(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=_m(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(qp(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?Am.visit(new Pm(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 Lh(n,e)))}slice(t,n){let r=this.schema;[t,n]=Kp({length:this.numRows},t,n);let i=ym(this.data,this._offsets,t,n);return new e(r,i.map(e=>new Lh(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=k({type:n,length:0,nullCount:0});t.push(r._changeLengthAndBackfillNullBitmap(this.numRows))}return new Pm(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]=jh(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(...jh(a,o))}};Ph=Symbol.toStringTag,Fh[Ph]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=Sm(xm),e.get=Sm(Lp.getVisitFn(S.Struct)),e.set=Cm(Uf.getVisitFn(S.Struct)),e.indexOf=wm(Om.getVisitFn(S.Struct)),`Table`))(Fh.prototype);var Ih,Lh=class e{constructor(...e){switch(e.length){case 2:if([this.schema]=e,!(this.schema instanceof Rm)||([,this.data=k({nullCount:0,type:new Id(this.schema.fields),children:this.schema.fields.map(e=>k({type:e.type,nullCount:0}))})]=e,!(this.data instanceof fm)))throw TypeError(`RecordBatch constructor expects a [Schema, Data] pair.`);[this.schema,this.data]=Rh(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]=zm.new({name:n,type:t[n].type,nullable:!0}),e),{length:0,fields:[],children:[]}),a=new Rm(n),o=k({type:new Id(n),length:i,children:r,nullCount:0});[this.schema,this.data]=Rh(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||=zh(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 Lp.visit(this.data,e)}at(e){return this.get(qp(e,this.numRows))}set(e,t){return Uf.visit(this.data,e,t)}indexOf(e,t){return Om.visit(this.data,e,t)}[Symbol.iterator](){return Am.visit(new Pm([this.data]))}toArray(){return[...this]}concat(...e){return new Fh(this.schema,[this,...e])}slice(t,n){let[r]=new Pm([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,k({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=k({type:new Id(n.fields),length:this.numRows,children:r});return new e(n,i)}};Ih=Symbol.toStringTag,Lh[Ih]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,`RecordBatch`))(Lh.prototype);function Rh(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))??k({type:c.type,length:n,nullCount:n,nullBitmap:new Uint8Array(o)}))}return[e.assign(i),k({type:new Id(i),length:n,children:a})]}function zh(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;++rk({type:e.type})),n=k({type:new Id(e.fields),nullCount:0,children:t});super(e,n)}},Vh=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):Nl.V1}headerType(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):Tu.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 nu).__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,Nl.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,Tu.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)}},Hh=class extends w{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return gu.startNull(t),gu.endNull(t)}visitInt(e,t){return eu.startInt(t),eu.addBitWidth(t,e.bitWidth),eu.addIsSigned(t,e.isSigned),eu.endInt(t)}visitFloat(e,t){return uu.startFloatingPoint(t),uu.addPrecision(t,e.precision),uu.endFloatingPoint(t)}visitBinary(e,t){return ru.startBinary(t),ru.endBinary(t)}visitLargeBinary(e,t){return fu.startLargeBinary(t),fu.endLargeBinary(t)}visitBool(e,t){return iu.startBool(t),iu.endBool(t)}visitUtf8(e,t){return xu.startUtf8(t),xu.endUtf8(t)}visitLargeUtf8(e,t){return pu.startLargeUtf8(t),pu.endLargeUtf8(t)}visitDecimal(e,t){return ou.startDecimal(t),ou.addScale(t,e.scale),ou.addPrecision(t,e.precision),ou.addBitWidth(t,e.bitWidth),ou.endDecimal(t)}visitDate(e,t){return au.startDate(t),au.addUnit(t,e.unit),au.endDate(t)}visitTime(e,t){return vu.startTime(t),vu.addUnit(t,e.unit),vu.addBitWidth(t,e.bitWidth),vu.endTime(t)}visitTimestamp(e,t){let n=e.timezone&&t.createString(e.timezone)||void 0;return yu.startTimestamp(t),yu.addUnit(t,e.unit),n!==void 0&&yu.addTimezone(t,n),yu.endTimestamp(t)}visitInterval(e,t){return du.startInterval(t),du.addUnit(t,e.unit),du.endInterval(t)}visitDuration(e,t){return su.startDuration(t),su.addUnit(t,e.unit),su.endDuration(t)}visitList(e,t){return mu.startList(t),mu.endList(t)}visitStruct(e,t){return _u.startStruct_(t),_u.endStruct_(t)}visitUnion(e,t){bu.startTypeIdsVector(t,e.typeIds.length);let n=bu.createTypeIdsVector(t,e.typeIds);return bu.startUnion(t),bu.addMode(t,e.mode),bu.addTypeIds(t,n),bu.endUnion(t)}visitDictionary(e,t){let n=this.visit(e.indices,t);return tu.startDictionaryEncoding(t),tu.addId(t,BigInt(e.id)),tu.addIsOrdered(t,e.isOrdered),n!==void 0&&tu.addIndexType(t,n),tu.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return cu.startFixedSizeBinary(t),cu.addByteWidth(t,e.byteWidth),cu.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return lu.startFixedSizeList(t),lu.addListSize(t,e.listSize),lu.endFixedSizeList(t)}visitMap(e,t){return hu.startMap(t),hu.addKeysSorted(t,e.keysSorted),hu.endMap(t)}};const Uh=new Hh;function Wh(e,t=new Map){return new Rm(qh(e,t),$h(e.metadata),t)}function Gh(e){return new ag(e.count,Yh(e.columns),Xh(e.columns))}function Kh(e){return new og(Gh(e.data),e.id,e.isDelta)}function qh(e,t){return(e.fields||[]).filter(Boolean).map(e=>zm.fromJSON(e,t))}function Jh(e,t){return(e.children||[]).filter(Boolean).map(e=>zm.fromJSON(e,t))}function Yh(e){return(e||[]).reduce((e,t)=>[...e,new cg(t.count,Zh(t.VALIDITY)),...Yh(t.children)],[])}function Xh(e,t=[]){for(let n=-1,r=(e||[]).length;++ne+ +(t===0),0)}function Qh(e,t){let n,r,i,a,o,s;return!t||!(a=e.dictionary)?(o=tg(e,Jh(e,t)),i=new zm(e.name,o,e.nullable,$h(e.metadata))):t.has(n=a.id)?(r=(r=a.indexType)?eg(r):new md,s=new Hd(t.get(n),r,n,a.isOrdered),i=new zm(e.name,s,e.nullable,$h(e.metadata))):(r=(r=a.indexType)?eg(r):new md,t.set(n,o=tg(e,Jh(e,t))),s=new Hd(o,r,n,a.isOrdered),i=new zm(e.name,s,e.nullable,$h(e.metadata))),i||null}function $h(e=[]){return new Map(e.map(({key:e,value:t})=>[e,t]))}function eg(e){return new dd(e.isSigned,e.bitWidth)}function tg(e,t){let n=e.type.name;switch(n){case`NONE`:return new ud;case`null`:return new ud;case`binary`:return new wd;case`largebinary`:return new Td;case`utf8`:return new Ed;case`largeutf8`:return new Dd;case`bool`:return new Od;case`list`:return new Fd((t||[])[0]);case`struct`:return new Id(t||[]);case`struct_`:return new Id(t||[])}switch(n){case`int`:{let t=e.type;return new dd(t.isSigned,t.bitWidth)}case`floatingpoint`:{let t=e.type;return new bd(Fl[t.precision])}case`decimal`:{let t=e.type;return new kd(t.scale,t.precision,t.bitWidth)}case`date`:{let t=e.type;return new Ad(Il[t.unit])}case`time`:{let t=e.type;return new jd(x[t.unit],t.bitWidth)}case`timestamp`:{let t=e.type;return new Md(x[t.unit],t.timezone)}case`interval`:{let t=e.type;return new Nd(Ll[t.unit])}case`duration`:{let t=e.type;return new Pd(x[t.unit])}case`union`:{let n=e.type,[r,...i]=(n.mode+``).toLowerCase(),a=r.toUpperCase()+i.join(``);return new Ld(Pl[a],n.typeIds||[],t||[])}case`fixedsizebinary`:{let t=e.type;return new Rd(t.byteWidth)}case`fixedsizelist`:{let n=e.type;return new zd(n.listSize,(t||[])[0])}case`map`:{let n=e.type;return new Bd((t||[])[0],n.keysSorted)}}throw Error(`Unrecognized type: "${n}"`)}var ng=Wl,rg=Ul,ig=class e{static fromJSON(t,n){let r=new e(0,Nl.V5,n);return r._createHeader=lg(t,n),r}static decode(t){t=new rg(_l(t));let n=Vh.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),a=n.headerType(),o=new e(r,i,a);return o._createHeader=ug(n,a),o}static encode(e){let t=new ng,n=-1;return e.isSchema()?n=Rm.encode(t,e.header()):e.isRecordBatch()?n=ag.encode(t,e.header()):e.isDictionaryBatch()&&(n=og.encode(t,e.header())),Vh.startMessage(t),Vh.addVersion(t,Nl.V5),Vh.addHeader(t,n),Vh.addHeaderType(t,e.headerType),Vh.addBodyLength(t,BigInt(e.bodyLength)),Vh.finishMessageBuffer(t,Vh.endMessage(t)),t.asUint8Array()}static from(t,n=0){if(t instanceof Rm)return new e(0,Nl.V5,Tu.Schema,t);if(t instanceof ag)return new e(n,Nl.V5,Tu.RecordBatch,t);if(t instanceof og)return new e(n,Nl.V5,Tu.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===Tu.Schema}isRecordBatch(){return this.headerType===Tu.RecordBatch}isDictionaryBatch(){return this.headerType===Tu.DictionaryBatch}constructor(e,t,n,r){this._version=t,this._headerType=n,this.body=new Uint8Array,r&&(this._createHeader=()=>r),this._bodyLength=Ou(e)}},ag=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=Ou(e)}},og=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=Ou(t)}},sg=class{constructor(e,t){this.offset=Ou(e),this.length=Ou(t)}},cg=class{constructor(e,t){this.length=Ou(e),this.nullCount=Ou(t)}};function lg(e,t){return(()=>{switch(t){case Tu.Schema:return Rm.fromJSON(e);case Tu.RecordBatch:return ag.fromJSON(e);case Tu.DictionaryBatch:return og.fromJSON(e)}throw Error(`Unrecognized Message type: { name: ${Tu[t]}, type: ${t} }`)})}function ug(e,t){return(()=>{switch(t){case Tu.Schema:return Rm.decode(e.header(new wu),new Map,e.version());case Tu.RecordBatch:return ag.decode(e.header(new Xl),e.version());case Tu.DictionaryBatch:return og.decode(e.header(new Zl),e.version())}throw Error(`Unrecognized Message type: { name: ${Tu[t]}, type: ${t} }`)})}zm.encode=Tg,zm.decode=bg,zm.fromJSON=Qh,Rm.encode=wg,Rm.decode=dg,Rm.fromJSON=Wh,ag.encode=Eg,ag.decode=fg,ag.fromJSON=Gh,og.encode=Dg,og.decode=pg,og.fromJSON=Kh,cg.encode=Og,cg.decode=hg,sg.encode=kg,sg.decode=mg;function dg(e,t=new Map,n=Nl.V5){let r=vg(e,t);return new Rm(r,xg(e),t,n)}function fg(e,t=Nl.V5){if(e.compression()!==null)throw Error(`Record batch compression not implemented`);return new ag(e.length(),gg(e),_g(e,t))}function pg(e,t=Nl.V5){return new og(ag.decode(e.data(),t),e.id(),e.isDelta())}function mg(e){return new sg(e.offset(),e.length())}function hg(e){return new cg(e.length(),e.nullCount())}function gg(e){let t=[];for(let n,r=-1,i=-1,a=e.nodesLength();++rzm.encode(e,t));wu.startFieldsVector(e,n.length);let r=wu.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?wu.createCustomMetadataVector(e,[...t.metadata].map(([t,n])=>{let r=e.createString(`${t}`),i=e.createString(`${n}`);return nu.startKeyValue(e),nu.addKey(e,r),nu.addValue(e,i),nu.endKeyValue(e)})):-1;return wu.startSchema(e),wu.addFields(e,r),wu.addEndianness(e,Ag?Ql.Little:Ql.Big),i!==-1&&wu.addCustomMetadata(e,i),wu.endSchema(e)}function Tg(e,t){let n=-1,r=-1,i=-1,a=t.type,o=t.typeId;C.isDictionary(a)?(o=a.dictionary.typeId,i=Uh.visit(a,e),r=Uh.visit(a.dictionary,e)):r=Uh.visit(a,e);let s=(a.children||[]).map(t=>zm.encode(e,t)),c=Cu.createChildrenVector(e,s),l=t.metadata&&t.metadata.size>0?Cu.createCustomMetadataVector(e,[...t.metadata].map(([t,n])=>{let r=e.createString(`${t}`),i=e.createString(`${n}`);return nu.startKeyValue(e),nu.addKey(e,r),nu.addValue(e,i),nu.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),Cu.startField(e),Cu.addType(e,r),Cu.addTypeType(e,o),Cu.addChildren(e,c),Cu.addNullable(e,!!t.nullable),n!==-1&&Cu.addName(e,n),i!==-1&&Cu.addDictionary(e,i),l!==-1&&Cu.addCustomMetadata(e,l),Cu.endField(e)}function Eg(e,t){let n=t.nodes||[],r=t.buffers||[];Xl.startNodesVector(e,n.length);for(let t of n.slice().reverse())cg.encode(e,t);let i=e.endVector();Xl.startBuffersVector(e,r.length);for(let t of r.slice().reverse())sg.encode(e,t);let a=e.endVector();return Xl.startRecordBatch(e),Xl.addLength(e,BigInt(t.length)),Xl.addNodes(e,i),Xl.addBuffers(e,a),Xl.endRecordBatch(e)}function Dg(e,t){let n=ag.encode(e,t.data);return Zl.startDictionaryBatch(e),Zl.addId(e,BigInt(t.id)),Zl.addIsDelta(e,t.isDelta),Zl.addData(e,n),Zl.endDictionaryBatch(e)}function Og(e,t){return Yl.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function kg(e,t){return Jl.createBuffer(e,BigInt(t.offset),BigInt(t.length))}const Ag=(()=>{let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),jg=e=>`Expected ${Tu[e]} Message in stream, but was null or length 0.`,Mg=e=>`Header pointer of flatbuffer-encoded ${Tu[e]} Message is null or length 0.`,Ng=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,Pg=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;var Fg=class{constructor(e){this.source=e instanceof Qm?e:new Qm(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?qm: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(jg(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array;let t=_l(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(jg(e));return t.value}readSchema(){let e=Tu.Schema,t=this.readMessage(e),n=t?.header();if(!t||!n)throw Error(Mg(e));return n}};const Rg=4,zg=new Uint8Array(6);for(let e=0;e<6;e+=1)zg[e]=`ARROW1`.codePointAt(e);function Bg(e,t=0){for(let n=-1,r=zg.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 Tl.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Tl.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:el(t)?i_(t):nl(t)?s_(t):Zc(t)?(()=>y(this,void 0,void 0,function*(){return yield e.from(yield t)}))():rl(t)||ol(t)||cl(t)||$c(t)?o_(new $m(t)):a_(new Qm(t))}static readAll(t){return t instanceof e?t.isSync()?n_(t):r_(t):el(t)||ArrayBuffer.isView(t)||Qc(t)||tl(t)?n_(t):r_(t)}},Gg=class extends Wg{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Bc(this,arguments,function*(){yield b(yield*Vc(Hc(this[Symbol.iterator]())))})}},Kg=class extends Wg{constructor(e){super(e),this._impl=e}readAll(){return y(this,void 0,void 0,function*(){var e,t,n,r;let i=[];try{for(var a=!0,o=Hc(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]()}},qg=class extends Gg{constructor(e){super(e),this._impl=e}},Jg=class extends Kg{constructor(e){super(e),this._impl=e}},Yg=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=k({type:new Id(this.schema.fields),length:e.length,children:n});return new Lh(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 Pm(c)):new Pm(c)).memoize()}_loadVectors(e,t,n){return new uh(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},Xg=class extends Yg{constructor(e,t){super(t),this._reader=el(e)?new Lg(this._handle=e):new Fg(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=t_(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):qm}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):qm}next(){if(this.closed)return qm;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 Bh(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}},Zg=class extends Yg{constructor(e,t){super(t),this._reader=new Ig(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return y(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 y(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=t_(this,e),(this.schema||=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):qm})}return(e){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):qm})}next(){return y(this,void 0,void 0,function*(){if(this.closed)return qm;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 Bh(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return y(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}},Qg=class extends Xg{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 nh?e:new nh(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(Tu.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(Tu.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-Hg,n=e.readInt32(t),r=e.readAt(t-n,n);return Wm.decode(r)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return y(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 y(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(Tu.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 y(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(Tu.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 y(this,void 0,void 0,function*(){let{_handle:e}=this;e._pending&&(yield e._pending);let t=e.size-Hg,n=yield e.readInt32(t),r=yield e.readAt(t-n,n);return Wm.decode(r)})}_readNextMessageAndValidate(e){return y(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?Bg(t)?new qg(new Qg(e.read())):new Gg(new Xg(e)):new Gg(new Xg(function*(){}()))}function o_(e){return y(this,void 0,void 0,function*(){let t=yield e.peek(Vg+7&-8);return t&&t.byteLength>=4?Bg(t)?new qg(new Qg(yield e.read())):new Kg(new Zg(e)):new Kg(new Zg(function(){return Bc(this,arguments,function*(){})}()))})}function s_(e){return y(this,void 0,void 0,function*(){let{size:t}=yield e.stat(),n=new rh(e,t);return t>=Ug&&Bg(yield n.readAt(0,Vg+7&-8))?new Jg(new $g(n)):new Kg(new Zg(n))})}var c_=class e extends w{static assemble(...t){let n=e=>e.flatMap(e=>Array.isArray(e)?n(e):e instanceof Lh?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 Pm)return this.visitMany(e.data),this;let{type:t}=e;if(!C.isDictionary(t)){let{length:n}=e;if(n>2147483647)throw RangeError(`Cannot write arrays larger than 2^31 - 1 in length`);if(C.isUnion(t))this.nodes.push(new cg(n,0));else{let{nullCount:r}=e;C.isNull(t)||l_.call(this,r<=0?new Uint8Array:om(e.offset,n,e.nullBitmap)),this.nodes.push(new cg(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 l_(e){let t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new sg(this._byteLength,t)),this._byteLength+=t,this}function u_(e){var t;let{type:n,length:r,typeIds:i,valueOffsets:a}=e;if(l_.call(this,i),n.mode===Pl.Sparse)return h_.call(this,e);if(n.mode===Pl.Dense){if(e.offset<=0)return l_.call(this,a),h_.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 d_(e){let t;return e.nullCount>=e.length?l_.call(this,new Uint8Array):(t=e.values)instanceof Uint8Array?l_.call(this,om(e.offset,e.length,t)):l_.call(this,sm(e.values))}function f_(e){return l_.call(this,e.values.subarray(0,e.length*e.stride))}function p_(e){let{length:t,values:n,valueOffsets:r}=e,i=Ou(r[0]),a=Ou(r[t]),o=Math.min(a-i,n.byteLength-i);return l_.call(this,Cl(-i,t+1,r)),l_.call(this,n.subarray(i,i+o)),this}function m_(e){let{length:t,valueOffsets:n}=e;if(n){let{0:r,[t]:i}=n;return l_.call(this,Cl(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function h_(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}c_.prototype.visitBool=d_,c_.prototype.visitInt=f_,c_.prototype.visitFloat=f_,c_.prototype.visitUtf8=p_,c_.prototype.visitLargeUtf8=p_,c_.prototype.visitBinary=p_,c_.prototype.visitLargeBinary=p_,c_.prototype.visitFixedSizeBinary=f_,c_.prototype.visitDate=f_,c_.prototype.visitTimestamp=f_,c_.prototype.visitTime=f_,c_.prototype.visitDecimal=f_,c_.prototype.visitList=m_,c_.prototype.visitStruct=h_,c_.prototype.visitUnion=u_,c_.prototype.visitInterval=f_,c_.prototype.visitDuration=f_,c_.prototype.visitFixedSizeList=m_,c_.prototype.visitMap=m_;var g_=class extends Ym{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 Zm,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Xc(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 Zc(e)?e.then(e=>this.writeAll(e)):$c(e)?b_(this,e):y_(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 Zm?this._sink=e:(this._sink=new Zm,e&&al(e)?this.toDOMStream({type:`bytes`}).pipeTo(e):e&&sl(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||!Ah(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 Fh&&!(t=e.schema)||e instanceof Lh&&!(t=e.schema))return this.finish()&&void 0}else throw Error(`RecordBatchWriter is closed`);if(t&&!Ah(t,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,t)}e instanceof Lh?e instanceof Bh||this._writeRecordBatch(e):e instanceof Fh?this.writeAll(e.batches):Qc(e)&&this.writeAll(e)}_writeMessage(e,t=8){let n=t-1,r=ig.encode(e),i=r.byteLength,a=this._writeLegacyIpcFormat?4:8,o=i+a+n&~n,s=o-i-a;return e.headerType===Tu.RecordBatch?this._recordBatchBlocks.push(new Km(o,e.bodyLength,this._position)):e.headerType===Tu.DictionaryBatch&&this._dictionaryBlocks.push(new Km(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=_l(e);t&&t.byteLength>0&&(this._sink.write(t),this._position+=t.byteLength)}return this}_writeSchema(e){return this._writeMessage(ig.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(zg)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:t,nodes:n,bufferRegions:r,buffers:i}=c_.assemble(e),a=new ag(e.numRows,n,r),o=ig.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}=c_.assemble(new Pm([e])),s=new ag(e.length,i,a),c=new og(s,t,n),l=ig.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)):$c(t)?b_(r,t):y_(r,t)}},v_=class e extends g_{static writeAll(t){let n=new e;return Zc(t)?t.then(e=>n.writeAll(e)):$c(t)?b_(n,t):y_(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=Wm.encode(new Wm(e,Nl.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(t)._write(Int32Array.of(t.byteLength))._writeMagic()}};function y_(e,t){let n=t;t instanceof Fh&&(n=t.batches,e.reset(void 0,t.schema));for(let t of n)e.write(t);return e.finish()}function b_(e,t){return y(this,void 0,void 0,function*(){var n,r,i,a,o,s,c;try{for(n=!0,r=Hc(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 x_(e,t=`stream`){return(t===`stream`?__:v_).writeAll(e).toUint8Array(!0)}var S_=Object.create,C_=Object.defineProperty,w_=Object.getOwnPropertyDescriptor,T_=Object.getOwnPropertyNames,E_=Object.getPrototypeOf,D_=Object.prototype.hasOwnProperty,O_=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),k_=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of T_(t))!D_.call(e,i)&&i!==n&&C_(e,i,{get:()=>t[i],enumerable:!(r=w_(t,i))||r.enumerable});return e},A_=(e,t,n)=>(n=e==null?{}:S_(E_(e)),k_(t||!e||!e.__esModule?C_(n,`default`,{value:e,enumerable:!0}):n,e)),j_=O_((e,t)=>{t.exports=Worker}),M_=(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))(M_||{}),N_=(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))(N_||{}),P_=(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))(P_||{}),F_=(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))(F_||{}),I_=(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))(I_||{}),L_=(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))(L_||{}),R_=class{log(e){}},z_=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}},B_=(e=>(e[e.SUCCESS=0]=`SUCCESS`,e))(B_||{}),V_=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=Wg.from(t);return console.assert(n.isSync(),`Reader is not sync`),console.assert(n.isFile(),`Reader is not file`),new Fh(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 H_(this._bindings,this._conn,n),i=await Wg.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 U_(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=x_(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)}},H_=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}},U_=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=Wg.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new Fh(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new H_(this.bindings,this.connectionId,t),r=await Wg.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},W_=(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))(W_||{}),G_=(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))(G_||{}),K_=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 q_(e){switch(e.typeId){case S.Binary:return{sqlType:`binary`};case S.Bool:return{sqlType:`bool`};case S.Date:return{sqlType:`date`};case S.DateDay:return{sqlType:`date32[d]`};case S.DateMillisecond:return{sqlType:`date64[ms]`};case S.Decimal:{let t=e;return{sqlType:`decimal`,precision:t.precision,scale:t.scale}}case S.Float:return{sqlType:`float`};case S.Float16:return{sqlType:`float16`};case S.Float32:return{sqlType:`float32`};case S.Float64:return{sqlType:`float64`};case S.Int:return{sqlType:`int32`};case S.Int16:return{sqlType:`int16`};case S.Int32:return{sqlType:`int32`};case S.Int64:return{sqlType:`int64`};case S.Uint16:return{sqlType:`uint16`};case S.Uint32:return{sqlType:`uint32`};case S.Uint64:return{sqlType:`uint64`};case S.Uint8:return{sqlType:`uint8`};case S.IntervalDayTime:return{sqlType:`interval[dt]`};case S.IntervalYearMonth:return{sqlType:`interval[m]`};case S.List:return{sqlType:`list`,valueType:q_(e.valueType)};case S.FixedSizeBinary:return{sqlType:`fixedsizebinary`,byteWidth:e.byteWidth};case S.Null:return{sqlType:`null`};case S.Utf8:return{sqlType:`utf8`};case S.Struct:return{sqlType:`struct`,fields:e.children.map(e=>J_(e.name,e.type))};case S.Map:{let t=e;return{sqlType:`map`,keyType:q_(t.keyType),valueType:q_(t.valueType)}}case S.Time:return{sqlType:`time[s]`};case S.TimeMicrosecond:return{sqlType:`time[us]`};case S.TimeMillisecond:return{sqlType:`time[ms]`};case S.TimeNanosecond:return{sqlType:`time[ns]`};case S.TimeSecond:return{sqlType:`time[s]`};case S.Timestamp:return{sqlType:`timestamp`,timezone:e.timezone||void 0};case S.TimestampSecond:return{sqlType:`timestamp[s]`,timezone:e.timezone||void 0};case S.TimestampMicrosecond:return{sqlType:`timestamp[us]`,timezone:e.timezone||void 0};case S.TimestampNanosecond:return{sqlType:`timestamp[ns]`,timezone:e.timezone||void 0};case S.TimestampMillisecond:return{sqlType:`timestamp[ms]`,timezone:e.timezone||void 0}}throw Error(`unsupported arrow type: ${e.toString()}`)}function J_(e,t){let n=q_(t);return n.name=e,n}var Y_=new TextEncoder,X_=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 K_(`RESET`,null);return await this.postTask(e)}async ping(){let e=new K_(`PING`,null);await this.postTask(e)}async dropFile(e){let t=new K_(`DROP_FILE`,e);return await this.postTask(t)}async dropFiles(){let e=new K_(`DROP_FILES`,null);return await this.postTask(e)}async flushFiles(){let e=new K_(`FLUSH_FILES`,null);return await this.postTask(e)}async instantiate(e,t=null,n=e=>{}){this._onInstantiationProgress.push(n);let r=new K_(`INSTANTIATE`,[e,t]);return await this.postTask(r)}async getVersion(){let e=new K_(`GET_VERSION`,null);return await this.postTask(e)}async getFeatureFlags(){let e=new K_(`GET_FEATURE_FLAGS`,null);return await this.postTask(e)}async open(e){let t=new K_(`OPEN`,e);await this.postTask(t)}async tokenize(e){let t=new K_(`TOKENIZE`,e);return await this.postTask(t)}async connectInternal(){let e=new K_(`CONNECT`,null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new V_(this,e)}async disconnect(e){let t=new K_(`DISCONNECT`,e);await this.postTask(t)}async runQuery(e,t){let n=new K_(`RUN_QUERY`,[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){let r=new K_(`START_PENDING_QUERY`,[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new K_(`POLL_PENDING_QUERY`,e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new K_(`CANCEL_PENDING_QUERY`,e);return await this.postTask(t)}async fetchQueryResults(e){let t=new K_(`FETCH_QUERY_RESULTS`,e);return await this.postTask(t)}async getTableNames(e,t){let n=new K_(`GET_TABLE_NAMES`,[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new K_(`CREATE_PREPARED`,[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new K_(`CLOSE_PREPARED`,[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new K_(`RUN_PREPARED`,[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new K_(`SEND_PREPARED`,[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new K_(`GLOB_FILE_INFOS`,e);return await this.postTask(t)}async registerFileText(e,t){let n=Y_.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new K_(`REGISTER_FILE_URL`,[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new K_(`REGISTER_FILE_BUFFER`,[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new K_(`REGISTER_FILE_HANDLE`,[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new K_(`REGISTER_OPFS_FILE_NAME`,[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new K_(`COLLECT_FILE_STATISTICS`,[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new K_(`EXPORT_FILE_STATISTICS`,e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new K_(`COPY_FILE_TO_BUFFER`,e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new K_(`COPY_FILE_TO_PATH`,[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new K_(`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(J_(t,r))}n.columnsFlat=e,delete n.columns}let r=new K_(`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(J_(t,r))}n.columnsFlat=e,delete n.columns}let r=new K_(`IMPORT_JSON_FROM_PATH`,[e,t,n]);await this.postTask(r)}};function Z_(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<`u`&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}Z_();var Q_=(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))(Q_||{}),$_=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])),ev=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])),tv=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])),nv=()=>(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])),rv={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`}}};rv.name,rv.version;var iv=rv.version.split(`.`);iv[0],iv[1],iv[2];var av=()=>typeof navigator>`u`,ov=null,sv=null,cv=null,lv=null,uv=null;async function dv(){return ov??=typeof BigInt64Array<`u`,sv??=await ev(),cv??=await nv(),lv??=await tv(),uv??=await $_(),{bigInt64Array:ov,crossOriginIsolated:av()||globalThis.crossOriginIsolated||!1,wasmExceptions:sv,wasmSIMD:lv,wasmThreads:cv,wasmBulkMemory:uv}}async function fv(e){let t=await dv();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}}A_(j_());const pv={},mv={};function hv(e,t){try{let n=pv[e]||=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`longOffset`}).format,r=n(t).split(`GMT`)[1];return r in mv?mv[r]:_v(r,r.split(`:`))}catch{if(e in mv)return mv[e];let t=e?.match(gv);return t?_v(e,t.slice(1)):NaN}}const gv=/([+-]\d\d):?(\d\d)?/;function _v(e,t){let n=+(t[0]||0),r=+(t[1]||0),i=(t[2]||0)/60;return mv[e]=n*60+r>0?n*60+r+i:n*60-r-i}var vv=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(hv(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)),Sv(this,NaN),bv(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=-hv(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),bv(this),+this}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}};const yv=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!yv.test(e))return;let t=e.replace(yv,`$1UTC`);vv.prototype[t]&&(e.startsWith(`get`)?vv.prototype[e]=function(){return this.internal[t]()}:(vv.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),xv(this),+this},vv.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),bv(this),+this}))});function bv(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-hv(e.timeZone,e)*60))}function xv(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()),Sv(e)}function Sv(e){let t=hv(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(-(hv(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 f=hv(e.timeZone,e),p=f>0?Math.floor(f):Math.ceil(f),m=-new Date(+e).getTimezoneOffset(),h=m-p,ee=p!==n,te=h-c;if(ee&&te){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+te);let t=hv(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=p-n;r&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+r),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+r))}}const Cv=new TextDecoder(`utf-8`),wv=e=>Cv.decode(e),Tv=new TextEncoder,Ev=e=>Tv.encode(e),Dv=e=>typeof e==`function`,Ov=e=>e!=null&&Object(e)===e,kv=e=>Ov(e)&&Dv(e.then),Av=e=>Ov(e)&&Dv(e[Symbol.iterator]),jv=e=>Ov(e)&&Dv(e[Symbol.asyncIterator]),Mv=e=>Ov(e)&&`done`in e&&`value`in e,Nv=e=>Ov(e)&&Dv(e.clear)&&Dv(e.bytes)&&Dv(e.position)&&Dv(e.setPosition)&&Dv(e.capacity)&&Dv(e.getBufferIdentifier)&&Dv(e.createLong);var Pv={};An(Pv,{compareArrayLike:()=>yy,joinUint8Arrays:()=>Rv,memcpy:()=>Lv,rebaseValueOffsets:()=>vy,toArrayBufferView:()=>zv,toArrayBufferViewAsyncIterator:()=>cy,toArrayBufferViewIterator:()=>Qv,toBigInt64Array:()=>Uv,toBigUint64Array:()=>qv,toFloat32Array:()=>Jv,toFloat32ArrayAsyncIterator:()=>hy,toFloat32ArrayIterator:()=>ay,toFloat64Array:()=>Yv,toFloat64ArrayAsyncIterator:()=>gy,toFloat64ArrayIterator:()=>oy,toInt16Array:()=>Vv,toInt16ArrayAsyncIterator:()=>uy,toInt16ArrayIterator:()=>ey,toInt32Array:()=>Hv,toInt32ArrayAsyncIterator:()=>dy,toInt32ArrayIterator:()=>ty,toInt8Array:()=>Bv,toInt8ArrayAsyncIterator:()=>ly,toInt8ArrayIterator:()=>$v,toUint16Array:()=>Gv,toUint16ArrayAsyncIterator:()=>py,toUint16ArrayIterator:()=>ry,toUint32Array:()=>Kv,toUint32ArrayAsyncIterator:()=>my,toUint32ArrayIterator:()=>iy,toUint8Array:()=>Wv,toUint8ArrayAsyncIterator:()=>fy,toUint8ArrayIterator:()=>ny,toUint8ClampedArray:()=>Xv,toUint8ClampedArrayAsyncIterator:()=>_y,toUint8ClampedArrayIterator:()=>sy});const Fv=typeof SharedArrayBuffer<`u`?SharedArrayBuffer:ArrayBuffer;function Iv(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;++czv(Int8Array,e),Vv=e=>zv(Int16Array,e),Hv=e=>zv(Int32Array,e),Uv=e=>zv(BigInt64Array,e),Wv=e=>zv(Uint8Array,e),Gv=e=>zv(Uint16Array,e),Kv=e=>zv(Uint32Array,e),qv=e=>zv(BigUint64Array,e),Jv=e=>zv(Float32Array,e),Yv=e=>zv(Float64Array,e),Xv=e=>zv(Uint8ClampedArray,e),Zv=e=>(e.next(),e);function*Qv(e,t){let n=function*(e){yield e},r=typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Fv?n(t):Av(t)?t:n(t);return yield*Zv((function*(t){let n=null;do n=t.next(yield zv(e,n));while(!n.done)})(r[Symbol.iterator]())),new e}const $v=e=>Qv(Int8Array,e),ey=e=>Qv(Int16Array,e),ty=e=>Qv(Int32Array,e),ny=e=>Qv(Uint8Array,e),ry=e=>Qv(Uint16Array,e),iy=e=>Qv(Uint32Array,e),ay=e=>Qv(Float32Array,e),oy=e=>Qv(Float64Array,e),sy=e=>Qv(Uint8ClampedArray,e);function cy(e,t){return Bc(this,arguments,function*(){if(kv(t))return yield b(yield b(yield*Vc(Hc(cy(e,yield b(t))))));let n=function(e){return Bc(this,arguments,function*(){yield yield b(yield b(e))})},r=function(e){return Bc(this,arguments,function*(){yield b(yield*Vc(Hc(Zv((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 Fv?n(t):Av(t)?r(t):jv(t)?t:n(t);return yield b(yield*Vc(Hc(Zv((function(t){return Bc(this,arguments,function*(){let n=null;do n=yield b(t.next(yield yield b(zv(e,n))));while(!n.done)})})(i[Symbol.asyncIterator]()))))),yield b(new e)})}const ly=e=>cy(Int8Array,e),uy=e=>cy(Int16Array,e),dy=e=>cy(Int32Array,e),fy=e=>cy(Uint8Array,e),py=e=>cy(Uint16Array,e),my=e=>cy(Uint32Array,e),hy=e=>cy(Float32Array,e),gy=e=>cy(Float64Array,e),_y=e=>cy(Uint8ClampedArray,e);function vy(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(++nEy});function Ey(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=>Ey(e))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(e,t)=>typeof t==`bigint`?`${t}`:t)}function Dy(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 Oy(e,t){return Dy(e/t)+Dy(e%t)/Dy(t)}var ky={};An(ky,{BN:()=>Vy,bigNumToBigInt:()=>zy,bigNumToNumber:()=>Ly,bigNumToString:()=>Ry,isArrowBigNumSymbol:()=>Ay});const Ay=Symbol.for(`isArrowBigNum`);function jy(e,...t){return t.length===0?Object.setPrototypeOf(zv(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}jy.prototype[Ay]=!0,jy.prototype.toJSON=function(){return`"${Ry(this)}"`},jy.prototype.valueOf=function(e){return Ly(this,e)},jy.prototype.toString=function(){return Ry(this)},jy.prototype[Symbol.toPrimitive]=function(e=`default`){switch(e){case`number`:return Ly(this);case`string`:return Ry(this);case`default`:return zy(this)}return Ry(this)};function My(...e){return jy.apply(this,e)}function Ny(...e){return jy.apply(this,e)}function Py(...e){return jy.apply(this,e)}Object.setPrototypeOf(My.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(Ny.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(Py.prototype,Object.create(Uint32Array.prototype)),Object.assign(My.prototype,jy.prototype,{constructor:My,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(Ny.prototype,jy.prototype,{constructor:Ny,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(Py.prototype,jy.prototype,{constructor:Py,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Fy=BigInt(4294967296)*BigInt(4294967296),Iy=Fy-BigInt(1);function Ly(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=Dy(n),a=`${r}`.padStart(t,`0`),o=s&&i===0?`-`:``;return+`${o}${i}.${a}`}return Dy(c)}function Ry(e){if(e.byteLength===8){let t=new e.BigIntArray(e.buffer,e.byteOffset,1);return`${t[0]}`}if(!e.signed)return By(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),n=new Int16Array([t.at(-1)])[0];if(n>=0)return By(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 ub=class extends L{constructor(){super(I.Null)}toString(){return`Null`}};Uy=Symbol.toStringTag,ub[Uy]=(e=>e[Symbol.toStringTag]=`Null`)(ub.prototype);var db=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}`}};Wy=Symbol.toStringTag,db[Wy]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]=`Int`))(db.prototype);var fb=class extends db{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},pb=class extends db{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},mb=class extends db{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},hb=class extends db{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},gb=class extends db{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},_b=class extends db{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},vb=class extends db{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},yb=class extends db{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(fb.prototype,`ArrayType`,{value:Int8Array}),Object.defineProperty(pb.prototype,`ArrayType`,{value:Int16Array}),Object.defineProperty(mb.prototype,`ArrayType`,{value:Int32Array}),Object.defineProperty(hb.prototype,`ArrayType`,{value:BigInt64Array}),Object.defineProperty(gb.prototype,`ArrayType`,{value:Uint8Array}),Object.defineProperty(_b.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(vb.prototype,`ArrayType`,{value:Uint32Array}),Object.defineProperty(yb.prototype,`ArrayType`,{value:BigUint64Array});var bb=class extends L{constructor(e){super(I.Float),this.precision=e}get ArrayType(){switch(this.precision){case xy.HALF:return Uint16Array;case xy.SINGLE:return Float32Array;case xy.DOUBLE:return Float64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};Gy=Symbol.toStringTag,bb[Gy]=(e=>(e.precision=null,e[Symbol.toStringTag]=`Float`))(bb.prototype);var xb=class extends bb{constructor(){super(xy.HALF)}},Sb=class extends bb{constructor(){super(xy.SINGLE)}},Cb=class extends bb{constructor(){super(xy.DOUBLE)}};Object.defineProperty(xb.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(Sb.prototype,`ArrayType`,{value:Float32Array}),Object.defineProperty(Cb.prototype,`ArrayType`,{value:Float64Array});var wb=class extends L{constructor(){super(I.Binary)}toString(){return`Binary`}};Ky=Symbol.toStringTag,wb[Ky]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Binary`))(wb.prototype);var Tb=class extends L{constructor(){super(I.LargeBinary)}toString(){return`LargeBinary`}};qy=Symbol.toStringTag,Tb[qy]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeBinary`))(Tb.prototype);var Eb=class extends L{constructor(){super(I.Utf8)}toString(){return`Utf8`}};Jy=Symbol.toStringTag,Eb[Jy]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Utf8`))(Eb.prototype);var Db=class extends L{constructor(){super(I.LargeUtf8)}toString(){return`LargeUtf8`}};Yy=Symbol.toStringTag,Db[Yy]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeUtf8`))(Db.prototype);var Ob=class extends L{constructor(){super(I.Bool)}toString(){return`Bool`}};Xy=Symbol.toStringTag,Ob[Xy]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Bool`))(Ob.prototype);var kb=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}]`}};Zy=Symbol.toStringTag,kb[Zy]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]=`Decimal`))(kb.prototype);var Ab=class extends L{constructor(e){super(I.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${Sy[this.unit]}>`}get ArrayType(){return this.unit===Sy.DAY?Int32Array:BigInt64Array}};Qy=Symbol.toStringTag,Ab[Qy]=(e=>(e.unit=null,e[Symbol.toStringTag]=`Date`))(Ab.prototype);var jb=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`)}};$y=Symbol.toStringTag,jb[$y]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]=`Time`))(jb.prototype);var Mb=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}`:``}>`}};eb=Symbol.toStringTag,Mb[eb]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Timestamp`))(Mb.prototype);var Nb=class extends L{constructor(e){super(I.Interval),this.unit=e}toString(){return`Interval<${Cy[this.unit]}>`}};tb=Symbol.toStringTag,Nb[tb]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]=`Interval`))(Nb.prototype);var Pb=class extends L{constructor(e){super(I.Duration),this.unit=e}toString(){return`Duration<${F[this.unit]}>`}};nb=Symbol.toStringTag,Pb[nb]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Duration`))(Pb.prototype);var Fb=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}};rb=Symbol.toStringTag,Fb[rb]=(e=>(e.children=null,e[Symbol.toStringTag]=`List`))(Fb.prototype);var Ib=class extends L{constructor(e){super(I.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};ib=Symbol.toStringTag,Ib[ib]=(e=>(e.children=null,e[Symbol.toStringTag]=`Struct`))(Ib.prototype);var Lb=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(` | `)}>`}};ab=Symbol.toStringTag,Lb[ab]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]=`Union`))(Lb.prototype);var Rb=class extends L{constructor(e){super(I.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};ob=Symbol.toStringTag,Rb[ob]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`FixedSizeBinary`))(Rb.prototype);var zb=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}>`}};sb=Symbol.toStringTag,zb[sb]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]=`FixedSizeList`))(zb.prototype);var Bb=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(`, `)}}>`}};cb=Symbol.toStringTag,Bb[cb]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]=`Map_`))(Bb.prototype);const Vb=(e=>()=>++e)(-1);var Hb=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?Vb():Dy(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}>`}};lb=Symbol.toStringTag,Hb[lb]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]=`Dictionary`))(Hb.prototype);function Ub(e){let t=e;switch(e.typeId){case I.Decimal:return e.bitWidth/32;case I.Interval:return t.unit===Cy.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 Wb(this,e,t)}getVisitFnByTypeId(e,t=!0){return Gb(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 Wb(e,t,n=!0){return typeof t==`number`?Gb(e,t,n):typeof t==`string`&&t in I?Gb(e,I[t],n):t&&t instanceof L?Gb(e,Kb(t),n):t?.type&&t.type instanceof L?Gb(e,Kb(t.type),n):Gb(e,I.NONE,n)}function Gb(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 Kb(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 xy.HALF:return I.Float16;case xy.SINGLE:return I.Float32;case xy.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 Sy.DAY:return I.DateDay;case Sy.MILLISECOND:return I.DateMillisecond}return I.Date;case I.Interval:switch(e.unit){case Cy.DAY_TIME:return I.IntervalDayTime;case Cy.YEAR_MONTH:return I.IntervalYearMonth;case Cy.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 by.Dense:return I.DenseUnion;case by.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 qb={};An(qb,{float64ToUint16:()=>Zb,uint16ToFloat64:()=>Xb});const Jb=new Float64Array(1),Yb=new Uint32Array(Jb.buffer);function Xb(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 Zb(e){if(e!==e)return 32256;Jb[0]=e;let t=(Yb[1]&2147483648)>>16&65535,n=Yb[1]&2146435072,r=0;return n>=1089470464?Yb[0]>0?n=31744:(n=(n&2080374784)>>16,r=(Yb[1]&1048575)>>10):n<=1056964608?(r=1048576+(Yb[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(Yb[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 Qb=(e,t,n)=>{e[t]=Math.floor(n/864e5)},$b=(e,t,n,r)=>{if(n+1{let i=e+n;r?t[i>>3]|=1<>3]&=~(1<{e[t]=n},nx=({values:e},t,n)=>{e[t]=n},rx=({values:e},t,n)=>{e[t]=Zb(n)},ix=(e,t,n)=>{switch(e.type.precision){case xy.HALF:return rx(e,t,n);case xy.SINGLE:case xy.DOUBLE:return nx(e,t,n)}},ax=({values:e},t,n)=>{Qb(e,t,n.valueOf())},ox=({values:e},t,n)=>{e[t]=BigInt(n)},sx=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},cx=({values:e,valueOffsets:t},n,r)=>$b(e,t,n,r),lx=({values:e,valueOffsets:t},n,r)=>$b(e,t,n,Ev(r)),ux=(e,t,n)=>{e.type.unit===Sy.DAY?ax(e,t,n):ox(e,t,n)},dx=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},fx=({values:e},t,n)=>{e[t]=BigInt(n)},px=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},mx=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},hx=(e,t,n)=>{switch(e.type.unit){case F.SECOND:return dx(e,t,n);case F.MILLISECOND:return fx(e,t,n);case F.MICROSECOND:return px(e,t,n);case F.NANOSECOND:return mx(e,t,n)}},gx=({values:e},t,n)=>{e[t]=n},_x=({values:e},t,n)=>{e[t]=n},vx=({values:e},t,n)=>{e[t]=n},yx=({values:e},t,n)=>{e[t]=n},bx=(e,t,n)=>{switch(e.type.unit){case F.SECOND:return gx(e,t,n);case F.MILLISECOND:return _x(e,t,n);case F.MICROSECOND:return vx(e,t,n);case F.NANOSECOND:return yx(e,t,n)}},xx=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},Sx=(e,t,n)=>{let r=e.children[0],i=e.valueOffsets,a=Ux.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=Ux.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},wx=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[a]),Tx=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(a)),Ex=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(i.name)),Dx=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[i.name]),Ox=(e,t,n)=>{let r=e.type.children.map(e=>Ux.getVisitFn(e.type)),i=n instanceof Map?Ex(t,n):n instanceof RC?Tx(t,n):Array.isArray(n)?wx(t,n):Dx(t,n);e.type.children.forEach((t,n)=>i(r[n],e.children[n],t,n))},kx=(e,t,n)=>{e.type.mode===by.Dense?Ax(e,t,n):jx(e,t,n)},Ax=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Ux.visit(i,e.valueOffsets[t],n)},jx=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Ux.visit(i,t,n)},Mx=(e,t,n)=>{var r;(r=e.dictionary)==null||r.set(e.values[t],n)},Nx=(e,t,n)=>{switch(e.type.unit){case Cy.YEAR_MONTH:return Fx(e,t,n);case Cy.DAY_TIME:return Px(e,t,n);case Cy.MONTH_DAY_NANO:return Ix(e,t,n)}},Px=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},Fx=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},Ix=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},Lx=({values:e},t,n)=>{e[t]=n},Rx=({values:e},t,n)=>{e[t]=n},zx=({values:e},t,n)=>{e[t]=n},Bx=({values:e},t,n)=>{e[t]=n},Vx=(e,t,n)=>{switch(e.type.unit){case F.SECOND:return Lx(e,t,n);case F.MILLISECOND:return Rx(e,t,n);case F.MICROSECOND:return zx(e,t,n);case F.NANOSECOND:return Bx(e,t,n)}},Hx=(e,t,n)=>{let{stride:r}=e,i=e.children[0],a=Ux.getVisitFn(i);if(Array.isArray(n))for(let e=-1,o=t*r;++e`${Ey(e)}: ${Ey(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}[Symbol.iterator](){return new qx(this[Wx],this[Gx])}},qx=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[Wx].type.children.some(e=>e.name===t)}getOwnPropertyDescriptor(e,t){if(e[Wx].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[Wx].type.children.findIndex(e=>e.name===t);if(n!==-1){let r=zS.visit(e[Wx].children[n],e[Gx]);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[Wx].type.children.findIndex(e=>e.name===t);return r===-1?Reflect.has(e,t)||typeof t==`symbol`?Reflect.set(e,t,n):!1:(Ux.visit(e[Wx].children[r],e[Gx],n),Reflect.set(e,t,n))}};const Yx=new Jx;var V=class extends R{};function H(e){return(t,n)=>t.getValid(n)?e(t,n):null}const Xx=(e,t)=>864e5*e[t],Zx=(e,t)=>null,Qx=(e,t,n)=>{if(n+1>=t.length)return null;let r=Dy(t[n]),i=Dy(t[n+1]);return e.subarray(r,i)},$x=({offset:e,values:t},n)=>{let r=e+n,i=t[r>>3];return(i&1<Xx(e,t),tS=({values:e},t)=>Dy(e[t]),nS=({stride:e,values:t},n)=>t[e*n],rS=({stride:e,values:t},n)=>Xb(t[e*n]),iS=({values:e},t)=>e[t],aS=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),oS=({values:e,valueOffsets:t},n)=>Qx(e,t,n),sS=({values:e,valueOffsets:t},n)=>{let r=Qx(e,t,n);return r===null?null:wv(r)},cS=({values:e},t)=>e[t],lS=({type:e,values:t},n)=>e.precision===xy.HALF?Xb(t[n]):t[n],uS=(e,t)=>e.type.unit===Sy.DAY?eS(e,t):tS(e,t),dS=({values:e},t)=>1e3*Dy(e[t]),fS=({values:e},t)=>Dy(e[t]),pS=({values:e},t)=>Oy(e[t],BigInt(1e3)),mS=({values:e},t)=>Oy(e[t],BigInt(1e6)),hS=(e,t)=>{switch(e.type.unit){case F.SECOND:return dS(e,t);case F.MILLISECOND:return fS(e,t);case F.MICROSECOND:return pS(e,t);case F.NANOSECOND:return mS(e,t)}},gS=({values:e},t)=>e[t],_S=({values:e},t)=>e[t],vS=({values:e},t)=>e[t],yS=({values:e},t)=>e[t],bS=(e,t)=>{switch(e.type.unit){case F.SECOND:return gS(e,t);case F.MILLISECOND:return _S(e,t);case F.MICROSECOND:return vS(e,t);case F.NANOSECOND:return yS(e,t)}},xS=({values:e,stride:t},n)=>Vy.decimal(e.subarray(t*n,t*(n+1))),SS=(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 RC([c])},CS=(e,t)=>{let{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:a}=n,o=r[0];return new WS(o.slice(i,a-i))},wS=(e,t)=>new Kx(e,t),TS=(e,t)=>e.type.mode===by.Dense?ES(e,t):DS(e,t),ES=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return zS.visit(r,e.valueOffsets[t])},DS=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return zS.visit(r,t)},OS=(e,t)=>{var n;return(n=e.dictionary)?.get(e.values[t])},kS=(e,t)=>e.type.unit===Cy.MONTH_DAY_NANO?MS(e,t):e.type.unit===Cy.DAY_TIME?AS(e,t):jS(e,t),AS=({values:e},t)=>e.subarray(2*t,2*(t+1)),jS=({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},MS=({values:e},t)=>e.subarray(4*t,4*(t+1)),NS=({values:e},t)=>e[t],PS=({values:e},t)=>e[t],FS=({values:e},t)=>e[t],IS=({values:e},t)=>e[t],LS=(e,t)=>{switch(e.type.unit){case F.SECOND:return NS(e,t);case F.MILLISECOND:return PS(e,t);case F.MICROSECOND:return FS(e,t);case F.NANOSECOND:return IS(e,t)}},RS=(e,t)=>{let{stride:n,children:r}=e,i=r[0],a=i.slice(t*n,n);return new RC([a])};V.prototype.visitNull=H(Zx),V.prototype.visitBool=H($x),V.prototype.visitInt=H(cS),V.prototype.visitInt8=H(nS),V.prototype.visitInt16=H(nS),V.prototype.visitInt32=H(nS),V.prototype.visitInt64=H(iS),V.prototype.visitUint8=H(nS),V.prototype.visitUint16=H(nS),V.prototype.visitUint32=H(nS),V.prototype.visitUint64=H(iS),V.prototype.visitFloat=H(lS),V.prototype.visitFloat16=H(rS),V.prototype.visitFloat32=H(nS),V.prototype.visitFloat64=H(nS),V.prototype.visitUtf8=H(sS),V.prototype.visitLargeUtf8=H(sS),V.prototype.visitBinary=H(oS),V.prototype.visitLargeBinary=H(oS),V.prototype.visitFixedSizeBinary=H(aS),V.prototype.visitDate=H(uS),V.prototype.visitDateDay=H(eS),V.prototype.visitDateMillisecond=H(tS),V.prototype.visitTimestamp=H(hS),V.prototype.visitTimestampSecond=H(dS),V.prototype.visitTimestampMillisecond=H(fS),V.prototype.visitTimestampMicrosecond=H(pS),V.prototype.visitTimestampNanosecond=H(mS),V.prototype.visitTime=H(bS),V.prototype.visitTimeSecond=H(gS),V.prototype.visitTimeMillisecond=H(_S),V.prototype.visitTimeMicrosecond=H(vS),V.prototype.visitTimeNanosecond=H(yS),V.prototype.visitDecimal=H(xS),V.prototype.visitList=H(SS),V.prototype.visitStruct=H(wS),V.prototype.visitUnion=H(TS),V.prototype.visitDenseUnion=H(ES),V.prototype.visitSparseUnion=H(DS),V.prototype.visitDictionary=H(OS),V.prototype.visitInterval=H(kS),V.prototype.visitIntervalDayTime=H(AS),V.prototype.visitIntervalYearMonth=H(jS),V.prototype.visitIntervalMonthDayNano=H(MS),V.prototype.visitDuration=H(LS),V.prototype.visitDurationSecond=H(NS),V.prototype.visitDurationMillisecond=H(PS),V.prototype.visitDurationMicrosecond=H(FS),V.prototype.visitDurationNanosecond=H(IS),V.prototype.visitFixedSizeList=H(RS),V.prototype.visitMap=H(CS);const zS=new V,BS=Symbol.for(`keys`),VS=Symbol.for(`vals`),HS=Symbol.for(`kKeysAsStrings`),US=Symbol.for(`_kKeysAsStrings`);var WS=class{constructor(e){return this[BS]=new RC([e.children[0]]).memoize(),this[VS]=e.children[1],new Proxy(this,new KS)}get[HS](){return this[US]||(this[US]=Array.from(this[BS].toArray(),String))}[Symbol.iterator](){return new GS(this[BS],this[VS])}get size(){return this[BS].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[BS],t=this[VS],n={};for(let r=-1,i=e.length;++r`${Ey(e)}: ${Ey(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}},GS=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),zS.visit(this.vals,e)]})}},KS=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[HS]}has(e,t){return e[HS].includes(t)}getOwnPropertyDescriptor(e,t){let n=e[HS].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[HS].indexOf(t);if(n!==-1){let r=zS.visit(Reflect.get(e,VS),n);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[HS].indexOf(t);return r===-1?Reflect.has(e,t)?Reflect.set(e,t,n):!1:(Ux.visit(Reflect.get(e,VS),r,n),Reflect.set(e,t,n))}};Object.defineProperties(WS.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[BS]:{writable:!0,enumerable:!1,configurable:!1,value:null},[VS]:{writable:!0,enumerable:!1,configurable:!1,value:null},[US]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var qS={};An(qS,{clampRange:()=>YS,createElementComparator:()=>QS,wrapIndex:()=>XS});let JS;function YS(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 XS=(e,t)=>e<0?t+e:e,ZS=e=>e!==e;function QS(e){let t=typeof e;if(t!==`object`||e===null)return ZS(e)?ZS: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?yy(e,t):!1:e instanceof Map?eC(e):Array.isArray(e)?$S(e):e instanceof RC?tC(e):nC(e,!0)}function $S(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 iC(e,n);case Map:return oC(e,n,n.keys());case WS:case Kx:case Object:case void 0:return oC(e,n,t||Object.keys(n))}return n instanceof RC?aC(e,n):!1}}function iC(e,t){let n=e.length;if(t.length!==n)return!1;for(let r=-1;++rpC,getBit:()=>lC,getBool:()=>cC,packBools:()=>fC,popcnt_array:()=>hC,popcnt_bit_range:()=>mC,popcnt_uint32:()=>gC,setBool:()=>uC,truncateBitmap:()=>dC});function cC(e,t,n,r){return(n&1<>r}function uC(e,t,n){return n?!!(e[t>>3]|=1<>3]&=~(1<0||n.byteLength>3):fC(new pC(n,e,t,null,cC)).subarray(0,r)),i}return n}function fC(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 pC=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 mC(e,t,i)+mC(e,r,n)+hC(e,i>>3,r-i>>3)}function hC(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+=gC(a.getUint32(i)),i+=4;for(;o-i>=2;)r+=gC(a.getUint16(i)),i+=2;for(;o-i>=1;)r+=gC(a.getUint8(i)),i+=1;return r}function gC(e){let t=Math.trunc(e);return t-=t>>>1&1431655765,t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var _C=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-mC(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=Ub(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===by.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(dC(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(dC(this.offset,t,this.nullBitmap),0);let i=this.buffers;return i[wy.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[wy.TYPE])&&(a[wy.TYPE]=i.subarray(e,e+t)),(i=a[wy.OFFSET])&&(a[wy.OFFSET]=i.subarray(e,e+t+1))||(i=a[wy.DATA])&&(a[wy.DATA]=r===6?i:i.subarray(n*e,n*(e+t))),a}_sliceChildren(e,t,n){return e.map(e=>e.slice(t,n))}};_C.prototype.children=Object.freeze([]);var vC=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 _C(t,n,r,r)}visitBool(e){let{type:t,offset:n=0}=e,r=Wv(e.nullBitmap),i=zv(t.ArrayType,e.data),{length:a=i.length>>3,nullCount:o=e.nullBitmap?-1:0}=e;return new _C(t,n,a,o,[void 0,i,r])}visitInt(e){let{type:t,offset:n=0}=e,r=Wv(e.nullBitmap),i=zv(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new _C(t,n,a,o,[void 0,i,r])}visitFloat(e){let{type:t,offset:n=0}=e,r=Wv(e.nullBitmap),i=zv(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new _C(t,n,a,o,[void 0,i,r])}visitUtf8(e){let{type:t,offset:n=0}=e,r=Wv(e.data),i=Wv(e.nullBitmap),a=Hv(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new _C(t,n,o,s,[a,r,i])}visitLargeUtf8(e){let{type:t,offset:n=0}=e,r=Wv(e.data),i=Wv(e.nullBitmap),a=Uv(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new _C(t,n,o,s,[a,r,i])}visitBinary(e){let{type:t,offset:n=0}=e,r=Wv(e.data),i=Wv(e.nullBitmap),a=Hv(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new _C(t,n,o,s,[a,r,i])}visitLargeBinary(e){let{type:t,offset:n=0}=e,r=Wv(e.data),i=Wv(e.nullBitmap),a=Uv(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new _C(t,n,o,s,[a,r,i])}visitFixedSizeBinary(e){let{type:t,offset:n=0}=e,r=Wv(e.nullBitmap),i=zv(t.ArrayType,e.data),{length:a=i.length/Ub(t),nullCount:o=e.nullBitmap?-1:0}=e;return new _C(t,n,a,o,[void 0,i,r])}visitDate(e){let{type:t,offset:n=0}=e,r=Wv(e.nullBitmap),i=zv(t.ArrayType,e.data),{length:a=i.length/Ub(t),nullCount:o=e.nullBitmap?-1:0}=e;return new _C(t,n,a,o,[void 0,i,r])}visitTimestamp(e){let{type:t,offset:n=0}=e,r=Wv(e.nullBitmap),i=zv(t.ArrayType,e.data),{length:a=i.length/Ub(t),nullCount:o=e.nullBitmap?-1:0}=e;return new _C(t,n,a,o,[void 0,i,r])}visitTime(e){let{type:t,offset:n=0}=e,r=Wv(e.nullBitmap),i=zv(t.ArrayType,e.data),{length:a=i.length/Ub(t),nullCount:o=e.nullBitmap?-1:0}=e;return new _C(t,n,a,o,[void 0,i,r])}visitDecimal(e){let{type:t,offset:n=0}=e,r=Wv(e.nullBitmap),i=zv(t.ArrayType,e.data),{length:a=i.length/Ub(t),nullCount:o=e.nullBitmap?-1:0}=e;return new _C(t,n,a,o,[void 0,i,r])}visitList(e){let{type:t,offset:n=0,child:r}=e,i=Wv(e.nullBitmap),a=Hv(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new _C(t,n,o,s,[a,void 0,i],[r])}visitStruct(e){let{type:t,offset:n=0,children:r=[]}=e,i=Wv(e.nullBitmap),{length:a=r.reduce((e,{length:t})=>Math.max(e,t),0),nullCount:o=e.nullBitmap?-1:0}=e;return new _C(t,n,a,o,[void 0,void 0,i],r)}visitUnion(e){let{type:t,offset:n=0,children:r=[]}=e,i=zv(t.ArrayType,e.typeIds),{length:a=i.length,nullCount:o=-1}=e;if(L.isSparseUnion(t))return new _C(t,n,a,o,[void 0,void 0,void 0,i],r);let s=Hv(e.valueOffsets);return new _C(t,n,a,o,[s,void 0,void 0,i],r)}visitDictionary(t){let{type:n,offset:r=0}=t,i=Wv(t.nullBitmap),a=zv(n.indices.ArrayType,t.data),{dictionary:o=new RC([new e().visit({type:n.dictionary})])}=t,{length:s=a.length,nullCount:c=t.nullBitmap?-1:0}=t;return new _C(n,r,s,c,[void 0,a,i],[],o)}visitInterval(e){let{type:t,offset:n=0}=e,r=Wv(e.nullBitmap),i=zv(t.ArrayType,e.data),{length:a=i.length/Ub(t),nullCount:o=e.nullBitmap?-1:0}=e;return new _C(t,n,a,o,[void 0,i,r])}visitDuration(e){let{type:t,offset:n=0}=e,r=Wv(e.nullBitmap),i=zv(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new _C(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=Wv(t.nullBitmap),{length:o=i.length/Ub(n),nullCount:s=t.nullBitmap?-1:0}=t;return new _C(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=Wv(t.nullBitmap),o=Hv(t.valueOffsets),{length:s=o.length-1,nullCount:c=t.nullBitmap?-1:0}=t;return new _C(n,r,s,c,[o,void 0,a],[i])}};new vC;var yC=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 xC(e){return e.reduce((e,t)=>e+t.nullCount,0)}function SC(e){return e.reduce((e,t,n)=>(e[n+1]=e[n]+t.length,e),new Uint32Array(e.length+1))}function CC(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 wC(e,t,n,r){let i=0,a=0,o=t.length-1;do{if(i>=o-1)return n0?0:-1}function AC(e,t){let{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(let i of new pC(n,e.offset+(t||0),e.length,n,cC)){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 AC(e,n)}let r=zS.getVisitFn(e),i=QS(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 yC(e.data.length,t=>{let r=e.data[t],i=r.length,a=e.slice(n,n+i);return n+=i,new NC(a)})}var NC=class{constructor(e){this.vector=e,this.index=0}next(){return this.indexe.data):t;if(a.length===0||a.some(e=>!(e instanceof _C)))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}=IC[o.typeId],r=a[0];this.isValid=e=>TC(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,LC[o.typeId]),this._offsets=SC(a);break}this.data=a,this.type=o,this.stride=Ub(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 bC(this.data)}get nullCount(){return xC(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(XS(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return PC.visit(this)}concat(...t){return new e(this.data.concat(t.flatMap(e=>e.data).flat(1/0)))}slice(t,n){return new e(YS(this,t,n,({data:e,_offsets:t},n,r)=>CC(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 zC(this.data[0].dictionary),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return new zC(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}};FC=Symbol.toStringTag,RC[FC]=(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=zS.getVisitFnByTypeId(n),r=Ux.getVisitFnByTypeId(n),i=MC.getVisitFnByTypeId(n);IC[n]={get:t,set:r,indexOf:i},LC[n]=Object.create(e,{isValid:{value:EC(TC)},get:{value:EC(zS.getVisitFnByTypeId(n))},set:{value:DC(Ux.getVisitFnByTypeId(n))},indexOf:{value:OC(MC.getVisitFnByTypeId(n))}})}return`Vector`})(RC.prototype);var zC=class e extends RC{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 RC(this.data)}),Object.defineProperty(this,`memoize`,{value:()=>this})}},BC={};An(BC,{BaseInt64:()=>UC,Int128:()=>KC,Int64:()=>GC,Uint64:()=>WC});function VC(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}const HC=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];var UC=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`${VC(this.buffer[3])} ${VC(this.buffer[2])} ${VC(this.buffer[1])} ${VC(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;nJC,toIntervalDayTimeObjects:()=>XC,toIntervalMonthDayNanoInt32Array:()=>YC,toIntervalMonthDayNanoObjects:()=>ZC});function JC(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 XC(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 QC(e,t){return t instanceof e.constructor}function $C(e,t){return e===t||QC(e,t)}function ew(e,t){return e===t||QC(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function tw(e,t){return e===t||QC(e,t)&&e.precision===t.precision}function nw(e,t){return e===t||QC(e,t)&&e.byteWidth===t.byteWidth}function rw(e,t){return e===t||QC(e,t)&&e.unit===t.unit}function iw(e,t){return e===t||QC(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function aw(e,t){return e===t||QC(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function ow(e,t){return e===t||QC(e,t)&&e.children.length===t.children.length&&mw.compareManyFields(e.children,t.children)}function sw(e,t){return e===t||QC(e,t)&&e.children.length===t.children.length&&mw.compareManyFields(e.children,t.children)}function cw(e,t){return e===t||QC(e,t)&&e.mode===t.mode&&e.typeIds.every((e,n)=>e===t.typeIds[n])&&mw.compareManyFields(e.children,t.children)}function lw(e,t){return e===t||QC(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&mw.visit(e.indices,t.indices)&&mw.visit(e.dictionary,t.dictionary)}function uw(e,t){return e===t||QC(e,t)&&e.unit===t.unit}function dw(e,t){return e===t||QC(e,t)&&e.unit===t.unit}function fw(e,t){return e===t||QC(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&mw.compareManyFields(e.children,t.children)}function pw(e,t){return e===t||QC(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&mw.compareManyFields(e.children,t.children)}q.prototype.visitNull=$C,q.prototype.visitBool=$C,q.prototype.visitInt=ew,q.prototype.visitInt8=ew,q.prototype.visitInt16=ew,q.prototype.visitInt32=ew,q.prototype.visitInt64=ew,q.prototype.visitUint8=ew,q.prototype.visitUint16=ew,q.prototype.visitUint32=ew,q.prototype.visitUint64=ew,q.prototype.visitFloat=tw,q.prototype.visitFloat16=tw,q.prototype.visitFloat32=tw,q.prototype.visitFloat64=tw,q.prototype.visitUtf8=$C,q.prototype.visitLargeUtf8=$C,q.prototype.visitBinary=$C,q.prototype.visitLargeBinary=$C,q.prototype.visitFixedSizeBinary=nw,q.prototype.visitDate=rw,q.prototype.visitDateDay=rw,q.prototype.visitDateMillisecond=rw,q.prototype.visitTimestamp=iw,q.prototype.visitTimestampSecond=iw,q.prototype.visitTimestampMillisecond=iw,q.prototype.visitTimestampMicrosecond=iw,q.prototype.visitTimestampNanosecond=iw,q.prototype.visitTime=aw,q.prototype.visitTimeSecond=aw,q.prototype.visitTimeMillisecond=aw,q.prototype.visitTimeMicrosecond=aw,q.prototype.visitTimeNanosecond=aw,q.prototype.visitDecimal=$C,q.prototype.visitList=ow,q.prototype.visitStruct=sw,q.prototype.visitUnion=cw,q.prototype.visitDenseUnion=cw,q.prototype.visitSparseUnion=cw,q.prototype.visitDictionary=lw,q.prototype.visitInterval=uw,q.prototype.visitIntervalDayTime=uw,q.prototype.visitIntervalYearMonth=uw,q.prototype.visitIntervalMonthDayNano=uw,q.prototype.visitDuration=dw,q.prototype.visitDurationSecond=dw,q.prototype.visitDurationMillisecond=dw,q.prototype.visitDurationMicrosecond=dw,q.prototype.visitDurationNanosecond=dw,q.prototype.visitFixedSizeList=fw,q.prototype.visitMap=pw;const mw=new q;function hw(e,t){return mw.compareSchemas(e,t)}function gw(e,t){return mw.compareFields(e,t)}function _w(e,t){return mw.visit(e,t)}const vw=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ky),BC),sC),qb),Pv),qS),Ty),qC),{compareSchemas:hw,compareFields:gw,compareTypes:_w}),yw=6048e5,bw=3600*24;bw*7,bw*365.2425;const xw=Symbol.for(`constructDateFrom`);function Sw(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&xw in e?e[xw](t):e instanceof Date?new e.constructor(t):new Date(t)}function Cw(e,t){return Sw(t||e,e)}let ww={};function Tw(){return ww}function Ew(e,t){let n=Tw(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Cw(e,t?.in),a=i.getDay(),o=(a=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function kw(e){let t=Cw(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 Aw(e,...t){let n=Sw.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function jw(e,t){let n=Cw(e,t?.in);return n.setHours(0,0,0,0),n}function Mw(e,t,n){let[r,i]=Aw(n?.in,e,t),a=jw(r),o=jw(i),s=+a-kw(a),c=+o-kw(o);return Math.round((s-c)/864e5)}function Nw(e,t){let n=Ow(e,t),r=Sw(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),Dw(r)}function Pw(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function Fw(e){return!(!Pw(e)&&typeof e!=`number`||isNaN(+Cw(e)))}function Iw(e,t){let n=Cw(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const Lw={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`}},Rw=(e,t,n)=>{let r,i=Lw[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 zw(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth,r=e.formats[n]||e.formats[e.defaultWidth];return r}}const Bw={full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},Vw={full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},Hw={full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},Uw={date:zw({formats:Bw,defaultWidth:`full`}),time:zw({formats:Vw,defaultWidth:`full`}),dateTime:zw({formats:Hw,defaultWidth:`full`})},Ww={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},Gw=(e,t,n,r)=>Ww[e];function Kw(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 qw={narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},Jw={narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},Yw={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`]},Xw={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`]},Zw={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`}},Qw={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`}},$w=(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`},eT={ordinalNumber:$w,era:Kw({values:qw,defaultWidth:`wide`}),quarter:Kw({values:Jw,defaultWidth:`wide`,argumentCallback:e=>e-1}),month:Kw({values:Yw,defaultWidth:`wide`}),day:Kw({values:Xw,defaultWidth:`wide`}),dayPeriod:Kw({values:Zw,defaultWidth:`wide`,formattingValues:Qw,defaultFormattingWidth:`wide`})};function tT(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)?rT(s,e=>e.test(o)):nT(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 nT(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function rT(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 aT=/^(\d+)(th|st|nd|rd)?/i,oT=/\d+/i,sT={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},cT={any:[/^b/i,/^(a|c)/i]},lT={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},uT={any:[/1/i,/2/i,/3/i,/4/i]},dT={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},fT={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]},pT={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},mT={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]},hT={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},gT={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}},_T={ordinalNumber:iT({matchPattern:aT,parsePattern:oT,valueCallback:e=>parseInt(e,10)}),era:tT({matchPatterns:sT,defaultMatchWidth:`wide`,parsePatterns:cT,defaultParseWidth:`any`}),quarter:tT({matchPatterns:lT,defaultMatchWidth:`wide`,parsePatterns:uT,defaultParseWidth:`any`,valueCallback:e=>e+1}),month:tT({matchPatterns:dT,defaultMatchWidth:`wide`,parsePatterns:fT,defaultParseWidth:`any`}),day:tT({matchPatterns:pT,defaultMatchWidth:`wide`,parsePatterns:mT,defaultParseWidth:`any`}),dayPeriod:tT({matchPatterns:hT,defaultMatchWidth:`any`,parsePatterns:gT,defaultParseWidth:`any`})},vT={code:`en-US`,formatDistance:Rw,formatLong:Uw,formatRelative:Gw,localize:eT,match:_T,options:{weekStartsOn:0,firstWeekContainsDate:1}};function yT(e,t){let n=Cw(e,t?.in),r=Mw(n,Iw(n)),i=r+1;return i}function bT(e,t){let n=Cw(e,t?.in),r=Dw(n)-+Nw(n);return Math.round(r/yw)+1}function xT(e,t){let n=Cw(e,t?.in),r=n.getFullYear(),i=Tw(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=Sw(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=Ew(o,t),c=Sw(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=Ew(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function ST(e,t){let n=Tw(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=xT(e,t),a=Sw(t?.in||e,0);a.setFullYear(i,0,r),a.setHours(0,0,0,0);let o=Ew(a,t);return o}function CT(e,t){let n=Cw(e,t?.in),r=Ew(n,t)-+ST(n,t);return Math.round(r/yw)+1}function wT(e,t){let n=e<0?`-`:``,r=Math.abs(e).toString().padStart(t,`0`);return n+r}const TT={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return wT(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):wT(n+1,2)},d(e,t){return wT(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 wT(e.getHours()%12||12,t.length)},H(e,t){return wT(e.getHours(),t.length)},m(e,t){return wT(e.getMinutes(),t.length)},s(e,t){return wT(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*10**(n-3));return wT(i,t.length)}},ET={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},DT={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 TT.y(e,t)},Y:function(e,t,n,r){let i=xT(e,r),a=i>0?i:1-i;if(t===`YY`){let e=a%100;return wT(e,2)}return t===`Yo`?n.ordinalNumber(a,{unit:`year`}):wT(a,t.length)},R:function(e,t){let n=Ow(e);return wT(n,t.length)},u:function(e,t){let n=e.getFullYear();return wT(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 wT(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 wT(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 TT.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 wT(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=CT(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):wT(i,t.length)},I:function(e,t,n){let r=bT(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):wT(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):TT.d(e,t)},D:function(e,t,n){let r=yT(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):wT(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 wT(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 wT(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 wT(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?ET.noon:r===0?ET.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?ET.evening:r>=12?ET.afternoon:r>=4?ET.morning:ET.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 TT.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):TT.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):wT(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):wT(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):TT.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):TT.s(e,t)},S:function(e,t){return TT.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return kT(r);case`XXXX`:case`XX`:return AT(r);case`XXXXX`:case`XXX`:default:return AT(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return kT(r);case`xxxx`:case`xx`:return AT(r);case`xxxxx`:case`xxx`:default:return AT(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+OT(r,`:`);case`OOOO`:default:return`GMT`+AT(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+OT(r,`:`);case`zzzz`:default:return`GMT`+AT(r,`:`)}},t:function(e,t,n){let r=Math.trunc(e/1e3);return wT(r,t.length)},T:function(e,t,n){return wT(+e,t.length)}};function OT(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+wT(a,2)}function kT(e,t){if(e%60==0){let t=e>0?`-`:`+`;return t+wT(Math.abs(e)/60,2)}return AT(e,t)}function AT(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=wT(Math.trunc(r/60),2),a=wT(r%60,2);return n+i+t+a}const jT=(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`})}},MT=(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`})}},NT=(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return jT(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}}`,jT(r,t)).replace(`{{time}}`,MT(i,t))},PT={p:MT,P:NT},FT=/^D+$/,IT=/^Y+$/,LT=[`D`,`DD`,`YY`,`YYYY`];function RT(e){return FT.test(e)}function zT(e){return IT.test(e)}function BT(e,t,n){let r=VT(e,t,n);if(console.warn(r),LT.includes(e))throw RangeError(r)}function VT(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 HT=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,UT=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,WT=/^'([^]*?)'?$/,GT=/''/g,KT=/[a-zA-Z]/;function qT(e,t,n){let r=Tw(),i=n?.locale??r.locale??vT,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=Cw(e,n?.in);if(!Fw(s))throw RangeError(`Invalid time value`);let c=t.match(UT).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=PT[t];return n(e,i.formatLong)}return e}).join(``).match(HT).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:JT(e)};if(DT[t])return{isToken:!0,value:e};if(t.match(KT))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&&zT(a)||!n?.useAdditionalDayOfYearTokens&&RT(a))&&BT(a,t,String(e));let o=DT[a[0]];return o(s,a,i.localize,l)}).join(``)}function JT(e){let t=e.match(WT);return t?t[1].replace(GT,`'`):e}function YT(e,t){return Cw(e*1e3,t?.in)}function XT(e,t){let n=ZT(t)?new t(0):Sw(t,0);return n.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),n.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),n}function ZT(e){return typeof e==`function`&&e.prototype?.constructor===e}function QT(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 $T(e){return e==null}function eE(e){return e!=null}async function tE(){if(typeof window<`u`&&window!==null)return`browser`;try{let e=await ae(()=>import(`./__vite-browser-external-Bi5T_TG6.js`).then(jn(1)),__vite__mapDeps([0,1,2]));return e!==void 0&&e.versions!=null&&e.versions.node!=null?`node`:`unknown`}catch{return`unknown`}}function nE(e){return $T(e)?!1:L.isInt(e.type)&&!cE(e)||rE(e)}function rE(e){return $T(e)?!1:L.isInt(e.type)&&e.type.isSigned===!1}function iE(e){return $T(e)?!1:L.isFloat(e.type)??!1}function aE(e){return $T(e)?!1:L.isDecimal(e.type)}function oE(e){return $T(e)?!1:L.isBool(e.type)}function sE(e){return $T(e)?!1:L.isDuration(e.type)}function cE(e){return $T(e)?!1:L.isInt(e.type)&&e.metadata.get(`ARROW:extension:name`)===`period`}function lE(e){return $T(e)?!1:L.isTimestamp(e.type)}function uE(e){return $T(e)?!1:L.isDate(e.type)}function dE(e){return $T(e)?!1:L.isTime(e.type)}function fE(e){return $T(e)?!1:L.isList(e.type)||L.isFixedSizeList(e.type)}function pE(e){return $T(e)?!1:L.isStruct(e.type)||L.isMap(e.type)}function mE(e){return $T(e)?!1:L.isStruct(e.type)&&e.metadata.get(`ARROW:extension:name`)===`interval`||L.isInterval(e.type)}function hE(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 gE(e,t){let n=hE(e,t?.type?.unit??F.SECOND);return YT(n)}function _E(e,t){let n=gE(e,t);return qT(n,n.getMilliseconds()===0?`HH:mm:ss`:`HH:mm:ss.SSS`)}function vE(e){return e instanceof Date||typeof e==`number`&&Number.isFinite(e)?qT(e,`yyyy-MM-dd`):(console.warn(`Unsupported date value: ${e}`),String(e))}function yE(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 vv(e,r):new vv(e),XT(n,Date)}function bE(e,t){let n=t?.type?.scale||0,r=vw.bigNumToString(new vw.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=QT(r.slice(-n),`0`)||``;return`${i}${a}${o?`.${o}`:``}`}new Intl.NumberFormat(`en-US`,{style:`decimal`,maximumFractionDigits:4,minimumFractionDigits:4,useGrouping:!0});function xE(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 SE(e,t){if(L.isInterval(t?.type))return xE(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=wE(i.left,t.type?.children?.[0]),c=wE(i.right,t.type?.children?.[1]);return`${a+s}, ${c+o}`}return String(e)}function CE(e,t){return t?.type instanceof Ib?JSON.parse(JSON.stringify(e,(e,t)=>{if(eE(t))return typeof t==`bigint`?Number(t):t})):JSON.parse(JSON.stringify(e,(e,t)=>typeof t==`bigint`?Number(t):t))}function wE(e,t){if($T(e))return null;let n=e instanceof Date||Number.isFinite(e);if(n&&uE(t))return vE(e);if(typeof e==`bigint`&&dE(t))return _E(Number(e),t);if(n&&lE(t))return yE(e,t);if(cE(t))throw Error(`Period type is not supported yet`);if(mE(t))return SE(e,t);if(sE(t))throw Error(`Duration type is not supported yet`);return aE(t)?bE(e,t):iE(t)&&Number.isFinite(e)||nE(t)?e:pE(t)||fE(t)?CE(e,t):oE(t)?!!e:String(e)}function TE(e){let t=(e.toArray()||[]).map(e=>e.toJSON())||[],n=t.map(t=>(e.schema.fields.forEach(e=>t[e.name]=wE(t[e.name],e)),t));return n}let EE=function(e){return e.ORIGIN_PRIVATE_FS=`origin-private-fs`,e.NODE_FS=`node-fs`,e}({});async function DE(e){let t=ze(e,{logger:!1}),n,r,i=await tE();if(i===`browser`){if(t.bundles===void 0){let{getBundles:e}=await ae(async()=>{let{getBundles:e}=await import(`./default-browser-DPbB-j00.js`);return{getBundles:e}},[]);t.bundles=await e()}r=await fv(await t.bundles),n=new Worker(r.mainWorker)}else if(i===`node`){if(t.bundles===void 0){let{getBundles:e}=await ae(async()=>{let{getBundles:e}=await import(`./default-node-DcE314Tg.js`);return{getBundles:e}},__vite__mapDeps([3,1,2]));t.bundles=await e()}r=await fv(await t.bundles);let e=r.mainWorker;e.startsWith(`/@fs/`)&&(e=e.replace(`/@fs/`,`file://`));let i=await ae(()=>import(`./browser-D5yVpD38.js`),[]);n=new i.default(e,{type:`module`})}else throw Error(`Unsupported environment: ${i}`);let a;a=t.logger===!0?new z_:t.logger===!1?new R_:t.logger;let o=new X_(a,n);if(await o.instantiate(r.mainModule,r.pthreadWorker),t.storage)switch(t.storage.type){case EE.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 EE.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:TE(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:TE(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 OE(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 kE(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 J=Symbol.for(`drizzle:entityKind`);function Y(e,t){if(!e||typeof e!=`object`)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,J))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(J in n&&n[J]===t[J])return!0;n=Object.getPrototypeOf(n)}return!1}var AE=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[J]=`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`}},jE=class{static[J]=`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 ME=Symbol.for(`drizzle:Name`);var NE=class{static[J]=`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 PE(e,this)}},PE=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[J]=`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[ME],...r,n[0].table[ME],...i];return e??`${a.join(`_`)}_fk`}};function FE(e,...t){return e(...t)}function IE(e,t){return`${e[ME]}_${t.join(`_`)}_unique`}function LE(e,t,n){for(let r=t;rArray.isArray(e)?BE(e):typeof e==`string`?`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`:`${e}`).join(`,`)}}`}var VE=class extends jE{foreignKeyConfigs=[];static[J]=`PgColumnBuilder`;array(e){return new WE(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})=>FE((n,r)=>{let i=new NE(()=>{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 UE(e,this.config)}},HE=class extends AE{constructor(e,t){t.uniqueName||=IE(e,[t.name]),super(e,t),this.table=e}static[J]=`PgColumn`},UE=class extends HE{static[J]=`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}},WE=class extends VE{static[J]=`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 GE(e,this.config,t)}},GE=class e extends HE{constructor(e,t,n,r){super(e,t),this.baseColumn=n,this.range=r,this.size=t.size}size;static[J]=`PgArray`;getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==`number`?this.size:``}]`}mapFromDriverValue(e){return typeof e==`string`&&(e=zE(e)),e.map(e=>this.baseColumn.mapFromDriverValue(e))}mapToDriverValue(t,n=!1){let r=t.map(t=>t===null?null:Y(this.baseColumn,e)?this.baseColumn.mapToDriverValue(t,!0):this.baseColumn.mapToDriverValue(t));return n?r:BE(r)}};const KE=Symbol.for(`drizzle:isPgEnum`);function qE(e){return!!e&&typeof e==`function`&&KE in e&&e[KE]===!0}var JE=class{static[J]=`Subquery`;constructor(e,t,n,r=!1,i=[]){this._={brand:`Subquery`,sql:e,selectedFields:t,alias:n,isWith:r,usedTables:i}}},YE=class extends JE{static[J]=`WithSubquery`};const XE={startActiveSpan(e,t){return t()}},ZE=Symbol.for(`drizzle:ViewBaseConfig`),QE=Symbol.for(`drizzle:Schema`),$E=Symbol.for(`drizzle:Columns`),eD=Symbol.for(`drizzle:ExtraConfigColumns`),tD=Symbol.for(`drizzle:OriginalName`),nD=Symbol.for(`drizzle:BaseName`),rD=Symbol.for(`drizzle:IsAlias`),iD=Symbol.for(`drizzle:ExtraConfigBuilder`),aD=Symbol.for(`drizzle:IsDrizzleTable`);var X=class{static[J]=`Table`;static Symbol={Name:ME,Schema:QE,OriginalName:tD,Columns:$E,ExtraConfigColumns:eD,BaseName:nD,IsAlias:rD,ExtraConfigBuilder:iD};[ME];[tD];[QE];[$E];[eD];[nD];[rD]=!1;[aD]=!0;[iD]=void 0;constructor(e,t,n){this[ME]=this[tD]=e,this[QE]=t,this[nD]=n}};function oD(e){return e[ME]}function sD(e){return`${e[QE]??`public`}.${e[ME]}`}function cD(e){return e!=null&&typeof e.getSQL==`function`}function lD(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 uD=class{static[J]=`StringChunk`;value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new Z([this])}},Z=class e{constructor(e){this.queryChunks=e;for(let t of e)if(Y(t,X)){let e=t[X.Symbol.Schema];this.usedTables.push(e===void 0?t[X.Symbol.Name]:e+`.`+t[X.Symbol.Name])}}static[J]=`SQL`;decoder=pD;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return XE.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 lD(t.map(t=>{if(Y(t,uD))return{sql:t.value.join(``),params:[]};if(Y(t,dD))return{sql:a(t.value),params:[]};if(t===void 0)return{sql:``,params:[]};if(Array.isArray(t)){let e=[new uD(`(`)];for(let[n,r]of t.entries())e.push(r),ne},mD={mapToDriverValue:e=>e};({...pD,...mD});var hD=class{constructor(e,t=mD){this.value=e,this.encoder=t}static[J]=`Param`;brand;getSQL(){return new Z([this])}};function Q(e,...t){let n=[];(t.length>0||e.length>0&&e[0]!==``)&&n.push(new uD(e[0]));for(let[r,i]of t.entries())n.push(i,new uD(e[r+1]));return new Z(n)}(e=>{function t(){return new Z([])}e.empty=t;function n(e){return new Z(e)}e.fromList=n;function r(e){return new Z([new uD(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 Z(n)}e.join=i;function a(e){return new dD(e)}e.identifier=a;function o(e){return new gD(e)}e.placeholder=o;function s(e,t){return new hD(e,t)}e.param=s})(Q||={}),(e=>{class t{constructor(e,t){this.sql=e,this.fieldAlias=t}static[J]=`SQL.Aliased`;isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(Z||={});var gD=class{constructor(e){this.name=e}static[J]=`Placeholder`;getSQL(){return new Z([this])}};function _D(e,t){return e.map(e=>{if(Y(e,gD)){if(!(e.name in t))throw Error(`No value for placeholder "${e.name}" was provided`);return t[e.name]}if(Y(e,hD)&&Y(e.value,gD)){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 vD=Symbol.for(`drizzle:IsDrizzleView`);var yD=class{static[J]=`View`;[ZE];[vD]=!0;constructor({name:e,schema:t,selectedFields:n,query:r}){this[ZE]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new Z([this])}};AE.prototype.getSQL=function(){return new Z([this])},X.prototype.getSQL=function(){return new Z([this])},JE.prototype.getSQL=function(){return new Z([this])};var bD=class{constructor(e){this.table=e}static[J]=`ColumnAliasProxyHandler`;get(e,t){return t===`table`?this.table:e[t]}},xD=class{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static[J]=`TableAliasProxyHandler`;get(e,t){if(t===X.Symbol.IsAlias)return!0;if(t===X.Symbol.Name||this.replaceOriginalName&&t===X.Symbol.OriginalName)return this.alias;if(t===ZE)return{...e[ZE],name:this.alias,isAlias:!0};if(t===X.Symbol.Columns){let t=e[X.Symbol.Columns];if(!t)return t;let n={};return Object.keys(t).map(r=>{n[r]=new Proxy(t[r],new bD(new Proxy(e,this)))}),n}let n=e[t];return Y(n,AE)?new Proxy(n,new bD(new Proxy(e,this))):n}};function SD(e,t){return new Proxy(e,new xD(t,!1))}function CD(e,t){return new Proxy(e,new bD(new Proxy(e.table,new xD(t,!1))))}function wD(e,t){return new Z.Aliased(TD(e.sql,t),e.fieldAlias)}function TD(e,t){return Q.join(e.queryChunks.map(e=>Y(e,AE)?CD(e,t):Y(e,Z)?TD(e,t):Y(e,Z.Aliased)?wD(e,t):e))}var ED=class extends Error{static[J]=`DrizzleError`;constructor({message:e,cause:t}){super(e),this.name=`DrizzleError`,this.cause=t}},DD=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)}},OD=class extends ED{static[J]=`TransactionRollbackError`;constructor(){super({message:`Rollback`})}},kD=class{static[J]=`ConsoleLogWriter`;write(e){console.log(e)}},AD=class{static[J]=`DefaultLogger`;writer;constructor(e){this.writer=e?.writer??new kD}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}`)}},jD=class{static[J]=`NoopLogger`;logQuery(){}},MD=class{static[J]=`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 ND(e,t){return Object.entries(e).reduce((e,[n,r])=>{if(typeof n!=`string`)return e;let i=t?[...t,n]:[n];return Y(r,AE)||Y(r,Z)||Y(r,Z.Aliased)?e.push({path:i,field:r}):Y(r,X)?e.push(...ND(r[X.Symbol.Columns],i)):e.push(...ND(r,i)),e},[])}function PD(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 FD(e,t){let n=Object.entries(t).filter(([,e])=>e!==void 0).map(([t,n])=>Y(n,Z)||Y(n,AE)?[t,n]:[t,new hD(n,e[X.Symbol.Columns][t])]);if(n.length===0)throw Error(`No values to set`);return Object.fromEntries(n)}function ID(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 LD(e){return e[X.Symbol.Columns]}function RD(e){return Y(e,JE)?e._.alias:Y(e,yD)?e[ZE].name:Y(e,Z)?void 0:e[X.Symbol.IsAlias]?e[X.Symbol.Name]:e[X.Symbol.BaseName]}function zD(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 BD=class extends HE{static[J]=`PgDate`;getSQLType(){return`date`}mapFromDriverValue(e){return new Date(e)}mapToDriverValue(e){return e.toISOString()}},VD=class extends HE{static[J]=`PgDateString`;getSQLType(){return`date`}},HD=class extends HE{static[J]=`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}},UD=class extends HE{static[J]=`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}},WD=class extends HE{static[J]=`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})`}},GD=class extends HE{static[J]=`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`:``}`}},KD=class extends HE{static[J]=`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()},qD=class extends HE{static[J]=`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`:``}`}},JD=class extends HE{static[J]=`PgUUID`;getSQLType(){return`uuid`}};const YD=Symbol.for(`drizzle:PgInlineForeignKeys`),XD=Symbol.for(`drizzle:EnableRLS`);var ZD=class extends X{static[J]=`PgTable`;static Symbol=Object.assign({},X.Symbol,{InlineForeignKeys:YD,EnableRLS:XD});[YD]=[];[XD]=!1;[X.Symbol.ExtraConfigBuilder]=void 0;[X.Symbol.ExtraConfigColumns]={}},QD=class{static[J]=`PgPrimaryKeyBuilder`;columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new $D(e,this.columns,this.name)}},$D=class{constructor(e,t,n){this.table=e,this.columns=t,this.name=n}static[J]=`PgPrimaryKey`;columns;name;getName(){return this.name??`${this.table[ZD.Symbol.Name]}_${this.columns.map(e=>e.name).join(`_`)}_pk`}};function eO(e,t){return fD(t)&&!cD(e)&&!Y(e,hD)&&!Y(e,gD)&&!Y(e,AE)&&!Y(e,X)&&!Y(e,yD)?new hD(e,t):e}const tO=(e,t)=>Q`${e} = ${eO(t,e)}`,nO=(e,t)=>Q`${e} <> ${eO(t,e)}`;function rO(...e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new Z(t):new Z([new uD(`(`),Q.join(t,new uD(` and `)),new uD(`)`)])}function iO(...e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new Z(t):new Z([new uD(`(`),Q.join(t,new uD(` or `)),new uD(`)`)])}function aO(e){return Q`not ${e}`}const oO=(e,t)=>Q`${e} > ${eO(t,e)}`,sO=(e,t)=>Q`${e} >= ${eO(t,e)}`,cO=(e,t)=>Q`${e} < ${eO(t,e)}`,lO=(e,t)=>Q`${e} <= ${eO(t,e)}`;function uO(e,t){return Array.isArray(t)?t.length===0?Q`false`:Q`${e} in ${t.map(t=>eO(t,e))}`:Q`${e} in ${eO(t,e)}`}function dO(e,t){return Array.isArray(t)?t.length===0?Q`true`:Q`${e} not in ${t.map(t=>eO(t,e))}`:Q`${e} not in ${eO(t,e)}`}function fO(e){return Q`${e} is null`}function pO(e){return Q`${e} is not null`}function mO(e){return Q`exists ${e}`}function hO(e){return Q`not exists ${e}`}function gO(e,t,n){return Q`${e} between ${eO(t,e)} and ${eO(n,e)}`}function _O(e,t,n){return Q`${e} not between ${eO(t,e)} and ${eO(n,e)}`}function vO(e,t){return Q`${e} like ${t}`}function yO(e,t){return Q`${e} not like ${t}`}function bO(e,t){return Q`${e} ilike ${t}`}function xO(e,t){return Q`${e} not ilike ${t}`}function SO(e){return Q`${e} asc`}function CO(e){return Q`${e} desc`}var wO=class{constructor(e,t,n){this.sourceTable=e,this.referencedTable=t,this.relationName=n,this.referencedTableName=t[X.Symbol.Name]}static[J]=`Relation`;referencedTableName;fieldName},TO=class{constructor(e,t){this.table=e,this.config=t}static[J]=`Relations`},EO=class e extends wO{constructor(e,t,n,r){super(e,t,n?.relationName),this.config=n,this.isNullable=r}static[J]=`One`;withFieldName(t){let n=new e(this.sourceTable,this.referencedTable,this.config,this.isNullable);return n.fieldName=t,n}},DO=class e extends wO{constructor(e,t,n){super(e,t,n?.relationName),this.config=n}static[J]=`Many`;withFieldName(t){let n=new e(this.sourceTable,this.referencedTable,this.config);return n.fieldName=t,n}};function OO(){return{and:rO,between:gO,eq:tO,exists:mO,gt:oO,gte:sO,ilike:bO,inArray:uO,isNull:fO,isNotNull:pO,like:vO,lt:cO,lte:lO,ne:nO,not:aO,notBetween:_O,notExists:hO,notLike:yO,notIlike:xO,notInArray:dO,or:iO,sql:Q}}function kO(){return{sql:Q,asc:SO,desc:CO}}function AO(e,t){Object.keys(e).length===1&&`default`in e&&!Y(e.default,X)&&(e=e.default);let n={},r={},i={};for(let[a,o]of Object.entries(e))if(Y(o,X)){let e=sD(o),t=r[e];n[e]=a,i[a]={tsName:a,dbName:o[X.Symbol.Name],schema:o[X.Symbol.Schema],columns:o[X.Symbol.Columns],relations:t?.relations??{},primaryKey:t?.primaryKey??[]};for(let e of Object.values(o[X.Symbol.Columns]))e.primary&&i[a].primaryKey.push(e);let s=o[X.Symbol.ExtraConfigBuilder]?.(o[X.Symbol.ExtraConfigColumns]);if(s)for(let e of Object.values(s))Y(e,QD)&&i[a].primaryKey.push(...e.columns)}else if(Y(o,TO)){let e=sD(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 jO(e){return function(t,n){return new EO(e,t,n,n?.fields.reduce((e,t)=>e&&t.notNull,!0)??!1)}}function MO(e){return function(t,n){return new DO(e,t,n)}}function NO(e,t,n){if(Y(n,EO)&&n.config)return{fields:n.config.fields,references:n.config.references};let r=t[sD(n.referencedTable)];if(!r)throw Error(`Table "${n.referencedTable[X.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[sD(a)];if(!o)throw Error(`Table "${a[X.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[X.Symbol.Name]}". Please specify relation name`);if(s[0]&&Y(s[0],EO)&&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 PO(e){return{one:jO(e),many:MO(e)}}function FO(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]=Y(r,EO)?l&&FO(e,e[s.relationTableTsKey],l,s.selection,i):l.map(t=>FO(e,e[s.relationTableTsKey],t,s.selection,i))}else{let e=i(n[o]),t=s.field,r;r=Y(t,AE)?t:Y(t,Z)?t.decoder:t.sql.decoder,a[s.tsKey]=e===null?null:r.mapFromDriverValue(e)}return a}var IO=class e{static[J]=`SelectionProxyHandler`;config;constructor(e){this.config={...e}}get(t,n){if(n===`_`)return{...t._,selectedFields:new Proxy(t._.selectedFields,this)};if(n===ZE)return{...t[ZE],selectedFields:new Proxy(t[ZE].selectedFields,this)};if(typeof n==`symbol`)return t[n];let r=Y(t,JE)?t._.selectedFields:Y(t,yD)?t[ZE].selectedFields:t,i=r[n];if(Y(i,Z.Aliased)){if(this.config.sqlAliasedBehavior===`sql`&&!i.isSelectionField)return i.sql;let e=i.clone();return e.isSelectionField=!0,e}if(Y(i,Z)){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 Y(i,AE)?this.config.alias?new Proxy(i,new bD(new Proxy(i.table,new xD(this.config.alias,this.config.replaceOriginalName??!1)))):i:typeof i!=`object`||!i?i:new Proxy(i,new e(this.config))}};function LO(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 RO(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 zO(e){return e}var BO=class{static[J]=`CasingCache`;cache={};cachedTables={};convert;constructor(e){this.convert=e===`snake_case`?LO:e===`camelCase`?RO:zO}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[X.Symbol.Schema]??`public`,n=e.table[X.Symbol.OriginalName],r=`${t}.${n}.${e.name}`;return this.cache[r]||this.cacheTable(e.table),this.cache[r]}cacheTable(e){let t=e[X.Symbol.Schema]??`public`,n=e[X.Symbol.OriginalName],r=`${t}.${n}`;if(!this.cachedTables[r]){for(let t of Object.values(e[X.Symbol.Columns])){let e=`${r}.${t.name}`;this.cache[e]=this.convert(t.name)}this.cachedTables[r]=!0}}clearCache(){this.cache={},this.cachedTables={}}},VO=class extends yD{static[J]=`PgViewBase`},HO=class{static[J]=`PgDialect`;casing;constructor(e){this.casing=new BO(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=Q` - CREATE TABLE IF NOT EXISTS ${Q.identifier(i)}.${Q.identifier(r)} ( - id SERIAL PRIMARY KEY, - hash text NOT NULL, - created_at bigint - ) - `;await t.execute(Q`CREATE SCHEMA IF NOT EXISTS ${Q.identifier(i)}`),await t.execute(a);let o=await t.all(Q`select id, hash, created_at from ${Q.identifier(i)}.${Q.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 Q.join(r.flatMap((e,r)=>{let a=n[e],o=t[e]??Q.param(a.onUpdateFn(),a),s=Q`${Q.identifier(this.casing.getColumnCasing(a))} = ${o}`;return r{let i=[];if(Y(e,Z.Aliased)&&e.isSelectionField)i.push(Q.identifier(e.fieldAlias));else if(Y(e,Z.Aliased)||Y(e,Z)){let n=Y(e,Z.Aliased)?e.sql:e;t?i.push(new Z(n.queryChunks.map(e=>Y(e,HE)?Q.identifier(this.casing.getColumnCasing(e)):e))):i.push(n),Y(e,Z.Aliased)&&i.push(Q` as ${Q.identifier(e.fieldAlias)}`)}else Y(e,AE)&&(t?i.push(Q.identifier(this.casing.getColumnCasing(e))):i.push(e));return ro?.some(({alias:t})=>t===(e[X.Symbol.IsAlias]?oD(e):e[X.Symbol.BaseName])))(e.field.table)){let t=oD(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 h=!o||o.length===0,ee=this.buildWithCTE(e),te;f&&(te=f===!0?Q` distinct`:Q` distinct on (${Q.join(f.on,Q`, `)})`);let ne=this.buildSelection(m,{isSingleTable:h}),re=this.buildFromTable(a),ie=this.buildJoins(o),ae=r?Q` where ${r}`:void 0,oe=i?Q` having ${i}`:void 0,se;s&&s.length>0&&(se=Q` order by ${Q.join(s,Q`, `)}`);let ce;c&&c.length>0&&(ce=Q` group by ${Q.join(c,Q`, `)}`);let le=typeof l==`object`||typeof l==`number`&&l>=0?Q` limit ${l}`:void 0,ue=u?Q` offset ${u}`:void 0,de=Q.empty();if(d){let e=Q` for ${Q.raw(d.strength)}`;d.config.of&&e.append(Q` of ${Q.join(Array.isArray(d.config.of)?d.config.of:[d.config.of],Q`, `)}`),d.config.noWait?e.append(Q` nowait`):d.config.skipLocked&&e.append(Q` skip locked`),de.append(e)}let fe=Q`${ee}select${te} ${ne} from ${re}${ie}${ae}${ce}${oe}${se}${le}${ue}${de}`;return p.length>0?this.buildSetOperations(fe,p):fe}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=Q`(${e.getSQL()}) `,c=Q`(${r.getSQL()})`,l;if(a&&a.length>0){let e=[];for(let t of a)if(Y(t,HE))e.push(Q.identifier(t.name));else if(Y(t,Z)){for(let e=0;e=0?Q` limit ${i}`:void 0,d=Q.raw(`${t} ${n?`all `:``}`),f=o?Q` offset ${o}`:void 0;return Q`${s}${d}${c}${l}${u}${f}`}buildInsertQuery({table:e,values:t,onConflict:n,returning:r,withList:i,select:a,overridingSystemValue_:o}){let s=[],c=e[X.Symbol.Columns],l=Object.entries(c).filter(([e,t])=>!t.shouldDisableInsert()),u=l.map(([,e])=>Q.identifier(this.casing.getColumnCasing(e)));if(a){let e=t;Y(e,Z)?s.push(e):s.push(e.getSQL())}else{let e=t;s.push(Q.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||Y(i,hD)&&i.value===void 0)if(t.defaultFn!==void 0){let e=t.defaultFn(),n=Y(e,Z)?e:Q.param(e,t);r.push(n)}else if(!t.default&&t.onUpdateFn!==void 0){let e=t.onUpdateFn(),n=Y(e,Z)?e:Q.param(e,t);r.push(n)}else r.push(Q`default`);else r.push(i)}s.push(r),t({dbKey:t.name,tsKey:e,field:CD(t,o),relationTableTsKey:void 0,isJson:!1,selection:[]}))}else{let r=Object.fromEntries(Object.entries(i.columns).map(([e,t])=>[e,CD(t,o)]));if(a.where){let e=typeof a.where==`function`?a.where(r,OO()):a.where;p=e&&TD(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 h=[];a.with&&(h=Object.entries(a.with).filter(e=>!!e[1]).map(([e,t])=>({tsKey:e,queryConfig:t,relation:i.relations[e]})));let ee;if(a.extras){ee=typeof a.extras==`function`?a.extras(r,{sql:Q}):a.extras;for(let[e,t]of Object.entries(ee))s.push({tsKey:e,value:wD(t,o)})}for(let{tsKey:e,value:t}of s)l.push({dbKey:Y(t,Z.Aliased)?t.fieldAlias:i.columns[e].name,tsKey:e,field:Y(t,AE)?CD(t,o):t,relationTableTsKey:void 0,isJson:!1,selection:[]});let te=typeof a.orderBy==`function`?a.orderBy(r,kO()):a.orderBy??[];Array.isArray(te)||(te=[te]),f=te.map(e=>Y(e,AE)?CD(e,o):TD(e,o)),u=a.limit,d=a.offset;for(let{tsKey:r,queryConfig:i,relation:a}of h){let s=NO(t,n,a),c=sD(a.referencedTable),u=n[c],d=`${o}_${r}`,f=rO(...s.fields.map((e,t)=>tO(CD(s.references[t],d),CD(e,o)))),p=this.buildRelationalQueryWithoutPK({fullSchema:e,schema:t,tableNamesMap:n,table:e[u],tableConfig:t[u],queryConfig:Y(a,EO)?i===!0?{limit:1}:{...i,limit:1}:i,tableAlias:d,joinOn:f,nestedQueryRelation:a}),h=Q`${Q.identifier(d)}.${Q.identifier(`data`)}`.as(r);m.push({on:Q`true`,table:new JE(p.sql,{},d),alias:d,joinType:`left`,lateral:!0}),l.push({dbKey:r,tsKey:r,field:h,relationTableTsKey:u,isJson:!0,selection:p.selection})}}if(l.length===0)throw new ED({message:`No fields selected for table "${i.tsName}" ("${o}")`});let h;if(p=rO(c,p),s){let e=Q`json_build_array(${Q.join(l.map(({field:e,tsKey:t,isJson:n})=>n?Q`${Q.identifier(`${o}_${t}`)}.${Q.identifier(`data`)}`:Y(e,Z.Aliased)?e.sql:e),Q`, `)})`;Y(s,DO)&&(e=Q`coalesce(json_agg(${e}${f.length>0?Q` order by ${Q.join(f,Q`, `)}`: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||f.length>0;n?(h=this.buildSelectQuery({table:SD(r,o),fields:{},fieldsFlat:[{path:[],field:Q.raw(`*`)}],where:p,limit:u,offset:d,orderBy:f,setOperators:[]}),p=void 0,u=void 0,d=void 0,f=[]):h=SD(r,o),h=this.buildSelectQuery({table:Y(h,ZD)?h:new JE(h,{},o),fields:{},fieldsFlat:t.map(({field:e})=>({path:[],field:Y(e,AE)?CD(e,o):e})),joins:m,where:p,limit:u,offset:d,orderBy:f,setOperators:[]})}else h=this.buildSelectQuery({table:SD(r,o),fields:{},fieldsFlat:l.map(({field:e})=>({path:[],field:Y(e,AE)?CD(e,o):e})),joins:m,where:p,limit:u,offset:d,orderBy:f,setOperators:[]});return{tableTsKey:i.tsName,sql:h,selection:l}}},UO=class{static[J]=`TypedQueryBuilder`;getSelectedFields(){return this._.selectedFields}},WO=class{static[J]=`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:Y(n,JE)?Object.fromEntries(Object.keys(n._.selectedFields).map(e=>[e,n[e]])):Y(n,VO)?n[ZE].selectedFields:Y(n,Z)?{}:LD(n),new KO({table:n,fields:r,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}},GO=class extends UO{static[J]=`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=RD(e),this.joinsNotNullableMap=typeof this.tableName==`string`?{[this.tableName]:!0}:{};for(let t of nk(e))this.usedTables.add(t)}getUsedTables(){return[...this.usedTables]}createJoin(e,t){return(n,r)=>{let i=this.tableName,a=RD(n);for(let e of nk(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`&&!Y(n,Z))){let e=Y(n,JE)?n._.selectedFields:Y(n,yD)?n[ZE].selectedFields:n[X.Symbol.Columns];this.config.fields[a]=e}if(typeof r==`function`&&(r=r(new Proxy(this.config.fields,new IO({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(JO()):n;if(!PD(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 IO({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))),this.config.where=e,this}having(e){return typeof e==`function`&&(e=e(new Proxy(this.config.fields,new IO({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 IO({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 IO({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(...nk(this.config.table)),this.config.joins)for(let e of this.config.joins)t.push(...nk(e.table));return new Proxy(new JE(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new IO({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`}))}getSelectedFields(){return new Proxy(this.config.fields,new IO({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}},KO=class extends GO{static[J]=`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 XE.startActiveSpan(`drizzle.prepareQuery`,()=>{let n=ND(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=>XE.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken))};ID(KO,[MD]);function qO(e,t){return(n,r,...i)=>{let a=[r,...i].map(n=>({type:e,isAll:t,rightSelect:n}));for(let e of a)if(!PD(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 JO=()=>({union:YO,unionAll:XO,intersect:ZO,intersectAll:QO,except:$O,exceptAll:ek}),YO=qO(`union`,!1),XO=qO(`union`,!0),ZO=qO(`intersect`,!1),QO=qO(`intersect`,!0),$O=qO(`except`,!1),ek=qO(`except`,!0);var tk=class{static[J]=`PgQueryBuilder`;dialect;dialectConfig;constructor(e){this.dialect=Y(e,HO)?e:void 0,this.dialectConfig=Y(e,HO)?void 0:e}$with=(e,t)=>{let n=this,r=r=>(typeof r==`function`&&(r=r(n)),new Proxy(new YE(r.getSQL(),t??(`getSelectedFields`in r?r.getSelectedFields()??{}:{}),e,!0),new IO({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`})));return{as:r}};with(...e){let t=this;function n(n){return new WO({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function r(e){return new WO({fields:e??void 0,session:void 0,dialect:t.getDialect(),distinct:!0})}function i(e,n){return new WO({fields:n??void 0,session:void 0,dialect:t.getDialect(),distinct:{on:e}})}return{select:n,selectDistinct:r,selectDistinctOn:i}}select(e){return new WO({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new WO({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn(e,t){return new WO({fields:t??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:e}})}getDialect(){return this.dialect||=new HO(this.dialectConfig),this.dialect}};function nk(e){return Y(e,ZD)?[e[QE]?`${e[QE]}.${e[X.Symbol.BaseName]}`:e[X.Symbol.BaseName]]:Y(e,JE)?e._.usedTables??[]:Y(e,Z)?e.usedTables??[]:[]}var rk=class extends MD{constructor(e,t,n,r){super(),this.session=t,this.dialect=n,this.config={table:e,withList:r}}static[J]=`PgDelete`;config;cacheConfig;where(e){return this.config.where=e,this}returning(e=this.config.table[X.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=ND(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return XE.startActiveSpan(`drizzle.prepareQuery`,()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:`delete`,tables:nk(this.config.table)},this.cacheConfig))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>XE.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken));getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new IO({alias:oD(this.config.table),sqlAliasedBehavior:`alias`,sqlBehavior:`error`})):void 0}$dynamic(){return this}},ik=class{constructor(e,t,n,r,i){this.table=e,this.session=t,this.dialect=n,this.withList=r,this.overridingSystemValue_=i}static[J]=`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[X.Symbol.Columns];for(let r of Object.keys(e)){let i=e[r];t[r]=Y(i,Z)?i:new hD(i,n[r])}return t});return new ak(this.table,t,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select(e){let t=typeof e==`function`?e(new tk):e;if(!Y(t,Z)&&!PD(this.table[$E],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 ak(this.table,t,this.session,this.dialect,this.withList,!0)}},ak=class extends MD{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[J]=`PgInsert`;config;cacheConfig;returning(e=this.config.table[X.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=ND(e),this}onConflictDoNothing(e={}){if(e.target===void 0)this.config.onConflict=Q`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?Q` where ${e.where}`:void 0;this.config.onConflict=Q`(${Q.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?Q` where ${e.where}`:void 0,n=e.targetWhere?Q` where ${e.targetWhere}`:void 0,r=e.setWhere?Q` where ${e.setWhere}`:void 0,i=this.dialect.buildUpdateSet(this.config.table,FD(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=Q`(${Q.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 XE.startActiveSpan(`drizzle.prepareQuery`,()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:`insert`,tables:nk(this.config.table)},this.cacheConfig))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>XE.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken));getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new IO({alias:oD(this.config.table),sqlAliasedBehavior:`alias`,sqlBehavior:`error`})):void 0}$dynamic(){return this}},ok=class extends MD{constructor(e,t,n){super(),this.session=t,this.dialect=n,this.config={view:e}}static[J]=`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 XE.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=>XE.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken))},sk=class{constructor(e,t,n,r){this.table=e,this.session=t,this.dialect=n,this.withList=r}static[J]=`PgUpdateBuilder`;authToken;setToken(e){return this.authToken=e,this}set(e){return new ck(this.table,FD(this.table,e),this.session,this.dialect,this.withList).setToken(this.authToken)}},ck=class extends MD{constructor(e,t,n,r,i){super(),this.session=n,this.dialect=r,this.config={set:t,table:e,withList:i,joins:[]},this.tableName=RD(e),this.joinsNotNullableMap=typeof this.tableName==`string`?{[this.tableName]:!0}:{}}static[J]=`PgUpdate`;config;tableName;joinsNotNullableMap;cacheConfig;from(e){let t=e,n=RD(t);return typeof n==`string`&&(this.joinsNotNullableMap[n]=!0),this.config.from=t,this}getTableLikeFields(e){return Y(e,ZD)?e[X.Symbol.Columns]:Y(e,JE)?e._.selectedFields:e[ZE].selectedFields}createJoin(e){return(t,n)=>{let r=RD(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&&!Y(this.config.from,Z)?this.getTableLikeFields(this.config.from):void 0;n=n(new Proxy(this.config.table[X.Symbol.Columns],new IO({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})),e&&new Proxy(e,new IO({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[X.Symbol.Columns]),this.config.from)){let t=RD(this.config.from);if(typeof t==`string`&&this.config.from&&!Y(this.config.from,Z)){let n=this.getTableLikeFields(this.config.from);e[t]=n}for(let t of this.config.joins){let n=RD(t.table);if(typeof n==`string`&&!Y(t.table,Z)){let r=this.getTableLikeFields(t.table);e[n]=r}}}return this.config.returningFields=e,this.config.returning=ND(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:nk(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 IO({alias:oD(this.config.table),sqlAliasedBehavior:`alias`,sqlBehavior:`error`})):void 0}$dynamic(){return this}},lk=class e extends Z{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[J]=`PgCountBuilder`;[Symbol.toStringTag]=`PgCountBuilder`;session;static buildEmbeddedCount(e,t){return Q`(select count(*) from ${e}${Q.raw(` where `).if(t)}${t})`}static buildCount(e,t){return Q`select count(*) as count from ${e}${Q.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})}},uk=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[J]=`PgRelationalQueryBuilder`;findMany(e){return new dk(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},`many`)}findFirst(e){return new dk(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},`first`)}},dk=class extends MD{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[J]=`PgRelationalQuery`;_prepare(e){return XE.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=>FO(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 XE.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(void 0,this.authToken))}},fk=class extends MD{constructor(e,t,n,r){super(),this.execute=e,this.sql=t,this.query=n,this.mapBatchResult=r}static[J]=`PgRaw`;getSQL(){return this.sql}getQuery(){return this.query}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}},pk=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 uk(n.fullSchema,this._.schema,this._.tableNamesMap,n.fullSchema[r],i,e,t);this.$cache={invalidate:async e=>{}}}static[J]=`PgDatabase`;query;$with=(e,t)=>{let n=this,r=r=>(typeof r==`function`&&(r=r(new tk(n.dialect))),new Proxy(new YE(r.getSQL(),t??(`getSelectedFields`in r?r.getSelectedFields()??{}:{}),e,!0),new IO({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`})));return{as:r}};$count(e,t){return new lk({source:e,filters:t,session:this.session})}$cache;with(...e){let t=this;function n(n){return new WO({fields:n??void 0,session:t.session,dialect:t.dialect,withList:e})}function r(n){return new WO({fields:n??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})}function i(n,r){return new WO({fields:r??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:{on:n}})}function a(n){return new sk(n,t.session,t.dialect,e)}function o(n){return new ik(n,t.session,t.dialect,e)}function s(n){return new rk(n,t.session,t.dialect,e)}return{select:n,selectDistinct:r,selectDistinctOn:i,update:a,insert:o,delete:s}}select(e){return new WO({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new WO({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn(e,t){return new WO({fields:t??void 0,session:this.session,dialect:this.dialect,distinct:{on:e}})}update(e){return new sk(e,this.session,this.dialect)}insert(e){return new ik(e,this.session,this.dialect)}delete(e){return new rk(e,this.session,this.dialect)}refreshMaterializedView(e){return new ok(e,this.session,this.dialect)}authToken;execute(e){let t=typeof e==`string`?Q.raw(e):e.getSQL(),n=this.dialect.sqlToQuery(t),r=this.session.prepareQuery(n,void 0,void 0,!1);return new fk(()=>r.execute(void 0,this.authToken),t,n,e=>r.mapResult(e,!0))}transaction(e,t){return this.session.transaction(e,t)}},mk=class{static[J]=`Cache`},hk=class extends mk{strategy(){return`all`}static[J]=`NoopCache`;async get(e){}async put(e,t,n,r){}async onMutate(e){}};async function gk(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 _k=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[J]=`PgPreparedQuery`;joinsNotNullableMap;async queryWithCache(e,t,n){if(this.cache===void 0||Y(this.cache,hk)||this.queryMetadata===void 0)try{return await n()}catch(n){throw new DD(e,t,n)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await n()}catch(n){throw new DD(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 DD(e,t,n)}if(!this.cacheConfig)try{return await n()}catch(n){throw new DD(e,t,n)}if(this.queryMetadata.type===`select`){let r=await this.cache.get(this.cacheConfig.tag??await gk(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 DD(e,t,n)}return await this.cache.put(this.cacheConfig.tag??await gk(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 DD(e,t,n)}}},vk=class{constructor(e){this.dialect=e}static[J]=`PgSession`;execute(e,t){return XE.startActiveSpan(`drizzle.operation`,()=>{let n=XE.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)}},yk=class extends pk{constructor(e,t,n,r=0){super(e,t,n),this.schema=n,this.nestedIndex=r}static[J]=`PgTransaction`;rollback(){throw new OD}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`),Q.raw(t.join(` `))}setTransaction(e){return this.session.execute(Q`set transaction ${this.getTransactionConfigSQL(e)}`)}};function bk(e){return typeof e==`string`&&/^true$/i.test(e)}function xk(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&&bk(r)&&(t.logger=!0);let i=n.searchParams.get(`storage`);switch(i){case EE.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:EE.ORIGIN_PRIVATE_FS,path:n.pathname.startsWith(`/`)?n.pathname.slice(1):n.pathname,...e&&bk(e)&&{accessMode:M_.READ_WRITE}};break}case null:break;default:console.warn(`Unknown storage type "${i}"`);break}return t}var Sk=class extends _k{static[J]=`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=_D(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=_D(this.params,e);this.logger.logQuery(this.queryString,t);let n=await this.client;return n.query(this.queryString,t)}},Ck=class e extends vk{static[J]=`DuckDBWasmSession`;logger;constructor(e,t,n,r={}){super(t),this.client=e,this.schema=n,this.options=r,this.logger=r.logger??new jD}prepareQuery(e,t,n,r,i){return new Sk(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 OE(this.client,async r=>{let i=new e(r,this.dialect,this.schema,this.options),a=new wk(this.dialect,i,this.schema);return n&&await a.setTransaction(n),t(a)})}},wk=class e extends yk{static[J]=`DuckDBWasmTransaction`;dialect;session;constructor(e,t,n,r=0){super(e,t,n,r),this.dialect=e,this.session=t}async transaction(t){return kE(this.session.client,``,async n=>{let r=new Ck(n,this.dialect,this.schema,this.session.options),i=new e(this.dialect,r,this.schema);return t(i)})}},Tk=class extends pk{static[J]=`DuckDBWasmDatabase`};function Ek(e,t={}){let n=new HO({casing:t.casing}),r;t.logger===!0?r=new AD:t.logger!==!1&&(r=t.logger);let i;if(t.schema){let e=AO(t.schema,PO);i={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let a=new Ck(e,n,i,{logger:r}),o=new Tk(n,a,i);return o.$client=e,o}function Dk(e,t){let n=xk(e),r;if(n.bundles===`import-url`){let e=async()=>{let e=await tE();switch(e){case`browser`:return(await ae(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 ae(async()=>{let{getImportUrlBundles:e}=await import(`./import-url-node-Cmtz-q5h.js`);return{getImportUrlBundles:e}},__vite__mapDeps([7,6]))).getImportUrlBundles();default:throw Error(`Unsupported environment: "${e}"`)}};r=e()}else{let e=async()=>{let e=await tE();switch(e){case`browser`:return(await ae(async()=>{let{getBundles:e}=await import(`./default-browser-DPbB-j00.js`);return{getBundles:e}},[])).getBundles();case`node`:return await(await ae(async()=>{let{getBundles:e}=await import(`./default-node-DcE314Tg.js`);return{getBundles:e}},__vite__mapDeps([3,1,2]))).getBundles();default:throw Error(`Unsupported environment: "${e}"`)}};r=e()}return Ek(DE({bundles:r,logger:n.logger?new z_:void 0,storage:n.storage}),t)}function Ok(...e){if(typeof e[0]==`string`)return Dk(e[0],e[1]);if(zD(e[0])){let{connection:t,client:n,...r}=e[0];if(n)return Ek(n,r);if(typeof t==`string`)return Dk(t,r);if(t===void 0)throw Error(`connection option is required`);return Ek(DE({bundles:t.bundles,logger:t.logger,storage:t.storage}),r)}return Ek(e[0],e[1])}(function(e){function t(e){return Ek({options:{parsers:{},serializers:{}}},e)}e.mock=t})(Ok||={});var kk=1/1e3,Ak=1e3,jk=class{constructor(){this.startTime=performance.now(),this.previousTime=0,this.currentTime=0,this._delta=0,this._elapsed=0,this._fixedDelta=1e3/60,this.timescale=1,this.useFixedDelta=!1,this._autoReset=!1}get autoReset(){return this._autoReset}set autoReset(e){typeof document<`u`&&document.hidden!==void 0&&(e?document.addEventListener(`visibilitychange`,this):document.removeEventListener(`visibilitychange`,this),this._autoReset=e)}get delta(){return this._delta*kk}get fixedDelta(){return this._fixedDelta*kk}set fixedDelta(e){this._fixedDelta=e*Ak}get elapsed(){return this._elapsed*kk}update(e){this.useFixedDelta?this._delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=(e===void 0?performance.now():e)-this.startTime,this._delta=this.currentTime-this.previousTime),this._delta*=this.timescale,this._elapsed+=this._delta}reset(){this._delta=0,this._elapsed=0,this.currentTime=performance.now()-this.startTime}getDelta(){return this.delta}getElapsed(){return this.elapsed}handleEvent(e){document.hidden||(this.currentTime=performance.now()-this.startTime)}dispose(){this.autoReset=!1}},Mk=(()=>{let e=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),t=new Float32Array([0,0,2,0,0,2]),n=new et;return n.setAttribute(`position`,new $e(e,3)),n.setAttribute(`uv`,new $e(t,2)),n})(),Nk=class e{static get fullscreenGeometry(){return Mk}constructor(e=`Pass`,t=new St,n=new ge){this.name=e,this.renderer=null,this.scene=t,this.camera=n,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(e){if(this.rtt===e){let t=this.fullscreenMaterial;t!==null&&(t.needsUpdate=!0),this.rtt=!e}}set mainScene(e){}set mainCamera(e){}setRenderer(e){this.renderer=e}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}get fullscreenMaterial(){return this.screen===null?null:this.screen.material}set fullscreenMaterial(t){let n=this.screen;n===null?(n=new jt(e.fullscreenGeometry,t),n.frustumCulled=!1,this.scene===null&&(this.scene=new St),this.scene.add(n),this.screen=n):n.material=t}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(e){this.fullscreenMaterial=e}getDepthTexture(){return null}setDepthTexture(e,t=Qe){}render(e,t,n,r,i){throw Error(`Render method not implemented!`)}setSize(e,t){}initialize(e,t,n){}dispose(){for(let t of Object.keys(this)){let n=this[t],r=n instanceof yn||n instanceof kt||n instanceof Ht||n instanceof e;r&&this[t].dispose()}this.fullscreenMaterial!==null&&this.fullscreenMaterial.dispose()}},Pk=class extends Nk{constructor(){super(`ClearMaskPass`,null,null),this.needsSwap=!1}render(e,t,n,r,i){let a=e.state.buffers.stencil;a.setLocked(!1),a.setTest(!1)}},Fk=`#include -#include -#ifdef FRAMEBUFFER_PRECISION_HIGH -uniform mediump sampler2D inputBuffer; -#else -uniform lowp sampler2D inputBuffer; -#endif -uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);gl_FragColor=opacity*texel; -#include -#include -}`,Ik=`varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}`,Lk=class extends tt{constructor(){super({name:`CopyMaterial`,uniforms:{inputBuffer:new cn(null),opacity:new cn(1)},blending:it,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Fk,vertexShader:Ik})}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}getOpacity(e){return this.uniforms.opacity.value}setOpacity(e){this.uniforms.opacity.value=e}},Rk=class extends Nk{constructor(e,t=!0){super(`CopyPass`),this.fullscreenMaterial=new Lk,this.needsSwap=!1,this.renderTarget=e,e===void 0&&(this.renderTarget=new yn(1,1,{minFilter:Ct,magFilter:Ct,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name=`CopyPass.Target`),this.autoResize=t}get resize(){return this.autoResize}set resize(e){this.autoResize=e}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(e){this.autoResize=e}render(e,t,n,r,i){this.fullscreenMaterial.inputBuffer=t.texture,e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){this.autoResize&&this.renderTarget.setSize(e,t)}initialize(e,t,n){n!==void 0&&(this.renderTarget.texture.type=n,n===un?e!==null&&e.outputColorSpace===bt&&(this.renderTarget.texture.colorSpace=bt):this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`)}},zk=new be,Bk=class extends Nk{constructor(e=!0,t=!0,n=!1){super(`ClearPass`,null,null),this.needsSwap=!1,this.color=e,this.depth=t,this.stencil=n,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(e,t,n){this.color=e,this.depth=t,this.stencil=n}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(e){this.overrideClearColor=e}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(e){this.overrideClearAlpha=e}render(e,t,n,r,i){let a=this.overrideClearColor,o=this.overrideClearAlpha,s=e.getClearAlpha(),c=a!==null,l=o>=0;c?(e.getClearColor(zk),e.setClearColor(a,l?o:s)):l&&e.setClearAlpha(o),e.setRenderTarget(this.renderToScreen?null:t),e.clear(this.color,this.depth,this.stencil),c?e.setClearColor(zk,s):l&&e.setClearAlpha(s)}},Vk=class extends Nk{constructor(e,t){super(`MaskPass`,e,t),this.needsSwap=!1,this.clearPass=new Bk(!1,!1,!0),this.inverse=!1}set mainScene(e){this.scene=e}set mainCamera(e){this.camera=e}get inverted(){return this.inverse}set inverted(e){this.inverse=e}get clear(){return this.clearPass.enabled}set clear(e){this.clearPass.enabled=e}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(e){this.inverted=e}render(e,t,n,r,i){let a=e.getContext(),o=e.state.buffers,s=this.scene,c=this.camera,l=this.clearPass,u=this.inverted?0:1,d=1-u;o.color.setMask(!1),o.depth.setMask(!1),o.color.setLocked(!0),o.depth.setLocked(!0),o.stencil.setTest(!0),o.stencil.setOp(a.REPLACE,a.REPLACE,a.REPLACE),o.stencil.setFunc(a.ALWAYS,u,4294967295),o.stencil.setClear(d),o.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?l.render(e,null):(l.render(e,t),l.render(e,n))),this.renderToScreen?(e.setRenderTarget(null),e.render(s,c)):(e.setRenderTarget(t),e.render(s,c),e.setRenderTarget(n),e.render(s,c)),o.color.setLocked(!1),o.depth.setLocked(!1),o.stencil.setLocked(!1),o.stencil.setFunc(a.EQUAL,1,4294967295),o.stencil.setOp(a.KEEP,a.KEEP,a.KEEP),o.stencil.setLocked(!0)}},Hk=class{constructor(e=null,{depthBuffer:t=!0,stencilBuffer:n=!1,multisampling:r=0,frameBufferType:i}={}){this.renderer=null,this.inputBuffer=this.createBuffer(t,n,i,r),this.outputBuffer=this.inputBuffer.clone(),this.copyPass=new Rk,this.depthTexture=null,this.passes=[],this.timer=new jk,this.autoRenderToScreen=!0,this.setRenderer(e)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(e){let t=this.inputBuffer,n=this.multisampling;n>0&&e>0?(this.inputBuffer.samples=e,this.outputBuffer.samples=e,this.inputBuffer.dispose(),this.outputBuffer.dispose()):n!==e&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),this.inputBuffer=this.createBuffer(t.depthBuffer,t.stencilBuffer,t.texture.type,e),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(e){if(this.renderer=e,e!==null){let t=e.getSize(new pn),n=e.getContext().getContextAttributes().alpha,r=this.inputBuffer.texture.type;r===un&&e.outputColorSpace===bt&&(this.inputBuffer.texture.colorSpace=bt,this.outputBuffer.texture.colorSpace=bt,this.inputBuffer.dispose(),this.outputBuffer.dispose()),e.autoClear=!1,this.setSize(t.width,t.height);for(let t of this.passes)t.initialize(e,n,r)}}replaceRenderer(e,t=!0){let n=this.renderer,r=n.domElement.parentNode;return this.setRenderer(e),t&&r!==null&&(r.removeChild(n.domElement),r.appendChild(e.domElement)),n}createDepthTexture(){let e=this.depthTexture=new Oe;return this.inputBuffer.depthTexture=e,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(e.format=De,e.type=dn):e.type=fn,e}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(let e of this.passes)e.setDepthTexture(null)}}createBuffer(e,t,n,r){let i=this.renderer,a=i===null?new pn:i.getDrawingBufferSize(new pn),o={minFilter:Ct,magFilter:Ct,stencilBuffer:t,depthBuffer:e,type:n},s=new yn(a.width,a.height,o);return r>0&&(s.ignoreDepthForMultisampleCopy=!1,s.samples=r),n===un&&i!==null&&i.outputColorSpace===bt&&(s.texture.colorSpace=bt),s.texture.name=`EffectComposer.Buffer`,s.texture.generateMipmaps=!1,s}setMainScene(e){for(let t of this.passes)t.mainScene=e}setMainCamera(e){for(let t of this.passes)t.mainCamera=e}addPass(e,t){let n=this.passes,r=this.renderer,i=r.getDrawingBufferSize(new pn),a=r.getContext().getContextAttributes().alpha,o=this.inputBuffer.texture.type;if(e.setRenderer(r),e.setSize(i.width,i.height),e.initialize(r,a,o),this.autoRenderToScreen&&(n.length>0&&(n[n.length-1].renderToScreen=!1),e.renderToScreen&&(this.autoRenderToScreen=!1)),t===void 0?n.push(e):n.splice(t,0,e),this.autoRenderToScreen&&(n[n.length-1].renderToScreen=!0),e.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){let t=this.createDepthTexture();for(e of n)e.setDepthTexture(t)}else e.setDepthTexture(this.depthTexture)}removePass(e){let t=this.passes,n=t.indexOf(e),r=n!==-1,i=r&&t.splice(n,1).length>0;if(i){if(this.depthTexture!==null){let n=(e,t)=>e||t.needsDepthTexture,r=t.reduce(n,!1);r||(e.getDepthTexture()===this.depthTexture&&e.setDepthTexture(null),this.deleteDepthTexture())}this.autoRenderToScreen&&n===t.length&&(e.renderToScreen=!1,t.length>0&&(t[t.length-1].renderToScreen=!0))}}removeAllPasses(){let e=this.passes;this.deleteDepthTexture(),e.length>0&&(this.autoRenderToScreen&&(e[e.length-1].renderToScreen=!1),this.passes=[])}render(e){let t=this.renderer,n=this.copyPass,r=this.inputBuffer,i=this.outputBuffer,a=!1,o,s,c;e===void 0&&(this.timer.update(),e=this.timer.getDelta());for(let l of this.passes)l.enabled&&(l.render(t,r,i,e,a),l.needsSwap&&(a&&(n.renderToScreen=l.renderToScreen,o=t.getContext(),s=t.state.buffers.stencil,s.setFunc(o.NOTEQUAL,1,4294967295),n.render(t,r,i,e,a),s.setFunc(o.EQUAL,1,4294967295)),c=r,r=i,i=c),l instanceof Vk?a=!0:l instanceof Pk&&(a=!1))}setSize(e,t,n){let r=this.renderer,i=r.getSize(new pn);(e===void 0||t===void 0)&&(e=i.width,t=i.height),(i.width!==e||i.height!==t)&&r.setSize(e,t,n);let a=r.getDrawingBufferSize(new pn);this.inputBuffer.setSize(a.width,a.height),this.outputBuffer.setSize(a.width,a.height);for(let e of this.passes)e.setSize(a.width,a.height)}reset(){this.dispose(),this.autoRenderToScreen=!0}dispose(){for(let e of this.passes)e.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose(),Nk.fullscreenGeometry.dispose()}},Uk={NONE:0,DEPTH:1,CONVOLUTION:2},Wk={FRAGMENT_HEAD:`FRAGMENT_HEAD`,FRAGMENT_MAIN_UV:`FRAGMENT_MAIN_UV`,FRAGMENT_MAIN_IMAGE:`FRAGMENT_MAIN_IMAGE`,VERTEX_HEAD:`VERTEX_HEAD`,VERTEX_MAIN_SUPPORT:`VERTEX_MAIN_SUPPORT`},Gk=class{constructor(){this.shaderParts=new Map([[Wk.FRAGMENT_HEAD,null],[Wk.FRAGMENT_MAIN_UV,null],[Wk.FRAGMENT_MAIN_IMAGE,null],[Wk.VERTEX_HEAD,null],[Wk.VERTEX_MAIN_SUPPORT,null]]),this.defines=new Map,this.uniforms=new Map,this.blendModes=new Map,this.extensions=new Set,this.attributes=Uk.NONE,this.varyings=new Set,this.uvTransformation=!1,this.readDepth=!1,this.colorSpace=Tt}},Kk=!1,qk=class{constructor(e=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(e),this.meshCount=0,this.replaceMaterial=e=>{if(e.isMesh){let t;if(e.material.flatShading)switch(e.material.side){case ke:t=this.materialsFlatShadedDoubleSide;break;case Ze:t=this.materialsFlatShadedBackSide;break;default:t=this.materialsFlatShaded;break}else switch(e.material.side){case ke:t=this.materialsDoubleSide;break;case Ze:t=this.materialsBackSide;break;default:t=this.materials;break}this.originalMaterials.set(e,e.material),e.isSkinnedMesh?e.material=t[2]:e.isInstancedMesh?e.material=t[1]:e.material=t[0],++this.meshCount}}}cloneMaterial(e){if(!(e instanceof tt))return e.clone();let t=e.uniforms,n=new Map;for(let e in t){let r=t[e].value;r.isRenderTargetTexture&&(t[e].value=null,n.set(e,r))}let r=e.clone();for(let e of n)t[e[0]].value=e[1],r.uniforms[e[0]].value=e[1];return r}setMaterial(e){if(this.disposeMaterials(),this.material=e,e!==null){let t=this.materials=[this.cloneMaterial(e),this.cloneMaterial(e),this.cloneMaterial(e)];for(let n of t)n.uniforms=Object.assign({},e.uniforms),n.side=Fe;t[2].skinning=!0,this.materialsBackSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.side=Ze,n}),this.materialsDoubleSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.side=ke,n}),this.materialsFlatShaded=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n}),this.materialsFlatShadedBackSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n.side=Ze,n}),this.materialsFlatShadedDoubleSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n.side=ke,n})}}render(e,t,n){let r=e.shadowMap.enabled;if(e.shadowMap.enabled=!1,Kk){let r=this.originalMaterials;this.meshCount=0,t.traverse(this.replaceMaterial),e.render(t,n);for(let e of r)e[0].material=e[1];this.meshCount!==r.size&&r.clear()}else{let r=t.overrideMaterial;t.overrideMaterial=this.material,e.render(t,n),t.overrideMaterial=r}e.shadowMap.enabled=r}disposeMaterials(){if(this.material!==null){let e=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(let t of e)t.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return Kk}static set workaroundEnabled(e){Kk=e}},Jk=-1,Yk=class extends Me{constructor(e,t=Jk,n=Jk,r=1){super(),this.resizable=e,this.baseSize=new pn(1,1),this.preferredSize=new pn(t,n),this.target=this.preferredSize,this.s=r,this.effectiveSize=new pn,this.addEventListener(`change`,()=>this.updateEffectiveSize()),this.updateEffectiveSize()}updateEffectiveSize(){let e=this.baseSize,t=this.preferredSize,n=this.effectiveSize,r=this.scale;t.width===Jk?t.height===Jk?n.width=Math.round(e.width*r):n.width=Math.round(t.height*(e.width/Math.max(e.height,1))):n.width=t.width,t.height===Jk?t.width===Jk?n.height=Math.round(e.height*r):n.height=Math.round(t.width/Math.max(e.width/Math.max(e.height,1),1)):n.height=t.height}get width(){return this.effectiveSize.width}set width(e){this.preferredWidth=e}get height(){return this.effectiveSize.height}set height(e){this.preferredHeight=e}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(e){this.s!==e&&(this.s=e,this.preferredSize.setScalar(Jk),this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getScale(){return this.scale}setScale(e){this.scale=e}get baseWidth(){return this.baseSize.width}set baseWidth(e){this.baseSize.width!==e&&(this.baseSize.width=e,this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseWidth(){return this.baseWidth}setBaseWidth(e){this.baseWidth=e}get baseHeight(){return this.baseSize.height}set baseHeight(e){this.baseSize.height!==e&&(this.baseSize.height=e,this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(e){this.baseHeight=e}setBaseSize(e,t){(this.baseSize.width!==e||this.baseSize.height!==t)&&(this.baseSize.set(e,t),this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}get preferredWidth(){return this.preferredSize.width}set preferredWidth(e){this.preferredSize.width!==e&&(this.preferredSize.width=e,this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(e){this.preferredWidth=e}get preferredHeight(){return this.preferredSize.height}set preferredHeight(e){this.preferredSize.height!==e&&(this.preferredSize.height=e,this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(e){this.preferredHeight=e}setPreferredSize(e,t){(this.preferredSize.width!==e||this.preferredSize.height!==t)&&(this.preferredSize.set(e,t),this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}copy(e){this.s=e.scale,this.baseSize.set(e.baseWidth,e.baseHeight),this.preferredSize.set(e.preferredWidth,e.preferredHeight),this.dispatchEvent({type:`change`}),this.resizable.setSize(this.baseSize.width,this.baseSize.height)}static get AUTO_SIZE(){return Jk}};Set;var $={SKIP:9,SET:30,ADD:0,ALPHA:1,AVERAGE:2,COLOR:3,COLOR_BURN:4,COLOR_DODGE:5,DARKEN:6,DIFFERENCE:7,DIVIDE:8,DST:9,EXCLUSION:10,HARD_LIGHT:11,HARD_MIX:12,HUE:13,INVERT:14,INVERT_RGB:15,LIGHTEN:16,LINEAR_BURN:17,LINEAR_DODGE:18,LINEAR_LIGHT:19,LUMINOSITY:20,MULTIPLY:21,NEGATION:22,NORMAL:23,OVERLAY:24,PIN_LIGHT:25,REFLECT:26,SATURATION:27,SCREEN:28,SOFT_LIGHT:29,SRC:30,SUBTRACT:31,VIVID_LIGHT:32},Xk=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb+y.rgb,y.a),opacity);}`,Zk=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,y,y.a*opacity);}`,Qk=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4((x.rgb+y.rgb)*0.5,y.a),opacity);}`,$k=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(yHSL.xy,xHSL.z));return mix(x,vec4(z,y.a),opacity);}`,eA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=x.rgb,b=y.rgb;vec3 z=mix(step(0.0,b)*(1.0-min(vec3(1.0),(1.0-a)/b)),vec3(1.0),step(1.0,a));return mix(x,vec4(z,y.a),opacity);}`,tA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=x.rgb,b=y.rgb;vec3 z=step(0.0,a)*mix(min(vec3(1.0),a/max(1.0-b,1e-9)),vec3(1.0),step(1.0,b));return mix(x,vec4(z,y.a),opacity);}`,nA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(min(x.rgb,y.rgb),y.a),opacity);}`,rA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(abs(x.rgb-y.rgb),y.a),opacity);}`,iA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb/max(y.rgb,1e-12),y.a),opacity);}`,aA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4((x.rgb+y.rgb-2.0*x.rgb*y.rgb),y.a),opacity);}`,oA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=min(x.rgb,1.0);vec3 b=min(y.rgb,1.0);vec3 z=mix(2.0*a*b,1.0-2.0*(1.0-a)*(1.0-b),step(0.5,b));return mix(x,vec4(z,y.a),opacity);}`,sA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(step(1.0,x.rgb+y.rgb),y.a),opacity);}`,cA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(yHSL.x,xHSL.yz));return mix(x,vec4(z,y.a),opacity);}`,lA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(1.0-y.rgb,y.a),opacity);}`,uA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(y.rgb*(1.0-x.rgb),y.a),opacity);}`,dA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(max(x.rgb,y.rgb),y.a),opacity);}`,fA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(clamp(y.rgb+x.rgb-1.0,0.0,1.0),y.a),opacity);}`,pA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(min(x.rgb+y.rgb,1.0),y.a),opacity);}`,mA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(clamp(2.0*y.rgb+x.rgb-1.0,0.0,1.0),y.a),opacity);}`,hA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(xHSL.xy,yHSL.z));return mix(x,vec4(z,y.a),opacity);}`,gA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb*y.rgb,y.a),opacity);}`,_A=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(1.0-abs(1.0-x.rgb-y.rgb),y.a),opacity);}`,vA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,y,opacity);}`,yA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 z=mix(2.0*y.rgb*x.rgb,1.0-2.0*(1.0-y.rgb)*(1.0-x.rgb),step(0.5,x.rgb));return mix(x,vec4(z,y.a),opacity);}`,bA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 y2=2.0*y.rgb;vec3 z=mix(mix(y2,x.rgb,step(0.5*x.rgb,y.rgb)),max(y2-1.0,vec3(0.0)),step(x.rgb,y2-1.0));return mix(x,vec4(z,y.a),opacity);}`,xA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 z=mix(min(x.rgb*x.rgb/max(1.0-y.rgb,1e-12),1.0),y.rgb,step(1.0,y.rgb));return mix(x,vec4(z,y.a),opacity);}`,SA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(xHSL.x,yHSL.y,xHSL.z));return mix(x,vec4(z,y.a),opacity);}`,CA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb+y.rgb-min(x.rgb*y.rgb,1.0),y.a),opacity);}`,wA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=x.rgb;vec3 b=y.rgb;vec3 y2=2.0*b;vec3 w=step(0.5,b);vec3 c=a-(1.0-y2)*a*(1.0-a);vec3 d=mix(a+(y2-1.0)*(sqrt(a)-a),a+(y2-1.0)*a*((16.0*a-12.0)*a+3.0),w*(1.0-step(0.25,a)));vec3 z=mix(c,d,w);return mix(x,vec4(z,y.a),opacity);}`,TA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y;}`,EA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(max(x.rgb+y.rgb-1.0,0.0),y.a),opacity);}`,DA=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 z=mix(max(1.0-min((1.0-x.rgb)/(2.0*y.rgb),1.0),0.0),min(x.rgb/(2.0*(1.0-y.rgb)),1.0),step(0.5,y.rgb));return mix(x,vec4(z,y.a),opacity);}`,OA=new Map([[$.ADD,Xk],[$.ALPHA,Zk],[$.AVERAGE,Qk],[$.COLOR,$k],[$.COLOR_BURN,eA],[$.COLOR_DODGE,tA],[$.DARKEN,nA],[$.DIFFERENCE,rA],[$.DIVIDE,iA],[$.DST,null],[$.EXCLUSION,aA],[$.HARD_LIGHT,oA],[$.HARD_MIX,sA],[$.HUE,cA],[$.INVERT,lA],[$.INVERT_RGB,uA],[$.LIGHTEN,dA],[$.LINEAR_BURN,fA],[$.LINEAR_DODGE,pA],[$.LINEAR_LIGHT,mA],[$.LUMINOSITY,hA],[$.MULTIPLY,gA],[$.NEGATION,_A],[$.NORMAL,vA],[$.OVERLAY,yA],[$.PIN_LIGHT,bA],[$.REFLECT,xA],[$.SATURATION,SA],[$.SCREEN,CA],[$.SOFT_LIGHT,wA],[$.SRC,TA],[$.SUBTRACT,EA],[$.VIVID_LIGHT,DA]]),kA=class extends Me{constructor(e,t=1){super(),this._blendFunction=e,this.opacity=new cn(t)}getOpacity(){return this.opacity.value}setOpacity(e){this.opacity.value=e}get blendFunction(){return this._blendFunction}set blendFunction(e){this._blendFunction=e,this.dispatchEvent({type:`change`})}getBlendFunction(){return this.blendFunction}setBlendFunction(e){this.blendFunction=e}getShaderCode(){return OA.get(this.blendFunction)}},AA=class extends Me{constructor(e,t,{attributes:n=Uk.NONE,blendFunction:r=$.NORMAL,defines:i=new Map,uniforms:a=new Map,extensions:o=null,vertexShader:s=null}={}){super(),this.name=e,this.renderer=null,this.attributes=n,this.fragmentShader=t,this.vertexShader=s,this.defines=i,this.uniforms=a,this.extensions=o,this.blendMode=new kA(r),this.blendMode.addEventListener(`change`,e=>this.setChanged()),this._inputColorSpace=Tt,this._outputColorSpace=at}get inputColorSpace(){return this._inputColorSpace}set inputColorSpace(e){this._inputColorSpace=e,this.setChanged()}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e,this.setChanged()}set mainScene(e){}set mainCamera(e){}getName(){return this.name}setRenderer(e){this.renderer=e}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(e){this.fragmentShader=e,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(e){this.vertexShader=e,this.setChanged()}setChanged(){this.dispatchEvent({type:`change`})}setDepthTexture(e,t=Qe){}update(e,t,n){}setSize(e,t){}initialize(e,t,n){}dispose(){for(let e of Object.keys(this)){let t=this[e],n=t instanceof yn||t instanceof kt||t instanceof Ht||t instanceof Nk;n&&this[e].dispose()}}};new Float32Array([0,0]),new Float32Array([0,1,1]),new Float32Array([0,1,1,2]),new Float32Array([0,1,2,2,3]),new Float32Array([0,1,2,3,4,4,5]),new Float32Array([0,1,2,3,4,5,7,8,9,10]);var jA=class extends Nk{constructor(e,t,n=null){super(`RenderPass`,e,t),this.needsSwap=!1,this.clearPass=new Bk,this.overrideMaterialManager=n===null?null:new qk(n),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}set mainScene(e){this.scene=e}set mainCamera(e){this.camera=e}get renderToScreen(){return super.renderToScreen}set renderToScreen(e){super.renderToScreen=e,this.clearPass.renderToScreen=e}get overrideMaterial(){let e=this.overrideMaterialManager;return e===null?null:e.material}set overrideMaterial(e){let t=this.overrideMaterialManager;e===null?t!==null&&(t.dispose(),this.overrideMaterialManager=null):t===null?this.overrideMaterialManager=new qk(e):t.setMaterial(e)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(e){this.overrideMaterial=e}get clear(){return this.clearPass.enabled}set clear(e){this.clearPass.enabled=e}getSelection(){return this.selection}setSelection(e){this.selection=e}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(e){this.ignoreBackground=e}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(e){this.skipShadowMapUpdate=e}getClearPass(){return this.clearPass}render(e,t,n,r,i){let a=this.scene,o=this.camera,s=this.selection,c=o.layers.mask,l=a.background,u=e.shadowMap.autoUpdate,d=this.renderToScreen?null:t;s!==null&&o.layers.set(s.getLayer()),this.skipShadowMapUpdate&&(e.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(a.background=null),this.clearPass.enabled&&this.clearPass.render(e,t),e.setRenderTarget(d),this.overrideMaterialManager===null?e.render(a,o):this.overrideMaterialManager.render(e,a,o),o.layers.mask=c,a.background=l,e.shadowMap.autoUpdate=u}},MA=`uniform vec3 hue;uniform float saturation;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=vec3(dot(inputColor.rgb,hue.xyz),dot(inputColor.rgb,hue.zxy),dot(inputColor.rgb,hue.yzx));float average=(color.r+color.g+color.b)/3.0;vec3 diff=average-color;if(saturation>0.0){color+=diff*(1.0-1.0/(1.001-saturation));}else{color+=diff*-saturation;}outputColor=vec4(min(color,1.0),inputColor.a);}`,NA=class extends AA{constructor({blendFunction:e=$.SRC,hue:t=0,saturation:n=0}={}){super(`HueSaturationEffect`,MA,{blendFunction:e,uniforms:new Map([[`hue`,new cn(new mn)],[`saturation`,new cn(n)]])}),this.hue=t}get saturation(){return this.uniforms.get(`saturation`).value}set saturation(e){this.uniforms.get(`saturation`).value=e}getSaturation(){return this.saturation}setSaturation(e){this.saturation=e}get hue(){let e=this.uniforms.get(`hue`).value;return Math.acos((e.x*3-1)/2)}set hue(e){let t=Math.sin(e),n=Math.cos(e);this.uniforms.get(`hue`).value.set((2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3)}getHue(){return this.hue}setHue(e){this.hue=e}};Math.PI*.5;var PA=`#include -#ifdef GL_FRAGMENT_PRECISION_HIGH -uniform highp sampler2D depthBuffer; -#else -uniform mediump sampler2D depthBuffer; -#endif -#ifdef DOWNSAMPLE_NORMALS -uniform lowp sampler2D normalBuffer; -#endif -varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;float readDepth(const in vec2 uv){ -#if DEPTH_PACKING == 3201 -return unpackRGBAToDepth(texture2D(depthBuffer,uv)); -#else -return texture2D(depthBuffer,uv).r; -#endif -}int findBestDepth(const in float samples[4]){float c=(samples[0]+samples[1]+samples[2]+samples[3])*0.25;float distances[4];distances[0]=abs(c-samples[0]);distances[1]=abs(c-samples[1]);distances[2]=abs(c-samples[2]);distances[3]=abs(c-samples[3]);float maxDistance=max(max(distances[0],distances[1]),max(distances[2],distances[3]));int remaining[3];int rejected[3];int i,j,k;for(i=0,j=0,k=0;i<4;++i){if(distances[i]this.setSize(s.baseWidth,s.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}setDepthTexture(e,t=Qe){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.depthPacking=t}render(e,t,n,r,i){e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height),this.fullscreenMaterial.setSize(e,t)}initialize(e,t,n){let r=e.getContext(),i=r.getExtension(`EXT_color_buffer_float`)||r.getExtension(`EXT_color_buffer_half_float`);if(!i)throw Error(`Rendering to float texture is not supported.`)}},RA=`#include -#include -#include -#define packFloatToRGBA(v) packDepthToRGBA(v) -#define unpackRGBAToFloat(v) unpackRGBAToDepth(v) -#ifdef FRAMEBUFFER_PRECISION_HIGH -uniform mediump sampler2D inputBuffer; -#else -uniform lowp sampler2D inputBuffer; -#endif -#if DEPTH_PACKING == 3201 -uniform lowp sampler2D depthBuffer; -#elif defined(GL_FRAGMENT_PRECISION_HIGH) -uniform highp sampler2D depthBuffer; -#else -uniform mediump sampler2D depthBuffer; -#endif -uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;vec4 sRGBToLinear(const in vec4 value){return vec4(mix(pow(value.rgb*0.9478672986+vec3(0.0521327014),vec3(2.4)),value.rgb*0.0773993808,vec3(lessThanEqual(value.rgb,vec3(0.04045)))),value.a);}float readDepth(const in vec2 uv){ -#if DEPTH_PACKING == 3201 -return unpackRGBAToDepth(texture2D(depthBuffer,uv)); -#else -return texture2D(depthBuffer,uv).r; -#endif -}float getViewZ(const in float depth){ -#ifdef PERSPECTIVE_CAMERA -return perspectiveDepthToViewZ(depth,cameraNear,cameraFar); -#else -return orthographicDepthToViewZ(depth,cameraNear,cameraFar); -#endif -}vec3 RGBToHCV(const in vec3 RGB){vec4 P=mix(vec4(RGB.bg,-1.0,2.0/3.0),vec4(RGB.gb,0.0,-1.0/3.0),step(RGB.b,RGB.g));vec4 Q=mix(vec4(P.xyw,RGB.r),vec4(RGB.r,P.yzx),step(P.x,RGB.r));float C=Q.x-min(Q.w,Q.y);float H=abs((Q.w-Q.y)/(6.0*C+EPSILON)+Q.z);return vec3(H,C,Q.x);}vec3 RGBToHSL(const in vec3 RGB){vec3 HCV=RGBToHCV(RGB);float L=HCV.z-HCV.y*0.5;float S=HCV.y/(1.0-abs(L*2.0-1.0)+EPSILON);return vec3(HCV.x,S,L);}vec3 HueToRGB(const in float H){float R=abs(H*6.0-3.0)-1.0;float G=2.0-abs(H*6.0-2.0);float B=2.0-abs(H*6.0-4.0);return clamp(vec3(R,G,B),0.0,1.0);}vec3 HSLToRGB(const in vec3 HSL){vec3 RGB=HueToRGB(HSL.x);float C=(1.0-abs(2.0*HSL.z-1.0))*HSL.y;return(RGB-0.5)*C+HSL.z;}FRAGMENT_HEAD void main(){FRAGMENT_MAIN_UV vec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGE color0.a=clamp(color0.a,0.0,1.0);gl_FragColor=color0; -#ifdef ENCODE_OUTPUT -#include -#endif -#include -}`,zA=`uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;VERTEX_HEAD void main(){vUv=position.xy*0.5+0.5;VERTEX_MAIN_SUPPORT gl_Position=vec4(position.xy,1.0,1.0);}`,BA=class extends tt{constructor(e,t,n,r,i=!1){super({name:`EffectMaterial`,defines:{THREE_REVISION:ut.replace(/\D+/g,``),DEPTH_PACKING:`0`,ENCODE_OUTPUT:`1`},uniforms:{inputBuffer:new cn(null),depthBuffer:new cn(null),resolution:new cn(new pn),texelSize:new cn(new pn),cameraNear:new cn(.3),cameraFar:new cn(1e3),aspect:new cn(1),time:new cn(0)},blending:it,toneMapped:!1,depthWrite:!1,depthTest:!1,dithering:i}),e&&this.setShaderParts(e),t&&this.setDefines(t),n&&this.setUniforms(n),this.copyCameraSettings(r)}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(e){this.uniforms.depthBuffer.value=e}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=Qe){this.depthBuffer=e,this.depthPacking=t}setShaderData(e){this.setShaderParts(e.shaderParts),this.setDefines(e.defines),this.setUniforms(e.uniforms),this.setExtensions(e.extensions)}setShaderParts(e){return this.fragmentShader=RA.replace(Wk.FRAGMENT_HEAD,e.get(Wk.FRAGMENT_HEAD)||``).replace(Wk.FRAGMENT_MAIN_UV,e.get(Wk.FRAGMENT_MAIN_UV)||``).replace(Wk.FRAGMENT_MAIN_IMAGE,e.get(Wk.FRAGMENT_MAIN_IMAGE)||``),this.vertexShader=zA.replace(Wk.VERTEX_HEAD,e.get(Wk.VERTEX_HEAD)||``).replace(Wk.VERTEX_MAIN_SUPPORT,e.get(Wk.VERTEX_MAIN_SUPPORT)||``),this.needsUpdate=!0,this}setDefines(e){for(let t of e.entries())this.defines[t[0]]=t[1];return this.needsUpdate=!0,this}setUniforms(e){for(let t of e.entries())this.uniforms[t[0]]=t[1];return this}setExtensions(e){this.extensions={};for(let t of e)this.extensions[t]=!0;return this}get encodeOutput(){return this.defines.ENCODE_OUTPUT!==void 0}set encodeOutput(e){this.encodeOutput!==e&&(e?this.defines.ENCODE_OUTPUT=`1`:delete this.defines.ENCODE_OUTPUT,this.needsUpdate=!0)}isOutputEncodingEnabled(e){return this.encodeOutput}setOutputEncodingEnabled(e){this.encodeOutput=e}get time(){return this.uniforms.time.value}set time(e){this.uniforms.time.value=e}setDeltaTime(e){this.uniforms.time.value+=e}adoptCameraSettings(e){this.copyCameraSettings(e)}copyCameraSettings(e){e&&(this.uniforms.cameraNear.value=e.near,this.uniforms.cameraFar.value=e.far,e instanceof st?this.defines.PERSPECTIVE_CAMERA=`1`:delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(e,t){let n=this.uniforms;n.resolution.value.set(e,t),n.texelSize.value.set(1/e,1/t),n.aspect.value=e/t}static get Section(){return Wk}};Number(ut.replace(/\D+/g,``));var VA=255/256;new Float32Array([VA/256**3,VA/256**2,VA/256,VA]),new Float32Array([VA,VA/256,VA/256**2,1/256**3]);function HA(e,t,n){for(let r of t){let t=`$1`+e+r.charAt(0).toUpperCase()+r.slice(1),i=RegExp(`([^\\.])(\\b`+r+`\\b)`,`g`);for(let e of n.entries())e[1]!==null&&n.set(e[0],e[1].replace(i,t))}}function UA(e,t,n){let r=t.getFragmentShader(),i=t.getVertexShader(),a=r!==void 0&&/mainImage/.test(r),o=r!==void 0&&/mainUv/.test(r);if(n.attributes|=t.getAttributes(),r===void 0)throw Error(`Missing fragment shader (${t.name})`);if(o&&(n.attributes&Uk.CONVOLUTION)!==0)throw Error(`Effects that transform UVs are incompatible with convolution effects (${t.name})`);if(!a&&!o)throw Error(`Could not find mainImage or mainUv function (${t.name})`);{let s=/\w+\s+(\w+)\([\w\s,]*\)\s*{/g,c=n.shaderParts,l=c.get(Wk.FRAGMENT_HEAD)||``,u=c.get(Wk.FRAGMENT_MAIN_UV)||``,d=c.get(Wk.FRAGMENT_MAIN_IMAGE)||``,f=c.get(Wk.VERTEX_HEAD)||``,p=c.get(Wk.VERTEX_MAIN_SUPPORT)||``,m=new Set,h=new Set;if(o&&(u+=` ${e}MainUv(UV); -`,n.uvTransformation=!0),i!==null&&/mainSupport/.test(i)){let t=/mainSupport *\([\w\s]*?uv\s*?\)/.test(i);p+=` ${e}MainSupport(`,p+=t?`vUv); -`:`); -`;for(let e of i.matchAll(/(?:varying\s+\w+\s+([\S\s]*?);)/g))for(let t of e[1].split(/\s*,\s*/))n.varyings.add(t),m.add(t),h.add(t);for(let e of i.matchAll(s))h.add(e[1])}for(let e of r.matchAll(s))h.add(e[1]);for(let e of t.defines.keys())h.add(e.replace(/\([\w\s,]*\)/g,``));for(let e of t.uniforms.keys())h.add(e);h.delete(`while`),h.delete(`for`),h.delete(`if`),t.uniforms.forEach((t,r)=>n.uniforms.set(e+r.charAt(0).toUpperCase()+r.slice(1),t)),t.defines.forEach((t,r)=>n.defines.set(e+r.charAt(0).toUpperCase()+r.slice(1),t));let ee=new Map([[`fragment`,r],[`vertex`,i]]);HA(e,h,n.defines),HA(e,h,ee),r=ee.get(`fragment`),i=ee.get(`vertex`);let te=t.blendMode;if(n.blendModes.set(te.blendFunction,te),a){t.inputColorSpace!==null&&t.inputColorSpace!==n.colorSpace&&(d+=t.inputColorSpace===bt?`color0 = sRGBTransferOETF(color0); - `:`color0 = sRGBToLinear(color0); - `),t.outputColorSpace===at?t.inputColorSpace!==null&&(n.colorSpace=t.inputColorSpace):n.colorSpace=t.outputColorSpace;let i=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/;d+=`${e}MainImage(color0, UV, `,(n.attributes&Uk.DEPTH)!==0&&i.test(r)&&(d+=`depth, `,n.readDepth=!0),d+=`color1); - `;let a=e+`BlendOpacity`;n.uniforms.set(a,te.opacity),d+=`color0 = blend${te.blendFunction}(color0, color1, ${a}); - - `,l+=`uniform float ${a}; - -`}if(l+=r+` -`,i!==null&&(f+=i+` -`),c.set(Wk.FRAGMENT_HEAD,l),c.set(Wk.FRAGMENT_MAIN_UV,u),c.set(Wk.FRAGMENT_MAIN_IMAGE,d),c.set(Wk.VERTEX_HEAD,f),c.set(Wk.VERTEX_MAIN_SUPPORT,p),t.extensions!==null)for(let e of t.extensions)n.extensions.add(e)}}var WA=class extends Nk{constructor(e,...t){super(`EffectPass`),this.fullscreenMaterial=new BA(null,null,null,e),this.listener=e=>this.handleEvent(e),this.effects=[],this.setEffects(t),this.skipRendering=!1,this.minTime=1,this.maxTime=1/0,this.timeScale=1}set mainScene(e){for(let t of this.effects)t.mainScene=e}set mainCamera(e){this.fullscreenMaterial.copyCameraSettings(e);for(let t of this.effects)t.mainCamera=e}get encodeOutput(){return this.fullscreenMaterial.encodeOutput}set encodeOutput(e){this.fullscreenMaterial.encodeOutput=e}get dithering(){return this.fullscreenMaterial.dithering}set dithering(e){let t=this.fullscreenMaterial;t.dithering=e,t.needsUpdate=!0}setEffects(e){for(let e of this.effects)e.removeEventListener(`change`,this.listener);this.effects=e.sort((e,t)=>t.attributes-e.attributes);for(let e of this.effects)e.addEventListener(`change`,this.listener)}updateMaterial(){let e=new Gk,t=0;for(let n of this.effects)if(n.blendMode.blendFunction===$.DST)e.attributes|=n.getAttributes()&Uk.DEPTH;else if((e.attributes&n.getAttributes()&Uk.CONVOLUTION)!==0)throw Error(`Convolution effects cannot be merged (${n.name})`);else UA(`e`+ t++,n,e);let n=e.shaderParts.get(Wk.FRAGMENT_HEAD),r=e.shaderParts.get(Wk.FRAGMENT_MAIN_IMAGE),i=e.shaderParts.get(Wk.FRAGMENT_MAIN_UV),a=/\bblend\b/g;for(let t of e.blendModes.values())n+=t.getShaderCode().replace(a,`blend${t.blendFunction}`)+` -`;(e.attributes&Uk.DEPTH)===0?this.needsDepthTexture=!1:(e.readDepth&&(r=`float depth = readDepth(UV); - - `+r),this.needsDepthTexture=this.getDepthTexture()===null),e.colorSpace===bt&&(r+=`color0 = sRGBToLinear(color0); - `),e.uvTransformation?(i=`vec2 transformedUv = vUv; -`+i,e.defines.set(`UV`,`transformedUv`)):e.defines.set(`UV`,`vUv`),e.shaderParts.set(Wk.FRAGMENT_HEAD,n),e.shaderParts.set(Wk.FRAGMENT_MAIN_IMAGE,r),e.shaderParts.set(Wk.FRAGMENT_MAIN_UV,i);for(let[t,n]of e.shaderParts)n!==null&&e.shaderParts.set(t,n.trim().replace(/^#/,` -#`));this.skipRendering=t===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderData(e)}recompile(){this.updateMaterial()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(e,t=Qe){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.depthPacking=t;for(let n of this.effects)n.setDepthTexture(e,t)}render(e,t,n,r,i){for(let n of this.effects)n.update(e,t,r);if(!this.skipRendering||this.renderToScreen){let i=this.fullscreenMaterial;i.inputBuffer=t.texture,i.time+=r*this.timeScale,e.setRenderTarget(this.renderToScreen?null:n),e.render(this.scene,this.camera)}}setSize(e,t){this.fullscreenMaterial.setSize(e,t);for(let n of this.effects)n.setSize(e,t)}initialize(e,t,n){this.renderer=e;for(let r of this.effects)r.initialize(e,t,n);this.updateMaterial(),n!==void 0&&n!==un&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`)}dispose(){super.dispose();for(let e of this.effects)e.removeEventListener(`change`,this.listener),e.dispose()}handleEvent(e){switch(e.type){case`change`:this.recompile();break}}},GA=class extends Nk{constructor(e,t,{renderTarget:n,resolutionScale:r=1,width:i=Yk.AUTO_SIZE,height:a=Yk.AUTO_SIZE,resolutionX:o=i,resolutionY:s=a}={}){super(`NormalPass`),this.needsSwap=!1,this.renderPass=new jA(e,t,new Pt);let c=this.renderPass;c.ignoreBackground=!0,c.skipShadowMapUpdate=!0;let l=c.getClearPass();l.overrideClearColor=new be(7829503),l.overrideClearAlpha=1,this.renderTarget=n,this.renderTarget===void 0&&(this.renderTarget=new yn(1,1,{minFilter:Lt,magFilter:Lt}),this.renderTarget.texture.name=`NormalPass.Target`);let u=this.resolution=new Yk(this,o,s,r);u.addEventListener(`change`,e=>this.setSize(u.baseWidth,u.baseHeight))}set mainScene(e){this.renderPass.mainScene=e}set mainCamera(e){this.renderPass.mainCamera=e}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}render(e,t,n,r,i){let a=this.renderToScreen?null:this.renderTarget;this.renderPass.render(e,a,a)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height)}};new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1]),new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,0,1]),new Float32Array([1,1,1]),new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([1,0,1]),new Float32Array([1,1,1]),new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1]),new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([0,1,1]),new Float32Array([1,1,1]),new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([0,1,1]),new Float32Array([1,1,1]),new Float32Array(2),new Float32Array(2),new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125]),new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4]),new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3]),qA(0,0,0,0),new Float32Array([0,0,0,0]),qA(0,0,0,1),new Float32Array([0,0,0,1]),qA(0,0,1,0),new Float32Array([0,0,1,0]),qA(0,0,1,1),new Float32Array([0,0,1,1]),qA(0,1,0,0),new Float32Array([0,1,0,0]),qA(0,1,0,1),new Float32Array([0,1,0,1]),qA(0,1,1,0),new Float32Array([0,1,1,0]),qA(0,1,1,1),new Float32Array([0,1,1,1]),qA(1,0,0,0),new Float32Array([1,0,0,0]),qA(1,0,0,1),new Float32Array([1,0,0,1]),qA(1,0,1,0),new Float32Array([1,0,1,0]),qA(1,0,1,1),new Float32Array([1,0,1,1]),qA(1,1,0,0),new Float32Array([1,1,0,0]),qA(1,1,0,1),new Float32Array([1,1,0,1]),qA(1,1,1,0),new Float32Array([1,1,1,0]),qA(1,1,1,1),new Float32Array([1,1,1,1]);function KA(e,t,n){return e+(t-e)*n}function qA(e,t,n,r){let i=KA(e,t,.75),a=KA(n,r,.75);return KA(i,a,.875)}var JA=class{static isWebGL2Available(){try{let e=document.createElement(`canvas`);return!!(window.WebGL2RenderingContext&&e.getContext(`webgl2`))}catch{return!1}}static isColorSpaceAvailable(e){try{let t=document.createElement(`canvas`),n=window.WebGL2RenderingContext&&t.getContext(`webgl2`);return n.drawingBufferColorSpace=e,n.drawingBufferColorSpace===e}catch{return!1}}static getWebGL2ErrorMessage(){return this.getErrorMessage(2)}static getErrorMessage(e){let t={1:`WebGL`,2:`WebGL 2`},n={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext},r=`Your $0 does not seem to support $1`,i=document.createElement(`div`);return i.id=`webglmessage`,i.style.fontFamily=`monospace`,i.style.fontSize=`13px`,i.style.fontWeight=`normal`,i.style.textAlign=`center`,i.style.background=`#fff`,i.style.color=`#000`,i.style.padding=`1.5em`,i.style.width=`400px`,i.style.margin=`5em auto 0`,r=n[e]?r.replace(`$0`,`graphics card`):r.replace(`$0`,`browser`),r=r.replace(`$1`,t[e]),i.innerHTML=r,i}static isWebGLAvailable(){console.warn(`isWebGLAvailable() has been deprecated and will be removed in r178. Use isWebGL2Available() instead.`);try{let e=document.createElement(`canvas`);return!!(window.WebGLRenderingContext&&(e.getContext(`webgl`)||e.getContext(`experimental-webgl`)))}catch{return!1}}static getWebGLErrorMessage(){return console.warn(`getWebGLErrorMessage() has been deprecated and will be removed in r178. Use getWebGL2ErrorMessage() instead.`),this.getErrorMessage(1)}};const YA=Symbol(`effectComposerPmndrs`),XA=Jt({__name:`EffectComposerPmndrs`,props:{enabled:{type:Boolean,default:!0},depthBuffer:{type:Boolean,default:void 0},disableNormalPass:{type:Boolean,default:!1},stencilBuffer:{type:Boolean,default:void 0},resolutionScale:{},autoClear:{type:Boolean,default:!0},multisampling:{default:0},frameBufferType:{default:Ie}},emits:[`render`],setup(e,{expose:t,emit:n}){let r=e,i=n,{scene:a,camera:o,renderer:s,sizes:c,render:l}=We(),u=Tn(null),d=null,f=null;nn(YA,u),t({composer:u});let p=()=>{u.value&&(f=new GA(a.value,o.value),f.enabled=!1,u.value.addPass(f),r.resolutionScale!==void 0&&JA.isWebGL2Available()&&(d=new LA({normalBuffer:f.texture,resolutionScale:r.resolutionScale}),d.enabled=!1,u.value.addPass(d)))},m=Cn(()=>{let e=new Hk,t={depthBuffer:r.depthBuffer===void 0?e.inputBuffer.depthBuffer:r.depthBuffer,stencilBuffer:r.stencilBuffer===void 0?e.inputBuffer.stencilBuffer:r.stencilBuffer,multisampling:JA.isWebGL2Available()?r.multisampling===void 0?e.multisampling:r.multisampling:0,frameBufferType:r.frameBufferType===void 0?Ie:r.frameBufferType};return e.dispose(),t}),h=()=>{var e;!s.value&&!a.value&&!o.value||((e=u.value)==null||e.dispose(),u.value=new Hk(s.value,m.value),u.value.addPass(new jA(a.value,o.value)),r.disableNormalPass||p())};on([s,a,o,()=>r.disableNormalPass],()=>{!c.width.value||!c.height.value||h()}),on(()=>[c.width.value,c.height.value],([e,t])=>{!e&&!t||(u.value?u.value.setSize(e,t):h())},{immediate:!0});let{render:ee}=Ue();return ee(()=>{if(r.enabled&&s.value&&u.value&&c.width.value&&c.height.value&&l.frames.value>0){let e=s.value.autoClear;s.value.autoClear=r.autoClear,r.stencilBuffer&&!r.autoClear&&s.value.clearStencil(),u.value.render(),i(`render`,u.value),s.value.autoClear=e}l.frames.value=l.mode.value===`always`?1:Math.max(0,l.frames.value-1)}),en(()=>{var e;(e=u.value)==null||e.dispose()}),(e,t)=>rn(e.$slots,`default`)}}),ZA=(e,t,n)=>{let r=Xt(YA),i=Tn(null),a=Tn(null),{scene:o,camera:s,invalidate:c}=We();on(t,()=>c());let l=()=>{var e,t,n;i.value&&((e=r?.value)==null||e.removePass(i.value)),(t=a.value)==null||t.dispose(),(n=i.value)==null||n.dispose()},u=t=>{!s.value||!(r!=null&&r.value)||!o.value||(a.value=e(),i.value=new WA(s.value,a.value),r.value.addPass(i.value,t))};n&&on(()=>n.map(e=>t[e]),()=>{var e;if(!(r!=null&&r.value))return;let t=(e=r.value)?.passes.findIndex(e=>e===i.value);~t&&(l(),u(t))}),sn(()=>{!s.value||!(a!=null&&a.value)||(a.value.mainCamera=s.value)});let d=sn(()=>{!s.value||!(r!=null&&r.value)||!o.value||(Qt(()=>d()),!a.value&&u())});return en(()=>{l()}),{pass:i,effect:a}},QA=/([^[.\]])+/g,$A=(e,t)=>{if(!t)return;let n=Array.isArray(t)?t:t.match(QA);return n?.reduce((e,t)=>e&&e[t],e)},ej=(e,t,n)=>{let r=Array.isArray(t)?t:t.match(QA);r&&r.reduce((e,t,i)=>(e[t]===void 0&&(e[t]={}),i===r.length-1&&(e[t]=n),e[t]),e)},tj=(e,t,n,r,i={})=>on(e,i=>{var a;if(t.value)if(i===void 0){let e=r();ej(t.value,n,$A(e,n)),(a=e.dispose)==null||a.call(e)}else ej(t.value,n,e())},i),nj=(e,t,n)=>e.map(([e,r])=>tj(e,t,r,n));Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const rj=Jt({__name:`HueSaturationPmndrs`,props:{saturation:{},hue:{},blendFunction:{}},setup(e,{expose:t}){let n=e,{pass:r,effect:i}=ZA(()=>new NA(n),n);return t({pass:r,effect:i}),nj([[()=>n.blendFunction,`blendMode.blendFunction`],[()=>n.hue,`hue`],[()=>n.saturation,`saturation`]],i,()=>new NA),()=>{}}});Boolean,Boolean;const ij={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` - - varying vec2 vUv; - - void main() { - - vUv = uv; - gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); - - }`,fragmentShader:` - - uniform float opacity; - - uniform sampler2D tDiffuse; - - varying vec2 vUv; - - void main() { - - vec4 texel = texture2D( tDiffuse, vUv ); - gl_FragColor = opacity * texel; - - - }`};var aj=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}};const oj=new ot(-1,1,1,-1,0,1);var sj=class extends et{constructor(){super(),this.setAttribute(`position`,new Ne([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new Ne([0,2,0,0,2,0],2))}};const cj=new sj;var lj=class{constructor(e){this._mesh=new jt(cj,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,oj)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}};Boolean,Boolean,Boolean,Math.PI/12*1,Math.PI/12*2,Math.PI/12*3,new pn(1/1024,1/512),new pn(1/1024,1/512),new pn(1/1024,1/512);const uj={name:`LuminosityHighPassShader`,shaderID:`luminosityHighPass`,uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new be(0)},defaultOpacity:{value:0}},vertexShader:` - - varying vec2 vUv; - - void main() { - - vUv = uv; - - gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); - - }`,fragmentShader:` - - uniform sampler2D tDiffuse; - uniform vec3 defaultColor; - uniform float defaultOpacity; - uniform float luminosityThreshold; - uniform float smoothWidth; - - varying vec2 vUv; - - void main() { - - vec4 texel = texture2D( tDiffuse, vUv ); - - float v = luminance( texel.xyz ); - - vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity ); - - float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v ); - - gl_FragColor = mix( outputColor, texel, alpha ); - - }`};var dj=class e extends aj{constructor(e,t,n,r){super(),this.strength=t===void 0?1:t,this.radius=n,this.threshold=r,this.resolution=e===void 0?new pn(256,256):new pn(e.x,e.y),this.clearColor=new be(0,0,0),this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let i=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);this.renderTargetBright=new yn(i,a,{type:Ie}),this.renderTargetBright.texture.name=`UnrealBloomPass.bright`,this.renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e - varying vec2 vUv; - uniform sampler2D colorTexture; - uniform vec2 invSize; - uniform vec2 direction; - uniform float gaussianCoefficients[KERNEL_RADIUS]; - - void main() { - float weightSum = gaussianCoefficients[0]; - vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum; - for( int i = 1; i < KERNEL_RADIUS; i ++ ) { - float x = float(i); - float w = gaussianCoefficients[i]; - vec2 uvOffset = direction * invSize * x; - vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb; - vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb; - diffuseSum += (sample1 + sample2) * w; - weightSum += 2.0 * w; - } - gl_FragColor = vec4(diffuseSum/weightSum, 1.0); - }`})}getCompositeMaterial(e){return new tt({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:`varying vec2 vUv; - void main() { - vUv = uv; - gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); - }`,fragmentShader:`varying vec2 vUv; - uniform sampler2D blurTexture1; - uniform sampler2D blurTexture2; - uniform sampler2D blurTexture3; - uniform sampler2D blurTexture4; - uniform sampler2D blurTexture5; - uniform float bloomStrength; - uniform float bloomRadius; - uniform float bloomFactors[NUM_MIPS]; - uniform vec3 bloomTintColors[NUM_MIPS]; - - float lerpBloomFactor(const in float factor) { - float mirrorFactor = 1.2 - factor; - return mix(factor, mirrorFactor, bloomRadius); - } - - void main() { - gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) + - lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) + - lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) + - lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) + - lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) ); - }`})}};dj.BlurDirectionX=new pn(1,0),dj.BlurDirectionY=new pn(0,1);var fj=class{static fromCubeTexture(e){let t=0,n=new mn,r=new mn,i=new be,a=[0,0,0,0,0,0,0,0,0],o=new Bt,s=o.coefficients;for(let o=0;o<6;o++){let c=e.image[o],l=c.width,u=c.height,d=document.createElement(`canvas`);d.width=l,d.height=u;let f=d.getContext(`2d`);f.drawImage(c,0,0,l,u);let p=f.getImageData(0,0,l,u),m=p.data,h=p.width,ee=2/h;for(let c=0,l=m.length;c(i=s.indexOf(` -`))&&a=e.byteLength||!(l=n(e)))&&t(1,`no header found`),(u=l.match(r))||t(3,`bad initial token`),c.valid|=1,c.programtype=u[1],c.string+=l+` -`;l=n(e),!1!==l;){if(c.string+=l+` -`,l.charAt(0)===`#`){c.comments+=l+` -`;continue}if((u=l.match(i))&&(c.gamma=parseFloat(u[1])),(u=l.match(a))&&(c.exposure=parseFloat(u[1])),(u=l.match(o))&&(c.valid|=2,c.format=u[1]),(u=l.match(s))&&(c.valid|=4,c.height=parseInt(u[1],10),c.width=parseInt(u[2],10)),c.valid&2&&c.valid&4)break}return c.valid&2||t(3,`missing format specifier`),c.valid&4||t(3,`missing image size specifier`),c},i=function(e,n,r){let i=n;if(i<8||i>32767||e[0]!==2||e[1]!==2||e[2]&128)return new Uint8Array(e);i!==(e[2]<<8|e[3])&&t(3,`wrong scanline width`);let a=new Uint8Array(4*n*r);a.length||t(4,`unable to allocate buffer space`);let o=0,s=0,c=4*i,l=new Uint8Array(4),u=new Uint8Array(c),d=r;for(;d>0&&se.byteLength&&t(1),l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++],(l[0]!=2||l[1]!=2||(l[2]<<8|l[3])!=i)&&t(3,`bad rgbe scanline format`);let n=0,r;for(;n128;if(i&&(r-=128),(r===0||n+r>c)&&t(3,`bad scanline data`),i){let t=e[s++];for(let e=0;e!!u.value&&!!u.value).toBeTruthy(),d(),e||=hj,u.value.outputColorSpace=bt,u.value.toneMapping=qe;try{let t=await new mj().loadAsync(e);t.mapping=Ae,t.generateMipmaps=!0,t.minFilter=wt,t.magFilter=Ct,t.colorSpace=Tt,o=new Ke(u.value);let n=o.fromEquirectangular(t);s=n;let d=new vn(256);d.fromEquirectangularTexture(u.value,t);let f=await fj.fromCubeRenderTarget(u.value,d);a.value=t;let p=l.value;p.environment=n.texture,r.asBackground&&(p.background=n.texture),p.backgroundBlurriness=r.backgroundBlurriness,p.backgroundIntensity=r.backgroundIntensity,c=t,i(`skyboxReady`,{hdri:c,irrSH:f.sh})}catch(e){console.warn(`Failed to load HDRI environment:`,e)}}return $t(async()=>{await f(r.skyBoxSrc),on(()=>[r.skyBoxSrc],([e])=>{f(e)},{deep:!1})}),t({reload:async e=>await f(e)}),en(async()=>{await d()}),(e,t)=>rn(e.$slots,`default`)}}),_j=gj;const vj=oe(`vrm`,()=>{let{post:e,data:t}=ue({name:`airi-stores-vrm`}),n=g([]),r=e=>{n.value.push(e)};function i(){e({type:`should-update-view`}),n.value.forEach(e=>e())}on(t,e=>{e.type===`should-update-view`&&n.value.forEach(e=>e())});let a=pe(`settings/vrm/cameraScale`,1),o=pe(`settings/vrm/modelSize`,{x:0,y:0,z:0}),s=pe(`settings/vrm/modelOrigin`,{x:0,y:0,z:0}),c=pe(`settings/vrm/modelOffset`,{x:0,y:0,z:0}),l=pe(`settings/vrm/modelRotationY`,0),u=pe(`settings/vrm/cameraFOV`,40),d=pe(`settings/vrm/camera-position`,{x:0,y:0,z:-1}),f=pe(`settings/vrm/cameraDistance`,0),p=pe(`settings/vrm/scenes/scene/directional-light/position`,{x:0,y:0,z:-1}),m=pe(`settings/vrm/scenes/scene/directional-light/target`,{x:0,y:0,z:0}),h=pe(`settings/vrm/scenes/scene/directional-light/rotation`,{x:0,y:0,z:0}),ee=pe(`settings/vrm/scenes/scene/directional-light/intensity`,2.02),te=pe(`settings/vrm/scenes/scene/directional-light/color`,`#fffbf5`),ne=pe(`settings/vrm/scenes/scene/hemisphere-light/sky-color`,`#FFFFFF`),re=pe(`settings/vrm/scenes/scene/hemisphere-light/ground-color`,`#222222`),ie=pe(`settings/vrm/scenes/scene/hemisphere-light/intensity`,.4),ae=pe(`settings/vrm/scenes/scene/ambient-light/color`,`#FFFFFF`),oe=pe(`settings/vrm/scenes/scene/ambient-light/intensity`,.6),se=pe(`settings/vrm/lookAtTarget`,{x:0,y:0,z:0}),ce=pe(`settings/vrm/isTracking`,!1),le=pe(`settings/vrm/trackingMode`,`none`),de=pe(`settings/vrm/eyeHeight`,0),fe=pe(`settings/vrm/envEnabled`,`skyBox`),me=pe(`settings/vrm/skyBoxUrl`,hj),he=pe(`settings/vrm/skyBoxIntensity`,.1);return{modelSize:o,scale:a,modelOrigin:s,modelOffset:c,modelRotationY:l,cameraFOV:u,cameraPosition:d,cameraDistance:f,directionalLightPosition:p,directionalLightTarget:m,directionalLightRotation:h,directionalLightIntensity:ee,directionalLightColor:te,ambientLightIntensity:oe,ambientLightColor:ae,hemisphereSkyColor:ne,hemisphereGroundColor:re,hemisphereLightIntensity:ie,lookAtTarget:se,isTracking:ce,trackingMode:le,eyeHeight:de,envSelect:fe,skyBoxSrc:me,skyBoxIntensity:he,shouldUpdateView:i,onShouldUpdateView:r}}),yj=[`color`,`ground-color`,`intensity`],bj=[`color`,`intensity`],xj=[`color`,`position`,`intensity`],Sj={key:2,size:1};var Cj=Jt({__name:`VRM`,props:{modelSrc:{},showAxes:{type:Boolean,default:!1},idleAnimation:{default:`/assets/vrm/animations/idle_loop.vrma`},paused:{type:Boolean,default:!1}},emits:[`loadModelProgress`,`error`],setup(e,{expose:t,emit:n}){let r=e,i=n,{x:a,y:o}=he(),s=g(),{width:c,height:l}=fe(s),{cameraFOV:u,cameraPosition:d,cameraDistance:f,modelOrigin:p,trackingMode:m,lookAtTarget:h,eyeHeight:ee,directionalLightIntensity:te,directionalLightColor:ne,directionalLightPosition:ie,directionalLightRotation:ae,directionalLightTarget:oe,ambientLightIntensity:ce,ambientLightColor:le,hemisphereLightIntensity:ue,hemisphereSkyColor:de,hemisphereGroundColor:pe,envSelect:me,skyBoxSrc:ge}=se(vj()),_e=g(),ve=Tn(new st),ye=Tn(),be=Tn(),xe=g(),Se=g();function Ce(e){be.value=e}let we={saturation:.3,hue:0,blendFunction:$.SRC},Te=!0,Ee=g(!1),De=g(!1),Oe=g(!1),ke=g(!1),Ae=new gt,Me=new pn,Ne=g(null),Pe=g(null);function Fe(e){Ne.value=e.hdri,Pe.value=e.irrSH||null}function Ie(){ke.value=!0}on(u,e=>{ve.value&&(ve.value.fov=e,ve.value.updateProjectionMatrix())}),on(()=>ye.value?.controls,e=>{if(e&&ve.value){Ee.value=!0;let t=()=>{if(Te)return;Te=!0;let e=ve.value.position,t=ye.value.controls.getDistance(),n=Math.abs(d.value.x-e.x)>1e-6||Math.abs(d.value.y-e.y)>1e-6||Math.abs(d.value.z-e.z)>1e-6,r=Math.abs(f.value-t)>1e-6;(n||r)&&(d.value={x:e.x,y:e.y,z:e.z},f.value=t),Te=!1};e.addEventListener(`change`,t)}});function Le(){De.value=!0}on([Ee,De,ke],([e,t])=>{if(e&&t&&ve.value&&ye.value&&ye.value.controls&&Se.value){Te=!0;try{ve.value.aspect=c.value/l.value,ve.value.fov=u.value,ye.value.setTarget(p.value),ve.value.position.set(d.value.x,d.value.y,d.value.z),ve.value.updateProjectionMatrix(),ye.value.controls.update(),f.value=ye.value.controls.getDistance(),Se.value.parent?.add(Se.value.target),Se.value.target.position.set(oe.value.x,oe.value.y,oe.value.z),Se.value.target.updateMatrixWorld()}finally{Te=!1,Oe.value=!0}}}),on(f,e=>{if(!Te&&ve.value&&ye.value&&ye.value.controls){Te=!0;let t=new mn,n=ye.value.controls.target,r=new mn().subVectors(ve.value.position,n).normalize();t.copy(n).addScaledVector(r,e),ve.value.position.set(t.x,t.y,t.z),ye.value.update(),d.value={x:t.x,y:t.y,z:t.z}}Te=!1});function Re(e){_e.value?.lookAtUpdate(e),h.value=e}function ze(e,t){Me.x=e/window.innerWidth*2-1,Me.y=-(t/window.innerHeight)*2+1,Ae.setFromCamera(Me,ve.value);let n=new mn;ve.value.getWorldDirection(n);let r=new ct;r.setFromNormalAndCoplanarPoint(n,ve.value.position.clone().add(n.multiplyScalar(1)));let i=new mn;Ae.ray.intersectPlane(r,i),h.value={x:i.x,y:i.y,z:i.z},_e.value?.lookAtUpdate(h.value)}function Be(e){let t=Se.value;if(!t)return;let{x:n,y:r,z:i}=e,a=new mn(ie.value.x,ie.value.y,ie.value.z),o=new mn(0,0,0),s=new je(At.degToRad(n),At.degToRad(r),At.degToRad(i),`XYZ`),c=o.clone().sub(a).normalize(),l=c.applyEuler(s).normalize(),u=a.distanceTo(o),d=a.clone().addScaledVector(l,u);t.target.position.copy(d),t.target.updateMatrixWorld(),oe.value={x:d.x,y:d.y,z:d.z}}return on(ae,e=>{Be(e)},{deep:!0}),on(d,e=>{!Oe.value||!_e.value||m.value===`camera`&&Re(e)},{deep:!0}),on([a,o],()=>{!Oe.value||!_e.value||m.value===`mouse`&&ze(a.value,o.value)}),on(m,e=>{!Oe.value||!_e.value||(e===`camera`?Re(d.value):e===`mouse`?ze(a.value,o.value):h.value={x:0,y:ee.value,z:-1e3})}),$t(()=>{me.value===`skyBox`&&xe.value?.reload(ge.value)}),t({setExpression:e=>{_e.value?.setExpression(e)},canvasElement:()=>be.value?.renderer.value.domElement}),(e,t)=>(tn(),Kt(`div`,{ref_key:`vrmContainerRef`,ref:s,w:`100%`,h:`100%`},[ve.value?wn((tn(),Wt(On(He),{key:0,camera:ve.value,antialias:!0,width:On(c),height:On(l),"tone-mapping":On(qe),"tone-mapping-exposure":1,"preserve-drawing-buffer":!0,onReady:Ce},{default:Rt(()=>[qt(On(eP),{ref_key:`controlsRef`,ref:ye},null,512),On(me)===`skyBox`?(tn(),Wt(_j,{key:0,ref_key:`skyBoxEnvRef`,ref:xe,"sky-box-src":On(ge),"as-background":!0,onSkyboxReady:Fe},null,8,[`sky-box-src`])):(tn(),Kt(`TresHemisphereLight`,{key:1,color:On(re)(On(de)),"ground-color":On(re)(On(pe)),position:[0,1,0],intensity:On(ue),"cast-shadow":``},null,8,yj)),Ut(`TresAmbientLight`,{color:On(re)(On(le)),intensity:On(ce),"cast-shadow":``},null,8,bj),Ut(`TresDirectionalLight`,{ref_key:`dirLightRef`,ref:Se,color:On(re)(On(ne)),position:[On(ie).x,On(ie).y,On(ie).z],intensity:On(te),"cast-shadow":``,onReady:Ie},null,40,xj),(tn(),Wt(Sn,null,{default:Rt(()=>[qt(On(XA),null,{default:Rt(()=>[qt(On(rj),kn(Yt(we)),null,16)]),_:1})]),_:1})),qt(On(kN),{ref_key:`modelRef`,ref:_e,"model-src":r.modelSrc,"idle-animation":r.idleAnimation,paused:r.paused,"npr-equirect-tex":Ne.value,"npr-irr-s-h":Pe.value,onLoadModelProgress:t[0]||=e=>i(`loadModelProgress`,e),onModelReady:Le,onError:t[1]||=e=>i(`error`,e)},null,8,[`model-src`,`idle-animation`,`paused`,`npr-equirect-tex`,`npr-irr-s-h`]),r.showAxes?(tn(),Kt(`TresAxesHelper`,Sj)):Gt(``,!0)]),_:1},8,[`camera`,`width`,`height`,`tone-mapping`])),[[bn,Oe.value]]):Gt(``,!0)],512))}}),wj=Cj;const Tj=async({description:e,execute:t,name:n,parameters:r,strict:i})=>{let a=await mr(r);return{execute:t,function:{description:e,name:n,parameters:i===!1?a:pr(a),strict:i??!0},type:`function`}},Ej=v(`ZodISODateTime`,(e,t)=>{ji.init(e,t),Qj.init(e,t)});function Dj(e){return La(Ej,e)}const Oj=v(`ZodISODate`,(e,t)=>{Ai.init(e,t),Qj.init(e,t)});function kj(e){return Ia(Oj,e)}const Aj=v(`ZodISOTime`,(e,t)=>{Ni.init(e,t),Qj.init(e,t)});function jj(e){return gr(Aj,e)}const Mj=v(`ZodISODuration`,(e,t)=>{Mi.init(e,t),Qj.init(e,t)});function Nj(e){return Ra(Mj,e)}const Pj=(e,t)=>{ca.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>ua(e,t)},flatten:{value:t=>la(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ga,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ga,2)}},isEmpty:{get(){return e.issues.length===0}}})};v(`ZodError`,Pj);const Fj=v(`ZodError`,Pj,{Parent:Error}),Ij=ea(Fj),Lj=ta(Fj),Rj=oa(Fj),zj=sa(Fj),Bj=Qi(Fj),Vj=Xi(Fj),Hj=$i(Fj),Uj=Zi(Fj),Wj=ia(Fj),Gj=na(Fj),Kj=aa(Fj),qj=ra(Fj),Jj=v(`ZodType`,(e,t)=>(si.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)=>fa(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Ij(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Rj(e,t,n),e.parseAsync=async(t,n)=>Lj(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>zj(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Bj(e,t,n),e.decode=(t,n)=>Vj(e,t,n),e.encodeAsync=async(t,n)=>Hj(e,t,n),e.decodeAsync=async(t,n)=>Uj(e,t,n),e.safeEncode=(t,n)=>Wj(e,t,n),e.safeDecode=(t,n)=>Gj(e,t,n),e.safeEncodeAsync=async(t,n)=>Kj(e,t,n),e.safeDecodeAsync=async(t,n)=>qj(e,t,n),e.refine=(t,n)=>e.check(rN(t,n)),e.superRefine=t=>e.check(iN(t)),e.overwrite=t=>e.check(Ar(t)),e.optional=()=>VM(e),e.nullable=()=>UM(e),e.nullish=()=>VM(UM(e)),e.nonoptional=t=>YM(e,t),e.array=()=>kM(e),e.or=t=>NM([e,t]),e.and=t=>FM(e,t),e.transform=t=>$M(e,zM(t)),e.default=t=>GM(e,t),e.prefault=t=>qM(e,t),e.catch=t=>ZM(e,t),e.pipe=t=>$M(e,t),e.readonly=()=>tN(e),e.describe=t=>{let n=e.clone();return qr.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return qr.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return qr.get(e);let n=e.clone();return qr.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Yj=v(`_ZodString`,(e,t)=>{ii.init(e,t),Jj.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(Mr(...t)),e.includes=(...t)=>e.check(Ma(...t)),e.startsWith=(...t)=>e.check(Nr(...t)),e.endsWith=(...t)=>e.check(Oa(...t)),e.min=(...t)=>e.check(wr(...t)),e.max=(...t)=>e.check(Cr(...t)),e.length=(...t)=>e.check(yr(...t)),e.nonempty=(...t)=>e.check(wr(1,...t)),e.lowercase=t=>e.check(br(t)),e.uppercase=t=>e.check(Vr(t)),e.trim=()=>e.check(Rr()),e.normalize=(...t)=>e.check(Or(...t)),e.toLowerCase=()=>e.check(Ir()),e.toUpperCase=()=>e.check(Lr())}),Xj=v(`ZodString`,(e,t)=>{ii.init(e,t),Yj.init(e,t),e.email=t=>e.check(Ea($j,t)),e.url=t=>e.check(Hr(nM,t)),e.jwt=t=>e.check(_r(_M,t)),e.emoji=t=>e.check(Da(rM,t)),e.guid=t=>e.check(ja(eM,t)),e.uuid=t=>e.check(hr(tM,t)),e.uuidv4=t=>e.check(Ur(tM,t)),e.uuidv6=t=>e.check(Wr(tM,t)),e.uuidv7=t=>e.check(Gr(tM,t)),e.nanoid=t=>e.check(Er(iM,t)),e.guid=t=>e.check(ja(eM,t)),e.cuid=t=>e.check(Ca(aM,t)),e.cuid2=t=>e.check(wa(oM,t)),e.ulid=t=>e.check(zr(sM,t)),e.base64=t=>e.check(va(mM,t)),e.base64url=t=>e.check(ya(hM,t)),e.xid=t=>e.check(Kr(cM,t)),e.ksuid=t=>e.check(vr(lM,t)),e.ipv4=t=>e.check(Pa(uM,t)),e.ipv6=t=>e.check(Fa(dM,t)),e.cidrv4=t=>e.check(xa(fM,t)),e.cidrv6=t=>e.check(Sa(pM,t)),e.e164=t=>e.check(Ta(gM,t)),e.datetime=t=>e.check(Dj(t)),e.date=t=>e.check(kj(t)),e.time=t=>e.check(jj(t)),e.duration=t=>e.check(Nj(t))});function Zj(e){return Pr(Xj,e)}const Qj=v(`ZodStringFormat`,(e,t)=>{ai.init(e,t),Yj.init(e,t)}),$j=v(`ZodEmail`,(e,t)=>{wi.init(e,t),Qj.init(e,t)}),eM=v(`ZodGUID`,(e,t)=>{Di.init(e,t),Qj.init(e,t)}),tM=v(`ZodUUID`,(e,t)=>{ui.init(e,t),Qj.init(e,t)}),nM=v(`ZodURL`,(e,t)=>{li.init(e,t),Qj.init(e,t)}),rM=v(`ZodEmoji`,(e,t)=>{Ti.init(e,t),Qj.init(e,t)}),iM=v(`ZodNanoID`,(e,t)=>{Li.init(e,t),Qj.init(e,t)}),aM=v(`ZodCUID`,(e,t)=>{vi.init(e,t),Qj.init(e,t)}),oM=v(`ZodCUID2`,(e,t)=>{yi.init(e,t),Qj.init(e,t)}),sM=v(`ZodULID`,(e,t)=>{ci.init(e,t),Qj.init(e,t)}),cM=v(`ZodXID`,(e,t)=>{pi.init(e,t),Qj.init(e,t)}),lM=v(`ZodKSUID`,(e,t)=>{Ii.init(e,t),Qj.init(e,t)}),uM=v(`ZodIPv4`,(e,t)=>{Oi.init(e,t),Qj.init(e,t)}),dM=v(`ZodIPv6`,(e,t)=>{ki.init(e,t),Qj.init(e,t)}),fM=v(`ZodCIDRv4`,(e,t)=>{gi.init(e,t),Qj.init(e,t)}),pM=v(`ZodCIDRv6`,(e,t)=>{_i.init(e,t),Qj.init(e,t)}),mM=v(`ZodBase64`,(e,t)=>{Yr.init(e,t),Qj.init(e,t)}),hM=v(`ZodBase64URL`,(e,t)=>{mi.init(e,t),Qj.init(e,t)}),gM=v(`ZodE164`,(e,t)=>{Ci.init(e,t),Qj.init(e,t)}),_M=v(`ZodJWT`,(e,t)=>{Fi.init(e,t),Qj.init(e,t)}),vM=v(`ZodNumber`,(e,t)=>{Zr.init(e,t),Jj.init(e,t),e.gt=(t,n)=>e.check(ka(t,n)),e.gte=(t,n)=>e.check(Aa(t,n)),e.min=(t,n)=>e.check(Aa(t,n)),e.lt=(t,n)=>e.check(xr(t,n)),e.lte=(t,n)=>e.check(Sr(t,n)),e.max=(t,n)=>e.check(Sr(t,n)),e.int=t=>e.check(xM(t)),e.safe=t=>e.check(xM(t)),e.positive=t=>e.check(ka(0,t)),e.nonnegative=t=>e.check(Aa(0,t)),e.negative=t=>e.check(xr(0,t)),e.nonpositive=t=>e.check(Sr(0,t)),e.multipleOf=(t,n)=>e.check(Tr(t,n)),e.step=(t,n)=>e.check(Tr(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 yM(e){return kr(vM,e)}const bM=v(`ZodNumberFormat`,(e,t)=>{Qr.init(e,t),vM.init(e,t)});function xM(e){return Na(bM,e)}const SM=v(`ZodBoolean`,(e,t)=>{hi.init(e,t),Jj.init(e,t)});function CM(e){return ba(SM,e)}const wM=v(`ZodUnknown`,(e,t)=>{fi.init(e,t),Jj.init(e,t)});function TM(){return Br(wM)}const EM=v(`ZodNever`,(e,t)=>{Ri.init(e,t),Jj.init(e,t)});function DM(e){return Dr(EM,e)}const OM=v(`ZodArray`,(e,t)=>{Jr.init(e,t),Jj.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(wr(t,n)),e.nonempty=t=>e.check(wr(1,t)),e.max=(t,n)=>e.check(Cr(t,n)),e.length=(t,n)=>e.check(yr(t,n)),e.unwrap=()=>e.element});function kM(e,t){return _a(OM,e,t)}const AM=v(`ZodObject`,(e,t)=>{$r.init(e,t),Jj.init(e,t),pa(e,`shape`,()=>t.shape),e.keyof=()=>LM(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:TM()}),e.loose=()=>e.clone({...e._zod.def,catchall:TM()}),e.strict=()=>e.clone({...e._zod.def,catchall:DM()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>ma(e,t),e.safeExtend=t=>qi(e,t),e.merge=t=>Bi(e,t),e.pick=t=>Gi(e,t),e.omit=t=>Ui(e,t),e.partial=(...t)=>Wi(BM,e,t[0]),e.required=(...t)=>Ki(JM,e,t[0])});function jM(e,t){let n={type:`object`,get shape(){return da(this,`shape`,e?Hi(e):{}),this.shape},...Vi(t)};return new AM(n)}const MM=v(`ZodUnion`,(e,t)=>{di.init(e,t),Jj.init(e,t),e.options=t.options});function NM(e,t){return new MM({type:`union`,options:e,...Vi(t)})}const PM=v(`ZodIntersection`,(e,t)=>{Pi.init(e,t),Jj.init(e,t)});function FM(e,t){return new PM({type:`intersection`,left:e,right:t})}const IM=v(`ZodEnum`,(e,t)=>{Ei.init(e,t),Jj.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 IM({...t,checks:[],...Vi(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 IM({...t,checks:[],...Vi(r),entries:i})}});function LM(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new IM({type:`enum`,entries:n,...Vi(t)})}const RM=v(`ZodTransform`,(e,t)=>{oi.init(e,t),Jj.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Yi(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(ha(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(ha(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function zM(e){return new RM({type:`transform`,transform:e})}const BM=v(`ZodOptional`,(e,t)=>{ei.init(e,t),Jj.init(e,t),e.unwrap=()=>e._zod.def.innerType});function VM(e){return new BM({type:`optional`,innerType:e})}const HM=v(`ZodNullable`,(e,t)=>{Xr.init(e,t),Jj.init(e,t),e.unwrap=()=>e._zod.def.innerType});function UM(e){return new HM({type:`nullable`,innerType:e})}const WM=v(`ZodDefault`,(e,t)=>{Si.init(e,t),Jj.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function GM(e,t){return new WM({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ji(t)}})}const KM=v(`ZodPrefault`,(e,t)=>{ni.init(e,t),Jj.init(e,t),e.unwrap=()=>e._zod.def.innerType});function qM(e,t){return new KM({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ji(t)}})}const JM=v(`ZodNonOptional`,(e,t)=>{zi.init(e,t),Jj.init(e,t),e.unwrap=()=>e._zod.def.innerType});function YM(e,t){return new JM({type:`nonoptional`,innerType:e,...Vi(t)})}const XM=v(`ZodCatch`,(e,t)=>{bi.init(e,t),Jj.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ZM(e,t){return new XM({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const QM=v(`ZodPipe`,(e,t)=>{ti.init(e,t),Jj.init(e,t),e.in=t.in,e.out=t.out});function $M(e,t){return new QM({type:`pipe`,in:e,out:t})}const eN=v(`ZodReadonly`,(e,t)=>{ri.init(e,t),Jj.init(e,t),e.unwrap=()=>e._zod.def.innerType});function tN(e){return new eN({type:`readonly`,innerType:e})}const nN=v(`ZodCustom`,(e,t)=>{xi.init(e,t),Jj.init(e,t)});function rN(e,t={}){return jr(nN,e,t)}function iN(e){return Fr(e)}const aN=[Tj({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:jM({})})],oN=async()=>Promise.all(aN);var sN,cN,lN,uN,dN;sN=new WeakMap,cN=new WeakMap,lN=new WeakMap,uN=new WeakMap;async function fN(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}dN=new WeakMap;async function pN(e,t){await fN(`plugin:mcp|connect_server`,{command:e,args:t})}async function mN(){await fN(`plugin:mcp|disconnect_server`)}async function hN(){return await fN(`plugin:mcp|list_tools`)}async function gN(e,t){return await fN(`plugin:mcp|call_tool`,{name:e,args:t})}const _N=[Tj({name:`mcp_list_tools`,description:`List all tools available on the MCP server`,execute:async(e,t)=>await hN(),parameters:jM({})}),Tj({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 pN(e,t),`success`),parameters:jM({command:Zj().describe(`The command to connect to the MCP server`),args:kM(Zj()).describe(`The arguments to pass to the MCP server`)})}),Tj({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 mN(),`success`),parameters:jM({})}),Tj({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 gN(e,n);return r},parameters:jM({name:Zj().describe(`The name of the tool to call`),parameters:kM(jM({name:Zj().describe(`The name of the parameter`),value:NM([Zj(),yM(),CM(),jM({})]).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`)})})],vN=async()=>Promise.all(_N);function yN(e,t,n,r,i=new Map){return!!(r?.supportsTools||i.get(`${t.chat(e).baseURL}-${e}`))}async function bN(e,t,n,r){let i=r?.headers;return await Xn({...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:yN(e,t,n,r)?[...await vN(),...await oN()]:void 0,onEvent(e){r?.onStreamEvent?.(e)}})}async function xN(e,t,n,r){async function i(n){try{let i=await bN(e,t,[{role:`user`,content:`Hello, world!`}],{...r,supportsTools:n});for await(let e of Ba(i.textStream));return!0}catch(e){if(e instanceof Error&&e.name===new f(``).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 SN=oe(`llm`,()=>{let e=g(new Map);async function t(t,n,r,i){if(e.value.has(`${n.chat(t).baseURL}-${t}`))return;let a=await xN(t,n,r,{...i,toolsCompatibility:e.value});e.value.set(`${n.chat(t).baseURL}-${t}`,a)}function n(t,n,r,i){return bN(t,n,r,{...i,toolsCompatibility:e.value})}async function r(e,t){if(e===``)return[];try{return await d({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}}),CN=oe(`chat`,()=>{let{stream:e,discoverToolsCompatibility:t}=SN(),{systemPrompt:n}=se(za()),r=g(!1),i=g([]),a=g([]),o=g([]),s=g([]),u=g([]),d=g([]),f=g([]),p=g([]);function m(e){i.value.push(e)}function h(e){a.value.push(e)}function ee(e){o.value.push(e)}function te(e){s.value.push(e)}function ne(e){u.value.push(e)}function re(e){d.value.push(e)}function ie(e){f.value.push(e)}function ae(e){p.value.push(e)}function oe(){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 ce=pe(`chat/messages`,[oe()]);function le(){ce.value=[oe()]}on(n,()=>{ce.value.length>0&&ce.value[0].role===`system`&&(ce.value[0]=oe())},{immediate:!0});let ue=g({role:`assistant`,content:``,slices:[],tool_results:[]});async function de(t,n){try{if(r.value=!0,!t&&!n.attachments?.length)return;for(let e of i.value)await e(t);let m=[{type:`text`,text:t}];if(n.attachments)for(let e of n.attachments)e.type===`image`&&m.push({type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}});let h=m.length>1?m:t;ce.value.push({role:`user`,content:h});let ee=cr({onLiteral:async e=>{for(let t of u.value)await t(e);ue.value.content+=e;let t=ue.value.slices.at(-1);if(t?.type===`text`){t.text+=e;return}ue.value.slices.push({type:`text`,text:e})},onSpecial:async e=>{for(let t of d.value)await t(e)},minLiteralEmitLength:24}),te=l({handlers:[async e=>{if(e.data.type===`tool-call`){ue.value.slices.push(e.data);return}e.data.type===`tool-call-result`&&ue.value.tool_results.push(e.data)}]});ue.value={role:`assistant`,content:``,slices:[],tool_results:[]};let ne=ce.value.map(e=>{if(e.role===`assistant`){let{slices:t,...n}=e;return n.tool_results=En(n.tool_results),En(n)}return En(e)});for(let e of a.value)await e(t);for(let e of o.value)await e(t);let re=``,ie=n.providerConfig?.headers||{};await e(n.model,n.chatProvider,ne,{headers:ie,async onStreamEvent(e){if(e.type===`tool-call`)te.enqueue({type:`tool-call`,toolCall:e});else if(e.type===`tool-result`)te.enqueue({type:`tool-call-result`,id:e.toolCallId,result:e.result});else if(e.type===`text-delta`)re+=e.text,await ee.consume(e.text);else if(e.type===`finish`){await ee.end(),ue.value.slices.length>0&&ce.value.push(En(ue.value)),ue.value={role:`assistant`,content:``,slices:[],tool_results:[]};let e=`${c}${c}`;for(let t of u.value)await t(e);for(let e of f.value)await e();for(let e of p.value)await e(re);console.debug(`LLM output:`,re)}}});for(let e of s.value)await e(t)}catch(e){throw console.error(`Error sending message:`,e),e}finally{r.value=!1}}return{sending:r,messages:ce,streamingMessage:ue,discoverToolsCompatibility:t,send:de,cleanupMessages:le,onBeforeMessageComposed:m,onAfterMessageComposed:h,onBeforeSend:ee,onAfterSend:te,onTokenLiteral:ne,onTokenSpecial:re,onStreamEnd:ie,onAssistantResponseEnd:ae}}),wN={relative:``},TN={"h-full":``,"w-full":``};var EN=Jt({__name:`Stage`,props:Zt({paused:{type:Boolean,default:!1},focusAt:{},xOffset:{},yOffset:{},scale:{default:1}},{state:{default:`pending`},stateModifiers:{}}),emits:[`update:state`],setup(e,{expose:c}){let d=an(e,`state`),f=g(),ee=g(),te=g(),re=me(),{stageModelRenderer:ie,stageViewControlsEnabled:ae,live2dDisableFocus:oe,stageModelSelectedUrl:ce}=se(re),{mouthOpenSize:le}=se(i()),{audioContext:ue,calculateVolume:de}=r(),{onBeforeMessageComposed:fe,onBeforeSend:pe,onTokenLiteral:he,onTokenSpecial:ge,onStreamEnd:_e,onAssistantResponseEnd:ve}=CN(),ye=u(),be=Pc(),xe=vj(),Se=g(!0);be.onShouldUpdateView(async()=>{Se.value=!1,await re.updateStageModel(),setTimeout(()=>{Se.value=!0},100)}),xe.onShouldUpdateView(async()=>{Se.value=!1,await re.updateStageModel(),setTimeout(()=>{Se.value=!0},100)});let Ce=g(),we=g(!1),Te=g(!1),Ee=null,De=l({handlers:[e=>new Promise(t=>{if(Ee){try{Ee.stop(),Ee.disconnect()}catch{}Ee=null}let n=ue.createBufferSource();n.buffer=e.data.audioBuffer,n.connect(ue.destination),n.connect(Ce.value),we.value=!0,Ee=n,n.start(0),n.onended=()=>{we.value=!1,Ee===n&&(Ee=null),t()}})]}),Oe=t(),{ssmlEnabled:ke,activeSpeechProvider:Ae,activeSpeechModel:je,activeSpeechVoice:Me,pitch:Ne}=se(Oe);async function Pe(e){try{if(!Ae.value){console.warn(`No active speech provider configured`);return}if(!Me.value){console.warn(`No active speech voice configured`);return}let t=await ye.getProviderInstance(Ae.value);if(!t){console.error(`Failed to initialize speech provider`);return}let r=ye.getProviderConfig(Ae.value),i=ke.value?Oe.generateSSML(e.data,Me.value,{...r,pitch:Ne.value}):e.data,a=await n({...t.speech(je.value,r),input:i,voice:Me.value.id}),o=await ue.decodeAudioData(a);De.enqueue({audioBuffer:o,text:e.data})}catch(e){console.error(`Speech generation failed:`,e)}}let Fe=l({handlers:[Pe]}),Ie=s(Fe),{currentMotion:Le}=se(Pc()),Re=l({handlers:[async e=>{if(ie.value===`vrm`){let t=h[e.data];if(!t)return;await ee.value.setExpression(t)}else ie.value===`live2d`&&(Le.value={group:m[e.data]})}]}),ze=o(Re);ze.onHandlerEvent(`emotion`,e=>{console.debug(`emotion detected`,e)});let Be=a();Be.onHandlerEvent(`delay`,e=>{console.debug(`delay detected`,e)});function Ve(){requestAnimationFrame(Ve),we.value&&(le.value=de(Ce.value,`linear`))}function He(){Te.value||=(Ve(),ue.resume(),!0)}function Ue(){Ce.value||=ue.createAnalyser()}fe(async()=>{if(Ee){try{Ee.stop(),Ee.disconnect()}catch{}Ee=null}De.clear(),Ue(),He()}),pe(async()=>{Le.value={group:ne}}),he(async e=>{Ie.enqueue(e)}),ge(async e=>{Be.enqueue(e),ze.enqueue(e)}),_e(async()=>{Be.enqueue(p)}),ve(async e=>{}),en(()=>{Te.value=!1}),$t(async()=>{f.value=Ok({connection:{bundles:fr()}}),await f.value.execute(`CREATE TABLE memory_test (vec FLOAT[768]);`)});function We(){if(ie.value===`live2d`)return te.value?.canvasElement();if(ie.value===`vrm`)return ee.value?.canvasElement()}return c({canvasElement:We}),(e,t)=>(tn(),Kt(`div`,wN,[Ut(`div`,TN,[On(ie)===`live2d`&&Se.value?(tn(),Wt(Rc,{key:0,ref_key:`live2dSceneRef`,ref:te,state:d.value,"onUpdate:state":t[0]||=e=>d.value=e,"min-w":`50% r.modelSrc),l=g(),u=g(),{scene:d}=We(),{onBeforeRender:f}=Ue(),p=ar(),m=g(),h=vj(),{modelOffset:ee,modelOrigin:te,modelSize:ne,cameraPosition:re,modelRotationY:ie,lookAtTarget:ae,eyeHeight:oe,trackingMode:ce,envSelect:le,skyBoxIntensity:ue}=se(h),de=g(),fe=or(),pe=g(0),me=null;async function he(){await Le(o).not.toBeTruthy(),o.value=!0,s.value=!1;try{if(!d.value){console.warn(`Scene is not ready, cannot load VRM model.`);return}if(l.value&&ve(),!c.value)return;try{let e=await nr(c.value,{scene:d.value,lookAt:!0,onProgress:e=>i(`loadModelProgress`,Number((100*e.loaded/e.total).toFixed(2)))});if(!e||!e._vrm){console.warn(`No VRM model loaded`);return}let{_vrm:t,_vrmGroup:n,modelCenter:o,modelSize:h,initialCameraOffset:se}=e;de.value=n,re.value={x:o.x+se.x,y:o.y+se.y,z:o.z+se.z},te.value={x:o.x,y:o.y,z:o.z},ne.value={x:h.x,y:h.y,z:h.z},de.value.position.set(ee.value.x,ee.value.y,ee.value.z);let le=new mn(0,0,-1),ue=t.lookAt,pe=new lt;if(ue){let e=ue.faceFront;pe.setFromUnitVectors(e.normalize(),le.normalize()),n.quaternion.premultiply(pe),n.updateMatrixWorld(!0)}else console.warn(`No look-at target found in VRM model`);ie.value=0;function he(e){let n=t.humanoid?.getNormalizedBoneNode(`hips`);if(!n){console.warn(`No hips node found in VRM model.`);return}n.updateMatrixWorld(!0);let r=new mn;n.getWorldPosition(r);let i=e.tracks.find(e=>e.name.endsWith(`Hips.position`));if(!(i instanceof gn)){console.warn(`No Hips.position track of type VectorKeyframeTrack found in animation.`);return}let a=new mn(i.values[0],i.values[1],i.values[2]),o=new mn().subVectors(a,r);e.tracks.forEach(e=>{if(e.name.endsWith(`.position`)&&e instanceof gn)for(let t=0;t!!e?.isShaderMaterial;!me&&d.value&&(me=Zn(d.value)),t.scene.traverse(e=>{if(e instanceof jt&&e.material){let t=Array.isArray(e.material)?e.material:[e.material];t.forEach(e=>{if(e instanceof It||e instanceof Ft)e.envMapIntensity=1,e.needsUpdate=!0;else if(ve(e))`toneMapped`in e&&(e.toneMapped=!1);else if(ye(e)){`toneMapped`in e&&(e.toneMapped=!1),`envMap`in e&&e.envMap&&(e.envMap=null);let t=e.map;if(t&&t.colorSpace!==void 0)try{t.colorSpace=bt}catch(e){console.warn(`Failed to set colorSpace on texture:`,e)}Qn(e)}})}}),l.value=t,i(`modelReady`),s.value=!0;function be(){let e=l.value?.humanoid?.getNormalizedBoneNode(`head`);if(!e)return null;let t=new mn;return e.getWorldPosition(t),t.y}oe.value=be(),ce.value=`none`,ae.value={x:0,y:oe.value,z:-1e3},a=f(({delta:e})=>{u.value?.update(e),l.value?.update(e),l.value?.lookAt?.update?.(e),p.update(l.value,e),fe.update(l.value,ae,e),m.value?.update(e)}).off}catch(e){i(`error`,e)}}catch(e){console.error(e)}finally{o.value=!1}}on(ee,()=>{de.value&&de.value.position.set(ee.value.x,ee.value.y,ee.value.z)},{deep:!0}),on(ie,e=>{l.value&&de.value&&(de.value.rotation.y=At.degToRad(e))}),on(c,(e,t)=>{e!==t&&he()});let{pause:ge,resume:_e}=Ue();on(()=>r.paused,e=>e?ge():_e());function ve(){a?.(),l.value&&(l.value.scene.removeFromParent(),sr.deepDispose(l.value.scene),me?.dispose())}return on(()=>[le.value,r.nprEquirectTex,ue.value,r.nprIrrSH],async()=>{if(!l.value)return;pe.value+=1;let e=$n(le.value);er(l.value?.scene,{mode:e,intensity:ue.value,sh:r.nprIrrSH??null}),me?.update(e,ue.value,r.nprIrrSH??null)},{immediate:!0,deep:!1}),$t(async()=>await he()),en(()=>ve()),t({setExpression(e){m.value?.setEmotionWithResetAfter(e,1e3)},scene:Cn(()=>l.value?.scene),lookAtUpdate(e){fe.instantUpdate(l.value,e)}}),(e,t)=>s.value?rn(e.$slots,`default`,{key:0}):Gt(``,!0)}}),kN=ON;const AN={type:`change`},jN={type:`start`},MN={type:`end`},NN=new ht,PN=new ct,FN=Math.cos(70*At.DEG2RAD),IN=new mn,LN=2*Math.PI,RN={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},zN=1e-6;var BN=class extends Se{constructor(e,t=null){super(e,t),this.state=RN.NONE,this.target=new mn,this.cursor=new mn,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,BOTTOM:`ArrowDown`},this.mouseButtons={LEFT:Ot.ROTATE,MIDDLE:Ot.DOLLY,RIGHT:Ot.PAN},this.touches={ONE:Vt.ROTATE,TWO:Vt.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new mn,this._lastQuaternion=new lt,this._lastTargetPosition=new mn,this._quat=new lt().setFromUnitVectors(e.up,new mn(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new zt,this._sphericalDelta=new zt,this._scale=1,this._panOffset=new mn,this._rotateStart=new pn,this._rotateEnd=new pn,this._rotateDelta=new pn,this._panStart=new pn,this._panEnd=new pn,this._panDelta=new pn,this._dollyStart=new pn,this._dollyEnd=new pn,this._dollyDelta=new pn,this._dollyDirection=new mn,this._mouse=new pn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=HN.bind(this),this._onPointerDown=VN.bind(this),this._onPointerUp=UN.bind(this),this._onContextMenu=XN.bind(this),this._onMouseWheel=KN.bind(this),this._onKeyDown=qN.bind(this),this._onTouchStart=JN.bind(this),this._onTouchMove=YN.bind(this),this._onMouseDown=WN.bind(this),this._onMouseMove=GN.bind(this),this._interceptControlDown=ZN.bind(this),this._interceptControlUp=QN.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointercancel`,this._onPointerUp),this.domElement.addEventListener(`contextmenu`,this._onContextMenu),this.domElement.addEventListener(`wheel`,this._onMouseWheel,{passive:!1});let t=this.domElement.getRootNode();t.addEventListener(`keydown`,this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction=`none`}disconnect(){this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.removeEventListener(`pointercancel`,this._onPointerUp),this.domElement.removeEventListener(`wheel`,this._onMouseWheel),this.domElement.removeEventListener(`contextmenu`,this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener(`keydown`,this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=`auto`}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(AN),this.update(),this.state=RN.NONE}update(e=null){let t=this.object.position;IN.copy(t).sub(this.target),IN.applyQuaternion(this._quat),this._spherical.setFromVector3(IN),this.autoRotate&&this.state===RN.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=LN:n>Math.PI&&(n-=LN),r<-Math.PI?r+=LN:r>Math.PI&&(r-=LN),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=e!=this._spherical.radius}if(IN.setFromSpherical(this._spherical),IN.applyQuaternion(this._quatInverse),t.copy(this.target).add(IN),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let e=null;if(this.object.isPerspectiveCamera){let t=IN.length();e=this._clampDistance(t*this._scale);let n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),i=!!n}else if(this.object.isOrthographicCamera){let t=new mn(this._mouse.x,this._mouse.y,0);t.unproject(this.object);let n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=n!==this.object.zoom;let r=new mn(this._mouse.x,this._mouse.y,0);r.unproject(this.object),this.object.position.sub(r).add(t),this.object.updateMatrixWorld(),e=IN.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),this.zoomToCursor=!1;e!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(NN.origin.copy(this.object.position),NN.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(NN.direction))zN||8*(1-this._lastQuaternion.dot(this.object.quaternion))>zN||this._lastTargetPosition.distanceToSquared(this.target)>zN?(this.dispatchEvent(AN),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?LN/60/60*this.autoRotateSpeed:LN/60*this.autoRotateSpeed*e}_getZoomScale(e){let t=Math.abs(e*.01);return .95**(this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){IN.setFromMatrixColumn(t,0),IN.multiplyScalar(-e),this._panOffset.add(IN)}_panUp(e,t){this.screenSpacePanning===!0?IN.setFromMatrixColumn(t,1):(IN.setFromMatrixColumn(t,0),IN.crossVectors(this.object.up,IN)),IN.multiplyScalar(e),this._panOffset.add(IN)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;IN.copy(r).sub(this.target);let i=IN.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),r=e-n.left,i=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(i/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(LN*this._rotateDelta.x/t.clientHeight),this._rotateUp(LN*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(LN*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-LN*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(LN*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-LN*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(LN*this._rotateDelta.x/t.clientHeight),this._rotateUp(LN*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),this._dollyDelta.set(0,(this._dollyEnd.y/this._dollyStart.y)**+this.zoomSpeed),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t{n.value&&r.value?.domElement&&(i.value=new BN(n.value,r.value.domElement),i.value.enableDamping=!0,i.value.dampingFactor=.5,i.value.mouseButtons={LEFT:Ot.ROTATE,MIDDLE:Ot.DOLLY,RIGHT:Ot.PAN},i.value.touches={ONE:Vt.ROTATE,TWO:Vt.DOLLY_PAN},i.value.enablePan=!1,i.value.minDistance=a.value.z,i.value.maxDistance=a.value.z*20,i.value.update(),o.value=i.value.getDistance())}),t({controls:i,getDistance:()=>i.value?.getDistance(),update:()=>i.value?.update(),setTarget:e=>{i.value&&(i.value.target.set(e.x,e.y,e.z),i.value.update())}}),(e,t)=>rn(e.$slots,`default`)}}),eP=$N;export{DN as b,CN as c,wj as d,vj as e,wT as f,Fw as g,Cw as h,Rc as i,Ic as j,Pc as k,Ha as l}; \ No newline at end of file