diff --git "a/assets/Scenes-CzNcBtyx.js" "b/assets/Scenes-CzNcBtyx.js" new file mode 100644--- /dev/null +++ "b/assets/Scenes-CzNcBtyx.js" @@ -0,0 +1,3157 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-DAzMqf4J.js","assets/index-DkYFrtmz.js","assets/index-C0W5FJsM.css","assets/default-node-KCowvLjx.js","assets/import-url-browser-agSP1LkN.js","assets/import-url-browser-CQxpIBxI.js","assets/duckdb-mvp-DkPAVKN8.js","assets/import-url-node-DsdDfn-V.js"])))=>i.map(i=>d[i]); +import{G as e,I as t,J as n,Y as r,ac as i,ae as a,af as o,ag as s,ah as c,ai as l,ap as u,b$ as d,bB as f,bL as p,bM as m,bN as h,bO as g,bP as _,bQ as v,bR as y,bS as b,bT as x,bX as S,bZ as C,b_ as w,bo as T,bp as E,bq as D,br as O,bs as k,bt as A,bv as j,bx as M,by as N,c as ee,c$ as P,c1 as F,c3 as I,c4 as L,c7 as te,c8 as ne,c9 as re,cJ as ie,cO as ae,cP as oe,cR as se,cS as ce,cV as le,cW as ue,cX as de,cY as fe,ca as pe,cb as me,cd as he,ce as ge,cf as _e,cg as ve,ch as ye,ci as be,cj as xe,ck as Se,cl as Ce,cm as we,co as Te,cq as Ee,cs as De,cu as Oe,cv as ke,cw as Ae,cz as je,d0 as Me,d1 as Ne,d2 as Pe,d3 as Fe,d4 as Ie,d5 as Le,d7 as Re,dA as ze,dB as Be,dF as Ve,dG as He,dI as Ue,dK as We,dP as Ge,dQ as Ke,dR as qe,dS as Je,dT as Ye,dU as Xe,dV as Ze,dW as Qe,dX as $e,dY as et,dZ as tt,d_ 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,e3 as St,e6 as Ct,e8 as wt,e9 as Tt,eA as Et,eB as Dt,eC as Ot,eE as R,eF as kt,eG as At,eH as jt,eJ as Mt,eL as Nt,eO as Pt,eQ as Ft,eR as It,eT as Lt,eU as Rt,ea as zt,eb as Bt,ec as Vt,ed as Ht,eg as Ut,eh as Wt,ei as Gt,ek as Kt,eo as qt,ep as Jt,eq as Yt,er as Xt,es as Zt,eu as Qt,ez as $t,m as en,n as tn,q as nn,r as rn,s as an,t as on,u as sn,v as cn,w as ln}from"./index-DkYFrtmz.js";import{b as un}from"./dist-BC1v5_Pa.js";import{b as dn,c as fn,d as pn,e as mn,f as hn,g as gn,h as _n,i as vn,j as yn,k as bn,l as xn}from"./expression-VxmeeMIB.js";import{b as Sn}from"./import-url-browser-CQxpIBxI.js";import{c as Cn,d as wn}from"./index-CAcLDIRJ-BJMh21ra.js";import{$ as Tn,A as En,B as Dn,C as On,D as kn,E as An,F as jn,G as Mn,H as Nn,I as Pn,J as Fn,K as In,L as Ln,M as Rn,N as zn,O as Bn,P as Vn,Q as Hn,R as Un,S as Wn,T as Gn,U as Kn,V as qn,W as Jn,X as Yn,Y as Xn,Z as Zn,_ as Qn,a1 as $n,a2 as er,a3 as tr,a4 as nr,a6 as rr,a8 as ir,a9 as ar,aA as or,aB as sr,aC as cr,aE as lr,aF as ur,aG as dr,aH as fr,aI as pr,aJ as mr,aK as hr,aL as gr,aM as _r,aN as vr,aO as yr,aP as br,aQ as xr,aR as Sr,aS as Cr,aa as wr,ab as Tr,ac as Er,ad as Dr,ae as Or,af as kr,ag as Ar,ah as jr,ai as Mr,aj as Nr,ak as Pr,al as Fr,am as Ir,an as Lr,ao as Rr,ap as zr,aq as Br,ar as Vr,as as Hr,at as Ur,au as Wr,av as Gr,aw as Kr,ax as qr,ay as Jr,az as Yr,bA as Xr,bB as Zr,bC as Qr,bD as $r,bE as ei,bF as ti,bG as ni,bH as ri,bI as ii,bK as ai,bL as oi,bc as si,bd as ci,be as li,bf as ui,bg as di,bh as fi,bi as pi,bj as mi,bk as hi,bl as gi,bm as _i,bn as vi,bq as yi,bs as bi,bt as xi,bu as Si,bv as Ci,bw as wi,bx as Ti,by as Ei,bz as Di,d as Oi,e as ki,f as Ai,g as ji,i as Mi,j as Ni,k as Pi,l as Fi,m as Ii,n as Li,o as Ri,p as zi,q as Bi,r as Vi,s as Hi,t as Ui,u as Wi,v as Gi,w as Ki,x as qi,y as Ji,z as Yi}from"./core-DeVZ8oOh.js";import{b as Xi}from"./airi-card-D5qc0j0Z.js";async function*Zi(e){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}} +/*! +* @pixi/constants - v6.5.10 +* Compiled Thu, 06 Jul 2023 15:25:11 UTC +* +* @pixi/constants is licensed under the MIT License. +* http://www.opensource.org/licenses/mit-license +*/ +var Qi;(function(e){e[e.WEBGL_LEGACY=0]=`WEBGL_LEGACY`,e[e.WEBGL=1]=`WEBGL`,e[e.WEBGL2=2]=`WEBGL2`})(Qi||={});var $i;(function(e){e[e.UNKNOWN=0]=`UNKNOWN`,e[e.WEBGL=1]=`WEBGL`,e[e.CANVAS=2]=`CANVAS`})($i||={});var ea;(function(e){e[e.COLOR=16384]=`COLOR`,e[e.DEPTH=256]=`DEPTH`,e[e.STENCIL=1024]=`STENCIL`})(ea||={});var ta;(function(e){e[e.NORMAL=0]=`NORMAL`,e[e.ADD=1]=`ADD`,e[e.MULTIPLY=2]=`MULTIPLY`,e[e.SCREEN=3]=`SCREEN`,e[e.OVERLAY=4]=`OVERLAY`,e[e.DARKEN=5]=`DARKEN`,e[e.LIGHTEN=6]=`LIGHTEN`,e[e.COLOR_DODGE=7]=`COLOR_DODGE`,e[e.COLOR_BURN=8]=`COLOR_BURN`,e[e.HARD_LIGHT=9]=`HARD_LIGHT`,e[e.SOFT_LIGHT=10]=`SOFT_LIGHT`,e[e.DIFFERENCE=11]=`DIFFERENCE`,e[e.EXCLUSION=12]=`EXCLUSION`,e[e.HUE=13]=`HUE`,e[e.SATURATION=14]=`SATURATION`,e[e.COLOR=15]=`COLOR`,e[e.LUMINOSITY=16]=`LUMINOSITY`,e[e.NORMAL_NPM=17]=`NORMAL_NPM`,e[e.ADD_NPM=18]=`ADD_NPM`,e[e.SCREEN_NPM=19]=`SCREEN_NPM`,e[e.NONE=20]=`NONE`,e[e.SRC_OVER=0]=`SRC_OVER`,e[e.SRC_IN=21]=`SRC_IN`,e[e.SRC_OUT=22]=`SRC_OUT`,e[e.SRC_ATOP=23]=`SRC_ATOP`,e[e.DST_OVER=24]=`DST_OVER`,e[e.DST_IN=25]=`DST_IN`,e[e.DST_OUT=26]=`DST_OUT`,e[e.DST_ATOP=27]=`DST_ATOP`,e[e.ERASE=26]=`ERASE`,e[e.SUBTRACT=28]=`SUBTRACT`,e[e.XOR=29]=`XOR`})(ta||={});var na;(function(e){e[e.POINTS=0]=`POINTS`,e[e.LINES=1]=`LINES`,e[e.LINE_LOOP=2]=`LINE_LOOP`,e[e.LINE_STRIP=3]=`LINE_STRIP`,e[e.TRIANGLES=4]=`TRIANGLES`,e[e.TRIANGLE_STRIP=5]=`TRIANGLE_STRIP`,e[e.TRIANGLE_FAN=6]=`TRIANGLE_FAN`})(na||={});var z;(function(e){e[e.RGBA=6408]=`RGBA`,e[e.RGB=6407]=`RGB`,e[e.RG=33319]=`RG`,e[e.RED=6403]=`RED`,e[e.RGBA_INTEGER=36249]=`RGBA_INTEGER`,e[e.RGB_INTEGER=36248]=`RGB_INTEGER`,e[e.RG_INTEGER=33320]=`RG_INTEGER`,e[e.RED_INTEGER=36244]=`RED_INTEGER`,e[e.ALPHA=6406]=`ALPHA`,e[e.LUMINANCE=6409]=`LUMINANCE`,e[e.LUMINANCE_ALPHA=6410]=`LUMINANCE_ALPHA`,e[e.DEPTH_COMPONENT=6402]=`DEPTH_COMPONENT`,e[e.DEPTH_STENCIL=34041]=`DEPTH_STENCIL`})(z||={});var ra;(function(e){e[e.TEXTURE_2D=3553]=`TEXTURE_2D`,e[e.TEXTURE_CUBE_MAP=34067]=`TEXTURE_CUBE_MAP`,e[e.TEXTURE_2D_ARRAY=35866]=`TEXTURE_2D_ARRAY`,e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]=`TEXTURE_CUBE_MAP_POSITIVE_X`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]=`TEXTURE_CUBE_MAP_NEGATIVE_X`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]=`TEXTURE_CUBE_MAP_POSITIVE_Y`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]=`TEXTURE_CUBE_MAP_NEGATIVE_Y`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]=`TEXTURE_CUBE_MAP_POSITIVE_Z`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]=`TEXTURE_CUBE_MAP_NEGATIVE_Z`})(ra||={});var ia;(function(e){e[e.UNSIGNED_BYTE=5121]=`UNSIGNED_BYTE`,e[e.UNSIGNED_SHORT=5123]=`UNSIGNED_SHORT`,e[e.UNSIGNED_SHORT_5_6_5=33635]=`UNSIGNED_SHORT_5_6_5`,e[e.UNSIGNED_SHORT_4_4_4_4=32819]=`UNSIGNED_SHORT_4_4_4_4`,e[e.UNSIGNED_SHORT_5_5_5_1=32820]=`UNSIGNED_SHORT_5_5_5_1`,e[e.UNSIGNED_INT=5125]=`UNSIGNED_INT`,e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]=`UNSIGNED_INT_10F_11F_11F_REV`,e[e.UNSIGNED_INT_2_10_10_10_REV=33640]=`UNSIGNED_INT_2_10_10_10_REV`,e[e.UNSIGNED_INT_24_8=34042]=`UNSIGNED_INT_24_8`,e[e.UNSIGNED_INT_5_9_9_9_REV=35902]=`UNSIGNED_INT_5_9_9_9_REV`,e[e.BYTE=5120]=`BYTE`,e[e.SHORT=5122]=`SHORT`,e[e.INT=5124]=`INT`,e[e.FLOAT=5126]=`FLOAT`,e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]=`FLOAT_32_UNSIGNED_INT_24_8_REV`,e[e.HALF_FLOAT=36193]=`HALF_FLOAT`})(ia||={});var aa;(function(e){e[e.FLOAT=0]=`FLOAT`,e[e.INT=1]=`INT`,e[e.UINT=2]=`UINT`})(aa||={});var oa;(function(e){e[e.NEAREST=0]=`NEAREST`,e[e.LINEAR=1]=`LINEAR`})(oa||={});var sa;(function(e){e[e.CLAMP=33071]=`CLAMP`,e[e.REPEAT=10497]=`REPEAT`,e[e.MIRRORED_REPEAT=33648]=`MIRRORED_REPEAT`})(sa||={});var ca;(function(e){e[e.OFF=0]=`OFF`,e[e.POW2=1]=`POW2`,e[e.ON=2]=`ON`,e[e.ON_MANUAL=3]=`ON_MANUAL`})(ca||={});var la;(function(e){e[e.NPM=0]=`NPM`,e[e.UNPACK=1]=`UNPACK`,e[e.PMA=2]=`PMA`,e[e.NO_PREMULTIPLIED_ALPHA=0]=`NO_PREMULTIPLIED_ALPHA`,e[e.PREMULTIPLY_ON_UPLOAD=1]=`PREMULTIPLY_ON_UPLOAD`,e[e.PREMULTIPLY_ALPHA=2]=`PREMULTIPLY_ALPHA`,e[e.PREMULTIPLIED_ALPHA=2]=`PREMULTIPLIED_ALPHA`})(la||={});var ua;(function(e){e[e.NO=0]=`NO`,e[e.YES=1]=`YES`,e[e.AUTO=2]=`AUTO`,e[e.BLEND=0]=`BLEND`,e[e.CLEAR=1]=`CLEAR`,e[e.BLIT=2]=`BLIT`})(ua||={});var da;(function(e){e[e.AUTO=0]=`AUTO`,e[e.MANUAL=1]=`MANUAL`})(da||={});var fa;(function(e){e.LOW=`lowp`,e.MEDIUM=`mediump`,e.HIGH=`highp`})(fa||={});var pa;(function(e){e[e.NONE=0]=`NONE`,e[e.SCISSOR=1]=`SCISSOR`,e[e.STENCIL=2]=`STENCIL`,e[e.SPRITE=3]=`SPRITE`,e[e.COLOR=4]=`COLOR`})(pa||={});var ma;(function(e){e[e.RED=1]=`RED`,e[e.GREEN=2]=`GREEN`,e[e.BLUE=4]=`BLUE`,e[e.ALPHA=8]=`ALPHA`})(ma||={});var ha;(function(e){e[e.NONE=0]=`NONE`,e[e.LOW=2]=`LOW`,e[e.MEDIUM=4]=`MEDIUM`,e[e.HIGH=8]=`HIGH`})(ha||={});var ga;(function(e){e[e.ELEMENT_ARRAY_BUFFER=34963]=`ELEMENT_ARRAY_BUFFER`,e[e.ARRAY_BUFFER=34962]=`ARRAY_BUFFER`,e[e.UNIFORM_BUFFER=35345]=`UNIFORM_BUFFER`})(ga||={});var _a={createCanvas:function(e,t){var n=document.createElement(`canvas`);return n.width=e,n.height=t,n},getWebGLRenderingContext:function(){return WebGLRenderingContext},getNavigator:function(){return navigator},getBaseUrl:function(){var e;return(e=document.baseURI)??window.location.href},fetch:function(e,t){return fetch(e,t)}},va=/iPhone/i,ya=/iPod/i,ba=/iPad/i,xa=/\biOS-universal(?:.+)Mac\b/i,Sa=/\bAndroid(?:.+)Mobile\b/i,Ca=/Android/i,wa=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Ta=/Silk/i,Ea=/Windows Phone/i,Da=/\bWindows(?:.+)ARM\b/i,Oa=/BlackBerry/i,ka=/BB10/i,Aa=/Opera Mini/i,ja=/\b(CriOS|Chrome)(?:.+)Mobile/i,Ma=/Mobile(?:.+)Firefox\b/i,Na=function(e){return e!==void 0&&e.platform===`MacIntel`&&typeof e.maxTouchPoints==`number`&&e.maxTouchPoints>1&&typeof MSStream>`u`};function Pa(e){return function(t){return t.test(e)}}function Fa(e){var t={userAgent:``,platform:``,maxTouchPoints:0};!e&&typeof navigator<`u`?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e==`string`?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});var n=t.userAgent,r=n.split(`[FBAN`);r[1]!==void 0&&(n=r[0]),r=n.split(`Twitter`),r[1]!==void 0&&(n=r[0]);var i=Pa(n),a={apple:{phone:i(va)&&!i(Ea),ipod:i(ya),tablet:!i(va)&&(i(ba)||Na(t))&&!i(Ea),universal:i(xa),device:(i(va)||i(ya)||i(ba)||i(xa)||Na(t))&&!i(Ea)},amazon:{phone:i(wa),tablet:!i(wa)&&i(Ta),device:i(wa)||i(Ta)},android:{phone:!i(Ea)&&i(wa)||!i(Ea)&&i(Sa),tablet:!i(Ea)&&!i(wa)&&!i(Sa)&&(i(Ta)||i(Ca)),device:!i(Ea)&&(i(wa)||i(Ta)||i(Sa)||i(Ca))||i(/\bokhttp\b/i)},windows:{phone:i(Ea),tablet:i(Da),device:i(Ea)||i(Da)},other:{blackberry:i(Oa),blackberry10:i(ka),opera:i(Aa),firefox:i(Ma),chrome:i(ja),device:i(Oa)||i(ka)||i(Aa)||i(Ma)||i(ja)},any:!1,phone:!1,tablet:!1};return a.any=a.apple.device||a.android.device||a.windows.device||a.other.device,a.phone=a.apple.phone||a.android.phone||a.windows.phone,a.tablet=a.apple.tablet||a.android.tablet||a.windows.tablet,a}var Ia=Fa(globalThis.navigator);function La(){return!Ia.apple.device}function Ra(e){var t=!0;if(Ia.tablet||Ia.phone){if(Ia.apple.device){var n=navigator.userAgent.match(/OS (\d+)_(\d+)?/);if(n){var r=parseInt(n[1],10);r<11&&(t=!1)}}if(Ia.android.device){var n=navigator.userAgent.match(/Android\s([0-9.]*)/);if(n){var r=parseInt(n[1],10);r<7&&(t=!1)}}}return t?e:4}var B={ADAPTER:_a,MIPMAP_TEXTURES:ca.POW2,ANISOTROPIC_LEVEL:0,RESOLUTION:1,FILTER_RESOLUTION:1,FILTER_MULTISAMPLE:ha.NONE,SPRITE_MAX_TEXTURES:Ra(32),SPRITE_BATCH_SIZE:4096,RENDER_OPTIONS:{view:null,width:800,height:600,autoDensity:!1,backgroundColor:0,backgroundAlpha:1,useContextAlpha:!0,clearBeforeRender:!0,antialias:!1,preserveDrawingBuffer:!1},GC_MODE:da.AUTO,GC_MAX_IDLE:3600,GC_MAX_CHECK_COUNT:600,WRAP_MODE:sa.CLAMP,SCALE_MODE:oa.LINEAR,PRECISION_VERTEX:fa.HIGH,PRECISION_FRAGMENT:Ia.apple.device?fa.HIGH:fa.MEDIUM,CAN_UPLOAD_SAME_BUFFER:La(),CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1},za=Pt(((exports,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i{t.exports=n,t.exports.default=n;function n(e,t,n){n||=2;var i=t&&t.length,o=i?t[0]*n:e.length,s=r(e,0,o,n,!0),c=[];if(!s||s.next===s.prev)return c;var l,d,f,p,m,h,g;if(i&&(s=u(e,t,s,n)),e.length>80*n){l=f=e[0],d=p=e[1];for(var _=n;_f&&(f=m),h>p&&(p=h);g=Math.max(f-l,p-d),g=g===0?0:32767/g}return a(s,c,n,l,d,g,0),c}function r(e,t,n,r,i){var a,o;if(i===N(e,t,n,r)>0)for(a=t;a=t;a-=r)o=A(a,e[a],e[a+1],o);return o&&S(o,o.next)&&(j(o),o=o.next),o}function i(e,t){if(!e)return e;t||=e;var n=e,r;do if(r=!1,!n.steiner&&(S(n,n.next)||x(n.prev,n,n.next)===0)){if(j(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function a(e,t,n,r,u,d,f){if(e){!f&&d&&h(e,r,u,d);for(var p=e,m,g;e.prev!==e.next;){if(m=e.prev,g=e.next,d?s(e,r,u,d):o(e)){t.push(m.i/n|0),t.push(e.i/n|0),t.push(g.i/n|0),j(e),e=g.next,p=g.next;continue}if(e=g,e===p){f?f===1?(e=c(i(e),t,n),a(e,t,n,r,u,d,2)):f===2&&l(e,t,n,r,u,d):a(i(e),t,n,r,u,d,1);break}}}}function o(e){var t=e.prev,n=e,r=e.next;if(x(t,n,r)>=0)return!1;for(var i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=ia?i>o?i:o:a>o?a:o,p=s>c?s>l?s:l:c>l?c:l,m=r.next;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&y(i,s,a,c,o,l,m.x,m.y)&&x(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function s(e,t,n,r){var i=e.prev,a=e,o=e.next;if(x(i,a,o)>=0)return!1;for(var s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=sc?s>l?s:l:c>l?c:l,g=u>d?u>f?u:f:d>f?d:f,v=_(p,m,t,n,r),b=_(h,g,t,n,r),S=e.prevZ,C=e.nextZ;S&&S.z>=v&&C&&C.z<=b;){if(S.x>=p&&S.x<=h&&S.y>=m&&S.y<=g&&S!==i&&S!==o&&y(s,u,c,d,l,f,S.x,S.y)&&x(S.prev,S,S.next)>=0||(S=S.prevZ,C.x>=p&&C.x<=h&&C.y>=m&&C.y<=g&&C!==i&&C!==o&&y(s,u,c,d,l,f,C.x,C.y)&&x(C.prev,C,C.next)>=0))return!1;C=C.nextZ}for(;S&&S.z>=v;){if(S.x>=p&&S.x<=h&&S.y>=m&&S.y<=g&&S!==i&&S!==o&&y(s,u,c,d,l,f,S.x,S.y)&&x(S.prev,S,S.next)>=0)return!1;S=S.prevZ}for(;C&&C.z<=b;){if(C.x>=p&&C.x<=h&&C.y>=m&&C.y<=g&&C!==i&&C!==o&&y(s,u,c,d,l,f,C.x,C.y)&&x(C.prev,C,C.next)>=0)return!1;C=C.nextZ}return!0}function c(e,t,n){var r=e;do{var a=r.prev,o=r.next.next;!S(a,o)&&C(a,r,r.next,o)&&D(a,o)&&D(o,a)&&(t.push(a.i/n|0),t.push(r.i/n|0),t.push(o.i/n|0),j(r),j(r.next),r=e=o),r=r.next}while(r!==e);return i(r)}function l(e,t,n,r,o,s){var c=e;do{for(var l=c.next.next;l!==c.prev;){if(c.i!==l.i&&b(c,l)){var u=k(c,l);c=i(c,c.next),u=i(u,u.next),a(c,t,n,r,o,s,0),a(u,t,n,r,o,s,0);return}l=l.next}c=c.next}while(c!==e)}function u(e,t,n,i){var a=[],o,s,c,l,u;for(o=0,s=t.length;o=n.next.y&&n.next.y!==n.y){var s=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=r&&s>a&&(a=s,o=n.x=n.x&&n.x>=l&&r!==n.x&&y(io.x||n.x===o.x&&m(o,n)))&&(o=n,d=f)),n=n.next;while(n!==c);return o}function m(e,t){return x(e.prev,e,t.prev)<0&&x(t.next,e,e.next)<0}function h(e,t,n,r){var i=e;do i.z===0&&(i.z=_(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,g(i)}function g(e){var t,n,r,i,a,o,s,c,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,r=n,s=0,t=0;t0||c>0&&r;)s!==0&&(c===0||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1);return e}function _(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function v(e){var t=e,n=e;do(t.x=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function b(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!E(e,t)&&(D(e,t)&&D(t,e)&&O(e,t)&&(x(e.prev,e,t.prev)||x(e,t.prev,t))||S(e,t)&&x(e.prev,e,e.next)>0&&x(t.prev,t,t.next)>0)}function x(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function S(e,t){return e.x===t.x&&e.y===t.y}function C(e,t,n,r){var i=T(x(e,t,n)),a=T(x(e,t,r)),o=T(x(n,r,e)),s=T(x(n,r,t));return!!(i!==a&&o!==s||i===0&&w(e,n,t)||a===0&&w(e,r,t)||o===0&&w(n,e,r)||s===0&&w(n,t,r))}function w(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function T(e){return e>0?1:e<0?-1:0}function E(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&C(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function D(e,t){return x(e.prev,e,e.next)<0?x(e,t,e.next)>=0&&x(e,e.prev,t)>=0:x(e,t,e.prev)<0||x(e,e.next,t)<0}function O(e,t){var n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function k(e,t){var n=new M(e.i,e.x,e.y),r=new M(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function A(e,t,n,r){var i=new M(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function j(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function M(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}n.deviation=function(e,t,n,r){var i=t&&t.length,a=i?t[0]*n:e.length,o=Math.abs(N(e,0,a,n));if(i)for(var s=0,c=t.length;s0&&(r+=e[i-1].length,n.holes.push(r))}return n}})),Va=Pt(((exports,t)=>{(function(n){var r=typeof exports==`object`&&exports&&!exports.nodeType&&exports,i=typeof t==`object`&&t&&!t.nodeType&&t,a=typeof global==`object`&&global;(a.global===a||a.window===a||a.self===a)&&(n=a);var o,s=2147483647,c=36,l=1,u=26,d=38,f=700,p=72,m=128,h=`-`,g=/^xn--/,_=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,y={overflow:`Overflow: input needs wider integers to process`,"not-basic":`Illegal input >= 0x80 (not a basic code point)`,"invalid-input":`Invalid input`},b=c-l,x=Math.floor,S=String.fromCharCode,C;function w(e){throw RangeError(y[e])}function T(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function E(e,t){var n=e.split(`@`),r=``;n.length>1&&(r=n[0]+`@`,e=n[1]),e=e.replace(v,`.`);var i=e.split(`.`),a=T(i,t).join(`.`);return r+a}function D(e){for(var t=[],n=0,r=e.length,i,a;n=55296&&i<=56319&&n65535&&(e-=65536,t+=S(e>>>10&1023|55296),e=56320|e&1023),t+=S(e),t}).join(``)}function k(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:c}function A(e,t){return e+22+75*(e<26)-((t!=0)<<5)}function j(e,t,n){var r=0;for(e=n?x(e/f):e>>1,e+=x(e/t);e>b*u>>1;r+=c)e=x(e/b);return x(r+(b+1)*e/(e+d))}function M(e){var t=[],n=e.length,r,i=0,a=m,o=p,d,f,g,_,v,y,b,S,C;for(d=e.lastIndexOf(h),d<0&&(d=0),f=0;f=128&&w(`not-basic`),t.push(e.charCodeAt(f));for(g=d>0?d+1:0;g=n&&w(`invalid-input`),b=k(e.charCodeAt(g++)),(b>=c||b>x((s-i)/v))&&w(`overflow`),i+=b*v,S=y<=o?l:y>=o+u?u:y-o,!(bx(s/C)&&w(`overflow`),v*=C;r=t.length+1,o=j(i-_,r,_==0),x(i/r)>s-a&&w(`overflow`),a+=x(i/r),i%=r,t.splice(i++,0,a)}return O(t)}function N(e){var t,n,r,i,a,o,d,f,g,_,v,y=[],b,C,T,E;for(e=D(e),b=e.length,t=m,n=0,a=p,o=0;o=t&&vx((s-n)/C)&&w(`overflow`),n+=(d-t)*C,t=d,o=0;os&&w(`overflow`),v==t){for(f=n,g=c;_=g<=a?l:g>=a+u?u:g-a,!(f<_);g+=c)E=f-_,T=c-_,y.push(S(A(_+E%T,0))),f=x(E/T);y.push(S(A(f,0))),a=j(n,C,r==i),n=0,++r}++n,++t}return y.join(``)}function ee(e){return E(e,function(e){return g.test(e)?M(e.slice(4).toLowerCase()):e})}function P(e){return E(e,function(e){return _.test(e)?`xn--`+N(e):e})}if(o={version:`1.4.1`,ucs2:{decode:D,encode:O},decode:M,encode:N,toASCII:P,toUnicode:ee},typeof define==`function`&&typeof define.amd==`object`&&define.amd)define(`punycode`,function(){return o});else if(r&&i)if(t.exports==r)i.exports=o;else for(C in o)o.hasOwnProperty(C)&&(r[C]=o[C]);else n.punycode=o})(exports)})),Ha=Pt(((exports,t)=>{Object.defineProperty(exports,`__esModule`,{value:!0});function n(){let e,t,n=n=>{if(n&&(typeof n==`object`||typeof n==`function`)){if(e)return e.get(n)}else if(t)return t.get(n)},r=(n,r)=>{n&&(typeof n==`object`||typeof n==`function`)?(e||=new WeakMap,e.set(n,r)):(t||=new Map,t.set(n,r))},i=n=>{if(n&&(typeof n==`object`||typeof n==`function`)){if(e)return e.has(n)}else if(t)return t.has(n);return!1},a=e=>{if(!i(e))throw TypeError(`Side channel does not contain the given key`)};return{get:n,set:r,has:i,assert:a}}exports.default=n,(typeof exports.default==`object`&&exports.default!==null||typeof exports.default==`function`)&&(Object.assign(exports.default,exports),t.exports=exports.default)})),Ua=Pt(((exports,t)=>{var n=String.prototype.replace,r=/%20/g,i={RFC1738:`RFC1738`,RFC3986:`RFC3986`};t.exports={default:i.RFC3986,formatters:{RFC1738:function(e){return n.call(e,r,`+`)},RFC3986:function(e){return String(e)}},RFC1738:i.RFC1738,RFC3986:i.RFC3986}})),Wa=Pt(((exports,t)=>{var n=Ua(),r=Object.prototype.hasOwnProperty,i=Array.isArray,a=function(){for(var e=[],t=0;t<256;++t)e.push(`%`+((t<16?`0`:``)+t.toString(16)).toUpperCase());return e}(),o=function(e){for(;e.length>1;){var t=e.pop(),n=t.obj[t.prop];if(i(n)){for(var r=[],a=0;a=d?s.slice(l,l+d):s,f=[],p=0;p=48&&m<=57||m>=65&&m<=90||m>=97&&m<=122||o===n.RFC1738&&(m===40||m===41)){f[f.length]=u.charAt(p);continue}if(m<128){f[f.length]=a[m];continue}if(m<2048){f[f.length]=a[192|m>>6]+a[128|m&63];continue}if(m<55296||m>=57344){f[f.length]=a[224|m>>12]+a[128|m>>6&63]+a[128|m&63];continue}p+=1,m=65536+((m&1023)<<10|u.charCodeAt(p)&1023),f[f.length]=a[240|m>>18]+a[128|m>>12&63]+a[128|m>>6&63]+a[128|m&63]}c+=f.join(``)}return c},p=function(e){for(var t=[{obj:{o:e},prop:`o`}],n=[],r=0;r{var n=Ha(),r=Wa(),i=Ua(),a=Object.prototype.hasOwnProperty,o={brackets:function(e){return e+`[]`},comma:`comma`,indices:function(e,t){return e+`[`+t+`]`},repeat:function(e){return e}},s=Array.isArray,c=Array.prototype.push,l=function(e,t){c.apply(e,s(t)?t:[t])},u=Date.prototype.toISOString,d=i.default,f={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:`indices`,charset:`utf-8`,charsetSentinel:!1,commaRoundTrip:!1,delimiter:`&`,encode:!0,encodeDotInKeys:!1,encoder:r.encode,encodeValuesOnly:!1,filter:void 0,format:d,formatter:i.formatters[d],indices:!1,serializeDate:function(e){return u.call(e)},skipNulls:!1,strictNullHandling:!1},p=function(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`symbol`||typeof e==`bigint`},m={},h=function e(t,i,a,o,c,u,d,h,g,_,v,y,b,x,S,C,w,T){for(var E=t,D=T,O=0,k=!1;(D=D.get(m))!==void 0&&!k;){var A=D.get(t);if(O+=1,A!==void 0){if(A===O)throw RangeError(`Cyclic object value`);k=!0}D.get(m)===void 0&&(O=0)}if(typeof _==`function`?E=_(i,E):E instanceof Date?E=b(E):a===`comma`&&s(E)&&(E=r.maybeMap(E,function(e){return e instanceof Date?b(e):e})),E===null){if(u)return g&&!C?g(i,f.encoder,w,`key`,x):i;E=``}if(p(E)||r.isBuffer(E)){if(g){var j=C?i:g(i,f.encoder,w,`key`,x);return[S(j)+`=`+S(g(E,f.encoder,w,`value`,x))]}return[S(i)+`=`+S(String(E))]}var M=[];if(E===void 0)return M;var N;if(a===`comma`&&s(E))C&&g&&(E=r.maybeMap(E,g)),N=[{value:E.length>0?E.join(`,`)||null:void 0}];else if(s(_))N=_;else{var ee=Object.keys(E);N=v?ee.sort(v):ee}var P=h?String(i).replace(/\./g,`%2E`):String(i),F=o&&s(E)&&E.length===1?P+`[]`:P;if(c&&s(E)&&E.length===0)return F+`[]`;for(var I=0;I0?b+y:``}})),Ka=Pt(((exports,t)=>{var n=Wa(),r=Object.prototype.hasOwnProperty,i=Array.isArray,a={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:`utf-8`,charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:n.decode,delimiter:`&`,depth:5,duplicates:`combine`,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},o=function(e){return e.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},s=function(e,t,n){if(e&&typeof e==`string`&&t.comma&&e.indexOf(`,`)>-1)return e.split(`,`);if(t.throwOnLimitExceeded&&n>=t.arrayLimit)throw RangeError(`Array limit exceeded. Only `+t.arrayLimit+` element`+(t.arrayLimit===1?``:`s`)+` allowed in an array.`);return e},c=`utf8=%26%2310003%3B`,l=`utf8=%E2%9C%93`,u=function(e,t){var u={__proto__:null},d=t.ignoreQueryPrefix?e.replace(/^\?/,``):e;d=d.replace(/%5B/gi,`[`).replace(/%5D/gi,`]`);var f=t.parameterLimit===1/0?void 0:t.parameterLimit,p=d.split(t.delimiter,t.throwOnLimitExceeded?f+1:f);if(t.throwOnLimitExceeded&&p.length>f)throw RangeError(`Parameter limit exceeded. Only `+f+` parameter`+(f===1?``:`s`)+` allowed.`);var m=-1,h,g=t.charset;if(t.charsetSentinel)for(h=0;h-1&&(x=i(x)?[x]:x);var S=r.call(u,b);S&&t.duplicates===`combine`?u[b]=n.combine(u[b],x):(!S||t.duplicates===`last`)&&(u[b]=x)}return u},d=function(e,t,r,i){var a=0;if(e.length>0&&e[e.length-1]===`[]`){var o=e.slice(0,-1).join(``);a=Array.isArray(t)&&t[o]?t[o].length:0}for(var c=i?t:s(t,r,a),l=e.length-1;l>=0;--l){var u,d=e[l];if(d===`[]`&&r.parseArrays)u=r.allowEmptyArrays&&(c===``||r.strictNullHandling&&c===null)?[]:n.combine([],c);else{u=r.plainObjects?{__proto__:null}:{};var f=d.charAt(0)===`[`&&d.charAt(d.length-1)===`]`?d.slice(1,-1):d,p=r.decodeDotInKeys?f.replace(/%2E/g,`.`):f,m=parseInt(p,10);!r.parseArrays&&p===``?u={0:c}:!isNaN(m)&&d!==p&&String(m)===p&&m>=0&&r.parseArrays&&m<=r.arrayLimit?(u=[],u[m]=c):p!==`__proto__`&&(u[p]=c)}c=u}return c},f=function(e,t,n,i){if(e){var a=n.allowDots?e.replace(/\.([^.[]+)/g,`[$1]`):e,o=/(\[[^[\]]*])/,s=/(\[[^[\]]*])/g,c=n.depth>0&&o.exec(a),l=c?a.slice(0,c.index):a,u=[];if(l){if(!n.plainObjects&&r.call(Object.prototype,l)&&!n.allowPrototypes)return;u.push(l)}for(var f=0;n.depth>0&&(c=s.exec(a))!==null&&f{var n=Ga(),r=Ka(),i=Ua();t.exports={formats:i,parse:r,stringify:n}})),Ja=Pt((exports=>{var t=Va();function n(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var r=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,a=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,o=[`<`,`>`,`"`,"`",` `,`\r`,` +`,` `],s=[`{`,`}`,`|`,`\\`,`^`,"`"].concat(o),c=[`'`].concat(s),l=[`%`,`/`,`?`,`;`,`#`].concat(c),u=[`/`,`?`,`#`],d=255,f=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},h={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},_=qa();function v(e,t,r){if(e&&typeof e==`object`&&e instanceof n)return e;var i=new n;return i.parse(e,t,r),i}n.prototype.parse=function(e,n,i){if(typeof e!=`string`)throw TypeError(`Parameter 'url' must be a string, not `+typeof e);var o=e.indexOf(`?`),s=o!==-1&&o127?ee+=`x`:ee+=N[P];if(!ee.match(f)){var I=j.slice(0,E),L=j.slice(E+1),te=N.match(p);te&&(I.push(te[1]),L.unshift(te[2])),L.length&&(b=`/`+L.join(`.`)+b),this.hostname=I.join(`.`);break}}}this.hostname.length>d?this.hostname=``:this.hostname=this.hostname.toLowerCase(),A||(this.hostname=t.toASCII(this.hostname));var ne=this.port?`:`+this.port:``,re=this.hostname||``;this.host=re+ne,this.href+=this.host,A&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),b[0]!==`/`&&(b=`/`+b))}if(!m[C])for(var E=0,M=c.length;E0?r.host.split(`@`):!1;w&&(r.auth=w.shift(),r.hostname=w.shift(),r.host=r.hostname)}return r.search=e.search,r.query=e.query,(r.pathname!==null||r.search!==null)&&(r.path=(r.pathname?r.pathname:``)+(r.search?r.search:``)),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path=`/`+r.search:r.path=null,r.href=r.format(),r;for(var T=S.slice(-1)[0],E=(r.host||e.host||S.length>1)&&(T===`.`||T===`..`)||T===``,D=0,O=S.length;O>=0;O--)T=S[O],T===`.`?S.splice(O,1):T===`..`?(S.splice(O,1),D++):D&&(S.splice(O,1),D--);if(!b&&!x)for(;D--;)S.unshift(`..`);b&&S[0]!==``&&(!S[0]||S[0].charAt(0)!==`/`)&&S.unshift(``),E&&S.join(`/`).substr(-1)!==`/`&&S.push(``);var k=S[0]===``||S[0]&&S[0].charAt(0)===`/`;if(C){r.hostname=k?``:S.length?S.shift():``,r.host=r.hostname;var w=r.host&&r.host.indexOf(`@`)>0?r.host.split(`@`):!1;w&&(r.auth=w.shift(),r.hostname=w.shift(),r.host=r.hostname)}return b||=r.host&&S.length,b&&!k&&S.unshift(``),S.length>0?r.pathname=S.join(`/`):(r.pathname=null,r.path=null),(r.pathname!==null||r.search!==null)&&(r.path=(r.pathname?r.pathname:``)+(r.search?r.search:``)),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var e=this.host,t=i.exec(e);t&&(t=t[0],t!==`:`&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)},exports.parse=v,exports.resolve=b,exports.format=y})),Ya=Rt(za(),1);Ba();var Xa=Rt(Ja(),1),Za={parse:Xa.parse,format:Xa.format,resolve:Xa.resolve};B.RETINA_PREFIX=/@([0-9\.]+)x/,B.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Qa=!1,$a=`6.5.10`;function eo(e){var t;if(!Qa){if(B.ADAPTER.getNavigator().userAgent.toLowerCase().indexOf(`chrome`)>-1){var n=[` + %c %c %c PixiJS `+$a+` - ✰ `+e+` ✰ %c %c http://www.pixijs.com/ %c %c ♥%c♥%c♥ + +`,`background: #ff66a5; padding:5px 0;`,`background: #ff66a5; padding:5px 0;`,`color: #ff66a5; background: #030307; padding:5px 0;`,`background: #ff66a5; padding:5px 0;`,`background: #ffc3dc; padding:5px 0;`,`background: #ff66a5; padding:5px 0;`,`color: #ff2424; background: #fff; padding:5px 0;`,`color: #ff2424; background: #fff; padding:5px 0;`,`color: #ff2424; background: #fff; padding:5px 0;`];(t=globalThis.console).log.apply(t,n)}else globalThis.console&&globalThis.console.log(`PixiJS `+$a+` - `+e+` - http://www.pixijs.com/`);Qa=!0}}var to;function no(){return to===void 0&&(to=(function(){var e={stencil:!0,failIfMajorPerformanceCaveat:B.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!B.ADAPTER.getWebGLRenderingContext())return!1;var t=B.ADAPTER.createCanvas(),n=t.getContext(`webgl`,e)||t.getContext(`experimental-webgl`,e),r=!!(n&&n.getContextAttributes().stencil);if(n){var i=n.getExtension(`WEBGL_lose_context`);i&&i.loseContext()}return n=null,r}catch{return!1}})()),to}function ro(e,t){return t===void 0&&(t=[]),t[0]=(e>>16&255)/255,t[1]=(e>>8&255)/255,t[2]=(e&255)/255,t}function io(e){var t=e.toString(16);return t=`000000`.substring(0,6-t.length)+t,`#`+t}function ao(e){return(e[0]*255<<16)+(e[1]*255<<8)+(e[2]*255|0)}function oo(){for(var e=[],t=[],n=0;n<32;n++)e[n]=n,t[n]=n;e[ta.NORMAL_NPM]=ta.NORMAL,e[ta.ADD_NPM]=ta.ADD,e[ta.SCREEN_NPM]=ta.SCREEN,t[ta.NORMAL]=ta.NORMAL_NPM,t[ta.ADD]=ta.ADD_NPM,t[ta.SCREEN]=ta.SCREEN_NPM;var r=[];return r.push(t),r.push(e),r}var so=oo();function co(e,t){if(t===1)return(t*255<<24)+e;if(t===0)return 0;var n=e>>16&255,r=e>>8&255,i=e&255;return n=n*t+.5|0,r=r*t+.5|0,i=i*t+.5|0,(t*255<<24)+(n<<16)+(r<<8)+i}function lo(e){if(e.BYTES_PER_ELEMENT===4)return e instanceof Float32Array?`Float32Array`:e instanceof Uint32Array?`Uint32Array`:`Int32Array`;if(e.BYTES_PER_ELEMENT===2){if(e instanceof Uint16Array)return`Uint16Array`}else if(e.BYTES_PER_ELEMENT===1&&e instanceof Uint8Array)return`Uint8Array`;return null}function uo(e){return e+=e===0?1:0,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1}function fo(e){return!(e&e-1)&&!!e}function po(e){var t=(e>65535?1:0)<<4;e>>>=t;var n=(e>255?1:0)<<3;return e>>>=n,t|=n,n=(e>15?1:0)<<2,e>>>=n,t|=n,n=(e>3?1:0)<<1,e>>>=n,t|=n,t|e>>1}function mo(e,t,n){var r=e.length,i;if(!(t>=r||n===0)){n=t+n>r?r-t:n;var a=r-n;for(i=t;i8)throw Error(`max arguments reached`);var c=this,l=c.name,u=c.items;this._aliasCount++;for(var d=0,f=u.length;d0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))},e.prototype.add=function(e){return e[this._name]&&(this.ensureNonAliasedItems(),this.remove(e),this.items.push(e)),this},e.prototype.remove=function(e){var t=this.items.indexOf(e);return t!==-1&&(this.ensureNonAliasedItems(),this.items.splice(t,1)),this},e.prototype.contains=function(e){return this.items.indexOf(e)!==-1},e.prototype.removeAll=function(){return this.ensureNonAliasedItems(),this.items.length=0,this},e.prototype.destroy=function(){this.removeAll(),this.items=null,this._name=null},Object.defineProperty(e.prototype,`empty`,{get:function(){return this.items.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,`name`,{get:function(){return this._name},enumerable:!1,configurable:!0}),e}();Object.defineProperties(ko.prototype,{dispatch:{value:ko.prototype.emit},run:{value:ko.prototype.emit}}),B.TARGET_FPMS=.06;var Ao;(function(e){e[e.INTERACTION=50]=`INTERACTION`,e[e.HIGH=25]=`HIGH`,e[e.NORMAL=0]=`NORMAL`,e[e.LOW=-25]=`LOW`,e[e.UTILITY=-50]=`UTILITY`})(Ao||={});var jo=function(){function e(e,t,n,r){t===void 0&&(t=null),n===void 0&&(n=0),r===void 0&&(r=!1),this.next=null,this.previous=null,this._destroyed=!1,this.fn=e,this.context=t,this.priority=n,this.once=r}return e.prototype.match=function(e,t){return t===void 0&&(t=null),this.fn===e&&this.context===t},e.prototype.emit=function(e){this.fn&&(this.context?this.fn.call(this.context,e):this.fn(e));var t=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),t},e.prototype.connect=function(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this},e.prototype.destroy=function(e){e===void 0&&(e=!1),this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);var t=this.next;return this.next=e?null:t,this.previous=null,t},e}(),Mo=function(){function e(){var e=this;this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new jo(null,null,1/0),this.deltaMS=1/B.TARGET_FPMS,this.elapsedMS=1/B.TARGET_FPMS,this._tick=function(t){e._requestId=null,e.started&&(e.update(t),e.started&&e._requestId===null&&e._head.next&&(e._requestId=requestAnimationFrame(e._tick)))}}return e.prototype._requestIfNeeded=function(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))},e.prototype._cancelIfNeeded=function(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)},e.prototype._startIfPossible=function(){this.started?this._requestIfNeeded():this.autoStart&&this.start()},e.prototype.add=function(e,t,n){return n===void 0&&(n=Ao.NORMAL),this._addListener(new jo(e,t,n))},e.prototype.addOnce=function(e,t,n){return n===void 0&&(n=Ao.NORMAL),this._addListener(new jo(e,t,n,!0))},e.prototype._addListener=function(e){var t=this._head.next,n=this._head;if(!t)e.connect(n);else{for(;t;){if(e.priority>t.priority){e.connect(n);break}n=t,t=t.next}e.previous||e.connect(n)}return this._startIfPossible(),this},e.prototype.remove=function(e,t){for(var n=this._head.next;n;)n=n.match(e,t)?n.destroy():n.next;return this._head.next||this._cancelIfNeeded(),this},Object.defineProperty(e.prototype,`count`,{get:function(){if(!this._head)return 0;for(var e=0,t=this._head;t=t.next;)e++;return e},enumerable:!1,configurable:!0}),e.prototype.start=function(){this.started||(this.started=!0,this._requestIfNeeded())},e.prototype.stop=function(){this.started&&(this.started=!1,this._cancelIfNeeded())},e.prototype.destroy=function(){if(!this._protected){this.stop();for(var e=this._head.next;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}},e.prototype.update=function(e){e===void 0&&(e=performance.now());var t;if(e>this.lastTime){if(t=this.elapsedMS=e-this.lastTime,t>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS){var n=e-this._lastFrame|0;if(n=this.x&&e=this.y&&te.right?e.right:this.right;if(r<=n)return!1;var i=this.ye.bottom?e.bottom:this.bottom;return a>i}var o=this.left,s=this.right,c=this.top,l=this.bottom;if(s<=o||l<=c)return!1;var u=zo[0].set(e.left,e.top),d=zo[1].set(e.left,e.bottom),f=zo[2].set(e.right,e.top),p=zo[3].set(e.right,e.bottom);if(f.x<=u.x||d.y<=u.y)return!1;var m=Math.sign(t.a*t.d-t.b*t.c);if(m===0||(t.apply(u,u),t.apply(d,d),t.apply(f,f),t.apply(p,p),Math.max(u.x,d.x,f.x,p.x)<=o||Math.min(u.x,d.x,f.x,p.x)>=s||Math.max(u.y,d.y,f.y,p.y)<=c||Math.min(u.y,d.y,f.y,p.y)>=l))return!1;var h=m*(d.y-u.y),g=m*(u.x-d.x),_=h*o+g*c,v=h*s+g*c,y=h*o+g*l,b=h*s+g*l;if(Math.max(_,v,y,b)<=h*u.x+g*u.y||Math.min(_,v,y,b)>=h*p.x+g*p.y)return!1;var x=m*(u.y-f.y),S=m*(f.x-u.x),C=x*o+S*c,w=x*s+S*c,T=x*o+S*l,E=x*s+S*l;return!(Math.max(C,w,T,E)<=x*u.x+S*u.y||Math.min(C,w,T,E)>=x*p.x+S*p.y)},e.prototype.pad=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=e),this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this},e.prototype.fit=function(e){var t=Math.max(this.x,e.x),n=Math.min(this.x+this.width,e.x+e.width),r=Math.max(this.y,e.y),i=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(n-t,0),this.y=r,this.height=Math.max(i-r,0),this},e.prototype.ceil=function(e,t){e===void 0&&(e=1),t===void 0&&(t=.001);var n=Math.ceil((this.x+this.width-t)*e)/e,r=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=n-this.x,this.height=r-this.y,this},e.prototype.enlarge=function(e){var t=Math.min(this.x,e.x),n=Math.max(this.x+this.width,e.x+e.width),r=Math.min(this.y,e.y),i=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=n-t,this.y=r,this.height=i-r,this},e.prototype.toString=function(){return`[@pixi/math:Rectangle x=`+this.x+` y=`+this.y+` width=`+this.width+` height=`+this.height+`]`},e}();(function(){function e(e,t,n){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0),this.x=e,this.y=t,this.radius=n,this.type=Lo.CIRC}return e.prototype.clone=function(){return new e(this.x,this.y,this.radius)},e.prototype.contains=function(e,t){if(this.radius<=0)return!1;var n=this.radius*this.radius,r=this.x-e,i=this.y-t;return r*=r,i*=i,r+i<=n},e.prototype.getBounds=function(){return new Bo(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)},e.prototype.toString=function(){return`[@pixi/math:Circle x=`+this.x+` y=`+this.y+` radius=`+this.radius+`]`},e})(),function(){function e(e,t,n,r){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0),this.x=e,this.y=t,this.width=n,this.height=r,this.type=Lo.ELIP}return e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height)},e.prototype.contains=function(e,t){if(this.width<=0||this.height<=0)return!1;var n=(e-this.x)/this.width,r=(t-this.y)/this.height;return n*=n,r*=r,n+r<=1},e.prototype.getBounds=function(){return new Bo(this.x-this.width,this.y-this.height,this.width,this.height)},e.prototype.toString=function(){return`[@pixi/math:Ellipse x=`+this.x+` y=`+this.y+` width=`+this.width+` height=`+this.height+`]`},e}(),function(){function e(){for(var e=arguments,t=[],n=0;nt!=l>t&&e<(c-o)*((t-s)/(l-s))+o;u&&(n=!n)}return n},e.prototype.toString=function(){return`[@pixi/math:Polygon`+(`closeStroke=`+this.closeStroke)+(`points=`+this.points.reduce(function(e,t){return e+`, `+t},``)+`]`)},e}(),function(){function e(e,t,n,r,i){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0),i===void 0&&(i=20),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=i,this.type=Lo.RREC}return e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height,this.radius)},e.prototype.contains=function(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){var n=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+n&&t<=this.y+this.height-n||e>=this.x+n&&e<=this.x+this.width-n)return!0;var r=e-(this.x+n),i=t-(this.y+n),a=n*n;if(r*r+i*i<=a||(r=e-(this.x+this.width-n),r*r+i*i<=a)||(i=t-(this.y+this.height-n),r*r+i*i<=a)||(r=e-(this.x+n),r*r+i*i<=a))return!0}return!1},e.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=`+this.x+` y=`+this.y+(`width=`+this.width+` height=`+this.height+` radius=`+this.radius+`]`)},e}();var Vo=function(){function e(e,t,n,r){n===void 0&&(n=0),r===void 0&&(r=0),this._x=n,this._y=r,this.cb=e,this.scope=t}return e.prototype.clone=function(t,n){return t===void 0&&(t=this.cb),n===void 0&&(n=this.scope),new e(t,n,this._x,this._y)},e.prototype.set=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=e),(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this.cb.call(this.scope)),this},e.prototype.copyFrom=function(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this.cb.call(this.scope)),this},e.prototype.copyTo=function(e){return e.set(this._x,this._y),e},e.prototype.equals=function(e){return e.x===this._x&&e.y===this._y},e.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=0 y=0 scope=`+this.scope+`]`},Object.defineProperty(e.prototype,`x`,{get:function(){return this._x},set:function(e){this._x!==e&&(this._x=e,this.cb.call(this.scope))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,`y`,{get:function(){return this._y},set:function(e){this._y!==e&&(this._y=e,this.cb.call(this.scope))},enumerable:!1,configurable:!0}),e}(),Ho=function(){function e(e,t,n,r,i,a){e===void 0&&(e=1),t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=1),i===void 0&&(i=0),a===void 0&&(a=0),this.array=null,this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}return e.prototype.fromArray=function(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]},e.prototype.set=function(e,t,n,r,i,a){return this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a,this},e.prototype.toArray=function(e,t){this.array||=new Float32Array(9);var n=t||this.array;return e?(n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1):(n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1),n},e.prototype.apply=function(e,t){t||=new Ro;var n=e.x,r=e.y;return t.x=this.a*n+this.c*r+this.tx,t.y=this.b*n+this.d*r+this.ty,t},e.prototype.applyInverse=function(e,t){t||=new Ro;var n=1/(this.a*this.d+this.c*-this.b),r=e.x,i=e.y;return t.x=this.d*n*r+-this.c*n*i+(this.ty*this.c-this.tx*this.d)*n,t.y=this.a*n*i+-this.b*n*r+(-this.ty*this.a+this.tx*this.b)*n,t},e.prototype.translate=function(e,t){return this.tx+=e,this.ty+=t,this},e.prototype.scale=function(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this},e.prototype.rotate=function(e){var t=Math.cos(e),n=Math.sin(e),r=this.a,i=this.c,a=this.tx;return this.a=r*t-this.b*n,this.b=r*n+this.b*t,this.c=i*t-this.d*n,this.d=i*n+this.d*t,this.tx=a*t-this.ty*n,this.ty=a*n+this.ty*t,this},e.prototype.append=function(e){var t=this.a,n=this.b,r=this.c,i=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*n+e.b*i,this.c=e.c*t+e.d*r,this.d=e.c*n+e.d*i,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*n+e.ty*i+this.ty,this},e.prototype.setTransform=function(e,t,n,r,i,a,o,s,c){return this.a=Math.cos(o+c)*i,this.b=Math.sin(o+c)*i,this.c=-Math.sin(o-s)*a,this.d=Math.cos(o-s)*a,this.tx=e-(n*this.a+r*this.c),this.ty=t-(n*this.b+r*this.d),this},e.prototype.prepend=function(e){var t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){var n=this.a,r=this.c;this.a=n*e.a+this.b*e.c,this.b=n*e.b+this.b*e.d,this.c=r*e.a+this.d*e.c,this.d=r*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this},e.prototype.decompose=function(e){var t=this.a,n=this.b,r=this.c,i=this.d,a=e.pivot,o=-Math.atan2(-r,i),s=Math.atan2(n,t),c=Math.abs(o+s);return c<1e-5||Math.abs(Po-c)<1e-5?(e.rotation=s,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=o,e.skew.y=s),e.scale.x=Math.sqrt(t*t+n*n),e.scale.y=Math.sqrt(r*r+i*i),e.position.x=this.tx+(a.x*t+a.y*r),e.position.y=this.ty+(a.x*n+a.y*i),e},e.prototype.invert=function(){var e=this.a,t=this.b,n=this.c,r=this.d,i=this.tx,a=e*r-t*n;return this.a=r/a,this.b=-t/a,this.c=-n/a,this.d=e/a,this.tx=(n*this.ty-r*i)/a,this.ty=-(e*this.ty-t*i)/a,this},e.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this},e.prototype.clone=function(){var t=new e;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t},e.prototype.copyTo=function(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e},e.prototype.copyFrom=function(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this},e.prototype.toString=function(){return`[@pixi/math:Matrix a=`+this.a+` b=`+this.b+` c=`+this.c+` d=`+this.d+` tx=`+this.tx+` ty=`+this.ty+`]`},Object.defineProperty(e,`IDENTITY`,{get:function(){return new e},enumerable:!1,configurable:!0}),Object.defineProperty(e,`TEMP_MATRIX`,{get:function(){return new e},enumerable:!1,configurable:!0}),e}(),Uo=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Wo=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Go=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Ko=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],qo=[],Jo=[],Yo=Math.sign;function Xo(){for(var e=0;e<16;e++){var t=[];qo.push(t);for(var n=0;n<16;n++)for(var r=Yo(Uo[e]*Uo[n]+Go[e]*Wo[n]),i=Yo(Wo[e]*Uo[n]+Ko[e]*Wo[n]),a=Yo(Uo[e]*Go[n]+Go[e]*Ko[n]),o=Yo(Wo[e]*Go[n]+Ko[e]*Ko[n]),s=0;s<16;s++)if(Uo[s]===r&&Wo[s]===i&&Go[s]===a&&Ko[s]===o){t.push(s);break}}for(var e=0;e<16;e++){var c=new Ho;c.set(Uo[e],Wo[e],Go[e],Ko[e],0,0),Jo.push(c)}}Xo();var Zo={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:function(e){return Uo[e]},uY:function(e){return Wo[e]},vX:function(e){return Go[e]},vY:function(e){return Ko[e]},inv:function(e){return e&8?e&15:-e&7},add:function(e,t){return qo[e][t]},sub:function(e,t){return qo[e][Zo.inv(t)]},rotate180:function(e){return e^4},isVertical:function(e){return(e&3)==2},byDirection:function(e,t){return Math.abs(e)*2<=Math.abs(t)?t>=0?Zo.S:Zo.N:Math.abs(t)*2<=Math.abs(e)?e>0?Zo.E:Zo.W:t>0?e>0?Zo.SE:Zo.SW:e>0?Zo.NE:Zo.NW},matrixAppendRotationInv:function(e,t,n,r){n===void 0&&(n=0),r===void 0&&(r=0);var i=Jo[Zo.inv(t)];i.tx=n,i.ty=r,e.append(i)}},Qo=function(){function e(){this.worldTransform=new Ho,this.localTransform=new Ho,this.position=new Vo(this.onChange,this,0,0),this.scale=new Vo(this.onChange,this,1,1),this.pivot=new Vo(this.onChange,this,0,0),this.skew=new Vo(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}return e.prototype.onChange=function(){this._localID++},e.prototype.updateSkew=function(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++},e.prototype.toString=function(){return`[@pixi/math:Transform `+(`position=(`+this.position.x+`, `+this.position.y+`) `)+(`rotation=`+this.rotation+` `)+(`scale=(`+this.scale.x+`, `+this.scale.y+`) `)+(`skew=(`+this.skew.x+`, `+this.skew.y+`) `)+`]`},e.prototype.updateLocalTransform=function(){var e=this.localTransform;this._localID!==this._currentLocalID&&(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this._currentLocalID=this._localID,this._parentID=-1)},e.prototype.updateTransform=function(e){var t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==e._worldID){var n=e.worldTransform,r=this.worldTransform;r.a=t.a*n.a+t.b*n.c,r.b=t.a*n.b+t.b*n.d,r.c=t.c*n.a+t.d*n.c,r.d=t.c*n.b+t.d*n.d,r.tx=t.tx*n.a+t.ty*n.c+n.tx,r.ty=t.tx*n.b+t.ty*n.d+n.ty,this._parentID=e._worldID,this._worldID++}},e.prototype.setFromMatrix=function(e){e.decompose(this),this._localID++},Object.defineProperty(e.prototype,`rotation`,{get:function(){return this._rotation},set:function(e){this._rotation!==e&&(this._rotation=e,this.updateSkew())},enumerable:!1,configurable:!0}),e.IDENTITY=new e,e}();B.PREFER_ENV=Ia.any?Qi.WEBGL:Qi.WEBGL2,B.STRICT_TEXTURE_CACHE=!1;var $o=[];function es(e,t){if(!e)return null;var n=``;if(typeof e==`string`){var r=/\.(\w{3,4})(?:$|\?|#)/i.exec(e);r&&(n=r[1].toLowerCase())}for(var i=$o.length-1;i>=0;--i){var a=$o[i];if(a.test&&a.test(e,n))return new a(e,t)}throw Error(`Unrecognized source type to auto-detect Resource`)} +/*! ***************************************************************************** +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 ts=function(e,t){return ts=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])},ts(e,t)};function ns(e,t){ts(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var rs=function(){return rs=Object.assign||function(e){for(var t=arguments,n,r=1,i=arguments.length;r0&&l>0,r.textureCacheIds=[],r.destroyed=!1,r.resource=null,r._batchEnabled=0,r._batchLocation=0,r.parentTextureArray=null,r.setResource(t),r}return Object.defineProperty(t.prototype,`realWidth`,{get:function(){return Math.round(this.width*this.resolution)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`realHeight`,{get:function(){return Math.round(this.height*this.resolution)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`mipmap`,{get:function(){return this._mipmap},set:function(e){this._mipmap!==e&&(this._mipmap=e,this.dirtyStyleId++)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`scaleMode`,{get:function(){return this._scaleMode},set:function(e){this._scaleMode!==e&&(this._scaleMode=e,this.dirtyStyleId++)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`wrapMode`,{get:function(){return this._wrapMode},set:function(e){this._wrapMode!==e&&(this._wrapMode=e,this.dirtyStyleId++)},enumerable:!1,configurable:!0}),t.prototype.setStyle=function(e,t){var n;return e!==void 0&&e!==this.scaleMode&&(this.scaleMode=e,n=!0),t!==void 0&&t!==this.mipmap&&(this.mipmap=t,n=!0),n&&this.dirtyStyleId++,this},t.prototype.setSize=function(e,t,n){return n||=this.resolution,this.setRealSize(e*n,t*n,n)},t.prototype.setRealSize=function(e,t,n){return this.resolution=n||this.resolution,this.width=Math.round(e)/this.resolution,this.height=Math.round(t)/this.resolution,this._refreshPOT(),this.update(),this},t.prototype._refreshPOT=function(){this.isPowerOfTwo=fo(this.realWidth)&&fo(this.realHeight)},t.prototype.setResolution=function(e){var t=this.resolution;return t===e?this:(this.resolution=e,this.valid&&(this.width=Math.round(this.width*t)/e,this.height=Math.round(this.height*t)/e,this.emit(`update`,this)),this._refreshPOT(),this)},t.prototype.setResource=function(e){if(this.resource===e)return this;if(this.resource)throw Error(`Resource can be set only once`);return e.bind(this),this.resource=e,this},t.prototype.update=function(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit(`update`,this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit(`loaded`,this),this.emit(`update`,this))},t.prototype.onError=function(e){this.emit(`error`,this,e)},t.prototype.destroy=function(){this.resource&&=(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),null),this.cacheId&&=(delete xo[this.cacheId],delete bo[this.cacheId],null),this.dispose(),t.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0},t.prototype.dispose=function(){this.emit(`dispose`,this)},t.prototype.castToBaseTexture=function(){return this},t.from=function(e,n,r){r===void 0&&(r=B.STRICT_TEXTURE_CACHE);var i=typeof e==`string`,a=null;if(i)a=e;else{if(!e._pixiId){var o=n&&n.pixiIdPrefix||`pixiid`;e._pixiId=o+`_`+go()}a=e._pixiId}var s=xo[a];if(i&&r&&!s)throw Error(`The cacheId "`+a+`" does not exist in BaseTextureCache.`);return s||(s=new t(e,n),s.cacheId=a,t.addToCache(s,a)),s},t.fromBuffer=function(e,n,r,i){e||=new Float32Array(n*r*4);var a=new cs(e,{width:n,height:r}),o=e instanceof Float32Array?ia.FLOAT:ia.UNSIGNED_BYTE;return new t(a,Object.assign({},ls,i||{width:n,height:r,type:o}))},t.addToCache=function(e,t){t&&(e.textureCacheIds.indexOf(t)===-1&&e.textureCacheIds.push(t),xo[t]&&console.warn(`BaseTexture added to the cache with an id [`+t+`] that already had an entry`),xo[t]=e)},t.removeFromCache=function(e){if(typeof e==`string`){var t=xo[e];if(t){var n=t.textureCacheIds.indexOf(e);return n>-1&&t.textureCacheIds.splice(n,1),delete xo[e],t}}else if(e&&e.textureCacheIds){for(var r=0;r0)if(e.resource)this.addResourceAt(e.resource,t);else throw Error(`CubeResource does not support copying of renderTexture.`);else e.target=ra.TEXTURE_CUBE_MAP_POSITIVE_X+t,e.parentTextureArray=this.baseTexture,this.items[t]=e;return e.valid&&!this.valid&&this.resize(e.realWidth,e.realHeight),this.items[t]=e,this},t.prototype.upload=function(e,n,r){for(var i=this.itemDirtyIds,a=0;a)?\s*()]*-->)?\s*\]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i,t}(ps),vs=function(e){ns(t,e);function t(n,r){var i=this;if(r||={},!(n instanceof HTMLVideoElement)){var a=document.createElement(`video`);a.setAttribute(`preload`,`auto`),a.setAttribute(`webkit-playsinline`,``),a.setAttribute(`playsinline`,``),typeof n==`string`&&(n=[n]);var o=n[0].src||n[0];ps.crossOrigin(a,o,r.crossorigin);for(var s=0;s2},t.prototype._onPlayStart=function(){this.valid||this._onCanPlay(),this.autoUpdate&&!this._isConnectedToTicker&&(Mo.shared.add(this.update,this),this._isConnectedToTicker=!0)},t.prototype._onPlayStop=function(){this._isConnectedToTicker&&=(Mo.shared.remove(this.update,this),!1)},t.prototype._onCanPlay=function(){var e=this.source;e.removeEventListener(`canplay`,this._onCanPlay),e.removeEventListener(`canplaythrough`,this._onCanPlay);var t=this.valid;this.resize(e.videoWidth,e.videoHeight),!t&&this._resolve&&(this._resolve(this),this._resolve=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&e.play()},t.prototype.dispose=function(){this._isConnectedToTicker&&=(Mo.shared.remove(this.update,this),!1);var t=this.source;t&&(t.removeEventListener(`error`,this._onError,!0),t.pause(),t.src=``,t.load()),e.prototype.dispose.call(this)},Object.defineProperty(t.prototype,`autoUpdate`,{get:function(){return this._autoUpdate},set:function(e){e!==this._autoUpdate&&(this._autoUpdate=e,!this._autoUpdate&&this._isConnectedToTicker?(Mo.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._isSourcePlaying()&&(Mo.shared.add(this.update,this),this._isConnectedToTicker=!0))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`updateFPS`,{get:function(){return this._updateFPS},set:function(e){e!==this._updateFPS&&(this._updateFPS=e)},enumerable:!1,configurable:!0}),t.test=function(e,n){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement||t.TYPES.indexOf(n)>-1},t.TYPES=[`mp4`,`m4v`,`webm`,`ogg`,`ogv`,`h264`,`avi`,`mov`],t.MIME_TYPES={ogv:`video/ogg`,mov:`video/quicktime`,m4v:`video/mp4`},t}(ps),ys=function(e){ns(t,e);function t(t){return e.call(this,t)||this}return t.test=function(e){return!!globalThis.createImageBitmap&&typeof ImageBitmap<`u`&&e instanceof ImageBitmap},t}(ps);$o.push(gs,ys,ms,vs,_s,cs,hs,fs);var bs={__proto__:null,Resource:ss,BaseImageResource:ps,INSTALLED:$o,autoDetectResource:es,AbstractMultiResource:ds,ArrayResource:fs,BufferResource:cs,CanvasResource:ms,CubeResource:hs,ImageResource:gs,SVGResource:_s,VideoResource:vs,ImageBitmapResource:ys},xs=function(e){ns(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.upload=function(e,t,n){var r=e.gl;r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.alphaMode===la.UNPACK);var i=t.realWidth,a=t.realHeight;return n.width===i&&n.height===a?r.texSubImage2D(t.target,0,0,0,i,a,t.format,n.type,this.data):(n.width=i,n.height=a,r.texImage2D(t.target,0,n.internalFormat,i,a,0,t.format,n.type,this.data)),!0},t}(cs),Ss=function(){function e(e,t){this.width=Math.round(e||100),this.height=Math.round(t||100),this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new ko(`disposeFramebuffer`),this.multisample=ha.NONE}return Object.defineProperty(e.prototype,`colorTexture`,{get:function(){return this.colorTextures[0]},enumerable:!1,configurable:!0}),e.prototype.addColorTexture=function(e,t){return e===void 0&&(e=0),this.colorTextures[e]=t||new us(null,{scaleMode:oa.NEAREST,resolution:1,mipmap:ca.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this},e.prototype.addDepthTexture=function(e){return this.depthTexture=e||new us(new xs(null,{width:this.width,height:this.height}),{scaleMode:oa.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:ca.OFF,format:z.DEPTH_COMPONENT,type:ia.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this},e.prototype.enableDepth=function(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this},e.prototype.enableStencil=function(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this},e.prototype.resize=function(e,t){if(e=Math.round(e),t=Math.round(t),!(e===this.width&&t===this.height)){this.width=e,this.height=t,this.dirtyId++,this.dirtySize++;for(var n=0;n-1&&t.textureCacheIds.splice(n,1),delete bo[e],t}}else if(e&&e.textureCacheIds){for(var r=0;rthis.baseTexture.width,o=n+i>this.baseTexture.height;if(a||o){var s=a&&o?`and`:`or`,c=`X: `+t+` + `+r+` = `+(t+r)+` > `+this.baseTexture.width,l=`Y: `+n+` + `+i+` = `+(n+i)+` > `+this.baseTexture.height;throw Error(`Texture Error: frame does not fit inside the base Texture dimensions: `+(c+` `+s+` `+l))}this.valid=r&&i&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=e),this.valid&&this.updateUvs()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`rotate`,{get:function(){return this._rotate},set:function(e){this._rotate=e,this.valid&&this.updateUvs()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`width`,{get:function(){return this.orig.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`height`,{get:function(){return this.orig.height},enumerable:!1,configurable:!0}),t.prototype.castToBaseTexture=function(){return this.baseTexture},Object.defineProperty(t,`EMPTY`,{get:function(){return t._EMPTY||(t._EMPTY=new t(new us),Es(t._EMPTY),Es(t._EMPTY.baseTexture)),t._EMPTY},enumerable:!1,configurable:!0}),Object.defineProperty(t,`WHITE`,{get:function(){if(!t._WHITE){var e=B.ADAPTER.createCanvas(16,16),n=e.getContext(`2d`);e.width=16,e.height=16,n.fillStyle=`white`,n.fillRect(0,0,16,16),t._WHITE=new t(us.from(e)),Es(t._WHITE),Es(t._WHITE.baseTexture)}return t._WHITE},enumerable:!1,configurable:!0}),t}(Ya.default),Os=function(e){ns(t,e);function t(t,n){var r=e.call(this,t,n)||this;return r.valid=!0,r.filterFrame=null,r.filterPoolKey=null,r.updateUvs(),r}return Object.defineProperty(t.prototype,`framebuffer`,{get:function(){return this.baseTexture.framebuffer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`multisample`,{get:function(){return this.framebuffer.multisample},set:function(e){this.framebuffer.multisample=e},enumerable:!1,configurable:!0}),t.prototype.resize=function(e,t,n){n===void 0&&(n=!0);var r=this.baseTexture.resolution,i=Math.round(e*r)/r,a=Math.round(t*r)/r;this.valid=i>0&&a>0,this._frame.width=this.orig.width=i,this._frame.height=this.orig.height=a,n&&this.baseTexture.resize(i,a),this.updateUvs()},t.prototype.setResolution=function(e){var t=this.baseTexture;t.resolution!==e&&(t.setResolution(e),this.resize(t.width,t.height,!1))},t.create=function(e){for(var n=arguments,r=[],i=1;i>>0,r>1&&(i+=r*4294967296)):i=r>1?-r:-1,this.texturePool[i]||(this.texturePool[i]=[]);var a=this.texturePool[i].pop();return a||=this.createTexture(e,t,r),a.filterPoolKey=i,a.setResolution(n),a},e.prototype.getFilterTexture=function(e,t,n){var r=this.getOptimalTexture(e.width,e.height,t||e.resolution,n||ha.NONE);return r.filterFrame=e.filterFrame,r},e.prototype.returnTexture=function(e){var t=e.filterPoolKey;e.filterFrame=null,this.texturePool[t].push(e)},e.prototype.returnFilterTexture=function(e){this.returnTexture(e)},e.prototype.clear=function(e){if(e=e!==!1,e)for(var t in this.texturePool){var n=this.texturePool[t];if(n)for(var r=0;r0&&e.height>0,this.texturePool){if(!(Number(t)<0))continue;var n=this.texturePool[t];if(n)for(var r=0;r1){for(var l=0;l1&&(u=this.getOptimalFilterTexture(l.width,l.height,t.resolution),u.filterFrame=l.filterFrame),n[d].apply(this,l,u,ua.CLEAR,t);var f=l;l=u,u=f}n[d].apply(this,l,c.renderTexture,ua.BLEND,t),d>1&&t.multisample>1&&this.returnFilterTexture(t.renderTexture),this.returnFilterTexture(l),this.returnFilterTexture(u)}t.clear(),this.statePool.push(t)},e.prototype.bindAndClear=function(e,t){t===void 0&&(t=ua.CLEAR);var n=this.renderer,r=n.renderTexture,i=n.state;if(e===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,e&&e.filterFrame){var a=this.tempRect;a.x=0,a.y=0,a.width=e.filterFrame.width,a.height=e.filterFrame.height,r.bind(e,e.filterFrame,a)}else e===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.renderTexture.bind(e,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame):r.bind(e);var o=i.stateId&1||this.forceClear;(t===ua.CLEAR||t===ua.BLIT&&o)&&this.renderer.framebuffer.clear(0,0,0,0)},e.prototype.applyFilter=function(e,t,n,r){var i=this.renderer;i.state.set(e.state),this.bindAndClear(n,r),e.uniforms.uSampler=t,e.uniforms.filterGlobals=this.globalUniforms,i.shader.bind(e),e.legacy=!!e.program.attributeData.aTextureCoord,e.legacy?(this.quadUv.map(t._frame,t.filterFrame),i.geometry.bind(this.quadUv),i.geometry.draw(na.TRIANGLES)):(i.geometry.bind(this.quad),i.geometry.draw(na.TRIANGLE_STRIP))},e.prototype.calculateSpriteMatrix=function(e,t){var n=this.activeState,r=n.sourceFrame,i=n.destinationFrame,a=t._texture.orig,o=e.set(i.width,0,0,i.height,r.x,r.y),s=t.worldTransform.copyTo(Ho.TEMP_MATRIX);return s.invert(),o.prepend(s),o.scale(1/a.width,1/a.height),o.translate(t.anchor.x,t.anchor.y),o},e.prototype.destroy=function(){this.renderer=null,this.texturePool.clear(!1)},e.prototype.getOptimalFilterTexture=function(e,t,n,r){return n===void 0&&(n=1),r===void 0&&(r=ha.NONE),this.texturePool.getOptimalTexture(e,t,n,r)},e.prototype.getFilterTexture=function(e,t,n){if(typeof e==`number`){var r=e;e=t,t=r}e||=this.activeState.renderTexture;var i=this.texturePool.getOptimalTexture(e.width,e.height,t||e.resolution,n||ha.NONE);return i.filterFrame=e.filterFrame,i},e.prototype.returnFilterTexture=function(e){this.texturePool.returnTexture(e)},e.prototype.emptyPool=function(){this.texturePool.clear(!0)},e.prototype.resize=function(){this.texturePool.setScreenSize(this.renderer.view)},e.prototype.transformAABB=function(e,t){var n=Ws[0],r=Ws[1],i=Ws[2],a=Ws[3];n.set(t.left,t.top),r.set(t.left,t.bottom),i.set(t.right,t.top),a.set(t.right,t.bottom),e.apply(n,n),e.apply(r,r),e.apply(i,i),e.apply(a,a);var o=Math.min(n.x,r.x,i.x,a.x),s=Math.min(n.y,r.y,i.y,a.y),c=Math.max(n.x,r.x,i.x,a.x),l=Math.max(n.y,r.y,i.y,a.y);t.x=o,t.y=s,t.width=c-o,t.height=l-s},e.prototype.roundFrame=function(e,t,n,r,i){if(!(e.width<=0||e.height<=0||n.width<=0||n.height<=0)){if(i){var a=i.a,o=i.b,s=i.c,c=i.d;if((Math.abs(o)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(a)>1e-4||Math.abs(c)>1e-4))return}i=i?Gs.copyFrom(i):Gs.identity(),i.translate(-n.x,-n.y).scale(r.width/n.width,r.height/n.height).translate(r.x,r.y),this.transformAABB(i,e),e.ceil(t),this.transformAABB(i.invert(),e)}},e}(),qs=function(){function e(e){this.renderer=e}return e.prototype.flush=function(){},e.prototype.destroy=function(){this.renderer=null},e.prototype.start=function(){},e.prototype.stop=function(){this.flush()},e.prototype.render=function(e){},e}(),Js=function(){function e(e){this.renderer=e,this.emptyRenderer=new qs(e),this.currentRenderer=this.emptyRenderer}return e.prototype.setObjectRenderer=function(e){this.currentRenderer!==e&&(this.currentRenderer.stop(),this.currentRenderer=e,this.currentRenderer.start())},e.prototype.flush=function(){this.setObjectRenderer(this.emptyRenderer)},e.prototype.reset=function(){this.setObjectRenderer(this.emptyRenderer)},e.prototype.copyBoundTextures=function(e,t){for(var n=this.renderer.texture.boundTextures,r=t-1;r>=0;--r)e[r]=n[r]||null,e[r]&&(e[r]._batchLocation=r)},e.prototype.boundArray=function(e,t,n,r){for(var i=e.elements,a=e.ids,o=e.count,s=0,c=0;c=0&&u=Qi.WEBGL2&&(n=e.getContext(`webgl2`,t)),n)this.webGLVersion=2;else if(this.webGLVersion=1,n=e.getContext(`webgl`,t)||e.getContext(`experimental-webgl`,t),!n)throw Error(`This browser does not support WebGL. Try using the canvas renderer`);return this.gl=n,this.getExtensions(),this.gl},e.prototype.getExtensions=function(){var e=this.gl,t={loseContext:e.getExtension(`WEBGL_lose_context`),anisotropicFiltering:e.getExtension(`EXT_texture_filter_anisotropic`),floatTextureLinear:e.getExtension(`OES_texture_float_linear`),s3tc:e.getExtension(`WEBGL_compressed_texture_s3tc`),s3tc_sRGB:e.getExtension(`WEBGL_compressed_texture_s3tc_srgb`),etc:e.getExtension(`WEBGL_compressed_texture_etc`),etc1:e.getExtension(`WEBGL_compressed_texture_etc1`),pvrtc:e.getExtension(`WEBGL_compressed_texture_pvrtc`)||e.getExtension(`WEBKIT_WEBGL_compressed_texture_pvrtc`),atc:e.getExtension(`WEBGL_compressed_texture_atc`),astc:e.getExtension(`WEBGL_compressed_texture_astc`)};this.webGLVersion===1?Object.assign(this.extensions,t,{drawBuffers:e.getExtension(`WEBGL_draw_buffers`),depthTexture:e.getExtension(`WEBGL_depth_texture`),vertexArrayObject:e.getExtension(`OES_vertex_array_object`)||e.getExtension(`MOZ_OES_vertex_array_object`)||e.getExtension(`WEBKIT_OES_vertex_array_object`),uint32ElementIndex:e.getExtension(`OES_element_index_uint`),floatTexture:e.getExtension(`OES_texture_float`),floatTextureLinear:e.getExtension(`OES_texture_float_linear`),textureHalfFloat:e.getExtension(`OES_texture_half_float`),textureHalfFloatLinear:e.getExtension(`OES_texture_half_float_linear`)}):this.webGLVersion===2&&Object.assign(this.extensions,t,{colorBufferFloat:e.getExtension(`EXT_color_buffer_float`)})},e.prototype.handleContextLost=function(e){var t=this;e.preventDefault(),setTimeout(function(){t.gl.isContextLost()&&t.extensions.loseContext&&t.extensions.loseContext.restoreContext()},0)},e.prototype.handleContextRestored=function(){this.renderer.runners.contextChange.emit(this.gl)},e.prototype.destroy=function(){var e=this.renderer.view;this.renderer=null,e.removeEventListener(`webglcontextlost`,this.handleContextLost),e.removeEventListener(`webglcontextrestored`,this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()},e.prototype.postrender=function(){this.renderer.renderingToScreen&&this.gl.flush()},e.prototype.validateContext=function(e){var t=e.getContextAttributes(),n=`WebGL2RenderingContext`in globalThis&&e instanceof globalThis.WebGL2RenderingContext;n&&(this.webGLVersion=2),t&&!t.stencil&&console.warn(`Provided WebGL context does not have a stencil buffer, masks may not render correctly`);var r=n||!!e.getExtension(`OES_element_index_uint`);this.supports.uint32Indices=r,r||console.warn(`Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly`)},e}(),Zs=function(){function e(e){this.framebuffer=e,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=ha.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}return e}(),Qs=new Bo,$s=function(){function e(e){this.renderer=e,this.managedFramebuffers=[],this.unknownFramebuffer=new Ss(10,10),this.msaaSamples=null}return e.prototype.contextChange=function(){this.disposeAll(!0);var e=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new Bo,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){var t=this.renderer.context.extensions.drawBuffers,n=this.renderer.context.extensions.depthTexture;B.PREFER_ENV===Qi.WEBGL_LEGACY&&(t=null,n=null),t?e.drawBuffers=function(e){return t.drawBuffersWEBGL(e)}:(this.hasMRT=!1,e.drawBuffers=function(){}),n||(this.writeDepthTexture=!1)}else this.msaaSamples=e.getInternalformatParameter(e.RENDERBUFFER,e.RGBA8,e.SAMPLES)},e.prototype.bind=function(e,t,n){n===void 0&&(n=0);var r=this.gl;if(e){var i=e.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(e);this.current!==e&&(this.current=e,r.bindFramebuffer(r.FRAMEBUFFER,i.framebuffer)),i.mipLevel!==n&&(e.dirtyId++,e.dirtyFormat++,i.mipLevel=n),i.dirtyId!==e.dirtyId&&(i.dirtyId=e.dirtyId,i.dirtyFormat===e.dirtyFormat?i.dirtySize!==e.dirtySize&&(i.dirtySize=e.dirtySize,this.resizeFramebuffer(e)):(i.dirtyFormat=e.dirtyFormat,i.dirtySize=e.dirtySize,this.updateFramebuffer(e,n)));for(var a=0;a>n,c=t.height>>n,l=s/t.width;this.setViewport(t.x*l,t.y*l,s,c)}else{var s=e.width>>n,c=e.height>>n;this.setViewport(0,0,s,c)}}else this.current&&(this.current=null,r.bindFramebuffer(r.FRAMEBUFFER,null)),t?this.setViewport(t.x,t.y,t.width,t.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)},e.prototype.setViewport=function(e,t,n,r){var i=this.viewport;e=Math.round(e),t=Math.round(t),n=Math.round(n),r=Math.round(r),(i.width!==n||i.height!==r||i.x!==e||i.y!==t)&&(i.x=e,i.y=t,i.width=n,i.height=r,this.gl.viewport(e,t,n,r))},Object.defineProperty(e.prototype,`size`,{get:function(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}},enumerable:!1,configurable:!0}),e.prototype.clear=function(e,t,n,r,i){i===void 0&&(i=ea.COLOR|ea.DEPTH);var a=this.gl;a.clearColor(e,t,n,r),a.clear(i)},e.prototype.initFramebuffer=function(e){var t=this.gl,n=new Zs(t.createFramebuffer());return n.multisample=this.detectSamples(e.multisample),e.glFramebuffers[this.CONTEXT_UID]=n,this.managedFramebuffers.push(e),e.disposeRunner.add(this),n},e.prototype.resizeFramebuffer=function(e){var t=this.gl,n=e.glFramebuffers[this.CONTEXT_UID];n.msaaBuffer&&(t.bindRenderbuffer(t.RENDERBUFFER,n.msaaBuffer),t.renderbufferStorageMultisample(t.RENDERBUFFER,n.multisample,t.RGBA8,e.width,e.height)),n.stencil&&(t.bindRenderbuffer(t.RENDERBUFFER,n.stencil),n.msaaBuffer?t.renderbufferStorageMultisample(t.RENDERBUFFER,n.multisample,t.DEPTH24_STENCIL8,e.width,e.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,e.width,e.height));var r=e.colorTextures,i=r.length;t.drawBuffers||(i=Math.min(i,1));for(var a=0;a1&&this.canMultisampleFramebuffer(e)?(r.msaaBuffer=r.msaaBuffer||n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,r.msaaBuffer),n.renderbufferStorageMultisample(n.RENDERBUFFER,r.multisample,n.RGBA8,e.width,e.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,r.msaaBuffer)):r.msaaBuffer&&(n.deleteRenderbuffer(r.msaaBuffer),r.msaaBuffer=null,r.blitFramebuffer&&=(r.blitFramebuffer.dispose(),null));for(var o=[],s=0;s1&&n.drawBuffers(o),e.depthTexture){var u=this.writeDepthTexture;if(u){var d=e.depthTexture;this.renderer.texture.bind(d,0),n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,d._glTextures[this.CONTEXT_UID].texture,t)}}(e.stencil||e.depth)&&!(e.depthTexture&&this.writeDepthTexture)?(r.stencil=r.stencil||n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,r.stencil),r.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,r.multisample,n.DEPTH24_STENCIL8,e.width,e.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,e.width,e.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,r.stencil)):r.stencil&&=(n.deleteRenderbuffer(r.stencil),null)},e.prototype.canMultisampleFramebuffer=function(e){return this.renderer.context.webGLVersion!==1&&e.colorTextures.length<=1&&!e.depthTexture},e.prototype.detectSamples=function(e){var t=this.msaaSamples,n=ha.NONE;if(e<=1||t===null)return n;for(var r=0;r=0&&this.managedFramebuffers.splice(i,1),e.disposeRunner.remove(this),t||(r.deleteFramebuffer(n.framebuffer),n.msaaBuffer&&r.deleteRenderbuffer(n.msaaBuffer),n.stencil&&r.deleteRenderbuffer(n.stencil)),n.blitFramebuffer&&n.blitFramebuffer.dispose()}},e.prototype.disposeAll=function(e){var t=this.managedFramebuffers;this.managedFramebuffers=[];for(var n=0;n=Qi.WEBGL2&&(t=e.getContext(`webgl2`,{})),t||(t=e.getContext(`webgl`,{})||e.getContext(`experimental-webgl`,{}),t?t.getExtension(`WEBGL_draw_buffers`):t=null),lc=t}return lc}var dc;function fc(){if(!dc){dc=fa.MEDIUM;var e=uc();if(e&&e.getShaderPrecisionFormat){var t=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT);dc=t.precision?fa.HIGH:fa.MEDIUM}}return dc}function pc(e,t,n){if(e.substring(0,9)!==`precision`){var r=t;return t===fa.HIGH&&n!==fa.HIGH&&(r=fa.MEDIUM),`precision `+r+` float; +`+e}else if(n!==fa.HIGH&&e.substring(0,15)===`precision highp`)return e.replace(`precision highp`,`precision mediump`);return e}var mc={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function hc(e){return mc[e]}var gc=null,_c={FLOAT:`float`,FLOAT_VEC2:`vec2`,FLOAT_VEC3:`vec3`,FLOAT_VEC4:`vec4`,INT:`int`,INT_VEC2:`ivec2`,INT_VEC3:`ivec3`,INT_VEC4:`ivec4`,UNSIGNED_INT:`uint`,UNSIGNED_INT_VEC2:`uvec2`,UNSIGNED_INT_VEC3:`uvec3`,UNSIGNED_INT_VEC4:`uvec4`,BOOL:`bool`,BOOL_VEC2:`bvec2`,BOOL_VEC3:`bvec3`,BOOL_VEC4:`bvec4`,FLOAT_MAT2:`mat2`,FLOAT_MAT3:`mat3`,FLOAT_MAT4:`mat4`,SAMPLER_2D:`sampler2D`,INT_SAMPLER_2D:`sampler2D`,UNSIGNED_INT_SAMPLER_2D:`sampler2D`,SAMPLER_CUBE:`samplerCube`,INT_SAMPLER_CUBE:`samplerCube`,UNSIGNED_INT_SAMPLER_CUBE:`samplerCube`,SAMPLER_2D_ARRAY:`sampler2DArray`,INT_SAMPLER_2D_ARRAY:`sampler2DArray`,UNSIGNED_INT_SAMPLER_2D_ARRAY:`sampler2DArray`};function vc(e,t){if(!gc){var n=Object.keys(_c);gc={};for(var r=0;r0&&(t+=` +else `),n0?this.maskStack[this.maskStack.length-1]._colorMask:15;n!==t&&this.renderer.gl.colorMask((n&1)!=0,(n&2)!=0,(n&4)!=0,(n&8)!=0)},e.prototype.destroy=function(){this.renderer=null},e}(),Xc=function(){function e(e){this.renderer=e,this.maskStack=[],this.glConst=0}return e.prototype.getStackLength=function(){return this.maskStack.length},e.prototype.setMaskStack=function(e){var t=this.renderer.gl,n=this.getStackLength();this.maskStack=e;var r=this.getStackLength();r!==n&&(r===0?t.disable(this.glConst):(t.enable(this.glConst),this._useCurrent()))},e.prototype._useCurrent=function(){},e.prototype.destroy=function(){this.renderer=null,this.maskStack=null},e}(),Zc=new Ho,Qc=[],$c=function(e){ns(t,e);function t(t){var n=e.call(this,t)||this;return n.glConst=B.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST,n}return t.prototype.getStackLength=function(){var e=this.maskStack[this.maskStack.length-1];return e?e._scissorCounter:0},t.prototype.calcScissorRect=function(e){var t;if(!e._scissorRectLocal){var n=e._scissorRect,r=e.maskObject,i=this.renderer,a=i.renderTexture,o=r.getBounds(!0,(t=Qc.pop())??new Bo);this.roundFrameToPixels(o,a.current?a.current.resolution:i.resolution,a.sourceFrame,a.destinationFrame,i.projection.transform),n&&o.fit(n),e._scissorRectLocal=o}},t.isMatrixRotated=function(e){if(!e)return!1;var t=e.a,n=e.b,r=e.c,i=e.d;return(Math.abs(n)>1e-4||Math.abs(r)>1e-4)&&(Math.abs(t)>1e-4||Math.abs(i)>1e-4)},t.prototype.testScissor=function(e){var n=e.maskObject;if(!n.isFastRect||!n.isFastRect()||t.isMatrixRotated(n.worldTransform)||t.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(e);var r=e._scissorRectLocal;return r.width>0&&r.height>0},t.prototype.roundFrameToPixels=function(e,n,r,i,a){t.isMatrixRotated(a)||(a=a?Zc.copyFrom(a):Zc.identity(),a.translate(-r.x,-r.y).scale(i.width/r.width,i.height/r.height).translate(i.x,i.y),this.renderer.filter.transformAABB(a,e),e.fit(i),e.x=Math.round(e.x*n),e.y=Math.round(e.y*n),e.width=Math.round(e.width*n),e.height=Math.round(e.height*n))},t.prototype.push=function(e){e._scissorRectLocal||this.calcScissorRect(e);var t=this.renderer.gl;e._scissorRect||t.enable(t.SCISSOR_TEST),e._scissorCounter++,e._scissorRect=e._scissorRectLocal,this._useCurrent()},t.prototype.pop=function(e){var t=this.renderer.gl;e&&Qc.push(e._scissorRectLocal),this.getStackLength()>0?this._useCurrent():t.disable(t.SCISSOR_TEST)},t.prototype._useCurrent=function(){var e=this.maskStack[this.maskStack.length-1]._scissorRect,t;t=this.renderer.renderTexture.current?e.y:this.renderer.height-e.height-e.y,this.renderer.gl.scissor(e.x,t,e.width,e.height)},t}(Xc),el=function(e){ns(t,e);function t(t){var n=e.call(this,t)||this;return n.glConst=B.ADAPTER.getWebGLRenderingContext().STENCIL_TEST,n}return t.prototype.getStackLength=function(){var e=this.maskStack[this.maskStack.length-1];return e?e._stencilCounter:0},t.prototype.push=function(e){var t=e.maskObject,n=this.renderer.gl,r=e._stencilCounter;r===0&&(this.renderer.framebuffer.forceStencil(),n.clearStencil(0),n.clear(n.STENCIL_BUFFER_BIT),n.enable(n.STENCIL_TEST)),e._stencilCounter++;var i=e._colorMask;i!==0&&(e._colorMask=0,n.colorMask(!1,!1,!1,!1)),n.stencilFunc(n.EQUAL,r,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.INCR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,i!==0&&(e._colorMask=i,n.colorMask((i&1)!=0,(i&2)!=0,(i&4)!=0,(i&8)!=0)),this._useCurrent()},t.prototype.pop=function(e){var t=this.renderer.gl;if(this.getStackLength()===0)t.disable(t.STENCIL_TEST);else{var n=this.maskStack.length===0?null:this.maskStack[this.maskStack.length-1],r=n?n._colorMask:15;r!==0&&(n._colorMask=0,t.colorMask(!1,!1,!1,!1)),t.stencilOp(t.KEEP,t.KEEP,t.DECR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,r!==0&&(n._colorMask=r,t.colorMask((r&1)!=0,(r&2)!=0,(r&4)!=0,(r&8)!=0)),this._useCurrent()}},t.prototype._useCurrent=function(){var e=this.renderer.gl;e.stencilFunc(e.EQUAL,this.getStackLength(),4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP)},t}(Xc),tl=function(){function e(e){this.renderer=e,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new Ho,this.transform=null}return e.prototype.update=function(e,t,n,r){this.destinationFrame=e||this.destinationFrame||this.defaultFrame,this.sourceFrame=t||this.sourceFrame||e,this.calculateProjection(this.destinationFrame,this.sourceFrame,n,r),this.transform&&this.projectionMatrix.append(this.transform);var i=this.renderer;i.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,i.globalUniforms.update(),i.shader.shader&&i.shader.syncUniformGroup(i.shader.shader.uniforms.globals)},e.prototype.calculateProjection=function(e,t,n,r){var i=this.projectionMatrix,a=r?-1:1;i.identity(),i.a=1/t.width*2,i.d=a*(1/t.height*2),i.tx=-1-t.x*i.a,i.ty=-a-t.y*i.d},e.prototype.setTransform=function(e){},e.prototype.destroy=function(){this.renderer=null},e}(),nl=new Bo,rl=new Bo,il=function(){function e(e){this.renderer=e,this.clearColor=e._backgroundColorRgba,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new Bo,this.destinationFrame=new Bo,this.viewportFrame=new Bo}return e.prototype.bind=function(e,t,n){e===void 0&&(e=null);var r=this.renderer;this.current=e;var i,a,o;e?(i=e.baseTexture,o=i.resolution,t||=(nl.width=e.frame.width,nl.height=e.frame.height,nl),n||=(rl.x=e.frame.x,rl.y=e.frame.y,rl.width=t.width,rl.height=t.height,rl),a=i.framebuffer):(o=r.resolution,t||=(nl.width=r.screen.width,nl.height=r.screen.height,nl),n||(n=nl,n.width=t.width,n.height=t.height));var s=this.viewportFrame;s.x=n.x*o,s.y=n.y*o,s.width=n.width*o,s.height=n.height*o,e||(s.y=r.view.height-(s.y+s.height)),s.ceil(),this.renderer.framebuffer.bind(a,s),this.renderer.projection.update(n,t,o,!a),e?this.renderer.mask.setMaskStack(i.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(t),this.destinationFrame.copyFrom(n)},e.prototype.clear=function(e,t){this.current?e||=this.current.baseTexture.clearColor:e||=this.clearColor;var n=this.destinationFrame,r=this.current?this.current.baseTexture:this.renderer.screen,i=n.width!==r.width||n.height!==r.height;if(i){var a=this.viewportFrame,o=a.x,s=a.y,c=a.width,l=a.height;o=Math.round(o),s=Math.round(s),c=Math.round(c),l=Math.round(l),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(o,s,c,l)}this.renderer.framebuffer.clear(e[0],e[1],e[2],e[3],t),i&&this.renderer.scissor.pop()},e.prototype.resize=function(){this.bind(null)},e.prototype.reset=function(){this.bind(null)},e.prototype.destroy=function(){this.renderer=null},e}();function al(e,t,n,r,i){n.buffer.update(i)}var ol={float:` + data[offset] = v; + `,vec2:` + data[offset] = v[0]; + data[offset+1] = v[1]; + `,vec3:` + data[offset] = v[0]; + data[offset+1] = v[1]; + data[offset+2] = v[2]; + + `,vec4:` + data[offset] = v[0]; + data[offset+1] = v[1]; + data[offset+2] = v[2]; + data[offset+3] = v[3]; + `,mat2:` + data[offset] = v[0]; + data[offset+1] = v[1]; + + data[offset+4] = v[2]; + data[offset+5] = v[3]; + `,mat3:` + data[offset] = v[0]; + data[offset+1] = v[1]; + data[offset+2] = v[2]; + + data[offset + 4] = v[3]; + data[offset + 5] = v[4]; + data[offset + 6] = v[5]; + + data[offset + 8] = v[6]; + data[offset + 9] = v[7]; + data[offset + 10] = v[8]; + `,mat4:` + for(var i = 0; i < 16; i++) + { + data[offset + i] = v[i]; + } + `},sl={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:32,mat3:48,mat4:64};function cl(e){for(var t=e.map(function(e){return{data:e,offset:0,dataLen:0,dirty:0}}),n=0,r=0,i=0,a=0;a1&&(n=Math.max(n,16)*o.data.size),o.dataLen=n,r%n!==0&&r<16){var s=r%n%16;r+=s,i+=s}r+n>16?(i=Math.ceil(i/16)*16,o.offset=i,i+=n,r=n):(o.offset=i,r+=n,i+=n)}return i=Math.ceil(i/16)*16,{uboElements:t,size:i}}function ll(e,t){var n=[];for(var r in e)t[r]&&n.push(t[r]);return n.sort(function(e,t){return e.index-t.index}),n}function ul(e,t){if(!e.autoManage)return{size:0,syncFunc:al};for(var n=ll(e.uniforms,t),r=cl(n),i=r.uboElements,a=r.size,o=[` + var v = null; + var v2 = null; + var cv = null; + var t = 0; + var gl = renderer.gl + var index = 0; + var data = buffer.data; + `],s=0;s1){var m=hc(c.data.type),h=Math.max(sl[c.data.type]/16,1),g=m/h,_=(4-g%4)%4;o.push(` + cv = ud.`+u+`.value; + v = uv.`+u+`; + offset = `+c.offset/4+`; + + t = 0; + + for(var i=0; i < `+c.data.size*h+`; i++) + { + for(var j = 0; j < `+g+`; j++) + { + data[offset++] = v[t++]; + } + offset += `+_+`; + } + + `)}else{var v=ol[c.data.type];o.push(` + cv = ud.`+u+`.value; + v = uv.`+u+`; + offset = `+c.offset/4+`; + `+v+`; + `)}}return o.push(` + renderer.buffer.update(buffer); + `),{size:a,syncFunc:Function(`ud`,`uv`,`renderer`,`syncData`,`buffer`,o.join(` +`))}}(function(){function e(){}return e})();var dl=function(){function e(e,t){this.program=e,this.uniformData=t,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}return e.prototype.destroy=function(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null},e}();function fl(e,t){for(var n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),i=0;it?1:-1});for(var o=0;o>=1,n++;this.stateId=e.data}for(var n=0;nthis.checkCountMax&&(this.checkCount=0,this.run())))},e.prototype.run=function(){for(var e=this.renderer.texture,t=e.managedTextures,n=!1,r=0;rthis.maxIdle&&(e.destroyTexture(i,!0),t[r]=null,n=!0)}if(n){for(var a=0,r=0;r=0;r--)this.unload(e.children[r])},e.prototype.destroy=function(){this.renderer=null},e}();function Dl(e){var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C;return C=`WebGL2RenderingContext`in globalThis&&e instanceof globalThis.WebGL2RenderingContext?(t={},t[ia.UNSIGNED_BYTE]=(n={},n[z.RGBA]=e.RGBA8,n[z.RGB]=e.RGB8,n[z.RG]=e.RG8,n[z.RED]=e.R8,n[z.RGBA_INTEGER]=e.RGBA8UI,n[z.RGB_INTEGER]=e.RGB8UI,n[z.RG_INTEGER]=e.RG8UI,n[z.RED_INTEGER]=e.R8UI,n[z.ALPHA]=e.ALPHA,n[z.LUMINANCE]=e.LUMINANCE,n[z.LUMINANCE_ALPHA]=e.LUMINANCE_ALPHA,n),t[ia.BYTE]=(r={},r[z.RGBA]=e.RGBA8_SNORM,r[z.RGB]=e.RGB8_SNORM,r[z.RG]=e.RG8_SNORM,r[z.RED]=e.R8_SNORM,r[z.RGBA_INTEGER]=e.RGBA8I,r[z.RGB_INTEGER]=e.RGB8I,r[z.RG_INTEGER]=e.RG8I,r[z.RED_INTEGER]=e.R8I,r),t[ia.UNSIGNED_SHORT]=(i={},i[z.RGBA_INTEGER]=e.RGBA16UI,i[z.RGB_INTEGER]=e.RGB16UI,i[z.RG_INTEGER]=e.RG16UI,i[z.RED_INTEGER]=e.R16UI,i[z.DEPTH_COMPONENT]=e.DEPTH_COMPONENT16,i),t[ia.SHORT]=(a={},a[z.RGBA_INTEGER]=e.RGBA16I,a[z.RGB_INTEGER]=e.RGB16I,a[z.RG_INTEGER]=e.RG16I,a[z.RED_INTEGER]=e.R16I,a),t[ia.UNSIGNED_INT]=(o={},o[z.RGBA_INTEGER]=e.RGBA32UI,o[z.RGB_INTEGER]=e.RGB32UI,o[z.RG_INTEGER]=e.RG32UI,o[z.RED_INTEGER]=e.R32UI,o[z.DEPTH_COMPONENT]=e.DEPTH_COMPONENT24,o),t[ia.INT]=(s={},s[z.RGBA_INTEGER]=e.RGBA32I,s[z.RGB_INTEGER]=e.RGB32I,s[z.RG_INTEGER]=e.RG32I,s[z.RED_INTEGER]=e.R32I,s),t[ia.FLOAT]=(c={},c[z.RGBA]=e.RGBA32F,c[z.RGB]=e.RGB32F,c[z.RG]=e.RG32F,c[z.RED]=e.R32F,c[z.DEPTH_COMPONENT]=e.DEPTH_COMPONENT32F,c),t[ia.HALF_FLOAT]=(l={},l[z.RGBA]=e.RGBA16F,l[z.RGB]=e.RGB16F,l[z.RG]=e.RG16F,l[z.RED]=e.R16F,l),t[ia.UNSIGNED_SHORT_5_6_5]=(u={},u[z.RGB]=e.RGB565,u),t[ia.UNSIGNED_SHORT_4_4_4_4]=(d={},d[z.RGBA]=e.RGBA4,d),t[ia.UNSIGNED_SHORT_5_5_5_1]=(f={},f[z.RGBA]=e.RGB5_A1,f),t[ia.UNSIGNED_INT_2_10_10_10_REV]=(p={},p[z.RGBA]=e.RGB10_A2,p[z.RGBA_INTEGER]=e.RGB10_A2UI,p),t[ia.UNSIGNED_INT_10F_11F_11F_REV]=(m={},m[z.RGB]=e.R11F_G11F_B10F,m),t[ia.UNSIGNED_INT_5_9_9_9_REV]=(h={},h[z.RGB]=e.RGB9_E5,h),t[ia.UNSIGNED_INT_24_8]=(g={},g[z.DEPTH_STENCIL]=e.DEPTH24_STENCIL8,g),t[ia.FLOAT_32_UNSIGNED_INT_24_8_REV]=(_={},_[z.DEPTH_STENCIL]=e.DEPTH32F_STENCIL8,_),t):(v={},v[ia.UNSIGNED_BYTE]=(y={},y[z.RGBA]=e.RGBA,y[z.RGB]=e.RGB,y[z.ALPHA]=e.ALPHA,y[z.LUMINANCE]=e.LUMINANCE,y[z.LUMINANCE_ALPHA]=e.LUMINANCE_ALPHA,y),v[ia.UNSIGNED_SHORT_5_6_5]=(b={},b[z.RGB]=e.RGB,b),v[ia.UNSIGNED_SHORT_4_4_4_4]=(x={},x[z.RGBA]=e.RGBA,x),v[ia.UNSIGNED_SHORT_5_5_5_1]=(S={},S[z.RGBA]=e.RGBA,S),v),C}var Ol=function(){function e(e){this.texture=e,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=ia.UNSIGNED_BYTE,this.internalFormat=z.RGBA,this.samplerType=0}return e}(),kl=function(){function e(e){this.renderer=e,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new us,this.hasIntegerTextures=!1}return e.prototype.contextChange=function(){var e=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=Dl(e);var t=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=t;for(var n=0;n=0;--a){var o=n[a];if(o){var s=o._glTextures[i];s.samplerType!==aa.FLOAT&&this.renderer.texture.unbind(o)}}},e.prototype.initTexture=function(e){var t=new Ol(this.gl.createTexture());return t.dirtyId=-1,e._glTextures[this.CONTEXT_UID]=t,this.managedTextures.push(e),e.on(`dispose`,this.destroyTexture,this),t},e.prototype.initTextureType=function(e,t){var n,r;t.internalFormat=(r=(n=this.internalFormats[e.type])?.[e.format])??e.format,this.webGLVersion===2&&e.type===ia.HALF_FLOAT?t.type=this.gl.HALF_FLOAT:t.type=e.type},e.prototype.updateTexture=function(e){var t=e._glTextures[this.CONTEXT_UID];if(t){var n=this.renderer;if(this.initTextureType(e,t),e.resource&&e.resource.upload(n,e,t))t.samplerType!==aa.FLOAT&&(this.hasIntegerTextures=!0);else{var r=e.realWidth,i=e.realHeight,a=n.gl;(t.width!==r||t.height!==i||t.dirtyId<0)&&(t.width=r,t.height=i,a.texImage2D(e.target,0,t.internalFormat,r,i,0,e.format,t.type,null))}e.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(e),t.dirtyId=e.dirtyId}},e.prototype.destroyTexture=function(e,t){var n=this.gl;if(e=e.castToBaseTexture(),e._glTextures[this.CONTEXT_UID]&&(this.unbind(e),n.deleteTexture(e._glTextures[this.CONTEXT_UID].texture),e.off(`dispose`,this.destroyTexture,this),delete e._glTextures[this.CONTEXT_UID],!t)){var r=this.managedTextures.indexOf(e);r!==-1&&mo(this.managedTextures,r,1)}},e.prototype.updateTextureStyle=function(e){var t=e._glTextures[this.CONTEXT_UID];t&&((e.mipmap===ca.POW2||this.webGLVersion!==2)&&!e.isPowerOfTwo?t.mipmap=!1:t.mipmap=e.mipmap>=1,this.webGLVersion!==2&&!e.isPowerOfTwo?t.wrapMode=sa.CLAMP:t.wrapMode=e.wrapMode,e.resource&&e.resource.style(this.renderer,e,t)||this.setStyle(e,t),t.dirtyStyleId=e.dirtyStyleId)},e.prototype.setStyle=function(e,t){var n=this.gl;if(t.mipmap&&e.mipmap!==ca.ON_MANUAL&&n.generateMipmap(e.target),n.texParameteri(e.target,n.TEXTURE_WRAP_S,t.wrapMode),n.texParameteri(e.target,n.TEXTURE_WRAP_T,t.wrapMode),t.mipmap){n.texParameteri(e.target,n.TEXTURE_MIN_FILTER,e.scaleMode===oa.LINEAR?n.LINEAR_MIPMAP_LINEAR:n.NEAREST_MIPMAP_NEAREST);var r=this.renderer.context.extensions.anisotropicFiltering;if(r&&e.anisotropicLevel>0&&e.scaleMode===oa.LINEAR){var i=Math.min(e.anisotropicLevel,n.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));n.texParameterf(e.target,r.TEXTURE_MAX_ANISOTROPY_EXT,i)}}else n.texParameteri(e.target,n.TEXTURE_MIN_FILTER,e.scaleMode===oa.LINEAR?n.LINEAR:n.NEAREST);n.texParameteri(e.target,n.TEXTURE_MAG_FILTER,e.scaleMode===oa.LINEAR?n.LINEAR:n.NEAREST)},e.prototype.destroy=function(){this.renderer=null},e}(),Al={__proto__:null,FilterSystem:Ks,BatchSystem:Js,ContextSystem:Xs,FramebufferSystem:$s,GeometrySystem:tc,MaskSystem:Yc,ScissorSystem:$c,StencilSystem:el,ProjectionSystem:tl,RenderTextureSystem:il,ShaderSystem:_l,StateSystem:Tl,TextureGCSystem:El,TextureSystem:kl},jl=new Ho,Ml=function(e){ns(t,e);function t(t,n){t===void 0&&(t=$i.UNKNOWN);var r=e.call(this)||this;return n=Object.assign({},B.RENDER_OPTIONS,n),r.options=n,r.type=t,r.screen=new Bo(0,0,n.width,n.height),r.view=n.view||B.ADAPTER.createCanvas(),r.resolution=n.resolution||B.RESOLUTION,r.useContextAlpha=n.useContextAlpha,r.autoDensity=!!n.autoDensity,r.preserveDrawingBuffer=n.preserveDrawingBuffer,r.clearBeforeRender=n.clearBeforeRender,r._backgroundColor=0,r._backgroundColorRgba=[0,0,0,1],r._backgroundColorString=`#000000`,r.backgroundColor=n.backgroundColor||r._backgroundColor,r.backgroundAlpha=n.backgroundAlpha,n.transparent!==void 0&&(vo(`6.0.0`,`Option transparent is deprecated, please use backgroundAlpha instead.`),r.useContextAlpha=n.transparent,r.backgroundAlpha=n.transparent?0:1),r._lastObjectRendered=null,r.plugins={},r}return t.prototype.initPlugins=function(e){for(var t in e)this.plugins[t]=new e[t](this)},Object.defineProperty(t.prototype,`width`,{get:function(){return this.view.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`height`,{get:function(){return this.view.height},enumerable:!1,configurable:!0}),t.prototype.resize=function(e,t){this.view.width=Math.round(e*this.resolution),this.view.height=Math.round(t*this.resolution);var n=this.view.width/this.resolution,r=this.view.height/this.resolution;this.screen.width=n,this.screen.height=r,this.autoDensity&&(this.view.style.width=n+`px`,this.view.style.height=r+`px`),this.emit(`resize`,n,r)},t.prototype.generateTexture=function(e,t,n,r){t===void 0&&(t={}),typeof t==`number`&&(vo(`6.1.0`,`generateTexture options (scaleMode, resolution, region) are now object options.`),t={scaleMode:t,resolution:n,region:r});var i=t.region,a=os(t,[`region`]);r=i||e.getLocalBounds(null,!0),r.width===0&&(r.width=1),r.height===0&&(r.height=1);var o=Os.create(rs({width:r.width,height:r.height},a));return jl.tx=-r.x,jl.ty=-r.y,this.render(e,{renderTexture:o,clear:!1,transform:jl,skipUpdateTransform:!!e.parent}),o},t.prototype.destroy=function(e){for(var t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null;e&&this.view.parentNode&&this.view.parentNode.removeChild(this.view);var n=this;n.plugins=null,n.type=$i.UNKNOWN,n.view=null,n.screen=null,n._tempDisplayObjectParent=null,n.options=null,this._backgroundColorRgba=null,this._backgroundColorString=null,this._lastObjectRendered=null},Object.defineProperty(t.prototype,`backgroundColor`,{get:function(){return this._backgroundColor},set:function(e){this._backgroundColor=e,this._backgroundColorString=io(e),ro(e,this._backgroundColorRgba)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`backgroundAlpha`,{get:function(){return this._backgroundColorRgba[3]},set:function(e){this._backgroundColorRgba[3]=e},enumerable:!1,configurable:!0}),t}(Ya.default),Nl=function(){function e(e){this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}return e}(),Pl=function(){function e(e){this.renderer=e,this.managedBuffers={},this.boundBufferBases={}}return e.prototype.destroy=function(){this.renderer=null},e.prototype.contextChange=function(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID},e.prototype.bind=function(e){var t=this,n=t.gl,r=t.CONTEXT_UID,i=e._glBuffers[r]||this.createGLBuffer(e);n.bindBuffer(e.type,i.buffer)},e.prototype.bindBufferBase=function(e,t){var n=this,r=n.gl,i=n.CONTEXT_UID;if(this.boundBufferBases[t]!==e){var a=e._glBuffers[i]||this.createGLBuffer(e);this.boundBufferBases[t]=e,r.bindBufferBase(r.UNIFORM_BUFFER,t,a.buffer)}},e.prototype.bindBufferRange=function(e,t,n){var r=this,i=r.gl,a=r.CONTEXT_UID;n||=0;var o=e._glBuffers[a]||this.createGLBuffer(e);i.bindBufferRange(i.UNIFORM_BUFFER,t||0,o.buffer,n*256,256)},e.prototype.update=function(e){var t=this,n=t.gl,r=t.CONTEXT_UID,i=e._glBuffers[r];if(e._updateID!==i.updateID)if(i.updateID=e._updateID,n.bindBuffer(e.type,i.buffer),i.byteLength>=e.data.byteLength)n.bufferSubData(e.type,0,e.data);else{var a=e.static?n.STATIC_DRAW:n.DYNAMIC_DRAW;i.byteLength=e.data.byteLength,n.bufferData(e.type,e.data,a)}},e.prototype.dispose=function(e,t){if(this.managedBuffers[e.id]){delete this.managedBuffers[e.id];var n=e._glBuffers[this.CONTEXT_UID],r=this.gl;e.disposeRunner.remove(this),n&&(t||r.deleteBuffer(n.buffer),delete e._glBuffers[this.CONTEXT_UID])}},e.prototype.disposeAll=function(e){for(var t=Object.keys(this.managedBuffers),n=0;n=ha.HIGH?this.multisample=ha.HIGH:t>=ha.MEDIUM?this.multisample=ha.MEDIUM:t>=ha.LOW?this.multisample=ha.LOW:this.multisample=ha.NONE},t.prototype.addSystem=function(e,t){var n=new e(this);if(this[t])throw Error(`Whoops! The name "`+t+`" is already in use`);for(var r in this[t]=n,this.runners)this.runners[r].add(n);return this},t.prototype.render=function(e,t){var n,r,i,a;if(t&&(t instanceof Os?(vo(`6.0.0`,`Renderer#render arguments changed, use options instead.`),n=t,r=arguments[2],i=arguments[3],a=arguments[4]):(n=t.renderTexture,r=t.clear,i=t.transform,a=t.skipUpdateTransform)),this.renderingToScreen=!n,this.runners.prerender.emit(),this.emit(`prerender`),this.projection.transform=i,!this.context.isLost){if(n||(this._lastObjectRendered=e),!a){var o=e.enableTempParent();e.updateTransform(),e.disableTempParent(o)}this.renderTexture.bind(n),this.batch.currentRenderer.start(),(r===void 0?this.clearBeforeRender:r)&&this.renderTexture.clear(),e.render(this),this.batch.currentRenderer.flush(),n&&n.baseTexture.update(),this.runners.postrender.emit(),this.projection.transform=null,this.emit(`postrender`)}},t.prototype.generateTexture=function(t,n,r,i){n===void 0&&(n={});var a=e.prototype.generateTexture.call(this,t,n,r,i);return this.framebuffer.blit(),a},t.prototype.resize=function(t,n){e.prototype.resize.call(this,t,n),this.runners.resize.emit(this.screen.height,this.screen.width)},t.prototype.reset=function(){return this.runners.reset.emit(),this},t.prototype.clear=function(){this.renderTexture.bind(),this.renderTexture.clear()},t.prototype.destroy=function(t){for(var n in this.runners.destroy.emit(),this.runners)this.runners[n].destroy();e.prototype.destroy.call(this,t),this.gl=null},Object.defineProperty(t.prototype,`extract`,{get:function(){return vo(`6.0.0`,`Renderer#extract has been deprecated, please use Renderer#plugins.extract instead.`),this.plugins.extract},enumerable:!1,configurable:!0}),t.registerPlugin=function(e,t){vo(`6.5.0`,`Renderer.registerPlugin() has been deprecated, please use extensions.add() instead.`),Oo.add({name:e,type:Eo.RendererPlugin,ref:t})},t.__plugins={},t}(Ml);Oo.handleByMap(Eo.RendererPlugin,Fl.__plugins);function Il(e){return Fl.create(e)}var Ll=`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; +}`,Rl=Ll;(function(){function e(e){vo(`6.1.0`,`System class is deprecated, implemement ISystem interface instead.`),this.renderer=e}return e.prototype.destroy=function(){this.renderer=null},e})();var zl=function(){function e(){this.texArray=null,this.blend=0,this.type=na.TRIANGLES,this.start=0,this.size=0,this.data=null}return e}(),Bl=function(){function e(){this.elements=[],this.ids=[],this.count=0}return e.prototype.clear=function(){for(var e=0;ethis.size&&this.flush(),this._vertexCount+=e.vertexData.length/2,this._indexCount+=e.indices.length,this._bufferedTextures[this._bufferSize]=e._texture.baseTexture,this._bufferedElements[this._bufferSize++]=e)},t.prototype.buildTexturesAndDrawCalls=function(){var e=this,n=e._bufferedTextures,r=e.MAX_TEXTURES,i=t._textureArrayPool,a=this.renderer.batch,o=this._tempBoundTextures,s=this.renderer.textureGC.count,c=++us._globalBatch,l=0,u=i[0],d=0;a.copyBoundTextures(o,r);for(var f=0;f=r&&(a.boundArray(u,o,c,r),this.buildDrawCalls(u,d,f),d=f,u=i[++l],++c),p._batchEnabled=c,p.touched=s,u.elements[u.count++]=p)}u.count>0&&(a.boundArray(u,o,c,r),this.buildDrawCalls(u,d,this._bufferSize),++l,++c);for(var f=0;f0&&(t+=` +else `),nthis.maxX||this.minY>this.maxY},e.prototype.clear=function(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0},e.prototype.getRectangle=function(e){return this.minX>this.maxX||this.minY>this.maxY?Bo.EMPTY:(e||=new Bo(0,0,1,1),e.x=this.minX,e.y=this.minY,e.width=this.maxX-this.minX,e.height=this.maxY-this.minY,e)},e.prototype.addPoint=function(e){this.minX=Math.min(this.minX,e.x),this.maxX=Math.max(this.maxX,e.x),this.minY=Math.min(this.minY,e.y),this.maxY=Math.max(this.maxY,e.y)},e.prototype.addPointMatrix=function(e,t){var n=e.a,r=e.b,i=e.c,a=e.d,o=e.tx,s=e.ty,c=n*t.x+i*t.y+o,l=r*t.x+a*t.y+s;this.minX=Math.min(this.minX,c),this.maxX=Math.max(this.maxX,c),this.minY=Math.min(this.minY,l),this.maxY=Math.max(this.maxY,l)},e.prototype.addQuad=function(e){var t=this.minX,n=this.minY,r=this.maxX,i=this.maxY,a=e[0],o=e[1];t=ar?a:r,i=o>i?o:i,a=e[2],o=e[3],t=ar?a:r,i=o>i?o:i,a=e[4],o=e[5],t=ar?a:r,i=o>i?o:i,a=e[6],o=e[7],t=ar?a:r,i=o>i?o:i,this.minX=t,this.minY=n,this.maxX=r,this.maxY=i},e.prototype.addFrame=function(e,t,n,r,i){this.addFrameMatrix(e.worldTransform,t,n,r,i)},e.prototype.addFrameMatrix=function(e,t,n,r,i){var a=e.a,o=e.b,s=e.c,c=e.d,l=e.tx,u=e.ty,d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,h=a*t+s*n+l,g=o*t+c*n+u;d=hp?h:p,m=g>m?g:m,h=a*r+s*n+l,g=o*r+c*n+u,d=hp?h:p,m=g>m?g:m,h=a*t+s*i+l,g=o*t+c*i+u,d=hp?h:p,m=g>m?g:m,h=a*r+s*i+l,g=o*r+c*i+u,d=hp?h:p,m=g>m?g:m,this.minX=d,this.minY=f,this.maxX=p,this.maxY=m},e.prototype.addVertexData=function(e,t,n){for(var r=this.minX,i=this.minY,a=this.maxX,o=this.maxY,s=t;sa?c:a,o=l>o?l:o}this.minX=r,this.minY=i,this.maxX=a,this.maxY=o},e.prototype.addVertices=function(e,t,n,r){this.addVerticesMatrix(e.worldTransform,t,n,r)},e.prototype.addVerticesMatrix=function(e,t,n,r,i,a){i===void 0&&(i=0),a===void 0&&(a=i);for(var o=e.a,s=e.b,c=e.c,l=e.d,u=e.tx,d=e.ty,f=this.minX,p=this.minY,m=this.maxX,h=this.maxY,g=n;gr?e.maxX:r,this.maxY=e.maxY>i?e.maxY:i},e.prototype.addBoundsMask=function(e,t){var n=e.minX>t.minX?e.minX:t.minX,r=e.minY>t.minY?e.minY:t.minY,i=e.maxXc?i:c,this.maxY=a>l?a:l}},e.prototype.addBoundsMatrix=function(e,t){this.addFrameMatrix(t,e.minX,e.minY,e.maxX,e.maxY)},e.prototype.addBoundsArea=function(e,t){var n=e.minX>t.x?e.minX:t.x,r=e.minY>t.y?e.minY:t.y,i=e.maxXc?i:c,this.maxY=a>l?a:l}},e.prototype.pad=function(e,t){e===void 0&&(e=0),t===void 0&&(t=e),this.isEmpty()||(this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t)},e.prototype.addFramePad=function(e,t,n,r,i,a){e-=i,t-=a,n+=i,r+=a,this.minX=this.minXn?this.maxX:n,this.minY=this.minYr?this.maxY:r},e}(),tu=function(e,t){return tu=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])},tu(e,t)};function nu(e,t){tu(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var ru=function(e){nu(t,e);function t(){var t=e.call(this)||this;return t.tempDisplayObjectParent=null,t.transform=new Qo,t.alpha=1,t.visible=!0,t.renderable=!0,t.cullable=!1,t.cullArea=null,t.parent=null,t.worldAlpha=1,t._lastSortedIndex=0,t._zIndex=0,t.filterArea=null,t.filters=null,t._enabledFilters=null,t._bounds=new eu,t._localBounds=null,t._boundsID=0,t._boundsRect=null,t._localBoundsRect=null,t._mask=null,t._maskRefCount=0,t._destroyed=!1,t.isSprite=!1,t.isMask=!1,t}return t.mixin=function(e){for(var n=Object.keys(e),r=0;r1)for(var r=0;rthis.children.length)throw Error(e+`addChildAt: The index `+t+` supplied is out of bounds `+this.children.length);return e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.splice(t,0,e),this._boundsID++,this.onChildrenChange(t),e.emit(`added`,this),this.emit(`childAdded`,e,this,t),e},t.prototype.swapChildren=function(e,t){if(e!==t){var n=this.getChildIndex(e),r=this.getChildIndex(t);this.children[n]=t,this.children[r]=e,this.onChildrenChange(n=this.children.length)throw Error(`The index `+t+` supplied is out of bounds `+this.children.length);var n=this.getChildIndex(e);mo(this.children,n,1),this.children.splice(t,0,e),this.onChildrenChange(t)},t.prototype.getChildAt=function(e){if(e<0||e>=this.children.length)throw Error(`getChildAt: Index (`+e+`) does not exist.`);return this.children[e]},t.prototype.removeChild=function(){for(var e=arguments,t=[],n=0;n1)for(var r=0;r0&&i<=r){a=this.children.splice(n,i);for(var o=0;o1&&this.children.sort(au),this.sortDirty=!1},t.prototype.updateTransform=function(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(var e=0,t=this.children.length;e0&&n.height>0){var r,i;if(this.cullArea?(r=this.cullArea,i=this.worldTransform):this._render!==t.prototype._render&&(r=this.getBounds(!0)),r&&n.intersects(r,i))this._render(e);else if(this.cullArea)return;for(var a=0,o=this.children.length;anew Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),du=class e{constructor(){this._breathParameters=[],this._currentTime=0}static create(){return new e}setParameters(e){this._breathParameters=e}getParameters(){return this._breathParameters}updateParameters(e,t){this._currentTime+=t;let n=this._currentTime*2*3.14159;for(let t=0;t=1&&(r=1,this._blinkingState=hu.EyeState_Closed,this._stateStartTimeSeconds=this._userTimeSeconds),n=1-r;break;case hu.EyeState_Closed:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,r>=1&&(this._blinkingState=hu.EyeState_Opening,this._stateStartTimeSeconds=this._userTimeSeconds),n=0;break;case hu.EyeState_Opening:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,r>=1&&(r=1,this._blinkingState=hu.EyeState_Interval,this._nextBlinkingTime=this.determinNextBlinkingTiming()),n=r;break;case hu.EyeState_Interval:this._nextBlinkingTime(e[e.EyeState_First=0]=`EyeState_First`,e[e.EyeState_Interval=1]=`EyeState_Interval`,e[e.EyeState_Closing=2]=`EyeState_Closing`,e[e.EyeState_Closed=3]=`EyeState_Closed`,e[e.EyeState_Opening=4]=`EyeState_Opening`,e))(hu||{});const gu=.5;var _u=class e{static create(t){let n=new e;typeof t.FadeInTime==`number`&&(n._fadeTimeSeconds=t.FadeInTime,n._fadeTimeSeconds<=0&&(n._fadeTimeSeconds=gu));let r=t.Groups,i=r.length;for(let e=0;e.001){if(i>=0)break;i=o,a=e.getPartOpacityByIndex(n),a+=t/this._fadeTimeSeconds,a>1&&(a=1)}}i<0&&(i=0,a=1);for(let t=n;ts&&(r=1-s/(1-a)),t>r&&(t=r),e.setPartOpacityByIndex(n,t)}}}constructor(){this._fadeTimeSeconds=gu,this._lastModel=void 0,this._partGroups=[],this._partGroupCounts=[]}},vu=class e{constructor(e){this.parameterIndex=0,this.partIndex=0,this.partId=``,this.link=[],e!=null&&this.assignment(e)}assignment(e){return this.partId=e.partId,this.link=e.link.map(e=>e.clone()),this}initialize(e){this.parameterIndex=e.getParameterIndex(this.partId),this.partIndex=e.getPartIndex(this.partId),e.setParameterValueByIndex(this.parameterIndex,1)}clone(){let t=new e;return t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=this.link.map(e=>e.clone()),t}},yu=class e{constructor(e,t){this.x=e||0,this.y=t||0}add(t){let n=new e(0,0);return n.x=this.x+t.x,n.y=this.y+t.y,n}substract(t){let n=new e(0,0);return n.x=this.x-t.x,n.y=this.y-t.y,n}multiply(t){let n=new e(0,0);return n.x=this.x*t.x,n.y=this.y*t.y,n}multiplyByScaler(t){return this.multiply(new e(t,t))}division(t){let n=new e(0,0);return n.x=this.x/t.x,n.y=this.y/t.y,n}divisionByScalar(t){return this.division(new e(t,t))}getLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}getDistanceWith(e){return Math.sqrt((this.x-e.x)*(this.x-e.x)+(this.y-e.y)*(this.y-e.y))}dot(e){return this.x*e.x+this.y*e.y}normalize(){let e=(this.x*this.x+this.y*this.y)**.5;this.x/=e,this.y/=e}isEqual(e){return this.x==e.x&&this.y==e.y}isNotEqual(e){return!this.isEqual(e)}};const bu=class{static range(e,t,n){return en&&(e=n),e}static sin(e){return Math.sin(e)}static cos(e){return Math.cos(e)}static abs(e){return Math.abs(e)}static sqrt(e){return Math.sqrt(e)}static cbrt(e){if(e===0)return e;let t=e,n=t<0;n&&(t=-t);let r;return t===1/0?r=1/0:(r=Math.exp(Math.log(t)/3),r=(t/(r*r)+2*r)/3),n?-r:r}static getEasingSine(e){return e<0?0:e>1?1:.5-.5*this.cos(e*Math.PI)}static max(e,t){return e>t?e:t}static min(e,t){return e>t?t:e}static degreesToRadian(e){return e/180*Math.PI}static radianToDegrees(e){return e*180/Math.PI}static directionToRadian(e,t){let n=Math.atan2(t.y,t.x),r=Math.atan2(e.y,e.x),i=n-r;for(;i<-Math.PI;)i+=Math.PI*2;for(;i>Math.PI;)i-=Math.PI*2;return i}static directionToDegrees(e,t){let n=this.directionToRadian(e,t),r=this.radianToDegrees(n);return t.x-e.x>0&&(r=-r),r}static radianToDirection(e){let t=new yu;return t.x=this.sin(e),t.y=this.cos(e),t}static quadraticEquation(e,t,n){return this.abs(e)1&&(e=1),t<0?t=0:t>1&&(t=1),n<0?n=0:n>1&&(n=1),r<0?r=0:r>1&&(r=1),this._modelColor.R=e,this._modelColor.G=t,this._modelColor.B=n,this._modelColor.A=r}getModelColor(){return Object.assign({},this._modelColor)}setIsPremultipliedAlpha(e){this._isPremultipliedAlpha=e}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(e){this._isCulling=e}isCulling(){return this._isCulling}setAnisotropy(e){this._anisortopy=e}getAnisotropy(){return this._anisortopy}getModel(){return this._model}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisortopy=0,this._modelColor=new Tu,this._mvpMatrix4x4=new Su,this._mvpMatrix4x4.loadIdentity()}},wu=(e=>(e[e.CubismBlendMode_Normal=0]=`CubismBlendMode_Normal`,e[e.CubismBlendMode_Additive=1]=`CubismBlendMode_Additive`,e[e.CubismBlendMode_Multiplicative=2]=`CubismBlendMode_Multiplicative`,e))(wu||{}),Tu=class{constructor(){this.R=1,this.G=1,this.B=1,this.A=1}};let Eu=!1,Du=!1,Ou;const ku={vertexOffset:0,vertexStep:2};var Au=class{static startUp(e){if(Eu)return Nu(`CubismFramework.startUp() is already done.`),Eu;if(Live2DCubismCore._isStarted)return Eu=!0,!0;if(Live2DCubismCore._isStarted=!0,Ou=e,Ou&&Live2DCubismCore.Logging.csmSetLogFunction(Ou.logFunction),Eu=!0,Eu){let e=Live2DCubismCore.Version.csmGetVersion(),t=(e&4278190080)>>24,n=(e&16711680)>>16,r=e&65535,i=e;Nu(`Live2D Cubism Core version: {0}.{1}.{2} ({3})`,(`00`+t).slice(-2),(`00`+n).slice(-2),(`0000`+r).slice(-4),i)}return Nu(`CubismFramework.startUp() is complete.`),Eu}static cleanUp(){Eu=!1,Du=!1,Ou=void 0}static initialize(){if(!Eu){Pu(`CubismFramework is not started.`);return}if(Du){Pu(`CubismFramework.initialize() skipped, already initialized.`);return}Du=!0,Nu(`CubismFramework.initialize() is complete.`)}static dispose(){if(!Eu){Pu(`CubismFramework is not started.`);return}if(!Du){Pu(`CubismFramework.dispose() skipped, not initialized.`);return}Cu.staticRelease(),Du=!1,Nu(`CubismFramework.dispose() is complete.`)}static isStarted(){return Eu}static isInitialized(){return Du}static coreLogFunction(e){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(e)}static getLoggingLevel(){return Ou==null?ju.LogLevel_Off:Ou.loggingLevel}constructor(){}},ju=(e=>(e[e.LogLevel_Verbose=0]=`LogLevel_Verbose`,e[e.LogLevel_Debug=1]=`LogLevel_Debug`,e[e.LogLevel_Info=2]=`LogLevel_Info`,e[e.LogLevel_Warning=3]=`LogLevel_Warning`,e[e.LogLevel_Error=4]=`LogLevel_Error`,e[e.LogLevel_Off=5]=`LogLevel_Off`,e))(ju||{});function Mu(e,...t){Iu.print(ju.LogLevel_Debug,`[CSM][D]`+e+` +`,t)}function Nu(e,...t){Iu.print(ju.LogLevel_Info,`[CSM][I]`+e+` +`,t)}function Pu(e,...t){Iu.print(ju.LogLevel_Warning,`[CSM][W]`+e+` +`,t)}function Fu(e,...t){Iu.print(ju.LogLevel_Error,`[CSM][E]`+e+` +`,t)}var Iu=class{static print(e,t,n){if(en[t]);r(i)}static dumpBytes(e,t,n){for(let r=0;r0?this.print(e,` +`):r%8==0&&r>0&&this.print(e,` `),this.print(e,`{0} `,[t[r]&255]);this.print(e,` +`)}constructor(){}},Lu=class{update(){this._model.update(),this._model.drawables.resetDynamicFlags()}getCanvasWidth(){return this._model==null?0:this._model.canvasinfo.CanvasWidth/this._model.canvasinfo.PixelsPerUnit}getCanvasHeight(){return this._model==null?0:this._model.canvasinfo.CanvasHeight/this._model.canvasinfo.PixelsPerUnit}saveParameters(){let e=this._model.parameters.count,t=this._savedParameters.length;for(let n=0;nt&&(t=this._model.parameters.minimumValues[e]),this._parameterValues[e]=n==1?t:this._parameterValues[e]=this._parameterValues[e]*(1-n)+t*n}setParameterValueById(e,t,n=1){let r=this.getParameterIndex(e);this.setParameterValueByIndex(r,t,n)}addParameterValueByIndex(e,t,n=1){this.setParameterValueByIndex(e,this.getParameterValueByIndex(e)+t*n)}addParameterValueById(e,t,n=1){let r=this.getParameterIndex(e);this.addParameterValueByIndex(r,t,n)}multiplyParameterValueById(e,t,n=1){let r=this.getParameterIndex(e);this.multiplyParameterValueByIndex(r,t,n)}multiplyParameterValueByIndex(e,t,n=1){this.setParameterValueByIndex(e,this.getParameterValueByIndex(e)*(1+(t-1)*n))}getDrawableIds(){return this._drawableIds.slice()}getDrawableIndex(e){let t=this._model.drawables.count;for(let n=0;nt&&(e=t);for(let t=0;t0&&t.getEndTime()(e[e.ExpressionBlendType_Add=0]=`ExpressionBlendType_Add`,e[e.ExpressionBlendType_Multiply=1]=`ExpressionBlendType_Multiply`,e[e.ExpressionBlendType_Overwrite=2]=`ExpressionBlendType_Overwrite`,e))(Vu||{}),Hu;(e=>{e.supportMoreMaskDivisions=!0,e.setOpacityFromMotion=!1})(Hu||={});var Uu=(e=>(e[e.CubismMotionCurveTarget_Model=0]=`CubismMotionCurveTarget_Model`,e[e.CubismMotionCurveTarget_Parameter=1]=`CubismMotionCurveTarget_Parameter`,e[e.CubismMotionCurveTarget_PartOpacity=2]=`CubismMotionCurveTarget_PartOpacity`,e))(Uu||{}),Wu=(e=>(e[e.CubismMotionSegmentType_Linear=0]=`CubismMotionSegmentType_Linear`,e[e.CubismMotionSegmentType_Bezier=1]=`CubismMotionSegmentType_Bezier`,e[e.CubismMotionSegmentType_Stepped=2]=`CubismMotionSegmentType_Stepped`,e[e.CubismMotionSegmentType_InverseStepped=3]=`CubismMotionSegmentType_InverseStepped`,e))(Wu||{}),Gu=class{constructor(e=0,t=0){this.time=e,this.value=t}},Ku=class{constructor(){this.basePointIndex=0,this.segmentType=0}},qu=class{constructor(){this.id=``,this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}},Ju=class{constructor(){this.fireTime=0,this.value=``}},Yu=class{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=[],this.segments=[],this.points=[],this.events=[]}},Xu=class{constructor(e){this._json=e}release(){this._json=void 0}getMotionDuration(){return this._json.Meta.Duration}isMotionLoop(){return this._json.Meta.Loop||!1}getEvaluationOptionFlag(e){return Zu.EvaluationOptionFlag_AreBeziersRistricted==e?!!this._json.Meta.AreBeziersRestricted:!1}getMotionCurveCount(){return this._json.Meta.CurveCount}getMotionFps(){return this._json.Meta.Fps}getMotionTotalSegmentCount(){return this._json.Meta.TotalSegmentCount}getMotionTotalPointCount(){return this._json.Meta.TotalPointCount}getMotionFadeInTime(){return this._json.Meta.FadeInTime}getMotionFadeOutTime(){return this._json.Meta.FadeOutTime}getMotionCurveTarget(e){return this._json.Curves[e].Target}getMotionCurveId(e){return this._json.Curves[e].Id}getMotionCurveFadeInTime(e){return this._json.Curves[e].FadeInTime}getMotionCurveFadeOutTime(e){return this._json.Curves[e].FadeOutTime}getMotionCurveSegmentCount(e){return this._json.Curves[e].Segments.length}getMotionCurveSegment(e,t){return this._json.Curves[e].Segments[t]}getEventCount(){return this._json.Meta.UserDataCount||0}getTotalEventValueSize(){return this._json.Meta.TotalUserDataSize}getEventTime(e){return this._json.UserData[e].Time}getEventValue(e){return this._json.UserData[e].Value}},Zu=(e=>(e[e.EvaluationOptionFlag_AreBeziersRistricted=0]=`EvaluationOptionFlag_AreBeziersRistricted`,e))(Zu||{});function Qu(e,t,n){let r=new Gu;return r.time=e.time+(t.time-e.time)*n,r.value=e.value+(t.value-e.value)*n,r}function $u(e,t){let n=(t-e[0].time)/(e[1].time-e[0].time);return n<0&&(n=0),e[0].value+(e[1].value-e[0].value)*n}function ed(e,t){let n=(t-e[0].time)/(e[3].time-e[0].time);n<0&&(n=0);let r=Qu(e[0],e[1],n),i=Qu(e[1],e[2],n),a=Qu(e[2],e[3],n),o=Qu(r,i,n),s=Qu(i,a,n);return Qu(o,s,n).value}function td(e,t){let n=t,r=e[0].time,i=e[3].time,a=e[1].time,o=e[2].time,s=i-3*o+3*a-r,c=3*o-6*a+3*r,l=3*a-3*r,u=r-n,d=xu.cardanoAlgorithmForBezier(s,c,l,u),f=Qu(e[0],e[1],d),p=Qu(e[1],e[2],d),m=Qu(e[2],e[3],d),h=Qu(f,p,d),g=Qu(p,m,d);return Qu(h,g,d).value}function nd(e,t){return e[0].value}function rd(e,t){return e[1].value}function id(e,t,n){let r=e.curves[t],i=-1,a=r.baseSegmentIndex+r.segmentCount,o=0;for(let t=r.baseSegmentIndex;tn){i=t;break}if(i==-1)return e.points[o].value;let s=e.segments[i];return s.evaluate(e.points.slice(s.basePointIndex),n)}var ad=class e extends zu{constructor(){super(),this._eyeBlinkParameterIds=[],this._lipSyncParameterIds=[],this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0}static create(t,n){let r=new e;return r.parse(t),r._sourceFrameRate=r._motionData.fps,r._loopDurationSeconds=r._motionData.duration,r._onFinishedMotion=n,r}doUpdateParameters(e,t,n,r){this._modelCurveIdEyeBlink??=`EyeBlink`,this._modelCurveIdLipSync??=`LipSync`;let i=t-r.getStartTime();i<0&&(i=0);let a=Number.MAX_VALUE,o=Number.MAX_VALUE,s=0,c=0;this._eyeBlinkParameterIds.length>64&&Mu(`too many eye blink targets : {0}`,this._eyeBlinkParameterIds.length),this._lipSyncParameterIds.length>64&&Mu(`too many lip sync targets : {0}`,this._lipSyncParameterIds.length);let l=this._fadeInSeconds<=0?1:xu.getEasingSine((t-r.getFadeInStartTime())/this._fadeInSeconds),u=this._fadeOutSeconds<=0||r.getEndTime()<0?1:xu.getEasingSine((r.getEndTime()-t)/this._fadeOutSeconds),d,f,p,m=i;if(this._isLoop)for(;m>this._motionData.duration;)m-=this._motionData.duration;let h=this._motionData.curves;for(f=0;f>t&1)continue;let i=r+(o-r)*n;e.setParameterValueById(this._eyeBlinkParameterIds[t],i)}if(a!=Number.MAX_VALUE)for(let t=0;t>t&1)continue;let i=r+(a-r)*n;e.setParameterValueById(this._lipSyncParameterIds[t],i)}for(;f=this._motionData.duration&&(this._isLoop?(r.setStartTime(t),this._isLoopFadeIn&&r.setFadeInStartTime(t)):(this._onFinishedMotion&&this._onFinishedMotion(this),r.setIsFinished(!0))),this._lastWeight=n}setIsLoop(e){this._isLoop=e}isLoop(){return this._isLoop}setIsLoopFadeIn(e){this._isLoopFadeIn=e}isLoopFadeIn(){return this._isLoopFadeIn}getDuration(){return this._isLoop?-1:this._loopDurationSeconds}getLoopDuration(){return this._loopDurationSeconds}setParameterFadeInTime(e,t){let n=this._motionData.curves;for(let r=0;rnew qu),this._motionData.segments=Array.from({length:t.getMotionTotalSegmentCount()}).map(()=>new Ku),this._motionData.events=Array.from({length:this._motionData.eventCount}).map(()=>new Ju),this._motionData.points=[];let a=0,o=0;for(let e=0;ee&&this._motionData.events[n].fireTime<=t&&this._firedEventValues.push(this._motionData.events[n].value);return this._firedEventValues}},od=class{constructor(){this._autoDelete=!1,this._available=!0,this._finished=!1,this._started=!1,this._startTimeSeconds=-1,this._fadeInStartTimeSeconds=0,this._endTimeSeconds=-1,this._stateTimeSeconds=0,this._stateWeight=0,this._lastEventCheckSeconds=0,this._motionQueueEntryHandle=this,this._fadeOutSeconds=0,this._isTriggeredFadeOut=!1}release(){this._autoDelete&&this._motion&&this._motion.release()}setFadeOut(e){this._fadeOutSeconds=e,this._isTriggeredFadeOut=!0}startFadeOut(e,t){let n=t+e;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||nt!=null&&t._motionQueueEntryHandle==e)}setEventCallback(e,t=null){this._eventCallBack=e,this._eventCustomData=t}doUpdateMotion(e,t){let n=!1,r=0;for(;r(e[e.CubismPhysicsTargetType_Parameter=0]=`CubismPhysicsTargetType_Parameter`,e))(ld||{}),ud=(e=>(e[e.CubismPhysicsSource_X=0]=`CubismPhysicsSource_X`,e[e.CubismPhysicsSource_Y=1]=`CubismPhysicsSource_Y`,e[e.CubismPhysicsSource_Angle=2]=`CubismPhysicsSource_Angle`,e))(ud||{}),dd=class{constructor(){this.initialPosition=new yu(0,0),this.position=new yu(0,0),this.lastPosition=new yu(0,0),this.lastGravity=new yu(0,0),this.force=new yu(0,0),this.velocity=new yu(0,0)}},fd=class{constructor(){this.normalizationPosition={},this.normalizationAngle={}}},pd=class{constructor(){this.source={}}},md=class{constructor(){this.destination={},this.translationScale=new yu(0,0)}},hd=class{constructor(){this.settings=[],this.inputs=[],this.outputs=[],this.particles=[],this.gravity=new yu(0,0),this.wind=new yu(0,0)}},gd=class{constructor(e){this._json=e}release(){this._json=void 0}getGravity(){let e=new yu(0,0);return e.x=this._json.Meta.EffectiveForces.Gravity.X,e.y=this._json.Meta.EffectiveForces.Gravity.Y,e}getWind(){let e=new yu(0,0);return e.x=this._json.Meta.EffectiveForces.Wind.X,e.y=this._json.Meta.EffectiveForces.Wind.Y,e}getSubRigCount(){return this._json.Meta.PhysicsSettingCount}getTotalInputCount(){return this._json.Meta.TotalInputCount}getTotalOutputCount(){return this._json.Meta.TotalOutputCount}getVertexCount(){return this._json.Meta.VertexCount}getNormalizationPositionMinimumValue(e){return this._json.PhysicsSettings[e].Normalization.Position.Minimum}getNormalizationPositionMaximumValue(e){return this._json.PhysicsSettings[e].Normalization.Position.Maximum}getNormalizationPositionDefaultValue(e){return this._json.PhysicsSettings[e].Normalization.Position.Default}getNormalizationAngleMinimumValue(e){return this._json.PhysicsSettings[e].Normalization.Angle.Minimum}getNormalizationAngleMaximumValue(e){return this._json.PhysicsSettings[e].Normalization.Angle.Maximum}getNormalizationAngleDefaultValue(e){return this._json.PhysicsSettings[e].Normalization.Angle.Default}getInputCount(e){return this._json.PhysicsSettings[e].Input.length}getInputWeight(e,t){return this._json.PhysicsSettings[e].Input[t].Weight}getInputReflect(e,t){return this._json.PhysicsSettings[e].Input[t].Reflect}getInputType(e,t){return this._json.PhysicsSettings[e].Input[t].Type}getInputSourceId(e,t){return this._json.PhysicsSettings[e].Input[t].Source.Id}getOutputCount(e){return this._json.PhysicsSettings[e].Output.length}getOutputVertexIndex(e,t){return this._json.PhysicsSettings[e].Output[t].VertexIndex}getOutputAngleScale(e,t){return this._json.PhysicsSettings[e].Output[t].Scale}getOutputWeight(e,t){return this._json.PhysicsSettings[e].Output[t].Weight}getOutputDestinationId(e,t){return this._json.PhysicsSettings[e].Output[t].Destination.Id}getOutputType(e,t){return this._json.PhysicsSettings[e].Output[t].Type}getOutputReflect(e,t){return this._json.PhysicsSettings[e].Output[t].Reflect}getParticleCount(e){return this._json.PhysicsSettings[e].Vertices.length}getParticleMobility(e,t){return this._json.PhysicsSettings[e].Vertices[t].Mobility}getParticleDelay(e,t){return this._json.PhysicsSettings[e].Vertices[t].Delay}getParticleAcceleration(e,t){return this._json.PhysicsSettings[e].Vertices[t].Acceleration}getParticleRadius(e,t){return this._json.PhysicsSettings[e].Vertices[t].Radius}getParticlePosition(e,t){let n=new yu(0,0);return n.x=this._json.PhysicsSettings[e].Vertices[t].Position.X,n.y=this._json.PhysicsSettings[e].Vertices[t].Position.Y,n}};const _d=`Angle`;var vd=class e{static create(t){let n=new e;return n.parse(t),n._physicsRig.gravity.y=0,n}evaluate(e,t){let n,r,i,a,o=new yu,s,c,l,u,d,f,p,m;d=e.getModel().parameters.values,f=e.getModel().parameters.maximumValues,p=e.getModel().parameters.minimumValues,m=e.getModel().parameters.defaultValues;for(let h=0;h=s.particleCount)break;l[t].destinationParameterIndex==-1&&(l[t].destinationParameterIndex=e.getParameterIndex(l[t].destination.id));let r=new yu;r.x=u[n].position.x-u[n-1].position.x,r.y=u[n].position.y-u[n-1].position.y,a=l[t].getValue(r,u,n,l[t].reflect,this._options.gravity);let i=l[t].destinationParameterIndex,o=!Float32Array.prototype.slice&&`subarray`in Float32Array.prototype?JSON.parse(JSON.stringify(d.subarray(i))):d.slice(i);Md(o,p[i],f[i],a,l[t]);for(let e=i,t=0;e=2?t[n-1].position.substract(t[n-2].position):i.multiplyByScaler(-1),a=xu.directionToRadian(i,e),r&&(a*=-1),a}function Ed(e,t){return Math.abs(Math.max(e,t)-Math.min(e,t))}function Dd(e,t){let n=Math.min(e,t);return n+Ed(e,t)/2}function Od(e,t){return e.x}function kd(e,t){return e.y}function Ad(e,t){return t}function jd(e,t,n,r,i,a,o,s){let c,l,u,d,f=new yu(0,0),p=new yu(0,0),m=new yu(0,0),h=new yu(0,0);e[0].position=new yu(n.x,n.y),c=xu.degreesToRadian(r),d=xu.radianToDirection(c),d.normalize();for(let n=1;nn&&(o>i.valueExceededMaximum&&(i.valueExceededMaximum=o),o=n),s=i.weight/100,s>=1||(o=e[0]*(1-s)+o*s),e[0]=o}function Nd(e,t,n,r,i,a,o,s){let c=0,l=xu.max(n,t);le&&(e=u);let d=xu.min(i,a),f=xu.max(i,a),p=o,m=Dd(u,l),h=e-m;switch(Math.sign(h)){case 1:{let e=f-p,t=l-m;t!=0&&(c=h*(e/t),c+=p);break}case-1:{let e=d-p,t=u-m;t!=0&&(c=h*(e/t),c+=p);break}case 0:c=p;break}return s?c:c*-1}var Pd=class{constructor(e=0,t=0,n=0,r=0){this.x=e,this.y=t,this.width=n,this.height=r}getCenterX(){return this.x+.5*this.width}getCenterY(){return this.y+.5*this.height}getRight(){return this.x+this.width}getBottom(){return this.y+this.height}setRect(e){this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height}expand(e,t){this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2}};let Fd,Id,Ld;var Rd=class{getChannelFlagAsColor(e){return this._channelColors[e]}getMaskRenderTexture(){let e=0;if(this._maskTexture&&this._maskTexture.texture!=0&&(this._maskTexture.frameNo=this._currentFrameNo,e=this._maskTexture.texture),e==0){let t=this._clippingMaskBufferSize;this._colorBuffer=this.gl.createTexture(),this.gl.bindTexture(this.gl.TEXTURE_2D,this._colorBuffer),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,t,t,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,null),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.bindTexture(this.gl.TEXTURE_2D,null),e=this.gl.createFramebuffer(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,e),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,this._colorBuffer,0),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,Ld),this._maskTexture=new zd(this._currentFrameNo,e)}return e}setGL(e){this.gl=e}calcClippedDrawTotalBounds(e,t){let n=Number.MAX_VALUE,r=Number.MAX_VALUE,i=Number.MIN_VALUE,a=Number.MIN_VALUE,o=t._clippedDrawableIndexList.length;for(let s=0;sf&&(f=t),np&&(p=n)}if(u!=Number.MAX_VALUE)if(ui&&(i=f),p>a&&(a=p),n==Number.MAX_VALUE)t._allClippedDrawRect.x=0,t._allClippedDrawRect.y=0,t._allClippedDrawRect.width=0,t._allClippedDrawRect.height=0,t._isUsing=!1;else{t._isUsing=!0;let e=i-n,o=a-r;t._allClippedDrawRect.x=n,t._allClippedDrawRect.y=r,t._allClippedDrawRect.width=e,t._allClippedDrawRect.height=o}}}constructor(){this._maskRenderTexture=null,this._colorBuffer=null,this._currentFrameNo=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=[],this._clippingContextListForDraw=[],this._channelColors=[],this._tmpBoundsOnModel=new Pd,this._tmpMatrix=new Su,this._tmpMatrixForMask=new Su,this._tmpMatrixForDraw=new Su;let e=new Tu;e.R=1,e.G=0,e.B=0,e.A=0,this._channelColors.push(e),e=new Tu,e.R=0,e.G=1,e.B=0,e.A=0,this._channelColors.push(e),e=new Tu,e.R=0,e.G=0,e.B=1,e.A=0,this._channelColors.push(e),e=new Tu,e.R=0,e.G=0,e.B=0,e.A=1,this._channelColors.push(e)}release(){var e,t,n;let r=this;for(let t=0;t0){this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),this._maskRenderTexture=this.getMaskRenderTexture(),t.getMvpMatrix(),t.preDraw(),this.setupLayoutBounds(n),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._maskRenderTexture),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT);for(let n=0;n(e[e.ShaderNames_SetupMask=0]=`ShaderNames_SetupMask`,e[e.ShaderNames_NormalPremultipliedAlpha=1]=`ShaderNames_NormalPremultipliedAlpha`,e[e.ShaderNames_NormalMaskedPremultipliedAlpha=2]=`ShaderNames_NormalMaskedPremultipliedAlpha`,e[e.ShaderNames_NomralMaskedInvertedPremultipliedAlpha=3]=`ShaderNames_NomralMaskedInvertedPremultipliedAlpha`,e[e.ShaderNames_AddPremultipliedAlpha=4]=`ShaderNames_AddPremultipliedAlpha`,e[e.ShaderNames_AddMaskedPremultipliedAlpha=5]=`ShaderNames_AddMaskedPremultipliedAlpha`,e[e.ShaderNames_AddMaskedPremultipliedAlphaInverted=6]=`ShaderNames_AddMaskedPremultipliedAlphaInverted`,e[e.ShaderNames_MultPremultipliedAlpha=7]=`ShaderNames_MultPremultipliedAlpha`,e[e.ShaderNames_MultMaskedPremultipliedAlpha=8]=`ShaderNames_MultMaskedPremultipliedAlpha`,e[e.ShaderNames_MultMaskedPremultipliedAlphaInverted=9]=`ShaderNames_MultMaskedPremultipliedAlphaInverted`,e))(Hd||{});const Ud=`attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_myPos;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_clipMatrix * a_position; v_myPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}`,Wd=`precision mediump float;varying vec2 v_texCoord;varying vec4 v_myPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;void main(){ float isInside = step(u_baseColor.x, v_myPos.x/v_myPos.w) * step(u_baseColor.y, v_myPos.y/v_myPos.w) * step(v_myPos.x/v_myPos.w, u_baseColor.z) * step(v_myPos.y/v_myPos.w, u_baseColor.w); gl_FragColor = u_channelFlag * texture2D(s_texture0, v_texCoord).a * isInside;}`,Gd=`attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;uniform mat4 u_matrix;void main(){ gl_Position = u_matrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}`,Kd=`attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform mat4 u_matrix;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_matrix * a_position; v_clipPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}`,qd=`precision mediump float;varying vec2 v_texCoord;uniform vec4 u_baseColor;uniform sampler2D s_texture0;void main(){ gl_FragColor = texture2D(s_texture0 , v_texCoord) * u_baseColor;}`,Jd=`precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;uniform sampler2D s_texture1;void main(){ vec4 col_formask = texture2D(s_texture0 , v_texCoord) * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * maskVal; gl_FragColor = col_formask;}`,Yd=`precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_channelFlag;uniform vec4 u_baseColor;void main(){vec4 col_formask = texture2D(s_texture0, v_texCoord) * u_baseColor;vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag;float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a;col_formask = col_formask * (1.0 - maskVal);gl_FragColor = col_formask;}`;var Xd=class extends Cu{constructor(){super(),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._clippingManager=new Rd,this.firstDraw=!0,this._textures={},this._sortedDrawableIndexList=[],this._bufferData={vertex:null,uv:null,index:null}}initialize(e){e.isUsingMasking()&&(this._clippingManager=new Rd,this._clippingManager.initialize(e,e.getDrawableCount(),e.getDrawableMasks(),e.getDrawableMaskCounts()));for(let t=e.getDrawableCount()-1;t>=0;t--)this._sortedDrawableIndexList[t]=0;super.initialize(e)}bindTexture(e,t){this._textures[e]=t}getBindedTextures(){return this._textures}setClippingMaskBufferSize(e){this._clippingManager.release(),this._clippingManager=new Rd,this._clippingManager.setClippingMaskBufferSize(e),this._clippingManager.initialize(this.getModel(),this.getModel().getDrawableCount(),this.getModel().getDrawableMasks(),this.getModel().getDrawableMaskCounts())}getClippingMaskBufferSize(){return this._clippingManager.getClippingMaskBufferSize()}release(){var e,t,n;let r=this;this._clippingManager.release(),r._clippingManager=void 0,(e=this.gl)==null||e.deleteBuffer(this._bufferData.vertex),this._bufferData.vertex=null,(t=this.gl)==null||t.deleteBuffer(this._bufferData.uv),this._bufferData.uv=null,(n=this.gl)==null||n.deleteBuffer(this._bufferData.index),this._bufferData.index=null,r._bufferData=void 0,r._textures=void 0}doDrawModel(){this.preDraw(),this._clippingManager!=null&&this._clippingManager.setupClippingContext(this.getModel(),this);let e=this.getModel().getDrawableCount(),t=this.getModel().getDrawableRenderOrders();for(let n=0;n{Xd.doStaticRelease()};var Zd=class{constructor(e){this.groups=e.Groups,this.hitAreas=e.HitAreas,this.layout=e.Layout,this.moc=e.FileReferences.Moc,this.expressions=e.FileReferences.Expressions,this.motions=e.FileReferences.Motions,this.textures=e.FileReferences.Textures,this.physics=e.FileReferences.Physics,this.pose=e.FileReferences.Pose}getEyeBlinkParameters(){var e,t;return(t=(e=this.groups)?.find(e=>e.Name===`EyeBlink`))?.Ids}getLipSyncParameters(){var e,t;return(t=(e=this.groups)?.find(e=>e.Name===`LipSync`))?.Ids}},Qd;(e=>{e.LOG_LEVEL_VERBOSE=0,e.LOG_LEVEL_WARNING=1,e.LOG_LEVEL_ERROR=2,e.LOG_LEVEL_NONE=999,e.logLevel=e.LOG_LEVEL_WARNING,e.sound=!0,e.motionSync=!0,e.motionFadingDuration=500,e.idleMotionFadingDuration=2e3,e.expressionFadingDuration=500,e.preserveExpressionOnMotion=!0,e.cubism4=Hu})(Qd||={});const $d={log(e,...t){Qd.logLevel<=Qd.LOG_LEVEL_VERBOSE&&console.log(`[${e}]`,...t)},warn(e,...t){Qd.logLevel<=Qd.LOG_LEVEL_WARNING&&console.warn(`[${e}]`,...t)},error(e,...t){Qd.logLevel<=Qd.LOG_LEVEL_ERROR&&console.error(`[${e}]`,...t)}};function ef(e,t,n){return en?n:e}function tf(e,t){t.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(n=>{n!==`constructor`&&Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n))})})}function nf(e){let t=e.lastIndexOf(`/`);return t!=-1&&(e=e.slice(0,t)),t=e.lastIndexOf(`/`),t!==-1&&(e=e.slice(t+1)),e}function rf(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}var af=class extends Ya.default{constructor(e,t){super(),this.expressions=[],this.reserveExpressionIndex=-1,this.destroyed=!1,this.settings=e,this.tag=`ExpressionManager(${e.name})`}init(){this.defaultExpression=this.createExpression({},void 0),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}loadExpression(e){return uu(this,null,function*(){if(!this.definitions[e]){$d.warn(this.tag,`Undefined expression at [${e}]`);return}if(this.expressions[e]===null){$d.warn(this.tag,`Cannot set expression at [${e}] because it's already failed in loading.`);return}if(this.expressions[e])return this.expressions[e];let t=yield this._loadExpression(e);return this.expressions[e]=t,t})}_loadExpression(e){throw Error(`Not implemented.`)}setRandomExpression(){return uu(this,null,function*(){if(this.definitions.length){let e=[];for(let t=0;t-1&&ec&&(a*=c/s,o*=c/s),this.vx+=a,this.vy+=o;let l=Math.sqrt(lu(this.vx,2)+lu(this.vy,2)),u=.5*(Math.sqrt(lu(c,2)+8*c*r)-c);l>u&&(this.vx*=u/l,this.vy*=u/l),this.x+=this.vx,this.y+=this.vy}},lf=class{constructor(e){this.json=e;let t=e.url;if(typeof t!=`string`)throw TypeError("The `url` field in settings JSON must be defined as a string.");this.url=t,this.name=nf(this.url)}resolveURL(e){return Za.resolve(this.url,e)}replaceFiles(e){this.moc=e(this.moc,`moc`),this.pose!==void 0&&(this.pose=e(this.pose,`pose`)),this.physics!==void 0&&(this.physics=e(this.physics,`physics`));for(let t=0;t(e.push(t),t)),e}validateFiles(e){let t=(t,n)=>{let r=this.resolveURL(t);if(!e.includes(r)){if(n)throw Error(`File "${t}" is defined in settings, but doesn't exist in given files`);return!1}return!0},n=[this.moc,...this.textures];n.forEach(e=>t(e,!0));let r=this.getDefinedFiles();return r.filter(e=>t(e,!1))}},uf=(e=>(e[e.NONE=0]=`NONE`,e[e.IDLE=1]=`IDLE`,e[e.NORMAL=2]=`NORMAL`,e[e.FORCE=3]=`FORCE`,e))(uf||{}),df=class{constructor(){this.debug=!1,this.currentPriority=0,this.reservePriority=0}reserve(e,t,n){if(n<=0)return $d.log(this.tag,`Cannot start a motion with MotionPriority.NONE.`),!1;if(e===this.currentGroup&&t===this.currentIndex)return $d.log(this.tag,`Motion is already playing.`,this.dump(e,t)),!1;if(e===this.reservedGroup&&t===this.reservedIndex||e===this.reservedIdleGroup&&t===this.reservedIdleIndex)return $d.log(this.tag,`Motion is already reserved.`,this.dump(e,t)),!1;if(n===1){if(this.currentPriority!==0)return $d.log(this.tag,`Cannot start idle motion because another motion is playing.`,this.dump(e,t)),!1;if(this.reservedIdleGroup!==void 0)return $d.log(this.tag,`Cannot start idle motion because another idle motion has reserved.`,this.dump(e,t)),!1;this.setReservedIdle(e,t)}else{if(n<3){if(n<=this.currentPriority)return $d.log(this.tag,`Cannot start motion because another motion is playing as an equivalent or higher priority.`,this.dump(e,t)),!1;if(n<=this.reservePriority)return $d.log(this.tag,`Cannot start motion because another motion has reserved as an equivalent or higher priority.`,this.dump(e,t)),!1}this.setReserved(e,t,n)}return!0}start(e,t,n,r){if(r===1){if(this.setReservedIdle(void 0,void 0),this.currentPriority!==0)return $d.log(this.tag,`Cannot start idle motion because another motion is playing.`,this.dump(t,n)),!1}else{if(t!==this.reservedGroup||n!==this.reservedIndex)return $d.log(this.tag,`Cannot start motion because another motion has taken the place.`,this.dump(t,n)),!1;this.setReserved(void 0,void 0,0)}return e?(this.setCurrent(t,n,r),!0):!1}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(e,t,n){this.currentPriority=n,this.currentGroup=e,this.currentIndex=t}setReserved(e,t,n){this.reservePriority=n,this.reservedGroup=e,this.reservedIndex=t}setReservedIdle(e,t){this.reservedIdleGroup=e,this.reservedIdleIndex=t}isActive(e,t){return e===this.currentGroup&&t===this.currentIndex||e===this.reservedGroup&&t===this.reservedIndex||e===this.reservedIdleGroup&&t===this.reservedIdleIndex}reset(){this.setCurrent(void 0,void 0,0),this.setReserved(void 0,void 0,0),this.setReservedIdle(void 0,void 0)}shouldRequestIdleMotion(){return this.currentGroup===void 0&&this.reservedIdleGroup===void 0}shouldOverrideExpression(){return!Qd.preserveExpressionOnMotion&&this.currentPriority>1}dump(e,t){if(this.debug){let n=[`currentPriority`,`reservePriority`,`currentGroup`,`currentIndex`,`reservedGroup`,`reservedIndex`,`reservedIdleGroup`,`reservedIdleIndex`];return` + group = "${e}", index = ${t} +`+n.map(e=>`[`+e+`] `+this[e]).join(` +`)}return``}},ff=class{static get volume(){return this._volume}static set volume(e){this._volume=(e>1?1:e<0?0:e)||0,this.audios.forEach(e=>e.volume=this._volume)}static add(e,t,n){let r=new Audio(e);return r.volume=this._volume,r.preload=`auto`,r.addEventListener(`ended`,()=>{this.dispose(r),t?.()}),r.addEventListener(`error`,t=>{this.dispose(r),$d.warn(`SoundManager`,`Error occurred on "${e}"`,t.error),n?.(t.error)}),this.audios.push(r),r}static play(e){return new Promise((t,n)=>{var r;(r=e.play())==null||r.catch(t=>{e.dispatchEvent(new ErrorEvent(`error`,{error:t})),n(t)}),e.readyState===e.HAVE_ENOUGH_DATA?t():e.addEventListener(`canplaythrough`,t)})}static dispose(e){e.pause(),e.removeAttribute(`src`),rf(this.audios,e)}static destroy(){for(let e=this.audios.length-1;e>=0;e--)this.dispose(this.audios[e])}};ff.audios=[],ff._volume=.5;var pf=class extends Ya.default{constructor(e,t){super(),this.motionGroups={},this.state=new df,this.playing=!1,this.destroyed=!1,this.settings=e,this.tag=`MotionManager(${e.name})`,this.state.tag=this.tag}init(e){e?.idleMotionGroup&&(this.groups.idle=e.idleMotionGroup),this.setupMotions(e),this.stopAllMotions()}setupMotions(e){for(let e of Object.keys(this.definitions))this.motionGroups[e]=[];let t;switch(e?.motionPreload){case`NONE`:return;case`ALL`:t=Object.keys(this.definitions);break;case`IDLE`:default:t=[this.groups.idle];break}for(let e of t)if(this.definitions[e])for(let t=0;tthis.currentAudio=void 0,()=>this.currentAudio=void 0),this.currentAudio=a}catch(t){$d.warn(this.tag,`Failed to create audio`,e,t)}}let o=yield this.loadMotion(e,t);if(a){let e=ff.play(a).catch(e=>$d.warn(this.tag,`Failed to play audio`,a.src,e));Qd.motionSync&&(yield e)}return this.state.start(o,e,t,n)?($d.log(this.tag,`Start motion:`,this.getMotionName(i)),this.emit(`motionStart`,e,t,a),this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),this.playing=!0,this._startMotion(o),!0):(a&&(ff.dispose(a),this.currentAudio=void 0),!1)})}startRandomMotion(e,t){return uu(this,null,function*(){let n=this.definitions[e];if(n?.length){let r=[];for(let t=0;te.index>=0);for(let t of e)this.hitAreas[t.name]=t}hitTest(e,t){return Object.keys(this.hitAreas).filter(n=>this.isHit(n,e,t))}isHit(e,t,n){if(!this.hitAreas[e])return!1;let r=this.hitAreas[e].index,i=this.getDrawableBounds(r,mf);return i.x<=t&&t<=i.x+i.width&&i.y<=n&&n<=i.y+i.height}getDrawableBounds(e,t){let n=this.getDrawableVertices(e),r=n[0],i=n[0],a=n[1],o=n[1];for(let e=0;e{(a.status===200||a.status===0)&&a.response?r(a.response):a.onerror()},a.onerror=()=>{$d.warn(`XHRLoader`,`Failed to load resource as ${a.responseType} (Status ${a.status}): ${t}`),i(new gf(`Network error.`,t,a.status))},a.onabort=()=>i(new gf(`Aborted.`,t,a.status,!0)),a.onloadend=()=>{var t;_f.allXhrSet.delete(a),e&&((t=_f.xhrMap.get(e))==null||t.delete(a))},a}static cancelXHRs(){var e;(e=_f.xhrMap.get(this))==null||e.forEach(e=>{e.abort(),_f.allXhrSet.delete(e)}),_f.xhrMap.delete(this)}static release(){_f.allXhrSet.forEach(e=>e.abort()),_f.allXhrSet.clear(),_f.xhrMap=new WeakMap}};let vf=_f;vf.xhrMap=new WeakMap,vf.allXhrSet=new Set,vf.loader=(e,t)=>new Promise((t,n)=>{let r=_f.createXHR(e.target,e.settings?e.settings.resolveURL(e.url):e.url,e.type,n=>{e.result=n,t()},n);r.send()});function yf(e,t){let n=-1;return r(0);function r(i,a){if(a)return Promise.reject(a);if(i<=n)return Promise.reject(Error(`next() called multiple times`));n=i;let o=e[i];if(!o)return Promise.resolve();try{return Promise.resolve(o(t,r.bind(null,i+1)))}catch(e){return Promise.reject(e)}}}var bf=class{static load(e){return yf(this.middlewares,e).then(()=>e.result)}};bf.middlewares=[vf.loader];function xf(e,t={}){var n;let r={resourceOptions:{crossorigin:t.crossOrigin}};if(Ds.fromURL)return Ds.fromURL(e,r).catch(e=>{if(e instanceof Error)throw e;let t=Error(`Texture loading error`);throw t.event=e,t});r.resourceOptions.autoLoad=!1;let i=Ds.from(e,r);if(i.baseTexture.valid)return Promise.resolve(i);let a=i.baseTexture.resource;return(n=a._live2d_load)??(a._live2d_load=new Promise((e,t)=>{let n=e=>{a.source.removeEventListener(`error`,n);let r=Error(`Texture loading error`);r.event=e,t(r)};a.source.addEventListener(`error`,n),a.load().then(()=>e(i)).catch(n)})),a._live2d_load}const Sf=`Live2DFactory`,Cf=(e,t)=>uu(void 0,null,function*(){if(typeof e.source==`string`){let t=yield bf.load({url:e.source,type:`json`,target:e.live2dModel});t.url=e.source,e.source=t,e.live2dModel.emit(`settingsJSONLoaded`,t)}return t()}),wf=(e,t)=>uu(void 0,null,function*(){if(e.source instanceof lf)return e.settings=e.source,t();if(typeof e.source==`object`){let n=Af.findRuntime(e.source);if(n){let r=n.createModelSettings(e.source);return e.settings=r,e.live2dModel.emit(`settingsLoaded`,r),t()}}throw TypeError(`Unknown settings format.`)}),Tf=(e,t)=>{if(e.settings){let n=Af.findRuntime(e.settings);if(n)return n.ready().then(t)}return t()},Ef=(e,t)=>uu(void 0,null,function*(){yield t();let n=e.internalModel;if(n){let t=e.settings,r=Af.findRuntime(t);if(r){let i=[];t.pose&&i.push(bf.load({settings:t,url:t.pose,type:`json`,target:n}).then(t=>{n.pose=r.createPose(n.coreModel,t),e.live2dModel.emit(`poseLoaded`,n.pose)}).catch(t=>{e.live2dModel.emit(`poseLoadError`,t),$d.warn(Sf,`Failed to load pose.`,t)})),t.physics&&i.push(bf.load({settings:t,url:t.physics,type:`json`,target:n}).then(t=>{n.physics=r.createPhysics(n.coreModel,t),e.live2dModel.emit(`physicsLoaded`,n.physics)}).catch(t=>{e.live2dModel.emit(`physicsLoadError`,t),$d.warn(Sf,`Failed to load physics.`,t)})),i.length&&(yield Promise.all(i))}}}),Df=(e,t)=>uu(void 0,null,function*(){if(e.settings){let n=e.live2dModel,r=e.settings.textures.map(t=>{let n=e.settings.resolveURL(t);return xf(n,{crossOrigin:e.options.crossOrigin})});if(yield t(),e.internalModel)n.internalModel=e.internalModel,n.emit(`modelLoaded`,e.internalModel);else throw TypeError(`Missing internal model.`);n.textures=yield Promise.all(r),n.emit(`textureLoaded`,n.textures)}else throw TypeError(`Missing settings.`)}),Of=(e,t)=>uu(void 0,null,function*(){let n=e.settings;if(n instanceof lf){let r=Af.findRuntime(n);if(!r)throw TypeError(`Unknown model settings.`);let i=yield bf.load({settings:n,url:n.moc,type:`arraybuffer`,target:e.live2dModel});if(!r.isValidMoc(i))throw Error(`Invalid moc data`);let a=r.createCoreModel(i);return e.internalModel=r.createInternalModel(a,n,e.options),t()}throw TypeError(`Missing settings.`)}),kf=class{static registerRuntime(e){kf.runtimes.push(e),kf.runtimes.sort((e,t)=>t.version-e.version)}static findRuntime(e){for(let t of kf.runtimes)if(t.test(e))return t}static setupLive2DModel(e,t,n){return uu(this,null,function*(){let r=new Promise(t=>e.once(`textureLoaded`,t)),i=new Promise(t=>e.once(`modelLoaded`,t)),a=Promise.all([r,i]).then(()=>e.emit(`ready`));yield yf(kf.live2DModelMiddlewares,{live2dModel:e,source:t,options:n||{}}),yield a,e.emit(`load`)})}static loadMotion(e,t,n){var r,i;let a=r=>e.emit(`motionLoadError`,t,n,r);try{let o=(r=e.definitions[t])?.[n];if(!o)return Promise.resolve(void 0);e.listeners(`destroy`).includes(kf.releaseTasks)||e.once(`destroy`,kf.releaseTasks);let s=kf.motionTasksMap.get(e);s||(s={},kf.motionTasksMap.set(e,s));let c=s[t];c||(c=[],s[t]=c);let l=e.getMotionFile(o);return(i=c[n])??(c[n]=bf.load({url:l,settings:e.settings,type:e.motionDataType,target:e}).then(r=>{var i;let a=(i=kf.motionTasksMap.get(e))?.[t];a&&delete a[n];let s=e.createMotion(r,t,o);return e.emit(`motionLoaded`,t,n,s),s}).catch(t=>{$d.warn(e.tag,`Failed to load motion: ${l} +`,t),a(t)})),c[n]}catch(r){$d.warn(e.tag,`Failed to load motion at "${t}"[${n}] +`,r),a(r)}return Promise.resolve(void 0)}static loadExpression(e,t){var n;let r=n=>e.emit(`expressionLoadError`,t,n);try{let i=e.definitions[t];if(!i)return Promise.resolve(void 0);e.listeners(`destroy`).includes(kf.releaseTasks)||e.once(`destroy`,kf.releaseTasks);let a=kf.expressionTasksMap.get(e);a||(a=[],kf.expressionTasksMap.set(e,a));let o=e.getExpressionFile(i);return(n=a[t])??(a[t]=bf.load({url:o,settings:e.settings,type:`json`,target:e}).then(n=>{let r=kf.expressionTasksMap.get(e);r&&delete r[t];let a=e.createExpression(n,i);return e.emit(`expressionLoaded`,t,a),a}).catch(t=>{$d.warn(e.tag,`Failed to load expression: ${o} +`,t),r(t)})),a[t]}catch(n){$d.warn(e.tag,`Failed to load expression at [${t}] +`,n),r(n)}return Promise.resolve(void 0)}static releaseTasks(){this instanceof pf?kf.motionTasksMap.delete(this):kf.expressionTasksMap.delete(this)}};let Af=kf;Af.runtimes=[],Af.urlToJSON=Cf,Af.jsonToSettings=wf,Af.waitUntilReady=Tf,Af.setupOptionals=Ef,Af.setupEssentials=Df,Af.createInternalModel=Of,Af.live2DModelMiddlewares=[Cf,wf,Tf,Ef,Df,Of],Af.motionTasksMap=new WeakMap,Af.expressionTasksMap=new WeakMap,pf.prototype._loadMotion=function(e,t){return Af.loadMotion(this,e,t)},af.prototype._loadExpression=function(e){return Af.loadExpression(this,e)};var jf=class{constructor(){this._autoInteract=!1}get autoInteract(){return this._autoInteract}set autoInteract(e){e!==this._autoInteract&&(e?this.on(`pointertap`,Mf,this):this.off(`pointertap`,Mf,this),this._autoInteract=e)}registerInteraction(e){e!==this.interactionManager&&(this.unregisterInteraction(),this._autoInteract&&e&&(this.interactionManager=e,e.on(`pointermove`,Nf,this)))}unregisterInteraction(){var e;this.interactionManager&&=((e=this.interactionManager)==null||e.off(`pointermove`,Nf,this),void 0)}};function Mf(e){this.tap(e.data.global.x,e.data.global.y)}function Nf(e){this.focus(e.data.global.x,e.data.global.y)}var Pf=class extends Qo{};const Ff=new Ro,If=new Ho;let Lf;var Rf=class extends ou{constructor(e){super(),this.tag=`Live2DModel(uninitialized)`,this.textures=[],this.transform=new Pf,this.anchor=new Vo(this.onAnchorChange,this,0,0),this.glContextID=-1,this.elapsedTime=performance.now(),this.deltaTime=0,this._autoUpdate=!1,this.once(`modelLoaded`,()=>this.init(e))}static from(e,t){let n=new this(t);return Af.setupLive2DModel(n,e,t).then(()=>n)}static fromSync(e,t){let n=new this(t);return Af.setupLive2DModel(n,e,t).then(t?.onLoad).catch(t?.onError),n}static registerTicker(e){Lf=e}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){var t;Lf||=(t=window.PIXI)?.Ticker,e?this._destroyed||(Lf?(Lf.shared.add(this.onTickerUpdate,this),this._autoUpdate=!0):$d.warn(this.tag,`No Ticker registered, please call Live2DModel.registerTicker(Ticker).`)):(Lf?.shared.remove(this.onTickerUpdate,this),this._autoUpdate=!1)}init(e){this.tag=`Live2DModel(${this.internalModel.settings.name})`;let t=Object.assign({autoUpdate:!0,autoInteract:!0},e);t.autoInteract&&(this.interactive=!0),this.autoInteract=t.autoInteract,this.autoUpdate=t.autoUpdate}onAnchorChange(){this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(e,t,n){return t===void 0?this.internalModel.motionManager.startRandomMotion(e,n):this.internalModel.motionManager.startMotion(e,t,n)}expression(e){return this.internalModel.motionManager.expressionManager?e===void 0?this.internalModel.motionManager.expressionManager.setRandomExpression():this.internalModel.motionManager.expressionManager.setExpression(e):Promise.resolve(!1)}focus(e,t,n=!1){Ff.x=e,Ff.y=t,this.toModelPosition(Ff,Ff,!0);let r=Ff.x/this.internalModel.originalWidth*2-1,i=Ff.y/this.internalModel.originalHeight*2-1,a=Math.atan2(i,r);this.internalModel.focusController.focus(Math.cos(a),-Math.sin(a),n)}tap(e,t){let n=this.hitTest(e,t);n.length&&($d.log(this.tag,`Hit`,n),this.emit(`hit`,n))}hitTest(e,t){return Ff.x=e,Ff.y=t,this.toModelPosition(Ff,Ff),this.internalModel.hitTest(Ff.x,Ff.y)}toModelPosition(e,t=e.clone(),n){return n||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.transform.worldTransform.applyInverse(e,t),this.internalModel.localTransform.applyInverse(t,t),t}containsPoint(e){return this.getBounds(!0).contains(e.x,e.y)}_calculateBounds(){this._bounds.addFrame(this.transform,0,0,this.internalModel.width,this.internalModel.height)}onTickerUpdate(){this.update(Lf.shared.deltaMS)}update(e){this.deltaTime+=e,this.elapsedTime+=e}_render(e){this.registerInteraction(e.plugins.interaction),e.batch.reset(),e.geometry.reset(),e.shader.reset(),e.state.reset();let t=!1;this.glContextID!==e.CONTEXT_UID&&(this.glContextID=e.CONTEXT_UID,this.internalModel.updateWebGLContext(e.gl,this.glContextID),t=!0);for(let n=0;nt.destroy(e.baseTexture)),this.internalModel.destroy(),super.destroy(e)}};tf(Rf,[jf]);const zf=class{static resolveURL(e,t){var n;let r=(n=zf.filesMap[e])?.[t];if(r===void 0)throw Error(`Cannot find this file from uploaded files: `+t);return r}static upload(e,t){return uu(this,null,function*(){let n={};for(let r of t.getDefinedFiles()){let i=decodeURI(Za.resolve(t.url,r)),a=e.find(e=>e.webkitRelativePath===i);a&&(n[r]=URL.createObjectURL(a))}zf.filesMap[t._objectURL]=n})}static createSettings(e){return uu(this,null,function*(){let t=e.find(e=>e.name.endsWith(`model.json`)||e.name.endsWith(`model3.json`));if(!t)throw TypeError(`Settings file not found`);let n=yield zf.readText(t),r=JSON.parse(n);r.url=t.webkitRelativePath;let i=Af.findRuntime(r);if(!i)throw Error(`Unknown settings JSON`);let a=i.createModelSettings(r);return a._objectURL=URL.createObjectURL(t),a})}static readText(e){return uu(this,null,function*(){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsText(e,`utf8`)})})}};let Bf=zf;Bf.filesMap={},Bf.factory=(e,t)=>uu(void 0,null,function*(){if(Array.isArray(e.source)&&e.source[0]instanceof File){let t=e.source,n=t.settings;if(!n)n=yield zf.createSettings(t);else if(!n._objectURL)throw Error(`"_objectURL" must be specified in ModelSettings`);n.validateFiles(t.map(e=>encodeURI(e.webkitRelativePath))),yield zf.upload(t,n),n.resolveURL=function(e){return zf.resolveURL(this._objectURL,e)},e.source=n,e.live2dModel.once(`modelLoaded`,e=>{e.once(`destroy`,function(){let e=this.settings._objectURL;if(URL.revokeObjectURL(e),zf.filesMap[e])for(let t of Object.values(zf.filesMap[e]))URL.revokeObjectURL(t);delete zf.filesMap[e]})})}return t()}),Af.live2DModelMiddlewares.unshift(Bf.factory);const Vf=class{static unzip(e,t){return uu(this,null,function*(){let n=yield Vf.getFilePaths(e),r=[];for(let e of t.getDefinedFiles()){let i=decodeURI(Za.resolve(t.url,e));n.includes(i)&&r.push(i)}let i=yield Vf.getFiles(e,r);for(let e=0;ee.endsWith(`model.json`)||e.endsWith(`model3.json`));if(!n)throw Error(`Settings file not found`);let r=yield Vf.readText(e,n);if(!r)throw Error(`Empty settings file: `+n);let i=JSON.parse(r);i.url=n;let a=Af.findRuntime(i);if(!a)throw Error(`Unknown settings JSON`);return a.createModelSettings(i)})}static zipReader(e,t){return uu(this,null,function*(){throw Error(`Not implemented`)})}static getFilePaths(e){return uu(this,null,function*(){throw Error(`Not implemented`)})}static getFiles(e,t){return uu(this,null,function*(){throw Error(`Not implemented`)})}static readText(e,t){return uu(this,null,function*(){throw Error(`Not implemented`)})}static releaseReader(e){}};let Hf=Vf;if(Hf.ZIP_PROTOCOL=`zip://`,Hf.uid=0,Hf.factory=(e,t)=>uu(void 0,null,function*(){let n=e.source,r,i,a;if(typeof n==`string`&&(n.endsWith(`.zip`)||n.startsWith(Vf.ZIP_PROTOCOL))?(r=n.startsWith(Vf.ZIP_PROTOCOL)?n.slice(Vf.ZIP_PROTOCOL.length):n,i=yield bf.load({url:r,type:`blob`,target:e.live2dModel})):Array.isArray(n)&&n.length===1&&n[0]instanceof File&&n[0].name.endsWith(`.zip`)&&(i=n[0],r=URL.createObjectURL(i),a=n.settings),i){if(!i.size)throw Error(`Empty zip file`);let t=yield Vf.zipReader(i,r);a||=yield Vf.createSettings(t),a._objectURL=Vf.ZIP_PROTOCOL+Vf.uid+`/`+a.url;let n=yield Vf.unzip(t,a);n.settings=a,e.source=n,r.startsWith(`blob:`)&&e.live2dModel.once(`modelLoaded`,e=>{e.once(`destroy`,function(){URL.revokeObjectURL(r)})}),Vf.releaseReader(t)}return t()}),Af.live2DModelMiddlewares.unshift(Hf.factory),!window.Live2DCubismCore)throw Error(`Could not find Cubism 4 runtime. This plugin requires live2dcubismcore.js to be loaded.`);var Uf=class extends af{constructor(e,t){var n;super(e,t),this.queueManager=new sd,this.definitions=(n=e.expressions)??[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(e){return this.definitions.findIndex(t=>t.Name===e)}getExpressionFile(e){return e.File}createExpression(e,t){return Bu.create(e)}_setExpression(e){return this.queueManager.startMotion(e,!1,performance.now())}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(e,t){return this.queueManager.doUpdateMotion(e,t)}},Wf=class e extends lf{constructor(t){if(super(t),!e.isValidJSON(t))throw TypeError(`Invalid JSON.`);Object.assign(this,new Zd(t))}static isValidJSON(e){var t;return!!e?.FileReferences&&typeof e.FileReferences.Moc==`string`&&(t=e.FileReferences.Textures)?.length>0&&e.FileReferences.Textures.every(e=>typeof e==`string`)}replaceFiles(e){if(super.replaceFiles(e),this.motions)for(let[t,n]of Object.entries(this.motions))for(let r=0;r{this.emit(`motion:`+t)})}isFinished(){return this.queueManager.isFinished()}_startMotion(e,t){return e.setFinishedMotionHandler(t),this.queueManager.stopAllMotions(),this.queueManager.startMotion(e,!1,performance.now())}_stopAllMotions(){this.queueManager.stopAllMotions()}createMotion(e,t,n){let r=ad.create(e),i=new Xu(e),a=(t===this.groups.idle?Qd.idleMotionFadingDuration:Qd.motionFadingDuration)/1e3;return i.getMotionFadeInTime()===void 0&&r.setFadeInTime(n.FadeInTime>0?n.FadeInTime:a),i.getMotionFadeOutTime()===void 0&&r.setFadeOutTime(n.FadeOutTime>0?n.FadeOutTime:a),r.setEffectIds(this.eyeBlinkIds,this.lipSyncIds),r}getMotionFile(e){return e.File}getMotionName(e){return e.File}getSoundFile(e){return e.Sound}updateParameters(e,t){return this.queueManager.doUpdateMotion(e,t)}destroy(){super.destroy(),this.queueManager.release(),this.queueManager=void 0}};const Kf=new Su;var qf=class extends hf{constructor(e,t,n){super(),this.lipSync=!0,this.breath=du.create(),this.renderer=new Xd,this.idParamAngleX=`ParamAngleX`,this.idParamAngleY=`ParamAngleY`,this.idParamAngleZ=`ParamAngleZ`,this.idParamEyeBallX=`ParamEyeBallX`,this.idParamEyeBallY=`ParamEyeBallY`,this.idParamBodyAngleX=`ParamBodyAngleX`,this.idParamBreath=`ParamBreath`,this.pixelsPerUnit=1,this.centeringTransform=new Ho,this.coreModel=e,this.settings=t,this.motionManager=new Gf(t,n),this.init()}init(){var e;super.init(),(e=this.settings.getEyeBlinkParameters())?.length>0&&(this.eyeBlink=mu.create(this.settings)),this.breath.setParameters([new fu(this.idParamAngleX,0,15,6.5345,.5),new fu(this.idParamAngleY,0,8,3.5345,.5),new fu(this.idParamAngleZ,0,10,5.5345,.5),new fu(this.idParamBodyAngleX,0,4,15.5345,.5),new fu(this.idParamBreath,0,.5,3.2345,.5)]),this.renderer.initialize(this.coreModel),this.renderer.setIsPremultipliedAlpha(!0)}getSize(){return[this.coreModel.getModel().canvasinfo.CanvasWidth,this.coreModel.getModel().canvasinfo.CanvasHeight]}getLayout(){let e={};if(this.settings.layout)for(let t of Object.keys(this.settings.layout)){let n=t.charAt(0).toLowerCase()+t.slice(1);e[n]=this.settings.layout[t]}return e}setupLayout(){super.setupLayout(),this.pixelsPerUnit=this.coreModel.getModel().canvasinfo.PixelsPerUnit,this.centeringTransform.scale(this.pixelsPerUnit,this.pixelsPerUnit).translate(this.originalWidth/2,this.originalHeight/2)}updateWebGLContext(e,t){this.renderer.firstDraw=!0,this.renderer._bufferData={vertex:null,uv:null,index:null},this.renderer.startUp(e),this.renderer._clippingManager._currentFrameNo=t,this.renderer._clippingManager._maskTexture=void 0,Vd.getInstance()._shaderSets=[]}bindTexture(e,t){this.renderer.bindTexture(e,t)}getHitAreaDefs(){var e,t;return(t=(e=this.settings.hitAreas)?.map(e=>({id:e.Id,name:e.Name,index:this.coreModel.getDrawableIndex(e.Id)})))??[]}getDrawableIDs(){return this.coreModel.getDrawableIds()}getDrawableIndex(e){return this.coreModel.getDrawableIndex(e)}getDrawableVertices(e){if(typeof e==`string`&&(e=this.coreModel.getDrawableIndex(e),e===-1))throw TypeError(`Unable to find drawable ID: `+e);let t=this.coreModel.getDrawableVertices(e).slice();for(let e=0;e{function n(){try{Zf(),e()}catch(e){if(Yf--,Yf<0){let n=Error(`Failed to start up Cubism 4 framework.`);n.cause=e,t(n);return}$d.log(`Cubism4`,`Startup failed, retrying 10ms later...`),setTimeout(n,10)}}n()}),Jf)}function Zf(e){e=Object.assign({logFunction:console.log,loggingLevel:ju.LogLevel_Verbose},e),Au.startUp(e),Au.initialize()}Af.registerRuntime({version:4,ready:Xf,test(e){return e instanceof Wf||Wf.isValidJSON(e)},isValidMoc(e){if(e.byteLength<4)return!1;let t=new Int8Array(e,0,4);return String.fromCharCode(...t)===`MOC3`},createModelSettings(e){return new Wf(e)},createCoreModel(e){let t=Ru.create(e);try{let e=t.createModel();return e.__moc=t,e}catch(e){try{t.release()}catch{}throw e}},createInternalModel(e,t,n){let r=new qf(e,t,n),i=e;return i.__moc&&(r.__moc=i.__moc,delete i.__moc,r.once(`destroy`,Qf)),r},createPhysics(e,t){return vd.create(t)},createPose(e,t){return _u.create(t)}});function Qf(){var e;(e=this.__moc)==null||e.release()}var $f=Wt({__name:`Canvas`,props:{width:{},height:{},resolution:{default:2}},setup(e,{expose:t}){let n=e,r=R(),i=R(!1),a=R(),o=R();async function s(e){i.value=!1,Rf.registerTicker(Mo),Oo.add(No),a.value=new cu({width:n.width*n.resolution,height:n.height*n.resolution,backgroundAlpha:0,preserveDrawingBuffer:!0}),o.value=a.value.view,o.value.style.width=`100%`,o.value.style.height=`100%`,o.value.style.objectFit=`cover`,o.value.style.display=`block`,e.appendChild(a.value.view),i.value=!0}function c(){a.value&&a.value.renderer.resize(n.width,n.height)}$t([()=>n.width,()=>n.height],()=>c()),$t(()=>n.resolution,e=>{a.value&&e&&(a.value.renderer.resolution=e,c())}),Jt(async()=>r.value&&await s(r.value)),Yt(()=>a.value?.destroy());async function l(){let e=new Promise(e=>{if(!o.value||!a.value)return e(null);a.value.render(),o.value.toBlob(e)});return e}function u(){return o.value}return t({captureFrame:l,canvasElement:u}),(e,t)=>(Xt(),Ht(`div`,{ref_key:`containerRef`,ref:r,"h-full":``,"w-full":``},[i.value?Qt(e.$slots,`default`,{key:0,app:a.value}):Vt(``,!0)],512))}}),ep=$f,tp=function(e,t){return tp=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])},tp(e,t)};function np(e,t){tp(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var rp=`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; +}`,ip=`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){np(t,e);function t(t){var n=e.call(this,rp,ip)||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})(Uc); +/*! ***************************************************************************** +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 ap=function(e,t){return ap=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])},ap(e,t)};function op(e,t){ap(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var sp=`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; +}`,cp=` +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; +}`,lp=` +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; +} +`,up=function(e){op(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,sp,r?lp:cp)||this;return i._kernels=[],i._blur=4,i._quality=3,i.uniforms.uOffset=new Float32Array(2),i._pixelSize=new Ro,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 Ro?(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}(Uc),dp=function(e,t){return dp=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])},dp(e,t)};function fp(e,t){dp(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var pp=`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; +}`,mp=` +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); + } +} +`,hp=function(e){fp(t,e);function t(t){t===void 0&&(t=.5);var n=e.call(this,pp,mp)||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}(Uc),gp=`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){fp(t,e);function t(n){var r=e.call(this,pp,gp)||this;r.bloomScale=1,r.brightness=1,r._resolution=B.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 hp(i.threshold),r._extractFilter.resolution=l,r._blurFilter=a?new up(a):new up(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:B.FILTER_RESOLUTION},t})(Uc); +/*! ***************************************************************************** +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 _p=function(e,t){return _p=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])},_p(e,t)};function vp(e,t){_p(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var yp=`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; +}`,bp=`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){vp(t,e);function t(t){t===void 0&&(t=8);var n=e.call(this,yp,bp)||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})(Uc); +/*! ***************************************************************************** +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 xp=function(e,t){return xp=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])},xp(e,t)};function Sp(e,t){xp(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Cp=`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; +}`,wp=`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){Sp(t,e);function t(t){var n=e.call(this,Cp,wp)||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/Io},set:function(e){this._angle=e*Io,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 ao(this.uniforms.lightColor)},set:function(e){ro(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 ao(this.uniforms.shadowColor)},set:function(e){ro(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})(Uc); +/*! ***************************************************************************** +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 Tp=function(e,t){return Tp=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])},Tp(e,t)};function Ep(e,t){Tp(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Dp=`varying vec2 vTextureCoord; + +uniform sampler2D uSampler; +uniform float uAlpha; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha; +} +`,Op=function(e){Ep(t,e);function t(t){t===void 0&&(t=1);var n=e.call(this,Rl,Dp,{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}(Uc),kp=function(e,t){return kp=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])},kp(e,t)};function Ap(e,t){kp(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var jp=` + 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 Mp(e,t){var n=Math.ceil(e/2),r=jp,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 Ip=function(e){Ap(t,e);function t(t,n,r,i,a){n===void 0&&(n=8),r===void 0&&(r=4),i===void 0&&(i=B.FILTER_RESOLUTION),a===void 0&&(a=5);var o=this,s=Mp(a,t),c=Fp(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,ua.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){Bp(t,e);function t(n){var r=e.call(this,Vp,Hp)||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})(Uc); +/*! ***************************************************************************** +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 Up=function(e,t){return Up=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])},Up(e,t)};function Wp(e,t){Up(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Gp=`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; +}`,Kp=`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(e){Wp(t,e);function t(t,n,r){n===void 0&&(n=!1),r===void 0&&(r=1);var i=e.call(this,Gp,Kp)||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=t,i}return t.prototype.apply=function(e,t,n,r){this.uniforms._mix=this.mix,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`colorSize`,{get:function(){return this._size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`colorMap`,{get:function(){return this._colorMap},set:function(e){var t;e&&(e instanceof Ds||(e=Ds.from(e)),(t=e)?.baseTexture&&(e.baseTexture.scaleMode=this._scaleMode,e.baseTexture.mipmap=ca.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(t.prototype,`nearest`,{get:function(){return this._nearest},set:function(e){this._nearest=e,this._scaleMode=e?oa.NEAREST:oa.LINEAR;var t=this._colorMap;t&&t.baseTexture&&(t.baseTexture._glTextures={},t.baseTexture.scaleMode=this._scaleMode,t.baseTexture.mipmap=ca.OFF,t._updateID++,t.baseTexture.emit(`update`,t.baseTexture))},enumerable:!1,configurable:!0}),t.prototype.updateColorMap=function(){var e=this._colorMap;e&&e.baseTexture&&(e._updateID++,e.baseTexture.emit(`update`,e.baseTexture),this.colorMap=e)},t.prototype.destroy=function(t){t===void 0&&(t=!1),this._colorMap&&this._colorMap.destroy(t),e.prototype.destroy.call(this)},t})(Uc); +/*! ***************************************************************************** +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 qp=function(e,t){return qp=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])},qp(e,t)};function Jp(e,t){qp(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Yp=`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; +}`,Xp=`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){Jp(t,e);function t(t,n){t===void 0&&(t=0),n===void 0&&(n=1);var r=e.call(this,Yp,Xp)||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`?(ro(e,t),this._color=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._color=ao(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})(Uc); +/*! ***************************************************************************** +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 Zp=function(e,t){return Zp=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])},Zp(e,t)};function Qp(e,t){Zp(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var $p=`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; +}`,em=`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){Qp(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,$p,em)||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`?(ro(e,t),this._originalColor=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._originalColor=ao(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`?(ro(e,t),this._newColor=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._newColor=ao(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})(Uc); +/*! ***************************************************************************** +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 tm=function(e,t){return tm=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])},tm(e,t)};function nm(e,t){tm(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var rm=`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; +}`,im=`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){nm(t,e);function t(t,n,r){n===void 0&&(n=200),r===void 0&&(r=200);var i=e.call(this,rm,im)||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})(Uc); +/*! ***************************************************************************** +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 am=function(e,t){return am=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])},am(e,t)};function om(e,t){am(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var sm=`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; +}`,cm=`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){om(t,e);function t(){return e.call(this,sm,cm)||this}return t})(Uc); +/*! ***************************************************************************** +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 lm=function(e,t){return lm=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])},lm(e,t)};function um(e,t){lm(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var dm=`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; +}`,fm=`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){um(t,e);function t(n){var r=e.call(this,dm,fm)||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})(Uc); +/*! ***************************************************************************** +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 pm=function(e,t){return pm=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])},pm(e,t)};function mm(e,t){pm(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var hm=`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; +}`,gm=`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){mm(t,e);function t(t,n){t===void 0&&(t=1),n===void 0&&(n=5);var r=e.call(this,hm,gm)||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})(Uc); +/*! ***************************************************************************** +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 _m=function(e,t){return _m=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])},_m(e,t)};function vm(e,t){_m(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var ym=function(){return ym=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(e){Om(t,e);function t(n){var r=e.call(this,km,Am)||this;return r.offset=100,r.fillMode=t.TRANSPARENT,r.average=!1,r.seed=0,r.minSize=8,r.sampleSize=512,r._slices=0,r._offsets=new Float32Array(1),r._sizes=new Float32Array(1),r._direction=-1,r.uniforms.dimensions=new Float32Array(2),r._canvas=document.createElement(`canvas`),r._canvas.width=4,r._canvas.height=r.sampleSize,r.texture=Ds.from(r._canvas,{scaleMode:oa.NEAREST}),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.aspect=o/a,this.uniforms.seed=this.seed,this.uniforms.offset=this.offset,this.uniforms.fillMode=this.fillMode,e.applyFilter(this,t,n,r)},t.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}},t.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(t.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})(Uc); +/*! ***************************************************************************** +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 Wm=function(e,t){return Wm=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])},Wm(e,t)};function Gm(e,t){Wm(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Km=`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; +}`,qm=`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){Gm(t,e);function t(t,n,r){n===void 0&&(n=.05),r===void 0&&(r=t.length);var i=e.call(this,Km,qm.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){Ym(t,e);function t(n,r){r===void 0&&(r=0);var i=e.call(this,Xm,Zm)||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})(Uc); +/*! ***************************************************************************** +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 Qm=function(e,t){return Qm=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])},Qm(e,t)};function $m(e,t){Qm(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var eh=`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; +}`,th=`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){$m(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,eh,th.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 ao(this.uniforms.outlineColor)},set:function(e){ro(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})(Uc); +/*! ***************************************************************************** +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 nh=function(e,t){return nh=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])},nh(e,t)};function rh(e,t){nh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var ih=`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; +}`,ah=`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){rh(t,e);function t(t){t===void 0&&(t=10);var n=e.call(this,ih,ah)||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})(Uc); +/*! ***************************************************************************** +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 oh=function(e,t){return oh=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])},oh(e,t)};function sh(e,t){oh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var ch=`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; +}`,lh=`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){sh(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,ch,lh)||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})(Uc); +/*! ***************************************************************************** +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 uh=function(e,t){return uh=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])},uh(e,t)};function dh(e,t){uh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var fh=`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; +}`,ph=`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){dh(t,e);function t(n){var r=e.call(this,fh,ph)||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})(Uc); +/*! ***************************************************************************** +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 mh=function(e,t){return mh=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])},mh(e,t)};function hh(e,t){mh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var gh=`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; +}`,_h=`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){hh(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,gh,_h)||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})(Uc); +/*! ***************************************************************************** +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 vh=function(e,t){return vh=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])},vh(e,t)};function yh(e,t){vh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var bh=`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; +}`,xh=`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){yh(t,e);function t(n,r,i){n===void 0&&(n=[0,0]),i===void 0&&(i=0);var a=e.call(this,bh,xh)||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})(Uc); +/*! ***************************************************************************** +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 Sh=function(e,t){return Sh=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])},Sh(e,t)};function Ch(e,t){Sh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var wh=`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; +}`,Th=`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){Ch(t,e);function t(t,n,r){n===void 0&&(n=0),r===void 0&&(r=1);var i=e.call(this,wh,Th)||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`?(ro(e,t),this._color=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],this._color=ao(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})(Uc); +/*! ***************************************************************************** +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 Eh=function(e,t){return Eh=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])},Eh(e,t)};function Dh(e,t){Eh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Oh=`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; +}`,kh=`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; +} +`,Ah=function(e){Dh(t,e);function t(t,n,r,i){t===void 0&&(t=100),n===void 0&&(n=600);var a=e.call(this,Oh,kh)||this;return a.uniforms.blur=t,a.uniforms.gradientBlur=n,a.uniforms.start=r||new Ro(0,window.innerHeight/2),a.uniforms.end=i||new Ro(600,window.innerHeight/2),a.uniforms.delta=new Ro(30,30),a.uniforms.texSize=new Ro(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}(Uc),jh=function(e){Dh(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}(Ah),Mh=function(e){Dh(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}(Ah);(function(e){Dh(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 jh(t,n,r,i),a.tiltShiftYFilter=new Mh(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})(Uc); +/*! ***************************************************************************** +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 Nh=function(e,t){return Nh=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])},Nh(e,t)};function Ph(e,t){Nh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Fh=`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; +}`,Ih=`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){Ph(t,e);function t(n){var r=e.call(this,Fh,Ih)||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 Ro},t})(Uc); +/*! ***************************************************************************** +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 Lh=function(e,t){return Lh=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])},Lh(e,t)};function Rh(e,t){Lh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function zh(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){Rh(t,e);function t(n){var r=this,i=Object.assign(t.defaults,n),a=i.maxKernelSize,o=zh(i,[`maxKernelSize`]);return r=e.call(this,Bh,Vh.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})(Uc);function Hh(){let e=-1,t,n=-1;function r(r,i){(i>=e||i{let{post:e,data:t}=A({name:`airi-stores-live2d`}),n=R([]),r=e=>{n.value.push(e)};function i(){e({type:`should-update-view`}),n.value.forEach(e=>e())}$t(t,e=>{e.type===`should-update-view`&&n.value.forEach(e=>e())});let a=N(`settings/live2d/position`,{x:0,y:0}),o=Tt(()=>({x:`${a.value.x}%`,y:`${a.value.y}%`})),s=R({group:`Idle`,index:0}),c=R([]),l=N(`settings/live2d/motion-map`,{}),u=N(`settings/live2d/scale`,1);return{position:a,positionInPercentageString:o,currentMotion:s,availableMotions:c,motionMap:l,scale:u,onShouldUpdateView:r,shouldUpdateView:i}});var Wh=Wt({__name:`Model`,props:{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}},emits:[`modelLoaded`],setup(e,{expose:t,emit:n}){let r=e,i=n;function a(){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 o=jt(()=>r.modelSrc),l=R(!1),d=Tt(()=>a()),f=jt(()=>r.app),h=jt(()=>r.paused),g=jt(()=>r.focusAt),_=R(),v=R(0),y=R(0),b=Tt(()=>Math.max(0,Math.min(100,r.mouthOpenSize))),x=R(0),S=j(),C=k(O),w=Tt(()=>C.between(`sm`,`md`).value||C.smaller(`sm`).value),T=Hh(),E=kt(new Sm({alpha:.2,blur:0,distance:20,rotation:45}));function A(){return _.value.internalModel.coreModel}function M(){if(!_.value)return;let e=2.2;w.value&&(e=2.2);let t=r.height*.95/y.value*e,n=r.width*.95/v.value*e,i=Math.min(t,n);_.value.scale.set(i*r.scale,i*r.scale),_.value.x=r.width/2+d.value.xOffset,_.value.y=r.height+d.value.yOffset}let{currentMotion:N,availableMotions:P,motionMap:F}=D(Uh()),{themeColorsHue:I,themeColorsHueDynamic:L}=D(ee()),te=R({group:`Idle`,index:0});async function ne(){if(await p(l).not.toBeTruthy(),l.value=!0,!f.value){l.value=!1;return}if(_.value&&=(f.value.stage.removeChild(_.value),_.value.destroy(),void 0),!o.value){console.warn(`No Live2D model source provided.`),l.value=!1;return}try{let e=new Rf;if(o.value.startsWith(`blob:`)){let t=await fetch(o.value),n=await t.blob();await Af.setupLive2DModel(e,[new File([n],`model.zip`)],{autoInteract:!1})}else await Af.setupLive2DModel(e,o.value,{autoInteract:!1});P.value.forEach(e=>{e.motionName in s?F.value[e.fileName]=e.motionName:F.value[e.fileName]=c}),_.value=e,f.value.stage.addChild(_.value),v.value=_.value.width,y.value=_.value.height,_.value.anchor.set(.5,.5),M(),_.value.on(`hit`,e=>{_.value&&e.includes(`body`)&&_.value.motion(`tap_body`)});let t=_.value.internalModel,n=t.coreModel,r=t.motionManager;n.setParameterValueById(`ParamMouthOpenY`,b.value),P.value=Object.entries(r.definitions).flatMap(([e,t])=>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 x.value=n,a?.call(this,e,n),!r.state.currentGroup||r.state.currentGroup===r.groups.idle?(T.update(t,n),t.eyeBlink!=null&&t.eyeBlink.updateParameters(e,(n-x.value)/1e3),!0):!1},r.on(`motionStart`,(e,t)=>{te.value={group:e,index:t}}),i(`modelLoaded`)}finally{l.value=!1}}async function re(e,t){await _.value?.motion(e,t,uf.FORCE)}let ie=m(M,100),ae=R(),oe=R(0);function se(){if(_.value){let e=getComputedStyle(ae.value).backgroundColor;E.value.color=Number(u(e).replace(`#`,`0x`)),_.value.filters=[E.value]}}$t([()=>r.width,()=>r.height],()=>ie()),$t(o,async()=>await ne(),{immediate:!0}),$t(S,se,{immediate:!0}),$t([_,I],se),$t(d,M),$t(()=>r.scale,M);function ce(){se(),oe.value=requestAnimationFrame(ce)}$t(L,()=>{L.value?oe.value=requestAnimationFrame(ce):(cancelAnimationFrame(oe.value),oe.value=0)},{immediate:!0}),$t(b,e=>A().setParameterValueById(`ParamMouthOpenY`,e)),$t(N,e=>re(e.group,e.index)),$t(h,e=>e?f.value?.stop():f.value?.start()),$t(g,e=>{_.value&&(r.disableFocusAt||_.value.focus(e.x,e.y))}),Jt(async()=>{se()});function le(){cancelAnimationFrame(oe.value),_.value&&f.value?.stage.removeChild(_.value)}Yt(()=>{le()});function ue(){return P.value}return t({setMotion:re,listMotionGroups:ue}),(e,t)=>(Xt(),Ht(Ct,null,[zt(`div`,{ref_key:`dropShadowColorComputer`,ref:ae,hidden:``,bg:`primary-400 dark:primary-500`},null,512),Qt(e.$slots,`default`)],64))}}),Gh=Wh,Kh=Pt(((exports,t)=>{ +/*! + +JSZip v3.10.1 - A JavaScript class for generating and reading zip files + + +(c) 2009-2016 Stuart Knightley +Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. + +JSZip uses the library pako released under the MIT license : +https://github.com/nodeca/pako/blob/main/LICENSE +*/ +(function(n){typeof exports==`object`&&t!==void 0?t.exports=n():typeof define==`function`&&define.amd?define([],n):(typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:this).JSZip=n()})(function(){return function e(t,n,r){function i(o,s){if(!n[o]){if(!t[o]){var c=typeof It==`function`&&It;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var l=Error(`Cannot find module '`+o+`'`);throw l.code=`MODULE_NOT_FOUND`,l}var u=n[o]={exports:{}};t[o][0].call(u.exports,function(e){var n=t[o][1][e];return i(n||e)},u,u.exports,e,t,n,r)}return n[o].exports}for(var a=typeof It==`function`&&It,o=0;o>2,s=(3&t)<<4|n>>4,c=1>6:64,l=2>4,n=(15&o)<<4|(s=a.indexOf(e.charAt(l++)))>>2,r=(3&s)<<6|(c=a.indexOf(e.charAt(l++))),f[u++]=t,s!==64&&(f[u++]=n),c!==64&&(f[u++]=r);return f}},{"./support":30,"./utils":32}],2:[function(e,t,n){var r=e(`./external`),i=e(`./stream/DataWorker`),a=e(`./stream/Crc32Probe`),o=e(`./stream/DataLengthProbe`);function s(e,t,n,r,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=r,this.compressedContent=i}s.prototype={getContentWorker:function(){var e=new i(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o(`data_length`)),t=this;return e.on(`end`,function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw Error(`Bug : uncompressed data size mismatch`)}),e},getCompressedWorker:function(){return new i(r.Promise.resolve(this.compressedContent)).withStreamInfo(`compressedSize`,this.compressedSize).withStreamInfo(`uncompressedSize`,this.uncompressedSize).withStreamInfo(`crc32`,this.crc32).withStreamInfo(`compression`,this.compression)}},s.createWorkerFrom=function(e,t,n){return e.pipe(new a).pipe(new o(`uncompressedSize`)).pipe(t.compressWorker(n)).pipe(new o(`compressedSize`)).withStreamInfo(`compression`,t)},t.exports=s},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){var r=e(`./stream/GenericWorker`);n.STORE={magic:`\0\0`,compressWorker:function(){return new r(`STORE compression`)},uncompressWorker:function(){return new r(`STORE decompression`)}},n.DEFLATE=e(`./flate`)},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){var r=e(`./utils`),i=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t){return e!==void 0&&e.length?r.getTypeOf(e)===`string`?function(e,t,n,r){var a=i,o=r+n;e^=-1;for(var s=r;s>>8^a[255&(e^t.charCodeAt(s))];return-1^e}(0|t,e,e.length,0):function(e,t,n,r){var a=i,o=r+n;e^=-1;for(var s=r;s>>8^a[255&(e^t[s])];return-1^e}(0|t,e,e.length,0):0}},{"./utils":32}],5:[function(e,t,n){n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){var r=null;r=typeof Promise<`u`?Promise:e(`lie`),t.exports={Promise:r}},{lie:37}],7:[function(e,t,n){var r=typeof Uint8Array<`u`&&typeof Uint16Array<`u`&&typeof Uint32Array<`u`,i=e(`pako`),a=e(`./utils`),o=e(`./stream/GenericWorker`),s=r?`uint8array`:`array`;function c(e,t){o.call(this,`FlateWorker/`+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}n.magic=`\b\0`,a.inherits(c,o),c.prototype.processChunk=function(e){this.meta=e.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(s,e.data),!1)},c.prototype.flush=function(){o.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},n.compressWorker=function(e){return new c(`Deflate`,e)},n.uncompressWorker=function(){return new c(`Inflate`,{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){function r(e,t){var n,r=``;for(n=0;n>>=8;return r}function i(e,t,n,i,o,u){var d,f,p=e.file,m=e.compression,h=u!==s.utf8encode,g=a.transformTo(`string`,u(p.name)),_=a.transformTo(`string`,s.utf8encode(p.name)),v=p.comment,y=a.transformTo(`string`,u(v)),b=a.transformTo(`string`,s.utf8encode(v)),x=_.length!==p.name.length,S=b.length!==v.length,C=``,w=``,T=``,E=p.dir,D=p.date,O={crc32:0,compressedSize:0,uncompressedSize:0};t&&!n||(O.crc32=e.crc32,O.compressedSize=e.compressedSize,O.uncompressedSize=e.uncompressedSize);var k=0;t&&(k|=8),h||!x&&!S||(k|=2048);var A=0,j=0;E&&(A|=16),o===`UNIX`?(j=798,A|=function(e,t){var n=e;return e||(n=t?16893:33204),(65535&n)<<16}(p.unixPermissions,E)):(j=20,A|=function(e){return 63&(e||0)}(p.dosPermissions)),d=D.getUTCHours(),d<<=6,d|=D.getUTCMinutes(),d<<=5,d|=D.getUTCSeconds()/2,f=D.getUTCFullYear()-1980,f<<=4,f|=D.getUTCMonth()+1,f<<=5,f|=D.getUTCDate(),x&&(w=r(1,1)+r(c(g),4)+_,C+=`up`+r(w.length,2)+w),S&&(T=r(1,1)+r(c(y),4)+b,C+=`uc`+r(T.length,2)+T);var M=``;return M+=` +\0`,M+=r(k,2),M+=m.magic,M+=r(d,2),M+=r(f,2),M+=r(O.crc32,4),M+=r(O.compressedSize,4),M+=r(O.uncompressedSize,4),M+=r(g.length,2),M+=r(C.length,2),{fileRecord:l.LOCAL_FILE_HEADER+M+g+C,dirRecord:l.CENTRAL_FILE_HEADER+r(j,2)+M+r(y.length,2)+`\0\0\0\0`+r(A,4)+r(i,4)+g+C+y}}var a=e(`../utils`),o=e(`../stream/GenericWorker`),s=e(`../utf8`),c=e(`../crc32`),l=e(`../signature`);function u(e,t,n,r){o.call(this,`ZipFileWorker`),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=r,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(u,o),u.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,r=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,o.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-r-1))/n:100}}))},u.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},u.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,n=i(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),t)this.push({data:function(e){return l.DATA_DESCRIPTOR+r(e.crc32,4)+r(e.compressedSize,4)+r(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},u.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return r.transformTo(`string`,this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,n){var r=e(`./Uint8ArrayReader`);function i(e){r.call(this,e)}e(`../utils`).inherits(i,r),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){var r=e(`./DataReader`);function i(e){r.call(this,e)}e(`../utils`).inherits(i,r),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){var r=e(`./ArrayReader`);function i(e){r.call(this,e)}e(`../utils`).inherits(i,r),i.prototype.readData=function(e){if(this.checkOffset(e),e===0)return new Uint8Array;var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){var r=e(`../utils`),i=e(`../support`),a=e(`./ArrayReader`),o=e(`./StringReader`),s=e(`./NodeBufferReader`),c=e(`./Uint8ArrayReader`);t.exports=function(e){var t=r.getTypeOf(e);return r.checkSupport(t),t!==`string`||i.uint8array?t===`nodebuffer`?new s(e):i.uint8array?new c(r.transformTo(`uint8array`,e)):new a(r.transformTo(`array`,e)):new o(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){n.LOCAL_FILE_HEADER=`PK`,n.CENTRAL_FILE_HEADER=`PK`,n.CENTRAL_DIRECTORY_END=`PK`,n.ZIP64_CENTRAL_DIRECTORY_LOCATOR=`PK\x07`,n.ZIP64_CENTRAL_DIRECTORY_END=`PK`,n.DATA_DESCRIPTOR=`PK\x07\b`},{}],24:[function(e,t,n){var r=e(`./GenericWorker`),i=e(`../utils`);function a(e){r.call(this,`ConvertWorker to `+e),this.destType=e}i.inherits(a,r),a.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){var r=e(`./GenericWorker`),i=e(`../crc32`);function a(){r.call(this,`Crc32Probe`),this.withStreamInfo(`crc32`,0)}e(`../utils`).inherits(a,r),a.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){var r=e(`../utils`),i=e(`./GenericWorker`);function a(e){i.call(this,`DataLengthProbe for `+e),this.propName=e,this.withStreamInfo(e,0)}r.inherits(a,i),a.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){var r=e(`../utils`),i=e(`./GenericWorker`);function a(e){i.call(this,`DataWorker`);var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type=``,this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=r.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}r.inherits(a,i),a.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case`string`:e=this.data.substring(this.index,t);break;case`uint8array`:e=this.data.subarray(this.index,t);break;case`array`:case`nodebuffer`:e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){function r(e){this.name=e||`default`,this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(e){this.emit(`data`,e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit(`end`),this.cleanUp(),this.isFinished=!0}catch(e){this.emit(`error`,e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit(`error`,e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n `+e:e}},t.exports=r},{}],29:[function(e,t,n){var r=e(`../utils`),i=e(`./ConvertWorker`),a=e(`./GenericWorker`),o=e(`../base64`),s=e(`../support`),c=e(`../external`),l=null;if(s.nodestream)try{l=e(`../nodejs/NodejsStreamOutputAdapter`)}catch{}function u(e,t){return new c.Promise(function(n,i){var a=[],s=e._internalType,c=e._outputType,l=e._mimeType;e.on(`data`,function(e,n){a.push(e),t&&t(n)}).on(`error`,function(e){a=[],i(e)}).on(`end`,function(){try{var e=function(e,t,n){switch(e){case`blob`:return r.newBlob(r.transformTo(`arraybuffer`,t),n);case`base64`:return o.encode(t);default:return r.transformTo(e,t)}}(c,function(e,t){var n,r=0,i=null,a=0;for(n=0;n`u`)n.blob=!1;else{var r=new ArrayBuffer(0);try{n.blob=new Blob([r],{type:`application/zip`}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(r),n.blob=i.getBlob(`application/zip`).size===0}catch{n.blob=!1}}}try{n.nodestream=!!e(`readable-stream`).Readable}catch{n.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,n){for(var r=e(`./utils`),i=e(`./support`),a=e(`./nodejsUtils`),o=e(`./stream/GenericWorker`),s=Array(256),c=0;c<256;c++)s[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;s[254]=s[254]=1;function l(){o.call(this,`utf-8 decode`),this.leftOver=null}function u(){o.call(this,`utf-8 encode`)}n.utf8encode=function(e){return i.nodebuffer?a.newBufferFrom(e,`utf-8`):function(e){var t,n,r,a,o,s=e.length,c=0;for(a=0;a>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t}(e)},n.utf8decode=function(e){return i.nodebuffer?r.transformTo(`nodebuffer`,e).toString(`utf-8`):function(e){var t,n,i,a,o=e.length,c=Array(2*o);for(t=n=0;t>10&1023,c[n++]=56320|1023&i)}return c.length!==n&&(c.subarray?c=c.subarray(0,n):c.length=n),r.applyFromCharCode(c)}(e=r.transformTo(i.uint8array?`uint8array`:`array`,e))},r.inherits(l,o),l.prototype.processChunk=function(e){var t=r.transformTo(i.uint8array?`uint8array`:`array`,e.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var a=t;(t=new Uint8Array(a.length+this.leftOver.length)).set(this.leftOver,0),t.set(a,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var o=function(e,t){var n;for((t||=e.length)>e.length&&(t=e.length),n=t-1;0<=n&&(192&e[n])==128;)n--;return n<0||n===0?t:n+s[e[n]]>t?n:t}(t),c=t;o!==t.length&&(i.uint8array?(c=t.subarray(0,o),this.leftOver=t.subarray(o,t.length)):(c=t.slice(0,o),this.leftOver=t.slice(o,t.length))),this.push({data:n.utf8decode(c),meta:e.meta})},l.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=l,r.inherits(u,o),u.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=u},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){var r=e(`./support`),i=e(`./base64`),a=e(`./nodejsUtils`),o=e(`./external`);function s(e){return e}function c(e,t){for(var n=0;n>8;this.dir=!!(16&this.externalFileAttributes),e==0&&(this.dosPermissions=63&this.externalFileAttributes),e==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!==`/`||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=r(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,n,r,i=e.index+this.extraFieldsLength;for(this.extraFields||={};e.index+4>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t},n.buf2binstring=function(e){return c(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n>10&1023,l[r++]=56320|1023&i)}return c(l,r)},n.utf8border=function(e,t){var n;for((t||=e.length)>e.length&&(t=e.length),n=t-1;0<=n&&(192&e[n])==128;)n--;return n<0||n===0?t:n+o[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){t.exports=function(e,t,n,r){for(var i=65535&e|0,a=e>>>16&65535|0,o=0;n!==0;){for(n-=o=2e3>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var a=r,o=i+n;e^=-1;for(var s=i;s>>8^a[255&(e^t[s])];return-1^e}},{}],46:[function(e,t,n){var r,i=e(`../utils/common`),a=e(`./trees`),o=e(`./adler32`),s=e(`./crc32`),c=e(`./messages`),l=0,u=4,d=0,f=-2,p=-1,m=4,h=2,g=8,_=9,v=286,y=30,b=19,x=2*v+1,S=15,C=3,w=258,T=w+C+1,E=42,D=113,O=1,k=2,A=3,j=4;function M(e,t){return e.msg=c[t],t}function N(e){return(e<<1)-(4e.avail_out&&(n=e.avail_out),n!==0&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function F(e,t){a._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,P(e.strm)}function I(e,t){e.pending_buf[e.pending++]=t}function L(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function te(e,t){var n,r,i=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-T?e.strstart-(e.w_size-T):0,l=e.window,u=e.w_mask,d=e.prev,f=e.strstart+w,p=l[a+o-1],m=l[a+o];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do if(l[(n=t)+o]===m&&l[n+o-1]===p&&l[n]===l[a]&&l[++n]===l[a+1]){a+=2,n++;do;while(l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&ac&&--i!=0);return o<=e.lookahead?o:e.lookahead}function ne(e){var t,n,r,a,c,l,u,d,f,p,m=e.w_size;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=m+(m-T)){for(i.arraySet(e.window,e.window,m,m,0),e.match_start-=m,e.strstart-=m,e.block_start-=m,t=n=e.hash_size;r=e.head[--t],e.head[t]=m<=r?r-m:0,--n;);for(t=n=m;r=e.prev[--t],e.prev[t]=m<=r?r-m:0,--n;);a+=m}if(e.strm.avail_in===0)break;if(l=e.strm,u=e.window,d=e.strstart+e.lookahead,f=a,p=void 0,p=l.avail_in,f=C)for(c=e.strstart-e.insert,e.ins_h=e.window[c],e.ins_h=(e.ins_h<=C&&(e.ins_h=(e.ins_h<=C)if(r=a._tr_tally(e,e.strstart-e.match_start,e.match_length-C),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=C){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=C&&(e.ins_h=(e.ins_h<=C&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-C,r=a._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-C),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(ne(e),e.lookahead===0&&t===l)return O;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,F(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-T&&(F(e,!1),e.strm.avail_out===0))return O}return e.insert=0,t===u?(F(e,!0),e.strm.avail_out===0?A:j):(e.strstart>e.block_start&&(F(e,!1),e.strm.avail_out),O)}),new ae(4,4,8,4,re),new ae(4,5,16,8,re),new ae(4,6,32,32,re),new ae(4,4,16,16,ie),new ae(8,16,32,32,ie),new ae(8,16,128,128,ie),new ae(8,32,128,256,ie),new ae(32,128,258,1024,ie),new ae(32,258,258,4096,ie)],n.deflateInit=function(e,t){return le(e,t,g,15,8,0)},n.deflateInit2=le,n.deflateReset=ce,n.deflateResetKeep=se,n.deflateSetHeader=function(e,t){return e&&e.state&&e.state.wrap===2?(e.state.gzhead=t,d):f},n.deflate=function(e,t){var n,i,o,c;if(!e||!e.state||5>8&255),I(i,i.gzhead.time>>16&255),I(i,i.gzhead.time>>24&255),I(i,i.level===9?2:2<=i.strategy||i.level<2?4:0),I(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(I(i,255&i.gzhead.extra.length),I(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=s(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(I(i,0),I(i,0),I(i,0),I(i,0),I(i,0),I(i,i.level===9?2:2<=i.strategy||i.level<2?4:0),I(i,3),i.status=D);else{var p=g+(i.w_bits-8<<4)<<8;p|=(2<=i.strategy||i.level<2?0:i.level<6?1:i.level===6?2:3)<<6,i.strstart!==0&&(p|=32),p+=31-p%31,i.status=D,L(i,p),i.strstart!==0&&(L(i,e.adler>>>16),L(i,65535&e.adler)),e.adler=1}if(i.status===69)if(i.gzhead.extra){for(o=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),P(e),o=i.pending,i.pending!==i.pending_buf_size));)I(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(i.status===73)if(i.gzhead.name){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),P(e),o=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindexo&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),c===0&&(i.gzindex=0,i.status=91)}else i.status=91;if(i.status===91)if(i.gzhead.comment){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),P(e),o=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindexo&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),c===0&&(i.status=103)}else i.status=103;if(i.status===103&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&P(e),i.pending+2<=i.pending_buf_size&&(I(i,255&e.adler),I(i,e.adler>>8&255),e.adler=0,i.status=D)):i.status=D),i.pending!==0){if(P(e),e.avail_out===0)return i.last_flush=-1,d}else if(e.avail_in===0&&N(t)<=N(n)&&t!==u)return M(e,-5);if(i.status===666&&e.avail_in!==0)return M(e,-5);if(e.avail_in!==0||i.lookahead!==0||t!==l&&i.status!==666){var m=i.strategy===2?function(e,t){for(var n;;){if(e.lookahead===0&&(ne(e),e.lookahead===0)){if(t===l)return O;break}if(e.match_length=0,n=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(F(e,!1),e.strm.avail_out===0))return O}return e.insert=0,t===u?(F(e,!0),e.strm.avail_out===0?A:j):e.last_lit&&(F(e,!1),e.strm.avail_out===0)?O:k}(i,t):i.strategy===3?function(e,t){for(var n,r,i,o,s=e.window;;){if(e.lookahead<=w){if(ne(e),e.lookahead<=w&&t===l)return O;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=C&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=C?(n=a._tr_tally(e,1,e.match_length-C),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(F(e,!1),e.strm.avail_out===0))return O}return e.insert=0,t===u?(F(e,!0),e.strm.avail_out===0?A:j):e.last_lit&&(F(e,!1),e.strm.avail_out===0)?O:k}(i,t):r[i.level].func(i,t);if(m!==A&&m!==j||(i.status=666),m===O||m===A)return e.avail_out===0&&(i.last_flush=-1),d;if(m===k&&(t===1?a._tr_align(i):t!==5&&(a._tr_stored_block(i,0,0,!1),t===3&&(ee(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),P(e),e.avail_out===0))return i.last_flush=-1,d}return t===u?i.wrap<=0?1:(i.wrap===2?(I(i,255&e.adler),I(i,e.adler>>8&255),I(i,e.adler>>16&255),I(i,e.adler>>24&255),I(i,255&e.total_in),I(i,e.total_in>>8&255),I(i,e.total_in>>16&255),I(i,e.total_in>>24&255)):(L(i,e.adler>>>16),L(i,65535&e.adler)),P(e),0=n.w_size&&(s===0&&(ee(n.head),n.strstart=0,n.block_start=0,n.insert=0),p=new i.Buf8(n.w_size),i.arraySet(p,t,m-n.w_size,n.w_size,0),t=p,m=n.w_size),c=e.avail_in,l=e.next_in,u=e.input,e.avail_in=m,e.next_in=0,e.input=t,ne(n);n.lookahead>=C;){for(r=n.strstart,a=n.lookahead-(C-1);n.ins_h=(n.ins_h<>>=b=y>>>24,m-=b,(b=y>>>16&255)==0)E[a++]=65535&y;else{if(!(16&b)){if(!(64&b)){y=h[(65535&y)+(p&(1<>>=b,m-=b),m<15&&(p+=T[r++]<>>=b=y>>>24,m-=b,!(16&(b=y>>>16&255))){if(!(64&b)){y=g[(65535&y)+(p&(1<>>=b,m-=b,(b=a-o)>3,p&=(1<<(m-=x<<3))-1,e.next_in=r,e.next_out=a,e.avail_in=r>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function g(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg=``,t.wrap&&(e.adler=1&t.wrap),t.mode=f,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(p),t.distcode=t.distdyn=new r.Buf32(m),t.sane=1,t.back=-1,u):d}function v(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,_(e)):d}function y(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=o.wsize?(r.arraySet(o.window,t,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(i<(a=o.wsize-o.wnext)&&(a=i),r.arraySet(o.window,t,n-i,a,o.wnext),(i-=a)?(r.arraySet(o.window,t,n-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,n.check=a(n.check,ne,2,0),x=b=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&b)<<8)+(b>>8))%31){e.msg=`incorrect header check`,n.mode=30;break}if((15&b)!=8){e.msg=`unknown compression method`,n.mode=30;break}if(x-=4,P=8+(15&(b>>>=4)),n.wbits===0)n.wbits=P;else if(P>n.wbits){e.msg=`invalid window size`,n.mode=30;break}n.dmax=1<>8&1),512&n.flags&&(ne[0]=255&b,ne[1]=b>>>8&255,n.check=a(n.check,ne,2,0)),x=b=0,n.mode=3;case 3:for(;x<32;){if(v===0)break e;v--,b+=p[g++]<>>8&255,ne[2]=b>>>16&255,ne[3]=b>>>24&255,n.check=a(n.check,ne,4,0)),x=b=0,n.mode=4;case 4:for(;x<16;){if(v===0)break e;v--,b+=p[g++]<>8),512&n.flags&&(ne[0]=255&b,ne[1]=b>>>8&255,n.check=a(n.check,ne,2,0)),x=b=0,n.mode=5;case 5:if(1024&n.flags){for(;x<16;){if(v===0)break e;v--,b+=p[g++]<>>8&255,n.check=a(n.check,ne,2,0)),x=b=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(v<(E=n.length)&&(E=v),E&&(n.head&&(P=n.head.extra_len-n.length,n.head.extra||(n.head.extra=Array(n.head.extra_len)),r.arraySet(n.head.extra,p,g,E,P)),512&n.flags&&(n.check=a(n.check,p,E,g)),v-=E,g+=E,n.length-=E),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(v===0)break e;for(E=0;P=p[g+ E++],n.head&&P&&n.length<65536&&(n.head.name+=String.fromCharCode(P)),P&&E>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;x<32;){if(v===0)break e;v--,b+=p[g++]<>>=7&x,x-=7&x,n.mode=27;break}for(;x<3;){if(v===0)break e;v--,b+=p[g++]<>>=1)){case 0:n.mode=14;break;case 1:if(w(n),n.mode=20,t!==6)break;b>>>=2,x-=2;break e;case 2:n.mode=17;break;case 3:e.msg=`invalid block type`,n.mode=30}b>>>=2,x-=2;break;case 14:for(b>>>=7&x,x-=7&x;x<32;){if(v===0)break e;v--,b+=p[g++]<>>16^65535)){e.msg=`invalid stored block lengths`,n.mode=30;break}if(n.length=65535&b,x=b=0,n.mode=15,t===6)break e;case 15:n.mode=16;case 16:if(E=n.length){if(v>>=5,x-=5,n.ndist=1+(31&b),b>>>=5,x-=5,n.ncode=4+(15&b),b>>>=4,x-=4,286>>=3,x-=3}for(;n.have<19;)n.lens[re[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,I={bits:n.lenbits},F=s(0,n.lens,0,19,n.lencode,0,n.work,I),n.lenbits=I.bits,F){e.msg=`invalid code lengths set`,n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,j=65535&te,!((k=te>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>>=k,x-=k,n.lens[n.have++]=j;else{if(j===16){for(L=k+2;x>>=k,x-=k,n.have===0){e.msg=`invalid bit length repeat`,n.mode=30;break}P=n.lens[n.have-1],E=3+(3&b),b>>>=2,x-=2}else if(j===17){for(L=k+3;x>>=k)),b>>>=3,x-=3}else{for(L=k+7;x>>=k)),b>>>=7,x-=7}if(n.have+E>n.nlen+n.ndist){e.msg=`invalid bit length repeat`,n.mode=30;break}for(;E--;)n.lens[n.have++]=P}}if(n.mode===30)break;if(n.lens[256]===0){e.msg=`invalid code -- missing end-of-block`,n.mode=30;break}if(n.lenbits=9,I={bits:n.lenbits},F=s(c,n.lens,0,n.nlen,n.lencode,0,n.work,I),n.lenbits=I.bits,F){e.msg=`invalid literal/lengths set`,n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,I={bits:n.distbits},F=s(l,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,I),n.distbits=I.bits,F){e.msg=`invalid distances set`,n.mode=30;break}if(n.mode=20,t===6)break e;case 20:n.mode=21;case 21:if(6<=v&&258<=y){e.next_out=_,e.avail_out=y,e.next_in=g,e.avail_in=v,n.hold=b,n.bits=x,o(e,C),_=e.next_out,m=e.output,y=e.avail_out,g=e.next_in,p=e.input,v=e.avail_in,b=n.hold,x=n.bits,n.mode===12&&(n.back=-1);break}for(n.back=0;A=(te=n.lencode[b&(1<>>16&255,j=65535&te,!((k=te>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>M)])>>>16&255,j=65535&te,!(M+(k=te>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>>=M,x-=M,n.back+=M}if(b>>>=k,x-=k,n.back+=k,n.length=j,A===0){n.mode=26;break}if(32&A){n.back=-1,n.mode=12;break}if(64&A){e.msg=`invalid literal/length code`,n.mode=30;break}n.extra=15&A,n.mode=22;case 22:if(n.extra){for(L=n.extra;x>>=n.extra,x-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;A=(te=n.distcode[b&(1<>>16&255,j=65535&te,!((k=te>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>M)])>>>16&255,j=65535&te,!(M+(k=te>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>>=M,x-=M,n.back+=M}if(b>>>=k,x-=k,n.back+=k,64&A){e.msg=`invalid distance code`,n.mode=30;break}n.offset=j,n.extra=15&A,n.mode=24;case 24:if(n.extra){for(L=n.extra;x>>=n.extra,x-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg=`invalid distance too far back`,n.mode=30;break}n.mode=25;case 25:if(y===0)break e;if(E=C-y,n.offset>E){if((E=n.offset-E)>n.whave&&n.sane){e.msg=`invalid distance too far back`,n.mode=30;break}D=E>n.wnext?(E-=n.wnext,n.wsize-E):n.wnext-E,E>n.length&&(E=n.length),O=n.window}else O=m,D=_-n.offset,E=n.length;for(yv?(b=I[L+d[w]],N[ee+d[w]]):(b=96,0),p=1<>k)+(m-=p)]=y<<24|b<<16|x|0,m!==0;);for(p=1<>=1;if(p===0?M=0:(M&=p-1,M+=p),w++,--P[C]==0){if(C===E)break;C=t[n+d[w]]}if(D>>7)]}function I(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function L(e,t,n){e.bi_valid>h-n?(e.bi_buf|=t<>h-e.bi_valid,e.bi_valid+=n-h):(e.bi_buf|=t<>>=1,n<<=1,0<--t;);return n>>>1}function re(e,t,n){var r,i,a=Array(m+1),o=0;for(r=1;r<=m;r++)a[r]=o=o+n[r-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];s!==0&&(e[2*i]=ne(a[s]++,s))}}function ie(e){var t;for(t=0;t>1;1<=n;n--)se(e,a,n);for(i=c;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],se(e,a,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,a[2*i]=a[2*n]+a[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,a[2*n+1]=a[2*r+1]=i,e.heap[1]=i++,se(e,a,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,a,o,s,c=t.dyn_tree,l=t.max_code,u=t.stat_desc.static_tree,d=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,h=t.stat_desc.extra_base,g=t.stat_desc.max_length,_=0;for(a=0;a<=m;a++)e.bl_count[a]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n>=7;r>>=1)if(1&n&&e.dyn_ltree[2*t]!==0)return i;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return a;for(t=32;t>>3,(s=e.static_len+3+7>>>3)<=o&&(o=s)):o=s=n+5,n+4<=o&&t!==-1?pe(e,t,n,r):e.strategy===4||s===o?(L(e,2+(r?1:0),3),ce(e,T,E)):(L(e,4+(r?1:0),3),function(e,t,n,r){var i;for(L(e,t-257,5),L(e,n-1,5),L(e,r-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,t===0?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(O[n]+l+1)]++,e.dyn_dtree[2*F(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){L(e,2,3),te(e,_,T),function(e){e.bi_valid===16?(I(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,n){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=``,this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,n){(function(e){(function(e,t){if(!e.setImmediate){var n,r,i,a,o=1,s={},c=!1,l=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,n={}.toString.call(e.process)===`[object process]`?function(e){process.nextTick(function(){f(e)})}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage(``,`*`),e.onmessage=n,t}}()?(a=`setImmediate$`+Math.random()+`$`,e.addEventListener?e.addEventListener(`message`,p,!1):e.attachEvent(`onmessage`,p),function(t){e.postMessage(a+t,`*`)}):e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){f(e.data)},function(e){i.port2.postMessage(e)}):l&&`onreadystatechange`in l.createElement(`script`)?(r=l.documentElement,function(e){var t=l.createElement(`script`);t.onreadystatechange=function(){f(e),t.onreadystatechange=null,r.removeChild(t),t=null},r.appendChild(t)}):function(e){setTimeout(f,0,e)},u.setImmediate=function(e){typeof e!=`function`&&(e=Function(``+e));for(var t=Array(arguments.length-1),r=0;r`u`?e===void 0?this:e:self)}).call(this,typeof global<`u`?global:typeof self<`u`?self:typeof window<`u`?window:{})},{}]},{},[10])(10)})})),qh=Rt(Kh());Hf.zipReader=(e,t)=>qh.default.loadAsync(e);const Jh=Hf.createSettings;Hf.createSettings=async e=>{let t=Object.keys(e.files);return t.find(e=>Yh(e))?Jh(e):Qh(t)};function Yh(e){return e.endsWith(`model3.json`)}function Xh(e){return e.endsWith(`.moc3`)}function Zh(e){return e.split(/[\\/]/).pop()}function Qh(e){let t=e.filter(e=>Xh(e));if(t.length!==1){let e=t.length?`(${t.map(e=>`"${e}"`).join(`,`)})`:``;throw Error(`Expected exactly one moc file, got ${t.length} ${e}`)}let n=t[0],r=Zh(n).replace(/\.moc3?/,``),i=e.filter(e=>e.endsWith(`.png`));if(!i.length)throw Error(`Textures not found`);let a=e.filter(e=>e.endsWith(`.mtn`)||e.endsWith(`.motion3.json`)),o=e.find(e=>e.includes(`physics`)),s=e.find(e=>e.includes(`pose`)),c=new Wf({url:`${r}.model3.json`,Version:3,FileReferences:{Moc:n,Textures:i,Physics:o,Pose:s,Motions:a.length?{"":a.map(e=>({File:e}))}:void 0}});return c.name=r,c._objectURL=`example://${c.url}`,c}Hf.readText=(e,t)=>{let n=e.file(t);if(!n)throw Error(`Cannot find file: ${t}`);return n.async(`text`)},Hf.getFilePaths=e=>{let t=[];return e.forEach(e=>t.push(e)),Promise.resolve(t)},Hf.getFiles=(e,t)=>Promise.all(t.map(async t=>{let n=t.slice(t.lastIndexOf(`/`)+1),r=await e.file(t).async(`blob`);return new File([r],n)}));var $h=Wt({__name:`Live2D`,props:{modelSrc:{},paused:{type:Boolean,default:!1},mouthOpenSize:{default:0},focusAt:{default:()=>({x:0,y:0})},disableFocusAt:{type:Boolean},xOffset:{},yOffset:{},scale:{default:1}},setup(e,{expose:t}){let n=R();return t({canvasElement:()=>n.value?.canvasElement()}),(e,t)=>(Xt(),Bt(r,{relative:``},{default:Dt(({width:t,height:r})=>[Ut(ep,{ref_key:`live2dCanvasRef`,ref:n,width:t,height:r,resolution:2,"max-h":`100dvh`},{default:Dt(({app:n})=>[Ut(Gh,{"model-src":e.modelSrc,app:n,"mouth-open-size":e.mouthOpenSize,width:t,height:r,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,[`model-src`,`app`,`mouth-open-size`,`width`,`height`,`paused`,`focus-at`,`x-offset`,`y-offset`,`scale`,`disable-focus-at`])]),_:2},1032,[`width`,`height`])]),_:1}))}}),eg=$h;function tg(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 ng(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 V(e){return this instanceof V?(this.v=e,this):new V(e)}function rg(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 V?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 ig(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:V(e[r](t)),done:!1}:i?i(t):t}:i}}function ag(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof ng==`function`?ng(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 og=new TextDecoder(`utf-8`),sg=e=>og.decode(e),cg=new TextEncoder,lg=e=>cg.encode(e),ug=e=>typeof e==`number`,dg=e=>typeof e==`boolean`,fg=e=>typeof e==`function`,pg=e=>e!=null&&Object(e)===e,mg=e=>pg(e)&&fg(e.then),hg=e=>pg(e)&&fg(e[Symbol.iterator]),gg=e=>pg(e)&&fg(e[Symbol.asyncIterator]),_g=e=>pg(e)&&pg(e.schema),vg=e=>pg(e)&&`done`in e&&`value`in e,yg=e=>pg(e)&&fg(e.stat)&&ug(e.fd),bg=e=>pg(e)&&Cg(e.body),xg=e=>`_getDOMStream`in e&&`_getNodeStream`in e,Sg=e=>pg(e)&&fg(e.abort)&&fg(e.getWriter)&&!xg(e),Cg=e=>pg(e)&&fg(e.cancel)&&fg(e.getReader)&&!xg(e),wg=e=>pg(e)&&fg(e.end)&&fg(e.write)&&dg(e.writable)&&!xg(e),Tg=e=>pg(e)&&fg(e.read)&&fg(e.pipe)&&dg(e.readable)&&!xg(e),Eg=e=>pg(e)&&fg(e.clear)&&fg(e.bytes)&&fg(e.position)&&fg(e.setPosition)&&fg(e.capacity)&&fg(e.getBufferIdentifier)&&fg(e.createLong),Dg=typeof SharedArrayBuffer<`u`?SharedArrayBuffer:ArrayBuffer;function Og(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;++cjg(Int32Array,e),Ng=e=>jg(BigInt64Array,e),Pg=e=>jg(Uint8Array,e),Fg=e=>(e.next(),e);function*Ig(e,t){let n=function*(e){yield e},r=typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Dg?n(t):hg(t)?t:n(t);return yield*Fg((function*(t){let n=null;do n=t.next(yield jg(e,n));while(!n.done)})(r[Symbol.iterator]())),new e}const Lg=e=>Ig(Uint8Array,e);function Rg(e,t){return rg(this,arguments,function*(){if(mg(t))return yield V(yield V(yield*ig(ag(Rg(e,yield V(t))))));let n=function(e){return rg(this,arguments,function*(){yield yield V(yield V(e))})},r=function(e){return rg(this,arguments,function*(){yield V(yield*ig(ag(Fg((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 Dg?n(t):hg(t)?r(t):gg(t)?t:n(t);return yield V(yield*ig(ag(Fg((function(t){return rg(this,arguments,function*(){let n=null;do n=yield V(t.next(yield yield V(jg(e,n))));while(!n.done)})})(i[Symbol.asyncIterator]()))))),yield V(new e)})}const zg=e=>Rg(Uint8Array,e);function Bg(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*Wg(e){let t,n=!1,r=[],i,a,o,s=0;function c(){return a===`peek`?Ag(r,o)[0]:([i,r,s]=Ag(r,o),i)}({cmd:a,size:o}=(yield(()=>null)())||{cmd:`read`,size:0});let l=Lg(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=zg(e)[Symbol.asyncIterator]();try{do if({done:t,value:i}=Number.isNaN(o-s)?yield V(l.next()):yield V(l.next(o-s)),!t&&i.byteLength>0&&(r.push(i),s+=i.byteLength),t||o<=s)do({cmd:a,size:o}=yield yield V(c()));while(onull)()))||{cmd:`read`,size:0});let l=new qg(e);try{do if({done:t,value:i}=Number.isNaN(o-s)?yield V(l.read()):yield V(l.read(o-s)),!t&&i.byteLength>0&&(r.push(Pg(i)),s+=i.byteLength),t||o<=s)do({cmd:a,size:o}=yield yield V(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 tg(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 tg(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=Pg(t)),t})}};const Jg=(e,t)=>{let n=e=>r([t,e]),r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function Yg(e){return rg(this,arguments,function*(){let t=[],n=`error`,r=!1,i=null,a,o,s=0,c=[],l;function u(){return a===`peek`?Ag(c,o)[0]:([l,c,s]=Ag(c,o),l)}if({cmd:a,size:o}=(yield yield V((()=>null)()))||{cmd:`read`,size:0},e.isTTY)return yield yield V(new Uint8Array),yield V(null);try{t[0]=Jg(e,`end`),t[1]=Jg(e,`error`);do{if(t[2]=Jg(e,`readable`),[n,i]=yield V(Promise.race(t.map(e=>e[2]))),n===`error`)break;if((r=n===`end`)||(Number.isFinite(o-s)?(l=Pg(e.read(o-s)),l.byteLength0&&(c.push(l),s+=l.byteLength)),r||o<=s)do({cmd:a,size:o}=yield yield V(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 Xg;(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`})(Xg||={});var Zg;(function(e){e[e.Sparse=0]=`Sparse`,e[e.Dense=1]=`Dense`})(Zg||={});var Qg;(function(e){e[e.HALF=0]=`HALF`,e[e.SINGLE=1]=`SINGLE`,e[e.DOUBLE=2]=`DOUBLE`})(Qg||={});var $g;(function(e){e[e.DAY=0]=`DAY`,e[e.MILLISECOND=1]=`MILLISECOND`})($g||={});var e_;(function(e){e[e.SECOND=0]=`SECOND`,e[e.MILLISECOND=1]=`MILLISECOND`,e[e.MICROSECOND=2]=`MICROSECOND`,e[e.NANOSECOND=3]=`NANOSECOND`})(e_||={});var t_;(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`})(t_||={});const n_=new Int32Array(2),r_=new Float32Array(n_.buffer),i_=new Float64Array(n_.buffer),a_=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var o_;(function(e){e[e.UTF8_BYTES=1]=`UTF8_BYTES`,e[e.UTF16_STRING=2]=`UTF16_STRING`})(o_||={});var s_=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){r_[0]=t,this.writeInt32(e,n_[0])}writeFloat64(e,t){i_[0]=t,this.writeInt32(e,n_[a_?0:1]),this.writeInt32(e+4,n_[a_?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)}},z_=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)}},B_;(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`})(B_||={});var V_=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):B_.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 y_).__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 b_).__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,B_.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}},H_=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):g_.Little}fields(e,t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new V_).__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 b_).__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,g_.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)}},U_;(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`})(U_||={});var H;(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`})(H||={});var W_;(function(e){e[e.OFFSET=0]=`OFFSET`,e[e.DATA=1]=`DATA`,e[e.VALIDITY=2]=`VALIDITY`,e[e.TYPE=3]=`TYPE`})(W_||={});function G_(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=>G_(e))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(e,t)=>typeof t==`bigint`?`${t}`:t)}function K_(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 q_(e,t){return K_(e/t)+K_(e%t)/K_(t)}const J_=Symbol.for(`isArrowBigNum`);function Y_(e,...t){return t.length===0?Object.setPrototypeOf(jg(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}Y_.prototype[J_]=!0,Y_.prototype.toJSON=function(){return`"${nv(this)}"`},Y_.prototype.valueOf=function(e){return tv(this,e)},Y_.prototype.toString=function(){return nv(this)},Y_.prototype[Symbol.toPrimitive]=function(e=`default`){switch(e){case`number`:return tv(this);case`string`:return nv(this);case`default`:return rv(this)}return nv(this)};function X_(...e){return Y_.apply(this,e)}function Z_(...e){return Y_.apply(this,e)}function Q_(...e){return Y_.apply(this,e)}Object.setPrototypeOf(X_.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(Z_.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(Q_.prototype,Object.create(Uint32Array.prototype)),Object.assign(X_.prototype,Y_.prototype,{constructor:X_,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(Z_.prototype,Y_.prototype,{constructor:Z_,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(Q_.prototype,Y_.prototype,{constructor:Q_,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const $_=BigInt(4294967296)*BigInt(4294967296),ev=$_-BigInt(1);function tv(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 iv(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`))(U.prototype);var Ov=class extends U{constructor(){super(H.Null)}toString(){return`Null`}};sv=Symbol.toStringTag,Ov[sv]=(e=>e[Symbol.toStringTag]=`Null`)(Ov.prototype);var kv=class extends U{constructor(e,t){super(H.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}`}};cv=Symbol.toStringTag,kv[cv]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]=`Int`))(kv.prototype);var Av=class extends kv{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},jv=class extends kv{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},Mv=class extends kv{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Nv=class extends kv{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},Pv=class extends kv{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},Fv=class extends kv{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},Iv=class extends kv{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},Lv=class extends kv{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(Av.prototype,`ArrayType`,{value:Int8Array}),Object.defineProperty(jv.prototype,`ArrayType`,{value:Int16Array}),Object.defineProperty(Mv.prototype,`ArrayType`,{value:Int32Array}),Object.defineProperty(Nv.prototype,`ArrayType`,{value:BigInt64Array}),Object.defineProperty(Pv.prototype,`ArrayType`,{value:Uint8Array}),Object.defineProperty(Fv.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(Iv.prototype,`ArrayType`,{value:Uint32Array}),Object.defineProperty(Lv.prototype,`ArrayType`,{value:BigUint64Array});var Rv=class extends U{constructor(e){super(H.Float),this.precision=e}get ArrayType(){switch(this.precision){case Qg.HALF:return Uint16Array;case Qg.SINGLE:return Float32Array;case Qg.DOUBLE:return Float64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};lv=Symbol.toStringTag,Rv[lv]=(e=>(e.precision=null,e[Symbol.toStringTag]=`Float`))(Rv.prototype);var zv=class extends Rv{constructor(){super(Qg.HALF)}},Bv=class extends Rv{constructor(){super(Qg.SINGLE)}},Vv=class extends Rv{constructor(){super(Qg.DOUBLE)}};Object.defineProperty(zv.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(Bv.prototype,`ArrayType`,{value:Float32Array}),Object.defineProperty(Vv.prototype,`ArrayType`,{value:Float64Array});var Hv=class extends U{constructor(){super(H.Binary)}toString(){return`Binary`}};uv=Symbol.toStringTag,Hv[uv]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Binary`))(Hv.prototype);var Uv=class extends U{constructor(){super(H.LargeBinary)}toString(){return`LargeBinary`}};dv=Symbol.toStringTag,Uv[dv]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeBinary`))(Uv.prototype);var Wv=class extends U{constructor(){super(H.Utf8)}toString(){return`Utf8`}};fv=Symbol.toStringTag,Wv[fv]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Utf8`))(Wv.prototype);var Gv=class extends U{constructor(){super(H.LargeUtf8)}toString(){return`LargeUtf8`}};pv=Symbol.toStringTag,Gv[pv]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeUtf8`))(Gv.prototype);var Kv=class extends U{constructor(){super(H.Bool)}toString(){return`Bool`}};mv=Symbol.toStringTag,Kv[mv]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Bool`))(Kv.prototype);var qv=class extends U{constructor(e,t,n=128){super(H.Decimal),this.scale=e,this.precision=t,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?`+`:``}${this.scale}]`}};hv=Symbol.toStringTag,qv[hv]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]=`Decimal`))(qv.prototype);var Jv=class extends U{constructor(e){super(H.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${$g[this.unit]}>`}get ArrayType(){return this.unit===$g.DAY?Int32Array:BigInt64Array}};gv=Symbol.toStringTag,Jv[gv]=(e=>(e.unit=null,e[Symbol.toStringTag]=`Date`))(Jv.prototype);var Yv=class extends U{constructor(e,t){super(H.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${e_[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};_v=Symbol.toStringTag,Yv[_v]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]=`Time`))(Yv.prototype);var Xv=class extends U{constructor(e,t){super(H.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${e_[this.unit]}${this.timezone?`, ${this.timezone}`:``}>`}};vv=Symbol.toStringTag,Xv[vv]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Timestamp`))(Xv.prototype);var Zv=class extends U{constructor(e){super(H.Interval),this.unit=e}toString(){return`Interval<${t_[this.unit]}>`}};yv=Symbol.toStringTag,Zv[yv]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]=`Interval`))(Zv.prototype);var Qv=class extends U{constructor(e){super(H.Duration),this.unit=e}toString(){return`Duration<${e_[this.unit]}>`}};bv=Symbol.toStringTag,Qv[bv]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Duration`))(Qv.prototype);var $v=class extends U{constructor(e){super(H.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}};xv=Symbol.toStringTag,$v[xv]=(e=>(e.children=null,e[Symbol.toStringTag]=`List`))($v.prototype);var ey=class extends U{constructor(e){super(H.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};Sv=Symbol.toStringTag,ey[Sv]=(e=>(e.children=null,e[Symbol.toStringTag]=`Struct`))(ey.prototype);var ty=class extends U{constructor(e,t,n){super(H.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(` | `)}>`}};Cv=Symbol.toStringTag,ty[Cv]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]=`Union`))(ty.prototype);var ny=class extends U{constructor(e){super(H.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};wv=Symbol.toStringTag,ny[wv]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`FixedSizeBinary`))(ny.prototype);var ry=class extends U{constructor(e,t){super(H.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}>`}};Tv=Symbol.toStringTag,ry[Tv]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]=`FixedSizeList`))(ry.prototype);var iy=class extends U{constructor(e,t=!1){var n,r,i;if(super(H.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(`, `)}}>`}};Ev=Symbol.toStringTag,iy[Ev]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]=`Map_`))(iy.prototype);const ay=(e=>()=>++e)(-1);var oy=class extends U{constructor(e,t,n,r){super(H.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=r||!1,this.id=n==null?ay():K_(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}>`}};Dv=Symbol.toStringTag,oy[Dv]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]=`Dictionary`))(oy.prototype);function sy(e){let t=e;switch(e.typeId){case H.Decimal:return e.bitWidth/32;case H.Interval:return 1+t.unit;case H.FixedSizeList:return t.listSize;case H.FixedSizeBinary:return t.byteWidth;default:return 1}}var cy=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 ly(this,e,t)}getVisitFnByTypeId(e,t=!0){return uy(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 ly(e,t,n=!0){return typeof t==`number`?uy(e,t,n):typeof t==`string`&&t in H?uy(e,H[t],n):t&&t instanceof U?uy(e,dy(t),n):t?.type&&t.type instanceof U?uy(e,dy(t.type),n):uy(e,H.NONE,n)}function uy(e,t,n=!0){let r=null;switch(t){case H.Null:r=e.visitNull;break;case H.Bool:r=e.visitBool;break;case H.Int:r=e.visitInt;break;case H.Int8:r=e.visitInt8||e.visitInt;break;case H.Int16:r=e.visitInt16||e.visitInt;break;case H.Int32:r=e.visitInt32||e.visitInt;break;case H.Int64:r=e.visitInt64||e.visitInt;break;case H.Uint8:r=e.visitUint8||e.visitInt;break;case H.Uint16:r=e.visitUint16||e.visitInt;break;case H.Uint32:r=e.visitUint32||e.visitInt;break;case H.Uint64:r=e.visitUint64||e.visitInt;break;case H.Float:r=e.visitFloat;break;case H.Float16:r=e.visitFloat16||e.visitFloat;break;case H.Float32:r=e.visitFloat32||e.visitFloat;break;case H.Float64:r=e.visitFloat64||e.visitFloat;break;case H.Utf8:r=e.visitUtf8;break;case H.LargeUtf8:r=e.visitLargeUtf8;break;case H.Binary:r=e.visitBinary;break;case H.LargeBinary:r=e.visitLargeBinary;break;case H.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case H.Date:r=e.visitDate;break;case H.DateDay:r=e.visitDateDay||e.visitDate;break;case H.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case H.Timestamp:r=e.visitTimestamp;break;case H.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case H.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case H.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case H.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case H.Time:r=e.visitTime;break;case H.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case H.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case H.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case H.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case H.Decimal:r=e.visitDecimal;break;case H.List:r=e.visitList;break;case H.Struct:r=e.visitStruct;break;case H.Union:r=e.visitUnion;break;case H.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case H.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case H.Dictionary:r=e.visitDictionary;break;case H.Interval:r=e.visitInterval;break;case H.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case H.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case H.Duration:r=e.visitDuration;break;case H.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case H.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case H.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case H.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case H.FixedSizeList:r=e.visitFixedSizeList;break;case H.Map:r=e.visitMap;break}if(typeof r==`function`)return r;if(!n)return()=>null;throw Error(`Unrecognized type '${H[t]}'`)}function dy(e){switch(e.typeId){case H.Null:return H.Null;case H.Int:{let{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?H.Int8:H.Uint8;case 16:return n?H.Int16:H.Uint16;case 32:return n?H.Int32:H.Uint32;case 64:return n?H.Int64:H.Uint64}return H.Int}case H.Float:switch(e.precision){case Qg.HALF:return H.Float16;case Qg.SINGLE:return H.Float32;case Qg.DOUBLE:return H.Float64}return H.Float;case H.Binary:return H.Binary;case H.LargeBinary:return H.LargeBinary;case H.Utf8:return H.Utf8;case H.LargeUtf8:return H.LargeUtf8;case H.Bool:return H.Bool;case H.Decimal:return H.Decimal;case H.Time:switch(e.unit){case e_.SECOND:return H.TimeSecond;case e_.MILLISECOND:return H.TimeMillisecond;case e_.MICROSECOND:return H.TimeMicrosecond;case e_.NANOSECOND:return H.TimeNanosecond}return H.Time;case H.Timestamp:switch(e.unit){case e_.SECOND:return H.TimestampSecond;case e_.MILLISECOND:return H.TimestampMillisecond;case e_.MICROSECOND:return H.TimestampMicrosecond;case e_.NANOSECOND:return H.TimestampNanosecond}return H.Timestamp;case H.Date:switch(e.unit){case $g.DAY:return H.DateDay;case $g.MILLISECOND:return H.DateMillisecond}return H.Date;case H.Interval:switch(e.unit){case t_.DAY_TIME:return H.IntervalDayTime;case t_.YEAR_MONTH:return H.IntervalYearMonth}return H.Interval;case H.Duration:switch(e.unit){case e_.SECOND:return H.DurationSecond;case e_.MILLISECOND:return H.DurationMillisecond;case e_.MICROSECOND:return H.DurationMicrosecond;case e_.NANOSECOND:return H.DurationNanosecond}return H.Duration;case H.Map:return H.Map;case H.List:return H.List;case H.Struct:return H.Struct;case H.Union:switch(e.mode){case Zg.Dense:return H.DenseUnion;case Zg.Sparse:return H.SparseUnion}return H.Union;case H.FixedSizeBinary:return H.FixedSizeBinary;case H.FixedSizeList:return H.FixedSizeList;case H.Dictionary:return H.Dictionary}throw Error(`Unrecognized type '${H[e.typeId]}'`)}cy.prototype.visitInt8=null,cy.prototype.visitInt16=null,cy.prototype.visitInt32=null,cy.prototype.visitInt64=null,cy.prototype.visitUint8=null,cy.prototype.visitUint16=null,cy.prototype.visitUint32=null,cy.prototype.visitUint64=null,cy.prototype.visitFloat16=null,cy.prototype.visitFloat32=null,cy.prototype.visitFloat64=null,cy.prototype.visitDateDay=null,cy.prototype.visitDateMillisecond=null,cy.prototype.visitTimestampSecond=null,cy.prototype.visitTimestampMillisecond=null,cy.prototype.visitTimestampMicrosecond=null,cy.prototype.visitTimestampNanosecond=null,cy.prototype.visitTimeSecond=null,cy.prototype.visitTimeMillisecond=null,cy.prototype.visitTimeMicrosecond=null,cy.prototype.visitTimeNanosecond=null,cy.prototype.visitDenseUnion=null,cy.prototype.visitSparseUnion=null,cy.prototype.visitIntervalDayTime=null,cy.prototype.visitIntervalYearMonth=null,cy.prototype.visitDuration=null,cy.prototype.visitDurationSecond=null,cy.prototype.visitDurationMillisecond=null,cy.prototype.visitDurationMicrosecond=null,cy.prototype.visitDurationNanosecond=null;const fy=new Float64Array(1),py=new Uint32Array(fy.buffer);function my(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 hy(e){if(e!==e)return 32256;fy[0]=e;let t=(py[1]&2147483648)>>16&65535,n=py[1]&2146435072,r=0;return n>=1089470464?py[0]>0?n=31744:(n=(n&2080374784)>>16,r=(py[1]&1048575)>>10):n<=1056964608?(r=1048576+(py[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(py[1]&1048575)+512>>10),t|n|r&65535}var gy=class extends cy{};function _y(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const vy=(e,t,n)=>{e[t]=Math.floor(n/864e5)},yy=(e,t,n,r)=>{if(n+1{let i=e+n;r?t[i>>3]|=1<>3]&=~(1<{e[t]=n},Sy=({values:e},t,n)=>{e[t]=n},Cy=({values:e},t,n)=>{e[t]=hy(n)},wy=(e,t,n)=>{switch(e.type.precision){case Qg.HALF:return Cy(e,t,n);case Qg.SINGLE:case Qg.DOUBLE:return Sy(e,t,n)}},Ty=({values:e},t,n)=>{vy(e,t,n.valueOf())},Ey=({values:e},t,n)=>{e[t]=BigInt(n)},Dy=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},Oy=({values:e,valueOffsets:t},n,r)=>yy(e,t,n,r),ky=({values:e,valueOffsets:t},n,r)=>yy(e,t,n,lg(r)),Ay=(e,t,n)=>{e.type.unit===$g.DAY?Ty(e,t,n):Ey(e,t,n)},jy=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},My=({values:e},t,n)=>{e[t]=BigInt(n)},Ny=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},Py=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},Fy=(e,t,n)=>{switch(e.type.unit){case e_.SECOND:return jy(e,t,n);case e_.MILLISECOND:return My(e,t,n);case e_.MICROSECOND:return Ny(e,t,n);case e_.NANOSECOND:return Py(e,t,n)}},Iy=({values:e},t,n)=>{e[t]=n},Ly=({values:e},t,n)=>{e[t]=n},Ry=({values:e},t,n)=>{e[t]=n},zy=({values:e},t,n)=>{e[t]=n},By=(e,t,n)=>{switch(e.type.unit){case e_.SECOND:return Iy(e,t,n);case e_.MILLISECOND:return Ly(e,t,n);case e_.MICROSECOND:return Ry(e,t,n);case e_.NANOSECOND:return zy(e,t,n)}},Vy=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},Hy=(e,t,n)=>{let r=e.children[0],i=e.valueOffsets,a=cb.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=cb.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},Wy=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[a]),Gy=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(a)),Ky=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(i.name)),qy=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[i.name]),Jy=(e,t,n)=>{let r=e.type.children.map(e=>cb.getVisitFn(e.type)),i=n instanceof Map?Ky(t,n):n instanceof oS?Gy(t,n):Array.isArray(n)?Wy(t,n):qy(t,n);e.type.children.forEach((t,n)=>i(r[n],e.children[n],t,n))},Yy=(e,t,n)=>{e.type.mode===Zg.Dense?Xy(e,t,n):Zy(e,t,n)},Xy=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];cb.visit(i,e.valueOffsets[t],n)},Zy=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];cb.visit(i,t,n)},Qy=(e,t,n)=>{var r;(r=e.dictionary)==null||r.set(e.values[t],n)},$y=(e,t,n)=>{e.type.unit===t_.DAY_TIME?eb(e,t,n):tb(e,t,n)},eb=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},tb=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},nb=({values:e},t,n)=>{e[t]=n},rb=({values:e},t,n)=>{e[t]=n},ib=({values:e},t,n)=>{e[t]=n},ab=({values:e},t,n)=>{e[t]=n},ob=(e,t,n)=>{switch(e.type.unit){case e_.SECOND:return nb(e,t,n);case e_.MILLISECOND:return rb(e,t,n);case e_.MICROSECOND:return ib(e,t,n);case e_.NANOSECOND:return ab(e,t,n)}},sb=(e,t,n)=>{let{stride:r}=e,i=e.children[0],a=cb.getVisitFn(i);if(Array.isArray(n))for(let e=-1,o=t*r;++e`${G_(e)}: ${G_(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}[Symbol.iterator](){return new fb(this[lb],this[ub])}},fb=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[lb].type.children.findIndex(e=>e.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[lb].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[lb].type.children.findIndex(e=>e.name===t);if(n!==-1){let r=ix.visit(e[lb].children[n],e[ub]);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[lb].type.children.findIndex(e=>e.name===t);return r===-1?Reflect.has(e,t)||typeof t==`symbol`?Reflect.set(e,t,n):!1:(cb.visit(e[lb].children[r],e[ub],n),Reflect.set(e,t,n))}},mb=class extends cy{};function hb(e){return(t,n)=>t.getValid(n)?e(t,n):null}const gb=(e,t)=>864e5*e[t],_b=(e,t)=>null,vb=(e,t,n)=>{if(n+1>=t.length)return null;let r=K_(t[n]),i=K_(t[n+1]);return e.subarray(r,i)},yb=({offset:e,values:t},n)=>{let r=e+n,i=t[r>>3];return(i&1<gb(e,t),xb=({values:e},t)=>K_(e[t]),Sb=({stride:e,values:t},n)=>t[e*n],Cb=({stride:e,values:t},n)=>my(t[e*n]),wb=({values:e},t)=>e[t],Tb=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),Eb=({values:e,valueOffsets:t},n)=>vb(e,t,n),Db=({values:e,valueOffsets:t},n)=>{let r=vb(e,t,n);return r===null?null:sg(r)},Ob=({values:e},t)=>e[t],kb=({type:e,values:t},n)=>e.precision===Qg.HALF?my(t[n]):t[n],Ab=(e,t)=>e.type.unit===$g.DAY?bb(e,t):xb(e,t),jb=({values:e},t)=>1e3*K_(e[t]),Mb=({values:e},t)=>K_(e[t]),Nb=({values:e},t)=>q_(e[t],BigInt(1e3)),Pb=({values:e},t)=>q_(e[t],BigInt(1e6)),Fb=(e,t)=>{switch(e.type.unit){case e_.SECOND:return jb(e,t);case e_.MILLISECOND:return Mb(e,t);case e_.MICROSECOND:return Nb(e,t);case e_.NANOSECOND:return Pb(e,t)}},Ib=({values:e},t)=>e[t],Lb=({values:e},t)=>e[t],Rb=({values:e},t)=>e[t],zb=({values:e},t)=>e[t],Bb=(e,t)=>{switch(e.type.unit){case e_.SECOND:return Ib(e,t);case e_.MILLISECOND:return Lb(e,t);case e_.MICROSECOND:return Rb(e,t);case e_.NANOSECOND:return zb(e,t)}},Vb=({values:e,stride:t},n)=>av.decimal(e.subarray(t*n,t*(n+1))),Hb=(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 oS([c])},Ub=(e,t)=>{let{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:a}=n,o=r[0];return new lx(o.slice(i,a-i))},Wb=(e,t)=>new db(e,t),Gb=(e,t)=>e.type.mode===Zg.Dense?Kb(e,t):qb(e,t),Kb=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return ix.visit(r,e.valueOffsets[t])},qb=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return ix.visit(r,t)},Jb=(e,t)=>{var n;return(n=e.dictionary)?.get(e.values[t])},Yb=(e,t)=>e.type.unit===t_.DAY_TIME?Xb(e,t):Zb(e,t),Xb=({values:e},t)=>e.subarray(2*t,2*(t+1)),Zb=({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},Qb=({values:e},t)=>e[t],$b=({values:e},t)=>e[t],ex=({values:e},t)=>e[t],tx=({values:e},t)=>e[t],nx=(e,t)=>{switch(e.type.unit){case e_.SECOND:return Qb(e,t);case e_.MILLISECOND:return $b(e,t);case e_.MICROSECOND:return ex(e,t);case e_.NANOSECOND:return tx(e,t)}},rx=(e,t)=>{let{stride:n,children:r}=e,i=r[0],a=i.slice(t*n,n);return new oS([a])};mb.prototype.visitNull=hb(_b),mb.prototype.visitBool=hb(yb),mb.prototype.visitInt=hb(Ob),mb.prototype.visitInt8=hb(Sb),mb.prototype.visitInt16=hb(Sb),mb.prototype.visitInt32=hb(Sb),mb.prototype.visitInt64=hb(wb),mb.prototype.visitUint8=hb(Sb),mb.prototype.visitUint16=hb(Sb),mb.prototype.visitUint32=hb(Sb),mb.prototype.visitUint64=hb(wb),mb.prototype.visitFloat=hb(kb),mb.prototype.visitFloat16=hb(Cb),mb.prototype.visitFloat32=hb(Sb),mb.prototype.visitFloat64=hb(Sb),mb.prototype.visitUtf8=hb(Db),mb.prototype.visitLargeUtf8=hb(Db),mb.prototype.visitBinary=hb(Eb),mb.prototype.visitLargeBinary=hb(Eb),mb.prototype.visitFixedSizeBinary=hb(Tb),mb.prototype.visitDate=hb(Ab),mb.prototype.visitDateDay=hb(bb),mb.prototype.visitDateMillisecond=hb(xb),mb.prototype.visitTimestamp=hb(Fb),mb.prototype.visitTimestampSecond=hb(jb),mb.prototype.visitTimestampMillisecond=hb(Mb),mb.prototype.visitTimestampMicrosecond=hb(Nb),mb.prototype.visitTimestampNanosecond=hb(Pb),mb.prototype.visitTime=hb(Bb),mb.prototype.visitTimeSecond=hb(Ib),mb.prototype.visitTimeMillisecond=hb(Lb),mb.prototype.visitTimeMicrosecond=hb(Rb),mb.prototype.visitTimeNanosecond=hb(zb),mb.prototype.visitDecimal=hb(Vb),mb.prototype.visitList=hb(Hb),mb.prototype.visitStruct=hb(Wb),mb.prototype.visitUnion=hb(Gb),mb.prototype.visitDenseUnion=hb(Kb),mb.prototype.visitSparseUnion=hb(qb),mb.prototype.visitDictionary=hb(Jb),mb.prototype.visitInterval=hb(Yb),mb.prototype.visitIntervalDayTime=hb(Xb),mb.prototype.visitIntervalYearMonth=hb(Zb),mb.prototype.visitDuration=hb(nx),mb.prototype.visitDurationSecond=hb(Qb),mb.prototype.visitDurationMillisecond=hb($b),mb.prototype.visitDurationMicrosecond=hb(ex),mb.prototype.visitDurationNanosecond=hb(tx),mb.prototype.visitFixedSizeList=hb(rx),mb.prototype.visitMap=hb(Ub);const ix=new mb,ax=Symbol.for(`keys`),ox=Symbol.for(`vals`),sx=Symbol.for(`kKeysAsStrings`),cx=Symbol.for(`_kKeysAsStrings`);var lx=class{constructor(e){return this[ax]=new oS([e.children[0]]).memoize(),this[ox]=e.children[1],new Proxy(this,new dx)}get[sx](){return this[cx]||(this[cx]=Array.from(this[ax].toArray(),String))}[Symbol.iterator](){return new ux(this[ax],this[ox])}get size(){return this[ax].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[ax],t=this[ox],n={};for(let r=-1,i=e.length;++r`${G_(e)}: ${G_(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}},ux=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),ix.visit(this.vals,e)]})}},dx=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[sx]}has(e,t){return e[sx].includes(t)}getOwnPropertyDescriptor(e,t){let n=e[sx].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[sx].indexOf(t);if(n!==-1){let r=ix.visit(Reflect.get(e,ox),n);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[sx].indexOf(t);return r===-1?Reflect.has(e,t)?Reflect.set(e,t,n):!1:(cb.visit(Reflect.get(e,ox),r,n),Reflect.set(e,t,n))}};Object.defineProperties(lx.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[ax]:{writable:!0,enumerable:!1,configurable:!1,value:null},[ox]:{writable:!0,enumerable:!1,configurable:!1,value:null},[cx]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let fx;function px(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 mx=(e,t)=>e<0?t+e:e,hx=e=>e!==e;function gx(e){let t=typeof e;if(t!==`object`||e===null)return hx(e)?hx: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?Vg(e,t):!1:e instanceof Map?vx(e):Array.isArray(e)?_x(e):e instanceof oS?yx(e):bx(e,!0)}function _x(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 Sx(e,n);case Map:return wx(e,n,n.keys());case lx:case db:case Object:case void 0:return wx(e,n,t||Object.keys(n))}return n instanceof oS?Cx(e,n):!1}}function Sx(e,t){let n=e.length;if(t.length!==n)return!1;for(let r=-1;++r>r}function Dx(e,t,n){let r=n.byteLength+7&-8;if(e>0||n.byteLength>3):Ox(new kx(n,e,t,null,Tx)).subarray(0,r)),i}return n}function Ox(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 kx=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 Ax(e,t,i)+Ax(e,r,n)+jx(e,i>>3,r-i>>3)}function jx(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+=Mx(a.getUint32(i)),i+=4;for(;o-i>=2;)r+=Mx(a.getUint16(i)),i+=2;for(;o-i>=1;)r+=Mx(a.getUint8(i)),i+=1;return r}function Mx(e){let t=Math.trunc(e);return t-=t>>>1&1431655765,t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var Nx=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 U.isSparseUnion(e)||U.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(U.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-Ax(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=sy(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(U.isUnion(t)){let n=t,r=this.children[n.typeIdToChildIndex[this.typeIds[e]]],i=n.mode===Zg.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(Dx(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===H.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(Dx(this.offset,t,this.nullBitmap),0);let i=this.buffers;return i[W_.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[W_.TYPE])&&(a[W_.TYPE]=i.subarray(e,e+t)),(i=a[W_.OFFSET])&&(a[W_.OFFSET]=i.subarray(e,e+t+1))||(i=a[W_.DATA])&&(a[W_.DATA]=r===6?i:i.subarray(n*e,n*(e+t))),a}_sliceChildren(e,t,n){return e.map(e=>e.slice(t,n))}};Nx.prototype.children=Object.freeze([]);var Px=class e extends cy{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{type:t,offset:n=0,length:r=0}=e;return new Nx(t,n,r,r)}visitBool(e){let{type:t,offset:n=0}=e,r=Pg(e.nullBitmap),i=jg(t.ArrayType,e.data),{length:a=i.length>>3,nullCount:o=e.nullBitmap?-1:0}=e;return new Nx(t,n,a,o,[void 0,i,r])}visitInt(e){let{type:t,offset:n=0}=e,r=Pg(e.nullBitmap),i=jg(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new Nx(t,n,a,o,[void 0,i,r])}visitFloat(e){let{type:t,offset:n=0}=e,r=Pg(e.nullBitmap),i=jg(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new Nx(t,n,a,o,[void 0,i,r])}visitUtf8(e){let{type:t,offset:n=0}=e,r=Pg(e.data),i=Pg(e.nullBitmap),a=Mg(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new Nx(t,n,o,s,[a,r,i])}visitLargeUtf8(e){let{type:t,offset:n=0}=e,r=Pg(e.data),i=Pg(e.nullBitmap),a=Ng(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new Nx(t,n,o,s,[a,r,i])}visitBinary(e){let{type:t,offset:n=0}=e,r=Pg(e.data),i=Pg(e.nullBitmap),a=Mg(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new Nx(t,n,o,s,[a,r,i])}visitLargeBinary(e){let{type:t,offset:n=0}=e,r=Pg(e.data),i=Pg(e.nullBitmap),a=Ng(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new Nx(t,n,o,s,[a,r,i])}visitFixedSizeBinary(e){let{type:t,offset:n=0}=e,r=Pg(e.nullBitmap),i=jg(t.ArrayType,e.data),{length:a=i.length/sy(t),nullCount:o=e.nullBitmap?-1:0}=e;return new Nx(t,n,a,o,[void 0,i,r])}visitDate(e){let{type:t,offset:n=0}=e,r=Pg(e.nullBitmap),i=jg(t.ArrayType,e.data),{length:a=i.length/sy(t),nullCount:o=e.nullBitmap?-1:0}=e;return new Nx(t,n,a,o,[void 0,i,r])}visitTimestamp(e){let{type:t,offset:n=0}=e,r=Pg(e.nullBitmap),i=jg(t.ArrayType,e.data),{length:a=i.length/sy(t),nullCount:o=e.nullBitmap?-1:0}=e;return new Nx(t,n,a,o,[void 0,i,r])}visitTime(e){let{type:t,offset:n=0}=e,r=Pg(e.nullBitmap),i=jg(t.ArrayType,e.data),{length:a=i.length/sy(t),nullCount:o=e.nullBitmap?-1:0}=e;return new Nx(t,n,a,o,[void 0,i,r])}visitDecimal(e){let{type:t,offset:n=0}=e,r=Pg(e.nullBitmap),i=jg(t.ArrayType,e.data),{length:a=i.length/sy(t),nullCount:o=e.nullBitmap?-1:0}=e;return new Nx(t,n,a,o,[void 0,i,r])}visitList(e){let{type:t,offset:n=0,child:r}=e,i=Pg(e.nullBitmap),a=Mg(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new Nx(t,n,o,s,[a,void 0,i],[r])}visitStruct(e){let{type:t,offset:n=0,children:r=[]}=e,i=Pg(e.nullBitmap),{length:a=r.reduce((e,{length:t})=>Math.max(e,t),0),nullCount:o=e.nullBitmap?-1:0}=e;return new Nx(t,n,a,o,[void 0,void 0,i],r)}visitUnion(e){let{type:t,offset:n=0,children:r=[]}=e,i=jg(t.ArrayType,e.typeIds),{length:a=i.length,nullCount:o=-1}=e;if(U.isSparseUnion(t))return new Nx(t,n,a,o,[void 0,void 0,void 0,i],r);let s=Mg(e.valueOffsets);return new Nx(t,n,a,o,[s,void 0,void 0,i],r)}visitDictionary(t){let{type:n,offset:r=0}=t,i=Pg(t.nullBitmap),a=jg(n.indices.ArrayType,t.data),{dictionary:o=new oS([new e().visit({type:n.dictionary})])}=t,{length:s=a.length,nullCount:c=t.nullBitmap?-1:0}=t;return new Nx(n,r,s,c,[void 0,a,i],[],o)}visitInterval(e){let{type:t,offset:n=0}=e,r=Pg(e.nullBitmap),i=jg(t.ArrayType,e.data),{length:a=i.length/sy(t),nullCount:o=e.nullBitmap?-1:0}=e;return new Nx(t,n,a,o,[void 0,i,r])}visitDuration(e){let{type:t,offset:n=0}=e,r=Pg(e.nullBitmap),i=jg(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new Nx(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=Pg(t.nullBitmap),{length:o=i.length/sy(n),nullCount:s=t.nullBitmap?-1:0}=t;return new Nx(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=Pg(t.nullBitmap),o=Mg(t.valueOffsets),{length:s=o.length-1,nullCount:c=t.nullBitmap?-1:0}=t;return new Nx(n,r,s,c,[o,void 0,a],[i])}};const Fx=new Px;function Ix(e){return Fx.visit(e)}var Lx=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 zx(e){return e.reduce((e,t)=>e+t.nullCount,0)}function Bx(e){return e.reduce((e,t,n)=>(e[n+1]=e[n]+t.length,e),new Uint32Array(e.length+1))}function Vx(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 Hx(e,t,n,r){let i=0,a=0,o=t.length-1;do{if(i>=o-1)return n0?0:-1}function Yx(e,t){let{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(let i of new kx(n,e.offset+(t||0),e.length,n,Tx)){if(!i)return r;++r}return-1}function Xx(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case H.Union:break;case H.Dictionary:break;default:return Yx(e,n)}let r=ix.getVisitFn(e),i=gx(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 Lx(e.data.length,t=>{let r=e.data[t],i=r.length,a=e.slice(n,n+i);return n+=i,new tS(a)})}var tS=class{constructor(e){this.vector=e,this.index=0}next(){return this.indexe.data):t;if(a.length===0||a.some(e=>!(e instanceof Nx)))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}=iS[o.typeId],r=a[0];this.isValid=e=>Ux(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,aS[o.typeId]),this._offsets=Bx(a);break}this.data=a,this.type=o,this.stride=sy(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 Rx(this.data)}get nullCount(){return zx(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${H[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(mx(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return nS.visit(this)}concat(...t){return new e(this.data.concat(t.flatMap(e=>e.data).flat(1/0)))}slice(t,n){return new e(px(this,t,n,({data:e,_offsets:t},n,r)=>Vx(e,t,n,r)))}toJSON(){return[...this]}toArray(){let{type:e,data:t,length:n,stride:r,ArrayType:i}=this;switch(e.typeId){case H.Int:case H.Float:case H.Decimal:case H.Time:case H.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 U.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(U.isDictionary(this.type)){let t=new sS(this.data[0].dictionary),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return new sS(this)}unmemoize(){if(U.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}};rS=Symbol.toStringTag,oS[rS]=(e=>{e.type=U.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(H).map(e=>H[e]).filter(e=>typeof e==`number`&&e!==H.NONE);for(let n of t){let t=ix.getVisitFnByTypeId(n),r=cb.getVisitFnByTypeId(n),i=Qx.getVisitFnByTypeId(n);iS[n]={get:t,set:r,indexOf:i},aS[n]=Object.create(e,{isValid:{value:Wx(Ux)},get:{value:Wx(ix.getVisitFnByTypeId(n))},set:{value:Gx(cb.getVisitFnByTypeId(n))},indexOf:{value:Kx(Qx.getVisitFnByTypeId(n))}})}return`Vector`})(oS.prototype);var sS=class e extends oS{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 oS(this.data)}),Object.defineProperty(this,`memoize`,{value:()=>this})}},cS=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()}},lS=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):Xg.V1}schema(e){let t=this.bb.__offset(this.bb_pos,6);return t?(e||new H_).__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 cS).__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 cS).__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 b_).__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,Xg.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)}},uS=class e{constructor(e=[],t,n,r=Xg.V5){this.fields=e||[],this.metadata=t||new Map,n||=pS(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=fS(fS(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:fS(fS(new Map,r[t].metadata),e.metadata)}))&&!1:!0}),o=pS(a,new Map);return new e([...r,...a],i,new Map([...this.dictionaries,...o]))}};uS.prototype.fields=null,uS.prototype.metadata=null,uS.prototype.dictionaries=null;var dS=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)}};dS.prototype.type=null,dS.prototype.name=null,dS.prototype.nullable=null,dS.prototype.metadata=null;function fS(e,t){return new Map([...e||new Map,...t||new Map])}function pS(e,t=new Map){for(let n=-1,r=e.length;++n0&&pS(i.children,t)}return t}var mS=c_,hS=s_,gS=class{static decode(e){e=new hS(Pg(e));let t=lS.getRootAsFooter(e),n=uS.decode(t.schema(),new Map,t.version());return new _S(n,t)}static encode(e){let t=new mS,n=uS.encode(t,e.schema);lS.startRecordBatchesVector(t,e.numRecordBatches);for(let n of[...e.recordBatches()].slice().reverse())vS.encode(t,n);let r=t.endVector();lS.startDictionariesVector(t,e.numDictionaries);for(let n of[...e.dictionaryBatches()].slice().reverse())vS.encode(t,n);let i=t.endVector();return lS.startFooter(t),lS.addSchema(t,n),lS.addVersion(t,Xg.V5),lS.addRecordBatches(t,r),lS.addDictionaries(t,i),lS.finishFooterBuffer(t,lS.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=Xg.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 tg(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(yS);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return Hg.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return Hg.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return tg(this,void 0,void 0,function*(){return yield this.abort(e),yS})}return(e){return tg(this,void 0,void 0,function*(){return yield this.close(),yS})}read(e){return tg(this,void 0,void 0,function*(){return(yield this.next(e,`read`)).value})}peek(e){return tg(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(yS)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw Error(`AsyncQueue is closed`)}},CS=class extends SS{write(e){if((e=Pg(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?sg(this.toUint8Array(!0)):this.toUint8Array(!1).then(sg)}toUint8Array(e=!1){return e?Ag(this._values)[0]:(()=>tg(this,void 0,void 0,function*(){var e,t,n,r;let i=[],a=0;try{for(var o=!0,s=ag(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 Ag(i,a)[0]}))()}},wS=class{constructor(e){e&&(this.source=new ES(Hg.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)}},TS=class e{constructor(t){t instanceof e?this.source=t.source:t instanceof CS?this.source=new DS(Hg.fromAsyncIterable(t)):Tg(t)?this.source=new DS(Hg.fromNodeStream(t)):Cg(t)?this.source=new DS(Hg.fromDOMStream(t)):bg(t)?this.source=new DS(Hg.fromDOMStream(t.body)):hg(t)?this.source=new DS(Hg.fromIterable(t)):(mg(t)||gg(t))&&(this.source=new DS(Hg.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)}},ES=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)||yS)}return(e){return Object.create(this.source.return&&this.source.return(e)||yS)}},DS=class{constructor(e){this.source=e,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(e){return tg(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return tg(this,void 0,void 0,function*(){return(yield this.next(e,`read`)).value})}peek(e){return tg(this,void 0,void 0,function*(){return(yield this.next(e,`peek`)).value})}next(e){return tg(this,arguments,void 0,function*(e,t=`read`){return yield this.source.next({cmd:t,size:e})})}throw(e){return tg(this,void 0,void 0,function*(){let t=this.source.throw&&(yield this.source.throw(e))||yS;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return tg(this,void 0,void 0,function*(){let t=this.source.return&&(yield this.source.return(e))||yS;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}},OS=class extends wS{constructor(e,t){super(),this.position=0,this.buffer=Pg(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),etg(this,void 0,void 0,function*(){this.size=(yield e.stat()).size,delete this._pending}))()}readInt32(e){return tg(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 tg(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`${AS(this.buffer[3])} ${AS(this.buffer[2])} ${AS(this.buffer[1])} ${AS(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)}},LS=class extends IS{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:Ox(this.sources[n])}readOffsets(e,{offset:t}=this.nextBufferRange()){return jg(Uint8Array,jg(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return jg(Uint8Array,jg(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){let{sources:n}=this;return U.isTimestamp(e)||(U.isInt(e)||U.isTime(e))&&e.bitWidth===64||U.isDuration(e)||U.isDate(e)&&e.unit===$g.MILLISECOND?jg(Uint8Array,PS.convertArray(n[t])):U.isDecimal(e)?jg(Uint8Array,FS.convertArray(n[t])):U.isBinary(e)||U.isLargeBinary(e)||U.isFixedSizeBinary(e)?RS(n[t]):U.isBool(e)?Ox(n[t]):U.isUtf8(e)||U.isLargeUtf8(e)?lg(n[t].join(``)):jg(Uint8Array,jg(e.ArrayType,n[t].map(e=>+e)))}};function RS(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 zS=class extends cy{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 BS(e,t){return t instanceof e.constructor}function VS(e,t){return e===t||BS(e,t)}function HS(e,t){return e===t||BS(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function US(e,t){return e===t||BS(e,t)&&e.precision===t.precision}function WS(e,t){return e===t||BS(e,t)&&e.byteWidth===t.byteWidth}function GS(e,t){return e===t||BS(e,t)&&e.unit===t.unit}function KS(e,t){return e===t||BS(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function qS(e,t){return e===t||BS(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function JS(e,t){return e===t||BS(e,t)&&e.children.length===t.children.length&&nC.compareManyFields(e.children,t.children)}function YS(e,t){return e===t||BS(e,t)&&e.children.length===t.children.length&&nC.compareManyFields(e.children,t.children)}function XS(e,t){return e===t||BS(e,t)&&e.mode===t.mode&&e.typeIds.every((e,n)=>e===t.typeIds[n])&&nC.compareManyFields(e.children,t.children)}function ZS(e,t){return e===t||BS(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&nC.visit(e.indices,t.indices)&&nC.visit(e.dictionary,t.dictionary)}function QS(e,t){return e===t||BS(e,t)&&e.unit===t.unit}function $S(e,t){return e===t||BS(e,t)&&e.unit===t.unit}function eC(e,t){return e===t||BS(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&nC.compareManyFields(e.children,t.children)}function tC(e,t){return e===t||BS(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&nC.compareManyFields(e.children,t.children)}zS.prototype.visitNull=VS,zS.prototype.visitBool=VS,zS.prototype.visitInt=HS,zS.prototype.visitInt8=HS,zS.prototype.visitInt16=HS,zS.prototype.visitInt32=HS,zS.prototype.visitInt64=HS,zS.prototype.visitUint8=HS,zS.prototype.visitUint16=HS,zS.prototype.visitUint32=HS,zS.prototype.visitUint64=HS,zS.prototype.visitFloat=US,zS.prototype.visitFloat16=US,zS.prototype.visitFloat32=US,zS.prototype.visitFloat64=US,zS.prototype.visitUtf8=VS,zS.prototype.visitLargeUtf8=VS,zS.prototype.visitBinary=VS,zS.prototype.visitLargeBinary=VS,zS.prototype.visitFixedSizeBinary=WS,zS.prototype.visitDate=GS,zS.prototype.visitDateDay=GS,zS.prototype.visitDateMillisecond=GS,zS.prototype.visitTimestamp=KS,zS.prototype.visitTimestampSecond=KS,zS.prototype.visitTimestampMillisecond=KS,zS.prototype.visitTimestampMicrosecond=KS,zS.prototype.visitTimestampNanosecond=KS,zS.prototype.visitTime=qS,zS.prototype.visitTimeSecond=qS,zS.prototype.visitTimeMillisecond=qS,zS.prototype.visitTimeMicrosecond=qS,zS.prototype.visitTimeNanosecond=qS,zS.prototype.visitDecimal=VS,zS.prototype.visitList=JS,zS.prototype.visitStruct=YS,zS.prototype.visitUnion=XS,zS.prototype.visitDenseUnion=XS,zS.prototype.visitSparseUnion=XS,zS.prototype.visitDictionary=ZS,zS.prototype.visitInterval=QS,zS.prototype.visitIntervalDayTime=QS,zS.prototype.visitIntervalYearMonth=QS,zS.prototype.visitDuration=$S,zS.prototype.visitDurationSecond=$S,zS.prototype.visitDurationMillisecond=$S,zS.prototype.visitDurationMicrosecond=$S,zS.prototype.visitDurationNanosecond=$S,zS.prototype.visitFixedSizeList=eC,zS.prototype.visitMap=tC;const nC=new zS;function rC(e,t){return nC.compareSchemas(e,t)}function iC(e,t){return aC(e,t.map(e=>e.data.concat()))}function aC(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++]=Ix({type:new ey(n),length:o,nullCount:0,children:u.slice()})))}return[e=e.assign(n),r.map(t=>new uC(e,t))]}function oC(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))??Ix({type:r.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return n}var sC,cC=class e{constructor(...t){var n,r;if(t.length===0)return this.batches=[],this.schema=new uS([]),this._offsets=[0],this;let i,a;t[0]instanceof uS&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(a=t.pop());let o=t=>{if(t){if(t instanceof uC)return[t];if(t instanceof e)return t.batches;if(t instanceof Nx){if(t.type instanceof ey)return[new uC(new uS(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 oS([t[e]])),r=i??new uS(e.map((e,t)=>new dS(String(e),n[t].type,n[t].nullable))),[,a]=iC(r,n);return a.length===0?[new uC(t)]:a}}return[]},s=t.flatMap(e=>o(e));if(i=(r=i??(n=s[0])?.schema)??new uS([]),!(i instanceof uS))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);for(let e of s){if(!(e instanceof uC))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);if(!rC(i,e.schema))throw TypeError(`Table and inner RecordBatch schemas must be equivalent.`)}this.schema=i,this.batches=s,this._offsets=a??Bx(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=zx(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(mx(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?nS.visit(new oS(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 uC(n,e)))}slice(t,n){let r=this.schema;[t,n]=px({length:this.numRows},t,n);let i=Vx(this.data,this._offsets,t,n);return new e(r,i.map(e=>new uC(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=Ix({type:n,length:0,nullCount:0});t.push(r._changeLengthAndBackfillNullBitmap(this.numRows))}return new oS(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]=iC(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(...iC(a,o))}};sC=Symbol.toStringTag,cC[sC]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=Wx(Ux),e.get=Wx(ix.getVisitFn(H.Struct)),e.set=Gx(cb.getVisitFn(H.Struct)),e.indexOf=Kx(Qx.getVisitFn(H.Struct)),`Table`))(cC.prototype);var lC,uC=class e{constructor(...e){switch(e.length){case 2:if([this.schema]=e,!(this.schema instanceof uS)||([,this.data=Ix({nullCount:0,type:new ey(this.schema.fields),children:this.schema.fields.map(e=>Ix({type:e.type,nullCount:0}))})]=e,!(this.data instanceof Nx)))throw TypeError(`RecordBatch constructor expects a [Schema, Data] pair.`);[this.schema,this.data]=dC(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]=dS.new({name:n,type:t[n].type,nullable:!0}),e),{length:0,fields:[],children:[]}),a=new uS(n),o=Ix({type:new ey(n),length:i,children:r,nullCount:0});[this.schema,this.data]=dC(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||=fC(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 ix.visit(this.data,e)}at(e){return this.get(mx(e,this.numRows))}set(e,t){return cb.visit(this.data,e,t)}indexOf(e,t){return Qx.visit(this.data,e,t)}[Symbol.iterator](){return nS.visit(new oS([this.data]))}toArray(){return[...this]}concat(...e){return new cC(this.schema,[this,...e])}slice(t,n){let[r]=new oS([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,Ix({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=Ix({type:new ey(n.fields),length:this.numRows,children:r});return new e(n,i)}};lC=Symbol.toStringTag,uC[lC]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,`RecordBatch`))(uC.prototype);function dC(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))??Ix({type:c.type,length:n,nullCount:n,nullBitmap:new Uint8Array(o)}))}return[e.assign(i),Ix({type:new ey(i),length:n,children:a})]}function fC(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;++rIx({type:e.type})),n=Ix({type:new ey(e.fields),nullCount:0,children:t});super(e,n)}},mC=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):Xg.V1}headerType(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):U_.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 b_).__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,Xg.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,U_.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)}},hC=class extends cy{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return P_.startNull(t),P_.endNull(t)}visitInt(e,t){return v_.startInt(t),v_.addBitWidth(t,e.bitWidth),v_.addIsSigned(t,e.isSigned),v_.endInt(t)}visitFloat(e,t){return O_.startFloatingPoint(t),O_.addPrecision(t,e.precision),O_.endFloatingPoint(t)}visitBinary(e,t){return x_.startBinary(t),x_.endBinary(t)}visitLargeBinary(e,t){return A_.startLargeBinary(t),A_.endLargeBinary(t)}visitBool(e,t){return S_.startBool(t),S_.endBool(t)}visitUtf8(e,t){return z_.startUtf8(t),z_.endUtf8(t)}visitLargeUtf8(e,t){return j_.startLargeUtf8(t),j_.endLargeUtf8(t)}visitDecimal(e,t){return w_.startDecimal(t),w_.addScale(t,e.scale),w_.addPrecision(t,e.precision),w_.addBitWidth(t,e.bitWidth),w_.endDecimal(t)}visitDate(e,t){return C_.startDate(t),C_.addUnit(t,e.unit),C_.endDate(t)}visitTime(e,t){return I_.startTime(t),I_.addUnit(t,e.unit),I_.addBitWidth(t,e.bitWidth),I_.endTime(t)}visitTimestamp(e,t){let n=e.timezone&&t.createString(e.timezone)||void 0;return L_.startTimestamp(t),L_.addUnit(t,e.unit),n!==void 0&&L_.addTimezone(t,n),L_.endTimestamp(t)}visitInterval(e,t){return k_.startInterval(t),k_.addUnit(t,e.unit),k_.endInterval(t)}visitDuration(e,t){return T_.startDuration(t),T_.addUnit(t,e.unit),T_.endDuration(t)}visitList(e,t){return M_.startList(t),M_.endList(t)}visitStruct(e,t){return F_.startStruct_(t),F_.endStruct_(t)}visitUnion(e,t){R_.startTypeIdsVector(t,e.typeIds.length);let n=R_.createTypeIdsVector(t,e.typeIds);return R_.startUnion(t),R_.addMode(t,e.mode),R_.addTypeIds(t,n),R_.endUnion(t)}visitDictionary(e,t){let n=this.visit(e.indices,t);return y_.startDictionaryEncoding(t),y_.addId(t,BigInt(e.id)),y_.addIsOrdered(t,e.isOrdered),n!==void 0&&y_.addIndexType(t,n),y_.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return E_.startFixedSizeBinary(t),E_.addByteWidth(t,e.byteWidth),E_.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return D_.startFixedSizeList(t),D_.addListSize(t,e.listSize),D_.endFixedSizeList(t)}visitMap(e,t){return N_.startMap(t),N_.addKeysSorted(t,e.keysSorted),N_.endMap(t)}};const gC=new hC;function _C(e,t=new Map){return new uS(bC(e,t),EC(e.metadata),t)}function vC(e){return new MC(e.count,SC(e.columns),CC(e.columns))}function yC(e){return new NC(vC(e.data),e.id,e.isDelta)}function bC(e,t){return(e.fields||[]).filter(Boolean).map(e=>dS.fromJSON(e,t))}function xC(e,t){return(e.children||[]).filter(Boolean).map(e=>dS.fromJSON(e,t))}function SC(e){return(e||[]).reduce((e,t)=>[...e,new FC(t.count,wC(t.VALIDITY)),...SC(t.children)],[])}function CC(e,t=[]){for(let n=-1,r=(e||[]).length;++ne+ +(t===0),0)}function TC(e,t){let n,r,i,a,o,s;return!t||!(a=e.dictionary)?(o=OC(e,xC(e,t)),i=new dS(e.name,o,e.nullable,EC(e.metadata))):t.has(n=a.id)?(r=(r=a.indexType)?DC(r):new Mv,s=new oy(t.get(n),r,n,a.isOrdered),i=new dS(e.name,s,e.nullable,EC(e.metadata))):(r=(r=a.indexType)?DC(r):new Mv,t.set(n,o=OC(e,xC(e,t))),s=new oy(o,r,n,a.isOrdered),i=new dS(e.name,s,e.nullable,EC(e.metadata))),i||null}function EC(e=[]){return new Map(e.map(({key:e,value:t})=>[e,t]))}function DC(e){return new kv(e.isSigned,e.bitWidth)}function OC(e,t){let n=e.type.name;switch(n){case`NONE`:return new Ov;case`null`:return new Ov;case`binary`:return new Hv;case`largebinary`:return new Uv;case`utf8`:return new Wv;case`largeutf8`:return new Gv;case`bool`:return new Kv;case`list`:return new $v((t||[])[0]);case`struct`:return new ey(t||[]);case`struct_`:return new ey(t||[])}switch(n){case`int`:{let t=e.type;return new kv(t.isSigned,t.bitWidth)}case`floatingpoint`:{let t=e.type;return new Rv(Qg[t.precision])}case`decimal`:{let t=e.type;return new qv(t.scale,t.precision,t.bitWidth)}case`date`:{let t=e.type;return new Jv($g[t.unit])}case`time`:{let t=e.type;return new Yv(e_[t.unit],t.bitWidth)}case`timestamp`:{let t=e.type;return new Xv(e_[t.unit],t.timezone)}case`interval`:{let t=e.type;return new Zv(t_[t.unit])}case`duration`:{let t=e.type;return new Qv(e_[t.unit])}case`union`:{let n=e.type,[r,...i]=(n.mode+``).toLowerCase(),a=r.toUpperCase()+i.join(``);return new ty(Zg[a],n.typeIds||[],t||[])}case`fixedsizebinary`:{let t=e.type;return new ny(t.byteWidth)}case`fixedsizelist`:{let n=e.type;return new ry(n.listSize,(t||[])[0])}case`map`:{let n=e.type;return new iy((t||[])[0],n.keysSorted)}}throw Error(`Unrecognized type: "${n}"`)}var kC=c_,AC=s_,jC=class e{static fromJSON(t,n){let r=new e(0,Xg.V5,n);return r._createHeader=IC(t,n),r}static decode(t){t=new AC(Pg(t));let n=mC.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),a=n.headerType(),o=new e(r,i,a);return o._createHeader=LC(n,a),o}static encode(e){let t=new kC,n=-1;return e.isSchema()?n=uS.encode(t,e.header()):e.isRecordBatch()?n=MC.encode(t,e.header()):e.isDictionaryBatch()&&(n=NC.encode(t,e.header())),mC.startMessage(t),mC.addVersion(t,Xg.V5),mC.addHeader(t,n),mC.addHeaderType(t,e.headerType),mC.addBodyLength(t,BigInt(e.bodyLength)),mC.finishMessageBuffer(t,mC.endMessage(t)),t.asUint8Array()}static from(t,n=0){if(t instanceof uS)return new e(0,Xg.V5,U_.Schema,t);if(t instanceof MC)return new e(n,Xg.V5,U_.RecordBatch,t);if(t instanceof NC)return new e(n,Xg.V5,U_.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===U_.Schema}isRecordBatch(){return this.headerType===U_.RecordBatch}isDictionaryBatch(){return this.headerType===U_.DictionaryBatch}constructor(e,t,n,r){this._version=t,this._headerType=n,this.body=new Uint8Array,r&&(this._createHeader=()=>r),this._bodyLength=K_(e)}},MC=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=K_(e)}},NC=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=K_(t)}},PC=class{constructor(e,t){this.offset=K_(e),this.length=K_(t)}},FC=class{constructor(e,t){this.length=K_(e),this.nullCount=K_(t)}};function IC(e,t){return(()=>{switch(t){case U_.Schema:return uS.fromJSON(e);case U_.RecordBatch:return MC.fromJSON(e);case U_.DictionaryBatch:return NC.fromJSON(e)}throw Error(`Unrecognized Message type: { name: ${U_[t]}, type: ${t} }`)})}function LC(e,t){return(()=>{switch(t){case U_.Schema:return uS.decode(e.header(new H_),new Map,e.version());case U_.RecordBatch:return MC.decode(e.header(new m_),e.version());case U_.DictionaryBatch:return NC.decode(e.header(new h_),e.version())}throw Error(`Unrecognized Message type: { name: ${U_[t]}, type: ${t} }`)})}dS.encode=QC,dS.decode=qC,dS.fromJSON=TC,uS.encode=ZC,uS.decode=RC,uS.fromJSON=_C,MC.encode=$C,MC.decode=zC,MC.fromJSON=vC,NC.encode=ew,NC.decode=BC,NC.fromJSON=yC,FC.encode=tw,FC.decode=HC,PC.encode=nw,PC.decode=VC;function RC(e,t=new Map,n=Xg.V5){let r=GC(e,t);return new uS(r,JC(e),t,n)}function zC(e,t=Xg.V5){if(e.compression()!==null)throw Error(`Record batch compression not implemented`);return new MC(e.length(),UC(e),WC(e,t))}function BC(e,t=Xg.V5){return new NC(MC.decode(e.data(),t),e.id(),e.isDelta())}function VC(e){return new PC(e.offset(),e.length())}function HC(e){return new FC(e.length(),e.nullCount())}function UC(e){let t=[];for(let n,r=-1,i=-1,a=e.nodesLength();++rdS.encode(e,t));H_.startFieldsVector(e,n.length);let r=H_.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?H_.createCustomMetadataVector(e,[...t.metadata].map(([t,n])=>{let r=e.createString(`${t}`),i=e.createString(`${n}`);return b_.startKeyValue(e),b_.addKey(e,r),b_.addValue(e,i),b_.endKeyValue(e)})):-1;return H_.startSchema(e),H_.addFields(e,r),H_.addEndianness(e,rw?g_.Little:g_.Big),i!==-1&&H_.addCustomMetadata(e,i),H_.endSchema(e)}function QC(e,t){let n=-1,r=-1,i=-1,a=t.type,o=t.typeId;U.isDictionary(a)?(o=a.dictionary.typeId,i=gC.visit(a,e),r=gC.visit(a.dictionary,e)):r=gC.visit(a,e);let s=(a.children||[]).map(t=>dS.encode(e,t)),c=V_.createChildrenVector(e,s),l=t.metadata&&t.metadata.size>0?V_.createCustomMetadataVector(e,[...t.metadata].map(([t,n])=>{let r=e.createString(`${t}`),i=e.createString(`${n}`);return b_.startKeyValue(e),b_.addKey(e,r),b_.addValue(e,i),b_.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),V_.startField(e),V_.addType(e,r),V_.addTypeType(e,o),V_.addChildren(e,c),V_.addNullable(e,!!t.nullable),n!==-1&&V_.addName(e,n),i!==-1&&V_.addDictionary(e,i),l!==-1&&V_.addCustomMetadata(e,l),V_.endField(e)}function $C(e,t){let n=t.nodes||[],r=t.buffers||[];m_.startNodesVector(e,n.length);for(let t of n.slice().reverse())FC.encode(e,t);let i=e.endVector();m_.startBuffersVector(e,r.length);for(let t of r.slice().reverse())PC.encode(e,t);let a=e.endVector();return m_.startRecordBatch(e),m_.addLength(e,BigInt(t.length)),m_.addNodes(e,i),m_.addBuffers(e,a),m_.endRecordBatch(e)}function ew(e,t){let n=MC.encode(e,t.data);return h_.startDictionaryBatch(e),h_.addId(e,BigInt(t.id)),h_.addIsDelta(e,t.isDelta),h_.addData(e,n),h_.endDictionaryBatch(e)}function tw(e,t){return p_.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function nw(e,t){return f_.createBuffer(e,BigInt(t.offset),BigInt(t.length))}const rw=(()=>{let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),iw=e=>`Expected ${U_[e]} Message in stream, but was null or length 0.`,aw=e=>`Header pointer of flatbuffer-encoded ${U_[e]} Message is null or length 0.`,ow=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,sw=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;var cw=class{constructor(e){this.source=e instanceof wS?e:new wS(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?yS: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(iw(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array;let t=Pg(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(iw(e));return t.value}readSchema(){let e=U_.Schema,t=this.readMessage(e),n=t?.header();if(!t||!n)throw Error(aw(e));return n}};const dw=4,fw=new Uint8Array(6);for(let e=0;e<6;e+=1)fw[e]=`ARROW1`.codePointAt(e);function pw(e,t=0){for(let n=-1,r=fw.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 Hg.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Hg.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:_g(t)?jw(t):yg(t)?Pw(t):mg(t)?(()=>tg(this,void 0,void 0,function*(){return yield e.from(yield t)}))():bg(t)||Cg(t)||Tg(t)||gg(t)?Nw(new TS(t)):Mw(new wS(t))}static readAll(t){return t instanceof e?t.isSync()?kw(t):Aw(t):_g(t)||ArrayBuffer.isView(t)||hg(t)||vg(t)?kw(t):Aw(t)}},vw=class extends _w{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return rg(this,arguments,function*(){yield V(yield*ig(ag(this[Symbol.iterator]())))})}},yw=class extends _w{constructor(e){super(e),this._impl=e}readAll(){return tg(this,void 0,void 0,function*(){var e,t,n,r;let i=[];try{for(var a=!0,o=ag(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]()}},bw=class extends vw{constructor(e){super(e),this._impl=e}},xw=class extends yw{constructor(e){super(e),this._impl=e}},Sw=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=Ix({type:new ey(this.schema.fields),length:e.length,children:n});return new uC(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 oS(c)):new oS(c)).memoize()}_loadVectors(e,t,n){return new IS(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},Cw=class extends Sw{constructor(e,t){super(t),this._reader=_g(e)?new uw(this._handle=e):new cw(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=Ow(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):yS}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):yS}next(){if(this.closed)return yS;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 pC(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}},ww=class extends Sw{constructor(e,t){super(t),this._reader=new lw(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return tg(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 tg(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Ow(this,e),(this.schema||=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return tg(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):yS})}return(e){return tg(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):yS})}next(){return tg(this,void 0,void 0,function*(){if(this.closed)return yS;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 pC(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return tg(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}},Tw=class extends Cw{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 OS?e:new OS(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(U_.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(U_.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-hw,n=e.readInt32(t),r=e.readAt(t-n,n);return gS.decode(r)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return tg(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 tg(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(U_.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 tg(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(U_.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 tg(this,void 0,void 0,function*(){let{_handle:e}=this;e._pending&&(yield e._pending);let t=e.size-hw,n=yield e.readInt32(t),r=yield e.readAt(t-n,n);return gS.decode(r)})}_readNextMessageAndValidate(e){return tg(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?pw(t)?new bw(new Tw(e.read())):new vw(new Cw(e)):new vw(new Cw(function*(){}()))}function Nw(e){return tg(this,void 0,void 0,function*(){let t=yield e.peek(mw+7&-8);return t&&t.byteLength>=4?pw(t)?new bw(new Tw(yield e.read())):new yw(new ww(e)):new yw(new ww(function(){return rg(this,arguments,function*(){})}()))})}function Pw(e){return tg(this,void 0,void 0,function*(){let{size:t}=yield e.stat(),n=new kS(e,t);return t>=gw&&pw(yield n.readAt(0,mw+7&-8))?new xw(new Ew(n)):new yw(new ww(n))})}var Fw=class e extends cy{static assemble(...t){let n=e=>e.flatMap(e=>Array.isArray(e)?n(e):e instanceof uC?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 oS)return this.visitMany(e.data),this;let{type:t}=e;if(!U.isDictionary(t)){let{length:n}=e;if(n>2147483647)throw RangeError(`Cannot write arrays larger than 2^31 - 1 in length`);if(U.isUnion(t))this.nodes.push(new FC(n,0));else{let{nullCount:r}=e;U.isNull(t)||Iw.call(this,r<=0?new Uint8Array:Dx(e.offset,n,e.nullBitmap)),this.nodes.push(new FC(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 Iw(e){let t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new PC(this._byteLength,t)),this._byteLength+=t,this}function Lw(e){var t;let{type:n,length:r,typeIds:i,valueOffsets:a}=e;if(Iw.call(this,i),n.mode===Zg.Sparse)return Hw.call(this,e);if(n.mode===Zg.Dense){if(e.offset<=0)return Iw.call(this,a),Hw.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 Rw(e){let t;return e.nullCount>=e.length?Iw.call(this,new Uint8Array):(t=e.values)instanceof Uint8Array?Iw.call(this,Dx(e.offset,e.length,t)):Iw.call(this,Ox(e.values))}function zw(e){return Iw.call(this,e.values.subarray(0,e.length*e.stride))}function Bw(e){let{length:t,values:n,valueOffsets:r}=e,i=K_(r[0]),a=K_(r[t]),o=Math.min(a-i,n.byteLength-i);return Iw.call(this,Bg(-i,t+1,r)),Iw.call(this,n.subarray(i,i+o)),this}function Vw(e){let{length:t,valueOffsets:n}=e;if(n){let{0:r,[t]:i}=n;return Iw.call(this,Bg(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function Hw(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}Fw.prototype.visitBool=Rw,Fw.prototype.visitInt=zw,Fw.prototype.visitFloat=zw,Fw.prototype.visitUtf8=Bw,Fw.prototype.visitLargeUtf8=Bw,Fw.prototype.visitBinary=Bw,Fw.prototype.visitLargeBinary=Bw,Fw.prototype.visitFixedSizeBinary=zw,Fw.prototype.visitDate=zw,Fw.prototype.visitTimestamp=zw,Fw.prototype.visitTime=zw,Fw.prototype.visitDecimal=zw,Fw.prototype.visitList=Vw,Fw.prototype.visitStruct=Hw,Fw.prototype.visitUnion=Lw,Fw.prototype.visitInterval=zw,Fw.prototype.visitDuration=zw,Fw.prototype.visitFixedSizeList=Vw,Fw.prototype.visitMap=Vw;var Uw=class extends xS{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 CS,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,pg(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 mg(e)?e.then(e=>this.writeAll(e)):gg(e)?qw(this,e):Kw(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 CS?this._sink=e:(this._sink=new CS,e&&Sg(e)?this.toDOMStream({type:`bytes`}).pipeTo(e):e&&wg(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||!rC(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 cC&&!(t=e.schema)||e instanceof uC&&!(t=e.schema))return this.finish()&&void 0}else throw Error(`RecordBatchWriter is closed`);if(t&&!rC(t,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,t)}e instanceof uC?e instanceof pC||this._writeRecordBatch(e):e instanceof cC?this.writeAll(e.batches):hg(e)&&this.writeAll(e)}_writeMessage(e,t=8){let n=t-1,r=jC.encode(e),i=r.byteLength,a=this._writeLegacyIpcFormat?4:8,o=i+a+n&~n,s=o-i-a;return e.headerType===U_.RecordBatch?this._recordBatchBlocks.push(new vS(o,e.bodyLength,this._position)):e.headerType===U_.DictionaryBatch&&this._dictionaryBlocks.push(new vS(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=Pg(e);t&&t.byteLength>0&&(this._sink.write(t),this._position+=t.byteLength)}return this}_writeSchema(e){return this._writeMessage(jC.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(fw)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:t,nodes:n,bufferRegions:r,buffers:i}=Fw.assemble(e),a=new MC(e.numRows,n,r),o=jC.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}=Fw.assemble(new oS([e])),s=new MC(e.length,i,a),c=new NC(s,t,n),l=jC.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)):gg(t)?qw(r,t):Kw(r,t)}},Gw=class e extends Uw{static writeAll(t){let n=new e;return mg(t)?t.then(e=>n.writeAll(e)):gg(t)?qw(n,t):Kw(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=gS.encode(new gS(e,Xg.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(t)._write(Int32Array.of(t.byteLength))._writeMagic()}};function Kw(e,t){let n=t;t instanceof cC&&(n=t.batches,e.reset(void 0,t.schema));for(let t of n)e.write(t);return e.finish()}function qw(e,t){return tg(this,void 0,void 0,function*(){var n,r,i,a,o,s,c;try{for(n=!0,r=ag(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 Jw(e,t=`stream`){return(t===`stream`?Ww:Gw).writeAll(e).toUint8Array(!0)}var Yw=Object.create,Xw=Object.defineProperty,Zw=Object.getOwnPropertyDescriptor,Qw=Object.getOwnPropertyNames,$w=Object.getPrototypeOf,eT=Object.prototype.hasOwnProperty,tT=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),nT=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of Qw(t))!eT.call(e,i)&&i!==n&&Xw(e,i,{get:()=>t[i],enumerable:!(r=Zw(t,i))||r.enumerable});return e},rT=(e,t,n)=>(n=e==null?{}:Yw($w(e)),nT(t||!e||!e.__esModule?Xw(n,`default`,{value:e,enumerable:!0}):n,e)),iT=tT((e,t)=>{t.exports=Worker}),aT=(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))(aT||{}),oT=(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))(oT||{}),sT=(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))(sT||{}),cT=(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))(cT||{}),lT=(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))(lT||{}),uT=(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))(uT||{}),dT=class{log(e){}},fT=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}},pT=(e=>(e[e.SUCCESS=0]=`SUCCESS`,e))(pT||{}),mT=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=_w.from(t);return console.assert(n.isSync(),`Reader is not sync`),console.assert(n.isFile(),`Reader is not file`),new cC(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 hT(this._bindings,this._conn,n),i=await _w.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 gT(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=Jw(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)}},hT=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}},gT=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=_w.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new cC(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new hT(this.bindings,this.connectionId,t),r=await _w.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},_T=(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))(_T||{}),vT=(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))(vT||{}),yT=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 bT(e){switch(e.typeId){case H.Binary:return{sqlType:`binary`};case H.Bool:return{sqlType:`bool`};case H.Date:return{sqlType:`date`};case H.DateDay:return{sqlType:`date32[d]`};case H.DateMillisecond:return{sqlType:`date64[ms]`};case H.Decimal:{let t=e;return{sqlType:`decimal`,precision:t.precision,scale:t.scale}}case H.Float:return{sqlType:`float`};case H.Float16:return{sqlType:`float16`};case H.Float32:return{sqlType:`float32`};case H.Float64:return{sqlType:`float64`};case H.Int:return{sqlType:`int32`};case H.Int16:return{sqlType:`int16`};case H.Int32:return{sqlType:`int32`};case H.Int64:return{sqlType:`int64`};case H.Uint16:return{sqlType:`uint16`};case H.Uint32:return{sqlType:`uint32`};case H.Uint64:return{sqlType:`uint64`};case H.Uint8:return{sqlType:`uint8`};case H.IntervalDayTime:return{sqlType:`interval[dt]`};case H.IntervalYearMonth:return{sqlType:`interval[m]`};case H.List:return{sqlType:`list`,valueType:bT(e.valueType)};case H.FixedSizeBinary:return{sqlType:`fixedsizebinary`,byteWidth:e.byteWidth};case H.Null:return{sqlType:`null`};case H.Utf8:return{sqlType:`utf8`};case H.Struct:return{sqlType:`struct`,fields:e.children.map(e=>xT(e.name,e.type))};case H.Map:{let t=e;return{sqlType:`map`,keyType:bT(t.keyType),valueType:bT(t.valueType)}}case H.Time:return{sqlType:`time[s]`};case H.TimeMicrosecond:return{sqlType:`time[us]`};case H.TimeMillisecond:return{sqlType:`time[ms]`};case H.TimeNanosecond:return{sqlType:`time[ns]`};case H.TimeSecond:return{sqlType:`time[s]`};case H.Timestamp:return{sqlType:`timestamp`,timezone:e.timezone||void 0};case H.TimestampSecond:return{sqlType:`timestamp[s]`,timezone:e.timezone||void 0};case H.TimestampMicrosecond:return{sqlType:`timestamp[us]`,timezone:e.timezone||void 0};case H.TimestampNanosecond:return{sqlType:`timestamp[ns]`,timezone:e.timezone||void 0};case H.TimestampMillisecond:return{sqlType:`timestamp[ms]`,timezone:e.timezone||void 0}}throw Error(`unsupported arrow type: ${e.toString()}`)}function xT(e,t){let n=bT(t);return n.name=e,n}var ST=new TextEncoder,CT=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 yT(`RESET`,null);return await this.postTask(e)}async ping(){let e=new yT(`PING`,null);await this.postTask(e)}async dropFile(e){let t=new yT(`DROP_FILE`,e);return await this.postTask(t)}async dropFiles(){let e=new yT(`DROP_FILES`,null);return await this.postTask(e)}async flushFiles(){let e=new yT(`FLUSH_FILES`,null);return await this.postTask(e)}async instantiate(e,t=null,n=e=>{}){this._onInstantiationProgress.push(n);let r=new yT(`INSTANTIATE`,[e,t]);return await this.postTask(r)}async getVersion(){let e=new yT(`GET_VERSION`,null);return await this.postTask(e)}async getFeatureFlags(){let e=new yT(`GET_FEATURE_FLAGS`,null);return await this.postTask(e)}async open(e){let t=new yT(`OPEN`,e);await this.postTask(t)}async tokenize(e){let t=new yT(`TOKENIZE`,e);return await this.postTask(t)}async connectInternal(){let e=new yT(`CONNECT`,null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new mT(this,e)}async disconnect(e){let t=new yT(`DISCONNECT`,e);await this.postTask(t)}async runQuery(e,t){let n=new yT(`RUN_QUERY`,[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){let r=new yT(`START_PENDING_QUERY`,[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new yT(`POLL_PENDING_QUERY`,e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new yT(`CANCEL_PENDING_QUERY`,e);return await this.postTask(t)}async fetchQueryResults(e){let t=new yT(`FETCH_QUERY_RESULTS`,e);return await this.postTask(t)}async getTableNames(e,t){let n=new yT(`GET_TABLE_NAMES`,[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new yT(`CREATE_PREPARED`,[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new yT(`CLOSE_PREPARED`,[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new yT(`RUN_PREPARED`,[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new yT(`SEND_PREPARED`,[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new yT(`GLOB_FILE_INFOS`,e);return await this.postTask(t)}async registerFileText(e,t){let n=ST.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new yT(`REGISTER_FILE_URL`,[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new yT(`REGISTER_FILE_BUFFER`,[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new yT(`REGISTER_FILE_HANDLE`,[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new yT(`REGISTER_OPFS_FILE_NAME`,[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new yT(`COLLECT_FILE_STATISTICS`,[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new yT(`EXPORT_FILE_STATISTICS`,e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new yT(`COPY_FILE_TO_BUFFER`,e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new yT(`COPY_FILE_TO_PATH`,[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new yT(`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(xT(t,r))}n.columnsFlat=e,delete n.columns}let r=new yT(`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(xT(t,r))}n.columnsFlat=e,delete n.columns}let r=new yT(`IMPORT_JSON_FROM_PATH`,[e,t,n]);await this.postTask(r)}};function wT(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<`u`&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}wT();var TT=(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))(TT||{}),ET=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])),DT=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])),OT=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])),kT=()=>(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])),AT={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`}}};AT.name,AT.version;var jT=AT.version.split(`.`);jT[0],jT[1],jT[2];var MT=()=>typeof navigator>`u`,NT=null,PT=null,FT=null,IT=null,LT=null;async function RT(){return NT??=typeof BigInt64Array<`u`,PT??=await DT(),FT??=await kT(),IT??=await OT(),LT??=await ET(),{bigInt64Array:NT,crossOriginIsolated:MT()||globalThis.crossOriginIsolated||!1,wasmExceptions:PT,wasmSIMD:IT,wasmThreads:FT,wasmBulkMemory:LT}}async function zT(e){let t=await RT();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}}rT(iT());const BT={},VT={};function HT(e,t){try{let n=BT[e]||=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`longOffset`}).format,r=n(t).split(`GMT`)[1];return r in VT?VT[r]:WT(r,r.split(`:`))}catch{if(e in VT)return VT[e];let t=e?.match(UT);return t?WT(e,t.slice(1)):NaN}}const UT=/([+-]\d\d):?(\d\d)?/;function WT(e,t){let n=+(t[0]||0),r=+(t[1]||0),i=(t[2]||0)/60;return VT[e]=n*60+r>0?n*60+r+i:n*60-r-i}var GT=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(HT(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)),YT(this,NaN),qT(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=-HT(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),qT(this),+this}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}};const KT=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!KT.test(e))return;let t=e.replace(KT,`$1UTC`);GT.prototype[t]&&(e.startsWith(`get`)?GT.prototype[e]=function(){return this.internal[t]()}:(GT.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),JT(this),+this},GT.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),qT(this),+this}))});function qT(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-HT(e.timeZone,e)*60))}function JT(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()),YT(e)}function YT(e){let t=HT(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(-(HT(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=HT(e.timeZone,e),p=f>0?Math.floor(f):Math.ceil(f),m=-new Date(+e).getTimezoneOffset(),h=m-p,g=p!==n,_=h-c;if(g&&_){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+_);let t=HT(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 XT=new TextDecoder(`utf-8`),ZT=e=>XT.decode(e),QT=new TextEncoder,$T=e=>QT.encode(e),eE=e=>typeof e==`function`,tE=e=>e!=null&&Object(e)===e,nE=e=>tE(e)&&eE(e.then),rE=e=>tE(e)&&eE(e[Symbol.iterator]),iE=e=>tE(e)&&eE(e[Symbol.asyncIterator]),aE=e=>tE(e)&&`done`in e&&`value`in e,oE=e=>tE(e)&&eE(e.clear)&&eE(e.bytes)&&eE(e.position)&&eE(e.setPosition)&&eE(e.capacity)&&eE(e.getBufferIdentifier)&&eE(e.createLong);var sE={};Ft(sE,{compareArrayLike:()=>KE,joinUint8Arrays:()=>dE,memcpy:()=>uE,rebaseValueOffsets:()=>GE,toArrayBufferView:()=>fE,toArrayBufferViewAsyncIterator:()=>FE,toArrayBufferViewIterator:()=>TE,toBigInt64Array:()=>gE,toBigUint64Array:()=>bE,toFloat32Array:()=>xE,toFloat32ArrayAsyncIterator:()=>HE,toFloat32ArrayIterator:()=>ME,toFloat64Array:()=>SE,toFloat64ArrayAsyncIterator:()=>UE,toFloat64ArrayIterator:()=>NE,toInt16Array:()=>mE,toInt16ArrayAsyncIterator:()=>LE,toInt16ArrayIterator:()=>DE,toInt32Array:()=>hE,toInt32ArrayAsyncIterator:()=>RE,toInt32ArrayIterator:()=>OE,toInt8Array:()=>pE,toInt8ArrayAsyncIterator:()=>IE,toInt8ArrayIterator:()=>EE,toUint16Array:()=>vE,toUint16ArrayAsyncIterator:()=>BE,toUint16ArrayIterator:()=>AE,toUint32Array:()=>yE,toUint32ArrayAsyncIterator:()=>VE,toUint32ArrayIterator:()=>jE,toUint8Array:()=>_E,toUint8ArrayAsyncIterator:()=>zE,toUint8ArrayIterator:()=>kE,toUint8ClampedArray:()=>CE,toUint8ClampedArrayAsyncIterator:()=>WE,toUint8ClampedArrayIterator:()=>PE});const cE=typeof SharedArrayBuffer<`u`?SharedArrayBuffer:ArrayBuffer;function lE(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;++cfE(Int8Array,e),mE=e=>fE(Int16Array,e),hE=e=>fE(Int32Array,e),gE=e=>fE(BigInt64Array,e),_E=e=>fE(Uint8Array,e),vE=e=>fE(Uint16Array,e),yE=e=>fE(Uint32Array,e),bE=e=>fE(BigUint64Array,e),xE=e=>fE(Float32Array,e),SE=e=>fE(Float64Array,e),CE=e=>fE(Uint8ClampedArray,e),wE=e=>(e.next(),e);function*TE(e,t){let n=function*(e){yield e},r=typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof cE?n(t):rE(t)?t:n(t);return yield*wE((function*(t){let n=null;do n=t.next(yield fE(e,n));while(!n.done)})(r[Symbol.iterator]())),new e}const EE=e=>TE(Int8Array,e),DE=e=>TE(Int16Array,e),OE=e=>TE(Int32Array,e),kE=e=>TE(Uint8Array,e),AE=e=>TE(Uint16Array,e),jE=e=>TE(Uint32Array,e),ME=e=>TE(Float32Array,e),NE=e=>TE(Float64Array,e),PE=e=>TE(Uint8ClampedArray,e);function FE(e,t){return rg(this,arguments,function*(){if(nE(t))return yield V(yield V(yield*ig(ag(FE(e,yield V(t))))));let n=function(e){return rg(this,arguments,function*(){yield yield V(yield V(e))})},r=function(e){return rg(this,arguments,function*(){yield V(yield*ig(ag(wE((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 cE?n(t):rE(t)?r(t):iE(t)?t:n(t);return yield V(yield*ig(ag(wE((function(t){return rg(this,arguments,function*(){let n=null;do n=yield V(t.next(yield yield V(fE(e,n))));while(!n.done)})})(i[Symbol.asyncIterator]()))))),yield V(new e)})}const IE=e=>FE(Int8Array,e),LE=e=>FE(Int16Array,e),RE=e=>FE(Int32Array,e),zE=e=>FE(Uint8Array,e),BE=e=>FE(Uint16Array,e),VE=e=>FE(Uint32Array,e),HE=e=>FE(Float32Array,e),UE=e=>FE(Float64Array,e),WE=e=>FE(Uint8ClampedArray,e);function GE(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(++neD});function eD(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=>eD(e))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(e,t)=>typeof t==`bigint`?`${t}`:t)}function tD(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 nD(e,t){return tD(e/t)+tD(e%t)/tD(t)}var rD={};Ft(rD,{BN:()=>hD,bigNumToBigInt:()=>pD,bigNumToNumber:()=>dD,bigNumToString:()=>fD,isArrowBigNumSymbol:()=>iD});const iD=Symbol.for(`isArrowBigNum`);function aD(e,...t){return t.length===0?Object.setPrototypeOf(fE(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}aD.prototype[iD]=!0,aD.prototype.toJSON=function(){return`"${fD(this)}"`},aD.prototype.valueOf=function(e){return dD(this,e)},aD.prototype.toString=function(){return fD(this)},aD.prototype[Symbol.toPrimitive]=function(e=`default`){switch(e){case`number`:return dD(this);case`string`:return fD(this);case`default`:return pD(this)}return fD(this)};function oD(...e){return aD.apply(this,e)}function sD(...e){return aD.apply(this,e)}function cD(...e){return aD.apply(this,e)}Object.setPrototypeOf(oD.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(sD.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(cD.prototype,Object.create(Uint32Array.prototype)),Object.assign(oD.prototype,aD.prototype,{constructor:oD,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(sD.prototype,aD.prototype,{constructor:sD,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(cD.prototype,aD.prototype,{constructor:cD,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const lD=BigInt(4294967296)*BigInt(4294967296),uD=lD-BigInt(1);function dD(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=tD(n),a=`${r}`.padStart(t,`0`),o=s&&i===0?`-`:``;return+`${o}${i}.${a}`}return tD(c)}function fD(e){if(e.byteLength===8){let t=new e.BigIntArray(e.buffer,e.byteOffset,1);return`${t[0]}`}if(!e.signed)return mD(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),n=new Int16Array([t.at(-1)])[0];if(n>=0)return mD(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`))(G.prototype);var RD=class extends G{constructor(){super(W.Null)}toString(){return`Null`}};_D=Symbol.toStringTag,RD[_D]=(e=>e[Symbol.toStringTag]=`Null`)(RD.prototype);var zD=class extends G{constructor(e,t){super(W.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}`}};vD=Symbol.toStringTag,zD[vD]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]=`Int`))(zD.prototype);var BD=class extends zD{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},VD=class extends zD{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},HD=class extends zD{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},UD=class extends zD{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},WD=class extends zD{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},GD=class extends zD{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},KD=class extends zD{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},qD=class extends zD{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(BD.prototype,`ArrayType`,{value:Int8Array}),Object.defineProperty(VD.prototype,`ArrayType`,{value:Int16Array}),Object.defineProperty(HD.prototype,`ArrayType`,{value:Int32Array}),Object.defineProperty(UD.prototype,`ArrayType`,{value:BigInt64Array}),Object.defineProperty(WD.prototype,`ArrayType`,{value:Uint8Array}),Object.defineProperty(GD.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(KD.prototype,`ArrayType`,{value:Uint32Array}),Object.defineProperty(qD.prototype,`ArrayType`,{value:BigUint64Array});var JD=class extends G{constructor(e){super(W.Float),this.precision=e}get ArrayType(){switch(this.precision){case JE.HALF:return Uint16Array;case JE.SINGLE:return Float32Array;case JE.DOUBLE:return Float64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};yD=Symbol.toStringTag,JD[yD]=(e=>(e.precision=null,e[Symbol.toStringTag]=`Float`))(JD.prototype);var YD=class extends JD{constructor(){super(JE.HALF)}},XD=class extends JD{constructor(){super(JE.SINGLE)}},ZD=class extends JD{constructor(){super(JE.DOUBLE)}};Object.defineProperty(YD.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(XD.prototype,`ArrayType`,{value:Float32Array}),Object.defineProperty(ZD.prototype,`ArrayType`,{value:Float64Array});var QD=class extends G{constructor(){super(W.Binary)}toString(){return`Binary`}};bD=Symbol.toStringTag,QD[bD]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Binary`))(QD.prototype);var $D=class extends G{constructor(){super(W.LargeBinary)}toString(){return`LargeBinary`}};xD=Symbol.toStringTag,$D[xD]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeBinary`))($D.prototype);var eO=class extends G{constructor(){super(W.Utf8)}toString(){return`Utf8`}};SD=Symbol.toStringTag,eO[SD]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Utf8`))(eO.prototype);var tO=class extends G{constructor(){super(W.LargeUtf8)}toString(){return`LargeUtf8`}};CD=Symbol.toStringTag,tO[CD]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeUtf8`))(tO.prototype);var nO=class extends G{constructor(){super(W.Bool)}toString(){return`Bool`}};wD=Symbol.toStringTag,nO[wD]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Bool`))(nO.prototype);var rO=class extends G{constructor(e,t,n=128){super(W.Decimal),this.scale=e,this.precision=t,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?`+`:``}${this.scale}]`}};TD=Symbol.toStringTag,rO[TD]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]=`Decimal`))(rO.prototype);var iO=class extends G{constructor(e){super(W.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${YE[this.unit]}>`}get ArrayType(){return this.unit===YE.DAY?Int32Array:BigInt64Array}};ED=Symbol.toStringTag,iO[ED]=(e=>(e.unit=null,e[Symbol.toStringTag]=`Date`))(iO.prototype);var aO=class extends G{constructor(e,t){super(W.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${XE[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};DD=Symbol.toStringTag,aO[DD]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]=`Time`))(aO.prototype);var oO=class extends G{constructor(e,t){super(W.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${XE[this.unit]}${this.timezone?`, ${this.timezone}`:``}>`}};OD=Symbol.toStringTag,oO[OD]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Timestamp`))(oO.prototype);var sO=class extends G{constructor(e){super(W.Interval),this.unit=e}toString(){return`Interval<${ZE[this.unit]}>`}};kD=Symbol.toStringTag,sO[kD]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]=`Interval`))(sO.prototype);var cO=class extends G{constructor(e){super(W.Duration),this.unit=e}toString(){return`Duration<${XE[this.unit]}>`}};AD=Symbol.toStringTag,cO[AD]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Duration`))(cO.prototype);var lO=class extends G{constructor(e){super(W.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}};jD=Symbol.toStringTag,lO[jD]=(e=>(e.children=null,e[Symbol.toStringTag]=`List`))(lO.prototype);var uO=class extends G{constructor(e){super(W.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};MD=Symbol.toStringTag,uO[MD]=(e=>(e.children=null,e[Symbol.toStringTag]=`Struct`))(uO.prototype);var dO=class extends G{constructor(e,t,n){super(W.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(` | `)}>`}};ND=Symbol.toStringTag,dO[ND]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]=`Union`))(dO.prototype);var fO=class extends G{constructor(e){super(W.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};PD=Symbol.toStringTag,fO[PD]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`FixedSizeBinary`))(fO.prototype);var pO=class extends G{constructor(e,t){super(W.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}>`}};FD=Symbol.toStringTag,pO[FD]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]=`FixedSizeList`))(pO.prototype);var mO=class extends G{constructor(e,t=!1){var n,r,i;if(super(W.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(`, `)}}>`}};ID=Symbol.toStringTag,mO[ID]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]=`Map_`))(mO.prototype);const hO=(e=>()=>++e)(-1);var gO=class extends G{constructor(e,t,n,r){super(W.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=r||!1,this.id=n==null?hO():tD(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,gO[LD]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]=`Dictionary`))(gO.prototype);function _O(e){let t=e;switch(e.typeId){case W.Decimal:return e.bitWidth/32;case W.Interval:return t.unit===ZE.MONTH_DAY_NANO?4:1+t.unit;case W.FixedSizeList:return t.listSize;case W.FixedSizeBinary:return t.byteWidth;default:return 1}}var vO=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 yO(this,e,t)}getVisitFnByTypeId(e,t=!0){return bO(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 yO(e,t,n=!0){return typeof t==`number`?bO(e,t,n):typeof t==`string`&&t in W?bO(e,W[t],n):t&&t instanceof G?bO(e,xO(t),n):t?.type&&t.type instanceof G?bO(e,xO(t.type),n):bO(e,W.NONE,n)}function bO(e,t,n=!0){let r=null;switch(t){case W.Null:r=e.visitNull;break;case W.Bool:r=e.visitBool;break;case W.Int:r=e.visitInt;break;case W.Int8:r=e.visitInt8||e.visitInt;break;case W.Int16:r=e.visitInt16||e.visitInt;break;case W.Int32:r=e.visitInt32||e.visitInt;break;case W.Int64:r=e.visitInt64||e.visitInt;break;case W.Uint8:r=e.visitUint8||e.visitInt;break;case W.Uint16:r=e.visitUint16||e.visitInt;break;case W.Uint32:r=e.visitUint32||e.visitInt;break;case W.Uint64:r=e.visitUint64||e.visitInt;break;case W.Float:r=e.visitFloat;break;case W.Float16:r=e.visitFloat16||e.visitFloat;break;case W.Float32:r=e.visitFloat32||e.visitFloat;break;case W.Float64:r=e.visitFloat64||e.visitFloat;break;case W.Utf8:r=e.visitUtf8;break;case W.LargeUtf8:r=e.visitLargeUtf8;break;case W.Binary:r=e.visitBinary;break;case W.LargeBinary:r=e.visitLargeBinary;break;case W.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case W.Date:r=e.visitDate;break;case W.DateDay:r=e.visitDateDay||e.visitDate;break;case W.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case W.Timestamp:r=e.visitTimestamp;break;case W.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case W.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case W.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case W.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case W.Time:r=e.visitTime;break;case W.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case W.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case W.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case W.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case W.Decimal:r=e.visitDecimal;break;case W.List:r=e.visitList;break;case W.Struct:r=e.visitStruct;break;case W.Union:r=e.visitUnion;break;case W.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case W.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case W.Dictionary:r=e.visitDictionary;break;case W.Interval:r=e.visitInterval;break;case W.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case W.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case W.IntervalMonthDayNano:r=e.visitIntervalMonthDayNano||e.visitInterval;break;case W.Duration:r=e.visitDuration;break;case W.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case W.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case W.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case W.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case W.FixedSizeList:r=e.visitFixedSizeList;break;case W.Map:r=e.visitMap;break}if(typeof r==`function`)return r;if(!n)return()=>null;throw Error(`Unrecognized type '${W[t]}'`)}function xO(e){switch(e.typeId){case W.Null:return W.Null;case W.Int:{let{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?W.Int8:W.Uint8;case 16:return n?W.Int16:W.Uint16;case 32:return n?W.Int32:W.Uint32;case 64:return n?W.Int64:W.Uint64}return W.Int}case W.Float:switch(e.precision){case JE.HALF:return W.Float16;case JE.SINGLE:return W.Float32;case JE.DOUBLE:return W.Float64}return W.Float;case W.Binary:return W.Binary;case W.LargeBinary:return W.LargeBinary;case W.Utf8:return W.Utf8;case W.LargeUtf8:return W.LargeUtf8;case W.Bool:return W.Bool;case W.Decimal:return W.Decimal;case W.Time:switch(e.unit){case XE.SECOND:return W.TimeSecond;case XE.MILLISECOND:return W.TimeMillisecond;case XE.MICROSECOND:return W.TimeMicrosecond;case XE.NANOSECOND:return W.TimeNanosecond}return W.Time;case W.Timestamp:switch(e.unit){case XE.SECOND:return W.TimestampSecond;case XE.MILLISECOND:return W.TimestampMillisecond;case XE.MICROSECOND:return W.TimestampMicrosecond;case XE.NANOSECOND:return W.TimestampNanosecond}return W.Timestamp;case W.Date:switch(e.unit){case YE.DAY:return W.DateDay;case YE.MILLISECOND:return W.DateMillisecond}return W.Date;case W.Interval:switch(e.unit){case ZE.DAY_TIME:return W.IntervalDayTime;case ZE.YEAR_MONTH:return W.IntervalYearMonth;case ZE.MONTH_DAY_NANO:return W.IntervalMonthDayNano}return W.Interval;case W.Duration:switch(e.unit){case XE.SECOND:return W.DurationSecond;case XE.MILLISECOND:return W.DurationMillisecond;case XE.MICROSECOND:return W.DurationMicrosecond;case XE.NANOSECOND:return W.DurationNanosecond}return W.Duration;case W.Map:return W.Map;case W.List:return W.List;case W.Struct:return W.Struct;case W.Union:switch(e.mode){case qE.Dense:return W.DenseUnion;case qE.Sparse:return W.SparseUnion}return W.Union;case W.FixedSizeBinary:return W.FixedSizeBinary;case W.FixedSizeList:return W.FixedSizeList;case W.Dictionary:return W.Dictionary}throw Error(`Unrecognized type '${W[e.typeId]}'`)}vO.prototype.visitInt8=null,vO.prototype.visitInt16=null,vO.prototype.visitInt32=null,vO.prototype.visitInt64=null,vO.prototype.visitUint8=null,vO.prototype.visitUint16=null,vO.prototype.visitUint32=null,vO.prototype.visitUint64=null,vO.prototype.visitFloat16=null,vO.prototype.visitFloat32=null,vO.prototype.visitFloat64=null,vO.prototype.visitDateDay=null,vO.prototype.visitDateMillisecond=null,vO.prototype.visitTimestampSecond=null,vO.prototype.visitTimestampMillisecond=null,vO.prototype.visitTimestampMicrosecond=null,vO.prototype.visitTimestampNanosecond=null,vO.prototype.visitTimeSecond=null,vO.prototype.visitTimeMillisecond=null,vO.prototype.visitTimeMicrosecond=null,vO.prototype.visitTimeNanosecond=null,vO.prototype.visitDenseUnion=null,vO.prototype.visitSparseUnion=null,vO.prototype.visitIntervalDayTime=null,vO.prototype.visitIntervalYearMonth=null,vO.prototype.visitIntervalMonthDayNano=null,vO.prototype.visitDuration=null,vO.prototype.visitDurationSecond=null,vO.prototype.visitDurationMillisecond=null,vO.prototype.visitDurationMicrosecond=null,vO.prototype.visitDurationNanosecond=null;var SO={};Ft(SO,{float64ToUint16:()=>EO,uint16ToFloat64:()=>TO});const CO=new Float64Array(1),wO=new Uint32Array(CO.buffer);function TO(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 EO(e){if(e!==e)return 32256;CO[0]=e;let t=(wO[1]&2147483648)>>16&65535,n=wO[1]&2146435072,r=0;return n>=1089470464?wO[0]>0?n=31744:(n=(n&2080374784)>>16,r=(wO[1]&1048575)>>10):n<=1056964608?(r=1048576+(wO[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(wO[1]&1048575)+512>>10),t|n|r&65535}var DO=class extends vO{};function OO(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const kO=(e,t,n)=>{e[t]=Math.floor(n/864e5)},AO=(e,t,n,r)=>{if(n+1{let i=e+n;r?t[i>>3]|=1<>3]&=~(1<{e[t]=n},NO=({values:e},t,n)=>{e[t]=n},PO=({values:e},t,n)=>{e[t]=EO(n)},FO=(e,t,n)=>{switch(e.type.precision){case JE.HALF:return PO(e,t,n);case JE.SINGLE:case JE.DOUBLE:return NO(e,t,n)}},IO=({values:e},t,n)=>{kO(e,t,n.valueOf())},LO=({values:e},t,n)=>{e[t]=BigInt(n)},RO=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},zO=({values:e,valueOffsets:t},n,r)=>AO(e,t,n,r),BO=({values:e,valueOffsets:t},n,r)=>AO(e,t,n,$T(r)),VO=(e,t,n)=>{e.type.unit===YE.DAY?IO(e,t,n):LO(e,t,n)},HO=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},UO=({values:e},t,n)=>{e[t]=BigInt(n)},WO=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},GO=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},KO=(e,t,n)=>{switch(e.type.unit){case XE.SECOND:return HO(e,t,n);case XE.MILLISECOND:return UO(e,t,n);case XE.MICROSECOND:return WO(e,t,n);case XE.NANOSECOND:return GO(e,t,n)}},qO=({values:e},t,n)=>{e[t]=n},JO=({values:e},t,n)=>{e[t]=n},YO=({values:e},t,n)=>{e[t]=n},XO=({values:e},t,n)=>{e[t]=n},ZO=(e,t,n)=>{switch(e.type.unit){case XE.SECOND:return qO(e,t,n);case XE.MILLISECOND:return JO(e,t,n);case XE.MICROSECOND:return YO(e,t,n);case XE.NANOSECOND:return XO(e,t,n)}},QO=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},$O=(e,t,n)=>{let r=e.children[0],i=e.valueOffsets,a=bk.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=bk.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},tk=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[a]),nk=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(a)),rk=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(i.name)),ik=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[i.name]),ak=(e,t,n)=>{let r=e.type.children.map(e=>bk.getVisitFn(e.type)),i=n instanceof Map?rk(t,n):n instanceof vj?nk(t,n):Array.isArray(n)?tk(t,n):ik(t,n);e.type.children.forEach((t,n)=>i(r[n],e.children[n],t,n))},ok=(e,t,n)=>{e.type.mode===qE.Dense?sk(e,t,n):ck(e,t,n)},sk=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];bk.visit(i,e.valueOffsets[t],n)},ck=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];bk.visit(i,t,n)},lk=(e,t,n)=>{var r;(r=e.dictionary)==null||r.set(e.values[t],n)},uk=(e,t,n)=>{switch(e.type.unit){case ZE.YEAR_MONTH:return fk(e,t,n);case ZE.DAY_TIME:return dk(e,t,n);case ZE.MONTH_DAY_NANO:return pk(e,t,n)}},dk=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},fk=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},pk=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},mk=({values:e},t,n)=>{e[t]=n},hk=({values:e},t,n)=>{e[t]=n},gk=({values:e},t,n)=>{e[t]=n},_k=({values:e},t,n)=>{e[t]=n},vk=(e,t,n)=>{switch(e.type.unit){case XE.SECOND:return mk(e,t,n);case XE.MILLISECOND:return hk(e,t,n);case XE.MICROSECOND:return gk(e,t,n);case XE.NANOSECOND:return _k(e,t,n)}},yk=(e,t,n)=>{let{stride:r}=e,i=e.children[0],a=bk.getVisitFn(i);if(Array.isArray(n))for(let e=-1,o=t*r;++e`${eD(e)}: ${eD(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}[Symbol.iterator](){return new wk(this[xk],this[Sk])}},wk=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[xk].type.children.some(e=>e.name===t)}getOwnPropertyDescriptor(e,t){if(e[xk].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[xk].type.children.findIndex(e=>e.name===t);if(n!==-1){let r=_A.visit(e[xk].children[n],e[Sk]);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[xk].type.children.findIndex(e=>e.name===t);return r===-1?Reflect.has(e,t)||typeof t==`symbol`?Reflect.set(e,t,n):!1:(bk.visit(e[xk].children[r],e[Sk],n),Reflect.set(e,t,n))}};const Ek=new Tk;var K=class extends vO{};function Dk(e){return(t,n)=>t.getValid(n)?e(t,n):null}const Ok=(e,t)=>864e5*e[t],kk=(e,t)=>null,Ak=(e,t,n)=>{if(n+1>=t.length)return null;let r=tD(t[n]),i=tD(t[n+1]);return e.subarray(r,i)},jk=({offset:e,values:t},n)=>{let r=e+n,i=t[r>>3];return(i&1<Ok(e,t),Nk=({values:e},t)=>tD(e[t]),Pk=({stride:e,values:t},n)=>t[e*n],Fk=({stride:e,values:t},n)=>TO(t[e*n]),Ik=({values:e},t)=>e[t],Lk=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),Rk=({values:e,valueOffsets:t},n)=>Ak(e,t,n),zk=({values:e,valueOffsets:t},n)=>{let r=Ak(e,t,n);return r===null?null:ZT(r)},Bk=({values:e},t)=>e[t],Vk=({type:e,values:t},n)=>e.precision===JE.HALF?TO(t[n]):t[n],Hk=(e,t)=>e.type.unit===YE.DAY?Mk(e,t):Nk(e,t),Uk=({values:e},t)=>1e3*tD(e[t]),Wk=({values:e},t)=>tD(e[t]),Gk=({values:e},t)=>nD(e[t],BigInt(1e3)),Kk=({values:e},t)=>nD(e[t],BigInt(1e6)),qk=(e,t)=>{switch(e.type.unit){case XE.SECOND:return Uk(e,t);case XE.MILLISECOND:return Wk(e,t);case XE.MICROSECOND:return Gk(e,t);case XE.NANOSECOND:return Kk(e,t)}},Jk=({values:e},t)=>e[t],Yk=({values:e},t)=>e[t],Xk=({values:e},t)=>e[t],Zk=({values:e},t)=>e[t],Qk=(e,t)=>{switch(e.type.unit){case XE.SECOND:return Jk(e,t);case XE.MILLISECOND:return Yk(e,t);case XE.MICROSECOND:return Xk(e,t);case XE.NANOSECOND:return Zk(e,t)}},$k=({values:e,stride:t},n)=>hD.decimal(e.subarray(t*n,t*(n+1))),eA=(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 vj([c])},tA=(e,t)=>{let{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:a}=n,o=r[0];return new SA(o.slice(i,a-i))},nA=(e,t)=>new Ck(e,t),rA=(e,t)=>e.type.mode===qE.Dense?iA(e,t):aA(e,t),iA=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return _A.visit(r,e.valueOffsets[t])},aA=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return _A.visit(r,t)},oA=(e,t)=>{var n;return(n=e.dictionary)?.get(e.values[t])},sA=(e,t)=>e.type.unit===ZE.MONTH_DAY_NANO?uA(e,t):e.type.unit===ZE.DAY_TIME?cA(e,t):lA(e,t),cA=({values:e},t)=>e.subarray(2*t,2*(t+1)),lA=({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},uA=({values:e},t)=>e.subarray(4*t,4*(t+1)),dA=({values:e},t)=>e[t],fA=({values:e},t)=>e[t],pA=({values:e},t)=>e[t],mA=({values:e},t)=>e[t],hA=(e,t)=>{switch(e.type.unit){case XE.SECOND:return dA(e,t);case XE.MILLISECOND:return fA(e,t);case XE.MICROSECOND:return pA(e,t);case XE.NANOSECOND:return mA(e,t)}},gA=(e,t)=>{let{stride:n,children:r}=e,i=r[0],a=i.slice(t*n,n);return new vj([a])};K.prototype.visitNull=Dk(kk),K.prototype.visitBool=Dk(jk),K.prototype.visitInt=Dk(Bk),K.prototype.visitInt8=Dk(Pk),K.prototype.visitInt16=Dk(Pk),K.prototype.visitInt32=Dk(Pk),K.prototype.visitInt64=Dk(Ik),K.prototype.visitUint8=Dk(Pk),K.prototype.visitUint16=Dk(Pk),K.prototype.visitUint32=Dk(Pk),K.prototype.visitUint64=Dk(Ik),K.prototype.visitFloat=Dk(Vk),K.prototype.visitFloat16=Dk(Fk),K.prototype.visitFloat32=Dk(Pk),K.prototype.visitFloat64=Dk(Pk),K.prototype.visitUtf8=Dk(zk),K.prototype.visitLargeUtf8=Dk(zk),K.prototype.visitBinary=Dk(Rk),K.prototype.visitLargeBinary=Dk(Rk),K.prototype.visitFixedSizeBinary=Dk(Lk),K.prototype.visitDate=Dk(Hk),K.prototype.visitDateDay=Dk(Mk),K.prototype.visitDateMillisecond=Dk(Nk),K.prototype.visitTimestamp=Dk(qk),K.prototype.visitTimestampSecond=Dk(Uk),K.prototype.visitTimestampMillisecond=Dk(Wk),K.prototype.visitTimestampMicrosecond=Dk(Gk),K.prototype.visitTimestampNanosecond=Dk(Kk),K.prototype.visitTime=Dk(Qk),K.prototype.visitTimeSecond=Dk(Jk),K.prototype.visitTimeMillisecond=Dk(Yk),K.prototype.visitTimeMicrosecond=Dk(Xk),K.prototype.visitTimeNanosecond=Dk(Zk),K.prototype.visitDecimal=Dk($k),K.prototype.visitList=Dk(eA),K.prototype.visitStruct=Dk(nA),K.prototype.visitUnion=Dk(rA),K.prototype.visitDenseUnion=Dk(iA),K.prototype.visitSparseUnion=Dk(aA),K.prototype.visitDictionary=Dk(oA),K.prototype.visitInterval=Dk(sA),K.prototype.visitIntervalDayTime=Dk(cA),K.prototype.visitIntervalYearMonth=Dk(lA),K.prototype.visitIntervalMonthDayNano=Dk(uA),K.prototype.visitDuration=Dk(hA),K.prototype.visitDurationSecond=Dk(dA),K.prototype.visitDurationMillisecond=Dk(fA),K.prototype.visitDurationMicrosecond=Dk(pA),K.prototype.visitDurationNanosecond=Dk(mA),K.prototype.visitFixedSizeList=Dk(gA),K.prototype.visitMap=Dk(tA);const _A=new K,vA=Symbol.for(`keys`),yA=Symbol.for(`vals`),bA=Symbol.for(`kKeysAsStrings`),xA=Symbol.for(`_kKeysAsStrings`);var SA=class{constructor(e){return this[vA]=new vj([e.children[0]]).memoize(),this[yA]=e.children[1],new Proxy(this,new wA)}get[bA](){return this[xA]||(this[xA]=Array.from(this[vA].toArray(),String))}[Symbol.iterator](){return new CA(this[vA],this[yA])}get size(){return this[vA].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[vA],t=this[yA],n={};for(let r=-1,i=e.length;++r`${eD(e)}: ${eD(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}},CA=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),_A.visit(this.vals,e)]})}},wA=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[bA]}has(e,t){return e[bA].includes(t)}getOwnPropertyDescriptor(e,t){let n=e[bA].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[bA].indexOf(t);if(n!==-1){let r=_A.visit(Reflect.get(e,yA),n);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[bA].indexOf(t);return r===-1?Reflect.has(e,t)?Reflect.set(e,t,n):!1:(bk.visit(Reflect.get(e,yA),r,n),Reflect.set(e,t,n))}};Object.defineProperties(SA.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[vA]:{writable:!0,enumerable:!1,configurable:!1,value:null},[yA]:{writable:!0,enumerable:!1,configurable:!1,value:null},[xA]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var TA={};Ft(TA,{clampRange:()=>DA,createElementComparator:()=>AA,wrapIndex:()=>OA});let EA;function DA(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 OA=(e,t)=>e<0?t+e:e,kA=e=>e!==e;function AA(e){let t=typeof e;if(t!==`object`||e===null)return kA(e)?kA: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?KE(e,t):!1:e instanceof Map?MA(e):Array.isArray(e)?jA(e):e instanceof vj?NA(e):PA(e,!0)}function jA(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 IA(e,n);case Map:return RA(e,n,n.keys());case SA:case Ck:case Object:case void 0:return RA(e,n,t||Object.keys(n))}return n instanceof vj?LA(e,n):!1}}function IA(e,t){let n=e.length;if(t.length!==n)return!1;for(let r=-1;++rGA,getBit:()=>VA,getBool:()=>BA,packBools:()=>WA,popcnt_array:()=>qA,popcnt_bit_range:()=>KA,popcnt_uint32:()=>JA,setBool:()=>HA,truncateBitmap:()=>UA});function BA(e,t,n,r){return(n&1<>r}function HA(e,t,n){return n?!!(e[t>>3]|=1<>3]&=~(1<0||n.byteLength>3):WA(new GA(n,e,t,null,BA)).subarray(0,r)),i}return n}function WA(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 GA=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 KA(e,t,i)+KA(e,r,n)+qA(e,i>>3,r-i>>3)}function qA(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+=JA(a.getUint32(i)),i+=4;for(;o-i>=2;)r+=JA(a.getUint16(i)),i+=2;for(;o-i>=1;)r+=JA(a.getUint8(i)),i+=1;return r}function JA(e){let t=Math.trunc(e);return t-=t>>>1&1431655765,t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var YA=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 G.isSparseUnion(e)||G.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(G.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-KA(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=_O(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(G.isUnion(t)){let n=t,r=this.children[n.typeIdToChildIndex[this.typeIds[e]]],i=n.mode===qE.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(UA(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===W.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(UA(this.offset,t,this.nullBitmap),0);let i=this.buffers;return i[QE.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[QE.TYPE])&&(a[QE.TYPE]=i.subarray(e,e+t)),(i=a[QE.OFFSET])&&(a[QE.OFFSET]=i.subarray(e,e+t+1))||(i=a[QE.DATA])&&(a[QE.DATA]=r===6?i:i.subarray(n*e,n*(e+t))),a}_sliceChildren(e,t,n){return e.map(e=>e.slice(t,n))}};YA.prototype.children=Object.freeze([]);var XA=class e extends vO{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{type:t,offset:n=0,length:r=0}=e;return new YA(t,n,r,r)}visitBool(e){let{type:t,offset:n=0}=e,r=_E(e.nullBitmap),i=fE(t.ArrayType,e.data),{length:a=i.length>>3,nullCount:o=e.nullBitmap?-1:0}=e;return new YA(t,n,a,o,[void 0,i,r])}visitInt(e){let{type:t,offset:n=0}=e,r=_E(e.nullBitmap),i=fE(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new YA(t,n,a,o,[void 0,i,r])}visitFloat(e){let{type:t,offset:n=0}=e,r=_E(e.nullBitmap),i=fE(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new YA(t,n,a,o,[void 0,i,r])}visitUtf8(e){let{type:t,offset:n=0}=e,r=_E(e.data),i=_E(e.nullBitmap),a=hE(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new YA(t,n,o,s,[a,r,i])}visitLargeUtf8(e){let{type:t,offset:n=0}=e,r=_E(e.data),i=_E(e.nullBitmap),a=gE(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new YA(t,n,o,s,[a,r,i])}visitBinary(e){let{type:t,offset:n=0}=e,r=_E(e.data),i=_E(e.nullBitmap),a=hE(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new YA(t,n,o,s,[a,r,i])}visitLargeBinary(e){let{type:t,offset:n=0}=e,r=_E(e.data),i=_E(e.nullBitmap),a=gE(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new YA(t,n,o,s,[a,r,i])}visitFixedSizeBinary(e){let{type:t,offset:n=0}=e,r=_E(e.nullBitmap),i=fE(t.ArrayType,e.data),{length:a=i.length/_O(t),nullCount:o=e.nullBitmap?-1:0}=e;return new YA(t,n,a,o,[void 0,i,r])}visitDate(e){let{type:t,offset:n=0}=e,r=_E(e.nullBitmap),i=fE(t.ArrayType,e.data),{length:a=i.length/_O(t),nullCount:o=e.nullBitmap?-1:0}=e;return new YA(t,n,a,o,[void 0,i,r])}visitTimestamp(e){let{type:t,offset:n=0}=e,r=_E(e.nullBitmap),i=fE(t.ArrayType,e.data),{length:a=i.length/_O(t),nullCount:o=e.nullBitmap?-1:0}=e;return new YA(t,n,a,o,[void 0,i,r])}visitTime(e){let{type:t,offset:n=0}=e,r=_E(e.nullBitmap),i=fE(t.ArrayType,e.data),{length:a=i.length/_O(t),nullCount:o=e.nullBitmap?-1:0}=e;return new YA(t,n,a,o,[void 0,i,r])}visitDecimal(e){let{type:t,offset:n=0}=e,r=_E(e.nullBitmap),i=fE(t.ArrayType,e.data),{length:a=i.length/_O(t),nullCount:o=e.nullBitmap?-1:0}=e;return new YA(t,n,a,o,[void 0,i,r])}visitList(e){let{type:t,offset:n=0,child:r}=e,i=_E(e.nullBitmap),a=hE(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new YA(t,n,o,s,[a,void 0,i],[r])}visitStruct(e){let{type:t,offset:n=0,children:r=[]}=e,i=_E(e.nullBitmap),{length:a=r.reduce((e,{length:t})=>Math.max(e,t),0),nullCount:o=e.nullBitmap?-1:0}=e;return new YA(t,n,a,o,[void 0,void 0,i],r)}visitUnion(e){let{type:t,offset:n=0,children:r=[]}=e,i=fE(t.ArrayType,e.typeIds),{length:a=i.length,nullCount:o=-1}=e;if(G.isSparseUnion(t))return new YA(t,n,a,o,[void 0,void 0,void 0,i],r);let s=hE(e.valueOffsets);return new YA(t,n,a,o,[s,void 0,void 0,i],r)}visitDictionary(t){let{type:n,offset:r=0}=t,i=_E(t.nullBitmap),a=fE(n.indices.ArrayType,t.data),{dictionary:o=new vj([new e().visit({type:n.dictionary})])}=t,{length:s=a.length,nullCount:c=t.nullBitmap?-1:0}=t;return new YA(n,r,s,c,[void 0,a,i],[],o)}visitInterval(e){let{type:t,offset:n=0}=e,r=_E(e.nullBitmap),i=fE(t.ArrayType,e.data),{length:a=i.length/_O(t),nullCount:o=e.nullBitmap?-1:0}=e;return new YA(t,n,a,o,[void 0,i,r])}visitDuration(e){let{type:t,offset:n=0}=e,r=_E(e.nullBitmap),i=fE(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new YA(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=_E(t.nullBitmap),{length:o=i.length/_O(n),nullCount:s=t.nullBitmap?-1:0}=t;return new YA(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=_E(t.nullBitmap),o=hE(t.valueOffsets),{length:s=o.length-1,nullCount:c=t.nullBitmap?-1:0}=t;return new YA(n,r,s,c,[o,void 0,a],[i])}};new XA;var ZA=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 $A(e){return e.reduce((e,t)=>e+t.nullCount,0)}function ej(e){return e.reduce((e,t,n)=>(e[n+1]=e[n]+t.length,e),new Uint32Array(e.length+1))}function tj(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 nj(e,t,n,r){let i=0,a=0,o=t.length-1;do{if(i>=o-1)return n0?0:-1}function cj(e,t){let{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(let i of new GA(n,e.offset+(t||0),e.length,n,BA)){if(!i)return r;++r}return-1}function lj(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case W.Union:break;case W.Dictionary:break;default:return cj(e,n)}let r=_A.getVisitFn(e),i=AA(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 ZA(e.data.length,t=>{let r=e.data[t],i=r.length,a=e.slice(n,n+i);return n+=i,new pj(a)})}var pj=class{constructor(e){this.vector=e,this.index=0}next(){return this.indexe.data):t;if(a.length===0||a.some(e=>!(e instanceof YA)))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}=gj[o.typeId],r=a[0];this.isValid=e=>rj(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,_j[o.typeId]),this._offsets=ej(a);break}this.data=a,this.type=o,this.stride=_O(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 QA(this.data)}get nullCount(){return $A(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${W[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(OA(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return mj.visit(this)}concat(...t){return new e(this.data.concat(t.flatMap(e=>e.data).flat(1/0)))}slice(t,n){return new e(DA(this,t,n,({data:e,_offsets:t},n,r)=>tj(e,t,n,r)))}toJSON(){return[...this]}toArray(){let{type:e,data:t,length:n,stride:r,ArrayType:i}=this;switch(e.typeId){case W.Int:case W.Float:case W.Decimal:case W.Time:case W.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 G.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(G.isDictionary(this.type)){let t=new yj(this.data[0].dictionary),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return new yj(this)}unmemoize(){if(G.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}};hj=Symbol.toStringTag,vj[hj]=(e=>{e.type=G.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(W).map(e=>W[e]).filter(e=>typeof e==`number`&&e!==W.NONE);for(let n of t){let t=_A.getVisitFnByTypeId(n),r=bk.getVisitFnByTypeId(n),i=dj.getVisitFnByTypeId(n);gj[n]={get:t,set:r,indexOf:i},_j[n]=Object.create(e,{isValid:{value:ij(rj)},get:{value:ij(_A.getVisitFnByTypeId(n))},set:{value:aj(bk.getVisitFnByTypeId(n))},indexOf:{value:oj(dj.getVisitFnByTypeId(n))}})}return`Vector`})(vj.prototype);var yj=class e extends vj{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 vj(this.data)}),Object.defineProperty(this,`memoize`,{value:()=>this})}},bj={};Ft(bj,{BaseInt64:()=>Cj,Int128:()=>Ej,Int64:()=>Tj,Uint64:()=>wj});function xj(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}const Sj=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];var Cj=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`${xj(this.buffer[3])} ${xj(this.buffer[2])} ${xj(this.buffer[1])} ${xj(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;nOj,toIntervalDayTimeObjects:()=>Aj,toIntervalMonthDayNanoInt32Array:()=>kj,toIntervalMonthDayNanoObjects:()=>jj});function Oj(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 Aj(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 Y=class extends vO{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 Mj(e,t){return t instanceof e.constructor}function Nj(e,t){return e===t||Mj(e,t)}function Pj(e,t){return e===t||Mj(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function Fj(e,t){return e===t||Mj(e,t)&&e.precision===t.precision}function Ij(e,t){return e===t||Mj(e,t)&&e.byteWidth===t.byteWidth}function Lj(e,t){return e===t||Mj(e,t)&&e.unit===t.unit}function Rj(e,t){return e===t||Mj(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function zj(e,t){return e===t||Mj(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function Bj(e,t){return e===t||Mj(e,t)&&e.children.length===t.children.length&&Jj.compareManyFields(e.children,t.children)}function Vj(e,t){return e===t||Mj(e,t)&&e.children.length===t.children.length&&Jj.compareManyFields(e.children,t.children)}function Hj(e,t){return e===t||Mj(e,t)&&e.mode===t.mode&&e.typeIds.every((e,n)=>e===t.typeIds[n])&&Jj.compareManyFields(e.children,t.children)}function Uj(e,t){return e===t||Mj(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&Jj.visit(e.indices,t.indices)&&Jj.visit(e.dictionary,t.dictionary)}function Wj(e,t){return e===t||Mj(e,t)&&e.unit===t.unit}function Gj(e,t){return e===t||Mj(e,t)&&e.unit===t.unit}function Kj(e,t){return e===t||Mj(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&Jj.compareManyFields(e.children,t.children)}function qj(e,t){return e===t||Mj(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&Jj.compareManyFields(e.children,t.children)}Y.prototype.visitNull=Nj,Y.prototype.visitBool=Nj,Y.prototype.visitInt=Pj,Y.prototype.visitInt8=Pj,Y.prototype.visitInt16=Pj,Y.prototype.visitInt32=Pj,Y.prototype.visitInt64=Pj,Y.prototype.visitUint8=Pj,Y.prototype.visitUint16=Pj,Y.prototype.visitUint32=Pj,Y.prototype.visitUint64=Pj,Y.prototype.visitFloat=Fj,Y.prototype.visitFloat16=Fj,Y.prototype.visitFloat32=Fj,Y.prototype.visitFloat64=Fj,Y.prototype.visitUtf8=Nj,Y.prototype.visitLargeUtf8=Nj,Y.prototype.visitBinary=Nj,Y.prototype.visitLargeBinary=Nj,Y.prototype.visitFixedSizeBinary=Ij,Y.prototype.visitDate=Lj,Y.prototype.visitDateDay=Lj,Y.prototype.visitDateMillisecond=Lj,Y.prototype.visitTimestamp=Rj,Y.prototype.visitTimestampSecond=Rj,Y.prototype.visitTimestampMillisecond=Rj,Y.prototype.visitTimestampMicrosecond=Rj,Y.prototype.visitTimestampNanosecond=Rj,Y.prototype.visitTime=zj,Y.prototype.visitTimeSecond=zj,Y.prototype.visitTimeMillisecond=zj,Y.prototype.visitTimeMicrosecond=zj,Y.prototype.visitTimeNanosecond=zj,Y.prototype.visitDecimal=Nj,Y.prototype.visitList=Bj,Y.prototype.visitStruct=Vj,Y.prototype.visitUnion=Hj,Y.prototype.visitDenseUnion=Hj,Y.prototype.visitSparseUnion=Hj,Y.prototype.visitDictionary=Uj,Y.prototype.visitInterval=Wj,Y.prototype.visitIntervalDayTime=Wj,Y.prototype.visitIntervalYearMonth=Wj,Y.prototype.visitIntervalMonthDayNano=Wj,Y.prototype.visitDuration=Gj,Y.prototype.visitDurationSecond=Gj,Y.prototype.visitDurationMillisecond=Gj,Y.prototype.visitDurationMicrosecond=Gj,Y.prototype.visitDurationNanosecond=Gj,Y.prototype.visitFixedSizeList=Kj,Y.prototype.visitMap=qj;const Jj=new Y;function Yj(e,t){return Jj.compareSchemas(e,t)}function Xj(e,t){return Jj.compareFields(e,t)}function Zj(e,t){return Jj.visit(e,t)}const Qj=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},rD),bj),zA),SO),sE),TA),$E),Dj),{compareSchemas:Yj,compareFields:Xj,compareTypes:Zj}),$j=6048e5,eM=3600*24;eM*7,eM*365.2425;const tM=Symbol.for(`constructDateFrom`);function nM(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&tM in e?e[tM](t):e instanceof Date?new e.constructor(t):new Date(t)}function rM(e,t){return nM(t||e,e)}let iM={};function aM(){return iM}function oM(e,t){let n=aM(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=rM(e,t?.in),a=i.getDay(),o=(a=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function lM(e){let t=rM(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 uM(e,...t){let n=nM.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function dM(e,t){let n=rM(e,t?.in);return n.setHours(0,0,0,0),n}function fM(e,t,n){let[r,i]=uM(n?.in,e,t),a=dM(r),o=dM(i),s=+a-lM(a),c=+o-lM(o);return Math.round((s-c)/864e5)}function pM(e,t){let n=cM(e,t),r=nM(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),sM(r)}function mM(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function hM(e){return!(!mM(e)&&typeof e!=`number`||isNaN(+rM(e)))}function gM(e,t){let n=rM(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const _M={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`}},vM=(e,t,n)=>{let r,i=_M[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 yM(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth,r=e.formats[n]||e.formats[e.defaultWidth];return r}}const bM={full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},xM={full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},SM={full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},CM={date:yM({formats:bM,defaultWidth:`full`}),time:yM({formats:xM,defaultWidth:`full`}),dateTime:yM({formats:SM,defaultWidth:`full`})},wM={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},TM=(e,t,n,r)=>wM[e];function EM(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 DM={narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},OM={narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},kM={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`]},AM={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`]},jM={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`}},MM={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`}},NM=(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`},PM={ordinalNumber:NM,era:EM({values:DM,defaultWidth:`wide`}),quarter:EM({values:OM,defaultWidth:`wide`,argumentCallback:e=>e-1}),month:EM({values:kM,defaultWidth:`wide`}),day:EM({values:AM,defaultWidth:`wide`}),dayPeriod:EM({values:jM,defaultWidth:`wide`,formattingValues:MM,defaultFormattingWidth:`wide`})};function FM(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)?LM(s,e=>e.test(o)):IM(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 IM(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function LM(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 zM=/^(\d+)(th|st|nd|rd)?/i,BM=/\d+/i,VM={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},HM={any:[/^b/i,/^(a|c)/i]},UM={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},WM={any:[/1/i,/2/i,/3/i,/4/i]},GM={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},KM={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]},qM={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},JM={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]},YM={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},XM={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}},ZM={ordinalNumber:RM({matchPattern:zM,parsePattern:BM,valueCallback:e=>parseInt(e,10)}),era:FM({matchPatterns:VM,defaultMatchWidth:`wide`,parsePatterns:HM,defaultParseWidth:`any`}),quarter:FM({matchPatterns:UM,defaultMatchWidth:`wide`,parsePatterns:WM,defaultParseWidth:`any`,valueCallback:e=>e+1}),month:FM({matchPatterns:GM,defaultMatchWidth:`wide`,parsePatterns:KM,defaultParseWidth:`any`}),day:FM({matchPatterns:qM,defaultMatchWidth:`wide`,parsePatterns:JM,defaultParseWidth:`any`}),dayPeriod:FM({matchPatterns:YM,defaultMatchWidth:`any`,parsePatterns:XM,defaultParseWidth:`any`})},QM={code:`en-US`,formatDistance:vM,formatLong:CM,formatRelative:TM,localize:PM,match:ZM,options:{weekStartsOn:0,firstWeekContainsDate:1}};function $M(e,t){let n=rM(e,t?.in),r=fM(n,gM(n)),i=r+1;return i}function eN(e,t){let n=rM(e,t?.in),r=sM(n)-+pM(n);return Math.round(r/$j)+1}function tN(e,t){let n=rM(e,t?.in),r=n.getFullYear(),i=aM(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=nM(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=oM(o,t),c=nM(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=oM(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function nN(e,t){let n=aM(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=tN(e,t),a=nM(t?.in||e,0);a.setFullYear(i,0,r),a.setHours(0,0,0,0);let o=oM(a,t);return o}function rN(e,t){let n=rM(e,t?.in),r=oM(n,t)-+nN(n,t);return Math.round(r/$j)+1}function iN(e,t){let n=e<0?`-`:``,r=Math.abs(e).toString().padStart(t,`0`);return n+r}const aN={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return iN(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):iN(n+1,2)},d(e,t){return iN(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 iN(e.getHours()%12||12,t.length)},H(e,t){return iN(e.getHours(),t.length)},m(e,t){return iN(e.getMinutes(),t.length)},s(e,t){return iN(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*10**(n-3));return iN(i,t.length)}},oN={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},sN={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 aN.y(e,t)},Y:function(e,t,n,r){let i=tN(e,r),a=i>0?i:1-i;if(t===`YY`){let e=a%100;return iN(e,2)}return t===`Yo`?n.ordinalNumber(a,{unit:`year`}):iN(a,t.length)},R:function(e,t){let n=cM(e);return iN(n,t.length)},u:function(e,t){let n=e.getFullYear();return iN(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 iN(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 iN(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 aN.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 iN(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=rN(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):iN(i,t.length)},I:function(e,t,n){let r=eN(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):iN(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):aN.d(e,t)},D:function(e,t,n){let r=$M(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):iN(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 iN(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 iN(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 iN(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?oN.noon:r===0?oN.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?oN.evening:r>=12?oN.afternoon:r>=4?oN.morning:oN.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 aN.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):aN.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):iN(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):iN(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):aN.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):aN.s(e,t)},S:function(e,t){return aN.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return lN(r);case`XXXX`:case`XX`:return uN(r);case`XXXXX`:case`XXX`:default:return uN(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return lN(r);case`xxxx`:case`xx`:return uN(r);case`xxxxx`:case`xxx`:default:return uN(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+cN(r,`:`);case`OOOO`:default:return`GMT`+uN(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+cN(r,`:`);case`zzzz`:default:return`GMT`+uN(r,`:`)}},t:function(e,t,n){let r=Math.trunc(e/1e3);return iN(r,t.length)},T:function(e,t,n){return iN(+e,t.length)}};function cN(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+iN(a,2)}function lN(e,t){if(e%60==0){let t=e>0?`-`:`+`;return t+iN(Math.abs(e)/60,2)}return uN(e,t)}function uN(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=iN(Math.trunc(r/60),2),a=iN(r%60,2);return n+i+t+a}const dN=(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`})}},fN=(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`})}},pN=(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return dN(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}}`,dN(r,t)).replace(`{{time}}`,fN(i,t))},mN={p:fN,P:pN},hN=/^D+$/,gN=/^Y+$/,_N=[`D`,`DD`,`YY`,`YYYY`];function vN(e){return hN.test(e)}function yN(e){return gN.test(e)}function bN(e,t,n){let r=xN(e,t,n);if(console.warn(r),_N.includes(e))throw RangeError(r)}function xN(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 SN=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,CN=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,wN=/^'([^]*?)'?$/,TN=/''/g,EN=/[a-zA-Z]/;function DN(e,t,n){let r=aM(),i=n?.locale??r.locale??QM,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=rM(e,n?.in);if(!hM(s))throw RangeError(`Invalid time value`);let c=t.match(CN).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=mN[t];return n(e,i.formatLong)}return e}).join(``).match(SN).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:ON(e)};if(sN[t])return{isToken:!0,value:e};if(t.match(EN))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&&yN(a)||!n?.useAdditionalDayOfYearTokens&&vN(a))&&bN(a,t,String(e));let o=sN[a[0]];return o(s,a,i.localize,l)}).join(``)}function ON(e){let t=e.match(wN);return t?t[1].replace(TN,`'`):e}function kN(e,t){return rM(e*1e3,t?.in)}function AN(e,t){let n=jN(t)?new t(0):nM(t,0);return n.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),n.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),n}function jN(e){return typeof e==`function`&&e.prototype?.constructor===e}function MN(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 NN(e){return e==null}function PN(e){return e!=null}async function FN(){if(typeof window<`u`&&window!==null)return`browser`;try{let e=await T(()=>import(`./__vite-browser-external-DAzMqf4J.js`).then(Lt(1)),__vite__mapDeps([0,1,2]));return e!==void 0&&e.versions!=null&&e.versions.node!=null?`node`:`unknown`}catch{return`unknown`}}function IN(e){return NN(e)?!1:G.isInt(e.type)&&!HN(e)||LN(e)}function LN(e){return NN(e)?!1:G.isInt(e.type)&&e.type.isSigned===!1}function RN(e){return NN(e)?!1:G.isFloat(e.type)??!1}function zN(e){return NN(e)?!1:G.isDecimal(e.type)}function BN(e){return NN(e)?!1:G.isBool(e.type)}function VN(e){return NN(e)?!1:G.isDuration(e.type)}function HN(e){return NN(e)?!1:G.isInt(e.type)&&e.metadata.get(`ARROW:extension:name`)===`period`}function UN(e){return NN(e)?!1:G.isTimestamp(e.type)}function WN(e){return NN(e)?!1:G.isDate(e.type)}function GN(e){return NN(e)?!1:G.isTime(e.type)}function KN(e){return NN(e)?!1:G.isList(e.type)||G.isFixedSizeList(e.type)}function qN(e){return NN(e)?!1:G.isStruct(e.type)||G.isMap(e.type)}function JN(e){return NN(e)?!1:G.isStruct(e.type)&&e.metadata.get(`ARROW:extension:name`)===`interval`||G.isInterval(e.type)}function YN(e,t){let n;if(t===XE.MILLISECOND)n=1e3;else if(t===XE.MICROSECOND)n=1e3*1e3;else if(t===XE.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 XN(e,t){let n=YN(e,t?.type?.unit??XE.SECOND);return kN(n)}function ZN(e,t){let n=XN(e,t);return DN(n,n.getMilliseconds()===0?`HH:mm:ss`:`HH:mm:ss.SSS`)}function QN(e){return e instanceof Date||typeof e==`number`&&Number.isFinite(e)?DN(e,`yyyy-MM-dd`):(console.warn(`Unsupported date value: ${e}`),String(e))}function $N(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 GT(e,r):new GT(e),AN(n,Date)}function eP(e,t){let n=t?.type?.scale||0,r=Qj.bigNumToString(new Qj.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=MN(r.slice(-n),`0`)||``;return`${i}${a}${o?`.${o}`:``}`}new Intl.NumberFormat(`en-US`,{style:`decimal`,maximumFractionDigits:4,minimumFractionDigits:4,useGrouping:!0});function tP(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 nP(e,t){if(G.isInterval(t?.type))return tP(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=iP(i.left,t.type?.children?.[0]),c=iP(i.right,t.type?.children?.[1]);return`${a+s}, ${c+o}`}return String(e)}function rP(e,t){return t?.type instanceof uO?JSON.parse(JSON.stringify(e,(e,t)=>{if(PN(t))return typeof t==`bigint`?Number(t):t})):JSON.parse(JSON.stringify(e,(e,t)=>typeof t==`bigint`?Number(t):t))}function iP(e,t){if(NN(e))return null;let n=e instanceof Date||Number.isFinite(e);if(n&&WN(t))return QN(e);if(typeof e==`bigint`&&GN(t))return ZN(Number(e),t);if(n&&UN(t))return $N(e,t);if(HN(t))throw Error(`Period type is not supported yet`);if(JN(t))return nP(e,t);if(VN(t))throw Error(`Duration type is not supported yet`);return zN(t)?eP(e,t):RN(t)&&Number.isFinite(e)||IN(t)?e:qN(t)||KN(t)?rP(e,t):BN(t)?!!e:String(e)}function aP(e){let t=(e.toArray()||[]).map(e=>e.toJSON())||[],n=t.map(t=>(e.schema.fields.forEach(e=>t[e.name]=iP(t[e.name],e)),t));return n}let oP=function(e){return e.ORIGIN_PRIVATE_FS=`origin-private-fs`,e.NODE_FS=`node-fs`,e}({});async function sP(e){let t=h(e,{logger:!1}),n,r,i=await FN();if(i===`browser`){if(t.bundles===void 0){let{getBundles:e}=await T(async()=>{let{getBundles:e}=await import(`./default-browser-DBEOGewc.js`);return{getBundles:e}},[]);t.bundles=await e()}r=await zT(await t.bundles),n=new Worker(r.mainWorker)}else if(i===`node`){if(t.bundles===void 0){let{getBundles:e}=await T(async()=>{let{getBundles:e}=await import(`./default-node-KCowvLjx.js`);return{getBundles:e}},__vite__mapDeps([3,1,2]));t.bundles=await e()}r=await zT(await t.bundles);let e=r.mainWorker;e.startsWith(`/@fs/`)&&(e=e.replace(`/@fs/`,`file://`));let i=await T(()=>import(`./browser-BADqPKKy.js`),[]);n=new i.default(e,{type:`module`})}else throw Error(`Unsupported environment: ${i}`);let a;a=t.logger===!0?new fT:t.logger===!1?new dT:t.logger;let o=new CT(a,n);if(await o.instantiate(r.mainModule,r.pthreadWorker),t.storage)switch(t.storage.type){case oP.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 oP.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:aP(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:aP(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 cP(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 lP(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 X=Symbol.for(`drizzle:entityKind`);function Z(e,t){if(!e||typeof e!=`object`)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,X))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(X in n&&n[X]===t[X])return!0;n=Object.getPrototypeOf(n)}return!1}var uP=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[X]=`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`}},dP=class{static[X]=`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 fP=Symbol.for(`drizzle:Name`);var pP=class{static[X]=`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 mP(e,this)}},mP=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[X]=`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[fP],...r,n[0].table[fP],...i];return e??`${a.join(`_`)}_fk`}};function hP(e,...t){return e(...t)}function gP(e,t){return`${e[fP]}_${t.join(`_`)}_unique`}function _P(e,t,n){for(let r=t;rArray.isArray(e)?bP(e):typeof e==`string`?`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`:`${e}`).join(`,`)}}`}var xP=class extends dP{foreignKeyConfigs=[];static[X]=`PgColumnBuilder`;array(e){return new wP(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})=>hP((n,r)=>{let i=new pP(()=>{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 CP(e,this.config)}},SP=class extends uP{constructor(e,t){t.uniqueName||=gP(e,[t.name]),super(e,t),this.table=e}static[X]=`PgColumn`},CP=class extends SP{static[X]=`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}},wP=class extends xP{static[X]=`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 TP(e,this.config,t)}},TP=class e extends SP{constructor(e,t,n,r){super(e,t),this.baseColumn=n,this.range=r,this.size=t.size}size;static[X]=`PgArray`;getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==`number`?this.size:``}]`}mapFromDriverValue(e){return typeof e==`string`&&(e=yP(e)),e.map(e=>this.baseColumn.mapFromDriverValue(e))}mapToDriverValue(t,n=!1){let r=t.map(t=>t===null?null:Z(this.baseColumn,e)?this.baseColumn.mapToDriverValue(t,!0):this.baseColumn.mapToDriverValue(t));return n?r:bP(r)}};const EP=Symbol.for(`drizzle:isPgEnum`);function DP(e){return!!e&&typeof e==`function`&&EP in e&&e[EP]===!0}var OP=class{static[X]=`Subquery`;constructor(e,t,n,r=!1,i=[]){this._={brand:`Subquery`,sql:e,selectedFields:t,alias:n,isWith:r,usedTables:i}}},kP=class extends OP{static[X]=`WithSubquery`};const AP={startActiveSpan(e,t){return t()}},jP=Symbol.for(`drizzle:ViewBaseConfig`),MP=Symbol.for(`drizzle:Schema`),NP=Symbol.for(`drizzle:Columns`),PP=Symbol.for(`drizzle:ExtraConfigColumns`),FP=Symbol.for(`drizzle:OriginalName`),IP=Symbol.for(`drizzle:BaseName`),LP=Symbol.for(`drizzle:IsAlias`),RP=Symbol.for(`drizzle:ExtraConfigBuilder`),zP=Symbol.for(`drizzle:IsDrizzleTable`);var Q=class{static[X]=`Table`;static Symbol={Name:fP,Schema:MP,OriginalName:FP,Columns:NP,ExtraConfigColumns:PP,BaseName:IP,IsAlias:LP,ExtraConfigBuilder:RP};[fP];[FP];[MP];[NP];[PP];[IP];[LP]=!1;[zP]=!0;[RP]=void 0;constructor(e,t,n){this[fP]=this[FP]=e,this[MP]=t,this[IP]=n}};function BP(e){return e[fP]}function VP(e){return`${e[MP]??`public`}.${e[fP]}`}function HP(e){return e!=null&&typeof e.getSQL==`function`}function UP(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 WP=class{static[X]=`StringChunk`;value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new GP([this])}},GP=class e{constructor(e){this.queryChunks=e;for(let t of e)if(Z(t,Q)){let e=t[Q.Symbol.Schema];this.usedTables.push(e===void 0?t[Q.Symbol.Name]:e+`.`+t[Q.Symbol.Name])}}static[X]=`SQL`;decoder=JP;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return AP.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 UP(t.map(t=>{if(Z(t,WP))return{sql:t.value.join(``),params:[]};if(Z(t,KP))return{sql:a(t.value),params:[]};if(t===void 0)return{sql:``,params:[]};if(Array.isArray(t)){let e=[new WP(`(`)];for(let[n,r]of t.entries())e.push(r),ne},YP={mapToDriverValue:e=>e};({...JP,...YP});var XP=class{constructor(e,t=YP){this.value=e,this.encoder=t}static[X]=`Param`;brand;getSQL(){return new GP([this])}};function $(e,...t){let n=[];(t.length>0||e.length>0&&e[0]!==``)&&n.push(new WP(e[0]));for(let[r,i]of t.entries())n.push(i,new WP(e[r+1]));return new GP(n)}(e=>{function t(){return new GP([])}e.empty=t;function n(e){return new GP(e)}e.fromList=n;function r(e){return new GP([new WP(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 GP(n)}e.join=i;function a(e){return new KP(e)}e.identifier=a;function o(e){return new ZP(e)}e.placeholder=o;function s(e,t){return new XP(e,t)}e.param=s})($||={}),(e=>{class t{constructor(e,t){this.sql=e,this.fieldAlias=t}static[X]=`SQL.Aliased`;isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(GP||={});var ZP=class{constructor(e){this.name=e}static[X]=`Placeholder`;getSQL(){return new GP([this])}};function QP(e,t){return e.map(e=>{if(Z(e,ZP)){if(!(e.name in t))throw Error(`No value for placeholder "${e.name}" was provided`);return t[e.name]}if(Z(e,XP)&&Z(e.value,ZP)){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 $P=Symbol.for(`drizzle:IsDrizzleView`);var eF=class{static[X]=`View`;[jP];[$P]=!0;constructor({name:e,schema:t,selectedFields:n,query:r}){this[jP]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new GP([this])}};uP.prototype.getSQL=function(){return new GP([this])},Q.prototype.getSQL=function(){return new GP([this])},OP.prototype.getSQL=function(){return new GP([this])};var tF=class{constructor(e){this.table=e}static[X]=`ColumnAliasProxyHandler`;get(e,t){return t===`table`?this.table:e[t]}},nF=class{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static[X]=`TableAliasProxyHandler`;get(e,t){if(t===Q.Symbol.IsAlias)return!0;if(t===Q.Symbol.Name||this.replaceOriginalName&&t===Q.Symbol.OriginalName)return this.alias;if(t===jP)return{...e[jP],name:this.alias,isAlias:!0};if(t===Q.Symbol.Columns){let t=e[Q.Symbol.Columns];if(!t)return t;let n={};return Object.keys(t).map(r=>{n[r]=new Proxy(t[r],new tF(new Proxy(e,this)))}),n}let n=e[t];return Z(n,uP)?new Proxy(n,new tF(new Proxy(e,this))):n}};function rF(e,t){return new Proxy(e,new nF(t,!1))}function iF(e,t){return new Proxy(e,new tF(new Proxy(e.table,new nF(t,!1))))}function aF(e,t){return new GP.Aliased(oF(e.sql,t),e.fieldAlias)}function oF(e,t){return $.join(e.queryChunks.map(e=>Z(e,uP)?iF(e,t):Z(e,GP)?oF(e,t):Z(e,GP.Aliased)?aF(e,t):e))}var sF=class extends Error{static[X]=`DrizzleError`;constructor({message:e,cause:t}){super(e),this.name=`DrizzleError`,this.cause=t}},cF=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)}},lF=class extends sF{static[X]=`TransactionRollbackError`;constructor(){super({message:`Rollback`})}},uF=class{static[X]=`ConsoleLogWriter`;write(e){console.log(e)}},dF=class{static[X]=`DefaultLogger`;writer;constructor(e){this.writer=e?.writer??new uF}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}`)}},fF=class{static[X]=`NoopLogger`;logQuery(){}},pF=class{static[X]=`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 mF(e,t){return Object.entries(e).reduce((e,[n,r])=>{if(typeof n!=`string`)return e;let i=t?[...t,n]:[n];return Z(r,uP)||Z(r,GP)||Z(r,GP.Aliased)?e.push({path:i,field:r}):Z(r,Q)?e.push(...mF(r[Q.Symbol.Columns],i)):e.push(...mF(r,i)),e},[])}function hF(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 gF(e,t){let n=Object.entries(t).filter(([,e])=>e!==void 0).map(([t,n])=>Z(n,GP)||Z(n,uP)?[t,n]:[t,new XP(n,e[Q.Symbol.Columns][t])]);if(n.length===0)throw Error(`No values to set`);return Object.fromEntries(n)}function _F(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 vF(e){return e[Q.Symbol.Columns]}function yF(e){return Z(e,OP)?e._.alias:Z(e,eF)?e[jP].name:Z(e,GP)?void 0:e[Q.Symbol.IsAlias]?e[Q.Symbol.Name]:e[Q.Symbol.BaseName]}function bF(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 xF=class extends SP{static[X]=`PgDate`;getSQLType(){return`date`}mapFromDriverValue(e){return new Date(e)}mapToDriverValue(e){return e.toISOString()}},SF=class extends SP{static[X]=`PgDateString`;getSQLType(){return`date`}},CF=class extends SP{static[X]=`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}},wF=class extends SP{static[X]=`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}},TF=class extends SP{static[X]=`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})`}},EF=class extends SP{static[X]=`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`:``}`}},DF=class extends SP{static[X]=`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()},OF=class extends SP{static[X]=`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`:``}`}},kF=class extends SP{static[X]=`PgUUID`;getSQLType(){return`uuid`}};const AF=Symbol.for(`drizzle:PgInlineForeignKeys`),jF=Symbol.for(`drizzle:EnableRLS`);var MF=class extends Q{static[X]=`PgTable`;static Symbol=Object.assign({},Q.Symbol,{InlineForeignKeys:AF,EnableRLS:jF});[AF]=[];[jF]=!1;[Q.Symbol.ExtraConfigBuilder]=void 0;[Q.Symbol.ExtraConfigColumns]={}},NF=class{static[X]=`PgPrimaryKeyBuilder`;columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new PF(e,this.columns,this.name)}},PF=class{constructor(e,t,n){this.table=e,this.columns=t,this.name=n}static[X]=`PgPrimaryKey`;columns;name;getName(){return this.name??`${this.table[MF.Symbol.Name]}_${this.columns.map(e=>e.name).join(`_`)}_pk`}};function FF(e,t){return qP(t)&&!HP(e)&&!Z(e,XP)&&!Z(e,ZP)&&!Z(e,uP)&&!Z(e,Q)&&!Z(e,eF)?new XP(e,t):e}const IF=(e,t)=>$`${e} = ${FF(t,e)}`,LF=(e,t)=>$`${e} <> ${FF(t,e)}`;function RF(...e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new GP(t):new GP([new WP(`(`),$.join(t,new WP(` and `)),new WP(`)`)])}function zF(...e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new GP(t):new GP([new WP(`(`),$.join(t,new WP(` or `)),new WP(`)`)])}function BF(e){return $`not ${e}`}const VF=(e,t)=>$`${e} > ${FF(t,e)}`,HF=(e,t)=>$`${e} >= ${FF(t,e)}`,UF=(e,t)=>$`${e} < ${FF(t,e)}`,WF=(e,t)=>$`${e} <= ${FF(t,e)}`;function GF(e,t){return Array.isArray(t)?t.length===0?$`false`:$`${e} in ${t.map(t=>FF(t,e))}`:$`${e} in ${FF(t,e)}`}function KF(e,t){return Array.isArray(t)?t.length===0?$`true`:$`${e} not in ${t.map(t=>FF(t,e))}`:$`${e} not in ${FF(t,e)}`}function qF(e){return $`${e} is null`}function JF(e){return $`${e} is not null`}function YF(e){return $`exists ${e}`}function XF(e){return $`not exists ${e}`}function ZF(e,t,n){return $`${e} between ${FF(t,e)} and ${FF(n,e)}`}function QF(e,t,n){return $`${e} not between ${FF(t,e)} and ${FF(n,e)}`}function $F(e,t){return $`${e} like ${t}`}function eI(e,t){return $`${e} not like ${t}`}function tI(e,t){return $`${e} ilike ${t}`}function nI(e,t){return $`${e} not ilike ${t}`}function rI(e){return $`${e} asc`}function iI(e){return $`${e} desc`}var aI=class{constructor(e,t,n){this.sourceTable=e,this.referencedTable=t,this.relationName=n,this.referencedTableName=t[Q.Symbol.Name]}static[X]=`Relation`;referencedTableName;fieldName},oI=class{constructor(e,t){this.table=e,this.config=t}static[X]=`Relations`},sI=class e extends aI{constructor(e,t,n,r){super(e,t,n?.relationName),this.config=n,this.isNullable=r}static[X]=`One`;withFieldName(t){let n=new e(this.sourceTable,this.referencedTable,this.config,this.isNullable);return n.fieldName=t,n}},cI=class e extends aI{constructor(e,t,n){super(e,t,n?.relationName),this.config=n}static[X]=`Many`;withFieldName(t){let n=new e(this.sourceTable,this.referencedTable,this.config);return n.fieldName=t,n}};function lI(){return{and:RF,between:ZF,eq:IF,exists:YF,gt:VF,gte:HF,ilike:tI,inArray:GF,isNull:qF,isNotNull:JF,like:$F,lt:UF,lte:WF,ne:LF,not:BF,notBetween:QF,notExists:XF,notLike:eI,notIlike:nI,notInArray:KF,or:zF,sql:$}}function uI(){return{sql:$,asc:rI,desc:iI}}function dI(e,t){Object.keys(e).length===1&&`default`in e&&!Z(e.default,Q)&&(e=e.default);let n={},r={},i={};for(let[a,o]of Object.entries(e))if(Z(o,Q)){let e=VP(o),t=r[e];n[e]=a,i[a]={tsName:a,dbName:o[Q.Symbol.Name],schema:o[Q.Symbol.Schema],columns:o[Q.Symbol.Columns],relations:t?.relations??{},primaryKey:t?.primaryKey??[]};for(let e of Object.values(o[Q.Symbol.Columns]))e.primary&&i[a].primaryKey.push(e);let s=o[Q.Symbol.ExtraConfigBuilder]?.(o[Q.Symbol.ExtraConfigColumns]);if(s)for(let e of Object.values(s))Z(e,NF)&&i[a].primaryKey.push(...e.columns)}else if(Z(o,oI)){let e=VP(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 fI(e){return function(t,n){return new sI(e,t,n,n?.fields.reduce((e,t)=>e&&t.notNull,!0)??!1)}}function pI(e){return function(t,n){return new cI(e,t,n)}}function mI(e,t,n){if(Z(n,sI)&&n.config)return{fields:n.config.fields,references:n.config.references};let r=t[VP(n.referencedTable)];if(!r)throw Error(`Table "${n.referencedTable[Q.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[VP(a)];if(!o)throw Error(`Table "${a[Q.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[Q.Symbol.Name]}". Please specify relation name`);if(s[0]&&Z(s[0],sI)&&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 hI(e){return{one:fI(e),many:pI(e)}}function gI(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]=Z(r,sI)?l&&gI(e,e[s.relationTableTsKey],l,s.selection,i):l.map(t=>gI(e,e[s.relationTableTsKey],t,s.selection,i))}else{let e=i(n[o]),t=s.field,r;r=Z(t,uP)?t:Z(t,GP)?t.decoder:t.sql.decoder,a[s.tsKey]=e===null?null:r.mapFromDriverValue(e)}return a}var _I=class e{static[X]=`SelectionProxyHandler`;config;constructor(e){this.config={...e}}get(t,n){if(n===`_`)return{...t._,selectedFields:new Proxy(t._.selectedFields,this)};if(n===jP)return{...t[jP],selectedFields:new Proxy(t[jP].selectedFields,this)};if(typeof n==`symbol`)return t[n];let r=Z(t,OP)?t._.selectedFields:Z(t,eF)?t[jP].selectedFields:t,i=r[n];if(Z(i,GP.Aliased)){if(this.config.sqlAliasedBehavior===`sql`&&!i.isSelectionField)return i.sql;let e=i.clone();return e.isSelectionField=!0,e}if(Z(i,GP)){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 Z(i,uP)?this.config.alias?new Proxy(i,new tF(new Proxy(i.table,new nF(this.config.alias,this.config.replaceOriginalName??!1)))):i:typeof i!=`object`||!i?i:new Proxy(i,new e(this.config))}};function vI(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 yI(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 bI(e){return e}var xI=class{static[X]=`CasingCache`;cache={};cachedTables={};convert;constructor(e){this.convert=e===`snake_case`?vI:e===`camelCase`?yI:bI}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[Q.Symbol.Schema]??`public`,n=e.table[Q.Symbol.OriginalName],r=`${t}.${n}.${e.name}`;return this.cache[r]||this.cacheTable(e.table),this.cache[r]}cacheTable(e){let t=e[Q.Symbol.Schema]??`public`,n=e[Q.Symbol.OriginalName],r=`${t}.${n}`;if(!this.cachedTables[r]){for(let t of Object.values(e[Q.Symbol.Columns])){let e=`${r}.${t.name}`;this.cache[e]=this.convert(t.name)}this.cachedTables[r]=!0}}clearCache(){this.cache={},this.cachedTables={}}},SI=class extends eF{static[X]=`PgViewBase`},CI=class{static[X]=`PgDialect`;casing;constructor(e){this.casing=new xI(e?.casing)}async migrate(e,t,n){let r=typeof n==`string`?`__drizzle_migrations`:n.migrationsTable??`__drizzle_migrations`,i=typeof n==`string`?`drizzle`:n.migrationsSchema??`drizzle`,a=$` + CREATE TABLE IF NOT EXISTS ${$.identifier(i)}.${$.identifier(r)} ( + id SERIAL PRIMARY KEY, + hash text NOT NULL, + created_at bigint + ) + `;await t.execute($`CREATE SCHEMA IF NOT EXISTS ${$.identifier(i)}`),await t.execute(a);let o=await t.all($`select id, hash, created_at from ${$.identifier(i)}.${$.identifier(r)} order by created_at desc limit 1`),s=o[0];await t.transaction(async t=>{for await(let n of e)if(!s||Number(s.created_at)t[e]!==void 0||n[e]?.onUpdateFn!==void 0),i=r.length;return $.join(r.flatMap((e,r)=>{let a=n[e],o=t[e]??$.param(a.onUpdateFn(),a),s=$`${$.identifier(this.casing.getColumnCasing(a))} = ${o}`;return r{let i=[];if(Z(e,GP.Aliased)&&e.isSelectionField)i.push($.identifier(e.fieldAlias));else if(Z(e,GP.Aliased)||Z(e,GP)){let n=Z(e,GP.Aliased)?e.sql:e;t?i.push(new GP(n.queryChunks.map(e=>Z(e,SP)?$.identifier(this.casing.getColumnCasing(e)):e))):i.push(n),Z(e,GP.Aliased)&&i.push($` as ${$.identifier(e.fieldAlias)}`)}else Z(e,uP)&&(t?i.push($.identifier(this.casing.getColumnCasing(e))):i.push(e));return ro?.some(({alias:t})=>t===(e[Q.Symbol.IsAlias]?BP(e):e[Q.Symbol.BaseName])))(e.field.table)){let t=BP(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,g=this.buildWithCTE(e),_;f&&(_=f===!0?$` distinct`:$` distinct on (${$.join(f.on,$`, `)})`);let v=this.buildSelection(m,{isSingleTable:h}),y=this.buildFromTable(a),b=this.buildJoins(o),x=r?$` where ${r}`:void 0,S=i?$` having ${i}`:void 0,C;s&&s.length>0&&(C=$` order by ${$.join(s,$`, `)}`);let w;c&&c.length>0&&(w=$` group by ${$.join(c,$`, `)}`);let T=typeof l==`object`||typeof l==`number`&&l>=0?$` limit ${l}`:void 0,E=u?$` offset ${u}`:void 0,D=$.empty();if(d){let e=$` for ${$.raw(d.strength)}`;d.config.of&&e.append($` of ${$.join(Array.isArray(d.config.of)?d.config.of:[d.config.of],$`, `)}`),d.config.noWait?e.append($` nowait`):d.config.skipLocked&&e.append($` skip locked`),D.append(e)}let O=$`${g}select${_} ${v} from ${y}${b}${x}${w}${S}${C}${T}${E}${D}`;return p.length>0?this.buildSetOperations(O,p):O}buildSetOperations(e,t){let[n,...r]=t;if(!n)throw Error(`Cannot pass undefined values to any set operator`);return r.length===0?this.buildSetOperationQuery({leftSelect:e,setOperator:n}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:n}),r)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:n,rightSelect:r,limit:i,orderBy:a,offset:o}}){let s=$`(${e.getSQL()}) `,c=$`(${r.getSQL()})`,l;if(a&&a.length>0){let e=[];for(let t of a)if(Z(t,SP))e.push($.identifier(t.name));else if(Z(t,GP)){for(let e=0;e=0?$` limit ${i}`:void 0,d=$.raw(`${t} ${n?`all `:``}`),f=o?$` offset ${o}`:void 0;return $`${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[Q.Symbol.Columns],l=Object.entries(c).filter(([e,t])=>!t.shouldDisableInsert()),u=l.map(([,e])=>$.identifier(this.casing.getColumnCasing(e)));if(a){let e=t;Z(e,GP)?s.push(e):s.push(e.getSQL())}else{let e=t;s.push($.raw(`values `));for(let[t,n]of e.entries()){let r=[];for(let[e,t]of l){let i=n[e];if(i===void 0||Z(i,XP)&&i.value===void 0)if(t.defaultFn!==void 0){let e=t.defaultFn(),n=Z(e,GP)?e:$.param(e,t);r.push(n)}else if(!t.default&&t.onUpdateFn!==void 0){let e=t.onUpdateFn(),n=Z(e,GP)?e:$.param(e,t);r.push(n)}else r.push($`default`);else r.push(i)}s.push(r),t({dbKey:t.name,tsKey:e,field:iF(t,o),relationTableTsKey:void 0,isJson:!1,selection:[]}))}else{let r=Object.fromEntries(Object.entries(i.columns).map(([e,t])=>[e,iF(t,o)]));if(a.where){let e=typeof a.where==`function`?a.where(r,lI()):a.where;p=e&&oF(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 g;if(a.extras){g=typeof a.extras==`function`?a.extras(r,{sql:$}):a.extras;for(let[e,t]of Object.entries(g))s.push({tsKey:e,value:aF(t,o)})}for(let{tsKey:e,value:t}of s)l.push({dbKey:Z(t,GP.Aliased)?t.fieldAlias:i.columns[e].name,tsKey:e,field:Z(t,uP)?iF(t,o):t,relationTableTsKey:void 0,isJson:!1,selection:[]});let _=typeof a.orderBy==`function`?a.orderBy(r,uI()):a.orderBy??[];Array.isArray(_)||(_=[_]),f=_.map(e=>Z(e,uP)?iF(e,o):oF(e,o)),u=a.limit,d=a.offset;for(let{tsKey:r,queryConfig:i,relation:a}of h){let s=mI(t,n,a),c=VP(a.referencedTable),u=n[c],d=`${o}_${r}`,f=RF(...s.fields.map((e,t)=>IF(iF(s.references[t],d),iF(e,o)))),p=this.buildRelationalQueryWithoutPK({fullSchema:e,schema:t,tableNamesMap:n,table:e[u],tableConfig:t[u],queryConfig:Z(a,sI)?i===!0?{limit:1}:{...i,limit:1}:i,tableAlias:d,joinOn:f,nestedQueryRelation:a}),h=$`${$.identifier(d)}.${$.identifier(`data`)}`.as(r);m.push({on:$`true`,table:new OP(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 sF({message:`No fields selected for table "${i.tsName}" ("${o}")`});let h;if(p=RF(c,p),s){let e=$`json_build_array(${$.join(l.map(({field:e,tsKey:t,isJson:n})=>n?$`${$.identifier(`${o}_${t}`)}.${$.identifier(`data`)}`:Z(e,GP.Aliased)?e.sql:e),$`, `)})`;Z(s,cI)&&(e=$`coalesce(json_agg(${e}${f.length>0?$` order by ${$.join(f,$`, `)}`: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:rF(r,o),fields:{},fieldsFlat:[{path:[],field:$.raw(`*`)}],where:p,limit:u,offset:d,orderBy:f,setOperators:[]}),p=void 0,u=void 0,d=void 0,f=[]):h=rF(r,o),h=this.buildSelectQuery({table:Z(h,MF)?h:new OP(h,{},o),fields:{},fieldsFlat:t.map(({field:e})=>({path:[],field:Z(e,uP)?iF(e,o):e})),joins:m,where:p,limit:u,offset:d,orderBy:f,setOperators:[]})}else h=this.buildSelectQuery({table:rF(r,o),fields:{},fieldsFlat:l.map(({field:e})=>({path:[],field:Z(e,uP)?iF(e,o):e})),joins:m,where:p,limit:u,offset:d,orderBy:f,setOperators:[]});return{tableTsKey:i.tsName,sql:h,selection:l}}},wI=class{static[X]=`TypedQueryBuilder`;getSelectedFields(){return this._.selectedFields}},TI=class{static[X]=`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:Z(n,OP)?Object.fromEntries(Object.keys(n._.selectedFields).map(e=>[e,n[e]])):Z(n,SI)?n[jP].selectedFields:Z(n,GP)?{}:vF(n),new DI({table:n,fields:r,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}},EI=class extends wI{static[X]=`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=yF(e),this.joinsNotNullableMap=typeof this.tableName==`string`?{[this.tableName]:!0}:{};for(let t of LI(e))this.usedTables.add(t)}getUsedTables(){return[...this.usedTables]}createJoin(e,t){return(n,r)=>{let i=this.tableName,a=yF(n);for(let e of LI(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`&&!Z(n,GP))){let e=Z(n,OP)?n._.selectedFields:Z(n,eF)?n[jP].selectedFields:n[Q.Symbol.Columns];this.config.fields[a]=e}if(typeof r==`function`&&(r=r(new Proxy(this.config.fields,new _I({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(kI()):n;if(!hF(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 _I({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))),this.config.where=e,this}having(e){return typeof e==`function`&&(e=e(new Proxy(this.config.fields,new _I({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 _I({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 _I({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(...LI(this.config.table)),this.config.joins)for(let e of this.config.joins)t.push(...LI(e.table));return new Proxy(new OP(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new _I({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`}))}getSelectedFields(){return new Proxy(this.config.fields,new _I({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}},DI=class extends EI{static[X]=`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 AP.startActiveSpan(`drizzle.prepareQuery`,()=>{let n=mF(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=>AP.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken))};_F(DI,[pF]);function OI(e,t){return(n,r,...i)=>{let a=[r,...i].map(n=>({type:e,isAll:t,rightSelect:n}));for(let e of a)if(!hF(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 kI=()=>({union:AI,unionAll:jI,intersect:MI,intersectAll:NI,except:PI,exceptAll:FI}),AI=OI(`union`,!1),jI=OI(`union`,!0),MI=OI(`intersect`,!1),NI=OI(`intersect`,!0),PI=OI(`except`,!1),FI=OI(`except`,!0);var II=class{static[X]=`PgQueryBuilder`;dialect;dialectConfig;constructor(e){this.dialect=Z(e,CI)?e:void 0,this.dialectConfig=Z(e,CI)?void 0:e}$with=(e,t)=>{let n=this,r=r=>(typeof r==`function`&&(r=r(n)),new Proxy(new kP(r.getSQL(),t??(`getSelectedFields`in r?r.getSelectedFields()??{}:{}),e,!0),new _I({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`})));return{as:r}};with(...e){let t=this;function n(n){return new TI({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function r(e){return new TI({fields:e??void 0,session:void 0,dialect:t.getDialect(),distinct:!0})}function i(e,n){return new TI({fields:n??void 0,session:void 0,dialect:t.getDialect(),distinct:{on:e}})}return{select:n,selectDistinct:r,selectDistinctOn:i}}select(e){return new TI({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new TI({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn(e,t){return new TI({fields:t??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:e}})}getDialect(){return this.dialect||=new CI(this.dialectConfig),this.dialect}};function LI(e){return Z(e,MF)?[e[MP]?`${e[MP]}.${e[Q.Symbol.BaseName]}`:e[Q.Symbol.BaseName]]:Z(e,OP)?e._.usedTables??[]:Z(e,GP)?e.usedTables??[]:[]}var RI=class extends pF{constructor(e,t,n,r){super(),this.session=t,this.dialect=n,this.config={table:e,withList:r}}static[X]=`PgDelete`;config;cacheConfig;where(e){return this.config.where=e,this}returning(e=this.config.table[Q.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=mF(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return AP.startActiveSpan(`drizzle.prepareQuery`,()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:`delete`,tables:LI(this.config.table)},this.cacheConfig))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>AP.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken));getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new _I({alias:BP(this.config.table),sqlAliasedBehavior:`alias`,sqlBehavior:`error`})):void 0}$dynamic(){return this}},zI=class{constructor(e,t,n,r,i){this.table=e,this.session=t,this.dialect=n,this.withList=r,this.overridingSystemValue_=i}static[X]=`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[Q.Symbol.Columns];for(let r of Object.keys(e)){let i=e[r];t[r]=Z(i,GP)?i:new XP(i,n[r])}return t});return new BI(this.table,t,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select(e){let t=typeof e==`function`?e(new II):e;if(!Z(t,GP)&&!hF(this.table[NP],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 BI(this.table,t,this.session,this.dialect,this.withList,!0)}},BI=class extends pF{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[X]=`PgInsert`;config;cacheConfig;returning(e=this.config.table[Q.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=mF(e),this}onConflictDoNothing(e={}){if(e.target===void 0)this.config.onConflict=$`do nothing`;else{let t=``;t=Array.isArray(e.target)?e.target.map(e=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(e))).join(`,`):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target));let n=e.where?$` where ${e.where}`:void 0;this.config.onConflict=$`(${$.raw(t)})${n} do nothing`}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw Error(`You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.`);let t=e.where?$` where ${e.where}`:void 0,n=e.targetWhere?$` where ${e.targetWhere}`:void 0,r=e.setWhere?$` where ${e.setWhere}`:void 0,i=this.dialect.buildUpdateSet(this.config.table,gF(this.config.table,e.set)),a=``;return a=Array.isArray(e.target)?e.target.map(e=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(e))).join(`,`):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target)),this.config.onConflict=$`(${$.raw(a)})${n} do update set ${i}${t}${r}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return AP.startActiveSpan(`drizzle.prepareQuery`,()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:`insert`,tables:LI(this.config.table)},this.cacheConfig))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>AP.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken));getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new _I({alias:BP(this.config.table),sqlAliasedBehavior:`alias`,sqlBehavior:`error`})):void 0}$dynamic(){return this}},VI=class extends pF{constructor(e,t,n){super(),this.session=t,this.dialect=n,this.config={view:e}}static[X]=`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 AP.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=>AP.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken))},HI=class{constructor(e,t,n,r){this.table=e,this.session=t,this.dialect=n,this.withList=r}static[X]=`PgUpdateBuilder`;authToken;setToken(e){return this.authToken=e,this}set(e){return new UI(this.table,gF(this.table,e),this.session,this.dialect,this.withList).setToken(this.authToken)}},UI=class extends pF{constructor(e,t,n,r,i){super(),this.session=n,this.dialect=r,this.config={set:t,table:e,withList:i,joins:[]},this.tableName=yF(e),this.joinsNotNullableMap=typeof this.tableName==`string`?{[this.tableName]:!0}:{}}static[X]=`PgUpdate`;config;tableName;joinsNotNullableMap;cacheConfig;from(e){let t=e,n=yF(t);return typeof n==`string`&&(this.joinsNotNullableMap[n]=!0),this.config.from=t,this}getTableLikeFields(e){return Z(e,MF)?e[Q.Symbol.Columns]:Z(e,OP)?e._.selectedFields:e[jP].selectedFields}createJoin(e){return(t,n)=>{let r=yF(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&&!Z(this.config.from,GP)?this.getTableLikeFields(this.config.from):void 0;n=n(new Proxy(this.config.table[Q.Symbol.Columns],new _I({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})),e&&new Proxy(e,new _I({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[Q.Symbol.Columns]),this.config.from)){let t=yF(this.config.from);if(typeof t==`string`&&this.config.from&&!Z(this.config.from,GP)){let n=this.getTableLikeFields(this.config.from);e[t]=n}for(let t of this.config.joins){let n=yF(t.table);if(typeof n==`string`&&!Z(t.table,GP)){let r=this.getTableLikeFields(t.table);e[n]=r}}}return this.config.returningFields=e,this.config.returning=mF(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:LI(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 _I({alias:BP(this.config.table),sqlAliasedBehavior:`alias`,sqlBehavior:`error`})):void 0}$dynamic(){return this}},WI=class e extends GP{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[X]=`PgCountBuilder`;[Symbol.toStringTag]=`PgCountBuilder`;session;static buildEmbeddedCount(e,t){return $`(select count(*) from ${e}${$.raw(` where `).if(t)}${t})`}static buildCount(e,t){return $`select count(*) as count from ${e}${$.raw(` where `).if(t)}${t};`}setToken(e){return this.token=e,this}then(e,t){return Promise.resolve(this.session.count(this.sql,this.token)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}},GI=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[X]=`PgRelationalQueryBuilder`;findMany(e){return new KI(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},`many`)}findFirst(e){return new KI(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},`first`)}},KI=class extends pF{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[X]=`PgRelationalQuery`;_prepare(e){return AP.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=>gI(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 AP.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(void 0,this.authToken))}},qI=class extends pF{constructor(e,t,n,r){super(),this.execute=e,this.sql=t,this.query=n,this.mapBatchResult=r}static[X]=`PgRaw`;getSQL(){return this.sql}getQuery(){return this.query}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}},JI=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 GI(n.fullSchema,this._.schema,this._.tableNamesMap,n.fullSchema[r],i,e,t);this.$cache={invalidate:async e=>{}}}static[X]=`PgDatabase`;query;$with=(e,t)=>{let n=this,r=r=>(typeof r==`function`&&(r=r(new II(n.dialect))),new Proxy(new kP(r.getSQL(),t??(`getSelectedFields`in r?r.getSelectedFields()??{}:{}),e,!0),new _I({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`})));return{as:r}};$count(e,t){return new WI({source:e,filters:t,session:this.session})}$cache;with(...e){let t=this;function n(n){return new TI({fields:n??void 0,session:t.session,dialect:t.dialect,withList:e})}function r(n){return new TI({fields:n??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})}function i(n,r){return new TI({fields:r??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:{on:n}})}function a(n){return new HI(n,t.session,t.dialect,e)}function o(n){return new zI(n,t.session,t.dialect,e)}function s(n){return new RI(n,t.session,t.dialect,e)}return{select:n,selectDistinct:r,selectDistinctOn:i,update:a,insert:o,delete:s}}select(e){return new TI({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new TI({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn(e,t){return new TI({fields:t??void 0,session:this.session,dialect:this.dialect,distinct:{on:e}})}update(e){return new HI(e,this.session,this.dialect)}insert(e){return new zI(e,this.session,this.dialect)}delete(e){return new RI(e,this.session,this.dialect)}refreshMaterializedView(e){return new VI(e,this.session,this.dialect)}authToken;execute(e){let t=typeof e==`string`?$.raw(e):e.getSQL(),n=this.dialect.sqlToQuery(t),r=this.session.prepareQuery(n,void 0,void 0,!1);return new qI(()=>r.execute(void 0,this.authToken),t,n,e=>r.mapResult(e,!0))}transaction(e,t){return this.session.transaction(e,t)}},YI=class{static[X]=`Cache`},XI=class extends YI{strategy(){return`all`}static[X]=`NoopCache`;async get(e){}async put(e,t,n,r){}async onMutate(e){}};async function ZI(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 QI=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[X]=`PgPreparedQuery`;joinsNotNullableMap;async queryWithCache(e,t,n){if(this.cache===void 0||Z(this.cache,XI)||this.queryMetadata===void 0)try{return await n()}catch(n){throw new cF(e,t,n)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await n()}catch(n){throw new cF(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 cF(e,t,n)}if(!this.cacheConfig)try{return await n()}catch(n){throw new cF(e,t,n)}if(this.queryMetadata.type===`select`){let r=await this.cache.get(this.cacheConfig.tag??await ZI(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 cF(e,t,n)}return await this.cache.put(this.cacheConfig.tag??await ZI(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 cF(e,t,n)}}},$I=class{constructor(e){this.dialect=e}static[X]=`PgSession`;execute(e,t){return AP.startActiveSpan(`drizzle.operation`,()=>{let n=AP.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)}},eL=class extends JI{constructor(e,t,n,r=0){super(e,t,n),this.schema=n,this.nestedIndex=r}static[X]=`PgTransaction`;rollback(){throw new lF}getTransactionConfigSQL(e){let t=[];return e.isolationLevel&&t.push(`isolation level ${e.isolationLevel}`),e.accessMode&&t.push(e.accessMode),typeof e.deferrable==`boolean`&&t.push(e.deferrable?`deferrable`:`not deferrable`),$.raw(t.join(` `))}setTransaction(e){return this.session.execute($`set transaction ${this.getTransactionConfigSQL(e)}`)}};function tL(e){return typeof e==`string`&&/^true$/i.test(e)}function nL(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&&tL(r)&&(t.logger=!0);let i=n.searchParams.get(`storage`);switch(i){case oP.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:oP.ORIGIN_PRIVATE_FS,path:n.pathname.startsWith(`/`)?n.pathname.slice(1):n.pathname,...e&&tL(e)&&{accessMode:aT.READ_WRITE}};break}case null:break;default:console.warn(`Unknown storage type "${i}"`);break}return t}var rL=class extends QI{static[X]=`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=QP(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=QP(this.params,e);this.logger.logQuery(this.queryString,t);let n=await this.client;return n.query(this.queryString,t)}},iL=class e extends $I{static[X]=`DuckDBWasmSession`;logger;constructor(e,t,n,r={}){super(t),this.client=e,this.schema=n,this.options=r,this.logger=r.logger??new fF}prepareQuery(e,t,n,r,i){return new rL(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 cP(this.client,async r=>{let i=new e(r,this.dialect,this.schema,this.options),a=new aL(this.dialect,i,this.schema);return n&&await a.setTransaction(n),t(a)})}},aL=class e extends eL{static[X]=`DuckDBWasmTransaction`;dialect;session;constructor(e,t,n,r=0){super(e,t,n,r),this.dialect=e,this.session=t}async transaction(t){return lP(this.session.client,``,async n=>{let r=new iL(n,this.dialect,this.schema,this.session.options),i=new e(this.dialect,r,this.schema);return t(i)})}},oL=class extends JI{static[X]=`DuckDBWasmDatabase`};function sL(e,t={}){let n=new CI({casing:t.casing}),r;t.logger===!0?r=new dF:t.logger!==!1&&(r=t.logger);let i;if(t.schema){let e=dI(t.schema,hI);i={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let a=new iL(e,n,i,{logger:r}),o=new oL(n,a,i);return o.$client=e,o}function cL(e,t){let n=nL(e),r;if(n.bundles===`import-url`){let e=async()=>{let e=await FN();switch(e){case`browser`:return(await T(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 T(async()=>{let{getImportUrlBundles:e}=await import(`./import-url-node-DsdDfn-V.js`);return{getImportUrlBundles:e}},__vite__mapDeps([7,6]))).getImportUrlBundles();default:throw Error(`Unsupported environment: "${e}"`)}};r=e()}else{let e=async()=>{let e=await FN();switch(e){case`browser`:return(await T(async()=>{let{getBundles:e}=await import(`./default-browser-DBEOGewc.js`);return{getBundles:e}},[])).getBundles();case`node`:return await(await T(async()=>{let{getBundles:e}=await import(`./default-node-KCowvLjx.js`);return{getBundles:e}},__vite__mapDeps([3,1,2]))).getBundles();default:throw Error(`Unsupported environment: "${e}"`)}};r=e()}return sL(sP({bundles:r,logger:n.logger?new fT:void 0,storage:n.storage}),t)}function lL(...e){if(typeof e[0]==`string`)return cL(e[0],e[1]);if(bF(e[0])){let{connection:t,client:n,...r}=e[0];if(n)return sL(n,r);if(typeof t==`string`)return cL(t,r);if(t===void 0)throw Error(`connection option is required`);return sL(sP({bundles:t.bundles,logger:t.logger,storage:t.storage}),r)}return sL(e[0],e[1])}(function(e){function t(e){return sL({options:{parsers:{},serializers:{}}},e)}e.mock=t})(lL||={});var uL=1/1e3,dL=1e3,fL=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*uL}get fixedDelta(){return this._fixedDelta*uL}set fixedDelta(e){this._fixedDelta=e*dL}get elapsed(){return this._elapsed*uL}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}},pL=(()=>{let e=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),t=new Float32Array([0,0,2,0,0,2]),n=new ne;return n.setAttribute(`position`,new te(e,3)),n.setAttribute(`uv`,new te(t,2)),n})(),mL=class e{static get fullscreenGeometry(){return pL}constructor(e=`Pass`,t=new ze,n=new re){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 P(e.fullscreenGeometry,t),n.frustumCulled=!1,this.scene===null&&(this.scene=new ze),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=L){}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 nt||n instanceof de||n instanceof We||n instanceof e;r&&this[t].dispose()}this.fullscreenMaterial!==null&&this.fullscreenMaterial.dispose()}},hL=class extends mL{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)}},gL=`#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 +}`,_L=`varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}`,vL=class extends Be{constructor(){super({name:`CopyMaterial`,uniforms:{inputBuffer:new Ge(null),opacity:new Ge(1)},blending:it,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:gL,vertexShader:_L})}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}},yL=class extends mL{constructor(e,t=!0){super(`CopyPass`),this.fullscreenMaterial=new vL,this.needsSwap=!1,this.renderTarget=e,e===void 0&&(this.renderTarget=new nt(1,1,{minFilter:ae,magFilter:ae,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===qe?e!==null&&e.outputColorSpace===bt&&(this.renderTarget.texture.colorSpace=bt):this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`)}},bL=new ge,xL=class extends mL{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(bL),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(bL,s):l&&e.setClearAlpha(s)}},SL=class extends mL{constructor(e,t){super(`MaskPass`,e,t),this.needsSwap=!1,this.clearPass=new xL(!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)}},CL=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 yL,this.depthTexture=null,this.passes=[],this.timer=new fL,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 Xe),n=e.getContext().getContextAttributes().alpha,r=this.inputBuffer.texture.type;r===qe&&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 we;return this.inputBuffer.depthTexture=e,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(e.format=Ce,e.type=Je):e.type=Ye,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 Xe:i.getDrawingBufferSize(new Xe),o={minFilter:ae,magFilter:ae,stencilBuffer:t,depthBuffer:e,type:n},s=new nt(a.width,a.height,o);return r>0&&(s.ignoreDepthForMultisampleCopy=!1,s.samples=r),n===qe&&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 Xe),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 SL?a=!0:l instanceof hL&&(a=!1))}setSize(e,t,n){let r=this.renderer,i=r.getSize(new Xe);(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 Xe);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(),mL.fullscreenGeometry.dispose()}},wL={NONE:0,DEPTH:1,CONVOLUTION:2},TL={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`},EL=class{constructor(){this.shaderParts=new Map([[TL.FRAGMENT_HEAD,null],[TL.FRAGMENT_MAIN_UV,null],[TL.FRAGMENT_MAIN_IMAGE,null],[TL.VERTEX_HEAD,null],[TL.VERTEX_MAIN_SUPPORT,null]]),this.defines=new Map,this.uniforms=new Map,this.blendModes=new Map,this.extensions=new Set,this.attributes=wL.NONE,this.varyings=new Set,this.uvTransformation=!1,this.readDepth=!1,this.colorSpace=se}},DL=!1,OL=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 Te:t=this.materialsFlatShadedDoubleSide;break;case I:t=this.materialsFlatShadedBackSide;break;default:t=this.materialsFlatShaded;break}else switch(e.material.side){case Te:t=this.materialsDoubleSide;break;case I: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 Be))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=Ae;t[2].skinning=!0,this.materialsBackSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.side=I,n}),this.materialsDoubleSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.side=Te,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=I,n}),this.materialsFlatShadedDoubleSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n.side=Te,n})}}render(e,t,n){let r=e.shadowMap.enabled;if(e.shadowMap.enabled=!1,DL){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 DL}static set workaroundEnabled(e){DL=e}},kL=-1,AL=class extends De{constructor(e,t=kL,n=kL,r=1){super(),this.resizable=e,this.baseSize=new Xe(1,1),this.preferredSize=new Xe(t,n),this.target=this.preferredSize,this.s=r,this.effectiveSize=new Xe,this.addEventListener(`change`,()=>this.updateEffectiveSize()),this.updateEffectiveSize()}updateEffectiveSize(){let e=this.baseSize,t=this.preferredSize,n=this.effectiveSize,r=this.scale;t.width===kL?t.height===kL?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===kL?t.width===kL?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(kL),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 kL}};Set;var jL={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},ML=`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);}`,NL=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,y,y.a*opacity);}`,PL=`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);}`,FL=`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);}`,IL=`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);}`,LL=`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);}`,RL=`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);}`,zL=`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);}`,BL=`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);}`,VL=`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);}`,HL=`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);}`,UL=`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);}`,WL=`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);}`,GL=`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);}`,KL=`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);}`,qL=`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);}`,JL=`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);}`,YL=`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);}`,XL=`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);}`,ZL=`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);}`,QL=`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);}`,$L=`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);}`,eR=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,y,opacity);}`,tR=`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);}`,nR=`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);}`,rR=`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);}`,iR=`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);}`,aR=`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);}`,oR=`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);}`,sR=`vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y;}`,cR=`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);}`,lR=`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);}`,uR=new Map([[jL.ADD,ML],[jL.ALPHA,NL],[jL.AVERAGE,PL],[jL.COLOR,FL],[jL.COLOR_BURN,IL],[jL.COLOR_DODGE,LL],[jL.DARKEN,RL],[jL.DIFFERENCE,zL],[jL.DIVIDE,BL],[jL.DST,null],[jL.EXCLUSION,VL],[jL.HARD_LIGHT,HL],[jL.HARD_MIX,UL],[jL.HUE,WL],[jL.INVERT,GL],[jL.INVERT_RGB,KL],[jL.LIGHTEN,qL],[jL.LINEAR_BURN,JL],[jL.LINEAR_DODGE,YL],[jL.LINEAR_LIGHT,XL],[jL.LUMINOSITY,ZL],[jL.MULTIPLY,QL],[jL.NEGATION,$L],[jL.NORMAL,eR],[jL.OVERLAY,tR],[jL.PIN_LIGHT,nR],[jL.REFLECT,rR],[jL.SATURATION,iR],[jL.SCREEN,aR],[jL.SOFT_LIGHT,oR],[jL.SRC,sR],[jL.SUBTRACT,cR],[jL.VIVID_LIGHT,lR]]),dR=class extends De{constructor(e,t=1){super(),this._blendFunction=e,this.opacity=new Ge(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 uR.get(this.blendFunction)}},fR=class extends De{constructor(e,t,{attributes:n=wL.NONE,blendFunction:r=jL.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 dR(r),this.blendMode.addEventListener(`change`,e=>this.setChanged()),this._inputColorSpace=se,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=L){}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 nt||t instanceof de||t instanceof We||t instanceof mL;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 pR=class extends mL{constructor(e,t,n=null){super(`RenderPass`,e,t),this.needsSwap=!1,this.clearPass=new xL,this.overrideMaterialManager=n===null?null:new OL(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 OL(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}},mR=`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);}`,hR=class extends fR{constructor({blendFunction:e=jL.SRC,hue:t=0,saturation:n=0}={}){super(`HueSaturationEffect`,mR,{blendFunction:e,uniforms:new Map([[`hue`,new Ge(new Ze)],[`saturation`,new Ge(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 gR=`#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=L){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.`)}},bR=`#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 +}`,xR=`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);}`,SR=class extends Be{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 Ge(null),depthBuffer:new Ge(null),resolution:new Ge(new Xe),texelSize:new Ge(new Xe),cameraNear:new Ge(.3),cameraFar:new Ge(1e3),aspect:new Ge(1),time:new Ge(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=L){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=bR.replace(TL.FRAGMENT_HEAD,e.get(TL.FRAGMENT_HEAD)||``).replace(TL.FRAGMENT_MAIN_UV,e.get(TL.FRAGMENT_MAIN_UV)||``).replace(TL.FRAGMENT_MAIN_IMAGE,e.get(TL.FRAGMENT_MAIN_IMAGE)||``),this.vertexShader=xR.replace(TL.VERTEX_HEAD,e.get(TL.VERTEX_HEAD)||``).replace(TL.VERTEX_MAIN_SUPPORT,e.get(TL.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 TL}};Number(ut.replace(/\D+/g,``));var CR=255/256;new Float32Array([CR/256**3,CR/256**2,CR/256,CR]),new Float32Array([CR,CR/256,CR/256**2,1/256**3]);function wR(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 TR(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&wL.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(TL.FRAGMENT_HEAD)||``,u=c.get(TL.FRAGMENT_MAIN_UV)||``,d=c.get(TL.FRAGMENT_MAIN_IMAGE)||``,f=c.get(TL.VERTEX_HEAD)||``,p=c.get(TL.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 g=new Map([[`fragment`,r],[`vertex`,i]]);wR(e,h,n.defines),wR(e,h,g),r=g.get(`fragment`),i=g.get(`vertex`);let _=t.blendMode;if(n.blendModes.set(_.blendFunction,_),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&wL.DEPTH)!==0&&i.test(r)&&(d+=`depth, `,n.readDepth=!0),d+=`color1); + `;let a=e+`BlendOpacity`;n.uniforms.set(a,_.opacity),d+=`color0 = blend${_.blendFunction}(color0, color1, ${a}); + + `,l+=`uniform float ${a}; + +`}if(l+=r+` +`,i!==null&&(f+=i+` +`),c.set(TL.FRAGMENT_HEAD,l),c.set(TL.FRAGMENT_MAIN_UV,u),c.set(TL.FRAGMENT_MAIN_IMAGE,d),c.set(TL.VERTEX_HEAD,f),c.set(TL.VERTEX_MAIN_SUPPORT,p),t.extensions!==null)for(let e of t.extensions)n.extensions.add(e)}}var ER=class extends mL{constructor(e,...t){super(`EffectPass`),this.fullscreenMaterial=new SR(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 EL,t=0;for(let n of this.effects)if(n.blendMode.blendFunction===jL.DST)e.attributes|=n.getAttributes()&wL.DEPTH;else if((e.attributes&n.getAttributes()&wL.CONVOLUTION)!==0)throw Error(`Convolution effects cannot be merged (${n.name})`);else TR(`e`+ t++,n,e);let n=e.shaderParts.get(TL.FRAGMENT_HEAD),r=e.shaderParts.get(TL.FRAGMENT_MAIN_IMAGE),i=e.shaderParts.get(TL.FRAGMENT_MAIN_UV),a=/\bblend\b/g;for(let t of e.blendModes.values())n+=t.getShaderCode().replace(a,`blend${t.blendFunction}`)+` +`;(e.attributes&wL.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(TL.FRAGMENT_HEAD,n),e.shaderParts.set(TL.FRAGMENT_MAIN_IMAGE,r),e.shaderParts.set(TL.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=L){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!==qe&&(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}}},DR=class extends mL{constructor(e,t,{renderTarget:n,resolutionScale:r=1,width:i=AL.AUTO_SIZE,height:a=AL.AUTO_SIZE,resolutionX:o=i,resolutionY:s=a}={}){super(`NormalPass`),this.needsSwap=!1,this.renderPass=new pR(e,t,new Pe);let c=this.renderPass;c.ignoreBackground=!0,c.skipShadowMapUpdate=!0;let l=c.getClearPass();l.overrideClearColor=new ge(7829503),l.overrideClearAlpha=1,this.renderTarget=n,this.renderTarget===void 0&&(this.renderTarget=new nt(1,1,{minFilter:Re,magFilter:Re}),this.renderTarget.texture.name=`NormalPass.Target`);let u=this.resolution=new AL(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]),kR(0,0,0,0),new Float32Array([0,0,0,0]),kR(0,0,0,1),new Float32Array([0,0,0,1]),kR(0,0,1,0),new Float32Array([0,0,1,0]),kR(0,0,1,1),new Float32Array([0,0,1,1]),kR(0,1,0,0),new Float32Array([0,1,0,0]),kR(0,1,0,1),new Float32Array([0,1,0,1]),kR(0,1,1,0),new Float32Array([0,1,1,0]),kR(0,1,1,1),new Float32Array([0,1,1,1]),kR(1,0,0,0),new Float32Array([1,0,0,0]),kR(1,0,0,1),new Float32Array([1,0,0,1]),kR(1,0,1,0),new Float32Array([1,0,1,0]),kR(1,0,1,1),new Float32Array([1,0,1,1]),kR(1,1,0,0),new Float32Array([1,1,0,0]),kR(1,1,0,1),new Float32Array([1,1,0,1]),kR(1,1,1,0),new Float32Array([1,1,1,0]),kR(1,1,1,1),new Float32Array([1,1,1,1]);function OR(e,t,n){return e+(t-e)*n}function kR(e,t,n,r){let i=OR(e,t,.75),a=OR(n,r,.75);return OR(i,a,.875)}var AR=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 jR=Symbol(`effectComposerPmndrs`),MR=Wt({__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:je}},emits:[`render`],setup(e,{expose:t,emit:n}){let r=e,i=n,{scene:a,camera:o,renderer:s,sizes:c,render:l}=b(),u=kt(null),d=null,f=null;Zt(jR,u),t({composer:u});let p=()=>{u.value&&(f=new DR(a.value,o.value),f.enabled=!1,u.value.addPass(f),r.resolutionScale!==void 0&&AR.isWebGL2Available()&&(d=new yR({normalBuffer:f.texture,resolutionScale:r.resolutionScale}),d.enabled=!1,u.value.addPass(d)))},m=Tt(()=>{let e=new CL,t={depthBuffer:r.depthBuffer===void 0?e.inputBuffer.depthBuffer:r.depthBuffer,stencilBuffer:r.stencilBuffer===void 0?e.inputBuffer.stencilBuffer:r.stencilBuffer,multisampling:AR.isWebGL2Available()?r.multisampling===void 0?e.multisampling:r.multisampling:0,frameBufferType:r.frameBufferType===void 0?je:r.frameBufferType};return e.dispose(),t}),h=()=>{var e;!s.value&&!a.value&&!o.value||((e=u.value)==null||e.dispose(),u.value=new CL(s.value,m.value),u.value.addPass(new pR(a.value,o.value)),r.disableNormalPass||p())};$t([s,a,o,()=>r.disableNormalPass],()=>{!c.width.value||!c.height.value||h()}),$t(()=>[c.width.value,c.height.value],([e,t])=>{!e&&!t||(u.value?u.value.setSize(e,t):h())},{immediate:!0});let{render:g}=y();return g(()=>{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)}),Yt(()=>{var e;(e=u.value)==null||e.dispose()}),(e,t)=>Qt(e.$slots,`default`)}}),NR=(e,t,n)=>{let r=Kt(jR),i=kt(null),a=kt(null),{scene:o,camera:s,invalidate:c}=b();$t(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 ER(s.value,a.value),r.value.addPass(i.value,t))};n&&$t(()=>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))}),Et(()=>{!s.value||!(a!=null&&a.value)||(a.value.mainCamera=s.value)});let d=Et(()=>{!s.value||!(r!=null&&r.value)||!o.value||(qt(()=>d()),!a.value&&u())});return Yt(()=>{l()}),{pass:i,effect:a}},PR=/([^[.\]])+/g,FR=(e,t)=>{if(!t)return;let n=Array.isArray(t)?t:t.match(PR);return n?.reduce((e,t)=>e&&e[t],e)},IR=(e,t,n)=>{let r=Array.isArray(t)?t:t.match(PR);r&&r.reduce((e,t,i)=>(e[t]===void 0&&(e[t]={}),i===r.length-1&&(e[t]=n),e[t]),e)},LR=(e,t,n,r,i={})=>$t(e,i=>{var a;if(t.value)if(i===void 0){let e=r();IR(t.value,n,FR(e,n)),(a=e.dispose)==null||a.call(e)}else IR(t.value,n,e())},i),RR=(e,t,n)=>e.map(([e,r])=>LR(e,t,r,n));Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const zR=Wt({__name:`HueSaturationPmndrs`,props:{saturation:{},hue:{},blendFunction:{}},setup(e,{expose:t}){let n=e,{pass:r,effect:i}=NR(()=>new hR(n),n);return t({pass:r,effect:i}),RR([[()=>n.blendFunction,`blendMode.blendFunction`],[()=>n.hue,`hue`],[()=>n.saturation,`saturation`]],i,()=>new hR),()=>{}}});Boolean,Boolean;const BR={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 VR=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 HR=new ot(-1,1,1,-1,0,1);var UR=class extends ne{constructor(){super(),this.setAttribute(`position`,new Oe([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new Oe([0,2,0,0,2,0],2))}};const WR=new UR;var GR=class{constructor(e){this._mesh=new P(WR,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,HR)}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 Xe(1/1024,1/512),new Xe(1/1024,1/512),new Xe(1/1024,1/512);const KR={name:`LuminosityHighPassShader`,shaderID:`luminosityHighPass`,uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new ge(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 qR=class e extends VR{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 Xe(256,256):new Xe(e.x,e.y),this.clearColor=new ge(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 nt(i,a,{type:je}),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 Be({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) ); + }`})}};qR.BlurDirectionX=new Xe(1,0),qR.BlurDirectionY=new Xe(0,1);var JR=class{static fromCubeTexture(e){let t=0,n=new Ze,r=new Ze,i=new ge,a=[0,0,0,0,0,0,0,0,0],o=new He,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,g=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||=ZR,u.value.outputColorSpace=bt,u.value.toneMapping=C;try{let t=await new XR().loadAsync(e);t.mapping=Ee,t.generateMipmaps=!0,t.minFilter=oe,t.magFilter=ae,t.colorSpace=se,o=new S(u.value);let n=o.fromEquirectangular(t);s=n;let d=new tt(256);d.fromEquirectangularTexture(u.value,t);let f=await JR.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 Jt(async()=>{await f(r.skyBoxSrc),$t(()=>[r.skyBoxSrc],([e])=>{f(e)},{deep:!1})}),t({reload:async e=>await f(e)}),Yt(async()=>{await d()}),(e,t)=>Qt(e.$slots,`default`)}}),$R=QR;const ez=E(`vrm`,()=>{let{post:e,data:t}=A({name:`airi-stores-vrm`}),n=R([]),r=e=>{n.value.push(e)};function i(){e({type:`should-update-view`}),n.value.forEach(e=>e())}$t(t,e=>{e.type===`should-update-view`&&n.value.forEach(e=>e())});let a=N(`settings/vrm/cameraScale`,1),o=N(`settings/vrm/modelSize`,{x:0,y:0,z:0}),s=N(`settings/vrm/modelOrigin`,{x:0,y:0,z:0}),c=N(`settings/vrm/modelOffset`,{x:0,y:0,z:0}),l=N(`settings/vrm/modelRotationY`,0),u=N(`settings/vrm/cameraFOV`,40),d=N(`settings/vrm/camera-position`,{x:0,y:0,z:-1}),f=N(`settings/vrm/cameraDistance`,0),p=N(`settings/vrm/scenes/scene/directional-light/position`,{x:0,y:0,z:-10}),m=N(`settings/vrm/scenes/scene/directional-light/target`,{x:0,y:0,z:0}),h=N(`settings/vrm/scenes/scene/directional-light/rotation`,{x:0,y:0,z:0}),g=N(`settings/vrm/scenes/scene/directional-light/intensity`,2.02),_=N(`settings/vrm/scenes/scene/directional-light/color`,`#fffbf5`),v=N(`settings/vrm/scenes/scene/hemisphere-light/sky-color`,`#FFFFFF`),y=N(`settings/vrm/scenes/scene/hemisphere-light/ground-color`,`#222222`),b=N(`settings/vrm/scenes/scene/hemisphere-light/intensity`,.4),x=N(`settings/vrm/scenes/scene/ambient-light/color`,`#FFFFFF`),S=N(`settings/vrm/scenes/scene/ambient-light/intensity`,.6),C=N(`settings/vrm/lookAtTarget`,{x:0,y:0,z:0}),w=N(`settings/vrm/isTracking`,!1),T=N(`settings/vrm/trackingMode`,`none`),E=N(`settings/vrm/eyeHeight`,0),D=N(`settings/vrm/envEnabled`,`skyBox`),O=N(`settings/vrm/skyBoxUrl`,ZR),k=N(`settings/vrm/specularMix`,0),j=N(`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:g,directionalLightColor:_,ambientLightIntensity:S,ambientLightColor:x,hemisphereSkyColor:v,hemisphereGroundColor:y,hemisphereLightIntensity:b,lookAtTarget:C,isTracking:w,trackingMode:T,eyeHeight:E,envSelect:D,skyBoxSrc:O,specularMix:k,skyBoxIntensity:j,shouldUpdateView:i,onShouldUpdateView:r}}),tz=[`color`,`ground-color`,`intensity`],nz=[`color`,`intensity`],rz=[`color`,`position`,`rotation`,`intensity`],iz={key:2,size:1};var az=Wt({__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}=f(),s=R(),{width:c,height:l}=M(s),{cameraFOV:d,cameraPosition:p,cameraDistance:m,modelOrigin:h,trackingMode:g,lookAtTarget:_,eyeHeight:y,directionalLightPosition:b,directionalLightRotation:x,directionalLightIntensity:S,directionalLightColor:w,ambientLightIntensity:T,ambientLightColor:E,hemisphereLightIntensity:O,hemisphereSkyColor:k,hemisphereGroundColor:A,envSelect:j,skyBoxSrc:N}=D(ez()),ee=R(),P=kt(new st),F=kt(),I=kt(),L=R();function te(e){I.value=e}let ne={saturation:.3,hue:0,blendFunction:jL.SRC},re=!0,ie=R(!1),ae=R(!1),oe=R(!1),se=new gt,ce=new Xe,le=R(null),ue=R(null);function de(e){le.value=e.hdri,ue.value=e.irrSH||null}$t(d,e=>{P.value&&(P.value.fov=e,P.value.updateProjectionMatrix())}),$t(()=>F.value?.controls,e=>{if(e&&P.value){ie.value=!0;let t=()=>{if(re)return;re=!0;let e=P.value.position,t=F.value.controls.getDistance(),n=Math.abs(p.value.x-e.x)>1e-6||Math.abs(p.value.y-e.y)>1e-6||Math.abs(p.value.z-e.z)>1e-6,r=Math.abs(m.value-t)>1e-6;(n||r)&&(p.value={x:e.x,y:e.y,z:e.z},m.value=t),re=!1};e.addEventListener(`change`,t)}});function fe(){ae.value=!0}$t([ie,ae],([e,t])=>{if(e&&t&&P.value&&F.value&&F.value.controls){re=!0;try{P.value.aspect=c.value/l.value,P.value.fov=d.value,F.value.setTarget(h.value),P.value.position.set(p.value.x,p.value.y,p.value.z),P.value.updateProjectionMatrix(),F.value.controls.update(),m.value=F.value.controls.getDistance()}finally{re=!1,oe.value=!0}}}),$t(m,e=>{if(!re&&P.value&&F.value&&F.value.controls){re=!0;let t=new Ze,n=F.value.controls.target,r=new Ze().subVectors(P.value.position,n).normalize();t.copy(n).addScaledVector(r,e),P.value.position.set(t.x,t.y,t.z),F.value.update(),p.value={x:t.x,y:t.y,z:t.z}}re=!1});function pe(e){ee.value?.lookAtUpdate(e),_.value=e}function me(e,t){ce.x=e/window.innerWidth*2-1,ce.y=-(t/window.innerHeight)*2+1,se.setFromCamera(ce,P.value);let n=new Ze;P.value.getWorldDirection(n);let r=new ct;r.setFromNormalAndCoplanarPoint(n,P.value.position.clone().add(n.multiplyScalar(1)));let i=new Ze;se.ray.intersectPlane(r,i),_.value={x:i.x,y:i.y,z:i.z},ee.value?.lookAtUpdate(_.value)}return $t(p,e=>{!oe.value||!ee.value||g.value===`camera`&&pe(e)},{deep:!0}),$t([a,o],()=>{!oe.value||!ee.value||g.value===`mouse`&&me(a.value,o.value)}),$t(g,e=>{!oe.value||!ee.value||(e===`camera`?pe(p.value):e===`mouse`?me(a.value,o.value):_.value={x:0,y:y.value,z:-1e3})}),Jt(()=>{j.value===`skyBox`&&L.value?.reload(N.value)}),t({setExpression:e=>{ee.value?.setExpression(e)},canvasElement:()=>I.value?.renderer.value.domElement}),(e,t)=>(Xt(),Ht(`div`,{ref_key:`vrmContainerRef`,ref:s,w:`100%`,h:`100%`},[P.value?Ot((Xt(),Bt(Mt(v),{key:0,camera:P.value,antialias:!0,width:Mt(c),height:Mt(l),"tone-mapping":Mt(C),"tone-mapping-exposure":1,"preserve-drawing-buffer":!0,onReady:te},{default:Dt(()=>[Ut(Mt(IV),{ref_key:`controlsRef`,ref:F},null,512),Mt(j)===`skyBox`?(Xt(),Bt($R,{key:0,ref_key:`skyBoxEnvRef`,ref:L,"sky-box-src":Mt(N),"as-background":!0,onSkyboxReady:de},null,8,[`sky-box-src`])):(Xt(),Ht(`TresHemisphereLight`,{key:1,color:Mt(u)(Mt(k)),"ground-color":Mt(u)(Mt(A)),position:[0,1,0],intensity:Mt(O),"cast-shadow":``},null,8,tz)),zt(`TresAmbientLight`,{color:Mt(u)(Mt(E)),intensity:Mt(T),"cast-shadow":``},null,8,nz),zt(`TresDirectionalLight`,{color:Mt(u)(Mt(w)),position:[Mt(b).x,Mt(b).y,Mt(b).z],rotation:[Mt(x).x,Mt(x).y,Mt(x).z],intensity:Mt(S),"cast-shadow":``},null,8,rz),(Xt(),Bt(wt,null,{default:Dt(()=>[Ut(Mt(MR),null,{default:Dt(()=>[Ut(Mt(zR),Nt(Gt(ne)),null,16)]),_:1})]),_:1})),Ut(Mt(dV),{ref_key:`modelRef`,ref:ee,"model-src":r.modelSrc,"idle-animation":r.idleAnimation,paused:r.paused,"npr-equirect-tex":le.value,"npr-irr-s-h":ue.value,onLoadModelProgress:t[0]||=e=>i(`loadModelProgress`,e),onModelReady:fe,onError:t[1]||=e=>i(`error`,e)},null,8,[`model-src`,`idle-animation`,`paused`,`npr-equirect-tex`,`npr-irr-s-h`]),r.showAxes?(Xt(),Ht(`TresAxesHelper`,iz)):Vt(``,!0)]),_:1},8,[`camera`,`width`,`height`,`tone-mapping`])),[[St,oe.value]]):Vt(``,!0)],512))}}),oz=az;const sz=async({description:e,execute:t,name:n,parameters:r,strict:i})=>{let a=await wn(r);return{execute:t,function:{description:e,name:n,parameters:i===!1?a:Cn(a),strict:i??!0},type:`function`}},cz=oi(`ZodISODateTime`,(e,t)=>{Vr.init(e,t),Pz.init(e,t)});function lz(e){return Ji(cz,e)}const uz=oi(`ZodISODate`,(e,t)=>{Br.init(e,t),Pz.init(e,t)});function dz(e){return qi(uz,e)}const fz=oi(`ZodISOTime`,(e,t)=>{Ur.init(e,t),Pz.init(e,t)});function pz(e){return En(fz,e)}const mz=oi(`ZodISODuration`,(e,t)=>{Hr.init(e,t),Pz.init(e,t)});function hz(e){return Yi(mz,e)}const gz=(e,t)=>{yi.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>xi(e,t)},flatten:{value:t=>bi(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Di,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Di,2)}},isEmpty:{get(){return e.issues.length===0}}})};oi(`ZodError`,gz);const _z=oi(`ZodError`,gz,{Parent:Error}),vz=di(_z),yz=fi(_z),bz=_i(_z),xz=vi(_z),Sz=li(_z),Cz=si(_z),wz=ui(_z),Tz=ci(_z),Ez=hi(_z),Dz=pi(_z),Oz=gi(_z),kz=mi(_z),Az=oi(`ZodType`,(e,t)=>(_r.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)=>Ci(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>vz(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>bz(e,t,n),e.parseAsync=async(t,n)=>yz(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>xz(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Sz(e,t,n),e.decode=(t,n)=>Cz(e,t,n),e.encodeAsync=async(t,n)=>wz(e,t,n),e.decodeAsync=async(t,n)=>Tz(e,t,n),e.safeEncode=(t,n)=>Ez(e,t,n),e.safeDecode=(t,n)=>Dz(e,t,n),e.safeEncodeAsync=async(t,n)=>Oz(e,t,n),e.safeDecodeAsync=async(t,n)=>kz(e,t,n),e.refine=(t,n)=>e.check(zB(t,n)),e.superRefine=t=>e.check(BB(t)),e.overwrite=t=>e.check(Bn(t)),e.optional=()=>CB(e),e.nullable=()=>TB(e),e.nullish=()=>CB(TB(e)),e.nonoptional=t=>jB(e,t),e.array=()=>dB(e),e.or=t=>hB([e,t]),e.and=t=>_B(e,t),e.transform=t=>FB(e,xB(t)),e.default=t=>DB(e,t),e.prefault=t=>kB(e,t),e.catch=t=>NB(e,t),e.pipe=t=>FB(e,t),e.readonly=()=>LB(e),e.describe=t=>{let n=e.clone();return rr.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return rr.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return rr.get(e);let n=e.clone();return rr.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),jz=oi(`_ZodString`,(e,t)=>{mr.init(e,t),Az.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(Hn(...t)),e.includes=(...t)=>e.check(Ui(...t)),e.startsWith=(...t)=>e.check(Un(...t)),e.endsWith=(...t)=>e.check(zi(...t)),e.min=(...t)=>e.check(Pn(...t)),e.max=(...t)=>e.check(Nn(...t)),e.length=(...t)=>e.check(kn(...t)),e.nonempty=(...t)=>e.check(Pn(1,...t)),e.lowercase=t=>e.check(An(t)),e.uppercase=t=>e.check(Zn(t)),e.trim=()=>e.check(Jn()),e.normalize=(...t)=>e.check(Rn(...t)),e.toLowerCase=()=>e.check(Kn()),e.toUpperCase=()=>e.check(qn())}),Mz=oi(`ZodString`,(e,t)=>{mr.init(e,t),jz.init(e,t),e.email=t=>e.check(Li(Fz,t)),e.url=t=>e.check(Qn(Rz,t)),e.jwt=t=>e.check(Dn($z,t)),e.emoji=t=>e.check(Ri(zz,t)),e.guid=t=>e.check(Hi(Iz,t)),e.uuid=t=>e.check(Tn(Lz,t)),e.uuidv4=t=>e.check($n(Lz,t)),e.uuidv6=t=>e.check(er(Lz,t)),e.uuidv7=t=>e.check(tr(Lz,t)),e.nanoid=t=>e.check(In(Bz,t)),e.guid=t=>e.check(Hi(Iz,t)),e.cuid=t=>e.check(Pi(Vz,t)),e.cuid2=t=>e.check(Fi(Hz,t)),e.ulid=t=>e.check(Yn(Uz,t)),e.base64=t=>e.check(ki(Xz,t)),e.base64url=t=>e.check(Ai(Zz,t)),e.xid=t=>e.check(nr(Wz,t)),e.ksuid=t=>e.check(On(Gz,t)),e.ipv4=t=>e.check(Gi(Kz,t)),e.ipv6=t=>e.check(Ki(qz,t)),e.cidrv4=t=>e.check(Mi(Jz,t)),e.cidrv6=t=>e.check(Ni(Yz,t)),e.e164=t=>e.check(Ii(Qz,t)),e.datetime=t=>e.check(lz(t)),e.date=t=>e.check(dz(t)),e.time=t=>e.check(pz(t)),e.duration=t=>e.check(hz(t))});function Nz(e){return Wn(Mz,e)}const Pz=oi(`ZodStringFormat`,(e,t)=>{hr.init(e,t),jz.init(e,t)}),Fz=oi(`ZodEmail`,(e,t)=>{Pr.init(e,t),Pz.init(e,t)}),Iz=oi(`ZodGUID`,(e,t)=>{Lr.init(e,t),Pz.init(e,t)}),Lz=oi(`ZodUUID`,(e,t)=>{br.init(e,t),Pz.init(e,t)}),Rz=oi(`ZodURL`,(e,t)=>{yr.init(e,t),Pz.init(e,t)}),zz=oi(`ZodEmoji`,(e,t)=>{Fr.init(e,t),Pz.init(e,t)}),Bz=oi(`ZodNanoID`,(e,t)=>{qr.init(e,t),Pz.init(e,t)}),Vz=oi(`ZodCUID`,(e,t)=>{Or.init(e,t),Pz.init(e,t)}),Hz=oi(`ZodCUID2`,(e,t)=>{kr.init(e,t),Pz.init(e,t)}),Uz=oi(`ZodULID`,(e,t)=>{vr.init(e,t),Pz.init(e,t)}),Wz=oi(`ZodXID`,(e,t)=>{Cr.init(e,t),Pz.init(e,t)}),Gz=oi(`ZodKSUID`,(e,t)=>{Kr.init(e,t),Pz.init(e,t)}),Kz=oi(`ZodIPv4`,(e,t)=>{Rr.init(e,t),Pz.init(e,t)}),qz=oi(`ZodIPv6`,(e,t)=>{zr.init(e,t),Pz.init(e,t)}),Jz=oi(`ZodCIDRv4`,(e,t)=>{Er.init(e,t),Pz.init(e,t)}),Yz=oi(`ZodCIDRv6`,(e,t)=>{Dr.init(e,t),Pz.init(e,t)}),Xz=oi(`ZodBase64`,(e,t)=>{ar.init(e,t),Pz.init(e,t)}),Zz=oi(`ZodBase64URL`,(e,t)=>{wr.init(e,t),Pz.init(e,t)}),Qz=oi(`ZodE164`,(e,t)=>{Nr.init(e,t),Pz.init(e,t)}),$z=oi(`ZodJWT`,(e,t)=>{Gr.init(e,t),Pz.init(e,t)}),eB=oi(`ZodNumber`,(e,t)=>{sr.init(e,t),Az.init(e,t),e.gt=(t,n)=>e.check(Bi(t,n)),e.gte=(t,n)=>e.check(Vi(t,n)),e.min=(t,n)=>e.check(Vi(t,n)),e.lt=(t,n)=>e.check(jn(t,n)),e.lte=(t,n)=>e.check(Mn(t,n)),e.max=(t,n)=>e.check(Mn(t,n)),e.int=t=>e.check(rB(t)),e.safe=t=>e.check(rB(t)),e.positive=t=>e.check(Bi(0,t)),e.nonnegative=t=>e.check(Vi(0,t)),e.negative=t=>e.check(jn(0,t)),e.nonpositive=t=>e.check(Mn(0,t)),e.multipleOf=(t,n)=>e.check(Fn(t,n)),e.step=(t,n)=>e.check(Fn(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 tB(e){return zn(eB,e)}const nB=oi(`ZodNumberFormat`,(e,t)=>{cr.init(e,t),eB.init(e,t)});function rB(e){return Wi(nB,e)}const iB=oi(`ZodBoolean`,(e,t)=>{Tr.init(e,t),Az.init(e,t)});function aB(e){return ji(iB,e)}const oB=oi(`ZodUnknown`,(e,t)=>{Sr.init(e,t),Az.init(e,t)});function sB(){return Xn(oB)}const cB=oi(`ZodNever`,(e,t)=>{Jr.init(e,t),Az.init(e,t)});function lB(e){return Ln(cB,e)}const uB=oi(`ZodArray`,(e,t)=>{ir.init(e,t),Az.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(Pn(t,n)),e.nonempty=t=>e.check(Pn(1,t)),e.max=(t,n)=>e.check(Nn(t,n)),e.length=(t,n)=>e.check(kn(t,n)),e.unwrap=()=>e.element});function dB(e,t){return Oi(uB,e,t)}const fB=oi(`ZodObject`,(e,t)=>{lr.init(e,t),Az.init(e,t),wi(e,`shape`,()=>t.shape),e.keyof=()=>yB(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:sB()}),e.loose=()=>e.clone({...e._zod.def,catchall:sB()}),e.strict=()=>e.clone({...e._zod.def,catchall:lB()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Ti(e,t),e.safeExtend=t=>ri(e,t),e.merge=t=>Xr(e,t),e.pick=t=>ti(e,t),e.omit=t=>$r(e,t),e.partial=(...t)=>ei(SB,e,t[0]),e.required=(...t)=>ni(AB,e,t[0])});function pB(e,t){let n={type:`object`,get shape(){return Si(this,`shape`,e?Qr(e):{}),this.shape},...Zr(t)};return new fB(n)}const mB=oi(`ZodUnion`,(e,t)=>{xr.init(e,t),Az.init(e,t),e.options=t.options});function hB(e,t){return new mB({type:`union`,options:e,...Zr(t)})}const gB=oi(`ZodIntersection`,(e,t)=>{Wr.init(e,t),Az.init(e,t)});function _B(e,t){return new gB({type:`intersection`,left:e,right:t})}const vB=oi(`ZodEnum`,(e,t)=>{Ir.init(e,t),Az.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 vB({...t,checks:[],...Zr(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 vB({...t,checks:[],...Zr(r),entries:i})}});function yB(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new vB({type:`enum`,entries:n,...Zr(t)})}const bB=oi(`ZodTransform`,(e,t)=>{gr.init(e,t),Az.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ai(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ei(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(Ei(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function xB(e){return new bB({type:`transform`,transform:e})}const SB=oi(`ZodOptional`,(e,t)=>{ur.init(e,t),Az.init(e,t),e.unwrap=()=>e._zod.def.innerType});function CB(e){return new SB({type:`optional`,innerType:e})}const wB=oi(`ZodNullable`,(e,t)=>{or.init(e,t),Az.init(e,t),e.unwrap=()=>e._zod.def.innerType});function TB(e){return new wB({type:`nullable`,innerType:e})}const EB=oi(`ZodDefault`,(e,t)=>{Mr.init(e,t),Az.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function DB(e,t){return new EB({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ii(t)}})}const OB=oi(`ZodPrefault`,(e,t)=>{fr.init(e,t),Az.init(e,t),e.unwrap=()=>e._zod.def.innerType});function kB(e,t){return new OB({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ii(t)}})}const AB=oi(`ZodNonOptional`,(e,t)=>{Yr.init(e,t),Az.init(e,t),e.unwrap=()=>e._zod.def.innerType});function jB(e,t){return new AB({type:`nonoptional`,innerType:e,...Zr(t)})}const MB=oi(`ZodCatch`,(e,t)=>{Ar.init(e,t),Az.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function NB(e,t){return new MB({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const PB=oi(`ZodPipe`,(e,t)=>{dr.init(e,t),Az.init(e,t),e.in=t.in,e.out=t.out});function FB(e,t){return new PB({type:`pipe`,in:e,out:t})}const IB=oi(`ZodReadonly`,(e,t)=>{pr.init(e,t),Az.init(e,t),e.unwrap=()=>e._zod.def.innerType});function LB(e){return new IB({type:`readonly`,innerType:e})}const RB=oi(`ZodCustom`,(e,t)=>{jr.init(e,t),Az.init(e,t)});function zB(e,t={}){return Vn(RB,e,t)}function BB(e){return Gn(e)}const VB=[sz({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:pB({})})],HB=async()=>Promise.all(VB);var UB,WB,GB,KB,qB;UB=new WeakMap,WB=new WeakMap,GB=new WeakMap,KB=new WeakMap;async function JB(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}qB=new WeakMap;async function YB(e,t){await JB(`plugin:mcp|connect_server`,{command:e,args:t})}async function XB(){await JB(`plugin:mcp|disconnect_server`)}async function ZB(){return await JB(`plugin:mcp|list_tools`)}async function QB(e,t){return await JB(`plugin:mcp|call_tool`,{name:e,args:t})}const $B=[sz({name:`mcp_list_tools`,description:`List all tools available on the MCP server`,execute:async(e,t)=>await ZB(),parameters:pB({})}),sz({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 YB(e,t),`success`),parameters:pB({command:Nz().describe(`The command to connect to the MCP server`),args:dB(Nz()).describe(`The arguments to pass to the MCP server`)})}),sz({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 XB(),`success`),parameters:pB({})}),sz({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 QB(e,n);return r},parameters:pB({name:Nz().describe(`The name of the tool to call`),parameters:dB(pB({name:Nz().describe(`The name of the parameter`),value:hB([Nz(),tB(),aB(),pB({})]).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`)})})],eV=async()=>Promise.all($B);function tV(e,t,n,r,i=new Map){return!!(r?.supportsTools||i.get(`${t.chat(e).baseURL}-${e}`))}async function nV(e,t,n,r){let i=r?.headers;return await un({...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:tV(e,t,n,r)?[...await eV(),...await HB()]:void 0,onEvent(e){r?.onStreamEvent?.(e)}})}async function rV(e,t,r,i){async function a(r){try{let n=await nV(e,t,[{role:`user`,content:`Hello, world!`}],{...i,supportsTools:r});for await(let e of Zi(n.textStream));return!0}catch(e){if(e instanceof Error&&e.name===new n(``).name&&(String(e).includes(`does not support tools`)||String(e).includes(`No endpoints found that support tool use.`)))return!1;throw e}}function o(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 s=[()=>a(!0),()=>a(!1)],c=await o(s,1e3);if(c.some(e=>e.error)){let t=Error(`Error during tools compatibility discovery for model: ${e}. Errors: ${c.map(e=>e.error).filter(Boolean).join(`, `)}`);throw t.cause=c.map(e=>e.error).filter(Boolean),t}return c[0].result===!0&&c[1].result===!0}const iV=E(`llm`,()=>{let e=R(new Map);async function n(t,n,r,i){if(e.value.has(`${n.chat(t).baseURL}-${t}`))return;let a=await rV(t,n,r,{...i,toolsCompatibility:e.value});e.value.set(`${n.chat(t).baseURL}-${t}`,a)}function r(t,n,r,i){return nV(t,n,r,{...i,toolsCompatibility:e.value})}async function i(e,n){if(e===``)return[];try{return await t({baseURL:e.endsWith(`/`)?e:`${e}/`,apiKey:n})}catch(e){if(String(e).includes(`Failed to construct 'URL': Invalid URL`))return[];throw e}}return{models:i,stream:r,discoverToolsCompatibility:n}}),aV=E(`chat`,()=>{let{stream:e,discoverToolsCompatibility:t}=iV(),{systemPrompt:n}=D(Xi()),r=R(!1),i=R([]),a=R([]),o=R([]),s=R([]),c=R([]),l=R([]),u=R([]),d=R([]);function f(e){i.value.push(e)}function p(e){a.value.push(e)}function m(e){o.value.push(e)}function h(e){s.value.push(e)}function g(e){c.value.push(e)}function _(e){l.value.push(e)}function v(e){u.value.push(e)}function y(e){d.value.push(e)}let b=R([{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}]),x=R({role:`assistant`,content:``,slices:[],tool_results:[]});async function S(t,n){try{if(r.value=!0,!t&&!n.attachments?.length)return;for(let e of i.value)await e(t);let f=[{type:`text`,text:t}];if(n.attachments)for(let e of n.attachments)e.type===`image`&&f.push({type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}});let p=f.length>1?f:t;b.value.push({role:`user`,content:p});let m=vn({onLiteral:async e=>{for(let t of c.value)await t(e);x.value.content+=e;let t=x.value.slices.at(-1);if(t?.type===`text`){t.text+=e;return}x.value.slices.push({type:`text`,text:e})},onSpecial:async e=>{for(let t of l.value)await t(e)},minLiteralEmitLength:24}),h=ln({handlers:[async e=>{if(e.data.type===`tool-call`){x.value.slices.push(e.data);return}e.data.type===`tool-call-result`&&x.value.tool_results.push(e.data)}]});x.value={role:`assistant`,content:``,slices:[],tool_results:[]};let g=b.value.map(e=>{if(e.role===`assistant`){let{slices:t,...n}=e;return n.tool_results=At(n.tool_results),At(n)}return At(e)});for(let e of a.value)await e(t);for(let e of o.value)await e(t);let _=``,v=n.providerConfig?.headers||{};await e(n.model,n.chatProvider,g,{headers:v,async onStreamEvent(e){if(e.type===`tool-call`)h.enqueue({type:`tool-call`,toolCall:e});else if(e.type===`tool-result`)h.enqueue({type:`tool-call-result`,id:e.toolCallId,result:e.result});else if(e.type===`text-delta`)_+=e.text,await m.consume(e.text);else if(e.type===`finish`){await m.end(),x.value.slices.length>0&&b.value.push(At(x.value)),x.value={role:`assistant`,content:``,slices:[],tool_results:[]};let e=`${cn}${cn}`;for(let t of c.value)await t(e);for(let e of u.value)await e();for(let e of d.value)await e(_);console.debug(`LLM output:`,_)}}});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:b,streamingMessage:x,discoverToolsCompatibility:t,send:S,onBeforeMessageComposed:f,onAfterMessageComposed:p,onBeforeSend:m,onAfterSend:h,onTokenLiteral:g,onTokenSpecial:_,onStreamEnd:v,onAssistantResponseEnd:y}}),oV={relative:``},sV={"h-full":``,"w-full":``};var cV=Wt({__name:`Stage`,props:{paused:{type:Boolean,default:!1},focusAt:{},xOffset:{},yOffset:{},scale:{default:1}},setup(t,{expose:n}){let r=R(),s=R(),c=R(),u=ee(),{stageModelRenderer:d,stageViewControlsEnabled:f,live2dDisableFocus:p,stageModelSelectedUrl:m}=D(u),{mouthOpenSize:h}=D(rn()),{audioContext:g,calculateVolume:_}=nn(),{onBeforeMessageComposed:v,onBeforeSend:y,onTokenLiteral:b,onTokenSpecial:x,onStreamEnd:S,onAssistantResponseEnd:C}=aV(),w=e(),T=Uh(),E=ez(),O=R(!0);T.onShouldUpdateView(async()=>{O.value=!1,await u.updateStageModel(),setTimeout(()=>{O.value=!0},100)}),E.onShouldUpdateView(async()=>{O.value=!1,await u.updateStageModel(),setTimeout(()=>{O.value=!0},100)});let k=R(),A=R(!1),j=R(!1),M=null,N=ln({handlers:[e=>new Promise(t=>{if(M){try{M.stop(),M.disconnect()}catch{}M=null}let n=g.createBufferSource();n.buffer=e.data.audioBuffer,n.connect(g.destination),n.connect(k.value),A.value=!0,M=n,n.start(0),n.onended=()=>{A.value=!1,M===n&&(M=null),t()}})]}),P=en(),{ssmlEnabled:F,activeSpeechProvider:I,activeSpeechModel:L,activeSpeechVoice:te,pitch:ne}=D(P);async function re(e){try{if(!I.value){console.warn(`No active speech provider configured`);return}if(!te.value){console.warn(`No active speech voice configured`);return}let t=await w.getProviderInstance(I.value);if(!t){console.error(`Failed to initialize speech provider`);return}let n=w.getProviderConfig(I.value),r=F.value?P.generateSSML(e.data,te.value,{...n,pitch:ne.value}):e.data,i=await tn({...t.speech(L.value,n),input:r,voice:te.value.id}),a=await g.decodeAudioData(i);N.enqueue({audioBuffer:a,text:e.data})}catch(e){console.error(`Speech generation failed:`,e)}}let ie=ln({handlers:[re]}),ae=sn(ie),{currentMotion:oe}=D(Uh()),se=ln({handlers:[async e=>{if(d.value===`vrm`){let t=o[e.data];if(!t)return;await s.value.setExpression(t)}else d.value===`live2d`&&(oe.value={group:a[e.data]})}]}),ce=on(se);ce.onHandlerEvent(`emotion`,e=>{console.debug(`emotion detected`,e)});let le=an();le.onHandlerEvent(`delay`,e=>{console.debug(`delay detected`,e)});function ue(){requestAnimationFrame(ue),A.value&&(h.value=_(k.value,`linear`))}function de(){j.value||=(ue(),g.resume(),!0)}function fe(){k.value||=g.createAnalyser()}v(async()=>{if(M){try{M.stop(),M.disconnect()}catch{}M=null}N.clear(),fe(),de()}),y(async()=>{oe.value={group:l}}),b(async e=>{ae.enqueue(e)}),x(async e=>{le.enqueue(e),ce.enqueue(e)}),S(async()=>{le.enqueue(i)}),C(async e=>{}),Yt(()=>{j.value=!1}),Jt(async()=>{r.value=lL({connection:{bundles:Sn()}}),await r.value.execute(`CREATE TABLE memory_test (vec FLOAT[768]);`)});function pe(){if(d.value===`live2d`)return c.value?.canvasElement();if(d.value===`vrm`)return s.value?.canvasElement()}return n({canvasElement:pe}),(e,t)=>(Xt(),Ht(`div`,oV,[zt(`div`,sV,[Mt(d)===`live2d`&&O.value?(Xt(),Bt(eg,{key:0,ref_key:`live2dSceneRef`,ref:c,"min-w":`50% r.modelSrc),l=R(),u=R(),{scene:d}=b(),{onBeforeRender:f}=y(),m=hn(),h=R(),g=ez(),{modelOffset:_,modelOrigin:v,modelSize:x,cameraPosition:S,modelRotationY:C,lookAtTarget:w,eyeHeight:T,trackingMode:E,envSelect:O,specularMix:k,skyBoxIntensity:A}=D(g),j=R(),M=gn(),N=R(0);function ee(e){if(`matcap`in e&&e.matcap)return e.matcap;let t=e.uniforms;if(t){if(t.matcapTexture?.value)return t.matcapTexture.value;if(t.sphereAddTexture?.value)return t.sphereAddTexture.value;if(t._MatCapTex?.value)return t._MatCapTex.value;if(t._SphereAdd?.value)return t._SphereAdd.value}let n=e.userData||{},r=n.gltfExtensions?.VRMC_materials_mtoon||n.vrmMaterialProperties||n.mtoon;if(r){let e=r.matcapTexture||r.sphereAddTexture||r.matcap||r.sphereAdd;if(e&&e.isTexture)return e}return null}function I(e){let t=Array.from({length:9},()=>new Ze);if(!e)return t;for(let n=0;n<9;n++)t[n].copy(e.coefficients[n]);return t}async function L(){await p(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&&re(),!c.value)return;try{let e=await fn(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:p,initialCameraOffset:g}=e;j.value=n,S.value={x:o.x+g.x,y:o.y+g.y,z:o.z+g.z},v.value={x:o.x,y:o.y,z:o.z},x.value={x:p.x,y:p.y,z:p.z},j.value.position.set(_.value.x,_.value.y,_.value.z);let y=new Ze(0,0,-1),b=t.lookAt,D=new lt;if(b){let e=b.faceFront;D.setFromUnitVectors(e.normalize(),y.normalize()),n.quaternion.premultiply(D),n.updateMatrixWorld(!0)}else console.warn(`No look-at target found in VRM model`);C.value=0;function I(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 Ze;n.getWorldPosition(r);let i=e.tracks.find(e=>e.name.endsWith(`Hips.position`));if(!(i instanceof $e)){console.warn(`No Hips.position track of type VectorKeyframeTrack found in animation.`);return}let a=new Ze(i.values[0],i.values[1],i.values[2]),o=new Ze().subVectors(a,r);e.tracks.forEach(e=>{if(e.name.endsWith(`.position`)&&e instanceof $e)for(let t=0;t{if(e instanceof P&&e.material){let t=Array.isArray(e.material)?e.material:[e.material];t.forEach(e=>{if(e instanceof Ie||e instanceof Fe)e.envMapIntensity=1,e.needsUpdate=!0;else if(e instanceof Le||e instanceof Me||e instanceof Be||e instanceof mt){if(`toneMapped`in e&&(e.toneMapped=!1),`envMap`in e&&e.envMap&&(e.envMap=null),`map`in e&&e.map&&`colorSpace`in e.map)try{e.map.colorSpace=bt}catch{}let t=e.customProgramCacheKey?.()??``;e.customProgramCacheKey=()=>`${t}|npr:${N.value}`;let n=e.onBeforeCompile;e.onBeforeCompile=(t,i)=>{n?.(t,i);let a=r.nprEquirectTex??null,o=e;o.extensions={...o.extensions||{},shaderTextureLOD:!0};let s=ee(e),c=t.fragmentShader.includes(`vNormal`);if(!c)return;t.vertexShader.includes(`varying vec3 vWorldPos`)||(t.vertexShader=` + varying vec3 vWorldPos; + varying vec3 vWorldNormal; + ${t.vertexShader}`),t.fragmentShader.includes(`varying vec3 vWorldPos`)||(t.fragmentShader=` + varying vec3 vWorldPos; + varying vec3 vWorldNormal; + ${t.fragmentShader}`),t.vertexShader=t.vertexShader.replace(`#include `,` + #include + vWorldNormal = normalize( mat3( modelMatrix ) * objectNormal ); + `).replace(`#include `,` + #include + vWorldPos = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz; + `),t.uniforms.uNprEnvMode={value:O.value===`hemisphere`?0:2},t.uniforms.uEnvIntensity={value:A.value},t.uniforms.uEnvMapEquirect={value:a},t.uniforms.uSpecularMix={value:k.value},t.uniforms.uEnvMaxMip={value:8},t.uniforms.uBrightMip={value:2},t.uniforms.uShadowMip={value:8},t.uniforms.uHighlightTint={value:.6},t.uniforms.uShadowTint={value:.35},t.uniforms.uSpecToonThreshold={value:.9},t.uniforms.uSpecToonWidth={value:.15},t.uniforms.uSpecPower={value:10},t.uniforms.uSpecMip={value:8};let l=Array.from({length:9},()=>new Ze);t.uniforms.uSHCoeffs={value:l},t.uniforms.uUseMatcap={value:!1},t.uniforms.uMatcap={value:s??null},t.uniforms.uMatcapIntensity={value:1},t.fragmentShader=t.fragmentShader.replace(`#include `,` + #include + uniform int uNprEnvMode; // 0=off, 2=Skybox + uniform float uEnvIntensity; + uniform float uSpecularMix; // 0=diffuse only, 1=specular only + + uniform float uSpecToonThreshold; + uniform float uSpecToonWidth; + uniform float uSpecPower; + uniform bool uUseMatcap; + uniform sampler2D uMatcap; + uniform float uMatcapIntensity; + + uniform sampler2D uEnvMapEquirect; // Skybox(equirect) + + uniform vec3 uSHCoeffs[9]; // for irradiance + uniform float uSpecMip; // default LOD mip for specular + + // --- Direction to equirectangular UV --- + vec2 dirToEquirectUV(vec3 d){ + d = normalize(d); + float phi = atan(d.z, d.x); + float th = asin(clamp(d.y, -1.0, 1.0)); + return vec2(0.5 + phi/(2.0*PI), 0.5 - th/PI); + } + + // --- Spherical Harmonics (3rd order) for diffuse IBL --- + + // Constants for SH basis functions + const float C0 = 1.0 / (2.0 * sqrt(PI)); + const float C1 = sqrt(3.0 / PI) / 2.0; + const float C2 = sqrt(15.0 / PI) / 2.0; + const float C3 = sqrt(5.0 / PI) / 4.0; + const float C4 = sqrt(15.0 / PI) / 4.0; + + vec3 evalIrradianceSH( vec3 n ) { + vec3 sh = vec3(0.0); + sh += uSHCoeffs[0] * C0; + sh += uSHCoeffs[1] * (-C1 * n.y); + sh += uSHCoeffs[2] * ( C1 * n.z); + sh += uSHCoeffs[3] * (-C1 * n.x); + sh += uSHCoeffs[4] * ( C2 * n.x * n.y); + sh += uSHCoeffs[5] * (-C2 * n.y * n.z); + sh += uSHCoeffs[6] * ( C3 * (3.0 * n.z * n.z - 1.0)); + sh += uSHCoeffs[7] * (-C2 * n.x * n.z); + sh += uSHCoeffs[8] * ( C4 * (n.x * n.x - n.y * n.y)); + return sh; + } + `).replace(`#include `,` + // --- NPR skybox env lighting injection --- + vec3 n = normalize(vNormal); + vec3 nW = inverseTransformDirection(n, viewMatrix); + + vec3 envCol = vec3(0.0); + if(uNprEnvMode == 2) { + // View direction in world space + #ifdef USE_VIEWPOSITION + vec3 v = normalize(-vViewPosition); + vec3 vW = inverseTransformDirection(v, viewMatrix); + #else + vec3 vW = normalize(-cameraPosition); + #endif + + // Reflection direction in world space + vec3 rW = reflect(-vW, nW); + + // To resolve the upside-down reflection issue of equirect map + // nW.y = -nW.y; + // rW.y = -rW.y; + + // --- IBL Diffusion --- + // SH-based irradiance + vec3 I = evalIrradianceSH(nW); + vec3 albedo = gl_FragColor.rgb; + // albedo/pi * I(n) + vec3 envDiff = (albedo / 3.14159265) * I * (uEnvIntensity); + // TODO: Tint + + // --- IBL Specular reflection --- + // TODO: a more stylistic specular reflection model. Is specular necessary? + vec3 envSpec; + if (uUseMatcap) { + // Matcap-based specular + vec3 V = vec3(0.0, 0.0, 1.0); + vec3 nV = n; + vec3 R = reflect(-V, nV); + float m = 2.0 * sqrt( pow(R.x, 2.0) + pow(R.y, 2.0) + pow(R.z + 1.0, 2.0) ); + vec2 uvMC = R.xy / m * 0.5 + 0.5; + vec3 matcapCol = texture2D(uMatcap, uvMC).rgb; + envSpec = matcapCol * uMatcapIntensity; + } + else { + // Equirect-based specular, LOD needed for NPR + vec3 N = normalize(vWorldNormal); + vec3 V = normalize(cameraPosition - vWorldPos); // camera to frag + vec3 R = reflect(-V, N); + vec2 uvRef = dirToEquirectUV(R); + #if __VERSION__ >= 300 + vec3 envRef = textureLod(uEnvMapEquirect, uvRef, uSpecMip).rgb; + #else + #ifdef GL_EXT_shader_texture_lod + vec3 envRef = texture2DLodEXT(uEnvMapEquirect, uvRef, uSpecMip).rgb; + #else + vec3 envRef = texture2D(uEnvMapEquirect, uvRef).rgb; + #endif + #endif + // Blinn/Phong + float specRaw = clamp(dot(R, V), 0.0, 1.0); + float sToon = smoothstep(uSpecToonThreshold - uSpecToonWidth, + uSpecToonThreshold + uSpecToonWidth, specRaw); + envSpec = pow(sToon, uSpecPower) * envRef * uEnvIntensity; + } + + // Mix specular and diffuse + envCol = mix(envDiff, envSpec, uSpecularMix); + + // skybox color mixing + gl_FragColor.rgb += envCol; + } + // --- Injection ends --- + + #include + `),e.userData.__nprUniforms=t.uniforms},e.needsUpdate=!0}})}}),l.value=t,i(`modelReady`),s.value=!0;function ne(){let e=l.value?.humanoid?.getNormalizedBoneNode(`head`);if(!e)return null;let t=new Ze;return e.getWorldPosition(t),t.y}T.value=ne(),E.value=`none`,w.value={x:0,y:T.value,z:-1e3},a=f(({delta:e})=>{u.value?.update(e),l.value?.update(e),l.value?.lookAt?.update?.(e),m.update(l.value,e),M.update(l.value,w,e),h.value?.update(e)}).off}catch(e){i(`error`,e)}}catch(e){console.error(e)}finally{o.value=!1}}$t(_,()=>{j.value&&j.value.position.set(_.value.x,_.value.y,_.value.z)},{deep:!0}),$t(C,e=>{l.value&&j.value&&(j.value.rotation.y=fe.degToRad(e))}),$t(c,(e,t)=>{e!==t&&L()});let{pause:te,resume:ne}=y();$t(()=>r.paused,e=>e?te():ne());function re(){a?.(),l.value&&(l.value.scene.removeFromParent(),_n.deepDispose(l.value.scene))}function ie(e,t){let n=l.value?.scene;if(!n)return;let r=O.value===`skyBox`&&e?2:0;n.traverse(n=>{if(n instanceof P&&n.material){let i=Array.isArray(n.material)?n.material:[n.material];i.forEach(n=>{let i=n.userData?.__nprUniforms;if(i){if(i.uEnvMapEquirect.value=e,i.uNprEnvMode.value=r,i.uEnvIntensity.value=A.value,i.uSpecularMix.value=k.value,i.uSHCoeffs&&t){let e=I(t);for(let t=0;t<9;t++)i.uSHCoeffs.value[t].copy(e[t])}if(e?.image?.width&&e?.image?.height){let t=Math.floor(Math.log2(Math.max(e.image.width,e.image.height)));i.uEnvMaxMip.value=t,i.uShadowMip.value=t}}})}})}return $t(()=>[O.value,r.nprEquirectTex,A.value,k.value,r.nprIrrSH],async()=>{N.value+=1,ie(r.nprEquirectTex??null,r.nprIrrSH??null)},{immediate:!0,deep:!1}),Jt(async()=>await L()),Yt(()=>re()),t({setExpression(e){h.value?.setEmotionWithResetAfter(e,1e3)},scene:Tt(()=>l.value?.scene),lookAtUpdate(e){M.instantUpdate(l.value,e)}}),(e,t)=>s.value?Qt(e.$slots,`default`,{key:0}):Vt(``,!0)}}),dV=uV;const fV={type:`change`},pV={type:`start`},mV={type:`end`},hV=new ht,gV=new ct,_V=Math.cos(70*fe.DEG2RAD),vV=new Ze,yV=2*Math.PI,bV={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},xV=1e-6;var SV=class extends ve{constructor(e,t=null){super(e,t),this.state=bV.NONE,this.target=new Ze,this.cursor=new Ze,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:ue.ROTATE,MIDDLE:ue.DOLLY,RIGHT:ue.PAN},this.touches={ONE:Ue.ROTATE,TWO:Ue.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new Ze,this._lastQuaternion=new lt,this._lastTargetPosition=new Ze,this._quat=new lt().setFromUnitVectors(e.up,new Ze(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Ve,this._sphericalDelta=new Ve,this._scale=1,this._panOffset=new Ze,this._rotateStart=new Xe,this._rotateEnd=new Xe,this._rotateDelta=new Xe,this._panStart=new Xe,this._panEnd=new Xe,this._panDelta=new Xe,this._dollyStart=new Xe,this._dollyEnd=new Xe,this._dollyDelta=new Xe,this._dollyDirection=new Ze,this._mouse=new Xe,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=wV.bind(this),this._onPointerDown=CV.bind(this),this._onPointerUp=TV.bind(this),this._onContextMenu=MV.bind(this),this._onMouseWheel=OV.bind(this),this._onKeyDown=kV.bind(this),this._onTouchStart=AV.bind(this),this._onTouchMove=jV.bind(this),this._onMouseDown=EV.bind(this),this._onMouseMove=DV.bind(this),this._interceptControlDown=NV.bind(this),this._interceptControlUp=PV.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(fV),this.update(),this.state=bV.NONE}update(e=null){let t=this.object.position;vV.copy(t).sub(this.target),vV.applyQuaternion(this._quat),this._spherical.setFromVector3(vV),this.autoRotate&&this.state===bV.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+=yV:n>Math.PI&&(n-=yV),r<-Math.PI?r+=yV:r>Math.PI&&(r-=yV),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(vV.setFromSpherical(this._spherical),vV.applyQuaternion(this._quatInverse),t.copy(this.target).add(vV),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=vV.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 Ze(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 Ze(this._mouse.x,this._mouse.y,0);r.unproject(this.object),this.object.position.sub(r).add(t),this.object.updateMatrixWorld(),e=vV.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):(hV.origin.copy(this.object.position),hV.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(hV.direction))<_V?this.object.lookAt(this.target):(gV.setFromNormalAndCoplanarPoint(this.object.up,this.target),hV.intersectPlane(gV,this.target))))}else if(this.object.isOrthographicCamera){let e=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),e!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>xV||8*(1-this._lastQuaternion.dot(this.object.quaternion))>xV||this._lastTargetPosition.distanceToSquared(this.target)>xV?(this.dispatchEvent(fV),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?yV/60/60*this.autoRotateSpeed:yV/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){vV.setFromMatrixColumn(t,0),vV.multiplyScalar(-e),this._panOffset.add(vV)}_panUp(e,t){this.screenSpacePanning===!0?vV.setFromMatrixColumn(t,1):(vV.setFromMatrixColumn(t,0),vV.crossVectors(this.object.up,vV)),vV.multiplyScalar(e),this._panOffset.add(vV)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;vV.copy(r).sub(this.target);let i=vV.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(yV*this._rotateDelta.x/t.clientHeight),this._rotateUp(yV*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(yV*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(-yV*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(yV*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(-yV*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(yV*this._rotateDelta.x/t.clientHeight),this._rotateUp(yV*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 SV(n.value,r.value.domElement),i.value.enableDamping=!0,i.value.dampingFactor=.5,i.value.mouseButtons={LEFT:ue.ROTATE,MIDDLE:ue.DOLLY,RIGHT:ue.PAN},i.value.touches={ONE:Ue.ROTATE,TWO:Ue.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)=>Qt(e.$slots,`default`)}}),IV=FV;export{lV as b,aV as c,oz as d,ez as e,iN as f,hM as g,rM as h,eg as i,Gh as j,Uh as k,ep as l}; \ No newline at end of file