diff --git "a/assets/live2d-zip-loader-C5j9stxV.js" "b/assets/live2d-zip-loader-C5j9stxV.js" new file mode 100644--- /dev/null +++ "b/assets/live2d-zip-loader-C5j9stxV.js" @@ -0,0 +1,4089 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/default-node-BIhtlSJe.js","assets/index-Dlp4W1Zl.js","assets/index-DIu27PLL.css","assets/import-url-browser-CPN8ipMD.js","assets/duckdb-mvp-CaaD-olE.js","assets/import-url-node-BfNoxhRr.js"])))=>i.map(i=>d[i]); +var f1=Object.defineProperty;var p1=(r,t,e)=>t in r?f1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var W=(r,t,e)=>p1(r,typeof t!="symbol"?t+"":t,e);import{bm as If,ci as Dn,b2 as m1,a0 as g1,a9 as Fe,V as mt,Q as ne,a3 as Ps,ba as No,av as Hp,ag as Xp,ak as Yp,b3 as ec,b6 as Ef,cj as y1,$ as v1,ck as _1,a1 as b1,cl as Ho,cm as xn,W as qr,a4 as Wn,a_ as Ca,as as nr,cn as w1,X as Ui,b7 as x1,b5 as S1,co as qp,bb as Af,cp as T1,aj as Jl,J as co,bc as I1,bf as E1,bg as A1,bp as M1,cq as Ei}from"./index-Dlp4W1Zl.js";/*! + * @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 li;(function(r){r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2"})(li||(li={}));var Oa;(function(r){r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS"})(Oa||(Oa={}));var tu;(function(r){r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL"})(tu||(tu={}));var Qt;(function(r){r[r.NORMAL=0]="NORMAL",r[r.ADD=1]="ADD",r[r.MULTIPLY=2]="MULTIPLY",r[r.SCREEN=3]="SCREEN",r[r.OVERLAY=4]="OVERLAY",r[r.DARKEN=5]="DARKEN",r[r.LIGHTEN=6]="LIGHTEN",r[r.COLOR_DODGE=7]="COLOR_DODGE",r[r.COLOR_BURN=8]="COLOR_BURN",r[r.HARD_LIGHT=9]="HARD_LIGHT",r[r.SOFT_LIGHT=10]="SOFT_LIGHT",r[r.DIFFERENCE=11]="DIFFERENCE",r[r.EXCLUSION=12]="EXCLUSION",r[r.HUE=13]="HUE",r[r.SATURATION=14]="SATURATION",r[r.COLOR=15]="COLOR",r[r.LUMINOSITY=16]="LUMINOSITY",r[r.NORMAL_NPM=17]="NORMAL_NPM",r[r.ADD_NPM=18]="ADD_NPM",r[r.SCREEN_NPM=19]="SCREEN_NPM",r[r.NONE=20]="NONE",r[r.SRC_OVER=0]="SRC_OVER",r[r.SRC_IN=21]="SRC_IN",r[r.SRC_OUT=22]="SRC_OUT",r[r.SRC_ATOP=23]="SRC_ATOP",r[r.DST_OVER=24]="DST_OVER",r[r.DST_IN=25]="DST_IN",r[r.DST_OUT=26]="DST_OUT",r[r.DST_ATOP=27]="DST_ATOP",r[r.ERASE=26]="ERASE",r[r.SUBTRACT=28]="SUBTRACT",r[r.XOR=29]="XOR"})(Qt||(Qt={}));var Pa;(function(r){r[r.POINTS=0]="POINTS",r[r.LINES=1]="LINES",r[r.LINE_LOOP=2]="LINE_LOOP",r[r.LINE_STRIP=3]="LINE_STRIP",r[r.TRIANGLES=4]="TRIANGLES",r[r.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",r[r.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(Pa||(Pa={}));var xt;(function(r){r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL"})(xt||(xt={}));var _s;(function(r){r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z"})(_s||(_s={}));var fe;(function(r){r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT"})(fe||(fe={}));var eu;(function(r){r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT"})(eu||(eu={}));var Pr;(function(r){r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR"})(Pr||(Pr={}));var ru;(function(r){r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"})(ru||(ru={}));var Un;(function(r){r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL"})(Un||(Un={}));var Ci;(function(r){r[r.NPM=0]="NPM",r[r.UNPACK=1]="UNPACK",r[r.PMA=2]="PMA",r[r.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",r[r.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",r[r.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA",r[r.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA"})(Ci||(Ci={}));var hn;(function(r){r[r.NO=0]="NO",r[r.YES=1]="YES",r[r.AUTO=2]="AUTO",r[r.BLEND=0]="BLEND",r[r.CLEAR=1]="CLEAR",r[r.BLIT=2]="BLIT"})(hn||(hn={}));var nu;(function(r){r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL"})(nu||(nu={}));var Rr;(function(r){r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp"})(Rr||(Rr={}));var He;(function(r){r[r.NONE=0]="NONE",r[r.SCISSOR=1]="SCISSOR",r[r.STENCIL=2]="STENCIL",r[r.SPRITE=3]="SPRITE",r[r.COLOR=4]="COLOR"})(He||(He={}));var Qp;(function(r){r[r.RED=1]="RED",r[r.GREEN=2]="GREEN",r[r.BLUE=4]="BLUE",r[r.ALPHA=8]="ALPHA"})(Qp||(Qp={}));var Ve;(function(r){r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH"})(Ve||(Ve={}));var Nn;(function(r){r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER"})(Nn||(Nn={}));/*! + * @pixi/settings - v6.5.10 + * Compiled Thu, 06 Jul 2023 15:25:11 UTC + * + * @pixi/settings is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */var C1={createCanvas:function(r,t){var e=document.createElement("canvas");return e.width=r,e.height=t,e},getWebGLRenderingContext:function(){return WebGLRenderingContext},getNavigator:function(){return navigator},getBaseUrl:function(){var r;return(r=document.baseURI)!==null&&r!==void 0?r:window.location.href},fetch:function(r,t){return fetch(r,t)}},Nc=/iPhone/i,Zp=/iPod/i,Kp=/iPad/i,Jp=/\biOS-universal(?:.+)Mac\b/i,Bc=/\bAndroid(?:.+)Mobile\b/i,tm=/Android/i,ks=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,fl=/Silk/i,qn=/Windows Phone/i,em=/\bWindows(?:.+)ARM\b/i,rm=/BlackBerry/i,nm=/BB10/i,im=/Opera Mini/i,sm=/\b(CriOS|Chrome)(?:.+)Mobile/i,om=/Mobile(?:.+)Firefox\b/i,am=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function O1(r){return function(t){return t.test(r)}}function P1(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,n=e.split("[FBAN");typeof n[1]<"u"&&(e=n[0]),n=e.split("Twitter"),typeof n[1]<"u"&&(e=n[0]);var i=O1(e),s={apple:{phone:i(Nc)&&!i(qn),ipod:i(Zp),tablet:!i(Nc)&&(i(Kp)||am(t))&&!i(qn),universal:i(Jp),device:(i(Nc)||i(Zp)||i(Kp)||i(Jp)||am(t))&&!i(qn)},amazon:{phone:i(ks),tablet:!i(ks)&&i(fl),device:i(ks)||i(fl)},android:{phone:!i(qn)&&i(ks)||!i(qn)&&i(Bc),tablet:!i(qn)&&!i(ks)&&!i(Bc)&&(i(fl)||i(tm)),device:!i(qn)&&(i(ks)||i(fl)||i(Bc)||i(tm))||i(/\bokhttp\b/i)},windows:{phone:i(qn),tablet:i(em),device:i(qn)||i(em)},other:{blackberry:i(rm),blackberry10:i(nm),opera:i(im),firefox:i(om),chrome:i(sm),device:i(rm)||i(nm)||i(im)||i(om)||i(sm)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}var ms=P1(globalThis.navigator);function R1(){return!ms.apple.device}function F1(r){var t=!0;if(ms.tablet||ms.phone){if(ms.apple.device){var e=navigator.userAgent.match(/OS (\d+)_(\d+)?/);if(e){var n=parseInt(e[1],10);n<11&&(t=!1)}}if(ms.android.device){var e=navigator.userAgent.match(/Android\s([0-9.]*)/);if(e){var n=parseInt(e[1],10);n<7&&(t=!1)}}}return t?r:4}var At={ADAPTER:C1,MIPMAP_TEXTURES:Un.POW2,ANISOTROPIC_LEVEL:0,RESOLUTION:1,FILTER_RESOLUTION:1,FILTER_MULTISAMPLE:Ve.NONE,SPRITE_MAX_TEXTURES:F1(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:nu.AUTO,GC_MAX_IDLE:60*60,GC_MAX_CHECK_COUNT:60*10,WRAP_MODE:ru.CLAMP,SCALE_MODE:Pr.LINEAR,PRECISION_VERTEX:Rr.HIGH,PRECISION_FRAGMENT:ms.apple.device?Rr.HIGH:Rr.MEDIUM,CAN_UPLOAD_SAME_BUFFER:R1(),CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1},Uc={exports:{}},lm;function D1(){return lm||(lm=1,function(r){var t=Object.prototype.hasOwnProperty,e="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(e=!1));function i(l,u,c){this.fn=l,this.context=u,this.once=c||!1}function s(l,u,c,h,f){if(typeof c!="function")throw new TypeError("The listener must be a function");var d=new i(c,h||l,f),m=e?e+u:u;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],d]:l._events[m].push(d):(l._events[m]=d,l._eventsCount++),l}function o(l,u){--l._eventsCount===0?l._events=new n:delete l._events[u]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var u=[],c,h;if(this._eventsCount===0)return u;for(h in c=this._events)t.call(c,h)&&u.push(e?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(c)):u},a.prototype.listeners=function(u){var c=e?e+u:u,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var f=0,d=h.length,m=new Array(d);f80*R){j=tt=P[0],et=gt=P[1];for(var vt=R;vttt&&(tt=_t),ct>gt&&(gt=ct);bt=Math.max(tt-j,gt-et),bt=bt!==0?32767/bt:0}return n(M,O,R,j,et,bt,0),O}function t(P,C,R,z,U){var M,O;if(U===nt(P,C,R,z)>0)for(M=C;M=C;M-=z)O=I(M,P[M],P[M+1],O);return O&&T(O,O.next)&&(Z(O),O=O.next),O}function e(P,C){if(!P)return P;C||(C=P);var R=P,z;do if(z=!1,!R.steiner&&(T(R,R.next)||S(R.prev,R,R.next)===0)){if(Z(R),R=C=R.prev,R===R.next)break;z=!0}else R=R.next;while(z||R!==C);return C}function n(P,C,R,z,U,M,O){if(P){!O&&M&&d(P,z,U,M);for(var j=P,et,tt;P.prev!==P.next;){if(et=P.prev,tt=P.next,M?s(P,z,U,M):i(P)){C.push(et.i/R|0),C.push(P.i/R|0),C.push(tt.i/R|0),Z(P),P=tt.next,j=tt.next;continue}if(P=tt,P===j){O?O===1?(P=o(e(P),C,R),n(P,C,R,z,U,M,2)):O===2&&a(P,C,R,z,U,M):n(e(P),C,R,z,U,M,1);break}}}}function i(P){var C=P.prev,R=P,z=P.next;if(S(C,R,z)>=0)return!1;for(var U=C.x,M=R.x,O=z.x,j=C.y,et=R.y,tt=z.y,gt=UM?U>O?U:O:M>O?M:O,bt=j>et?j>tt?j:tt:et>tt?et:tt,vt=z.next;vt!==C;){if(vt.x>=gt&&vt.x<=ct&&vt.y>=_t&&vt.y<=bt&&y(U,j,M,et,O,tt,vt.x,vt.y)&&S(vt.prev,vt,vt.next)>=0)return!1;vt=vt.next}return!0}function s(P,C,R,z){var U=P.prev,M=P,O=P.next;if(S(U,M,O)>=0)return!1;for(var j=U.x,et=M.x,tt=O.x,gt=U.y,_t=M.y,ct=O.y,bt=jet?j>tt?j:tt:et>tt?et:tt,re=gt>_t?gt>ct?gt:ct:_t>ct?_t:ct,ue=g(bt,vt,C,R,z),b=g(Et,re,C,R,z),K=P.prevZ,Q=P.nextZ;K&&K.z>=ue&&Q&&Q.z<=b;){if(K.x>=bt&&K.x<=Et&&K.y>=vt&&K.y<=re&&K!==U&&K!==O&&y(j,gt,et,_t,tt,ct,K.x,K.y)&&S(K.prev,K,K.next)>=0||(K=K.prevZ,Q.x>=bt&&Q.x<=Et&&Q.y>=vt&&Q.y<=re&&Q!==U&&Q!==O&&y(j,gt,et,_t,tt,ct,Q.x,Q.y)&&S(Q.prev,Q,Q.next)>=0))return!1;Q=Q.nextZ}for(;K&&K.z>=ue;){if(K.x>=bt&&K.x<=Et&&K.y>=vt&&K.y<=re&&K!==U&&K!==O&&y(j,gt,et,_t,tt,ct,K.x,K.y)&&S(K.prev,K,K.next)>=0)return!1;K=K.prevZ}for(;Q&&Q.z<=b;){if(Q.x>=bt&&Q.x<=Et&&Q.y>=vt&&Q.y<=re&&Q!==U&&Q!==O&&y(j,gt,et,_t,tt,ct,Q.x,Q.y)&&S(Q.prev,Q,Q.next)>=0)return!1;Q=Q.nextZ}return!0}function o(P,C,R){var z=P;do{var U=z.prev,M=z.next.next;!T(U,M)&&v(U,z,z.next,M)&&N(U,M)&&N(M,U)&&(C.push(U.i/R|0),C.push(z.i/R|0),C.push(M.i/R|0),Z(z),Z(z.next),z=P=M),z=z.next}while(z!==P);return e(z)}function a(P,C,R,z,U,M){var O=P;do{for(var j=O.next.next;j!==O.prev;){if(O.i!==j.i&&_(O,j)){var et=it(O,j);O=e(O,O.next),et=e(et,et.next),n(O,C,R,z,U,M,0),n(et,C,R,z,U,M,0);return}j=j.next}O=O.next}while(O!==P)}function l(P,C,R,z){var U=[],M,O,j,et,tt;for(M=0,O=C.length;M=R.next.y&&R.next.y!==R.y){var j=R.x+(U-R.y)*(R.next.x-R.x)/(R.next.y-R.y);if(j<=z&&j>M&&(M=j,O=R.x=R.x&&R.x>=tt&&z!==R.x&&y(UO.x||R.x===O.x&&f(O,R)))&&(O=R,_t=ct)),R=R.next;while(R!==et);return O}function f(P,C){return S(P.prev,P,C.prev)<0&&S(C.next,P,P.next)<0}function d(P,C,R,z){var U=P;do U.z===0&&(U.z=g(U.x,U.y,C,R,z)),U.prevZ=U.prev,U.nextZ=U.next,U=U.next;while(U!==P);U.prevZ.nextZ=null,U.prevZ=null,m(U)}function m(P){var C,R,z,U,M,O,j,et,tt=1;do{for(R=P,P=null,M=null,O=0;R;){for(O++,z=R,j=0,C=0;C0||et>0&&z;)j!==0&&(et===0||!z||R.z<=z.z)?(U=R,R=R.nextZ,j--):(U=z,z=z.nextZ,et--),M?M.nextZ=U:P=U,U.prevZ=M,M=U;R=z}M.nextZ=null,tt*=2}while(O>1);return P}function g(P,C,R,z,U){return P=(P-R)*U|0,C=(C-z)*U|0,P=(P|P<<8)&16711935,P=(P|P<<4)&252645135,P=(P|P<<2)&858993459,P=(P|P<<1)&1431655765,C=(C|C<<8)&16711935,C=(C|C<<4)&252645135,C=(C|C<<2)&858993459,C=(C|C<<1)&1431655765,P|C<<1}function p(P){var C=P,R=P;do(C.x=(P-O)*(M-j)&&(P-O)*(z-j)>=(R-O)*(C-j)&&(R-O)*(M-j)>=(U-O)*(z-j)}function _(P,C){return P.next.i!==C.i&&P.prev.i!==C.i&&!B(P,C)&&(N(P,C)&&N(C,P)&&$(P,C)&&(S(P.prev,P,C.prev)||S(P,C.prev,C))||T(P,C)&&S(P.prev,P,P.next)>0&&S(C.prev,C,C.next)>0)}function S(P,C,R){return(C.y-P.y)*(R.x-C.x)-(C.x-P.x)*(R.y-C.y)}function T(P,C){return P.x===C.x&&P.y===C.y}function v(P,C,R,z){var U=w(S(P,C,R)),M=w(S(P,C,z)),O=w(S(R,z,P)),j=w(S(R,z,C));return!!(U!==M&&O!==j||U===0&&E(P,R,C)||M===0&&E(P,z,C)||O===0&&E(R,P,z)||j===0&&E(R,C,z))}function E(P,C,R){return C.x<=Math.max(P.x,R.x)&&C.x>=Math.min(P.x,R.x)&&C.y<=Math.max(P.y,R.y)&&C.y>=Math.min(P.y,R.y)}function w(P){return P>0?1:P<0?-1:0}function B(P,C){var R=P;do{if(R.i!==P.i&&R.next.i!==P.i&&R.i!==C.i&&R.next.i!==C.i&&v(R,R.next,P,C))return!0;R=R.next}while(R!==P);return!1}function N(P,C){return S(P.prev,P,P.next)<0?S(P,C,P.next)>=0&&S(P,P.prev,C)>=0:S(P,C,P.prev)<0||S(P,P.next,C)<0}function $(P,C){var R=P,z=!1,U=(P.x+C.x)/2,M=(P.y+C.y)/2;do R.y>M!=R.next.y>M&&R.next.y!==R.y&&U<(R.next.x-R.x)*(M-R.y)/(R.next.y-R.y)+R.x&&(z=!z),R=R.next;while(R!==P);return z}function it(P,C){var R=new x(P.i,P.x,P.y),z=new x(C.i,C.x,C.y),U=P.next,M=C.prev;return P.next=C,C.prev=P,R.next=U,U.prev=R,z.next=R,R.prev=z,M.next=z,z.prev=M,z}function I(P,C,R,z){var U=new x(P,C,R);return z?(U.next=z.next,U.prev=z,z.next.prev=U,z.next=U):(U.prev=U,U.next=U),U}function Z(P){P.next.prev=P.prev,P.prev.next=P.next,P.prevZ&&(P.prevZ.nextZ=P.nextZ),P.nextZ&&(P.nextZ.prevZ=P.prevZ)}function x(P,C,R){this.i=P,this.x=C,this.y=R,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}r.deviation=function(P,C,R,z){var U=C&&C.length,M=U?C[0]*R:P.length,O=Math.abs(nt(P,0,M,R));if(U)for(var j=0,et=C.length;j0&&(z+=P[U-1].length,R.holes.push(z))}return R},pl.exports}N1();var Hi={},aa={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var B1=aa.exports,cm;function U1(){return cm||(cm=1,function(r,t){(function(e){var n=t&&!t.nodeType&&t,i=r&&!r.nodeType&&r,s=typeof Dn=="object"&&Dn;(s.global===s||s.window===s||s.self===s)&&(e=s);var o,a=2147483647,l=36,u=1,c=26,h=38,f=700,d=72,m=128,g="-",p=/^xn--/,y=/[^\x20-\x7E]/,_=/[\x2E\u3002\uFF0E\uFF61]/g,S={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},T=l-u,v=Math.floor,E=String.fromCharCode,w;function B(U){throw new RangeError(S[U])}function N(U,M){for(var O=U.length,j=[];O--;)j[O]=M(U[O]);return j}function $(U,M){var O=U.split("@"),j="";O.length>1&&(j=O[0]+"@",U=O[1]),U=U.replace(_,".");var et=U.split("."),tt=N(et,M).join(".");return j+tt}function it(U){for(var M=[],O=0,j=U.length,et,tt;O=55296&&et<=56319&&O65535&&(M-=65536,O+=E(M>>>10&1023|55296),M=56320|M&1023),O+=E(M),O}).join("")}function Z(U){return U-48<10?U-22:U-65<26?U-65:U-97<26?U-97:l}function x(U,M){return U+22+75*(U<26)-((M!=0)<<5)}function nt(U,M,O){var j=0;for(U=O?v(U/f):U>>1,U+=v(U/M);U>T*c>>1;j+=l)U=v(U/T);return v(j+(T+1)*U/(U+h))}function P(U){var M=[],O=U.length,j,et=0,tt=m,gt=d,_t,ct,bt,vt,Et,re,ue,b,K;for(_t=U.lastIndexOf(g),_t<0&&(_t=0),ct=0;ct<_t;++ct)U.charCodeAt(ct)>=128&&B("not-basic"),M.push(U.charCodeAt(ct));for(bt=_t>0?_t+1:0;bt=O&&B("invalid-input"),ue=Z(U.charCodeAt(bt++)),(ue>=l||ue>v((a-et)/Et))&&B("overflow"),et+=ue*Et,b=re<=gt?u:re>=gt+c?c:re-gt,!(uev(a/K)&&B("overflow"),Et*=K;j=M.length+1,gt=nt(et-vt,j,vt==0),v(et/j)>a-tt&&B("overflow"),tt+=v(et/j),et%=j,M.splice(et++,0,tt)}return I(M)}function C(U){var M,O,j,et,tt,gt,_t,ct,bt,vt,Et,re=[],ue,b,K,Q;for(U=it(U),ue=U.length,M=m,O=0,tt=d,gt=0;gt=M&&Et<_t&&(_t=Et);for(b=j+1,_t-M>v((a-O)/b)&&B("overflow"),O+=(_t-M)*b,M=_t,gt=0;gta&&B("overflow"),Et==M){for(ct=O,bt=l;vt=bt<=tt?u:bt>=tt+c?c:bt-tt,!(ct{if(u&&(typeof u=="object"||typeof u=="function")){if(n)return n.get(u)}else if(i)return i.get(u)},o=(u,c)=>{u&&(typeof u=="object"||typeof u=="function")?(n||(n=new WeakMap),n.set(u,c)):(i||(i=new Map),i.set(u,c))},a=u=>{if(u&&(typeof u=="object"||typeof u=="function")){if(n)return n.has(u)}else if(i)return i.has(u);return!1};return{get:s,set:o,has:a,assert:u=>{if(!a(u))throw new TypeError("Side channel does not contain the given key")}}}t.default=e,(typeof t.default=="object"&&t.default!==null||typeof t.default=="function")&&(Object.assign(t.default,t),r.exports=t.default)}(ml,ml.exports)),ml.exports}var kc,dm;function Mf(){if(dm)return kc;dm=1;var r=String.prototype.replace,t=/%20/g,e={RFC1738:"RFC1738",RFC3986:"RFC3986"};return kc={default:e.RFC3986,formatters:{RFC1738:function(n){return r.call(n,t,"+")},RFC3986:function(n){return String(n)}},RFC1738:e.RFC1738,RFC3986:e.RFC3986},kc}var zc,fm;function x0(){if(fm)return zc;fm=1;var r=Mf(),t=Object.prototype.hasOwnProperty,e=Array.isArray,n=function(){for(var p=[],y=0;y<256;++y)p.push("%"+((y<16?"0":"")+y.toString(16)).toUpperCase());return p}(),i=function(y){for(;y.length>1;){var _=y.pop(),S=_.obj[_.prop];if(e(S)){for(var T=[],v=0;v=u?E.slice(B,B+u):E,$=[],it=0;it=48&&I<=57||I>=65&&I<=90||I>=97&&I<=122||v===r.RFC1738&&(I===40||I===41)){$[$.length]=N.charAt(it);continue}if(I<128){$[$.length]=n[I];continue}if(I<2048){$[$.length]=n[192|I>>6]+n[128|I&63];continue}if(I<55296||I>=57344){$[$.length]=n[224|I>>12]+n[128|I>>6&63]+n[128|I&63];continue}it+=1,I=65536+((I&1023)<<10|N.charCodeAt(it)&1023),$[$.length]=n[240|I>>18]+n[128|I>>12&63]+n[128|I>>6&63]+n[128|I&63]}w+=$.join("")}return w},h=function(y){for(var _=[{obj:{o:y},prop:"o"}],S=[],T=0;T<_.length;++T)for(var v=_[T],E=v.obj[v.prop],w=Object.keys(E),B=0;B"u"&&(U=0)}if(typeof N=="function"?R=N(y,R):R instanceof Date?R=I(R):_==="comma"&&s(R)&&(R=t.maybeMap(R,function(K){return K instanceof Date?I(K):K})),R===null){if(v)return B&&!nt?B(y,c.encoder,P,"key",Z):y;R=""}if(h(R)||t.isBuffer(R)){if(B){var j=nt?y:B(y,c.encoder,P,"key",Z);return[x(j)+"="+x(B(R,c.encoder,P,"value",Z))]}return[x(y)+"="+x(String(R))]}var et=[];if(typeof R>"u")return et;var tt;if(_==="comma"&&s(R))nt&&B&&(R=t.maybeMap(R,B)),tt=[{value:R.length>0?R.join(",")||null:void 0}];else if(s(N))tt=N;else{var gt=Object.keys(R);tt=$?gt.sort($):gt}var _t=w?String(y).replace(/\./g,"%2E"):String(y),ct=S&&s(R)&&R.length===1?_t+"[]":_t;if(T&&s(R)&&R.length===0)return ct+"[]";for(var bt=0;bt"u"?p.encodeDotInKeys===!0?!0:c.allowDots:!!p.allowDots;return{addQueryPrefix:typeof p.addQueryPrefix=="boolean"?p.addQueryPrefix:c.addQueryPrefix,allowDots:E,allowEmptyArrays:typeof p.allowEmptyArrays=="boolean"?!!p.allowEmptyArrays:c.allowEmptyArrays,arrayFormat:v,charset:y,charsetSentinel:typeof p.charsetSentinel=="boolean"?p.charsetSentinel:c.charsetSentinel,commaRoundTrip:!!p.commaRoundTrip,delimiter:typeof p.delimiter>"u"?c.delimiter:p.delimiter,encode:typeof p.encode=="boolean"?p.encode:c.encode,encodeDotInKeys:typeof p.encodeDotInKeys=="boolean"?p.encodeDotInKeys:c.encodeDotInKeys,encoder:typeof p.encoder=="function"?p.encoder:c.encoder,encodeValuesOnly:typeof p.encodeValuesOnly=="boolean"?p.encodeValuesOnly:c.encodeValuesOnly,filter:T,format:_,formatter:S,serializeDate:typeof p.serializeDate=="function"?p.serializeDate:c.serializeDate,skipNulls:typeof p.skipNulls=="boolean"?p.skipNulls:c.skipNulls,sort:typeof p.sort=="function"?p.sort:null,strictNullHandling:typeof p.strictNullHandling=="boolean"?p.strictNullHandling:c.strictNullHandling}};return Vc=function(g,p){var y=g,_=m(p),S,T;typeof _.filter=="function"?(T=_.filter,y=T("",y)):s(_.filter)&&(T=_.filter,S=T);var v=[];if(typeof y!="object"||y===null)return"";var E=i[_.arrayFormat],w=E==="comma"&&_.commaRoundTrip;S||(S=Object.keys(y)),_.sort&&S.sort(_.sort);for(var B=r(),N=0;N0?Z+I:""},Vc}var jc,mm;function V1(){if(mm)return jc;mm=1;var r=x0(),t=Object.prototype.hasOwnProperty,e=Array.isArray,n={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:r.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},i=function(f){return f.replace(/&#(\d+);/g,function(d,m){return String.fromCharCode(parseInt(m,10))})},s=function(f,d,m){if(f&&typeof f=="string"&&d.comma&&f.indexOf(",")>-1)return f.split(",");if(d.throwOnLimitExceeded&&m>=d.arrayLimit)throw new RangeError("Array limit exceeded. Only "+d.arrayLimit+" element"+(d.arrayLimit===1?"":"s")+" allowed in an array.");return f},o="utf8=%26%2310003%3B",a="utf8=%E2%9C%93",l=function(d,m){var g={__proto__:null},p=m.ignoreQueryPrefix?d.replace(/^\?/,""):d;p=p.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var y=m.parameterLimit===1/0?void 0:m.parameterLimit,_=p.split(m.delimiter,m.throwOnLimitExceeded?y+1:y);if(m.throwOnLimitExceeded&&_.length>y)throw new RangeError("Parameter limit exceeded. Only "+y+" parameter"+(y===1?"":"s")+" allowed.");var S=-1,T,v=m.charset;if(m.charsetSentinel)for(T=0;T<_.length;++T)_[T].indexOf("utf8=")===0&&(_[T]===a?v="utf-8":_[T]===o&&(v="iso-8859-1"),S=T,T=_.length);for(T=0;T<_.length;++T)if(T!==S){var E=_[T],w=E.indexOf("]="),B=w===-1?E.indexOf("="):w+1,N,$;B===-1?(N=m.decoder(E,n.decoder,v,"key"),$=m.strictNullHandling?null:""):(N=m.decoder(E.slice(0,B),n.decoder,v,"key"),$=r.maybeMap(s(E.slice(B+1),m,e(g[N])?g[N].length:0),function(I){return m.decoder(I,n.decoder,v,"value")})),$&&m.interpretNumericEntities&&v==="iso-8859-1"&&($=i(String($))),E.indexOf("[]=")>-1&&($=e($)?[$]:$);var it=t.call(g,N);it&&m.duplicates==="combine"?g[N]=r.combine(g[N],$):(!it||m.duplicates==="last")&&(g[N]=$)}return g},u=function(f,d,m,g){var p=0;if(f.length>0&&f[f.length-1]==="[]"){var y=f.slice(0,-1).join("");p=Array.isArray(d)&&d[y]?d[y].length:0}for(var _=g?d:s(d,m,p),S=f.length-1;S>=0;--S){var T,v=f[S];if(v==="[]"&&m.parseArrays)T=m.allowEmptyArrays&&(_===""||m.strictNullHandling&&_===null)?[]:r.combine([],_);else{T=m.plainObjects?{__proto__:null}:{};var E=v.charAt(0)==="["&&v.charAt(v.length-1)==="]"?v.slice(1,-1):v,w=m.decodeDotInKeys?E.replace(/%2E/g,"."):E,B=parseInt(w,10);!m.parseArrays&&w===""?T={0:_}:!isNaN(B)&&v!==w&&String(B)===w&&B>=0&&m.parseArrays&&B<=m.arrayLimit?(T=[],T[B]=_):w!=="__proto__"&&(T[w]=_)}_=T}return _},c=function(d,m,g,p){if(d){var y=g.allowDots?d.replace(/\.([^.[]+)/g,"[$1]"):d,_=/(\[[^[\]]*])/,S=/(\[[^[\]]*])/g,T=g.depth>0&&_.exec(y),v=T?y.slice(0,T.index):y,E=[];if(v){if(!g.plainObjects&&t.call(Object.prototype,v)&&!g.allowPrototypes)return;E.push(v)}for(var w=0;g.depth>0&&(T=S.exec(y))!==null&&w"u"?n.charset:d.charset,g=typeof d.duplicates>"u"?n.duplicates:d.duplicates;if(g!=="combine"&&g!=="first"&&g!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var p=typeof d.allowDots>"u"?d.decodeDotInKeys===!0?!0:n.allowDots:!!d.allowDots;return{allowDots:p,allowEmptyArrays:typeof d.allowEmptyArrays=="boolean"?!!d.allowEmptyArrays:n.allowEmptyArrays,allowPrototypes:typeof d.allowPrototypes=="boolean"?d.allowPrototypes:n.allowPrototypes,allowSparse:typeof d.allowSparse=="boolean"?d.allowSparse:n.allowSparse,arrayLimit:typeof d.arrayLimit=="number"?d.arrayLimit:n.arrayLimit,charset:m,charsetSentinel:typeof d.charsetSentinel=="boolean"?d.charsetSentinel:n.charsetSentinel,comma:typeof d.comma=="boolean"?d.comma:n.comma,decodeDotInKeys:typeof d.decodeDotInKeys=="boolean"?d.decodeDotInKeys:n.decodeDotInKeys,decoder:typeof d.decoder=="function"?d.decoder:n.decoder,delimiter:typeof d.delimiter=="string"||r.isRegExp(d.delimiter)?d.delimiter:n.delimiter,depth:typeof d.depth=="number"||d.depth===!1?+d.depth:n.depth,duplicates:g,ignoreQueryPrefix:d.ignoreQueryPrefix===!0,interpretNumericEntities:typeof d.interpretNumericEntities=="boolean"?d.interpretNumericEntities:n.interpretNumericEntities,parameterLimit:typeof d.parameterLimit=="number"?d.parameterLimit:n.parameterLimit,parseArrays:d.parseArrays!==!1,plainObjects:typeof d.plainObjects=="boolean"?d.plainObjects:n.plainObjects,strictDepth:typeof d.strictDepth=="boolean"?!!d.strictDepth:n.strictDepth,strictNullHandling:typeof d.strictNullHandling=="boolean"?d.strictNullHandling:n.strictNullHandling,throwOnLimitExceeded:typeof d.throwOnLimitExceeded=="boolean"?d.throwOnLimitExceeded:!1}};return jc=function(f,d){var m=h(d);if(f===""||f===null||typeof f>"u")return m.plainObjects?{__proto__:null}:{};for(var g=typeof f=="string"?l(f,m):f,p=m.plainObjects?{__proto__:null}:{},y=Object.keys(g),_=0;_",'"',"`"," ","\r",` +`," "],o=["{","}","|","\\","^","`"].concat(s),a=["'"].concat(o),l=["%","/","?",";","#"].concat(a),u=["/","?","#"],c=255,h=/^[+a-z0-9A-Z_-]{0,63}$/,f=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,d={javascript:!0,"javascript:":!0},m={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},p=j1();function y(v,E,w){if(v&&typeof v=="object"&&v instanceof t)return v;var B=new t;return B.parse(v,E,w),B}t.prototype.parse=function(v,E,w){if(typeof v!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof v);var B=v.indexOf("?"),N=B!==-1&&B127?gt+="x":gt+=tt[_t];if(!gt.match(h)){var bt=j.slice(0,R),vt=j.slice(R+1),Et=tt.match(f);Et&&(bt.push(Et[1]),vt.unshift(Et[2])),vt.length&&(I="/"+vt.join(".")+I),this.hostname=bt.join(".");break}}}this.hostname.length>c?this.hostname="":this.hostname=this.hostname.toLowerCase(),O||(this.hostname=r.toASCII(this.hostname));var re=this.port?":"+this.port:"",ue=this.hostname||"";this.host=ue+re,this.href+=this.host,O&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),I[0]!=="/"&&(I="/"+I))}if(!d[nt])for(var R=0,et=a.length;R0?w.host.split("@"):!1;gt&&(w.auth=gt.shift(),w.hostname=gt.shift(),w.host=w.hostname)}return w.search=v.search,w.query=v.query,(w.pathname!==null||w.search!==null)&&(w.path=(w.pathname?w.pathname:"")+(w.search?w.search:"")),w.href=w.format(),w}if(!j.length)return w.pathname=null,w.search?w.path="/"+w.search:w.path=null,w.href=w.format(),w;for(var _t=j.slice(-1)[0],ct=(w.host||v.host||j.length>1)&&(_t==="."||_t==="..")||_t==="",bt=0,vt=j.length;vt>=0;vt--)_t=j[vt],_t==="."?j.splice(vt,1):_t===".."?(j.splice(vt,1),bt++):bt&&(j.splice(vt,1),bt--);if(!M&&!O)for(;bt--;bt)j.unshift("..");M&&j[0]!==""&&(!j[0]||j[0].charAt(0)!=="/")&&j.unshift(""),ct&&j.join("/").substr(-1)!=="/"&&j.push("");var Et=j[0]===""||j[0]&&j[0].charAt(0)==="/";if(tt){w.hostname=Et?"":j.length?j.shift():"",w.host=w.hostname;var gt=w.host&&w.host.indexOf("@")>0?w.host.split("@"):!1;gt&&(w.auth=gt.shift(),w.hostname=gt.shift(),w.host=w.hostname)}return M=M||w.host&&j.length,M&&!Et&&j.unshift(""),j.length>0?w.pathname=j.join("/"):(w.pathname=null,w.path=null),(w.pathname!==null||w.search!==null)&&(w.path=(w.pathname?w.pathname:"")+(w.search?w.search:"")),w.auth=v.auth||w.auth,w.slashes=w.slashes||v.slashes,w.href=w.format(),w},t.prototype.parseHost=function(){var v=this.host,E=n.exec(v);E&&(E=E[0],E!==":"&&(this.port=E.substr(1)),v=v.substr(0,v.length-E.length)),v&&(this.hostname=v)},Hi.parse=y,Hi.resolve=S,Hi.resolveObject=T,Hi.format=_,Hi.Url=t,Hi}var Gc=$1();/*! + * @pixi/utils - v6.5.10 + * Compiled Thu, 06 Jul 2023 15:25:11 UTC + * + * @pixi/utils is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */var rc={parse:Gc.parse,format:Gc.format,resolve:Gc.resolve};At.RETINA_PREFIX=/@([0-9\.]+)x/;At.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var vm=!1,_m="6.5.10";function G1(r){var t;if(!vm){if(At.ADAPTER.getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){var e=[` + %c %c %c PixiJS `+_m+" - ✰ "+r+` ✰ %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,e)}else globalThis.console&&globalThis.console.log("PixiJS "+_m+" - "+r+" - http://www.pixijs.com/");vm=!0}}var Wc;function W1(){return typeof Wc>"u"&&(Wc=function(){var t={stencil:!0,failIfMajorPerformanceCaveat:At.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!At.ADAPTER.getWebGLRenderingContext())return!1;var e=At.ADAPTER.createCanvas(),n=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),i=!!(n&&n.getContextAttributes().stencil);if(n){var s=n.getExtension("WEBGL_lose_context");s&&s.loseContext()}return n=null,i}catch{return!1}}()),Wc}function en(r,t){return t===void 0&&(t=[]),t[0]=(r>>16&255)/255,t[1]=(r>>8&255)/255,t[2]=(r&255)/255,t}function H1(r){var t=r.toString(16);return t="000000".substring(0,6-t.length)+t,"#"+t}function fn(r){return(r[0]*255<<16)+(r[1]*255<<8)+(r[2]*255|0)}function X1(){for(var r=[],t=[],e=0;e<32;e++)r[e]=e,t[e]=e;r[Qt.NORMAL_NPM]=Qt.NORMAL,r[Qt.ADD_NPM]=Qt.ADD,r[Qt.SCREEN_NPM]=Qt.SCREEN,t[Qt.NORMAL]=Qt.NORMAL_NPM,t[Qt.ADD]=Qt.ADD_NPM,t[Qt.SCREEN]=Qt.SCREEN_NPM;var n=[];return n.push(t),n.push(r),n}var Y1=X1();function q1(r,t){if(t===1)return(t*255<<24)+r;if(t===0)return 0;var e=r>>16&255,n=r>>8&255,i=r&255;return e=e*t+.5|0,n=n*t+.5|0,i=i*t+.5|0,(t*255<<24)+(e<<16)+(n<<8)+i}function S0(r){if(r.BYTES_PER_ELEMENT===4)return r instanceof Float32Array?"Float32Array":r instanceof Uint32Array?"Uint32Array":"Int32Array";if(r.BYTES_PER_ELEMENT===2){if(r instanceof Uint16Array)return"Uint16Array"}else if(r.BYTES_PER_ELEMENT===1&&r instanceof Uint8Array)return"Uint8Array";return null}function iu(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function bm(r){return!(r&r-1)&&!!r}function wm(r){var t=(r>65535?1:0)<<4;r>>>=t;var e=(r>255?1:0)<<3;return r>>>=e,t|=e,e=(r>15?1:0)<<2,r>>>=e,t|=e,e=(r>3?1:0)<<1,r>>>=e,t|=e,t|r>>1}function Nl(r,t,e){var n=r.length,i;if(!(t>=n||e===0)){e=t+e>n?n-t:e;var s=n-e;for(i=t;i"u"?console.warn("PixiJS Deprecation Warning: ",t+` +Deprecated since v`+r):(n=n.split(` +`).splice(e).join(` +`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",t+` +Deprecated since v`+r),console.warn(n),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",t+` +Deprecated since v`+r),console.warn(n))),xm[t]=!0}}var Sm={},Qn=Object.create(null),Xi=Object.create(null);(function(){function r(t,e,n){this.canvas=At.ADAPTER.createCanvas(),this.context=this.canvas.getContext("2d"),this.resolution=n||At.RESOLUTION,this.resize(t,e)}return r.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height)},r.prototype.resize=function(t,e){this.canvas.width=Math.round(t*this.resolution),this.canvas.height=Math.round(e*this.resolution)},r.prototype.destroy=function(){this.context=null,this.canvas=null},Object.defineProperty(r.prototype,"width",{get:function(){return this.canvas.width},set:function(t){this.canvas.width=Math.round(t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"height",{get:function(){return this.canvas.height},set:function(t){this.canvas.height=Math.round(t)},enumerable:!1,configurable:!0}),r})();var gl;function Z1(r,t){if(t===void 0&&(t=globalThis.location),r.indexOf("data:")===0)return"";t=t||globalThis.location,gl||(gl=document.createElement("a")),gl.href=r;var e=rc.parse(gl.href),n=!e.port&&t.port===""||e.port===t.port;return e.hostname!==t.hostname||!n||e.protocol!==t.protocol?"anonymous":""}function Tm(r,t){var e=At.RETINA_PREFIX.exec(r);return e?parseFloat(e[1]):t!==void 0?t:1}/*! + * @pixi/extensions - v6.5.10 + * Compiled Thu, 06 Jul 2023 15:25:11 UTC + * + * @pixi/extensions is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 xa=function(){return xa=Object.assign||function(t){for(var e=arguments,n,i=1,s=arguments.length;i8)throw new Error("max arguments reached");var u=this,c=u.name,h=u.items;this._aliasCount++;for(var f=0,d=h.length;f0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))},r.prototype.add=function(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this},r.prototype.remove=function(t){var e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this},r.prototype.contains=function(t){return this.items.indexOf(t)!==-1},r.prototype.removeAll=function(){return this.ensureNonAliasedItems(),this.items.length=0,this},r.prototype.destroy=function(){this.removeAll(),this.items=null,this._name=null},Object.defineProperty(r.prototype,"empty",{get:function(){return this.items.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),r}();Object.defineProperties(tr.prototype,{dispatch:{value:tr.prototype.emit},run:{value:tr.prototype.emit}});/*! + * @pixi/ticker - v6.5.10 + * Compiled Thu, 06 Jul 2023 15:25:11 UTC + * + * @pixi/ticker is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */At.TARGET_FPMS=.06;var Ao;(function(r){r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY"})(Ao||(Ao={}));var Hc=function(){function r(t,e,n,i){e===void 0&&(e=null),n===void 0&&(n=0),i===void 0&&(i=!1),this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=n,this.once=i}return r.prototype.match=function(t,e){return e===void 0&&(e=null),this.fn===t&&this.context===e},r.prototype.emit=function(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));var e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e},r.prototype.connect=function(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this},r.prototype.destroy=function(t){t===void 0&&(t=!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 e=this.next;return this.next=t?null:e,this.previous=null,e},r}(),Mn=function(){function r(){var t=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 Hc(null,null,1/0),this.deltaMS=1/At.TARGET_FPMS,this.elapsedMS=1/At.TARGET_FPMS,this._tick=function(e){t._requestId=null,t.started&&(t.update(e),t.started&&t._requestId===null&&t._head.next&&(t._requestId=requestAnimationFrame(t._tick)))}}return r.prototype._requestIfNeeded=function(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))},r.prototype._cancelIfNeeded=function(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)},r.prototype._startIfPossible=function(){this.started?this._requestIfNeeded():this.autoStart&&this.start()},r.prototype.add=function(t,e,n){return n===void 0&&(n=Ao.NORMAL),this._addListener(new Hc(t,e,n))},r.prototype.addOnce=function(t,e,n){return n===void 0&&(n=Ao.NORMAL),this._addListener(new Hc(t,e,n,!0))},r.prototype._addListener=function(t){var e=this._head.next,n=this._head;if(!e)t.connect(n);else{for(;e;){if(t.priority>e.priority){t.connect(n);break}n=e,e=e.next}t.previous||t.connect(n)}return this._startIfPossible(),this},r.prototype.remove=function(t,e){for(var n=this._head.next;n;)n.match(t,e)?n=n.destroy():n=n.next;return this._head.next||this._cancelIfNeeded(),this},Object.defineProperty(r.prototype,"count",{get:function(){if(!this._head)return 0;for(var t=0,e=this._head;e=e.next;)t++;return t},enumerable:!1,configurable:!0}),r.prototype.start=function(){this.started||(this.started=!0,this._requestIfNeeded())},r.prototype.stop=function(){this.started&&(this.started=!1,this._cancelIfNeeded())},r.prototype.destroy=function(){if(!this._protected){this.stop();for(var t=this._head.next;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}},r.prototype.update=function(t){t===void 0&&(t=performance.now());var e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){var n=t-this._lastFrame|0;if(n=this.x&&t=this.y&&et.right?t.right:this.right;if(i<=n)return!1;var s=this.yt.bottom?t.bottom:this.bottom;return o>s}var a=this.left,l=this.right,u=this.top,c=this.bottom;if(l<=a||c<=u)return!1;var h=yl[0].set(t.left,t.top),f=yl[1].set(t.left,t.bottom),d=yl[2].set(t.right,t.top),m=yl[3].set(t.right,t.bottom);if(d.x<=h.x||f.y<=h.y)return!1;var g=Math.sign(e.a*e.d-e.b*e.c);if(g===0||(e.apply(h,h),e.apply(f,f),e.apply(d,d),e.apply(m,m),Math.max(h.x,f.x,d.x,m.x)<=a||Math.min(h.x,f.x,d.x,m.x)>=l||Math.max(h.y,f.y,d.y,m.y)<=u||Math.min(h.y,f.y,d.y,m.y)>=c))return!1;var p=g*(f.y-h.y),y=g*(h.x-f.x),_=p*a+y*u,S=p*l+y*u,T=p*a+y*c,v=p*l+y*c;if(Math.max(_,S,T,v)<=p*h.x+y*h.y||Math.min(_,S,T,v)>=p*m.x+y*m.y)return!1;var E=g*(h.y-d.y),w=g*(d.x-h.x),B=E*a+w*u,N=E*l+w*u,$=E*a+w*c,it=E*l+w*c;return!(Math.max(B,N,$,it)<=E*h.x+w*h.y||Math.min(B,N,$,it)>=E*m.x+w*m.y)},r.prototype.pad=function(t,e){return t===void 0&&(t=0),e===void 0&&(e=t),this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this},r.prototype.fit=function(t){var e=Math.max(this.x,t.x),n=Math.min(this.x+this.width,t.x+t.width),i=Math.max(this.y,t.y),s=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(n-e,0),this.y=i,this.height=Math.max(s-i,0),this},r.prototype.ceil=function(t,e){t===void 0&&(t=1),e===void 0&&(e=.001);var n=Math.ceil((this.x+this.width-e)*t)/t,i=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=n-this.x,this.height=i-this.y,this},r.prototype.enlarge=function(t){var e=Math.min(this.x,t.x),n=Math.max(this.x+this.width,t.x+t.width),i=Math.min(this.y,t.y),s=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=n-e,this.y=i,this.height=s-i,this},r.prototype.toString=function(){return"[@pixi/math:Rectangle x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+"]"},r}(),ho=function(){function r(t,e,n,i){n===void 0&&(n=0),i===void 0&&(i=0),this._x=n,this._y=i,this.cb=t,this.scope=e}return r.prototype.clone=function(t,e){return t===void 0&&(t=this.cb),e===void 0&&(e=this.scope),new r(t,e,this._x,this._y)},r.prototype.set=function(t,e){return t===void 0&&(t=0),e===void 0&&(e=t),(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this},r.prototype.copyFrom=function(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this},r.prototype.copyTo=function(t){return t.set(this._x,this._y),t},r.prototype.equals=function(t){return t.x===this._x&&t.y===this._y},r.prototype.toString=function(){return"[@pixi/math:ObservablePoint x=0 y=0 scope="+this.scope+"]"},Object.defineProperty(r.prototype,"x",{get:function(){return this._x},set:function(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"y",{get:function(){return this._y},set:function(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))},enumerable:!1,configurable:!0}),r}(),ir=function(){function r(t,e,n,i,s,o){t===void 0&&(t=1),e===void 0&&(e=0),n===void 0&&(n=0),i===void 0&&(i=1),s===void 0&&(s=0),o===void 0&&(o=0),this.array=null,this.a=t,this.b=e,this.c=n,this.d=i,this.tx=s,this.ty=o}return r.prototype.fromArray=function(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]},r.prototype.set=function(t,e,n,i,s,o){return this.a=t,this.b=e,this.c=n,this.d=i,this.tx=s,this.ty=o,this},r.prototype.toArray=function(t,e){this.array||(this.array=new Float32Array(9));var n=e||this.array;return t?(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},r.prototype.apply=function(t,e){e=e||new Oe;var n=t.x,i=t.y;return e.x=this.a*n+this.c*i+this.tx,e.y=this.b*n+this.d*i+this.ty,e},r.prototype.applyInverse=function(t,e){e=e||new Oe;var n=1/(this.a*this.d+this.c*-this.b),i=t.x,s=t.y;return e.x=this.d*n*i+-this.c*n*s+(this.ty*this.c-this.tx*this.d)*n,e.y=this.a*n*s+-this.b*n*i+(-this.ty*this.a+this.tx*this.b)*n,e},r.prototype.translate=function(t,e){return this.tx+=t,this.ty+=e,this},r.prototype.scale=function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},r.prototype.rotate=function(t){var e=Math.cos(t),n=Math.sin(t),i=this.a,s=this.c,o=this.tx;return this.a=i*e-this.b*n,this.b=i*n+this.b*e,this.c=s*e-this.d*n,this.d=s*n+this.d*e,this.tx=o*e-this.ty*n,this.ty=o*n+this.ty*e,this},r.prototype.append=function(t){var e=this.a,n=this.b,i=this.c,s=this.d;return this.a=t.a*e+t.b*i,this.b=t.a*n+t.b*s,this.c=t.c*e+t.d*i,this.d=t.c*n+t.d*s,this.tx=t.tx*e+t.ty*i+this.tx,this.ty=t.tx*n+t.ty*s+this.ty,this},r.prototype.setTransform=function(t,e,n,i,s,o,a,l,u){return this.a=Math.cos(a+u)*s,this.b=Math.sin(a+u)*s,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(n*this.a+i*this.c),this.ty=e-(n*this.b+i*this.d),this},r.prototype.prepend=function(t){var e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){var n=this.a,i=this.c;this.a=n*t.a+this.b*t.c,this.b=n*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this},r.prototype.decompose=function(t){var e=this.a,n=this.b,i=this.c,s=this.d,o=t.pivot,a=-Math.atan2(-i,s),l=Math.atan2(n,e),u=Math.abs(a+l);return u<1e-5||Math.abs(K1-u)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=l),t.scale.x=Math.sqrt(e*e+n*n),t.scale.y=Math.sqrt(i*i+s*s),t.position.x=this.tx+(o.x*e+o.y*i),t.position.y=this.ty+(o.x*n+o.y*s),t},r.prototype.invert=function(){var t=this.a,e=this.b,n=this.c,i=this.d,s=this.tx,o=t*i-e*n;return this.a=i/o,this.b=-e/o,this.c=-n/o,this.d=t/o,this.tx=(n*this.ty-i*s)/o,this.ty=-(t*this.ty-e*s)/o,this},r.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this},r.prototype.clone=function(){var t=new r;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},r.prototype.copyTo=function(t){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},r.prototype.copyFrom=function(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this},r.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(r,"IDENTITY",{get:function(){return new r},enumerable:!1,configurable:!0}),Object.defineProperty(r,"TEMP_MATRIX",{get:function(){return new r},enumerable:!1,configurable:!0}),r}(),es=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],rs=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],ns=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],is=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Hh=[],T0=[],vl=Math.sign;function tI(){for(var r=0;r<16;r++){var t=[];Hh.push(t);for(var e=0;e<16;e++)for(var n=vl(es[r]*es[e]+ns[r]*rs[e]),i=vl(rs[r]*es[e]+is[r]*rs[e]),s=vl(es[r]*ns[e]+ns[r]*is[e]),o=vl(rs[r]*ns[e]+is[r]*is[e]),a=0;a<16;a++)if(es[a]===n&&rs[a]===i&&ns[a]===s&&is[a]===o){t.push(a);break}}for(var r=0;r<16;r++){var l=new ir;l.set(es[r],rs[r],ns[r],is[r],0,0),T0.push(l)}}tI();var Re={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(r){return es[r]},uY:function(r){return rs[r]},vX:function(r){return ns[r]},vY:function(r){return is[r]},inv:function(r){return r&8?r&15:-r&7},add:function(r,t){return Hh[r][t]},sub:function(r,t){return Hh[r][Re.inv(t)]},rotate180:function(r){return r^4},isVertical:function(r){return(r&3)===2},byDirection:function(r,t){return Math.abs(r)*2<=Math.abs(t)?t>=0?Re.S:Re.N:Math.abs(t)*2<=Math.abs(r)?r>0?Re.E:Re.W:t>0?r>0?Re.SE:Re.SW:r>0?Re.NE:Re.NW},matrixAppendRotationInv:function(r,t,e,n){e===void 0&&(e=0),n===void 0&&(n=0);var i=T0[Re.inv(t)];i.tx=e,i.ty=n,r.append(i)}},I0=function(){function r(){this.worldTransform=new ir,this.localTransform=new ir,this.position=new ho(this.onChange,this,0,0),this.scale=new ho(this.onChange,this,1,1),this.pivot=new ho(this.onChange,this,0,0),this.skew=new ho(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 r.prototype.onChange=function(){this._localID++},r.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++},r.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+") ")+"]"},r.prototype.updateLocalTransform=function(){var t=this.localTransform;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)},r.prototype.updateTransform=function(t){var e=this.localTransform;if(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),this._parentID!==t._worldID){var n=t.worldTransform,i=this.worldTransform;i.a=e.a*n.a+e.b*n.c,i.b=e.a*n.b+e.b*n.d,i.c=e.c*n.a+e.d*n.c,i.d=e.c*n.b+e.d*n.d,i.tx=e.tx*n.a+e.ty*n.c+n.tx,i.ty=e.tx*n.b+e.ty*n.d+n.ty,this._parentID=t._worldID,this._worldID++}},r.prototype.setFromMatrix=function(t){t.decompose(this),this._localID++},Object.defineProperty(r.prototype,"rotation",{get:function(){return this._rotation},set:function(t){this._rotation!==t&&(this._rotation=t,this.updateSkew())},enumerable:!1,configurable:!0}),r.IDENTITY=new r,r}();/*! + * @pixi/core - v6.5.10 + * Compiled Thu, 06 Jul 2023 15:25:11 UTC + * + * @pixi/core is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */At.PREFER_ENV=ms.any?li.WEBGL:li.WEBGL2;At.STRICT_TEXTURE_CACHE=!1;var Xh=[];function E0(r,t){if(!r)return null;var e="";if(typeof r=="string"){var n=/\.(\w{3,4})(?:$|\?|#)/i.exec(r);n&&(e=n[1].toLowerCase())}for(var i=Xh.length-1;i>=0;--i){var s=Xh[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new 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 Yh=function(r,t){return Yh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i])},Yh(r,t)};function Ce(r,t){Yh(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var qh=function(){return qh=Object.assign||function(t){for(var e=arguments,n,i=1,s=arguments.length;i0&&c>0,i.textureCacheIds=[],i.destroyed=!1,i.resource=null,i._batchEnabled=0,i._batchLocation=0,i.parentTextureArray=null,i.setResource(e),i}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,n){var i;return e!==void 0&&e!==this.scaleMode&&(this.scaleMode=e,i=!0),n!==void 0&&n!==this.mipmap&&(this.mipmap=n,i=!0),i&&this.dirtyStyleId++,this},t.prototype.setSize=function(e,n,i){return i=i||this.resolution,this.setRealSize(e*i,n*i,i)},t.prototype.setRealSize=function(e,n,i){return this.resolution=i||this.resolution,this.width=Math.round(e)/this.resolution,this.height=Math.round(n)/this.resolution,this._refreshPOT(),this.update(),this},t.prototype._refreshPOT=function(){this.isPowerOfTwo=bm(this.realWidth)&&bm(this.realHeight)},t.prototype.setResolution=function(e){var n=this.resolution;return n===e?this:(this.resolution=e,this.valid&&(this.width=Math.round(this.width*n)/e,this.height=Math.round(this.height*n)/e,this.emit("update",this)),this._refreshPOT(),this)},t.prototype.setResource=function(e){if(this.resource===e)return this;if(this.resource)throw new 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(),this.resource=null),this.cacheId&&(delete Xi[this.cacheId],delete Qn[this.cacheId],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,i){i===void 0&&(i=At.STRICT_TEXTURE_CACHE);var s=typeof e=="string",o=null;if(s)o=e;else{if(!e._pixiId){var a=n&&n.pixiIdPrefix||"pixiid";e._pixiId=a+"_"+Ra()}o=e._pixiId}var l=Xi[o];if(s&&i&&!l)throw new Error('The cacheId "'+o+'" does not exist in BaseTextureCache.');return l||(l=new t(e,n),l.cacheId=o,t.addToCache(l,o)),l},t.fromBuffer=function(e,n,i,s){e=e||new Float32Array(n*i*4);var o=new Cf(e,{width:n,height:i}),a=e instanceof Float32Array?fe.FLOAT:fe.UNSIGNED_BYTE;return new t(o,Object.assign({},rI,s||{width:n,height:i,type:a}))},t.addToCache=function(e,n){n&&(e.textureCacheIds.indexOf(n)===-1&&e.textureCacheIds.push(n),Xi[n]&&console.warn("BaseTexture added to the cache with an id ["+n+"] that already had an entry"),Xi[n]=e)},t.removeFromCache=function(e){if(typeof e=="string"){var n=Xi[e];if(n){var i=n.textureCacheIds.indexOf(e);return i>-1&&n.textureCacheIds.splice(i,1),delete Xi[e],n}}else if(e&&e.textureCacheIds){for(var s=0;s0)if(e.resource)this.addResourceAt(e.resource,n);else throw new Error("CubeResource does not support copying of renderTexture.");else e.target=_s.TEXTURE_CUBE_MAP_POSITIVE_X+n,e.parentTextureArray=this.baseTexture,this.items[n]=e;return e.valid&&!this.valid&&this.resize(e.realWidth,e.realHeight),this.items[n]=e,this},t.prototype.upload=function(e,n,i){for(var s=this.itemDirtyIds,o=0;o)?\s*()]*-->)?\s*\]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i,t}(Oi),aI=function(r){Ce(t,r);function t(e,n){var i=this;if(n=n||{},!(e instanceof HTMLVideoElement)){var s=document.createElement("video");s.setAttribute("preload","auto"),s.setAttribute("webkit-playsinline",""),s.setAttribute("playsinline",""),typeof e=="string"&&(e=[e]);var o=e[0].src||e[0];Oi.crossOrigin(s,o,n.crossorigin);for(var a=0;a2},t.prototype._onPlayStart=function(){this.valid||this._onCanPlay(),this.autoUpdate&&!this._isConnectedToTicker&&(Mn.shared.add(this.update,this),this._isConnectedToTicker=!0)},t.prototype._onPlayStop=function(){this._isConnectedToTicker&&(Mn.shared.remove(this.update,this),this._isConnectedToTicker=!1)},t.prototype._onCanPlay=function(){var e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);var n=this.valid;this.resize(e.videoWidth,e.videoHeight),!n&&this._resolve&&(this._resolve(this),this._resolve=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&e.play()},t.prototype.dispose=function(){this._isConnectedToTicker&&(Mn.shared.remove(this.update,this),this._isConnectedToTicker=!1);var e=this.source;e&&(e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),r.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?(Mn.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._isSourcePlaying()&&(Mn.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}(Oi),lI=function(r){Ce(t,r);function t(e){return r.call(this,e)||this}return t.test=function(e){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&e instanceof ImageBitmap},t}(Oi);Xh.push(M0,lI,iI,aI,oI,Cf,sI,nI);var uI=function(r){Ce(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.upload=function(e,n,i){var s=e.gl;s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.alphaMode===Ci.UNPACK);var o=n.realWidth,a=n.realHeight;return i.width===o&&i.height===a?s.texSubImage2D(n.target,0,0,0,o,a,n.format,i.type,this.data):(i.width=o,i.height=a,s.texImage2D(n.target,0,i.internalFormat,o,a,0,n.format,i.type,this.data)),!0},t}(Cf),Qh=function(){function r(t,e){this.width=Math.round(t||100),this.height=Math.round(e||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 tr("disposeFramebuffer"),this.multisample=Ve.NONE}return Object.defineProperty(r.prototype,"colorTexture",{get:function(){return this.colorTextures[0]},enumerable:!1,configurable:!0}),r.prototype.addColorTexture=function(t,e){return t===void 0&&(t=0),this.colorTextures[t]=e||new Xe(null,{scaleMode:Pr.NEAREST,resolution:1,mipmap:Un.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this},r.prototype.addDepthTexture=function(t){return this.depthTexture=t||new Xe(new uI(null,{width:this.width,height:this.height}),{scaleMode:Pr.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Un.OFF,format:xt.DEPTH_COMPONENT,type:fe.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this},r.prototype.enableDepth=function(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this},r.prototype.enableStencil=function(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this},r.prototype.resize=function(t,e){if(t=Math.round(t),e=Math.round(e),!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(var n=0;n-1&&n.textureCacheIds.splice(i,1),delete Qn[e],n}}else if(e&&e.textureCacheIds){for(var s=0;sthis.baseTexture.width,l=i+o>this.baseTexture.height;if(a||l){var u=a&&l?"and":"or",c="X: "+n+" + "+s+" = "+(n+s)+" > "+this.baseTexture.width,h="Y: "+i+" + "+o+" = "+(i+o)+" > "+this.baseTexture.height;throw new Error("Texture Error: frame does not fit inside the base Texture dimensions: "+(c+" "+u+" "+h))}this.valid=s&&o&&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 Xe),_l(t._EMPTY),_l(t._EMPTY.baseTexture)),t._EMPTY},enumerable:!1,configurable:!0}),Object.defineProperty(t,"WHITE",{get:function(){if(!t._WHITE){var e=At.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(Xe.from(e)),_l(t._WHITE),_l(t._WHITE.baseTexture)}return t._WHITE},enumerable:!1,configurable:!0}),t}(ki),Of=function(r){Ce(t,r);function t(e,n){var i=r.call(this,e,n)||this;return i.valid=!0,i.filterFrame=null,i.filterPoolKey=null,i.updateUvs(),i}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,n,i){i===void 0&&(i=!0);var s=this.baseTexture.resolution,o=Math.round(e*s)/s,a=Math.round(n*s)/s;this.valid=o>0&&a>0,this._frame.width=this.orig.width=o,this._frame.height=this.orig.height=a,i&&this.baseTexture.resize(o,a),this.updateUvs()},t.prototype.setResolution=function(e){var n=this.baseTexture;n.resolution!==e&&(n.setResolution(e),this.resize(n.width,n.height,!1))},t.create=function(e){for(var n=arguments,i=[],s=1;s>>0,i>1&&(s+=i*4294967296)):s=i>1?-i:-1,this.texturePool[s]||(this.texturePool[s]=[]);var o=this.texturePool[s].pop();return o||(o=this.createTexture(t,e,i)),o.filterPoolKey=s,o.setResolution(n),o},r.prototype.getFilterTexture=function(t,e,n){var i=this.getOptimalTexture(t.width,t.height,e||t.resolution,n||Ve.NONE);return i.filterFrame=t.filterFrame,i},r.prototype.returnTexture=function(t){var e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)},r.prototype.returnFilterTexture=function(t){this.returnTexture(t)},r.prototype.clear=function(t){if(t=t!==!1,t)for(var e in this.texturePool){var n=this.texturePool[e];if(n)for(var i=0;i0&&t.height>0;for(var e in this.texturePool)if(Number(e)<0){var n=this.texturePool[e];if(n)for(var i=0;i1){for(var c=0;c1&&(h=this.getOptimalFilterTexture(c.width,c.height,e.resolution),h.filterFrame=c.filterFrame),n[f].apply(this,c,h,hn.CLEAR,e);var d=c;c=h,h=d}n[f].apply(this,c,u.renderTexture,hn.BLEND,e),f>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(c),this.returnFilterTexture(h)}e.clear(),this.statePool.push(e)},r.prototype.bindAndClear=function(t,e){e===void 0&&(e=hn.CLEAR);var n=this.renderer,i=n.renderTexture,s=n.state;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t&&t.filterFrame){var o=this.tempRect;o.x=0,o.y=0,o.width=t.filterFrame.width,o.height=t.filterFrame.height,i.bind(t,t.filterFrame,o)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);var a=s.stateId&1||this.forceClear;(e===hn.CLEAR||e===hn.BLIT&&a)&&this.renderer.framebuffer.clear(0,0,0,0)},r.prototype.applyFilter=function(t,e,n,i){var s=this.renderer;s.state.set(t.state),this.bindAndClear(n,i),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,s.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),s.geometry.bind(this.quadUv),s.geometry.draw(Pa.TRIANGLES)):(s.geometry.bind(this.quad),s.geometry.draw(Pa.TRIANGLE_STRIP))},r.prototype.calculateSpriteMatrix=function(t,e){var n=this.activeState,i=n.sourceFrame,s=n.destinationFrame,o=e._texture.orig,a=t.set(s.width,0,0,s.height,i.x,i.y),l=e.worldTransform.copyTo(ir.TEMP_MATRIX);return l.invert(),a.prepend(l),a.scale(1/o.width,1/o.height),a.translate(e.anchor.x,e.anchor.y),a},r.prototype.destroy=function(){this.renderer=null,this.texturePool.clear(!1)},r.prototype.getOptimalFilterTexture=function(t,e,n,i){return n===void 0&&(n=1),i===void 0&&(i=Ve.NONE),this.texturePool.getOptimalTexture(t,e,n,i)},r.prototype.getFilterTexture=function(t,e,n){if(typeof t=="number"){var i=t;t=e,e=i}t=t||this.activeState.renderTexture;var s=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,n||Ve.NONE);return s.filterFrame=t.filterFrame,s},r.prototype.returnFilterTexture=function(t){this.texturePool.returnTexture(t)},r.prototype.emptyPool=function(){this.texturePool.clear(!0)},r.prototype.resize=function(){this.texturePool.setScreenSize(this.renderer.view)},r.prototype.transformAABB=function(t,e){var n=bl[0],i=bl[1],s=bl[2],o=bl[3];n.set(e.left,e.top),i.set(e.left,e.bottom),s.set(e.right,e.top),o.set(e.right,e.bottom),t.apply(n,n),t.apply(i,i),t.apply(s,s),t.apply(o,o);var a=Math.min(n.x,i.x,s.x,o.x),l=Math.min(n.y,i.y,s.y,o.y),u=Math.max(n.x,i.x,s.x,o.x),c=Math.max(n.y,i.y,s.y,o.y);e.x=a,e.y=l,e.width=u-a,e.height=c-l},r.prototype.roundFrame=function(t,e,n,i,s){if(!(t.width<=0||t.height<=0||n.width<=0||n.height<=0)){if(s){var o=s.a,a=s.b,l=s.c,u=s.d;if((Math.abs(a)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(u)>1e-4))return}s=s?Xc.copyFrom(s):Xc.identity(),s.translate(-n.x,-n.y).scale(i.width/n.width,i.height/n.height).translate(i.x,i.y),this.transformAABB(s,t),t.ceil(e),this.transformAABB(s.invert(),t)}},r}(),P0=function(){function r(t){this.renderer=t}return r.prototype.flush=function(){},r.prototype.destroy=function(){this.renderer=null},r.prototype.start=function(){},r.prototype.stop=function(){this.flush()},r.prototype.render=function(t){},r}(),wI=function(){function r(t){this.renderer=t,this.emptyRenderer=new P0(t),this.currentRenderer=this.emptyRenderer}return r.prototype.setObjectRenderer=function(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())},r.prototype.flush=function(){this.setObjectRenderer(this.emptyRenderer)},r.prototype.reset=function(){this.setObjectRenderer(this.emptyRenderer)},r.prototype.copyBoundTextures=function(t,e){for(var n=this.renderer.texture.boundTextures,i=e-1;i>=0;--i)t[i]=n[i]||null,t[i]&&(t[i]._batchLocation=i)},r.prototype.boundArray=function(t,e,n,i){for(var s=t.elements,o=t.ids,a=t.count,l=0,u=0;u=0&&h=li.WEBGL2&&(n=t.getContext("webgl2",e)),n)this.webGLVersion=2;else if(this.webGLVersion=1,n=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!n)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=n,this.getExtensions(),this.gl},r.prototype.getExtensions=function(){var t=this.gl,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})},r.prototype.handleContextLost=function(t){var e=this;t.preventDefault(),setTimeout(function(){e.gl.isContextLost()&&e.extensions.loseContext&&e.extensions.loseContext.restoreContext()},0)},r.prototype.handleContextRestored=function(){this.renderer.runners.contextChange.emit(this.gl)},r.prototype.destroy=function(){var t=this.renderer.view;this.renderer=null,t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()},r.prototype.postrender=function(){this.renderer.renderingToScreen&&this.gl.flush()},r.prototype.validateContext=function(t){var e=t.getContextAttributes(),n="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;n&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");var i=n||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=i,i||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")},r}(),SI=function(){function r(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Ve.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}return r}(),TI=new $e,II=function(){function r(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Qh(10,10),this.msaaSamples=null}return r.prototype.contextChange=function(){this.disposeAll(!0);var t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new $e,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){var e=this.renderer.context.extensions.drawBuffers,n=this.renderer.context.extensions.depthTexture;At.PREFER_ENV===li.WEBGL_LEGACY&&(e=null,n=null),e?t.drawBuffers=function(i){return e.drawBuffersWEBGL(i)}:(this.hasMRT=!1,t.drawBuffers=function(){}),n||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)},r.prototype.bind=function(t,e,n){n===void 0&&(n=0);var i=this.gl;if(t){var s=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,i.bindFramebuffer(i.FRAMEBUFFER,s.framebuffer)),s.mipLevel!==n&&(t.dirtyId++,t.dirtyFormat++,s.mipLevel=n),s.dirtyId!==t.dirtyId&&(s.dirtyId=t.dirtyId,s.dirtyFormat!==t.dirtyFormat?(s.dirtyFormat=t.dirtyFormat,s.dirtySize=t.dirtySize,this.updateFramebuffer(t,n)):s.dirtySize!==t.dirtySize&&(s.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(var o=0;o>n,u=e.height>>n,c=l/e.width;this.setViewport(e.x*c,e.y*c,l,u)}else{var l=t.width>>n,u=t.height>>n;this.setViewport(0,0,l,u)}}else this.current&&(this.current=null,i.bindFramebuffer(i.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)},r.prototype.setViewport=function(t,e,n,i){var s=this.viewport;t=Math.round(t),e=Math.round(e),n=Math.round(n),i=Math.round(i),(s.width!==n||s.height!==i||s.x!==t||s.y!==e)&&(s.x=t,s.y=e,s.width=n,s.height=i,this.gl.viewport(t,e,n,i))},Object.defineProperty(r.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}),r.prototype.clear=function(t,e,n,i,s){s===void 0&&(s=tu.COLOR|tu.DEPTH);var o=this.gl;o.clearColor(t,e,n,i),o.clear(s)},r.prototype.initFramebuffer=function(t){var e=this.gl,n=new SI(e.createFramebuffer());return n.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=n,this.managedFramebuffers.push(t),t.disposeRunner.add(this),n},r.prototype.resizeFramebuffer=function(t){var e=this.gl,n=t.glFramebuffers[this.CONTEXT_UID];n.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,n.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,n.multisample,e.RGBA8,t.width,t.height)),n.stencil&&(e.bindRenderbuffer(e.RENDERBUFFER,n.stencil),n.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,n.multisample,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,t.width,t.height));var i=t.colorTextures,s=i.length;e.drawBuffers||(s=Math.min(s,1));for(var o=0;o1&&this.canMultisampleFramebuffer(t)?(i.msaaBuffer=i.msaaBuffer||n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,i.msaaBuffer),n.renderbufferStorageMultisample(n.RENDERBUFFER,i.multisample,n.RGBA8,t.width,t.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,i.msaaBuffer)):i.msaaBuffer&&(n.deleteRenderbuffer(i.msaaBuffer),i.msaaBuffer=null,i.blitFramebuffer&&(i.blitFramebuffer.dispose(),i.blitFramebuffer=null));for(var a=[],l=0;l1&&n.drawBuffers(a),t.depthTexture){var h=this.writeDepthTexture;if(h){var f=t.depthTexture;this.renderer.texture.bind(f,0),n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,f._glTextures[this.CONTEXT_UID].texture,e)}}(t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)?(i.stencil=i.stencil||n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,i.stencil),i.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,i.multisample,n.DEPTH24_STENCIL8,t.width,t.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,t.width,t.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,i.stencil)):i.stencil&&(n.deleteRenderbuffer(i.stencil),i.stencil=null)},r.prototype.canMultisampleFramebuffer=function(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture},r.prototype.detectSamples=function(t){var e=this.msaaSamples,n=Ve.NONE;if(t<=1||e===null)return n;for(var i=0;i=0&&this.managedFramebuffers.splice(s,1),t.disposeRunner.remove(this),e||(i.deleteFramebuffer(n.framebuffer),n.msaaBuffer&&i.deleteRenderbuffer(n.msaaBuffer),n.stencil&&i.deleteRenderbuffer(n.stencil)),n.blitFramebuffer&&n.blitFramebuffer.dispose()}},r.prototype.disposeAll=function(t){var e=this.managedFramebuffers;this.managedFramebuffers=[];for(var n=0;n=li.WEBGL2&&(t=r.getContext("webgl2",{})),t||(t=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),Xo=t}return Xo}var wl;function OI(){if(!wl){wl=Rr.MEDIUM;var r=CI();if(r&&r.getShaderPrecisionFormat){var t=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);wl=t.precision?Rr.HIGH:Rr.MEDIUM}}return wl}function Rm(r,t,e){if(r.substring(0,9)!=="precision"){var n=t;return t===Rr.HIGH&&e!==Rr.HIGH&&(n=Rr.MEDIUM),"precision "+n+` float; +`+r}else if(e!==Rr.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}var PI={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 D0(r){return PI[r]}var xl=null,Fm={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 L0(r,t){if(!xl){var e=Object.keys(Fm);xl={};for(var n=0;n0&&(t+=` +else `),e"u"?.5:e,this.isSimple=!1}return Object.defineProperty(r.prototype,"texture",{get:function(){return this._texture},set:function(t){this._texture=t,this._textureID=-1},enumerable:!1,configurable:!0}),r.prototype.multiplyUvs=function(t,e){e===void 0&&(e=t);for(var n=this.mapCoord,i=0;i0?this.maskStack[this.maskStack.length-1]._colorMask:15;n!==e&&this.renderer.gl.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)},r.prototype.destroy=function(){this.renderer=null},r}(),B0=function(){function r(t){this.renderer=t,this.maskStack=[],this.glConst=0}return r.prototype.getStackLength=function(){return this.maskStack.length},r.prototype.setMaskStack=function(t){var e=this.renderer.gl,n=this.getStackLength();this.maskStack=t;var i=this.getStackLength();i!==n&&(i===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))},r.prototype._useCurrent=function(){},r.prototype.destroy=function(){this.renderer=null,this.maskStack=null},r}(),Lm=new ir,Nm=[],qI=function(r){Ce(t,r);function t(e){var n=r.call(this,e)||this;return n.glConst=At.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 n;if(!e._scissorRectLocal){var i=e._scissorRect,s=e.maskObject,o=this.renderer,a=o.renderTexture,l=s.getBounds(!0,(n=Nm.pop())!==null&&n!==void 0?n:new $e);this.roundFrameToPixels(l,a.current?a.current.resolution:o.resolution,a.sourceFrame,a.destinationFrame,o.projection.transform),i&&l.fit(i),e._scissorRectLocal=l}},t.isMatrixRotated=function(e){if(!e)return!1;var n=e.a,i=e.b,s=e.c,o=e.d;return(Math.abs(i)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(n)>1e-4||Math.abs(o)>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 i=e._scissorRectLocal;return i.width>0&&i.height>0},t.prototype.roundFrameToPixels=function(e,n,i,s,o){t.isMatrixRotated(o)||(o=o?Lm.copyFrom(o):Lm.identity(),o.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.renderer.filter.transformAABB(o,e),e.fit(s),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 n=this.renderer.gl;e._scissorRect||n.enable(n.SCISSOR_TEST),e._scissorCounter++,e._scissorRect=e._scissorRectLocal,this._useCurrent()},t.prototype.pop=function(e){var n=this.renderer.gl;e&&Nm.push(e._scissorRectLocal),this.getStackLength()>0?this._useCurrent():n.disable(n.SCISSOR_TEST)},t.prototype._useCurrent=function(){var e=this.maskStack[this.maskStack.length-1]._scissorRect,n;this.renderer.renderTexture.current?n=e.y:n=this.renderer.height-e.height-e.y,this.renderer.gl.scissor(e.x,n,e.width,e.height)},t}(B0),QI=function(r){Ce(t,r);function t(e){var n=r.call(this,e)||this;return n.glConst=At.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 n=e.maskObject,i=this.renderer.gl,s=e._stencilCounter;s===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),e._stencilCounter++;var o=e._colorMask;o!==0&&(e._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,s,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),n.renderable=!0,n.render(this.renderer),this.renderer.batch.flush(),n.renderable=!1,o!==0&&(e._colorMask=o,i.colorMask((o&1)!==0,(o&2)!==0,(o&4)!==0,(o&8)!==0)),this._useCurrent()},t.prototype.pop=function(e){var n=this.renderer.gl;if(this.getStackLength()===0)n.disable(n.STENCIL_TEST);else{var i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,s=i?i._colorMask:15;s!==0&&(i._colorMask=0,n.colorMask(!1,!1,!1,!1)),n.stencilOp(n.KEEP,n.KEEP,n.DECR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,s!==0&&(i._colorMask=s,n.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&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}(B0),ZI=function(){function r(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new ir,this.transform=null}return r.prototype.update=function(t,e,n,i){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,n,i),this.transform&&this.projectionMatrix.append(this.transform);var s=this.renderer;s.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,s.globalUniforms.update(),s.shader.shader&&s.shader.syncUniformGroup(s.shader.shader.uniforms.globals)},r.prototype.calculateProjection=function(t,e,n,i){var s=this.projectionMatrix,o=i?-1:1;s.identity(),s.a=1/e.width*2,s.d=o*(1/e.height*2),s.tx=-1-e.x*s.a,s.ty=-o-e.y*s.d},r.prototype.setTransform=function(t){},r.prototype.destroy=function(){this.renderer=null},r}(),Yi=new $e,qo=new $e,KI=function(){function r(t){this.renderer=t,this.clearColor=t._backgroundColorRgba,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new $e,this.destinationFrame=new $e,this.viewportFrame=new $e}return r.prototype.bind=function(t,e,n){t===void 0&&(t=null);var i=this.renderer;this.current=t;var s,o,a;t?(s=t.baseTexture,a=s.resolution,e||(Yi.width=t.frame.width,Yi.height=t.frame.height,e=Yi),n||(qo.x=t.frame.x,qo.y=t.frame.y,qo.width=e.width,qo.height=e.height,n=qo),o=s.framebuffer):(a=i.resolution,e||(Yi.width=i.screen.width,Yi.height=i.screen.height,e=Yi),n||(n=Yi,n.width=e.width,n.height=e.height));var l=this.viewportFrame;l.x=n.x*a,l.y=n.y*a,l.width=n.width*a,l.height=n.height*a,t||(l.y=i.view.height-(l.y+l.height)),l.ceil(),this.renderer.framebuffer.bind(o,l),this.renderer.projection.update(n,e,a,!o),t?this.renderer.mask.setMaskStack(s.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(n)},r.prototype.clear=function(t,e){this.current?t=t||this.current.baseTexture.clearColor:t=t||this.clearColor;var n=this.destinationFrame,i=this.current?this.current.baseTexture:this.renderer.screen,s=n.width!==i.width||n.height!==i.height;if(s){var o=this.viewportFrame,a=o.x,l=o.y,u=o.width,c=o.height;a=Math.round(a),l=Math.round(l),u=Math.round(u),c=Math.round(c),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(a,l,u,c)}this.renderer.framebuffer.clear(t[0],t[1],t[2],t[3],e),s&&this.renderer.scissor.pop()},r.prototype.resize=function(){this.bind(null)},r.prototype.reset=function(){this.bind(null)},r.prototype.destroy=function(){this.renderer=null},r}();function JI(r,t,e,n,i){e.buffer.update(i)}var tE={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]; + } + `},U0={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:16*2,mat3:16*3,mat4:16*4};function eE(r){for(var t=r.map(function(l){return{data:l,offset:0,dataLen:0,dirty:0}}),e=0,n=0,i=0,s=0;s1&&(e=Math.max(e,16)*o.data.size),o.dataLen=e,n%e!==0&&n<16){var a=n%e%16;n+=a,i+=a}n+e>16?(i=Math.ceil(i/16)*16,o.offset=i,i+=e,n=e):(o.offset=i,n+=e,i+=e)}return i=Math.ceil(i/16)*16,{uboElements:t,size:i}}function rE(r,t){var e=[];for(var n in r)t[n]&&e.push(t[n]);return e.sort(function(i,s){return i.index-s.index}),e}function nE(r,t){if(!r.autoManage)return{size:0,syncFunc:JI};for(var e=rE(r.uniforms,t),n=eE(e),i=n.uboElements,s=n.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; + `],a=0;a1){var m=D0(l.data.type),g=Math.max(U0[l.data.type]/16,1),p=m/g,y=(4-p%4)%4;o.push(` + cv = ud.`+c+`.value; + v = uv.`+c+`; + offset = `+l.offset/4+`; + + t = 0; + + for(var i=0; i < `+l.data.size*g+`; i++) + { + for(var j = 0; j < `+p+`; j++) + { + data[offset++] = v[t++]; + } + offset += `+y+`; + } + + `)}else{var _=tE[l.data.type];o.push(` + cv = ud.`+c+`.value; + v = uv.`+c+`; + offset = `+l.offset/4+`; + `+_+`; + `)}}return o.push(` + renderer.buffer.update(buffer); + `),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",o.join(` +`))}}var iE=function(){function r(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}return r.prototype.destroy=function(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null},r}();function sE(r,t){for(var e={},n=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES),i=0;ih?1:-1});for(var o=0;o>1,n++;this.stateId=t.data}for(var n=0;nthis.checkCountMax&&(this.checkCount=0,this.run())))},r.prototype.run=function(){for(var t=this.renderer.texture,e=t.managedTextures,n=!1,i=0;ithis.maxIdle&&(t.destroyTexture(s,!0),e[i]=null,n=!0)}if(n){for(var o=0,i=0;i=0;i--)this.unload(t.children[i])},r.prototype.destroy=function(){this.renderer=null},r}();function _E(r){var t,e,n,i,s,o,a,l,u,c,h,f,d,m,g,p,y,_,S,T,v,E,w;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?w=(t={},t[fe.UNSIGNED_BYTE]=(e={},e[xt.RGBA]=r.RGBA8,e[xt.RGB]=r.RGB8,e[xt.RG]=r.RG8,e[xt.RED]=r.R8,e[xt.RGBA_INTEGER]=r.RGBA8UI,e[xt.RGB_INTEGER]=r.RGB8UI,e[xt.RG_INTEGER]=r.RG8UI,e[xt.RED_INTEGER]=r.R8UI,e[xt.ALPHA]=r.ALPHA,e[xt.LUMINANCE]=r.LUMINANCE,e[xt.LUMINANCE_ALPHA]=r.LUMINANCE_ALPHA,e),t[fe.BYTE]=(n={},n[xt.RGBA]=r.RGBA8_SNORM,n[xt.RGB]=r.RGB8_SNORM,n[xt.RG]=r.RG8_SNORM,n[xt.RED]=r.R8_SNORM,n[xt.RGBA_INTEGER]=r.RGBA8I,n[xt.RGB_INTEGER]=r.RGB8I,n[xt.RG_INTEGER]=r.RG8I,n[xt.RED_INTEGER]=r.R8I,n),t[fe.UNSIGNED_SHORT]=(i={},i[xt.RGBA_INTEGER]=r.RGBA16UI,i[xt.RGB_INTEGER]=r.RGB16UI,i[xt.RG_INTEGER]=r.RG16UI,i[xt.RED_INTEGER]=r.R16UI,i[xt.DEPTH_COMPONENT]=r.DEPTH_COMPONENT16,i),t[fe.SHORT]=(s={},s[xt.RGBA_INTEGER]=r.RGBA16I,s[xt.RGB_INTEGER]=r.RGB16I,s[xt.RG_INTEGER]=r.RG16I,s[xt.RED_INTEGER]=r.R16I,s),t[fe.UNSIGNED_INT]=(o={},o[xt.RGBA_INTEGER]=r.RGBA32UI,o[xt.RGB_INTEGER]=r.RGB32UI,o[xt.RG_INTEGER]=r.RG32UI,o[xt.RED_INTEGER]=r.R32UI,o[xt.DEPTH_COMPONENT]=r.DEPTH_COMPONENT24,o),t[fe.INT]=(a={},a[xt.RGBA_INTEGER]=r.RGBA32I,a[xt.RGB_INTEGER]=r.RGB32I,a[xt.RG_INTEGER]=r.RG32I,a[xt.RED_INTEGER]=r.R32I,a),t[fe.FLOAT]=(l={},l[xt.RGBA]=r.RGBA32F,l[xt.RGB]=r.RGB32F,l[xt.RG]=r.RG32F,l[xt.RED]=r.R32F,l[xt.DEPTH_COMPONENT]=r.DEPTH_COMPONENT32F,l),t[fe.HALF_FLOAT]=(u={},u[xt.RGBA]=r.RGBA16F,u[xt.RGB]=r.RGB16F,u[xt.RG]=r.RG16F,u[xt.RED]=r.R16F,u),t[fe.UNSIGNED_SHORT_5_6_5]=(c={},c[xt.RGB]=r.RGB565,c),t[fe.UNSIGNED_SHORT_4_4_4_4]=(h={},h[xt.RGBA]=r.RGBA4,h),t[fe.UNSIGNED_SHORT_5_5_5_1]=(f={},f[xt.RGBA]=r.RGB5_A1,f),t[fe.UNSIGNED_INT_2_10_10_10_REV]=(d={},d[xt.RGBA]=r.RGB10_A2,d[xt.RGBA_INTEGER]=r.RGB10_A2UI,d),t[fe.UNSIGNED_INT_10F_11F_11F_REV]=(m={},m[xt.RGB]=r.R11F_G11F_B10F,m),t[fe.UNSIGNED_INT_5_9_9_9_REV]=(g={},g[xt.RGB]=r.RGB9_E5,g),t[fe.UNSIGNED_INT_24_8]=(p={},p[xt.DEPTH_STENCIL]=r.DEPTH24_STENCIL8,p),t[fe.FLOAT_32_UNSIGNED_INT_24_8_REV]=(y={},y[xt.DEPTH_STENCIL]=r.DEPTH32F_STENCIL8,y),t):w=(_={},_[fe.UNSIGNED_BYTE]=(S={},S[xt.RGBA]=r.RGBA,S[xt.RGB]=r.RGB,S[xt.ALPHA]=r.ALPHA,S[xt.LUMINANCE]=r.LUMINANCE,S[xt.LUMINANCE_ALPHA]=r.LUMINANCE_ALPHA,S),_[fe.UNSIGNED_SHORT_5_6_5]=(T={},T[xt.RGB]=r.RGB,T),_[fe.UNSIGNED_SHORT_4_4_4_4]=(v={},v[xt.RGBA]=r.RGBA,v),_[fe.UNSIGNED_SHORT_5_5_5_1]=(E={},E[xt.RGBA]=r.RGBA,E),_),w}var rh=function(){function r(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=fe.UNSIGNED_BYTE,this.internalFormat=xt.RGBA,this.samplerType=0}return r}(),bE=function(){function r(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new Xe,this.hasIntegerTextures=!1}return r.prototype.contextChange=function(){var t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=_E(t);var e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(var n=0;n=0;--o){var a=n[o];if(a){var l=a._glTextures[s];l.samplerType!==eu.FLOAT&&this.renderer.texture.unbind(a)}}},r.prototype.initTexture=function(t){var e=new rh(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e},r.prototype.initTextureType=function(t,e){var n,i;e.internalFormat=(i=(n=this.internalFormats[t.type])===null||n===void 0?void 0:n[t.format])!==null&&i!==void 0?i:t.format,this.webGLVersion===2&&t.type===fe.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type},r.prototype.updateTexture=function(t){var e=t._glTextures[this.CONTEXT_UID];if(e){var n=this.renderer;if(this.initTextureType(t,e),t.resource&&t.resource.upload(n,t,e))e.samplerType!==eu.FLOAT&&(this.hasIntegerTextures=!0);else{var i=t.realWidth,s=t.realHeight,o=n.gl;(e.width!==i||e.height!==s||e.dirtyId<0)&&(e.width=i,e.height=s,o.texImage2D(t.target,0,e.internalFormat,i,s,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}},r.prototype.destroyTexture=function(t,e){var n=this.gl;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),n.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){var i=this.managedTextures.indexOf(t);i!==-1&&Nl(this.managedTextures,i,1)}},r.prototype.updateTextureStyle=function(t){var e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===Un.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=ru.CLAMP:e.wrapMode=t.wrapMode,t.resource&&t.resource.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)},r.prototype.setStyle=function(t,e){var n=this.gl;if(e.mipmap&&t.mipmap!==Un.ON_MANUAL&&n.generateMipmap(t.target),n.texParameteri(t.target,n.TEXTURE_WRAP_S,e.wrapMode),n.texParameteri(t.target,n.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){n.texParameteri(t.target,n.TEXTURE_MIN_FILTER,t.scaleMode===Pr.LINEAR?n.LINEAR_MIPMAP_LINEAR:n.NEAREST_MIPMAP_NEAREST);var i=this.renderer.context.extensions.anisotropicFiltering;if(i&&t.anisotropicLevel>0&&t.scaleMode===Pr.LINEAR){var s=Math.min(t.anisotropicLevel,n.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT));n.texParameterf(t.target,i.TEXTURE_MAX_ANISOTROPY_EXT,s)}}else n.texParameteri(t.target,n.TEXTURE_MIN_FILTER,t.scaleMode===Pr.LINEAR?n.LINEAR:n.NEAREST);n.texParameteri(t.target,n.TEXTURE_MAG_FILTER,t.scaleMode===Pr.LINEAR?n.LINEAR:n.NEAREST)},r.prototype.destroy=function(){this.renderer=null},r}(),nh=new ir,wE=function(r){Ce(t,r);function t(e,n){e===void 0&&(e=Oa.UNKNOWN);var i=r.call(this)||this;return n=Object.assign({},At.RENDER_OPTIONS,n),i.options=n,i.type=e,i.screen=new $e(0,0,n.width,n.height),i.view=n.view||At.ADAPTER.createCanvas(),i.resolution=n.resolution||At.RESOLUTION,i.useContextAlpha=n.useContextAlpha,i.autoDensity=!!n.autoDensity,i.preserveDrawingBuffer=n.preserveDrawingBuffer,i.clearBeforeRender=n.clearBeforeRender,i._backgroundColor=0,i._backgroundColorRgba=[0,0,0,1],i._backgroundColorString="#000000",i.backgroundColor=n.backgroundColor||i._backgroundColor,i.backgroundAlpha=n.backgroundAlpha,n.transparent!==void 0&&(bs("6.0.0","Option transparent is deprecated, please use backgroundAlpha instead."),i.useContextAlpha=n.transparent,i.backgroundAlpha=n.transparent?0:1),i._lastObjectRendered=null,i.plugins={},i}return t.prototype.initPlugins=function(e){for(var n in e)this.plugins[n]=new e[n](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,n){this.view.width=Math.round(e*this.resolution),this.view.height=Math.round(n*this.resolution);var i=this.view.width/this.resolution,s=this.view.height/this.resolution;this.screen.width=i,this.screen.height=s,this.autoDensity&&(this.view.style.width=i+"px",this.view.style.height=s+"px"),this.emit("resize",i,s)},t.prototype.generateTexture=function(e,n,i,s){n===void 0&&(n={}),typeof n=="number"&&(bs("6.1.0","generateTexture options (scaleMode, resolution, region) are now object options."),n={scaleMode:n,resolution:i,region:s});var o=n.region,a=eI(n,["region"]);s=o||e.getLocalBounds(null,!0),s.width===0&&(s.width=1),s.height===0&&(s.height=1);var l=Of.create(qh({width:s.width,height:s.height},a));return nh.tx=-s.x,nh.ty=-s.y,this.render(e,{renderTexture:l,clear:!1,transform:nh,skipUpdateTransform:!!e.parent}),l},t.prototype.destroy=function(e){for(var n in this.plugins)this.plugins[n].destroy(),this.plugins[n]=null;e&&this.view.parentNode&&this.view.parentNode.removeChild(this.view);var i=this;i.plugins=null,i.type=Oa.UNKNOWN,i.view=null,i.screen=null,i._tempDisplayObjectParent=null,i.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=H1(e),en(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}(ki),xE=function(){function r(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}return r}(),SE=function(){function r(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}return r.prototype.destroy=function(){this.renderer=null},r.prototype.contextChange=function(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID},r.prototype.bind=function(t){var e=this,n=e.gl,i=e.CONTEXT_UID,s=t._glBuffers[i]||this.createGLBuffer(t);n.bindBuffer(t.type,s.buffer)},r.prototype.bindBufferBase=function(t,e){var n=this,i=n.gl,s=n.CONTEXT_UID;if(this.boundBufferBases[e]!==t){var o=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,o.buffer)}},r.prototype.bindBufferRange=function(t,e,n){var i=this,s=i.gl,o=i.CONTEXT_UID;n=n||0;var a=t._glBuffers[o]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,a.buffer,n*256,256)},r.prototype.update=function(t){var e=this,n=e.gl,i=e.CONTEXT_UID,s=t._glBuffers[i];if(t._updateID!==s.updateID)if(s.updateID=t._updateID,n.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)n.bufferSubData(t.type,0,t.data);else{var o=t.static?n.STATIC_DRAW:n.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,n.bufferData(t.type,t.data,o)}},r.prototype.dispose=function(t,e){if(this.managedBuffers[t.id]){delete this.managedBuffers[t.id];var n=t._glBuffers[this.CONTEXT_UID],i=this.gl;t.disposeRunner.remove(this),n&&(e||i.deleteBuffer(n.buffer),delete t._glBuffers[this.CONTEXT_UID])}},r.prototype.disposeAll=function(t){for(var e=Object.keys(this.managedBuffers),n=0;n=Ve.HIGH?this.multisample=Ve.HIGH:n>=Ve.MEDIUM?this.multisample=Ve.MEDIUM:n>=Ve.LOW?this.multisample=Ve.LOW:this.multisample=Ve.NONE},t.prototype.addSystem=function(e,n){var i=new e(this);if(this[n])throw new Error('Whoops! The name "'+n+'" is already in use');this[n]=i;for(var s in this.runners)this.runners[s].add(i);return this},t.prototype.render=function(e,n){var i,s,o,a;if(n&&(n instanceof Of?(bs("6.0.0","Renderer#render arguments changed, use options instead."),i=n,s=arguments[2],o=arguments[3],a=arguments[4]):(i=n.renderTexture,s=n.clear,o=n.transform,a=n.skipUpdateTransform)),this.renderingToScreen=!i,this.runners.prerender.emit(),this.emit("prerender"),this.projection.transform=o,!this.context.isLost){if(i||(this._lastObjectRendered=e),!a){var l=e.enableTempParent();e.updateTransform(),e.disableTempParent(l)}this.renderTexture.bind(i),this.batch.currentRenderer.start(),(s!==void 0?s:this.clearBeforeRender)&&this.renderTexture.clear(),e.render(this),this.batch.currentRenderer.flush(),i&&i.baseTexture.update(),this.runners.postrender.emit(),this.projection.transform=null,this.emit("postrender")}},t.prototype.generateTexture=function(e,n,i,s){n===void 0&&(n={});var o=r.prototype.generateTexture.call(this,e,n,i,s);return this.framebuffer.blit(),o},t.prototype.resize=function(e,n){r.prototype.resize.call(this,e,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(e){this.runners.destroy.emit();for(var n in this.runners)this.runners[n].destroy();r.prototype.destroy.call(this,e),this.gl=null},Object.defineProperty(t.prototype,"extract",{get:function(){return bs("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,n){bs("6.5.0","Renderer.registerPlugin() has been deprecated, please use extensions.add() instead."),qa.add({name:e,type:rn.RendererPlugin,ref:n})},t.__plugins={},t}(wE);qa.handleByMap(rn.RendererPlugin,k0.__plugins);function TE(r){return k0.create(r)}var IE=`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; +}`,EE=IE,AE=function(){function r(){this.texArray=null,this.blend=0,this.type=Pa.TRIANGLES,this.start=0,this.size=0,this.data=null}return r}(),ME=function(){function r(){this.elements=[],this.ids=[],this.count=0}return r.prototype.clear=function(){for(var t=0;tthis.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,i=e.MAX_TEXTURES,s=t._textureArrayPool,o=this.renderer.batch,a=this._tempBoundTextures,l=this.renderer.textureGC.count,u=++Xe._globalBatch,c=0,h=s[0],f=0;o.copyBoundTextures(a,i);for(var d=0;d=i&&(o.boundArray(h,a,u,i),this.buildDrawCalls(h,f,d),f=d,h=s[++c],++u),m._batchEnabled=u,m.touched=l,h.elements[h.count++]=m)}h.count>0&&(o.boundArray(h,a,u,i),this.buildDrawCalls(h,f,this._bufferSize),++c,++u);for(var d=0;d0&&(e+=` +else `),nthis.maxX||this.minY>this.maxY},r.prototype.clear=function(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0},r.prototype.getRectangle=function(t){return this.minX>this.maxX||this.minY>this.maxY?$e.EMPTY:(t=t||new $e(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)},r.prototype.addPoint=function(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)},r.prototype.addPointMatrix=function(t,e){var n=t.a,i=t.b,s=t.c,o=t.d,a=t.tx,l=t.ty,u=n*e.x+s*e.y+a,c=i*e.x+o*e.y+l;this.minX=Math.min(this.minX,u),this.maxX=Math.max(this.maxX,u),this.minY=Math.min(this.minY,c),this.maxY=Math.max(this.maxY,c)},r.prototype.addQuad=function(t){var e=this.minX,n=this.minY,i=this.maxX,s=this.maxY,o=t[0],a=t[1];e=oi?o:i,s=a>s?a:s,o=t[2],a=t[3],e=oi?o:i,s=a>s?a:s,o=t[4],a=t[5],e=oi?o:i,s=a>s?a:s,o=t[6],a=t[7],e=oi?o:i,s=a>s?a:s,this.minX=e,this.minY=n,this.maxX=i,this.maxY=s},r.prototype.addFrame=function(t,e,n,i,s){this.addFrameMatrix(t.worldTransform,e,n,i,s)},r.prototype.addFrameMatrix=function(t,e,n,i,s){var o=t.a,a=t.b,l=t.c,u=t.d,c=t.tx,h=t.ty,f=this.minX,d=this.minY,m=this.maxX,g=this.maxY,p=o*e+l*n+c,y=a*e+u*n+h;f=pm?p:m,g=y>g?y:g,p=o*i+l*n+c,y=a*i+u*n+h,f=pm?p:m,g=y>g?y:g,p=o*e+l*s+c,y=a*e+u*s+h,f=pm?p:m,g=y>g?y:g,p=o*i+l*s+c,y=a*i+u*s+h,f=pm?p:m,g=y>g?y:g,this.minX=f,this.minY=d,this.maxX=m,this.maxY=g},r.prototype.addVertexData=function(t,e,n){for(var i=this.minX,s=this.minY,o=this.maxX,a=this.maxY,l=e;lo?u:o,a=c>a?c:a}this.minX=i,this.minY=s,this.maxX=o,this.maxY=a},r.prototype.addVertices=function(t,e,n,i){this.addVerticesMatrix(t.worldTransform,e,n,i)},r.prototype.addVerticesMatrix=function(t,e,n,i,s,o){s===void 0&&(s=0),o===void 0&&(o=s);for(var a=t.a,l=t.b,u=t.c,c=t.d,h=t.tx,f=t.ty,d=this.minX,m=this.minY,g=this.maxX,p=this.maxY,y=n;yi?t.maxX:i,this.maxY=t.maxY>s?t.maxY:s},r.prototype.addBoundsMask=function(t,e){var n=t.minX>e.minX?t.minX:e.minX,i=t.minY>e.minY?t.minY:e.minY,s=t.maxXu?s:u,this.maxY=o>c?o:c}},r.prototype.addBoundsMatrix=function(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)},r.prototype.addBoundsArea=function(t,e){var n=t.minX>e.x?t.minX:e.x,i=t.minY>e.y?t.minY:e.y,s=t.maxXu?s:u,this.maxY=o>c?o:c}},r.prototype.pad=function(t,e){t===void 0&&(t=0),e===void 0&&(e=t),this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)},r.prototype.addFramePad=function(t,e,n,i,s,o){t-=s,e-=o,n+=s,i+=o,this.minX=this.minXn?this.maxX:n,this.minY=this.minYi?this.maxY:i},r}();/*! ***************************************************************************** +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 Zh=function(r,t){return Zh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i])},Zh(r,t)};function Df(r,t){Zh(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Da=function(r){Df(t,r);function t(){var e=r.call(this)||this;return e.tempDisplayObjectParent=null,e.transform=new I0,e.alpha=1,e.visible=!0,e.renderable=!0,e.cullable=!1,e.cullArea=null,e.parent=null,e.worldAlpha=1,e._lastSortedIndex=0,e._zIndex=0,e.filterArea=null,e.filters=null,e._enabledFilters=null,e._bounds=new km,e._localBounds=null,e._boundsID=0,e._boundsRect=null,e._localBoundsRect=null,e._mask=null,e._maskRefCount=0,e._destroyed=!1,e.isSprite=!1,e.isMask=!1,e}return t.mixin=function(e){for(var n=Object.keys(e),i=0;i1)for(var s=0;sthis.children.length)throw new Error(e+"addChildAt: The index "+n+" 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(n,0,e),this._boundsID++,this.onChildrenChange(n),e.emit("added",this),this.emit("childAdded",e,this,n),e},t.prototype.swapChildren=function(e,n){if(e!==n){var i=this.getChildIndex(e),s=this.getChildIndex(n);this.children[i]=n,this.children[s]=e,this.onChildrenChange(i=this.children.length)throw new Error("The index "+n+" supplied is out of bounds "+this.children.length);var i=this.getChildIndex(e);Nl(this.children,i,1),this.children.splice(n,0,e),this.onChildrenChange(n)},t.prototype.getChildAt=function(e){if(e<0||e>=this.children.length)throw new Error("getChildAt: Index ("+e+") does not exist.");return this.children[e]},t.prototype.removeChild=function(){for(var e=arguments,n=[],i=0;i1)for(var s=0;s0&&o<=s){a=this.children.splice(i,o);for(var l=0;l1&&this.children.sort(LE),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,n=this.children.length;e0&&n.height>0){var i,s;if(this.cullArea?(i=this.cullArea,s=this.worldTransform):this._render!==t.prototype._render&&(i=this.getBounds(!0)),i&&n.intersects(i,s))this._render(e);else if(this.cullArea)return;for(var o=0,a=this.children.length;onew Promise((n,i)=>{var s=l=>{try{a(e.next(l))}catch(u){i(u)}},o=l=>{try{a(e.throw(l))}catch(u){i(u)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,o);a((e=e.apply(r,t)).next())});class Lf{constructor(){this._breathParameters=[],this._currentTime=0}static create(){return new Lf}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,e){this._currentTime+=e;const n=this._currentTime*2*3.14159;for(let i=0;i=1&&(n=1,this._blinkingState=Gr.EyeState_Closed,this._stateStartTimeSeconds=this._userTimeSeconds),e=1-n;break;case Gr.EyeState_Closed:n=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,n>=1&&(this._blinkingState=Gr.EyeState_Opening,this._stateStartTimeSeconds=this._userTimeSeconds),e=0;break;case Gr.EyeState_Opening:n=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,n>=1&&(n=1,this._blinkingState=Gr.EyeState_Interval,this._nextBlinkingTime=this.determinNextBlinkingTiming()),e=n;break;case Gr.EyeState_Interval:this._nextBlinkingTime(r[r.EyeState_First=0]="EyeState_First",r[r.EyeState_Interval=1]="EyeState_Interval",r[r.EyeState_Closing=2]="EyeState_Closing",r[r.EyeState_Closed=3]="EyeState_Closed",r[r.EyeState_Opening=4]="EyeState_Opening",r))(Gr||{});const UE=.001,zm=.5;class Nf{static create(t){const e=new Nf;typeof t.FadeInTime=="number"&&(e._fadeTimeSeconds=t.FadeInTime,e._fadeTimeSeconds<=0&&(e._fadeTimeSeconds=zm));const n=t.Groups,i=n.length;for(let s=0;sUE){if(s>=0)break;s=u,o=t.getPartOpacityByIndex(c),o+=e/this._fadeTimeSeconds,o>1&&(o=1)}}s<0&&(s=0,o=1);for(let u=n;ul&&(f=1-l/(1-o)),h>f&&(h=f),t.setPartOpacityByIndex(c,h)}}}constructor(){this._fadeTimeSeconds=zm,this._lastModel=void 0,this._partGroups=[],this._partGroupCounts=[]}}class ou{constructor(t){this.parameterIndex=0,this.partIndex=0,this.partId="",this.link=[],t!=null&&this.assignment(t)}assignment(t){return this.partId=t.partId,this.link=t.link.map(e=>e.clone()),this}initialize(t){this.parameterIndex=t.getParameterIndex(this.partId),this.partIndex=t.getPartIndex(this.partId),t.setParameterValueByIndex(this.parameterIndex,1)}clone(){const t=new ou;return t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=this.link.map(e=>e.clone()),t}}class ee{constructor(t,e){this.x=t||0,this.y=e||0}add(t){const e=new ee(0,0);return e.x=this.x+t.x,e.y=this.y+t.y,e}substract(t){const e=new ee(0,0);return e.x=this.x-t.x,e.y=this.y-t.y,e}multiply(t){const e=new ee(0,0);return e.x=this.x*t.x,e.y=this.y*t.y,e}multiplyByScaler(t){return this.multiply(new ee(t,t))}division(t){const e=new ee(0,0);return e.x=this.x/t.x,e.y=this.y/t.y,e}divisionByScalar(t){return this.division(new ee(t,t))}getLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}getDistanceWith(t){return Math.sqrt((this.x-t.x)*(this.x-t.x)+(this.y-t.y)*(this.y-t.y))}dot(t){return this.x*t.x+this.y*t.y}normalize(){const t=Math.pow(this.x*this.x+this.y*this.y,.5);this.x=this.x/t,this.y=this.y/t}isEqual(t){return this.x==t.x&&this.y==t.y}isNotEqual(t){return!this.isEqual(t)}}const Bl=class{static range(r,t,e){return re&&(r=e),r}static sin(r){return Math.sin(r)}static cos(r){return Math.cos(r)}static abs(r){return Math.abs(r)}static sqrt(r){return Math.sqrt(r)}static cbrt(r){if(r===0)return r;let t=r;const e=t<0;e&&(t=-t);let n;return t===1/0?n=1/0:(n=Math.exp(Math.log(t)/3),n=(t/(n*n)+2*n)/3),e?-n:n}static getEasingSine(r){return r<0?0:r>1?1:.5-.5*this.cos(r*Math.PI)}static max(r,t){return r>t?r:t}static min(r,t){return r>t?t:r}static degreesToRadian(r){return r/180*Math.PI}static radianToDegrees(r){return r*180/Math.PI}static directionToRadian(r,t){const e=Math.atan2(t.y,t.x),n=Math.atan2(r.y,r.x);let i=e-n;for(;i<-Math.PI;)i+=Math.PI*2;for(;i>Math.PI;)i-=Math.PI*2;return i}static directionToDegrees(r,t){const e=this.directionToRadian(r,t);let n=this.radianToDegrees(e);return t.x-r.x>0&&(n=-n),n}static radianToDirection(r){const t=new ee;return t.x=this.sin(r),t.y=this.cos(r),t}static quadraticEquation(r,t,e){return this.abs(r)1&&(t=1),e<0?e=0:e>1&&(e=1),n<0?n=0:n>1&&(n=1),i<0?i=0:i>1&&(i=1),this._modelColor.R=t,this._modelColor.G=e,this._modelColor.B=n,this._modelColor.A=i}getModelColor(){return Object.assign({},this._modelColor)}setIsPremultipliedAlpha(t){this._isPremultipliedAlpha=t}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(t){this._isCulling=t}isCulling(){return this._isCulling}setAnisotropy(t){this._anisortopy=t}getAnisotropy(){return this._anisortopy}getModel(){return this._model}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisortopy=0,this._modelColor=new la,this._mvpMatrix4x4=new Jr,this._mvpMatrix4x4.loadIdentity()}}var Mi=(r=>(r[r.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",r[r.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",r[r.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",r))(Mi||{});class la{constructor(){this.R=1,this.G=1,this.B=1,this.A=1}}let vn=!1,zs=!1,Vs;const ih={vertexOffset:0,vertexStep:2};class La{static startUp(t){if(vn)return Zo("CubismFramework.startUp() is already done."),vn;if(Live2DCubismCore._isStarted)return vn=!0,!0;if(Live2DCubismCore._isStarted=!0,Vs=t,Vs&&Live2DCubismCore.Logging.csmSetLogFunction(Vs.logFunction),vn=!0,vn){const e=Live2DCubismCore.Version.csmGetVersion(),n=(e&4278190080)>>24,i=(e&16711680)>>16,s=e&65535,o=e;Zo("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+n).slice(-2),("00"+i).slice(-2),("0000"+s).slice(-4),o)}return Zo("CubismFramework.startUp() is complete."),vn}static cleanUp(){vn=!1,zs=!1,Vs=void 0}static initialize(){if(!vn){ua("CubismFramework is not started.");return}if(zs){ua("CubismFramework.initialize() skipped, already initialized.");return}zs=!0,Zo("CubismFramework.initialize() is complete.")}static dispose(){if(!vn){ua("CubismFramework is not started.");return}if(!zs){ua("CubismFramework.dispose() skipped, not initialized.");return}Bf.staticRelease(),zs=!1,Zo("CubismFramework.dispose() is complete.")}static isStarted(){return vn}static isInitialized(){return zs}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return Vs!=null?Vs.loggingLevel:Rs.LogLevel_Off}constructor(){}}var Rs=(r=>(r[r.LogLevel_Verbose=0]="LogLevel_Verbose",r[r.LogLevel_Debug=1]="LogLevel_Debug",r[r.LogLevel_Info=2]="LogLevel_Info",r[r.LogLevel_Warning=3]="LogLevel_Warning",r[r.LogLevel_Error=4]="LogLevel_Error",r[r.LogLevel_Off=5]="LogLevel_Off",r))(Rs||{});const Il=()=>{};function Vm(r,...t){nc.print(Rs.LogLevel_Debug,"[CSM][D]"+r+` +`,t)}function Zo(r,...t){nc.print(Rs.LogLevel_Info,"[CSM][I]"+r+` +`,t)}function ua(r,...t){nc.print(Rs.LogLevel_Warning,"[CSM][W]"+r+` +`,t)}function Ys(r,...t){nc.print(Rs.LogLevel_Error,"[CSM][E]"+r+` +`,t)}class nc{static print(t,e,n){if(tn[a]);i(s)}static dumpBytes(t,e,n){for(let i=0;i0?this.print(t,` +`):i%8==0&&i>0&&this.print(t," "),this.print(t,"{0} ",[e[i]&255]);this.print(t,` +`)}constructor(){}}class kE{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(){const t=this._model.parameters.count,e=this._savedParameters.length;for(let n=0;ne&&(e=this._model.parameters.minimumValues[t]),this._parameterValues[t]=n==1?e:this._parameterValues[t]=this._parameterValues[t]*(1-n)+e*n}setParameterValueById(t,e,n=1){const i=this.getParameterIndex(t);this.setParameterValueByIndex(i,e,n)}addParameterValueByIndex(t,e,n=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)+e*n)}addParameterValueById(t,e,n=1){const i=this.getParameterIndex(t);this.addParameterValueByIndex(i,e,n)}multiplyParameterValueById(t,e,n=1){const i=this.getParameterIndex(t);this.multiplyParameterValueByIndex(i,e,n)}multiplyParameterValueByIndex(t,e,n=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)*(1+(e-1)*n))}getDrawableIds(){return this._drawableIds.slice()}getDrawableIndex(t){const e=this._model.drawables.count;for(let n=0;ne&&(t=e);for(let n=0;n0&&e.getEndTime()(r[r.ExpressionBlendType_Add=0]="ExpressionBlendType_Add",r[r.ExpressionBlendType_Multiply=1]="ExpressionBlendType_Multiply",r[r.ExpressionBlendType_Overwrite=2]="ExpressionBlendType_Overwrite",r))(ss||{}),Na;(r=>{r.supportMoreMaskDivisions=!0,r.setOpacityFromMotion=!1})(Na||(Na={}));var os=(r=>(r[r.CubismMotionCurveTarget_Model=0]="CubismMotionCurveTarget_Model",r[r.CubismMotionCurveTarget_Parameter=1]="CubismMotionCurveTarget_Parameter",r[r.CubismMotionCurveTarget_PartOpacity=2]="CubismMotionCurveTarget_PartOpacity",r))(os||{}),Tn=(r=>(r[r.CubismMotionSegmentType_Linear=0]="CubismMotionSegmentType_Linear",r[r.CubismMotionSegmentType_Bezier=1]="CubismMotionSegmentType_Bezier",r[r.CubismMotionSegmentType_Stepped=2]="CubismMotionSegmentType_Stepped",r[r.CubismMotionSegmentType_InverseStepped=3]="CubismMotionSegmentType_InverseStepped",r))(Tn||{});class xi{constructor(t=0,e=0){this.time=t,this.value=e}}class zE{constructor(){this.basePointIndex=0,this.segmentType=0}}class VE{constructor(){this.id="",this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}}class jE{constructor(){this.fireTime=0,this.value=""}}class $E{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=[],this.segments=[],this.points=[],this.events=[]}}class $0{constructor(t){this._json=t}release(){this._json=void 0}getMotionDuration(){return this._json.Meta.Duration}isMotionLoop(){return this._json.Meta.Loop||!1}getEvaluationOptionFlag(t){return zf.EvaluationOptionFlag_AreBeziersRistricted==t?!!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(t){return this._json.Curves[t].Target}getMotionCurveId(t){return this._json.Curves[t].Id}getMotionCurveFadeInTime(t){return this._json.Curves[t].FadeInTime}getMotionCurveFadeOutTime(t){return this._json.Curves[t].FadeOutTime}getMotionCurveSegmentCount(t){return this._json.Curves[t].Segments.length}getMotionCurveSegment(t,e){return this._json.Curves[t].Segments[e]}getEventCount(){return this._json.Meta.UserDataCount||0}getTotalEventValueSize(){return this._json.Meta.TotalUserDataSize}getEventTime(t){return this._json.UserData[t].Time}getEventValue(t){return this._json.UserData[t].Value}}var zf=(r=>(r[r.EvaluationOptionFlag_AreBeziersRistricted=0]="EvaluationOptionFlag_AreBeziersRistricted",r))(zf||{});const GE="EyeBlink",WE="LipSync",HE="Model",XE="Parameter",YE="PartOpacity",qE=!1;function Qr(r,t,e){const n=new xi;return n.time=r.time+(t.time-r.time)*e,n.value=r.value+(t.value-r.value)*e,n}function QE(r,t){let e=(t-r[0].time)/(r[1].time-r[0].time);return e<0&&(e=0),r[0].value+(r[1].value-r[0].value)*e}function ZE(r,t){let e=(t-r[0].time)/(r[3].time-r[0].time);e<0&&(e=0);const n=Qr(r[0],r[1],e),i=Qr(r[1],r[2],e),s=Qr(r[2],r[3],e),o=Qr(n,i,e),a=Qr(i,s,e);return Qr(o,a,e).value}function KE(r,t){const e=t,n=r[0].time,i=r[3].time,s=r[1].time,o=r[2].time,a=i-3*o+3*s-n,l=3*o-6*s+3*n,u=3*s-3*n,c=n-e,h=Me.cardanoAlgorithmForBezier(a,l,u,c),f=Qr(r[0],r[1],h),d=Qr(r[1],r[2],h),m=Qr(r[2],r[3],h),g=Qr(f,d,h),p=Qr(d,m,h);return Qr(g,p,h).value}function JE(r,t){return r[0].value}function tA(r,t){return r[1].value}function sh(r,t,e){const n=r.curves[t];let i=-1;const s=n.baseSegmentIndex+n.segmentCount;let o=0;for(let l=n.baseSegmentIndex;le){i=l;break}if(i==-1)return r.points[o].value;const a=r.segments[i];return a.evaluate(r.points.slice(a.basePointIndex),e)}class Vf extends j0{constructor(){super(),this._eyeBlinkParameterIds=[],this._lipSyncParameterIds=[],this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0}static create(t,e){const n=new Vf;return n.parse(t),n._sourceFrameRate=n._motionData.fps,n._loopDurationSeconds=n._motionData.duration,n._onFinishedMotion=e,n}doUpdateParameters(t,e,n,i){this._modelCurveIdEyeBlink==null&&(this._modelCurveIdEyeBlink=GE),this._modelCurveIdLipSync==null&&(this._modelCurveIdLipSync=WE);let s=e-i.getStartTime();s<0&&(s=0);let o=Number.MAX_VALUE,a=Number.MAX_VALUE;const l=64;let u=0,c=0;this._eyeBlinkParameterIds.length>l&&Vm("too many eye blink targets : {0}",this._eyeBlinkParameterIds.length),this._lipSyncParameterIds.length>l&&Vm("too many lip sync targets : {0}",this._lipSyncParameterIds.length);const h=this._fadeInSeconds<=0?1:Me.getEasingSine((e-i.getFadeInStartTime())/this._fadeInSeconds),f=this._fadeOutSeconds<=0||i.getEndTime()<0?1:Me.getEasingSine((i.getEndTime()-e)/this._fadeOutSeconds);let d,m,g,p=s;if(this._isLoop)for(;p>this._motionData.duration;)p-=this._motionData.duration;const y=this._motionData.curves;for(m=0;m>_&1)continue;const T=S+(a-S)*n;t.setParameterValueById(this._eyeBlinkParameterIds[_],T)}if(o!=Number.MAX_VALUE)for(let _=0;_>_&1)continue;const T=S+(o-S)*n;t.setParameterValueById(this._lipSyncParameterIds[_],T)}}for(;m=this._motionData.duration&&(this._isLoop?(i.setStartTime(e),this._isLoopFadeIn&&i.setFadeInStartTime(e)):(this._onFinishedMotion&&this._onFinishedMotion(this),i.setIsFinished(!0))),this._lastWeight=n}setIsLoop(t){this._isLoop=t}isLoop(){return this._isLoop}setIsLoopFadeIn(t){this._isLoopFadeIn=t}isLoopFadeIn(){return this._isLoopFadeIn}getDuration(){return this._isLoop?-1:this._loopDurationSeconds}getLoopDuration(){return this._loopDurationSeconds}setParameterFadeInTime(t,e){const n=this._motionData.curves;for(let i=0;inew VE),this._motionData.segments=Array.from({length:e.getMotionTotalSegmentCount()}).map(()=>new zE),this._motionData.events=Array.from({length:this._motionData.eventCount}).map(()=>new jE),this._motionData.points=[];let o=0,a=0;for(let l=0;lt&&this._motionData.events[n].fireTime<=e&&this._firedEventValues.push(this._motionData.events[n].value);return this._firedEventValues}}class eA{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(t){this._fadeOutSeconds=t,this._isTriggeredFadeOut=!0}startFadeOut(t,e){const n=e+t;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||ne!=null&&e._motionQueueEntryHandle==t)}setEventCallback(t,e=null){this._eventCallBack=t,this._eventCustomData=e}doUpdateMotion(t,e){let n=!1,i=0;for(;i(r[r.CubismPhysicsTargetType_Parameter=0]="CubismPhysicsTargetType_Parameter",r))(Jh||{}),as=(r=>(r[r.CubismPhysicsSource_X=0]="CubismPhysicsSource_X",r[r.CubismPhysicsSource_Y=1]="CubismPhysicsSource_Y",r[r.CubismPhysicsSource_Angle=2]="CubismPhysicsSource_Angle",r))(as||{});class nA{constructor(){this.initialPosition=new ee(0,0),this.position=new ee(0,0),this.lastPosition=new ee(0,0),this.lastGravity=new ee(0,0),this.force=new ee(0,0),this.velocity=new ee(0,0)}}class iA{constructor(){this.normalizationPosition={},this.normalizationAngle={}}}class sA{constructor(){this.source={}}}class oA{constructor(){this.destination={},this.translationScale=new ee(0,0)}}class aA{constructor(){this.settings=[],this.inputs=[],this.outputs=[],this.particles=[],this.gravity=new ee(0,0),this.wind=new ee(0,0)}}class lA{constructor(t){this._json=t}release(){this._json=void 0}getGravity(){const t=new ee(0,0);return t.x=this._json.Meta.EffectiveForces.Gravity.X,t.y=this._json.Meta.EffectiveForces.Gravity.Y,t}getWind(){const t=new ee(0,0);return t.x=this._json.Meta.EffectiveForces.Wind.X,t.y=this._json.Meta.EffectiveForces.Wind.Y,t}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(t){return this._json.PhysicsSettings[t].Normalization.Position.Minimum}getNormalizationPositionMaximumValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Maximum}getNormalizationPositionDefaultValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Default}getNormalizationAngleMinimumValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Minimum}getNormalizationAngleMaximumValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Maximum}getNormalizationAngleDefaultValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Default}getInputCount(t){return this._json.PhysicsSettings[t].Input.length}getInputWeight(t,e){return this._json.PhysicsSettings[t].Input[e].Weight}getInputReflect(t,e){return this._json.PhysicsSettings[t].Input[e].Reflect}getInputType(t,e){return this._json.PhysicsSettings[t].Input[e].Type}getInputSourceId(t,e){return this._json.PhysicsSettings[t].Input[e].Source.Id}getOutputCount(t){return this._json.PhysicsSettings[t].Output.length}getOutputVertexIndex(t,e){return this._json.PhysicsSettings[t].Output[e].VertexIndex}getOutputAngleScale(t,e){return this._json.PhysicsSettings[t].Output[e].Scale}getOutputWeight(t,e){return this._json.PhysicsSettings[t].Output[e].Weight}getOutputDestinationId(t,e){return this._json.PhysicsSettings[t].Output[e].Destination.Id}getOutputType(t,e){return this._json.PhysicsSettings[t].Output[e].Type}getOutputReflect(t,e){return this._json.PhysicsSettings[t].Output[e].Reflect}getParticleCount(t){return this._json.PhysicsSettings[t].Vertices.length}getParticleMobility(t,e){return this._json.PhysicsSettings[t].Vertices[e].Mobility}getParticleDelay(t,e){return this._json.PhysicsSettings[t].Vertices[e].Delay}getParticleAcceleration(t,e){return this._json.PhysicsSettings[t].Vertices[e].Acceleration}getParticleRadius(t,e){return this._json.PhysicsSettings[t].Vertices[e].Radius}getParticlePosition(t,e){const n=new ee(0,0);return n.x=this._json.PhysicsSettings[t].Vertices[e].Position.X,n.y=this._json.PhysicsSettings[t].Vertices[e].Position.Y,n}}const $m="X",Gm="Y",Wm="Angle",uA=5,W0=100,cA=.001;class jf{static create(t){const e=new jf;return e.parse(t),e._physicsRig.gravity.y=0,e}evaluate(t,e){let n,i,s,o;const a=new ee;let l,u,c,h,f,d,m,g;f=t.getModel().parameters.values,d=t.getModel().parameters.maximumValues,m=t.getModel().parameters.minimumValues,g=t.getModel().parameters.defaultValues;for(let p=0;p=l.particleCount)break;c[y].destinationParameterIndex==-1&&(c[y].destinationParameterIndex=t.getParameterIndex(c[y].destination.id));const S=new ee;S.x=h[_].position.x-h[_-1].position.x,S.y=h[_].position.y-h[_-1].position.y,o=c[y].getValue(S,h,_,c[y].reflect,this._options.gravity);const T=c[y].destinationParameterIndex,v=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(f.subarray(T))):f.slice(T);TA(v,m[T],d[T],o,c[y]);for(let E=T,w=0;E=2?i=t[e-1].position.substract(t[e-2].position):i=i.multiplyByScaler(-1),s=Me.directionToRadian(i,r),n&&(s*=-1),s}function vA(r,t){return Math.abs(Math.max(r,t)-Math.min(r,t))}function _A(r,t){return Math.min(r,t)+vA(r,t)/2}function bA(r,t){return r.x}function wA(r,t){return r.y}function xA(r,t){return t}function SA(r,t,e,n,i,s,o,a){let l,u,c,h,f=new ee(0,0),d=new ee(0,0),m=new ee(0,0),g=new ee(0,0);r[0].position=new ee(e.x,e.y),l=Me.degreesToRadian(n),h=Me.radianToDirection(l),h.normalize();for(let p=1;pe&&(o>i.valueExceededMaximum&&(i.valueExceededMaximum=o),o=e),a=i.weight/W0,a>=1||(o=r[0]*(1-a)+o*a),r[0]=o}function $f(r,t,e,n,i,s,o,a){let l=0;const u=Me.max(e,t);ur&&(r=c);const h=Me.min(i,s),f=Me.max(i,s),d=o,m=_A(c,u),g=r-m;switch(Math.sign(g)){case 1:{const p=f-d,y=u-m;y!=0&&(l=g*(p/y),l+=d);break}case-1:{const p=h-d,y=c-m;y!=0&&(l=g*(p/y),l+=d);break}case 0:{l=d;break}}return a?l:l*-1}class td{constructor(t=0,e=0,n=0,i=0){this.x=t,this.y=e,this.width=n,this.height=i}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(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}expand(t,e){this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2}}const oh=4,IA=10;let Qi,ca,ed;class ah{getChannelFlagAsColor(t){return this._channelColors[t]}getMaskRenderTexture(){let t=0;if(this._maskTexture&&this._maskTexture.texture!=0&&(this._maskTexture.frameNo=this._currentFrameNo,t=this._maskTexture.texture),t==0){const e=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,e,e,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),t=this.gl.createFramebuffer(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,this._colorBuffer,0),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,ed),this._maskTexture=new EA(this._currentFrameNo,t)}return t}setGL(t){this.gl=t}calcClippedDrawTotalBounds(t,e){let n=Number.MAX_VALUE,i=Number.MAX_VALUE,s=Number.MIN_VALUE,o=Number.MIN_VALUE;const a=e._clippedDrawableIndexList.length;for(let l=0;lm&&(m=_),Sg&&(g=S)}if(f!=Number.MAX_VALUE)if(fs&&(s=m),g>o&&(o=g),n==Number.MAX_VALUE)e._allClippedDrawRect.x=0,e._allClippedDrawRect.y=0,e._allClippedDrawRect.width=0,e._allClippedDrawRect.height=0,e._isUsing=!1;else{e._isUsing=!0;const y=s-n,_=o-i;e._allClippedDrawRect.x=n,e._allClippedDrawRect.y=i,e._allClippedDrawRect.width=y,e._allClippedDrawRect.height=_}}}constructor(){this._maskRenderTexture=null,this._colorBuffer=null,this._currentFrameNo=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=[],this._clippingContextListForDraw=[],this._channelColors=[],this._tmpBoundsOnModel=new td,this._tmpMatrix=new Jr,this._tmpMatrixForMask=new Jr,this._tmpMatrixForDraw=new Jr;let t=new la;t.R=1,t.G=0,t.B=0,t.A=0,this._channelColors.push(t),t=new la,t.R=0,t.G=1,t.B=0,t.A=0,this._channelColors.push(t),t=new la,t.R=0,t.G=0,t.B=1,t.A=0,this._channelColors.push(t),t=new la,t.R=0,t.G=0,t.B=0,t.A=1,this._channelColors.push(t)}release(){var t,e,n;const i=this;for(let s=0;s0){this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),this._maskRenderTexture=this.getMaskRenderTexture(),e.getMvpMatrix(),e.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 i=0;i(r[r.ShaderNames_SetupMask=0]="ShaderNames_SetupMask",r[r.ShaderNames_NormalPremultipliedAlpha=1]="ShaderNames_NormalPremultipliedAlpha",r[r.ShaderNames_NormalMaskedPremultipliedAlpha=2]="ShaderNames_NormalMaskedPremultipliedAlpha",r[r.ShaderNames_NomralMaskedInvertedPremultipliedAlpha=3]="ShaderNames_NomralMaskedInvertedPremultipliedAlpha",r[r.ShaderNames_AddPremultipliedAlpha=4]="ShaderNames_AddPremultipliedAlpha",r[r.ShaderNames_AddMaskedPremultipliedAlpha=5]="ShaderNames_AddMaskedPremultipliedAlpha",r[r.ShaderNames_AddMaskedPremultipliedAlphaInverted=6]="ShaderNames_AddMaskedPremultipliedAlphaInverted",r[r.ShaderNames_MultPremultipliedAlpha=7]="ShaderNames_MultPremultipliedAlpha",r[r.ShaderNames_MultMaskedPremultipliedAlpha=8]="ShaderNames_MultMaskedPremultipliedAlpha",r[r.ShaderNames_MultMaskedPremultipliedAlphaInverted=9]="ShaderNames_MultMaskedPremultipliedAlphaInverted",r))(ha||{});const MA="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;}",CA="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;}",OA="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;}",Hm="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;}",PA="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;}",RA="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;}",FA="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;}";class H0 extends Bf{constructor(){super(),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._clippingManager=new ah,this.firstDraw=!0,this._textures={},this._sortedDrawableIndexList=[],this._bufferData={vertex:null,uv:null,index:null}}initialize(t){t.isUsingMasking()&&(this._clippingManager=new ah,this._clippingManager.initialize(t,t.getDrawableCount(),t.getDrawableMasks(),t.getDrawableMaskCounts()));for(let e=t.getDrawableCount()-1;e>=0;e--)this._sortedDrawableIndexList[e]=0;super.initialize(t)}bindTexture(t,e){this._textures[t]=e}getBindedTextures(){return this._textures}setClippingMaskBufferSize(t){this._clippingManager.release(),this._clippingManager=new ah,this._clippingManager.setClippingMaskBufferSize(t),this._clippingManager.initialize(this.getModel(),this.getModel().getDrawableCount(),this.getModel().getDrawableMasks(),this.getModel().getDrawableMaskCounts())}getClippingMaskBufferSize(){return this._clippingManager.getClippingMaskBufferSize()}release(){var t,e,n;const i=this;this._clippingManager.release(),i._clippingManager=void 0,(t=this.gl)==null||t.deleteBuffer(this._bufferData.vertex),this._bufferData.vertex=null,(e=this.gl)==null||e.deleteBuffer(this._bufferData.uv),this._bufferData.uv=null,(n=this.gl)==null||n.deleteBuffer(this._bufferData.index),this._bufferData.index=null,i._bufferData=void 0,i._textures=void 0}doDrawModel(){this.preDraw(),this._clippingManager!=null&&this._clippingManager.setupClippingContext(this.getModel(),this);const t=this.getModel().getDrawableCount(),e=this.getModel().getDrawableRenderOrders();for(let n=0;n{H0.doStaticRelease()};class X0{constructor(t){this.groups=t.Groups,this.hitAreas=t.HitAreas,this.layout=t.Layout,this.moc=t.FileReferences.Moc,this.expressions=t.FileReferences.Expressions,this.motions=t.FileReferences.Motions,this.textures=t.FileReferences.Textures,this.physics=t.FileReferences.Physics,this.pose=t.FileReferences.Pose}getEyeBlinkParameters(){var t,e;return(e=(t=this.groups)==null?void 0:t.find(n=>n.Name==="EyeBlink"))==null?void 0:e.Ids}getLipSyncParameters(){var t,e;return(e=(t=this.groups)==null?void 0:t.find(n=>n.Name==="LipSync"))==null?void 0:e.Ids}}const DA="ParamAngleX",LA="ParamAngleY",NA="ParamAngleZ",BA="ParamEyeBallX",UA="ParamEyeBallY",kA="ParamBodyAngleX",zA="ParamBreath",Xm=2,Ym=2;var Mr;(r=>{r.LOG_LEVEL_VERBOSE=0,r.LOG_LEVEL_WARNING=1,r.LOG_LEVEL_ERROR=2,r.LOG_LEVEL_NONE=999,r.logLevel=r.LOG_LEVEL_WARNING,r.sound=!0,r.motionSync=!0,r.motionFadingDuration=500,r.idleMotionFadingDuration=2e3,r.expressionFadingDuration=500,r.preserveExpressionOnMotion=!0,r.cubism4=Na})(Mr||(Mr={}));const Se={log(r,...t){Mr.logLevel<=Mr.LOG_LEVEL_VERBOSE&&console.log(`[${r}]`,...t)},warn(r,...t){Mr.logLevel<=Mr.LOG_LEVEL_WARNING&&console.warn(`[${r}]`,...t)},error(r,...t){Mr.logLevel<=Mr.LOG_LEVEL_ERROR&&console.error(`[${r}]`,...t)}};function qm(r,t,e){return re?e:r}function Y0(r,t){t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(n=>{n!=="constructor"&&Object.defineProperty(r.prototype,n,Object.getOwnPropertyDescriptor(e.prototype,n))})})}function VA(r){let t=r.lastIndexOf("/");return t!=-1&&(r=r.slice(0,t)),t=r.lastIndexOf("/"),t!==-1&&(r=r.slice(t+1)),r}function jA(r,t){const e=r.indexOf(t);e!==-1&&r.splice(e,1)}class q0 extends ki{constructor(t,e){super(),this.expressions=[],this.reserveExpressionIndex=-1,this.destroyed=!1,this.settings=t,this.tag=`ExpressionManager(${t.name})`}init(){this.defaultExpression=this.createExpression({},void 0),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}loadExpression(t){return De(this,null,function*(){if(!this.definitions[t]){Se.warn(this.tag,`Undefined expression at [${t}]`);return}if(this.expressions[t]===null){Se.warn(this.tag,`Cannot set expression at [${t}] because it's already failed in loading.`);return}if(this.expressions[t])return this.expressions[t];const e=yield this._loadExpression(t);return this.expressions[t]=e,e})}_loadExpression(t){throw new Error("Not implemented.")}setRandomExpression(){return De(this,null,function*(){if(this.definitions.length){const t=[];for(let e=0;e-1&&tu&&(o*=u/l,a*=u/l),this.vx+=o,this.vy+=a;const c=Math.sqrt(qi(this.vx,2)+qi(this.vy,2)),h=.5*(Math.sqrt(qi(u,2)+8*u*i)-u);c>h&&(this.vx*=h/c,this.vy*=h/c),this.x+=this.vx,this.y+=this.vy}}class Gf{constructor(t){this.json=t;let e=t.url;if(typeof e!="string")throw new TypeError("The `url` field in settings JSON must be defined as a string.");this.url=e,this.name=VA(this.url)}resolveURL(t){return rc.resolve(this.url,t)}replaceFiles(t){this.moc=t(this.moc,"moc"),this.pose!==void 0&&(this.pose=t(this.pose,"pose")),this.physics!==void 0&&(this.physics=t(this.physics,"physics"));for(let e=0;e(t.push(e),e)),t}validateFiles(t){const e=(s,o)=>{const a=this.resolveURL(s);if(!t.includes(a)){if(o)throw new Error(`File "${s}" is defined in settings, but doesn't exist in given files`);return!1}return!0};return[this.moc,...this.textures].forEach(s=>e(s,!0)),this.getDefinedFiles().filter(s=>e(s,!1))}}var rd=(r=>(r[r.NONE=0]="NONE",r[r.IDLE=1]="IDLE",r[r.NORMAL=2]="NORMAL",r[r.FORCE=3]="FORCE",r))(rd||{});class HA{constructor(){this.debug=!1,this.currentPriority=0,this.reservePriority=0}reserve(t,e,n){if(n<=0)return Se.log(this.tag,"Cannot start a motion with MotionPriority.NONE."),!1;if(t===this.currentGroup&&e===this.currentIndex)return Se.log(this.tag,"Motion is already playing.",this.dump(t,e)),!1;if(t===this.reservedGroup&&e===this.reservedIndex||t===this.reservedIdleGroup&&e===this.reservedIdleIndex)return Se.log(this.tag,"Motion is already reserved.",this.dump(t,e)),!1;if(n===1){if(this.currentPriority!==0)return Se.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(t,e)),!1;if(this.reservedIdleGroup!==void 0)return Se.log(this.tag,"Cannot start idle motion because another idle motion has reserved.",this.dump(t,e)),!1;this.setReservedIdle(t,e)}else{if(n<3){if(n<=this.currentPriority)return Se.log(this.tag,"Cannot start motion because another motion is playing as an equivalent or higher priority.",this.dump(t,e)),!1;if(n<=this.reservePriority)return Se.log(this.tag,"Cannot start motion because another motion has reserved as an equivalent or higher priority.",this.dump(t,e)),!1}this.setReserved(t,e,n)}return!0}start(t,e,n,i){if(i===1){if(this.setReservedIdle(void 0,void 0),this.currentPriority!==0)return Se.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(e,n)),!1}else{if(e!==this.reservedGroup||n!==this.reservedIndex)return Se.log(this.tag,"Cannot start motion because another motion has taken the place.",this.dump(e,n)),!1;this.setReserved(void 0,void 0,0)}return t?(this.setCurrent(e,n,i),!0):!1}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(t,e,n){this.currentPriority=n,this.currentGroup=t,this.currentIndex=e}setReserved(t,e,n){this.reservePriority=n,this.reservedGroup=t,this.reservedIndex=e}setReservedIdle(t,e){this.reservedIdleGroup=t,this.reservedIdleIndex=e}isActive(t,e){return t===this.currentGroup&&e===this.currentIndex||t===this.reservedGroup&&e===this.reservedIndex||t===this.reservedIdleGroup&&e===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!Mr.preserveExpressionOnMotion&&this.currentPriority>1}dump(t,e){if(this.debug){const n=["currentPriority","reservePriority","currentGroup","currentIndex","reservedGroup","reservedIndex","reservedIdleGroup","reservedIdleIndex"];return` + group = "${t}", index = ${e} +`+n.map(i=>"["+i+"] "+this[i]).join(` +`)}return""}}const XA="SoundManager",YA=.5;class ds{static get volume(){return this._volume}static set volume(t){this._volume=(t>1?1:t<0?0:t)||0,this.audios.forEach(e=>e.volume=this._volume)}static add(t,e,n){const i=new Audio(t);return i.volume=this._volume,i.preload="auto",i.addEventListener("ended",()=>{this.dispose(i),e==null||e()}),i.addEventListener("error",s=>{this.dispose(i),Se.warn(XA,`Error occurred on "${t}"`,s.error),n==null||n(s.error)}),this.audios.push(i),i}static play(t){return new Promise((e,n)=>{var i;(i=t.play())==null||i.catch(s=>{t.dispatchEvent(new ErrorEvent("error",{error:s})),n(s)}),t.readyState===t.HAVE_ENOUGH_DATA?e():t.addEventListener("canplaythrough",e)})}static dispose(t){t.pause(),t.removeAttribute("src"),jA(this.audios,t)}static destroy(){for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}}ds.audios=[];ds._volume=YA;class Wf extends ki{constructor(t,e){super(),this.motionGroups={},this.state=new HA,this.playing=!1,this.destroyed=!1,this.settings=t,this.tag=`MotionManager(${t.name})`,this.state.tag=this.tag}init(t){t!=null&&t.idleMotionGroup&&(this.groups.idle=t.idleMotionGroup),this.setupMotions(t),this.stopAllMotions()}setupMotions(t){for(const n of Object.keys(this.definitions))this.motionGroups[n]=[];let e;switch(t==null?void 0:t.motionPreload){case"NONE":return;case"ALL":e=Object.keys(this.definitions);break;case"IDLE":default:e=[this.groups.idle];break}for(const n of e)if(this.definitions[n])for(let i=0;ithis.currentAudio=void 0,()=>this.currentAudio=void 0),this.currentAudio=l}catch(h){Se.warn(this.tag,"Failed to create audio",c,h)}}const u=yield this.loadMotion(n,i);if(l){const c=ds.play(l).catch(h=>Se.warn(this.tag,"Failed to play audio",l.src,h));Mr.motionSync&&(yield c)}return this.state.start(u,n,i,s)?(Se.log(this.tag,"Start motion:",this.getMotionName(a)),this.emit("motionStart",n,i,l),this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),this.playing=!0,this._startMotion(u),!0):(l&&(ds.dispose(l),this.currentAudio=void 0),!1)})}startRandomMotion(t,e){return De(this,null,function*(){const n=this.definitions[t];if(n!=null&&n.length){const i=[];for(let s=0;se.index>=0);for(const e of t)this.hitAreas[e.name]=e}hitTest(t,e){return Object.keys(this.hitAreas).filter(n=>this.isHit(n,t,e))}isHit(t,e,n){if(!this.hitAreas[t])return!1;const i=this.hitAreas[t].index,s=this.getDrawableBounds(i,qA);return s.x<=e&&e<=s.x+s.width&&s.y<=n&&n<=s.y+s.height}getDrawableBounds(t,e){const n=this.getDrawableVertices(t);let i=n[0],s=n[0],o=n[1],a=n[1];for(let l=0;l{(s.status===200||s.status===0)&&s.response?n(s.response):s.onerror()},s.onerror=()=>{Se.warn(ZA,`Failed to load resource as ${s.responseType} (Status ${s.status}): ${t}`),i(new Zm("Network error.",t,s.status))},s.onabort=()=>i(new Zm("Aborted.",t,s.status,!0)),s.onloadend=()=>{var o;hr.allXhrSet.delete(s),r&&((o=hr.xhrMap.get(r))==null||o.delete(s))},s}static cancelXHRs(){var r;(r=hr.xhrMap.get(this))==null||r.forEach(t=>{t.abort(),hr.allXhrSet.delete(t)}),hr.xhrMap.delete(this)}static release(){hr.allXhrSet.forEach(r=>r.abort()),hr.allXhrSet.clear(),hr.xhrMap=new WeakMap}};let ic=hr;ic.xhrMap=new WeakMap;ic.allXhrSet=new Set;ic.loader=(r,t)=>new Promise((e,n)=>{hr.createXHR(r.target,r.settings?r.settings.resolveURL(r.url):r.url,r.type,s=>{r.result=s,e()},n).send()});function Q0(r,t){let e=-1;return n(0);function n(i,s){if(s)return Promise.reject(s);if(i<=e)return Promise.reject(new Error("next() called multiple times"));e=i;const o=r[i];if(!o)return Promise.resolve();try{return Promise.resolve(o(t,n.bind(null,i+1)))}catch(a){return Promise.reject(a)}}}class Pi{static load(t){return Q0(this.middlewares,t).then(()=>t.result)}}Pi.middlewares=[ic.loader];function KA(r,t={}){var e;const n={resourceOptions:{crossorigin:t.crossOrigin}};if(ws.fromURL)return ws.fromURL(r,n).catch(o=>{if(o instanceof Error)throw o;const a=new Error("Texture loading error");throw a.event=o,a});n.resourceOptions.autoLoad=!1;const i=ws.from(r,n);if(i.baseTexture.valid)return Promise.resolve(i);const s=i.baseTexture.resource;return(e=s._live2d_load)!=null||(s._live2d_load=new Promise((o,a)=>{const l=u=>{s.source.removeEventListener("error",l);const c=new Error("Texture loading error");c.event=u,a(c)};s.source.addEventListener("error",l),s.load().then(()=>o(i)).catch(l)})),s._live2d_load}const Km="Live2DFactory",Z0=(r,t)=>De(void 0,null,function*(){if(typeof r.source=="string"){const e=yield Pi.load({url:r.source,type:"json",target:r.live2dModel});e.url=r.source,r.source=e,r.live2dModel.emit("settingsJSONLoaded",e)}return t()}),K0=(r,t)=>De(void 0,null,function*(){if(r.source instanceof Gf)return r.settings=r.source,t();if(typeof r.source=="object"){const e=Ue.findRuntime(r.source);if(e){const n=e.createModelSettings(r.source);return r.settings=n,r.live2dModel.emit("settingsLoaded",n),t()}}throw new TypeError("Unknown settings format.")}),J0=(r,t)=>{if(r.settings){const e=Ue.findRuntime(r.settings);if(e)return e.ready().then(t)}return t()},tb=(r,t)=>De(void 0,null,function*(){yield t();const e=r.internalModel;if(e){const n=r.settings,i=Ue.findRuntime(n);if(i){const s=[];n.pose&&s.push(Pi.load({settings:n,url:n.pose,type:"json",target:e}).then(o=>{e.pose=i.createPose(e.coreModel,o),r.live2dModel.emit("poseLoaded",e.pose)}).catch(o=>{r.live2dModel.emit("poseLoadError",o),Se.warn(Km,"Failed to load pose.",o)})),n.physics&&s.push(Pi.load({settings:n,url:n.physics,type:"json",target:e}).then(o=>{e.physics=i.createPhysics(e.coreModel,o),r.live2dModel.emit("physicsLoaded",e.physics)}).catch(o=>{r.live2dModel.emit("physicsLoadError",o),Se.warn(Km,"Failed to load physics.",o)})),s.length&&(yield Promise.all(s))}}}),eb=(r,t)=>De(void 0,null,function*(){if(r.settings){const e=r.live2dModel,n=r.settings.textures.map(i=>{const s=r.settings.resolveURL(i);return KA(s,{crossOrigin:r.options.crossOrigin})});if(yield t(),r.internalModel)e.internalModel=r.internalModel,e.emit("modelLoaded",r.internalModel);else throw new TypeError("Missing internal model.");e.textures=yield Promise.all(n),e.emit("textureLoaded",e.textures)}else throw new TypeError("Missing settings.")}),rb=(r,t)=>De(void 0,null,function*(){const e=r.settings;if(e instanceof Gf){const n=Ue.findRuntime(e);if(!n)throw new TypeError("Unknown model settings.");const i=yield Pi.load({settings:e,url:e.moc,type:"arraybuffer",target:r.live2dModel});if(!n.isValidMoc(i))throw new Error("Invalid moc data");const s=n.createCoreModel(i);return r.internalModel=n.createInternalModel(s,e,r.options),t()}throw new TypeError("Missing settings.")}),Je=class{static registerRuntime(r){Je.runtimes.push(r),Je.runtimes.sort((t,e)=>e.version-t.version)}static findRuntime(r){for(const t of Je.runtimes)if(t.test(r))return t}static setupLive2DModel(r,t,e){return De(this,null,function*(){const n=new Promise(o=>r.once("textureLoaded",o)),i=new Promise(o=>r.once("modelLoaded",o)),s=Promise.all([n,i]).then(()=>r.emit("ready"));yield Q0(Je.live2DModelMiddlewares,{live2dModel:r,source:t,options:e||{}}),yield s,r.emit("load")})}static loadMotion(r,t,e){var n,i;const s=o=>r.emit("motionLoadError",t,e,o);try{const o=(n=r.definitions[t])==null?void 0:n[e];if(!o)return Promise.resolve(void 0);r.listeners("destroy").includes(Je.releaseTasks)||r.once("destroy",Je.releaseTasks);let a=Je.motionTasksMap.get(r);a||(a={},Je.motionTasksMap.set(r,a));let l=a[t];l||(l=[],a[t]=l);const u=r.getMotionFile(o);return(i=l[e])!=null||(l[e]=Pi.load({url:u,settings:r.settings,type:r.motionDataType,target:r}).then(c=>{var h;const f=(h=Je.motionTasksMap.get(r))==null?void 0:h[t];f&&delete f[e];const d=r.createMotion(c,t,o);return r.emit("motionLoaded",t,e,d),d}).catch(c=>{Se.warn(r.tag,`Failed to load motion: ${u} +`,c),s(c)})),l[e]}catch(o){Se.warn(r.tag,`Failed to load motion at "${t}"[${e}] +`,o),s(o)}return Promise.resolve(void 0)}static loadExpression(r,t){var e;const n=i=>r.emit("expressionLoadError",t,i);try{const i=r.definitions[t];if(!i)return Promise.resolve(void 0);r.listeners("destroy").includes(Je.releaseTasks)||r.once("destroy",Je.releaseTasks);let s=Je.expressionTasksMap.get(r);s||(s=[],Je.expressionTasksMap.set(r,s));const o=r.getExpressionFile(i);return(e=s[t])!=null||(s[t]=Pi.load({url:o,settings:r.settings,type:"json",target:r}).then(a=>{const l=Je.expressionTasksMap.get(r);l&&delete l[t];const u=r.createExpression(a,i);return r.emit("expressionLoaded",t,u),u}).catch(a=>{Se.warn(r.tag,`Failed to load expression: ${o} +`,a),n(a)})),s[t]}catch(i){Se.warn(r.tag,`Failed to load expression at [${t}] +`,i),n(i)}return Promise.resolve(void 0)}static releaseTasks(){this instanceof Wf?Je.motionTasksMap.delete(this):Je.expressionTasksMap.delete(this)}};let Ue=Je;Ue.runtimes=[];Ue.urlToJSON=Z0;Ue.jsonToSettings=K0;Ue.waitUntilReady=J0;Ue.setupOptionals=tb;Ue.setupEssentials=eb;Ue.createInternalModel=rb;Ue.live2DModelMiddlewares=[Z0,K0,J0,tb,eb,rb];Ue.motionTasksMap=new WeakMap;Ue.expressionTasksMap=new WeakMap;Wf.prototype._loadMotion=function(r,t){return Ue.loadMotion(this,r,t)};q0.prototype._loadExpression=function(r){return Ue.loadExpression(this,r)};class JA{constructor(){this._autoInteract=!1}get autoInteract(){return this._autoInteract}set autoInteract(t){t!==this._autoInteract&&(t?this.on("pointertap",Jm,this):this.off("pointertap",Jm,this),this._autoInteract=t)}registerInteraction(t){t!==this.interactionManager&&(this.unregisterInteraction(),this._autoInteract&&t&&(this.interactionManager=t,t.on("pointermove",tg,this)))}unregisterInteraction(){var t;this.interactionManager&&((t=this.interactionManager)==null||t.off("pointermove",tg,this),this.interactionManager=void 0)}}function Jm(r){this.tap(r.data.global.x,r.data.global.y)}function tg(r){this.focus(r.data.global.x,r.data.global.y)}class tM extends I0{}const jr=new Oe,eM=new ir;let vi;class rM extends su{constructor(t){super(),this.tag="Live2DModel(uninitialized)",this.textures=[],this.transform=new tM,this.anchor=new ho(this.onAnchorChange,this,0,0),this.glContextID=-1,this.elapsedTime=performance.now(),this.deltaTime=0,this._autoUpdate=!1,this.once("modelLoaded",()=>this.init(t))}static from(t,e){const n=new this(e);return Ue.setupLive2DModel(n,t,e).then(()=>n)}static fromSync(t,e){const n=new this(e);return Ue.setupLive2DModel(n,t,e).then(e==null?void 0:e.onLoad).catch(e==null?void 0:e.onError),n}static registerTicker(t){vi=t}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){var e;vi||(vi=(e=window.PIXI)==null?void 0:e.Ticker),t?this._destroyed||(vi?(vi.shared.add(this.onTickerUpdate,this),this._autoUpdate=!0):Se.warn(this.tag,"No Ticker registered, please call Live2DModel.registerTicker(Ticker).")):(vi==null||vi.shared.remove(this.onTickerUpdate,this),this._autoUpdate=!1)}init(t){this.tag=`Live2DModel(${this.internalModel.settings.name})`;const e=Object.assign({autoUpdate:!0,autoInteract:!0},t);e.autoInteract&&(this.interactive=!0),this.autoInteract=e.autoInteract,this.autoUpdate=e.autoUpdate}onAnchorChange(){this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(t,e,n){return e===void 0?this.internalModel.motionManager.startRandomMotion(t,n):this.internalModel.motionManager.startMotion(t,e,n)}expression(t){return this.internalModel.motionManager.expressionManager?t===void 0?this.internalModel.motionManager.expressionManager.setRandomExpression():this.internalModel.motionManager.expressionManager.setExpression(t):Promise.resolve(!1)}focus(t,e,n=!1){jr.x=t,jr.y=e,this.toModelPosition(jr,jr,!0);let i=jr.x/this.internalModel.originalWidth*2-1,s=jr.y/this.internalModel.originalHeight*2-1,o=Math.atan2(s,i);this.internalModel.focusController.focus(Math.cos(o),-Math.sin(o),n)}tap(t,e){const n=this.hitTest(t,e);n.length&&(Se.log(this.tag,"Hit",n),this.emit("hit",n))}hitTest(t,e){return jr.x=t,jr.y=e,this.toModelPosition(jr,jr),this.internalModel.hitTest(jr.x,jr.y)}toModelPosition(t,e=t.clone(),n){return n||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.transform.worldTransform.applyInverse(t,e),this.internalModel.localTransform.applyInverse(e,e),e}containsPoint(t){return this.getBounds(!0).contains(t.x,t.y)}_calculateBounds(){this._bounds.addFrame(this.transform,0,0,this.internalModel.width,this.internalModel.height)}onTickerUpdate(){this.update(vi.shared.deltaMS)}update(t){this.deltaTime+=t,this.elapsedTime+=t}_render(t){this.registerInteraction(t.plugins.interaction),t.batch.reset(),t.geometry.reset(),t.shader.reset(),t.state.reset();let e=!1;this.glContextID!==t.CONTEXT_UID&&(this.glContextID=t.CONTEXT_UID,this.internalModel.updateWebGLContext(t.gl,this.glContextID),e=!0);for(let s=0;se.destroy(t.baseTexture)),this.internalModel.destroy(),super.destroy(t)}}Y0(rM,[JA]);const Cn=class{static resolveURL(r,t){var e;const n=(e=Cn.filesMap[r])==null?void 0:e[t];if(n===void 0)throw new Error("Cannot find this file from uploaded files: "+t);return n}static upload(r,t){return De(this,null,function*(){const e={};for(const n of t.getDefinedFiles()){const i=decodeURI(rc.resolve(t.url,n)),s=r.find(o=>o.webkitRelativePath===i);s&&(e[n]=URL.createObjectURL(s))}Cn.filesMap[t._objectURL]=e})}static createSettings(r){return De(this,null,function*(){const t=r.find(o=>o.name.endsWith("model.json")||o.name.endsWith("model3.json"));if(!t)throw new TypeError("Settings file not found");const e=yield Cn.readText(t),n=JSON.parse(e);n.url=t.webkitRelativePath;const i=Ue.findRuntime(n);if(!i)throw new Error("Unknown settings JSON");const s=i.createModelSettings(n);return s._objectURL=URL.createObjectURL(t),s})}static readText(r){return De(this,null,function*(){return new Promise((t,e)=>{const n=new FileReader;n.onload=()=>t(n.result),n.onerror=e,n.readAsText(r,"utf8")})})}};let Hf=Cn;Hf.filesMap={};Hf.factory=(r,t)=>De(void 0,null,function*(){if(Array.isArray(r.source)&&r.source[0]instanceof File){const e=r.source;let n=e.settings;if(!n)n=yield Cn.createSettings(e);else if(!n._objectURL)throw new Error('"_objectURL" must be specified in ModelSettings');n.validateFiles(e.map(i=>encodeURI(i.webkitRelativePath))),yield Cn.upload(e,n),n.resolveURL=function(i){return Cn.resolveURL(this._objectURL,i)},r.source=n,r.live2dModel.once("modelLoaded",i=>{i.once("destroy",function(){const s=this.settings._objectURL;if(URL.revokeObjectURL(s),Cn.filesMap[s])for(const o of Object.values(Cn.filesMap[s]))URL.revokeObjectURL(o);delete Cn.filesMap[s]})})}return t()});Ue.live2DModelMiddlewares.unshift(Hf.factory);const yr=class{static unzip(r,t){return De(this,null,function*(){const e=yield yr.getFilePaths(r),n=[];for(const s of t.getDefinedFiles()){const o=decodeURI(rc.resolve(t.url,s));e.includes(o)&&n.push(o)}const i=yield yr.getFiles(r,n);for(let s=0;so.endsWith("model.json")||o.endsWith("model3.json"));if(!e)throw new Error("Settings file not found");const n=yield yr.readText(r,e);if(!n)throw new Error("Empty settings file: "+e);const i=JSON.parse(n);i.url=e;const s=Ue.findRuntime(i);if(!s)throw new Error("Unknown settings JSON");return s.createModelSettings(i)})}static zipReader(r,t){return De(this,null,function*(){throw new Error("Not implemented")})}static getFilePaths(r){return De(this,null,function*(){throw new Error("Not implemented")})}static getFiles(r,t){return De(this,null,function*(){throw new Error("Not implemented")})}static readText(r,t){return De(this,null,function*(){throw new Error("Not implemented")})}static releaseReader(r){}};let Hn=yr;Hn.ZIP_PROTOCOL="zip://";Hn.uid=0;Hn.factory=(r,t)=>De(void 0,null,function*(){const e=r.source;let n,i,s;if(typeof e=="string"&&(e.endsWith(".zip")||e.startsWith(yr.ZIP_PROTOCOL))?(e.startsWith(yr.ZIP_PROTOCOL)?n=e.slice(yr.ZIP_PROTOCOL.length):n=e,i=yield Pi.load({url:n,type:"blob",target:r.live2dModel})):Array.isArray(e)&&e.length===1&&e[0]instanceof File&&e[0].name.endsWith(".zip")&&(i=e[0],n=URL.createObjectURL(i),s=e.settings),i){if(!i.size)throw new Error("Empty zip file");const o=yield yr.zipReader(i,n);s||(s=yield yr.createSettings(o)),s._objectURL=yr.ZIP_PROTOCOL+yr.uid+"/"+s.url;const a=yield yr.unzip(o,s);a.settings=s,r.source=a,n.startsWith("blob:")&&r.live2dModel.once("modelLoaded",l=>{l.once("destroy",function(){URL.revokeObjectURL(n)})}),yr.releaseReader(o)}return t()});Ue.live2DModelMiddlewares.unshift(Hn.factory);if(!window.Live2DCubismCore)throw new Error("Could not find Cubism 4 runtime. This plugin requires live2dcubismcore.js to be loaded.");class nM extends q0{constructor(t,e){var n;super(t,e),this.queueManager=new G0,this.definitions=(n=t.expressions)!=null?n:[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(t){return this.definitions.findIndex(e=>e.Name===t)}getExpressionFile(t){return t.File}createExpression(t,e){return kf.create(t)}_setExpression(t){return this.queueManager.startMotion(t,!1,performance.now())}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.doUpdateMotion(t,e)}}class xs extends Gf{constructor(t){if(super(t),!xs.isValidJSON(t))throw new TypeError("Invalid JSON.");Object.assign(this,new X0(t))}static isValidJSON(t){var e;return!!(t!=null&&t.FileReferences)&&typeof t.FileReferences.Moc=="string"&&((e=t.FileReferences.Textures)==null?void 0:e.length)>0&&t.FileReferences.Textures.every(n=>typeof n=="string")}replaceFiles(t){if(super.replaceFiles(t),this.motions)for(const[e,n]of Object.entries(this.motions))for(let i=0;i{this.emit("motion:"+n)})}isFinished(){return this.queueManager.isFinished()}_startMotion(t,e){return t.setFinishedMotionHandler(e),this.queueManager.stopAllMotions(),this.queueManager.startMotion(t,!1,performance.now())}_stopAllMotions(){this.queueManager.stopAllMotions()}createMotion(t,e,n){const i=Vf.create(t),s=new $0(t),o=(e===this.groups.idle?Mr.idleMotionFadingDuration:Mr.motionFadingDuration)/1e3;return s.getMotionFadeInTime()===void 0&&i.setFadeInTime(n.FadeInTime>0?n.FadeInTime:o),s.getMotionFadeOutTime()===void 0&&i.setFadeOutTime(n.FadeOutTime>0?n.FadeOutTime:o),i.setEffectIds(this.eyeBlinkIds,this.lipSyncIds),i}getMotionFile(t){return t.File}getMotionName(t){return t.File}getSoundFile(t){return t.Sound}updateParameters(t,e){return this.queueManager.doUpdateMotion(t,e)}destroy(){super.destroy(),this.queueManager.release(),this.queueManager=void 0}}const eg=new Jr;class sM extends QA{constructor(t,e,n){super(),this.lipSync=!0,this.breath=Lf.create(),this.renderer=new H0,this.idParamAngleX=DA,this.idParamAngleY=LA,this.idParamAngleZ=NA,this.idParamEyeBallX=BA,this.idParamEyeBallY=UA,this.idParamBodyAngleX=kA,this.idParamBreath=zA,this.pixelsPerUnit=1,this.centeringTransform=new ir,this.coreModel=t,this.settings=e,this.motionManager=new iM(e,n),this.init()}init(){var t;super.init(),((t=this.settings.getEyeBlinkParameters())==null?void 0:t.length)>0&&(this.eyeBlink=V0.create(this.settings)),this.breath.setParameters([new Qo(this.idParamAngleX,0,15,6.5345,.5),new Qo(this.idParamAngleY,0,8,3.5345,.5),new Qo(this.idParamAngleZ,0,10,5.5345,.5),new Qo(this.idParamBodyAngleX,0,4,15.5345,.5),new Qo(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(){const t={};if(this.settings.layout)for(const e of Object.keys(this.settings.layout)){const n=e.charAt(0).toLowerCase()+e.slice(1);t[n]=this.settings.layout[e]}return t}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(t,e){this.renderer.firstDraw=!0,this.renderer._bufferData={vertex:null,uv:null,index:null},this.renderer.startUp(t),this.renderer._clippingManager._currentFrameNo=e,this.renderer._clippingManager._maskTexture=void 0,yo.getInstance()._shaderSets=[]}bindTexture(t,e){this.renderer.bindTexture(t,e)}getHitAreaDefs(){var t,e;return(e=(t=this.settings.hitAreas)==null?void 0:t.map(n=>({id:n.Id,name:n.Name,index:this.coreModel.getDrawableIndex(n.Id)})))!=null?e:[]}getDrawableIDs(){return this.coreModel.getDrawableIds()}getDrawableIndex(t){return this.coreModel.getDrawableIndex(t)}getDrawableVertices(t){if(typeof t=="string"&&(t=this.coreModel.getDrawableIndex(t),t===-1))throw new TypeError("Unable to find drawable ID: "+t);const e=this.coreModel.getDrawableVertices(t).slice();for(let n=0;n{function e(){try{aM(),r()}catch(n){if(rg--,rg<0){const i=new Error("Failed to start up Cubism 4 framework.");i.cause=n,t(i);return}Se.log("Cubism4","Startup failed, retrying 10ms later..."),setTimeout(e,10)}}e()})),El)}function aM(r){r=Object.assign({logFunction:console.log,loggingLevel:Rs.LogLevel_Verbose},r),La.startUp(r),La.initialize()}Ue.registerRuntime({version:4,ready:oM,test(r){return r instanceof xs||xs.isValidJSON(r)},isValidMoc(r){if(r.byteLength<4)return!1;const t=new Int8Array(r,0,4);return String.fromCharCode(...t)==="MOC3"},createModelSettings(r){return new xs(r)},createCoreModel(r){const t=Uf.create(r);try{const e=t.createModel();return e.__moc=t,e}catch(e){try{t.release()}catch{}throw e}},createInternalModel(r,t,e){const n=new sM(r,t,e),i=r;return i.__moc&&(n.__moc=i.__moc,delete i.__moc,n.once("destroy",lM)),n},createPhysics(r,t){return jf.create(t)},createPose(r,t){return Nf.create(t)}});function lM(){var r;(r=this.__moc)==null||r.release()}/*! + * @pixi/interaction - v6.5.10 + * Compiled Thu, 06 Jul 2023 15:25:11 UTC + * + * @pixi/interaction is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */var ng=function(){function r(){this.pressure=0,this.rotationAngle=0,this.twist=0,this.tangentialPressure=0,this.global=new Oe,this.target=null,this.originalEvent=null,this.identifier=null,this.isPrimary=!1,this.button=0,this.buttons=0,this.width=0,this.height=0,this.tiltX=0,this.tiltY=0,this.pointerType=null,this.pressure=0,this.rotationAngle=0,this.twist=0,this.tangentialPressure=0}return Object.defineProperty(r.prototype,"pointerId",{get:function(){return this.identifier},enumerable:!1,configurable:!0}),r.prototype.getLocalPosition=function(t,e,n){return t.worldTransform.applyInverse(n||this.global,e)},r.prototype.copyEvent=function(t){"isPrimary"in t&&t.isPrimary&&(this.isPrimary=!0),this.button="button"in t&&t.button;var e="buttons"in t&&t.buttons;this.buttons=Number.isInteger(e)?e:"which"in t&&t.which,this.width="width"in t&&t.width,this.height="height"in t&&t.height,this.tiltX="tiltX"in t&&t.tiltX,this.tiltY="tiltY"in t&&t.tiltY,this.pointerType="pointerType"in t&&t.pointerType,this.pressure="pressure"in t&&t.pressure,this.rotationAngle="rotationAngle"in t&&t.rotationAngle,this.twist="twist"in t&&t.twist||0,this.tangentialPressure="tangentialPressure"in t&&t.tangentialPressure||0},r.prototype.reset=function(){this.isPrimary=!1},r}();/*! ***************************************************************************** +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 nd=function(r,t){return nd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i])},nd(r,t)};function uM(r,t){nd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var cM=function(){function r(){this.stopped=!1,this.stopsPropagatingAt=null,this.stopPropagationHint=!1,this.target=null,this.currentTarget=null,this.type=null,this.data=null}return r.prototype.stopPropagation=function(){this.stopped=!0,this.stopPropagationHint=!0,this.stopsPropagatingAt=this.currentTarget},r.prototype.reset=function(){this.stopped=!1,this.stopsPropagatingAt=null,this.stopPropagationHint=!1,this.currentTarget=null,this.target=null},r}(),lh=function(){function r(t){this._pointerId=t,this._flags=r.FLAGS.NONE}return r.prototype._doSet=function(t,e){e?this._flags=this._flags|t:this._flags=this._flags&~t},Object.defineProperty(r.prototype,"pointerId",{get:function(){return this._pointerId},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"flags",{get:function(){return this._flags},set:function(t){this._flags=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"none",{get:function(){return this._flags===r.FLAGS.NONE},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"over",{get:function(){return(this._flags&r.FLAGS.OVER)!==0},set:function(t){this._doSet(r.FLAGS.OVER,t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rightDown",{get:function(){return(this._flags&r.FLAGS.RIGHT_DOWN)!==0},set:function(t){this._doSet(r.FLAGS.RIGHT_DOWN,t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"leftDown",{get:function(){return(this._flags&r.FLAGS.LEFT_DOWN)!==0},set:function(t){this._doSet(r.FLAGS.LEFT_DOWN,t)},enumerable:!1,configurable:!0}),r.FLAGS=Object.freeze({NONE:0,OVER:1,LEFT_DOWN:2,RIGHT_DOWN:4}),r}(),hM=function(){function r(){this._tempPoint=new Oe}return r.prototype.recursiveFindHit=function(t,e,n,i,s){var o;if(!e||!e.visible)return!1;var a=t.data.global;s=e.interactive||s;var l=!1,u=s,c=!0;if(e.hitArea)i&&(e.worldTransform.applyInverse(a,this._tempPoint),e.hitArea.contains(this._tempPoint.x,this._tempPoint.y)?l=!0:(i=!1,c=!1)),u=!1;else if(e._mask&&i){var h=e._mask.isMaskData?e._mask.maskObject:e._mask;h&&!(!((o=h.containsPoint)===null||o===void 0)&&o.call(h,a))&&(i=!1)}if(c&&e.interactiveChildren&&e.children)for(var f=e.children,d=f.length-1;d>=0;d--){var m=f[d],g=this.recursiveFindHit(t,m,n,i,u);if(g){if(!m.parent)continue;u=!1,g&&(t.target&&(i=!1),l=!0)}}return s&&(i&&!t.target&&!e.hitArea&&e.containsPoint&&e.containsPoint(a)&&(l=!0),e.interactive&&(l&&!t.target&&(t.target=e),n&&n(t,e,!!l))),l},r.prototype.findHit=function(t,e,n,i){this.recursiveFindHit(t,e,n,i,!1)},r}(),dM={interactive:!1,interactiveChildren:!0,hitArea:null,get buttonMode(){return this.cursor==="pointer"},set buttonMode(r){r?this.cursor="pointer":this.cursor==="pointer"&&(this.cursor=null)},cursor:null,get trackedPointers(){return this._trackedPointers===void 0&&(this._trackedPointers={}),this._trackedPointers},_trackedPointers:void 0};Da.mixin(dM);var Al=1,Ml={target:null,data:{global:null}},Kk=function(r){uM(t,r);function t(e,n){var i=r.call(this)||this;return n=n||{},i.renderer=e,i.autoPreventDefault=n.autoPreventDefault!==void 0?n.autoPreventDefault:!0,i.interactionFrequency=n.interactionFrequency||10,i.mouse=new ng,i.mouse.identifier=Al,i.mouse.global.set(-999999),i.activeInteractionData={},i.activeInteractionData[Al]=i.mouse,i.interactionDataPool=[],i.eventData=new cM,i.interactionDOMElement=null,i.moveWhenInside=!1,i.eventsAdded=!1,i.tickerAdded=!1,i.mouseOverRenderer=!("PointerEvent"in globalThis),i.supportsTouchEvents="ontouchstart"in globalThis,i.supportsPointerEvents=!!globalThis.PointerEvent,i.onPointerUp=i.onPointerUp.bind(i),i.processPointerUp=i.processPointerUp.bind(i),i.onPointerCancel=i.onPointerCancel.bind(i),i.processPointerCancel=i.processPointerCancel.bind(i),i.onPointerDown=i.onPointerDown.bind(i),i.processPointerDown=i.processPointerDown.bind(i),i.onPointerMove=i.onPointerMove.bind(i),i.processPointerMove=i.processPointerMove.bind(i),i.onPointerOut=i.onPointerOut.bind(i),i.processPointerOverOut=i.processPointerOverOut.bind(i),i.onPointerOver=i.onPointerOver.bind(i),i.cursorStyles={default:"inherit",pointer:"pointer"},i.currentCursorMode=null,i.cursor=null,i.resolution=1,i.delayedEvents=[],i.search=new hM,i._tempDisplayObject=new z0,i._eventListenerOptions={capture:!0,passive:!1},i._useSystemTicker=n.useSystemTicker!==void 0?n.useSystemTicker:!0,i.setTargetElement(i.renderer.view,i.renderer.resolution),i}return Object.defineProperty(t.prototype,"useSystemTicker",{get:function(){return this._useSystemTicker},set:function(e){this._useSystemTicker=e,e?this.addTickerListener():this.removeTickerListener()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastObjectRendered",{get:function(){return this.renderer._lastObjectRendered||this._tempDisplayObject},enumerable:!1,configurable:!0}),t.prototype.hitTest=function(e,n){return Ml.target=null,Ml.data.global=e,n||(n=this.lastObjectRendered),this.processInteractive(Ml,n,null,!0),Ml.target},t.prototype.setTargetElement=function(e,n){n===void 0&&(n=1),this.removeTickerListener(),this.removeEvents(),this.interactionDOMElement=e,this.resolution=n,this.addEvents(),this.addTickerListener()},t.prototype.addTickerListener=function(){this.tickerAdded||!this.interactionDOMElement||!this._useSystemTicker||(Mn.system.add(this.tickerUpdate,this,Ao.INTERACTION),this.tickerAdded=!0)},t.prototype.removeTickerListener=function(){this.tickerAdded&&(Mn.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)},t.prototype.addEvents=function(){if(!(this.eventsAdded||!this.interactionDOMElement)){var e=this.interactionDOMElement.style;globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):this.supportsPointerEvents&&(e.touchAction="none"),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.addEventListener("pointerdown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.addEventListener("pointerleave",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.addEventListener("pointerover",this.onPointerOver,this._eventListenerOptions),globalThis.addEventListener("pointercancel",this.onPointerCancel,this._eventListenerOptions),globalThis.addEventListener("pointerup",this.onPointerUp,this._eventListenerOptions)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.addEventListener("mousedown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.addEventListener("mouseout",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.addEventListener("mouseover",this.onPointerOver,this._eventListenerOptions),globalThis.addEventListener("mouseup",this.onPointerUp,this._eventListenerOptions)),this.supportsTouchEvents&&(this.interactionDOMElement.addEventListener("touchstart",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.addEventListener("touchcancel",this.onPointerCancel,this._eventListenerOptions),this.interactionDOMElement.addEventListener("touchend",this.onPointerUp,this._eventListenerOptions),this.interactionDOMElement.addEventListener("touchmove",this.onPointerMove,this._eventListenerOptions)),this.eventsAdded=!0}},t.prototype.removeEvents=function(){if(!(!this.eventsAdded||!this.interactionDOMElement)){var e=this.interactionDOMElement.style;globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):this.supportsPointerEvents&&(e.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("pointerdown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("pointerleave",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("pointerover",this.onPointerOver,this._eventListenerOptions),globalThis.removeEventListener("pointercancel",this.onPointerCancel,this._eventListenerOptions),globalThis.removeEventListener("pointerup",this.onPointerUp,this._eventListenerOptions)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("mousedown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("mouseout",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("mouseover",this.onPointerOver,this._eventListenerOptions),globalThis.removeEventListener("mouseup",this.onPointerUp,this._eventListenerOptions)),this.supportsTouchEvents&&(this.interactionDOMElement.removeEventListener("touchstart",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("touchcancel",this.onPointerCancel,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("touchend",this.onPointerUp,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("touchmove",this.onPointerMove,this._eventListenerOptions)),this.interactionDOMElement=null,this.eventsAdded=!1}},t.prototype.tickerUpdate=function(e){this._deltaTime+=e,!(this._deltaTime0&&(a=e.composedPath()[0]);for(var l=a!==this.interactionDOMElement?"outside":"",u=0;u"u"&&(o.button=e.touches.length?1:0),typeof o.buttons>"u"&&(o.buttons=e.touches.length?1:0),typeof o.isPrimary>"u"&&(o.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof o.width>"u"&&(o.width=o.radiusX||1),typeof o.height>"u"&&(o.height=o.radiusY||1),typeof o.tiltX>"u"&&(o.tiltX=0),typeof o.tiltY>"u"&&(o.tiltY=0),typeof o.pointerType>"u"&&(o.pointerType="touch"),typeof o.pointerId>"u"&&(o.pointerId=o.identifier||0),typeof o.pressure>"u"&&(o.pressure=o.force||.5),typeof o.twist>"u"&&(o.twist=0),typeof o.tangentialPressure>"u"&&(o.tangentialPressure=0),typeof o.layerX>"u"&&(o.layerX=o.offsetX=o.clientX),typeof o.layerY>"u"&&(o.layerY=o.offsetY=o.clientY),o.isNormalized=!0,n.push(o)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){var a=e;typeof a.isPrimary>"u"&&(a.isPrimary=!0),typeof a.width>"u"&&(a.width=1),typeof a.height>"u"&&(a.height=1),typeof a.tiltX>"u"&&(a.tiltX=0),typeof a.tiltY>"u"&&(a.tiltY=0),typeof a.pointerType>"u"&&(a.pointerType="mouse"),typeof a.pointerId>"u"&&(a.pointerId=Al),typeof a.pressure>"u"&&(a.pressure=.5),typeof a.twist>"u"&&(a.twist=0),typeof a.tangentialPressure>"u"&&(a.tangentialPressure=0),a.isNormalized=!0,n.push(a)}else n.push(e);return n},t.prototype.destroy=function(){this.removeEvents(),this.removeTickerListener(),this.removeAllListeners(),this.renderer=null,this.mouse=null,this.eventData=null,this.interactionDOMElement=null,this.onPointerDown=null,this.processPointerDown=null,this.onPointerUp=null,this.processPointerUp=null,this.onPointerCancel=null,this.processPointerCancel=null,this.onPointerMove=null,this.processPointerMove=null,this.onPointerOut=null,this.processPointerOverOut=null,this.onPointerOver=null,this.search=null},t.extension={name:"interaction",type:[rn.RendererPlugin,rn.CanvasRendererPlugin]},t}(ki);function Ai(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var uh={exports:{}};/*! + localForage -- Offline Storage, Improved + Version 1.10.0 + https://localforage.github.io/localForage + (c) 2013-2017 Mozilla, Apache License 2.0 +*/var ig;function fM(){return ig||(ig=1,function(r,t){(function(e){r.exports=e()})(function(){return function e(n,i,s){function o(u,c){if(!i[u]){if(!n[u]){var h=typeof Ai=="function"&&Ai;if(!c&&h)return h(u,!0);if(a)return a(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var d=i[u]={exports:{}};n[u][0].call(d.exports,function(m){var g=n[u][1][m];return o(g||m)},d,d.exports,e,n,i,s)}return i[u].exports}for(var a=typeof Ai=="function"&&Ai,l=0;l"u"&&e(3);var h=Promise;function f(A,V){V&&A.then(function(F){V(null,F)},function(F){V(F)})}function d(A,V,F){typeof V=="function"&&A.then(V),typeof F=="function"&&A.catch(F)}function m(A){return typeof A!="string"&&(console.warn(A+" used as a key, but it is not a string."),A=String(A)),A}function g(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var p="local-forage-detect-blob-support",y=void 0,_={},S=Object.prototype.toString,T="readonly",v="readwrite";function E(A){for(var V=A.length,F=new ArrayBuffer(V),X=new Uint8Array(F),J=0;J=43)}}).catch(function(){return!1})}function B(A){return typeof y=="boolean"?h.resolve(y):w(A).then(function(V){return y=V,y})}function N(A){var V=_[A.name],F={};F.promise=new h(function(X,J){F.resolve=X,F.reject=J}),V.deferredOperations.push(F),V.dbReady?V.dbReady=V.dbReady.then(function(){return F.promise}):V.dbReady=F.promise}function $(A){var V=_[A.name],F=V.deferredOperations.pop();if(F)return F.resolve(),F.promise}function it(A,V){var F=_[A.name],X=F.deferredOperations.pop();if(X)return X.reject(V),X.promise}function I(A,V){return new h(function(F,X){if(_[A.name]=_[A.name]||O(),A.db)if(V)N(A),A.db.close();else return F(A.db);var J=[A.name];V&&J.push(A.version);var G=l.open.apply(l,J);V&&(G.onupgradeneeded=function(st){var ut=G.result;try{ut.createObjectStore(A.storeName),st.oldVersion<=1&&ut.createObjectStore(p)}catch(dt){if(dt.name==="ConstraintError")console.warn('The database "'+A.name+'" has been upgraded from version '+st.oldVersion+" to version "+st.newVersion+', but the storage "'+A.storeName+'" already exists.');else throw dt}}),G.onerror=function(st){st.preventDefault(),X(G.error)},G.onsuccess=function(){var st=G.result;st.onversionchange=function(ut){ut.target.close()},F(st),$(A)}})}function Z(A){return I(A,!1)}function x(A){return I(A,!0)}function nt(A,V){if(!A.db)return!0;var F=!A.db.objectStoreNames.contains(A.storeName),X=A.versionA.db.version;if(X&&(A.version!==V&&console.warn('The database "'+A.name+`" can't be downgraded from version `+A.db.version+" to version "+A.version+"."),A.version=A.db.version),J||F){if(F){var G=A.db.version+1;G>A.version&&(A.version=G)}return!0}return!1}function P(A){return new h(function(V,F){var X=new FileReader;X.onerror=F,X.onloadend=function(J){var G=btoa(J.target.result||"");V({__local_forage_encoded_blob:!0,data:G,type:A.type})},X.readAsBinaryString(A)})}function C(A){var V=E(atob(A.data));return c([V],{type:A.type})}function R(A){return A&&A.__local_forage_encoded_blob}function z(A){var V=this,F=V._initReady().then(function(){var X=_[V._dbInfo.name];if(X&&X.dbReady)return X.dbReady});return d(F,A,A),F}function U(A){N(A);for(var V=_[A.name],F=V.forages,X=0;X0&&(!A.db||G.name==="InvalidStateError"||G.name==="NotFoundError"))return h.resolve().then(function(){if(!A.db||G.name==="NotFoundError"&&!A.db.objectStoreNames.contains(A.storeName)&&A.version<=A.db.version)return A.db&&(A.version=A.db.version+1),x(A)}).then(function(){return U(A).then(function(){M(A,V,F,X-1)})}).catch(F);F(G)}}function O(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function j(A){var V=this,F={db:null};if(A)for(var X in A)F[X]=A[X];var J=_[F.name];J||(J=O(),_[F.name]=J),J.forages.push(V),V._initReady||(V._initReady=V.ready,V.ready=z);var G=[];function st(){return h.resolve()}for(var ut=0;ut>4,yt[J++]=(st&15)<<4|ut>>2,yt[J++]=(ut&3)<<6|dt&63;return pt}function yn(A){var V=new Uint8Array(A),F="",X;for(X=0;X>2],F+=K[(V[X]&3)<<4|V[X+1]>>4],F+=K[(V[X+1]&15)<<2|V[X+2]>>6],F+=K[V[X+2]&63];return V.length%3===2?F=F.substring(0,F.length-1)+"=":V.length%3===1&&(F=F.substring(0,F.length-2)+"=="),F}function gi(A,V){var F="";if(A&&(F=ln.call(A)),A&&(F==="[object ArrayBuffer]"||A.buffer&&ln.call(A.buffer)==="[object ArrayBuffer]")){var X,J=D;A instanceof ArrayBuffer?(X=A,J+=ot):(X=A.buffer,F==="[object Int8Array]"?J+=rt:F==="[object Uint8Array]"?J+=ht:F==="[object Uint8ClampedArray]"?J+=wt:F==="[object Int16Array]"?J+=ft:F==="[object Uint16Array]"?J+=ge:F==="[object Int32Array]"?J+=Mt:F==="[object Uint32Array]"?J+=oe:F==="[object Float32Array]"?J+=Ke:F==="[object Float64Array]"?J+=sr:V(new Error("Failed to get type for BinaryArray"))),V(J+yn(X))}else if(F==="[object Blob]"){var G=new FileReader;G.onload=function(){var st=Q+A.type+"~"+yn(this.result);V(D+at+st)},G.readAsArrayBuffer(A)}else try{V(JSON.stringify(A))}catch(st){console.error("Couldn't convert value into a JSON string: ",A),V(null,st)}}function Ir(A){if(A.substring(0,q)!==D)return JSON.parse(A);var V=A.substring(cr),F=A.substring(q,cr),X;if(F===at&&L.test(V)){var J=V.match(L);X=J[1],V=V.substring(J[0].length)}var G=Ie(V);switch(F){case ot:return G;case at:return c([G],{type:X});case rt:return new Int8Array(G);case ht:return new Uint8Array(G);case wt:return new Uint8ClampedArray(G);case ft:return new Int16Array(G);case ge:return new Uint16Array(G);case Mt:return new Int32Array(G);case oe:return new Uint32Array(G);case Ke:return new Float32Array(G);case sr:return new Float64Array(G);default:throw new Error("Unkown type: "+F)}}var yi={serialize:gi,deserialize:Ir,stringToBuffer:Ie,bufferToString:yn};function Gi(A,V,F,X){A.executeSql("CREATE TABLE IF NOT EXISTS "+V.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],F,X)}function Vo(A){var V=this,F={db:null};if(A)for(var X in A)F[X]=typeof A[X]!="string"?A[X].toString():A[X];var J=new h(function(G,st){try{F.db=openDatabase(F.name,String(F.version),F.description,F.size)}catch(ut){return st(ut)}F.db.transaction(function(ut){Gi(ut,F,function(){V._dbInfo=F,G()},function(dt,pt){st(pt)})},st)});return F.serializer=yi,J}function kr(A,V,F,X,J,G){A.executeSql(F,X,J,function(st,ut){ut.code===ut.SYNTAX_ERR?st.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[V.storeName],function(dt,pt){pt.rows.length?G(dt,ut):Gi(dt,V,function(){dt.executeSql(F,X,J,G)},G)},G):G(st,ut)},G)}function Wi(A,V){var F=this;A=m(A);var X=new h(function(J,G){F.ready().then(function(){var st=F._dbInfo;st.db.transaction(function(ut){kr(ut,st,"SELECT * FROM "+st.storeName+" WHERE key = ? LIMIT 1",[A],function(dt,pt){var yt=pt.rows.length?pt.rows.item(0).value:null;yt&&(yt=st.serializer.deserialize(yt)),J(yt)},function(dt,pt){G(pt)})})}).catch(G)});return f(X,V),X}function Yn(A,V){var F=this,X=new h(function(J,G){F.ready().then(function(){var st=F._dbInfo;st.db.transaction(function(ut){kr(ut,st,"SELECT * FROM "+st.storeName,[],function(dt,pt){for(var yt=pt.rows,Tt=yt.length,ae=0;ae0){st(zr.apply(J,[A,dt,F,X-1]));return}ut(ae)}})})}).catch(ut)});return f(G,F),G}function Ns(A,V,F){return zr.apply(this,[A,V,F,1])}function sl(A,V){var F=this;A=m(A);var X=new h(function(J,G){F.ready().then(function(){var st=F._dbInfo;st.db.transaction(function(ut){kr(ut,st,"DELETE FROM "+st.storeName+" WHERE key = ?",[A],function(){J()},function(dt,pt){G(pt)})})}).catch(G)});return f(X,V),X}function yc(A){var V=this,F=new h(function(X,J){V.ready().then(function(){var G=V._dbInfo;G.db.transaction(function(st){kr(st,G,"DELETE FROM "+G.storeName,[],function(){X()},function(ut,dt){J(dt)})})}).catch(J)});return f(F,A),F}function jo(A){var V=this,F=new h(function(X,J){V.ready().then(function(){var G=V._dbInfo;G.db.transaction(function(st){kr(st,G,"SELECT COUNT(key) as c FROM "+G.storeName,[],function(ut,dt){var pt=dt.rows.item(0).c;X(pt)},function(ut,dt){J(dt)})})}).catch(J)});return f(F,A),F}function vc(A,V){var F=this,X=new h(function(J,G){F.ready().then(function(){var st=F._dbInfo;st.db.transaction(function(ut){kr(ut,st,"SELECT key FROM "+st.storeName+" WHERE id = ? LIMIT 1",[A+1],function(dt,pt){var yt=pt.rows.length?pt.rows.item(0).key:null;J(yt)},function(dt,pt){G(pt)})})}).catch(G)});return f(X,V),X}function _c(A){var V=this,F=new h(function(X,J){V.ready().then(function(){var G=V._dbInfo;G.db.transaction(function(st){kr(st,G,"SELECT key FROM "+G.storeName,[],function(ut,dt){for(var pt=[],yt=0;yt '__WebKitDatabaseInfoTable__'",[],function(J,G){for(var st=[],ut=0;ut0}function $o(A){var V=this,F={};if(A)for(var X in A)F[X]=A[X];return F.keyPrefix=al(A,V._defaultConfig),Tc()?(V._dbInfo=F,F.serializer=yi,h.resolve()):h.reject()}function ll(A){var V=this,F=V.ready().then(function(){for(var X=V._dbInfo.keyPrefix,J=localStorage.length-1;J>=0;J--){var G=localStorage.key(J);G.indexOf(X)===0&&localStorage.removeItem(G)}});return f(F,A),F}function Ic(A,V){var F=this;A=m(A);var X=F.ready().then(function(){var J=F._dbInfo,G=localStorage.getItem(J.keyPrefix+A);return G&&(G=J.serializer.deserialize(G)),G});return f(X,V),X}function Ec(A,V){var F=this,X=F.ready().then(function(){for(var J=F._dbInfo,G=J.keyPrefix,st=G.length,ut=localStorage.length,dt=1,pt=0;pt=0;st--){var ut=localStorage.key(st);ut.indexOf(G)===0&&localStorage.removeItem(ut)}}):J=h.reject("Invalid arguments"),f(J,V),J}var Oc={_driver:"localStorageWrapper",_initStorage:$o,_support:xc(),iterate:Ec,getItem:Ic,setItem:Cc,removeItem:Mc,clear:ll,length:ul,key:$p,keys:Ac,dropInstance:Bs},Pc=function(V,F){return V===F||typeof V=="number"&&typeof F=="number"&&isNaN(V)&&isNaN(F)},cl=function(V,F){for(var X=V.length,J=0;J"u"?"undefined":s(F))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var X in F){if(X==="storeName"&&(F[X]=F[X].replace(/\W/g,"_")),X==="version"&&typeof F[X]!="number")return new Error("Database version must be a number.");this._config[X]=F[X]}return"driver"in F&&F.driver?this.setDriver(this._config.driver):!0}else return typeof F=="string"?this._config[F]:this._config},A.prototype.defineDriver=function(F,X,J){var G=new h(function(st,ut){try{var dt=F._driver,pt=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!F._driver){ut(pt);return}for(var yt=Rc.concat("_initStorage"),Tt=0,ae=yt.length;Tt 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(r){mM(t,r);function t(e){var n=r.call(this,gM,yM)||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,e),n}return t.prototype.apply=function(e,n,i,s){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,n,i,s)},t})(ie);/*! + * @pixi/filter-kawase-blur - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-kawase-blur is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 sd=function(r,t){return sd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},sd(r,t)};function vM(r,t){sd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var _M=`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; +}`,bM=` +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; +}`,wM=` +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; +} +`,au=function(r){vM(t,r);function t(e,n,i){e===void 0&&(e=4),n===void 0&&(n=3),i===void 0&&(i=!1);var s=r.call(this,_M,i?wM:bM)||this;return s._kernels=[],s._blur=4,s._quality=3,s.uniforms.uOffset=new Float32Array(2),s._pixelSize=new Oe,s.pixelSize=1,s._clamp=i,Array.isArray(e)?s.kernels=e:(s._blur=e,s.quality=n),s}return t.prototype.apply=function(e,n,i,s){var o=this._pixelSize.x/n._frame.width,a=this._pixelSize.y/n._frame.height,l;if(this._quality===1||this._blur===0)l=this._kernels[0]+.5,this.uniforms.uOffset[0]=l*o,this.uniforms.uOffset[1]=l*a,e.applyFilter(this,n,i,s);else{for(var u=e.getFilterTexture(),c=n,h=u,f=void 0,d=this._quality-1,m=0;m0)for(var s=e,o=e/n,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 Oe?(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}(ie);/*! + * @pixi/filter-advanced-bloom - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-advanced-bloom is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 od=function(r,t){return od=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},od(r,t)};function nb(r,t){od(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var ib=`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; +}`,xM=` +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); + } +} +`,SM=function(r){nb(t,r);function t(e){e===void 0&&(e=.5);var n=r.call(this,ib,xM)||this;return n.threshold=e,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}(ie),TM=`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(r){nb(t,r);function t(e){var n=r.call(this,ib,TM)||this;n.bloomScale=1,n.brightness=1,n._resolution=At.FILTER_RESOLUTION,typeof e=="number"&&(e={threshold:e});var i=Object.assign(t.defaults,e);n.bloomScale=i.bloomScale,n.brightness=i.brightness;var s=i.kernels,o=i.blur,a=i.quality,l=i.pixelSize,u=i.resolution;return n._extractFilter=new SM(i.threshold),n._extractFilter.resolution=u,n._blurFilter=s?new au(s):new au(o,a),n.pixelSize=l,n.resolution=u,n}return t.prototype.apply=function(e,n,i,s,o){var a=e.getFilterTexture();this._extractFilter.apply(e,n,a,1,o);var l=e.getFilterTexture();this._blurFilter.apply(e,a,l,1),this.uniforms.bloomScale=this.bloomScale,this.uniforms.brightness=this.brightness,this.uniforms.bloomTexture=l,e.applyFilter(this,n,i,s),e.returnFilterTexture(l),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:At.FILTER_RESOLUTION},t})(ie);/*! + * @pixi/filter-ascii - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-ascii is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 ad=function(r,t){return ad=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},ad(r,t)};function IM(r,t){ad(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var EM=`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; +}`,AM=`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(r){IM(t,r);function t(e){e===void 0&&(e=8);var n=r.call(this,EM,AM)||this;return n.size=e,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})(ie);/*! + * @pixi/filter-bevel - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-bevel is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 ld=function(r,t){return ld=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},ld(r,t)};function MM(r,t){ld(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var CM=`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; +}`,OM=`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(r){MM(t,r);function t(e){var n=r.call(this,CM,OM)||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},e),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/Ts},set:function(e){this._angle=e*Ts,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 fn(this.uniforms.lightColor)},set:function(e){en(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 fn(this.uniforms.shadowColor)},set:function(e){en(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})(ie);/*! + * @pixi/filter-alpha - v6.5.10 + * Compiled Thu, 06 Jul 2023 15:25:11 UTC + * + * @pixi/filter-alpha is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 ud=function(r,t){return ud=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i])},ud(r,t)};function PM(r,t){ud(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var RM=`varying vec2 vTextureCoord; + +uniform sampler2D uSampler; +uniform float uAlpha; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha; +} +`,FM=function(r){PM(t,r);function t(e){e===void 0&&(e=1);var n=r.call(this,EE,RM,{uAlpha:1})||this;return n.alpha=e,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}(ie);/*! + * @pixi/filter-blur - v6.5.10 + * Compiled Thu, 06 Jul 2023 15:25:11 UTC + * + * @pixi/filter-blur is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 cd=function(r,t){return cd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i])},cd(r,t)};function sb(r,t){cd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var DM=` + 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 LM(r,t){var e=Math.ceil(r/2),n=DM,i="",s;t?s="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":s="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(var o=0;o=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),i+=l,i+=` +`}return n=n.replace("%blur%",i),n=n.replace("%size%",r.toString()),n}var lu=function(r){sb(t,r);function t(e,n,i,s,o){n===void 0&&(n=8),i===void 0&&(i=4),s===void 0&&(s=At.FILTER_RESOLUTION),o===void 0&&(o=5);var a=this,l=LM(o,e),u=UM(o);return a=r.call(this,l,u)||this,a.horizontal=e,a.resolution=s,a._quality=0,a.quality=i,a.blur=n,a}return t.prototype.apply=function(e,n,i,s){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/n.width):this.uniforms.strength=1/i.height*(i.height/n.height):this.horizontal?this.uniforms.strength=1/e.renderer.width*(e.renderer.width/n.width):this.uniforms.strength=1/e.renderer.height*(e.renderer.height/n.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)e.applyFilter(this,n,i,s);else{var o=e.getFilterTexture(),a=e.renderer,l=n,u=o;this.state.blend=!1,e.applyFilter(this,l,u,hn.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(r){zM(t,r);function t(e){var n=r.call(this,VM,jM)||this;return n.uniforms.dimensions=new Float32Array(2),Object.assign(n,t.defaults,e),n}return t.prototype.apply=function(e,n,i,s){var o=n.filterFrame,a=o.width,l=o.height;this.uniforms.dimensions[0]=a,this.uniforms.dimensions[1]=l,e.applyFilter(this,n,i,s)},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})(ie);/*! + * @pixi/filter-color-map - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-color-map is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 fd=function(r,t){return fd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},fd(r,t)};function $M(r,t){fd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var GM=`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; +}`,WM=`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(r){$M(t,r);function t(e,n,i){n===void 0&&(n=!1),i===void 0&&(i=1);var s=r.call(this,GM,WM)||this;return s.mix=1,s._size=0,s._sliceSize=0,s._slicePixelSize=0,s._sliceInnerSize=0,s._nearest=!1,s._scaleMode=null,s._colorMap=null,s._scaleMode=null,s.nearest=n,s.mix=i,s.colorMap=e,s}return t.prototype.apply=function(e,n,i,s){this.uniforms._mix=this.mix,e.applyFilter(this,n,i,s)},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 n;e&&(e instanceof ws||(e=ws.from(e)),!((n=e)===null||n===void 0)&&n.baseTexture&&(e.baseTexture.scaleMode=this._scaleMode,e.baseTexture.mipmap=Un.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?Pr.NEAREST:Pr.LINEAR;var n=this._colorMap;n&&n.baseTexture&&(n.baseTexture._glTextures={},n.baseTexture.scaleMode=this._scaleMode,n.baseTexture.mipmap=Un.OFF,n._updateID++,n.baseTexture.emit("update",n.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(e){e===void 0&&(e=!1),this._colorMap&&this._colorMap.destroy(e),r.prototype.destroy.call(this)},t})(ie);/*! + * @pixi/filter-color-overlay - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-color-overlay is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 pd=function(r,t){return pd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},pd(r,t)};function HM(r,t){pd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var XM=`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; +}`,YM=`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(r){HM(t,r);function t(e,n){e===void 0&&(e=0),n===void 0&&(n=1);var i=r.call(this,XM,YM)||this;return i._color=0,i._alpha=1,i.uniforms.color=new Float32Array(3),i.color=e,i.alpha=n,i}return Object.defineProperty(t.prototype,"color",{get:function(){return this._color},set:function(e){var n=this.uniforms.color;typeof e=="number"?(en(e,n),this._color=e):(n[0]=e[0],n[1]=e[1],n[2]=e[2],this._color=fn(n))},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})(ie);/*! + * @pixi/filter-color-replace - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-color-replace is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 md=function(r,t){return md=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},md(r,t)};function qM(r,t){md(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var QM=`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; +}`,ZM=`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(r){qM(t,r);function t(e,n,i){e===void 0&&(e=16711680),n===void 0&&(n=0),i===void 0&&(i=.4);var s=r.call(this,QM,ZM)||this;return s._originalColor=16711680,s._newColor=0,s.uniforms.originalColor=new Float32Array(3),s.uniforms.newColor=new Float32Array(3),s.originalColor=e,s.newColor=n,s.epsilon=i,s}return Object.defineProperty(t.prototype,"originalColor",{get:function(){return this._originalColor},set:function(e){var n=this.uniforms.originalColor;typeof e=="number"?(en(e,n),this._originalColor=e):(n[0]=e[0],n[1]=e[1],n[2]=e[2],this._originalColor=fn(n))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"newColor",{get:function(){return this._newColor},set:function(e){var n=this.uniforms.newColor;typeof e=="number"?(en(e,n),this._newColor=e):(n[0]=e[0],n[1]=e[1],n[2]=e[2],this._newColor=fn(n))},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})(ie);/*! + * @pixi/filter-convolution - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-convolution is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 gd=function(r,t){return gd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},gd(r,t)};function KM(r,t){gd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var JM=`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; +}`,tC=`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(r){KM(t,r);function t(e,n,i){n===void 0&&(n=200),i===void 0&&(i=200);var s=r.call(this,JM,tC)||this;return s.uniforms.texelSize=new Float32Array(2),s.uniforms.matrix=new Float32Array(9),e!==void 0&&(s.matrix=e),s.width=n,s.height=i,s}return Object.defineProperty(t.prototype,"matrix",{get:function(){return this.uniforms.matrix},set:function(e){var n=this;e.forEach(function(i,s){n.uniforms.matrix[s]=i})},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})(ie);/*! + * @pixi/filter-cross-hatch - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-cross-hatch is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 yd=function(r,t){return yd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},yd(r,t)};function eC(r,t){yd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var rC=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,nC=`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(r){eC(t,r);function t(){return r.call(this,rC,nC)||this}return t})(ie);/*! + * @pixi/filter-crt - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-crt is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 vd=function(r,t){return vd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},vd(r,t)};function iC(r,t){vd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var sC=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,oC=`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(r){iC(t,r);function t(e){var n=r.call(this,sC,oC)||this;return n.time=0,n.seed=0,n.uniforms.dimensions=new Float32Array(2),Object.assign(n,t.defaults,e),n}return t.prototype.apply=function(e,n,i,s){var o=n.filterFrame,a=o.width,l=o.height;this.uniforms.dimensions[0]=a,this.uniforms.dimensions[1]=l,this.uniforms.seed=this.seed,this.uniforms.time=this.time,e.applyFilter(this,n,i,s)},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})(ie);/*! + * @pixi/filter-dot - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-dot is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 _d=function(r,t){return _d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},_d(r,t)};function aC(r,t){_d(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var lC=`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; +}`,uC=`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(r){aC(t,r);function t(e,n){e===void 0&&(e=1),n===void 0&&(n=5);var i=r.call(this,lC,uC)||this;return i.scale=e,i.angle=n,i}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})(ie);/*! + * @pixi/filter-drop-shadow - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-drop-shadow is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 bd=function(r,t){return bd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},bd(r,t)};function cC(r,t){bd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var uu=function(){return uu=Object.assign||function(t){for(var e=arguments,n,i=1,s=arguments.length;i 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(r){gC(t,r);function t(e){var n=r.call(this,yC,vC)||this;return n.offset=100,n.fillMode=t.TRANSPARENT,n.average=!1,n.seed=0,n.minSize=8,n.sampleSize=512,n._slices=0,n._offsets=new Float32Array(1),n._sizes=new Float32Array(1),n._direction=-1,n.uniforms.dimensions=new Float32Array(2),n._canvas=document.createElement("canvas"),n._canvas.width=4,n._canvas.height=n.sampleSize,n.texture=ws.from(n._canvas,{scaleMode:Pr.NEAREST}),Object.assign(n,t.defaults,e),n}return t.prototype.apply=function(e,n,i,s){var o=n.filterFrame,a=o.width,l=o.height;this.uniforms.dimensions[0]=a,this.uniforms.dimensions[1]=l,this.uniforms.aspect=l/a,this.uniforms.seed=this.seed,this.uniforms.offset=this.offset,this.uniforms.fillMode=this.fillMode,e.applyFilter(this,n,i,s)},t.prototype._randomizeSizes=function(){var e=this._sizes,n=this._slices-1,i=this.sampleSize,s=Math.min(this.minSize/i,.9/this._slices);if(this.average){for(var o=this._slices,a=1,l=0;l0;i--){var s=Math.random()*i>>0,o=e[i];e[i]=e[s],e[s]=o}},t.prototype._randomizeOffsets=function(){for(var e=0;e0?s:0,c=s<0?-s:0;i.fillStyle="rgba("+u+", "+c+", 0, 1)",i.fillRect(0,o>>0,e,l+1>>0),o+=l}n.baseTexture.update(),this.uniforms.displacementMap=n},Object.defineProperty(t.prototype,"sizes",{get:function(){return this._sizes},set:function(e){for(var n=Math.min(this._slices,e.length),i=0;i>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})(ie);/*! + * @pixi/filter-multi-color-replace - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-multi-color-replace is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 Ed=function(r,t){return Ed=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},Ed(r,t)};function CC(r,t){Ed(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var OC=`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; +}`,PC=`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(r){CC(t,r);function t(e,n,i){n===void 0&&(n=.05),i===void 0&&(i=e.length);var s=r.call(this,OC,PC.replace(/%maxColors%/g,i.toFixed(0)))||this;return s._replacements=[],s._maxColors=0,s.epsilon=n,s._maxColors=i,s.uniforms.originalColors=new Float32Array(i*3),s.uniforms.targetColors=new Float32Array(i*3),s.replacements=e,s}return Object.defineProperty(t.prototype,"replacements",{get:function(){return this._replacements},set:function(e){var n=this.uniforms.originalColors,i=this.uniforms.targetColors,s=e.length;if(s>this._maxColors)throw new Error("Length of replacements ("+s+") exceeds the maximum colors length ("+this._maxColors+")");n[s*3]=-1;for(var o=0;o 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(r){RC(t,r);function t(e,n){n===void 0&&(n=0);var i=r.call(this,FC,DC)||this;return i.seed=0,i.uniforms.dimensions=new Float32Array(2),typeof e=="number"?(i.seed=e,e=void 0):i.seed=n,Object.assign(i,t.defaults,e),i}return t.prototype.apply=function(e,n,i,s){var o,a;this.uniforms.dimensions[0]=(o=n.filterFrame)===null||o===void 0?void 0:o.width,this.uniforms.dimensions[1]=(a=n.filterFrame)===null||a===void 0?void 0:a.height,this.uniforms.seed=this.seed,e.applyFilter(this,n,i,s)},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})(ie);/*! + * @pixi/filter-outline - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-outline is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 Md=function(r,t){return Md=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},Md(r,t)};function LC(r,t){Md(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var NC=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,BC=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; + +uniform 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(r){LC(t,r);function t(e,n,i){e===void 0&&(e=1),n===void 0&&(n=0),i===void 0&&(i=.1);var s=r.call(this,NC,BC.replace(/\$\{angleStep\}/,t.getAngleStep(i)))||this;return s._thickness=1,s.uniforms.thickness=new Float32Array([0,0]),s.uniforms.outlineColor=new Float32Array([0,0,0,1]),Object.assign(s,{thickness:e,color:n,quality:i}),s}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,n,i,s){this.uniforms.thickness[0]=this._thickness/n._frame.width,this.uniforms.thickness[1]=this._thickness/n._frame.height,e.applyFilter(this,n,i,s)},Object.defineProperty(t.prototype,"color",{get:function(){return fn(this.uniforms.outlineColor)},set:function(e){en(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})(ie);/*! + * @pixi/filter-pixelate - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-pixelate is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 Cd=function(r,t){return Cd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},Cd(r,t)};function UC(r,t){Cd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var kC=`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; +}`,zC=`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(r){UC(t,r);function t(e){e===void 0&&(e=10);var n=r.call(this,kC,zC)||this;return n.size=e,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})(ie);/*! + * @pixi/filter-radial-blur - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-radial-blur is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 Od=function(r,t){return Od=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},Od(r,t)};function VC(r,t){Od(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var jC=`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; +}`,$C=`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(r){VC(t,r);function t(e,n,i,s){e===void 0&&(e=0),n===void 0&&(n=[0,0]),i===void 0&&(i=5),s===void 0&&(s=-1);var o=r.call(this,jC,$C)||this;return o._angle=0,o.angle=e,o.center=n,o.kernelSize=i,o.radius=s,o}return t.prototype.apply=function(e,n,i,s){this.uniforms.uKernelSize=this._angle!==0?this.kernelSize:0,e.applyFilter(this,n,i,s)},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})(ie);/*! + * @pixi/filter-reflection - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-reflection is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 Pd=function(r,t){return Pd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},Pd(r,t)};function GC(r,t){Pd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var WC=`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; +}`,HC=`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(r){GC(t,r);function t(e){var n=r.call(this,WC,HC)||this;return n.time=0,n.uniforms.amplitude=new Float32Array(2),n.uniforms.waveLength=new Float32Array(2),n.uniforms.alpha=new Float32Array(2),n.uniforms.dimensions=new Float32Array(2),Object.assign(n,t.defaults,e),n}return t.prototype.apply=function(e,n,i,s){var o,a;this.uniforms.dimensions[0]=(o=n.filterFrame)===null||o===void 0?void 0:o.width,this.uniforms.dimensions[1]=(a=n.filterFrame)===null||a===void 0?void 0:a.height,this.uniforms.time=this.time,e.applyFilter(this,n,i,s)},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})(ie);/*! + * @pixi/filter-rgb-split - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-rgb-split is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 Rd=function(r,t){return Rd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},Rd(r,t)};function XC(r,t){Rd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var YC=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,qC=`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(r){XC(t,r);function t(e,n,i){e===void 0&&(e=[-10,0]),n===void 0&&(n=[0,10]),i===void 0&&(i=[0,0]);var s=r.call(this,YC,qC)||this;return s.red=e,s.green=n,s.blue=i,s}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})(ie);/*! + * @pixi/filter-shockwave - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-shockwave is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 Fd=function(r,t){return Fd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},Fd(r,t)};function QC(r,t){Fd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var ZC=`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; +}`,KC=`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(r){QC(t,r);function t(e,n,i){e===void 0&&(e=[0,0]),i===void 0&&(i=0);var s=r.call(this,ZC,KC)||this;return s.center=e,Object.assign(s,t.defaults,n),s.time=i,s}return t.prototype.apply=function(e,n,i,s){this.uniforms.time=this.time,e.applyFilter(this,n,i,s)},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})(ie);/*! + * @pixi/filter-simple-lightmap - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-simple-lightmap is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 Dd=function(r,t){return Dd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},Dd(r,t)};function JC(r,t){Dd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var tO=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,eO=`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(r){JC(t,r);function t(e,n,i){n===void 0&&(n=0),i===void 0&&(i=1);var s=r.call(this,tO,eO)||this;return s._color=0,s.uniforms.dimensions=new Float32Array(2),s.uniforms.ambientColor=new Float32Array([0,0,0,i]),s.texture=e,s.color=n,s}return t.prototype.apply=function(e,n,i,s){var o,a;this.uniforms.dimensions[0]=(o=n.filterFrame)===null||o===void 0?void 0:o.width,this.uniforms.dimensions[1]=(a=n.filterFrame)===null||a===void 0?void 0:a.height,e.applyFilter(this,n,i,s)},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 n=this.uniforms.ambientColor;typeof e=="number"?(en(e,n),this._color=e):(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],this._color=fn(n))},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})(ie);/*! + * @pixi/filter-tilt-shift - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-tilt-shift is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 Ld=function(r,t){return Ld=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},Ld(r,t)};function sc(r,t){Ld(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var rO=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,nO=`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; +} +`,ob=function(r){sc(t,r);function t(e,n,i,s){e===void 0&&(e=100),n===void 0&&(n=600);var o=r.call(this,rO,nO)||this;return o.uniforms.blur=e,o.uniforms.gradientBlur=n,o.uniforms.start=i||new Oe(0,window.innerHeight/2),o.uniforms.end=s||new Oe(600,window.innerHeight/2),o.uniforms.delta=new Oe(30,30),o.uniforms.texSize=new Oe(window.innerWidth,window.innerHeight),o.updateDelta(),o}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}(ie),iO=function(r){sc(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.updateDelta=function(){var e=this.uniforms.end.x-this.uniforms.start.x,n=this.uniforms.end.y-this.uniforms.start.y,i=Math.sqrt(e*e+n*n);this.uniforms.delta.x=e/i,this.uniforms.delta.y=n/i},t}(ob),sO=function(r){sc(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.updateDelta=function(){var e=this.uniforms.end.x-this.uniforms.start.x,n=this.uniforms.end.y-this.uniforms.start.y,i=Math.sqrt(e*e+n*n);this.uniforms.delta.x=-n/i,this.uniforms.delta.y=e/i},t}(ob);(function(r){sc(t,r);function t(e,n,i,s){e===void 0&&(e=100),n===void 0&&(n=600);var o=r.call(this)||this;return o.tiltShiftXFilter=new iO(e,n,i,s),o.tiltShiftYFilter=new sO(e,n,i,s),o}return t.prototype.apply=function(e,n,i,s){var o=e.getFilterTexture();this.tiltShiftXFilter.apply(e,n,o,1),this.tiltShiftYFilter.apply(e,o,i,s),e.returnFilterTexture(o)},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})(ie);/*! + * @pixi/filter-twist - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-twist is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 Nd=function(r,t){return Nd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},Nd(r,t)};function oO(r,t){Nd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var aO=`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; +}`,lO=`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(r){oO(t,r);function t(e){var n=r.call(this,aO,lO)||this;return Object.assign(n,t.defaults,e),n}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 Oe},t})(ie);/*! + * @pixi/filter-zoom-blur - v4.2.0 + * Compiled Fri, 05 Aug 2022 19:53:35 UTC + * + * @pixi/filter-zoom-blur is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +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 Bd=function(r,t){return Bd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},Bd(r,t)};function uO(r,t){Bd(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function cO(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);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(r){uO(t,r);function t(e){var n=this,i=Object.assign(t.defaults,e),s=i.maxKernelSize,o=cO(i,["maxKernelSize"]);return n=r.call(this,hO,dO.replace("${maxKernelSize}",s.toFixed(1)))||this,Object.assign(n,o),n}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})(ie);const Ud=400,On=[[.075,800],[.11,0],[.125,0],[.14,0],[.125,0],[.05,0],[.04,0],[.03,0],[.02,0],[1,0]];for(let r=1;r(r.Idle="<|EMOTE_NEUTRAL|>",r.Happy="<|EMOTE_HAPPY|>",r.Sad="<|EMOTE_SAD|>",r.Angry="<|EMOTE_ANGRY|>",r.Think="<|EMOTE_THINK|>",r.Surprise="<|EMOTE_SURPRISE|>",r.Awkward="<|EMOTE_AWKWARD|>",r.Question="<|EMOTE_QUESTION|>",r))(ab||{});const r3=Object.values(ab),fO="Happy",pO="Sad",mO="Angry",gO="Awkward",yO="Think",vO="Surprise",_O="Question",bO="Idle",n3={"<|EMOTE_HAPPY|>":fO,"<|EMOTE_SAD|>":pO,"<|EMOTE_ANGRY|>":mO,"<|EMOTE_THINK|>":yO,"<|EMOTE_SURPRISE|>":vO,"<|EMOTE_AWKWARD|>":gO,"<|EMOTE_QUESTION|>":_O,"<|EMOTE_NEUTRAL|>":bO},i3={"<|EMOTE_HAPPY|>":"happy","<|EMOTE_SAD|>":"sad","<|EMOTE_ANGRY|>":"angry","<|EMOTE_THINK|>":void 0,"<|EMOTE_SURPRISE|>":"surprised","<|EMOTE_AWKWARD|>":void 0,"<|EMOTE_QUESTION|>":void 0,"<|EMOTE_NEUTRAL|>":void 0};/*! + * @pixiv/three-vrm v3.3.6 + * VRM file loader for three.js. + * + * Copyright (c) 2019-2025 pixiv Inc. + * @pixiv/three-vrm is distributed under MIT License + * https://github.com/pixiv/three-vrm/blob/release/LICENSE + */var Cl=(r,t,e)=>new Promise((n,i)=>{var s=l=>{try{a(e.next(l))}catch(u){i(u)}},o=l=>{try{a(e.throw(l))}catch(u){i(u)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,o);a((e=e.apply(r,t)).next())}),pe=(r,t,e)=>new Promise((n,i)=>{var s=l=>{try{a(e.next(l))}catch(u){i(u)}},o=l=>{try{a(e.throw(l))}catch(u){i(u)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,o);a((e=e.apply(r,t)).next())}),sg=class extends Ca{constructor(r){super(),this.weight=0,this.isBinary=!1,this.overrideBlink="none",this.overrideLookAt="none",this.overrideMouth="none",this._binds=[],this.name=`VRMExpression_${r}`,this.expressionName=r,this.type="VRMExpression",this.visible=!1}get binds(){return this._binds}get overrideBlinkAmount(){return this.overrideBlink==="block"?0.5?1:0:this.weight}addBind(r){this._binds.push(r)}deleteBind(r){const t=this._binds.indexOf(r);t>=0&&this._binds.splice(t,1)}applyWeight(r){var t;let e=this.outputWeight;e*=(t=r==null?void 0:r.multiplier)!=null?t:1,this.isBinary&&e<1&&(e=0),this._binds.forEach(n=>n.applyWeight(e))}clearAppliedWeight(){this._binds.forEach(r=>r.clearAppliedWeight())}};function lb(r,t,e){var n,i;const s=r.parser.json,o=(n=s.nodes)==null?void 0:n[t];if(o==null)return console.warn(`extractPrimitivesInternal: Attempt to use nodes[${t}] of glTF but the node doesn't exist`),null;const a=o.mesh;if(a==null)return null;const l=(i=s.meshes)==null?void 0:i[a];if(l==null)return console.warn(`extractPrimitivesInternal: Attempt to use meshes[${a}] of glTF but the mesh doesn't exist`),null;const u=l.primitives.length,c=[];return e.traverse(h=>{c.length{const s=lb(r,i,n);s!=null&&e.set(i,s)}),e})}var kd={Aa:"aa",Ih:"ih",Ou:"ou",Ee:"ee",Oh:"oh",Blink:"blink",Happy:"happy",Angry:"angry",Sad:"sad",Relaxed:"relaxed",LookUp:"lookUp",Surprised:"surprised",LookDown:"lookDown",LookLeft:"lookLeft",LookRight:"lookRight",BlinkLeft:"blinkLeft",BlinkRight:"blinkRight",Neutral:"neutral"};function ub(r){return Math.max(Math.min(r,1),0)}var lg=class cb{constructor(){this.blinkExpressionNames=["blink","blinkLeft","blinkRight"],this.lookAtExpressionNames=["lookLeft","lookRight","lookUp","lookDown"],this.mouthExpressionNames=["aa","ee","ih","oh","ou"],this._expressions=[],this._expressionMap={}}get expressions(){return this._expressions.concat()}get expressionMap(){return Object.assign({},this._expressionMap)}get presetExpressionMap(){const t={},e=new Set(Object.values(kd));return Object.entries(this._expressionMap).forEach(([n,i])=>{e.has(n)&&(t[n]=i)}),t}get customExpressionMap(){const t={},e=new Set(Object.values(kd));return Object.entries(this._expressionMap).forEach(([n,i])=>{e.has(n)||(t[n]=i)}),t}copy(t){return this._expressions.concat().forEach(n=>{this.unregisterExpression(n)}),t._expressions.forEach(n=>{this.registerExpression(n)}),this.blinkExpressionNames=t.blinkExpressionNames.concat(),this.lookAtExpressionNames=t.lookAtExpressionNames.concat(),this.mouthExpressionNames=t.mouthExpressionNames.concat(),this}clone(){return new cb().copy(this)}getExpression(t){var e;return(e=this._expressionMap[t])!=null?e:null}registerExpression(t){this._expressions.push(t),this._expressionMap[t.expressionName]=t}unregisterExpression(t){const e=this._expressions.indexOf(t);e===-1&&console.warn("VRMExpressionManager: The specified expressions is not registered"),this._expressions.splice(e,1),delete this._expressionMap[t.expressionName]}getValue(t){var e;const n=this.getExpression(t);return(e=n==null?void 0:n.weight)!=null?e:null}setValue(t,e){const n=this.getExpression(t);n&&(n.weight=ub(e))}resetValues(){this._expressions.forEach(t=>{t.weight=0})}getExpressionTrackName(t){const e=this.getExpression(t);return e?`${e.name}.weight`:null}update(){const t=this._calculateWeightMultipliers();this._expressions.forEach(e=>{e.clearAppliedWeight()}),this._expressions.forEach(e=>{let n=1;const i=e.expressionName;this.blinkExpressionNames.indexOf(i)!==-1&&(n*=t.blink),this.lookAtExpressionNames.indexOf(i)!==-1&&(n*=t.lookAt),this.mouthExpressionNames.indexOf(i)!==-1&&(n*=t.mouth),e.applyWeight({multiplier:n})})}_calculateWeightMultipliers(){let t=1,e=1,n=1;return this._expressions.forEach(i=>{t-=i.overrideBlinkAmount,e-=i.overrideLookAtAmount,n-=i.overrideMouthAmount}),t=Math.max(0,t),e=Math.max(0,e),n=Math.max(0,n),{blink:t,lookAt:e,mouth:n}}},Ko={Color:"color",EmissionColor:"emissionColor",ShadeColor:"shadeColor",RimColor:"rimColor",OutlineColor:"outlineColor"},wO={_Color:Ko.Color,_EmissionColor:Ko.EmissionColor,_ShadeColor:Ko.ShadeColor,_RimColor:Ko.RimColor,_OutlineColor:Ko.OutlineColor},xO=new qr,hb=class db{constructor({material:t,type:e,targetValue:n,targetAlpha:i}){this.material=t,this.type=e,this.targetValue=n,this.targetAlpha=i??1;const s=this._initColorBindState(),o=this._initAlphaBindState();this._state={color:s,alpha:o}}applyWeight(t){const{color:e,alpha:n}=this._state;if(e!=null){const{propertyName:i,deltaValue:s}=e,o=this.material[i];o!=null&&o.add(xO.copy(s).multiplyScalar(t))}if(n!=null){const{propertyName:i,deltaValue:s}=n;this.material[i]!=null&&(this.material[i]+=s*t)}}clearAppliedWeight(){const{color:t,alpha:e}=this._state;if(t!=null){const{propertyName:n,initialValue:i}=t,s=this.material[n];s!=null&&s.copy(i)}if(e!=null){const{propertyName:n,initialValue:i}=e;this.material[n]!=null&&(this.material[n]=i)}}_initColorBindState(){var t,e,n;const{material:i,type:s,targetValue:o}=this,a=this._getPropertyNameMap(),l=(e=(t=a==null?void 0:a[s])==null?void 0:t[0])!=null?e:null;if(l==null)return console.warn(`Tried to add a material color bind to the material ${(n=i.name)!=null?n:"(no name)"}, the type ${s} but the material or the type is not supported.`),null;const c=i[l].clone(),h=new qr(o.r-c.r,o.g-c.g,o.b-c.b);return{propertyName:l,initialValue:c,deltaValue:h}}_initAlphaBindState(){var t,e,n;const{material:i,type:s,targetAlpha:o}=this,a=this._getPropertyNameMap(),l=(e=(t=a==null?void 0:a[s])==null?void 0:t[1])!=null?e:null;if(l==null&&o!==1)return console.warn(`Tried to add a material alpha bind to the material ${(n=i.name)!=null?n:"(no name)"}, the type ${s} but the material or the type does not support alpha.`),null;if(l==null)return null;const u=i[l],c=o-u;return{propertyName:l,initialValue:u,deltaValue:c}}_getPropertyNameMap(){var t,e;return(e=(t=Object.entries(db._propertyNameMapMap).find(([n])=>this.material[n]===!0))==null?void 0:t[1])!=null?e:null}};hb._propertyNameMapMap={isMeshStandardMaterial:{color:["color","opacity"],emissionColor:["emissive",null]},isMeshBasicMaterial:{color:["color","opacity"]},isMToonMaterial:{color:["color","opacity"],emissionColor:["emissive",null],outlineColor:["outlineColorFactor",null],matcapColor:["matcapFactor",null],rimColor:["parametricRimColorFactor",null],shadeColor:["shadeColorFactor",null]}};var ug=hb,cu=class{constructor({primitives:r,index:t,weight:e}){this.primitives=r,this.index=t,this.weight=e}applyWeight(r){this.primitives.forEach(t=>{var e;((e=t.morphTargetInfluences)==null?void 0:e[this.index])!=null&&(t.morphTargetInfluences[this.index]+=this.weight*r)})}clearAppliedWeight(){this.primitives.forEach(r=>{var t;((t=r.morphTargetInfluences)==null?void 0:t[this.index])!=null&&(r.morphTargetInfluences[this.index]=0)})}},cg=new co,fb=class pb{constructor({material:t,scale:e,offset:n}){var i,s;this.material=t,this.scale=e,this.offset=n;const o=(i=Object.entries(pb._propertyNamesMap).find(([a])=>t[a]===!0))==null?void 0:i[1];o==null?(console.warn(`Tried to add a texture transform bind to the material ${(s=t.name)!=null?s:"(no name)"} but the material is not supported.`),this._properties=[]):(this._properties=[],o.forEach(a=>{var l;const u=(l=t[a])==null?void 0:l.clone();if(!u)return null;t[a]=u;const c=u.offset.clone(),h=u.repeat.clone(),f=n.clone().sub(c),d=e.clone().sub(h);this._properties.push({name:a,initialOffset:c,deltaOffset:f,initialScale:h,deltaScale:d})}))}applyWeight(t){this._properties.forEach(e=>{const n=this.material[e.name];n!==void 0&&(n.offset.add(cg.copy(e.deltaOffset).multiplyScalar(t)),n.repeat.add(cg.copy(e.deltaScale).multiplyScalar(t)))})}clearAppliedWeight(){this._properties.forEach(t=>{const e=this.material[t.name];e!==void 0&&(e.offset.copy(t.initialOffset),e.repeat.copy(t.initialScale))})}};fb._propertyNamesMap={isMeshStandardMaterial:["map","emissiveMap","bumpMap","normalMap","displacementMap","roughnessMap","metalnessMap","alphaMap"],isMeshBasicMaterial:["map","specularMap","alphaMap"],isMToonMaterial:["map","normalMap","emissiveMap","shadeMultiplyTexture","rimMultiplyTexture","outlineWidthMultiplyTexture","uvAnimationMaskTexture"]};var hg=fb,SO=new Set(["1.0","1.0-beta"]),mb=class gb{get name(){return"VRMExpressionLoaderPlugin"}constructor(t){this.parser=t}afterRoot(t){return pe(this,null,function*(){t.userData.vrmExpressionManager=yield this._import(t)})}_import(t){return pe(this,null,function*(){const e=yield this._v1Import(t);if(e)return e;const n=yield this._v0Import(t);return n||null})}_v1Import(t){return pe(this,null,function*(){var e,n;const i=this.parser.json;if(!(((e=i.extensionsUsed)==null?void 0:e.indexOf("VRMC_vrm"))!==-1))return null;const o=(n=i.extensions)==null?void 0:n.VRMC_vrm;if(!o)return null;const a=o.specVersion;if(!SO.has(a))return console.warn(`VRMExpressionLoaderPlugin: Unknown VRMC_vrm specVersion "${a}"`),null;const l=o.expressions;if(!l)return null;const u=new Set(Object.values(kd)),c=new Map;l.preset!=null&&Object.entries(l.preset).forEach(([f,d])=>{if(d!=null){if(!u.has(f)){console.warn(`VRMExpressionLoaderPlugin: Unknown preset name "${f}" detected. Ignoring the expression`);return}c.set(f,d)}}),l.custom!=null&&Object.entries(l.custom).forEach(([f,d])=>{if(u.has(f)){console.warn(`VRMExpressionLoaderPlugin: Custom expression cannot have preset name "${f}". Ignoring the expression`);return}c.set(f,d)});const h=new lg;return yield Promise.all(Array.from(c.entries()).map(f=>pe(this,[f],function*([d,m]){var g,p,y,_,S,T,v;const E=new sg(d);if(t.scene.add(E),E.isBinary=(g=m.isBinary)!=null?g:!1,E.overrideBlink=(p=m.overrideBlink)!=null?p:"none",E.overrideLookAt=(y=m.overrideLookAt)!=null?y:"none",E.overrideMouth=(_=m.overrideMouth)!=null?_:"none",(S=m.morphTargetBinds)==null||S.forEach(w=>pe(this,null,function*(){var B;if(w.node===void 0||w.index===void 0)return;const N=yield og(t,w.node),$=w.index;if(!N.every(it=>Array.isArray(it.morphTargetInfluences)&&${const N=B.material;N&&(Array.isArray(N)?w.push(...N):w.push(N))}),(T=m.materialColorBinds)==null||T.forEach(B=>pe(this,null,function*(){w.filter($=>{var it;const I=(it=this.parser.associations.get($))==null?void 0:it.materials;return B.material===I}).forEach($=>{E.addBind(new ug({material:$,type:B.type,targetValue:new qr().fromArray(B.targetValue),targetAlpha:B.targetValue[3]}))})})),(v=m.textureTransformBinds)==null||v.forEach(B=>pe(this,null,function*(){w.filter($=>{var it;const I=(it=this.parser.associations.get($))==null?void 0:it.materials;return B.material===I}).forEach($=>{var it,I;E.addBind(new hg({material:$,offset:new co().fromArray((it=B.offset)!=null?it:[0,0]),scale:new co().fromArray((I=B.scale)!=null?I:[1,1])}))})}))}h.registerExpression(E)}))),h})}_v0Import(t){return pe(this,null,function*(){var e;const n=this.parser.json,i=(e=n.extensions)==null?void 0:e.VRM;if(!i)return null;const s=i.blendShapeMaster;if(!s)return null;const o=new lg,a=s.blendShapeGroups;if(!a)return o;const l=new Set;return yield Promise.all(a.map(u=>pe(this,null,function*(){var c;const h=u.presetName,f=h!=null&&gb.v0v1PresetNameMap[h]||null,d=f??u.name;if(d==null){console.warn("VRMExpressionLoaderPlugin: One of custom expressions has no name. Ignoring the expression");return}if(l.has(d)){console.warn(`VRMExpressionLoaderPlugin: An expression preset ${h} has duplicated entries. Ignoring the expression`);return}l.add(d);const m=new sg(d);t.scene.add(m),m.isBinary=(c=u.isBinary)!=null?c:!1,u.binds&&u.binds.forEach(p=>pe(this,null,function*(){var y;if(p.mesh===void 0||p.index===void 0)return;const _=[];(y=n.nodes)==null||y.forEach((T,v)=>{T.mesh===p.mesh&&_.push(v)});const S=p.index;yield Promise.all(_.map(T=>pe(this,null,function*(){var v;const E=yield og(t,T);if(!E.every(w=>Array.isArray(w.morphTargetInfluences)&&S{if(p.materialName===void 0||p.propertyName===void 0||p.targetValue===void 0)return;const y=[];t.scene.traverse(S=>{if(S.material){const T=S.material;Array.isArray(T)?y.push(...T.filter(v=>(v.name===p.materialName||v.name===p.materialName+" (Outline)")&&y.indexOf(v)===-1)):T.name===p.materialName&&y.indexOf(T)===-1&&y.push(T)}});const _=p.propertyName;y.forEach(S=>{if(_==="_MainTex_ST"){const v=new co(p.targetValue[0],p.targetValue[1]),E=new co(p.targetValue[2],p.targetValue[3]);E.y=1-E.y-v.y,m.addBind(new hg({material:S,scale:v,offset:E}));return}const T=wO[_];if(T){m.addBind(new ug({material:S,type:T,targetValue:new qr().fromArray(p.targetValue),targetAlpha:p.targetValue[3]}));return}console.warn(_+" is not supported")})}),o.registerExpression(m)}))),o})}};mb.v0v1PresetNameMap={a:"aa",e:"ee",i:"ih",o:"oh",u:"ou",blink:"blink",joy:"happy",angry:"angry",sorrow:"sad",fun:"relaxed",lookup:"lookUp",lookdown:"lookDown",lookleft:"lookLeft",lookright:"lookRight",blink_l:"blinkLeft",blink_r:"blinkRight",neutral:"neutral"};var TO=mb,Xf=class qs{constructor(t,e){this._firstPersonOnlyLayer=qs.DEFAULT_FIRSTPERSON_ONLY_LAYER,this._thirdPersonOnlyLayer=qs.DEFAULT_THIRDPERSON_ONLY_LAYER,this._initializedLayers=!1,this.humanoid=t,this.meshAnnotations=e}copy(t){if(this.humanoid!==t.humanoid)throw new Error("VRMFirstPerson: humanoid must be same in order to copy");return this.meshAnnotations=t.meshAnnotations.map(e=>({meshes:e.meshes.concat(),type:e.type})),this}clone(){return new qs(this.humanoid,this.meshAnnotations).copy(this)}get firstPersonOnlyLayer(){return this._firstPersonOnlyLayer}get thirdPersonOnlyLayer(){return this._thirdPersonOnlyLayer}setup({firstPersonOnlyLayer:t=qs.DEFAULT_FIRSTPERSON_ONLY_LAYER,thirdPersonOnlyLayer:e=qs.DEFAULT_THIRDPERSON_ONLY_LAYER}={}){this._initializedLayers||(this._firstPersonOnlyLayer=t,this._thirdPersonOnlyLayer=e,this.meshAnnotations.forEach(n=>{n.meshes.forEach(i=>{n.type==="firstPersonOnly"?(i.layers.set(this._firstPersonOnlyLayer),i.traverse(s=>s.layers.set(this._firstPersonOnlyLayer))):n.type==="thirdPersonOnly"?(i.layers.set(this._thirdPersonOnlyLayer),i.traverse(s=>s.layers.set(this._thirdPersonOnlyLayer))):n.type==="auto"&&this._createHeadlessModel(i)})}),this._initializedLayers=!0)}_excludeTriangles(t,e,n,i){let s=0;if(e!=null&&e.length>0)for(let o=0;o0&&i.includes(h[0])||c[1]>0&&i.includes(h[1])||c[2]>0&&i.includes(h[2])||c[3]>0&&i.includes(h[3]))continue;const f=e[l],d=n[l];if(f[0]>0&&i.includes(d[0])||f[1]>0&&i.includes(d[1])||f[2]>0&&i.includes(d[2])||f[3]>0&&i.includes(d[3]))continue;const m=e[u],g=n[u];m[0]>0&&i.includes(g[0])||m[1]>0&&i.includes(g[1])||m[2]>0&&i.includes(g[2])||m[3]>0&&i.includes(g[3])||(t[s++]=a,t[s++]=l,t[s++]=u)}return s}_createErasedMesh(t,e){const n=new S1(t.geometry.clone(),t.material);n.name=`${t.name}(erase)`,n.frustumCulled=t.frustumCulled,n.layers.set(this._firstPersonOnlyLayer);const i=n.geometry,s=i.getAttribute("skinIndex"),o=s instanceof qp?[]:s.array,a=[];for(let g=0;g{this._isEraseTarget(s)&&n.push(o)}),!n.length){e.layers.enable(this._thirdPersonOnlyLayer),e.layers.enable(this._firstPersonOnlyLayer);return}e.layers.set(this._thirdPersonOnlyLayer);const i=this._createErasedMesh(e,n);t.add(i)}_createHeadlessModel(t){if(t.type==="Group")if(t.layers.set(this._thirdPersonOnlyLayer),this._isEraseTarget(t))t.traverse(e=>e.layers.set(this._thirdPersonOnlyLayer));else{const e=new No;e.name=`_headless_${t.name}`,e.layers.set(this._firstPersonOnlyLayer),t.parent.add(e),t.children.filter(n=>n.type==="SkinnedMesh").forEach(n=>{const i=n;this._createHeadlessModelForSkinnedMesh(e,i)})}else if(t.type==="SkinnedMesh"){const e=t;this._createHeadlessModelForSkinnedMesh(t.parent,e)}else this._isEraseTarget(t)&&(t.layers.set(this._thirdPersonOnlyLayer),t.traverse(e=>e.layers.set(this._thirdPersonOnlyLayer)))}_isEraseTarget(t){return t===this.humanoid.getRawBoneNode("head")?!0:t.parent?this._isEraseTarget(t.parent):!1}};Xf.DEFAULT_FIRSTPERSON_ONLY_LAYER=9;Xf.DEFAULT_THIRDPERSON_ONLY_LAYER=10;var dg=Xf,IO=new Set(["1.0","1.0-beta"]),EO=class{get name(){return"VRMFirstPersonLoaderPlugin"}constructor(r){this.parser=r}afterRoot(r){return pe(this,null,function*(){const t=r.userData.vrmHumanoid;if(t!==null){if(t===void 0)throw new Error("VRMFirstPersonLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first");r.userData.vrmFirstPerson=yield this._import(r,t)}})}_import(r,t){return pe(this,null,function*(){if(t==null)return null;const e=yield this._v1Import(r,t);if(e)return e;const n=yield this._v0Import(r,t);return n||null})}_v1Import(r,t){return pe(this,null,function*(){var e,n;const i=this.parser.json;if(!(((e=i.extensionsUsed)==null?void 0:e.indexOf("VRMC_vrm"))!==-1))return null;const o=(n=i.extensions)==null?void 0:n.VRMC_vrm;if(!o)return null;const a=o.specVersion;if(!IO.has(a))return console.warn(`VRMFirstPersonLoaderPlugin: Unknown VRMC_vrm specVersion "${a}"`),null;const l=o.firstPerson,u=[],c=yield ag(r);return Array.from(c.entries()).forEach(([h,f])=>{var d,m;const g=(d=l==null?void 0:l.meshAnnotations)==null?void 0:d.find(p=>p.node===h);u.push({meshes:f,type:(m=g==null?void 0:g.type)!=null?m:"auto"})}),new dg(t,u)})}_v0Import(r,t){return pe(this,null,function*(){var e;const n=this.parser.json,i=(e=n.extensions)==null?void 0:e.VRM;if(!i)return null;const s=i.firstPerson;if(!s)return null;const o=[],a=yield ag(r);return Array.from(a.entries()).forEach(([l,u])=>{const c=n.nodes[l],h=s.meshAnnotations?s.meshAnnotations.find(f=>f.mesh===c.mesh):void 0;o.push({meshes:u,type:this._convertV0FlagToV1Type(h==null?void 0:h.firstPersonFlag)})}),new dg(t,o)})}_convertV0FlagToV1Type(r){return r==="FirstPersonOnly"?"firstPersonOnly":r==="ThirdPersonOnly"?"thirdPersonOnly":r==="Both"?"both":"auto"}},fg=new mt,pg=new mt,AO=new ne,mg=class extends No{constructor(r){super(),this.vrmHumanoid=r,this._boneAxesMap=new Map,Object.values(r.humanBones).forEach(t=>{const e=new T1(1);e.matrixAutoUpdate=!1,e.material.depthTest=!1,e.material.depthWrite=!1,this.add(e),this._boneAxesMap.set(t,e)})}dispose(){Array.from(this._boneAxesMap.values()).forEach(r=>{r.geometry.dispose(),r.material.dispose()})}updateMatrixWorld(r){Array.from(this._boneAxesMap.entries()).forEach(([t,e])=>{t.node.updateWorldMatrix(!0,!1),t.node.matrixWorld.decompose(fg,AO,pg);const n=fg.set(.1,.1,.1).divide(pg);e.matrix.copy(t.node.matrixWorld).scale(n)}),super.updateMatrixWorld(r)}},ch=["hips","spine","chest","upperChest","neck","head","leftEye","rightEye","jaw","leftUpperLeg","leftLowerLeg","leftFoot","leftToes","rightUpperLeg","rightLowerLeg","rightFoot","rightToes","leftShoulder","leftUpperArm","leftLowerArm","leftHand","rightShoulder","rightUpperArm","rightLowerArm","rightHand","leftThumbMetacarpal","leftThumbProximal","leftThumbDistal","leftIndexProximal","leftIndexIntermediate","leftIndexDistal","leftMiddleProximal","leftMiddleIntermediate","leftMiddleDistal","leftRingProximal","leftRingIntermediate","leftRingDistal","leftLittleProximal","leftLittleIntermediate","leftLittleDistal","rightThumbMetacarpal","rightThumbProximal","rightThumbDistal","rightIndexProximal","rightIndexIntermediate","rightIndexDistal","rightMiddleProximal","rightMiddleIntermediate","rightMiddleDistal","rightRingProximal","rightRingIntermediate","rightRingDistal","rightLittleProximal","rightLittleIntermediate","rightLittleDistal"],MO={hips:null,spine:"hips",chest:"spine",upperChest:"chest",neck:"upperChest",head:"neck",leftEye:"head",rightEye:"head",jaw:"head",leftUpperLeg:"hips",leftLowerLeg:"leftUpperLeg",leftFoot:"leftLowerLeg",leftToes:"leftFoot",rightUpperLeg:"hips",rightLowerLeg:"rightUpperLeg",rightFoot:"rightLowerLeg",rightToes:"rightFoot",leftShoulder:"upperChest",leftUpperArm:"leftShoulder",leftLowerArm:"leftUpperArm",leftHand:"leftLowerArm",rightShoulder:"upperChest",rightUpperArm:"rightShoulder",rightLowerArm:"rightUpperArm",rightHand:"rightLowerArm",leftThumbMetacarpal:"leftHand",leftThumbProximal:"leftThumbMetacarpal",leftThumbDistal:"leftThumbProximal",leftIndexProximal:"leftHand",leftIndexIntermediate:"leftIndexProximal",leftIndexDistal:"leftIndexIntermediate",leftMiddleProximal:"leftHand",leftMiddleIntermediate:"leftMiddleProximal",leftMiddleDistal:"leftMiddleIntermediate",leftRingProximal:"leftHand",leftRingIntermediate:"leftRingProximal",leftRingDistal:"leftRingIntermediate",leftLittleProximal:"leftHand",leftLittleIntermediate:"leftLittleProximal",leftLittleDistal:"leftLittleIntermediate",rightThumbMetacarpal:"rightHand",rightThumbProximal:"rightThumbMetacarpal",rightThumbDistal:"rightThumbProximal",rightIndexProximal:"rightHand",rightIndexIntermediate:"rightIndexProximal",rightIndexDistal:"rightIndexIntermediate",rightMiddleProximal:"rightHand",rightMiddleIntermediate:"rightMiddleProximal",rightMiddleDistal:"rightMiddleIntermediate",rightRingProximal:"rightHand",rightRingIntermediate:"rightRingProximal",rightRingDistal:"rightRingIntermediate",rightLittleProximal:"rightHand",rightLittleIntermediate:"rightLittleProximal",rightLittleDistal:"rightLittleIntermediate"};function yb(r){return r.invert?r.invert():r.inverse(),r}var Zi=new mt,Ki=new ne,zd=class{constructor(r){this.humanBones=r,this.restPose=this.getAbsolutePose()}getAbsolutePose(){const r={};return Object.keys(this.humanBones).forEach(t=>{const e=t,n=this.getBoneNode(e);n&&(Zi.copy(n.position),Ki.copy(n.quaternion),r[e]={position:Zi.toArray(),rotation:Ki.toArray()})}),r}getPose(){const r={};return Object.keys(this.humanBones).forEach(t=>{const e=t,n=this.getBoneNode(e);if(!n)return;Zi.set(0,0,0),Ki.identity();const i=this.restPose[e];i!=null&&i.position&&Zi.fromArray(i.position).negate(),i!=null&&i.rotation&&yb(Ki.fromArray(i.rotation)),Zi.add(n.position),Ki.premultiply(n.quaternion),r[e]={position:Zi.toArray(),rotation:Ki.toArray()}}),r}setPose(r){Object.entries(r).forEach(([t,e])=>{const n=t,i=this.getBoneNode(n);if(!i)return;const s=this.restPose[n];s&&(e!=null&&e.position&&(i.position.fromArray(e.position),s.position&&i.position.add(Zi.fromArray(s.position))),e!=null&&e.rotation&&(i.quaternion.fromArray(e.rotation),s.rotation&&i.quaternion.multiply(Ki.fromArray(s.rotation))))})}resetPose(){Object.entries(this.restPose).forEach(([r,t])=>{const e=this.getBoneNode(r);e&&(t!=null&&t.position&&e.position.fromArray(t.position),t!=null&&t.rotation&&e.quaternion.fromArray(t.rotation))})}getBone(r){var t;return(t=this.humanBones[r])!=null?t:void 0}getBoneNode(r){var t,e;return(e=(t=this.humanBones[r])==null?void 0:t.node)!=null?e:null}},hh=new mt,CO=new ne,OO=new mt,gg=class vb extends zd{static _setupTransforms(t){const e=new Ca;e.name="VRMHumanoidRig";const n={},i={},s={};ch.forEach(a=>{var l;const u=t.getBoneNode(a);if(u){const c=new mt,h=new ne;u.updateWorldMatrix(!0,!1),u.matrixWorld.decompose(c,h,hh),n[a]=c,i[a]=u.quaternion.clone();const f=new ne;(l=u.parent)==null||l.matrixWorld.decompose(hh,f,hh),s[a]=f}});const o={};return ch.forEach(a=>{var l;const u=t.getBoneNode(a);if(u){const c=n[a];let h=a,f;for(;f==null&&(h=MO[h],h!=null);)f=n[h];const d=new Ca;d.name="Normalized_"+u.name,(h?(l=o[h])==null?void 0:l.node:e).add(d),d.position.copy(c),f&&d.position.sub(f),o[a]={node:d}}}),{rigBones:o,root:e,parentWorldRotations:s,boneRotations:i}}constructor(t){const{rigBones:e,root:n,parentWorldRotations:i,boneRotations:s}=vb._setupTransforms(t);super(e),this.original=t,this.root=n,this._parentWorldRotations=i,this._boneRotations=s}update(){ch.forEach(t=>{const e=this.original.getBoneNode(t);if(e!=null){const n=this.getBoneNode(t),i=this._parentWorldRotations[t],s=CO.copy(i).invert(),o=this._boneRotations[t];if(e.quaternion.copy(n.quaternion).multiply(i).premultiply(s).multiply(o),t==="hips"){const a=n.getWorldPosition(OO);e.parent.updateWorldMatrix(!0,!1);const l=e.parent.matrixWorld,u=a.applyMatrix4(l.invert());e.position.copy(u)}}})}},yg=class _b{get restPose(){return console.warn("VRMHumanoid: restPose is deprecated. Use either rawRestPose or normalizedRestPose instead."),this.rawRestPose}get rawRestPose(){return this._rawHumanBones.restPose}get normalizedRestPose(){return this._normalizedHumanBones.restPose}get humanBones(){return this._rawHumanBones.humanBones}get rawHumanBones(){return this._rawHumanBones.humanBones}get normalizedHumanBones(){return this._normalizedHumanBones.humanBones}get normalizedHumanBonesRoot(){return this._normalizedHumanBones.root}constructor(t,e){var n;this.autoUpdateHumanBones=(n=e==null?void 0:e.autoUpdateHumanBones)!=null?n:!0,this._rawHumanBones=new zd(t),this._normalizedHumanBones=new gg(this._rawHumanBones)}copy(t){return this.autoUpdateHumanBones=t.autoUpdateHumanBones,this._rawHumanBones=new zd(t.humanBones),this._normalizedHumanBones=new gg(this._rawHumanBones),this}clone(){return new _b(this.humanBones,{autoUpdateHumanBones:this.autoUpdateHumanBones}).copy(this)}getAbsolutePose(){return console.warn("VRMHumanoid: getAbsolutePose() is deprecated. Use either getRawAbsolutePose() or getNormalizedAbsolutePose() instead."),this.getRawAbsolutePose()}getRawAbsolutePose(){return this._rawHumanBones.getAbsolutePose()}getNormalizedAbsolutePose(){return this._normalizedHumanBones.getAbsolutePose()}getPose(){return console.warn("VRMHumanoid: getPose() is deprecated. Use either getRawPose() or getNormalizedPose() instead."),this.getRawPose()}getRawPose(){return this._rawHumanBones.getPose()}getNormalizedPose(){return this._normalizedHumanBones.getPose()}setPose(t){return console.warn("VRMHumanoid: setPose() is deprecated. Use either setRawPose() or setNormalizedPose() instead."),this.setRawPose(t)}setRawPose(t){return this._rawHumanBones.setPose(t)}setNormalizedPose(t){return this._normalizedHumanBones.setPose(t)}resetPose(){return console.warn("VRMHumanoid: resetPose() is deprecated. Use either resetRawPose() or resetNormalizedPose() instead."),this.resetRawPose()}resetRawPose(){return this._rawHumanBones.resetPose()}resetNormalizedPose(){return this._normalizedHumanBones.resetPose()}getBone(t){return console.warn("VRMHumanoid: getBone() is deprecated. Use either getRawBone() or getNormalizedBone() instead."),this.getRawBone(t)}getRawBone(t){return this._rawHumanBones.getBone(t)}getNormalizedBone(t){return this._normalizedHumanBones.getBone(t)}getBoneNode(t){return console.warn("VRMHumanoid: getBoneNode() is deprecated. Use either getRawBoneNode() or getNormalizedBoneNode() instead."),this.getRawBoneNode(t)}getRawBoneNode(t){return this._rawHumanBones.getBoneNode(t)}getNormalizedBoneNode(t){return this._normalizedHumanBones.getBoneNode(t)}update(){this.autoUpdateHumanBones&&this._normalizedHumanBones.update()}},PO={Hips:"hips",Spine:"spine",Head:"head",LeftUpperLeg:"leftUpperLeg",LeftLowerLeg:"leftLowerLeg",LeftFoot:"leftFoot",RightUpperLeg:"rightUpperLeg",RightLowerLeg:"rightLowerLeg",RightFoot:"rightFoot",LeftUpperArm:"leftUpperArm",LeftLowerArm:"leftLowerArm",LeftHand:"leftHand",RightUpperArm:"rightUpperArm",RightLowerArm:"rightLowerArm",RightHand:"rightHand"},RO=new Set(["1.0","1.0-beta"]),vg={leftThumbProximal:"leftThumbMetacarpal",leftThumbIntermediate:"leftThumbProximal",rightThumbProximal:"rightThumbMetacarpal",rightThumbIntermediate:"rightThumbProximal"},FO=class{get name(){return"VRMHumanoidLoaderPlugin"}constructor(r,t){this.parser=r,this.helperRoot=t==null?void 0:t.helperRoot,this.autoUpdateHumanBones=t==null?void 0:t.autoUpdateHumanBones}afterRoot(r){return pe(this,null,function*(){r.userData.vrmHumanoid=yield this._import(r)})}_import(r){return pe(this,null,function*(){const t=yield this._v1Import(r);if(t)return t;const e=yield this._v0Import(r);return e||null})}_v1Import(r){return pe(this,null,function*(){var t,e;const n=this.parser.json;if(!(((t=n.extensionsUsed)==null?void 0:t.indexOf("VRMC_vrm"))!==-1))return null;const s=(e=n.extensions)==null?void 0:e.VRMC_vrm;if(!s)return null;const o=s.specVersion;if(!RO.has(o))return console.warn(`VRMHumanoidLoaderPlugin: Unknown VRMC_vrm specVersion "${o}"`),null;const a=s.humanoid;if(!a)return null;const l=a.humanBones.leftThumbIntermediate!=null||a.humanBones.rightThumbIntermediate!=null,u={};a.humanBones!=null&&(yield Promise.all(Object.entries(a.humanBones).map(h=>pe(this,[h],function*([f,d]){let m=f;const g=d.node;if(l){const y=vg[m];y!=null&&(m=y)}const p=yield this.parser.getDependency("node",g);if(p==null){console.warn(`A glTF node bound to the humanoid bone ${m} (index = ${g}) does not exist`);return}u[m]={node:p}}))));const c=new yg(this._ensureRequiredBonesExist(u),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(r.scene.add(c.normalizedHumanBonesRoot),this.helperRoot){const h=new mg(c);this.helperRoot.add(h),h.renderOrder=this.helperRoot.renderOrder}return c})}_v0Import(r){return pe(this,null,function*(){var t;const n=(t=this.parser.json.extensions)==null?void 0:t.VRM;if(!n)return null;const i=n.humanoid;if(!i)return null;const s={};i.humanBones!=null&&(yield Promise.all(i.humanBones.map(a=>pe(this,null,function*(){const l=a.bone,u=a.node;if(l==null||u==null)return;const c=yield this.parser.getDependency("node",u);if(c==null){console.warn(`A glTF node bound to the humanoid bone ${l} (index = ${u}) does not exist`);return}const h=vg[l],f=h??l;if(s[f]!=null){console.warn(`Multiple bone entries for ${f} detected (index = ${u}), ignoring duplicated entries.`);return}s[f]={node:c}}))));const o=new yg(this._ensureRequiredBonesExist(s),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(r.scene.add(o.normalizedHumanBonesRoot),this.helperRoot){const a=new mg(o);this.helperRoot.add(a),a.renderOrder=this.helperRoot.renderOrder}return o})}_ensureRequiredBonesExist(r){const t=Object.values(PO).filter(e=>r[e]==null);if(t.length>0)throw new Error(`VRMHumanoidLoaderPlugin: These humanoid bones are required but not exist: ${t.join(", ")}`);return r}},_g=class extends Ui{constructor(){super(),this._currentTheta=0,this._currentRadius=0,this.theta=0,this.radius=0,this._currentTheta=0,this._currentRadius=0,this._attrPos=new nr(new Float32Array(65*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new nr(new Uint16Array(3*63),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let r=!1;this._currentTheta!==this.theta&&(this._currentTheta=this.theta,r=!0),this._currentRadius!==this.radius&&(this._currentRadius=this.radius,r=!0),r&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,0,0,0);for(let r=0;r<64;r++){const t=r/63*this._currentTheta;this._attrPos.setXYZ(r+1,this._currentRadius*Math.sin(t),0,this._currentRadius*Math.cos(t))}this._attrPos.needsUpdate=!0}_buildIndex(){for(let r=0;r<63;r++)this._attrIndex.setXYZ(r*3,0,r+1,r+2);this._attrIndex.needsUpdate=!0}},DO=class extends Ui{constructor(){super(),this.radius=0,this._currentRadius=0,this.tail=new mt,this._currentTail=new mt,this._attrPos=new nr(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new nr(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let r=!1;this._currentRadius!==this.radius&&(this._currentRadius=this.radius,r=!0),this._currentTail.equals(this.tail)||(this._currentTail.copy(this.tail),r=!0),r&&this._buildPosition()}_buildPosition(){for(let r=0;r<32;r++){const t=r/16*Math.PI;this._attrPos.setXYZ(r,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+r,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+r,Math.sin(t),0,Math.cos(t))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let r=0;r<32;r++){const t=(r+1)%32;this._attrIndex.setXY(r*2,r,t),this._attrIndex.setXY(64+r*2,32+r,32+t),this._attrIndex.setXY(128+r*2,64+r,64+t)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}},Ol=new ne,bg=new ne,Jo=new mt,wg=new mt,xg=Math.sqrt(2)/2,LO=new ne(0,0,-xg,xg),NO=new mt(0,1,0),BO=class extends No{constructor(r){super(),this.matrixAutoUpdate=!1,this.vrmLookAt=r;{const t=new _g;t.radius=.5;const e=new Hp({color:65280,transparent:!0,opacity:.5,side:Xp,depthTest:!1,depthWrite:!1});this._meshPitch=new Yp(t,e),this.add(this._meshPitch)}{const t=new _g;t.radius=.5;const e=new Hp({color:16711680,transparent:!0,opacity:.5,side:Xp,depthTest:!1,depthWrite:!1});this._meshYaw=new Yp(t,e),this.add(this._meshYaw)}{const t=new DO;t.radius=.1;const e=new ec({color:16777215,depthTest:!1,depthWrite:!1});this._lineTarget=new Ef(t,e),this._lineTarget.frustumCulled=!1,this.add(this._lineTarget)}}dispose(){this._meshYaw.geometry.dispose(),this._meshYaw.material.dispose(),this._meshPitch.geometry.dispose(),this._meshPitch.material.dispose(),this._lineTarget.geometry.dispose(),this._lineTarget.material.dispose()}updateMatrixWorld(r){const t=Fe.DEG2RAD*this.vrmLookAt.yaw;this._meshYaw.geometry.theta=t,this._meshYaw.geometry.update();const e=Fe.DEG2RAD*this.vrmLookAt.pitch;this._meshPitch.geometry.theta=e,this._meshPitch.geometry.update(),this.vrmLookAt.getLookAtWorldPosition(Jo),this.vrmLookAt.getLookAtWorldQuaternion(Ol),Ol.multiply(this.vrmLookAt.getFaceFrontQuaternion(bg)),this._meshYaw.position.copy(Jo),this._meshYaw.quaternion.copy(Ol),this._meshPitch.position.copy(Jo),this._meshPitch.quaternion.copy(Ol),this._meshPitch.quaternion.multiply(bg.setFromAxisAngle(NO,t)),this._meshPitch.quaternion.multiply(LO);const{target:n,autoUpdate:i}=this.vrmLookAt;n!=null&&i&&(n.getWorldPosition(wg).sub(Jo),this._lineTarget.geometry.tail.copy(wg),this._lineTarget.geometry.update(),this._lineTarget.position.copy(Jo)),super.updateMatrixWorld(r)}},UO=new mt,kO=new mt;function Vd(r,t){return r.matrixWorld.decompose(UO,t,kO),t}function Ul(r){return[Math.atan2(-r.z,r.x),Math.atan2(r.y,Math.sqrt(r.x*r.x+r.z*r.z))]}function Sg(r){const t=Math.round(r/2/Math.PI);return r-2*Math.PI*t}var Tg=new mt(0,0,1),zO=new mt,VO=new mt,jO=new mt,$O=new ne,dh=new ne,Ig=new ne,GO=new ne,fh=new Ps,bb=class wb{constructor(t,e){this.offsetFromHeadBone=new mt,this.autoUpdate=!0,this.faceFront=new mt(0,0,1),this.humanoid=t,this.applier=e,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new ne)}get yaw(){return this._yaw}set yaw(t){this._yaw=t,this._needsUpdate=!0}get pitch(){return this._pitch}set pitch(t){this._pitch=t,this._needsUpdate=!0}get euler(){return console.warn("VRMLookAt: euler is deprecated. use getEuler() instead."),this.getEuler(new Ps)}getEuler(t){return t.set(Fe.DEG2RAD*this._pitch,Fe.DEG2RAD*this._yaw,0,"YXZ")}copy(t){if(this.humanoid!==t.humanoid)throw new Error("VRMLookAt: humanoid must be same in order to copy");return this.offsetFromHeadBone.copy(t.offsetFromHeadBone),this.applier=t.applier,this.autoUpdate=t.autoUpdate,this.target=t.target,this.faceFront.copy(t.faceFront),this}clone(){return new wb(this.humanoid,this.applier).copy(this)}reset(){this._yaw=0,this._pitch=0,this._needsUpdate=!0}getLookAtWorldPosition(t){const e=this.humanoid.getRawBoneNode("head");return t.copy(this.offsetFromHeadBone).applyMatrix4(e.matrixWorld)}getLookAtWorldQuaternion(t){const e=this.humanoid.getRawBoneNode("head");return Vd(e,t)}getFaceFrontQuaternion(t){if(this.faceFront.distanceToSquared(Tg)<.01)return t.copy(this._restHeadWorldQuaternion).invert();const[e,n]=Ul(this.faceFront);return fh.set(0,.5*Math.PI+e,n,"YZX"),t.setFromEuler(fh).premultiply(GO.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(t){return this.getLookAtWorldQuaternion(dh),this.getFaceFrontQuaternion(Ig),t.copy(Tg).applyQuaternion(dh).applyQuaternion(Ig).applyEuler(this.getEuler(fh))}lookAt(t){const e=$O.copy(this._restHeadWorldQuaternion).multiply(yb(this.getLookAtWorldQuaternion(dh))),n=this.getLookAtWorldPosition(VO),i=jO.copy(t).sub(n).applyQuaternion(e).normalize(),[s,o]=Ul(this.faceFront),[a,l]=Ul(i),u=Sg(a-s),c=Sg(o-l);this._yaw=Fe.RAD2DEG*u,this._pitch=Fe.RAD2DEG*c,this._needsUpdate=!0}update(t){this.target!=null&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(zO)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};bb.EULER_ORDER="YXZ";var WO=bb,HO=new mt(0,0,1),_n=new ne,js=new ne,$r=new Ps(0,0,0,"YXZ"),kl=class{constructor(r,t,e,n,i){this.humanoid=r,this.rangeMapHorizontalInner=t,this.rangeMapHorizontalOuter=e,this.rangeMapVerticalDown=n,this.rangeMapVerticalUp=i,this.faceFront=new mt(0,0,1),this._restQuatLeftEye=new ne,this._restQuatRightEye=new ne,this._restLeftEyeParentWorldQuat=new ne,this._restRightEyeParentWorldQuat=new ne;const s=this.humanoid.getRawBoneNode("leftEye"),o=this.humanoid.getRawBoneNode("rightEye");s&&(this._restQuatLeftEye.copy(s.quaternion),Vd(s.parent,this._restLeftEyeParentWorldQuat)),o&&(this._restQuatRightEye.copy(o.quaternion),Vd(o.parent,this._restRightEyeParentWorldQuat))}applyYawPitch(r,t){const e=this.humanoid.getRawBoneNode("leftEye"),n=this.humanoid.getRawBoneNode("rightEye"),i=this.humanoid.getNormalizedBoneNode("leftEye"),s=this.humanoid.getNormalizedBoneNode("rightEye");e&&(t<0?$r.x=-Fe.DEG2RAD*this.rangeMapVerticalDown.map(-t):$r.x=Fe.DEG2RAD*this.rangeMapVerticalUp.map(t),r<0?$r.y=-Fe.DEG2RAD*this.rangeMapHorizontalInner.map(-r):$r.y=Fe.DEG2RAD*this.rangeMapHorizontalOuter.map(r),_n.setFromEuler($r),this._getWorldFaceFrontQuat(js),i.quaternion.copy(js).multiply(_n).multiply(js.invert()),_n.copy(this._restLeftEyeParentWorldQuat),e.quaternion.copy(i.quaternion).multiply(_n).premultiply(_n.invert()).multiply(this._restQuatLeftEye)),n&&(t<0?$r.x=-Fe.DEG2RAD*this.rangeMapVerticalDown.map(-t):$r.x=Fe.DEG2RAD*this.rangeMapVerticalUp.map(t),r<0?$r.y=-Fe.DEG2RAD*this.rangeMapHorizontalOuter.map(-r):$r.y=Fe.DEG2RAD*this.rangeMapHorizontalInner.map(r),_n.setFromEuler($r),this._getWorldFaceFrontQuat(js),s.quaternion.copy(js).multiply(_n).multiply(js.invert()),_n.copy(this._restRightEyeParentWorldQuat),n.quaternion.copy(s.quaternion).multiply(_n).premultiply(_n.invert()).multiply(this._restQuatRightEye))}lookAt(r){console.warn("VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.");const t=Fe.RAD2DEG*r.y,e=Fe.RAD2DEG*r.x;this.applyYawPitch(t,e)}_getWorldFaceFrontQuat(r){if(this.faceFront.distanceToSquared(HO)<.01)return r.identity();const[t,e]=Ul(this.faceFront);return $r.set(0,.5*Math.PI+t,e,"YZX"),r.setFromEuler($r)}};kl.type="bone";var jd=class{constructor(r,t,e,n,i){this.expressions=r,this.rangeMapHorizontalInner=t,this.rangeMapHorizontalOuter=e,this.rangeMapVerticalDown=n,this.rangeMapVerticalUp=i}applyYawPitch(r,t){t<0?(this.expressions.setValue("lookDown",0),this.expressions.setValue("lookUp",this.rangeMapVerticalUp.map(-t))):(this.expressions.setValue("lookUp",0),this.expressions.setValue("lookDown",this.rangeMapVerticalDown.map(t))),r<0?(this.expressions.setValue("lookLeft",0),this.expressions.setValue("lookRight",this.rangeMapHorizontalOuter.map(-r))):(this.expressions.setValue("lookRight",0),this.expressions.setValue("lookLeft",this.rangeMapHorizontalOuter.map(r)))}lookAt(r){console.warn("VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.");const t=Fe.RAD2DEG*r.y,e=Fe.RAD2DEG*r.x;this.applyYawPitch(t,e)}};jd.type="expression";var Eg=class{constructor(r,t){this.inputMaxValue=r,this.outputScale=t}map(r){return this.outputScale*ub(r/this.inputMaxValue)}},XO=new Set(["1.0","1.0-beta"]),Pl=.01,YO=class{get name(){return"VRMLookAtLoaderPlugin"}constructor(r,t){this.parser=r,this.helperRoot=t==null?void 0:t.helperRoot}afterRoot(r){return pe(this,null,function*(){const t=r.userData.vrmHumanoid;if(t===null)return;if(t===void 0)throw new Error("VRMLookAtLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first");const e=r.userData.vrmExpressionManager;if(e!==null){if(e===void 0)throw new Error("VRMLookAtLoaderPlugin: vrmExpressionManager is undefined. VRMExpressionLoaderPlugin have to be used first");r.userData.vrmLookAt=yield this._import(r,t,e)}})}_import(r,t,e){return pe(this,null,function*(){if(t==null||e==null)return null;const n=yield this._v1Import(r,t,e);if(n)return n;const i=yield this._v0Import(r,t,e);return i||null})}_v1Import(r,t,e){return pe(this,null,function*(){var n,i,s;const o=this.parser.json;if(!(((n=o.extensionsUsed)==null?void 0:n.indexOf("VRMC_vrm"))!==-1))return null;const l=(i=o.extensions)==null?void 0:i.VRMC_vrm;if(!l)return null;const u=l.specVersion;if(!XO.has(u))return console.warn(`VRMLookAtLoaderPlugin: Unknown VRMC_vrm specVersion "${u}"`),null;const c=l.lookAt;if(!c)return null;const h=c.type==="expression"?1:10,f=this._v1ImportRangeMap(c.rangeMapHorizontalInner,h),d=this._v1ImportRangeMap(c.rangeMapHorizontalOuter,h),m=this._v1ImportRangeMap(c.rangeMapVerticalDown,h),g=this._v1ImportRangeMap(c.rangeMapVerticalUp,h);let p;c.type==="expression"?p=new jd(e,f,d,m,g):p=new kl(t,f,d,m,g);const y=this._importLookAt(t,p);return y.offsetFromHeadBone.fromArray((s=c.offsetFromHeadBone)!=null?s:[0,.06,0]),y})}_v1ImportRangeMap(r,t){var e,n;let i=(e=r==null?void 0:r.inputMaxValue)!=null?e:90;const s=(n=r==null?void 0:r.outputScale)!=null?n:t;return i(console.error(o),console.warn("VRMMetaLoaderPlugin: Failed to load a thumbnail image"),null))})}},KO=class{constructor(r){this.scene=r.scene,this.meta=r.meta,this.humanoid=r.humanoid,this.expressionManager=r.expressionManager,this.firstPerson=r.firstPerson,this.lookAt=r.lookAt}update(r){this.humanoid.update(),this.lookAt&&this.lookAt.update(r),this.expressionManager&&this.expressionManager.update()}},JO=class extends KO{constructor(r){super(r),this.materials=r.materials,this.springBoneManager=r.springBoneManager,this.nodeConstraintManager=r.nodeConstraintManager}update(r){super.update(r),this.nodeConstraintManager&&this.nodeConstraintManager.update(),this.springBoneManager&&this.springBoneManager.update(r),this.materials&&this.materials.forEach(t=>{t.update&&t.update(r)})}},tP=Object.defineProperty,Ag=Object.getOwnPropertySymbols,eP=Object.prototype.hasOwnProperty,rP=Object.prototype.propertyIsEnumerable,Mg=(r,t,e)=>t in r?tP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Cg=(r,t)=>{for(var e in t||(t={}))eP.call(t,e)&&Mg(r,e,t[e]);if(Ag)for(var e of Ag(t))rP.call(t,e)&&Mg(r,e,t[e]);return r},gs=(r,t,e)=>new Promise((n,i)=>{var s=l=>{try{a(e.next(l))}catch(u){i(u)}},o=l=>{try{a(e.throw(l))}catch(u){i(u)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,o);a((e=e.apply(r,t)).next())}),nP={"":3e3,srgb:3001};function iP(r,t){parseInt(Jl,10)>=152?r.colorSpace=t:r.encoding=nP[t]}var sP=class{get pending(){return Promise.all(this._pendings)}constructor(r,t){this._parser=r,this._materialParams=t,this._pendings=[]}assignPrimitive(r,t){t!=null&&(this._materialParams[r]=t)}assignColor(r,t,e){t!=null&&(this._materialParams[r]=new qr().fromArray(t),e&&this._materialParams[r].convertSRGBToLinear())}assignTexture(r,t,e){return gs(this,null,function*(){const n=gs(this,null,function*(){t!=null&&(yield this._parser.assignTexture(this._materialParams,r,t),e&&iP(this._materialParams[r],"srgb"))});return this._pendings.push(n),n})}assignTextureByIndex(r,t,e){return gs(this,null,function*(){return this.assignTexture(r,t!=null?{index:t}:void 0,e)})}},oP=`// #define PHONG + +varying vec3 vViewPosition; + +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif + +#include + +// #include +#ifdef MTOON_USE_UV + varying vec2 vUv; + + // COMPAT: pre-r151 uses a common uvTransform + #if THREE_VRM_THREE_REVISION < 151 + uniform mat3 uvTransform; + #endif +#endif + +// #include +// COMAPT: pre-r151 uses uv2 for lightMap and aoMap +#if THREE_VRM_THREE_REVISION < 151 + #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + attribute vec2 uv2; + varying vec2 vUv2; + uniform mat3 uv2Transform; + #endif +#endif + +// #include +// #include +#include +#include +#include +#include +#include +#include +#include + +#ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE + uniform sampler2D outlineWidthMultiplyTexture; + uniform mat3 outlineWidthMultiplyTextureUvTransform; +#endif + +uniform float outlineWidthFactor; + +void main() { + + // #include + #ifdef MTOON_USE_UV + // COMPAT: pre-r151 uses a common uvTransform + #if THREE_VRM_THREE_REVISION >= 151 + vUv = uv; + #else + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #endif + + // #include + // COMAPT: pre-r151 uses uv2 for lightMap and aoMap + #if THREE_VRM_THREE_REVISION < 151 + #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; + #endif + #endif + + #include + + #include + #include + #include + #include + + // we need this to compute the outline properly + objectNormal = normalize( objectNormal ); + + #include + + #ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED + vNormal = normalize( transformedNormal ); + #endif + + #include + + #include + #include + // #include + #include + #include + #include + + vViewPosition = - mvPosition.xyz; + + #ifdef OUTLINE + float worldNormalLength = length( transformedNormal ); + vec3 outlineOffset = outlineWidthFactor * worldNormalLength * objectNormal; + + #ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE + vec2 outlineWidthMultiplyTextureUv = ( outlineWidthMultiplyTextureUvTransform * vec3( vUv, 1 ) ).xy; + float outlineTex = texture2D( outlineWidthMultiplyTexture, outlineWidthMultiplyTextureUv ).g; + outlineOffset *= outlineTex; + #endif + + #ifdef OUTLINE_WIDTH_SCREEN + outlineOffset *= vViewPosition.z / projectionMatrix[ 1 ].y; + #endif + + gl_Position = projectionMatrix * modelViewMatrix * vec4( outlineOffset + transformed, 1.0 ); + + gl_Position.z += 1E-6 * gl_Position.w; // anti-artifact magic + #endif + + #include + // #include + #include + #include + +}`,aP=`// #define PHONG + +uniform vec3 litFactor; + +uniform float opacity; + +uniform vec3 shadeColorFactor; +#ifdef USE_SHADEMULTIPLYTEXTURE + uniform sampler2D shadeMultiplyTexture; + uniform mat3 shadeMultiplyTextureUvTransform; +#endif + +uniform float shadingShiftFactor; +uniform float shadingToonyFactor; + +#ifdef USE_SHADINGSHIFTTEXTURE + uniform sampler2D shadingShiftTexture; + uniform mat3 shadingShiftTextureUvTransform; + uniform float shadingShiftTextureScale; +#endif + +uniform float giEqualizationFactor; + +uniform vec3 parametricRimColorFactor; +#ifdef USE_RIMMULTIPLYTEXTURE + uniform sampler2D rimMultiplyTexture; + uniform mat3 rimMultiplyTextureUvTransform; +#endif +uniform float rimLightingMixFactor; +uniform float parametricRimFresnelPowerFactor; +uniform float parametricRimLiftFactor; + +#ifdef USE_MATCAPTEXTURE + uniform vec3 matcapFactor; + uniform sampler2D matcapTexture; + uniform mat3 matcapTextureUvTransform; +#endif + +uniform vec3 emissive; +uniform float emissiveIntensity; + +uniform vec3 outlineColorFactor; +uniform float outlineLightingMixFactor; + +#ifdef USE_UVANIMATIONMASKTEXTURE + uniform sampler2D uvAnimationMaskTexture; + uniform mat3 uvAnimationMaskTextureUvTransform; +#endif + +uniform float uvAnimationScrollXOffset; +uniform float uvAnimationScrollYOffset; +uniform float uvAnimationRotationPhase; + +#include +#include +#include +#include + +// #include +#if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) ) + varying vec2 vUv; +#endif + +// #include +// COMAPT: pre-r151 uses uv2 for lightMap and aoMap +#if THREE_VRM_THREE_REVISION < 151 + #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + varying vec2 vUv2; + #endif +#endif + +#include + +#ifdef USE_MAP + uniform mat3 mapUvTransform; +#endif + +// #include + +#include + +#include +// #include +#include + +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapUvTransform; +#endif + +// #include +// #include +// #include +#include + +// #include +// COMPAT: pre-r151 doesn't have BRDF_Lambert in +#if THREE_VRM_THREE_REVISION < 151 + vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; + } +#endif + +#include + +#include + +// #include +varying vec3 vViewPosition; + +struct MToonMaterial { + vec3 diffuseColor; + vec3 shadeColor; + float shadingShift; +}; + +float linearstep( float a, float b, float t ) { + return clamp( ( t - a ) / ( b - a ), 0.0, 1.0 ); +} + +/** + * Convert NdotL into toon shading factor using shadingShift and shadingToony + */ +float getShading( + const in float dotNL, + const in float shadow, + const in float shadingShift +) { + float shading = dotNL; + shading = shading + shadingShift; + shading = linearstep( -1.0 + shadingToonyFactor, 1.0 - shadingToonyFactor, shading ); + shading *= shadow; + return shading; +} + +/** + * Mix diffuseColor and shadeColor using shading factor and light color + */ +vec3 getDiffuse( + const in MToonMaterial material, + const in float shading, + in vec3 lightColor +) { + #ifdef DEBUG_LITSHADERATE + return vec3( BRDF_Lambert( shading * lightColor ) ); + #endif + + vec3 col = lightColor * BRDF_Lambert( mix( material.shadeColor, material.diffuseColor, shading ) ); + + // The "comment out if you want to PBR absolutely" line + #ifdef V0_COMPAT_SHADE + col = min( col, material.diffuseColor ); + #endif + + return col; +} + +// COMPAT: pre-r156 uses a struct GeometricContext +#if THREE_VRM_THREE_REVISION >= 157 + void RE_Direct_MToon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in MToonMaterial material, const in float shadow, inout ReflectedLight reflectedLight ) { + float dotNL = clamp( dot( geometryNormal, directLight.direction ), -1.0, 1.0 ); + vec3 irradiance = directLight.color; + + // directSpecular will be used for rim lighting, not an actual specular + reflectedLight.directSpecular += irradiance; + + irradiance *= dotNL; + + float shading = getShading( dotNL, shadow, material.shadingShift ); + + // toon shaded diffuse + reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color ); + } + + void RE_IndirectDiffuse_MToon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in MToonMaterial material, inout ReflectedLight reflectedLight ) { + // indirect diffuse will use diffuseColor, no shadeColor involved + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + + // directSpecular will be used for rim lighting, not an actual specular + reflectedLight.directSpecular += irradiance; + } +#else + void RE_Direct_MToon( const in IncidentLight directLight, const in GeometricContext geometry, const in MToonMaterial material, const in float shadow, inout ReflectedLight reflectedLight ) { + float dotNL = clamp( dot( geometry.normal, directLight.direction ), -1.0, 1.0 ); + vec3 irradiance = directLight.color; + + // directSpecular will be used for rim lighting, not an actual specular + reflectedLight.directSpecular += irradiance; + + irradiance *= dotNL; + + float shading = getShading( dotNL, shadow, material.shadingShift ); + + // toon shaded diffuse + reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color ); + } + + void RE_IndirectDiffuse_MToon( const in vec3 irradiance, const in GeometricContext geometry, const in MToonMaterial material, inout ReflectedLight reflectedLight ) { + // indirect diffuse will use diffuseColor, no shadeColor involved + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + + // directSpecular will be used for rim lighting, not an actual specular + reflectedLight.directSpecular += irradiance; + } +#endif + +#define RE_Direct RE_Direct_MToon +#define RE_IndirectDiffuse RE_IndirectDiffuse_MToon +#define Material_LightProbeLOD( material ) (0) + +#include +// #include + +// #include +#ifdef USE_NORMALMAP + + uniform sampler2D normalMap; + uniform mat3 normalMapUvTransform; + uniform vec2 normalScale; + +#endif + +// COMPAT: pre-r151 +// USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151 +#if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP ) + + uniform mat3 normalMatrix; + +#endif + +// COMPAT: pre-r151 +// USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151 +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( TANGENTSPACE_NORMALMAP ) ) + + // Per-Pixel Tangent Space Normal Mapping + // http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html + + // three-vrm specific change: it requires \`uv\` as an input in order to support uv scrolls + + // Temporary compat against shader change @ Three.js r126, r151 + #if THREE_VRM_THREE_REVISION >= 151 + + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + + vec3 N = surf_norm; + + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + + return mat3( T * scale, B * scale, N ); + + } + + #else + + vec3 perturbNormal2Arb( vec2 uv, vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) { + + vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) ); + vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + + vec3 N = normalize( surf_norm ); + + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + + // three-vrm specific change: Workaround for the issue that happens when delta of uv = 0.0 + // TODO: Is this still required? Or shall I make a PR about it? + if ( length( T ) == 0.0 || length( B ) == 0.0 ) { + return surf_norm; + } + + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det ); + + return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ); + + } + + #endif + +#endif + +// #include +#include +#include + +// == post correction ========================================================== +void postCorrection() { + #include + #include + #include + #include + #include +} + +// == main procedure =========================================================== +void main() { + #include + + vec2 uv = vec2(0.5, 0.5); + + #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) ) + uv = vUv; + + float uvAnimMask = 1.0; + #ifdef USE_UVANIMATIONMASKTEXTURE + vec2 uvAnimationMaskTextureUv = ( uvAnimationMaskTextureUvTransform * vec3( uv, 1 ) ).xy; + uvAnimMask = texture2D( uvAnimationMaskTexture, uvAnimationMaskTextureUv ).b; + #endif + + float uvRotCos = cos( uvAnimationRotationPhase * uvAnimMask ); + float uvRotSin = sin( uvAnimationRotationPhase * uvAnimMask ); + uv = mat2( uvRotCos, -uvRotSin, uvRotSin, uvRotCos ) * ( uv - 0.5 ) + 0.5; + uv = uv + vec2( uvAnimationScrollXOffset, uvAnimationScrollYOffset ) * uvAnimMask; + #endif + + #ifdef DEBUG_UV + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) ) + gl_FragColor = vec4( uv, 0.0, 1.0 ); + #endif + return; + #endif + + vec4 diffuseColor = vec4( litFactor, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive * emissiveIntensity; + + #include + + // #include + #ifdef USE_MAP + vec2 mapUv = ( mapUvTransform * vec3( uv, 1 ) ).xy; + vec4 sampledDiffuseColor = texture2D( map, mapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); + #endif + diffuseColor *= sampledDiffuseColor; + #endif + + // #include + #if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) ) + diffuseColor.rgb *= vColor; + #endif + + // #include + + #include + + // #include + + // #include + float faceDirection = gl_FrontFacing ? 1.0 : -1.0; + + #ifdef FLAT_SHADED + + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); + + #else + + vec3 normal = normalize( vNormal ); + + #ifdef DOUBLE_SIDED + + normal *= faceDirection; + + #endif + + #endif + + #ifdef USE_NORMALMAP + + vec2 normalMapUv = ( normalMapUvTransform * vec3( uv, 1 ) ).xy; + + #endif + + #ifdef USE_NORMALMAP_TANGENTSPACE + + #ifdef USE_TANGENT + + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + + #else + + mat3 tbn = getTangentFrame( - vViewPosition, normal, normalMapUv ); + + #endif + + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + + #endif + + #endif + + #ifdef USE_CLEARCOAT_NORMALMAP + + #ifdef USE_TANGENT + + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + + #else + + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + + #endif + + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + + #endif + + #endif + + // non perturbed normal for clearcoat among others + + vec3 nonPerturbedNormal = normal; + + #ifdef OUTLINE + normal *= -1.0; + #endif + + // #include + + // COMPAT: pre-r151 + // USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151 + #if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP ) + + normal = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals + + #ifdef FLIP_SIDED + + normal = - normal; + + #endif + + #ifdef DOUBLE_SIDED + + normal = normal * faceDirection; + + #endif + + normal = normalize( normalMatrix * normal ); + + // COMPAT: pre-r151 + // USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151 + #elif defined( USE_NORMALMAP_TANGENTSPACE ) || defined( TANGENTSPACE_NORMALMAP ) + + vec3 mapN = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + + // COMPAT: pre-r151 + #if THREE_VRM_THREE_REVISION >= 151 || defined( USE_TANGENT ) + + normal = normalize( tbn * mapN ); + + #else + + normal = perturbNormal2Arb( uv, -vViewPosition, normal, mapN, faceDirection ); + + #endif + + #endif + + // #include + #ifdef USE_EMISSIVEMAP + vec2 emissiveMapUv = ( emissiveMapUvTransform * vec3( uv, 1 ) ).xy; + totalEmissiveRadiance *= texture2D( emissiveMap, emissiveMapUv ).rgb; + #endif + + #ifdef DEBUG_NORMAL + gl_FragColor = vec4( 0.5 + 0.5 * normal, 1.0 ); + return; + #endif + + // -- MToon: lighting -------------------------------------------------------- + // accumulation + // #include + MToonMaterial material; + + material.diffuseColor = diffuseColor.rgb; + + material.shadeColor = shadeColorFactor; + #ifdef USE_SHADEMULTIPLYTEXTURE + vec2 shadeMultiplyTextureUv = ( shadeMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy; + material.shadeColor *= texture2D( shadeMultiplyTexture, shadeMultiplyTextureUv ).rgb; + #endif + + #if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) ) + material.shadeColor.rgb *= vColor; + #endif + + material.shadingShift = shadingShiftFactor; + #ifdef USE_SHADINGSHIFTTEXTURE + vec2 shadingShiftTextureUv = ( shadingShiftTextureUvTransform * vec3( uv, 1 ) ).xy; + material.shadingShift += texture2D( shadingShiftTexture, shadingShiftTextureUv ).r * shadingShiftTextureScale; + #endif + + // #include + + // MToon Specific changes: + // Since we want to take shadows into account of shading instead of irradiance, + // we had to modify the codes that multiplies the results of shadowmap into color of direct lights. + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + vec3 geometryPosition = - vViewPosition; + vec3 geometryNormal = normal; + vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); + + vec3 geometryClearcoatNormal; + + #ifdef USE_CLEARCOAT + + geometryClearcoatNormal = clearcoatNormal; + + #endif + #else + GeometricContext geometry; + + geometry.position = - vViewPosition; + geometry.normal = normal; + geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); + + #ifdef USE_CLEARCOAT + + geometry.clearcoatNormal = clearcoatNormal; + + #endif + #endif + + IncidentLight directLight; + + // since these variables will be used in unrolled loop, we have to define in prior + float shadow; + + #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + + pointLight = pointLights[ i ]; + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + getPointLightInfo( pointLight, geometryPosition, directLight ); + #else + getPointLightInfo( pointLight, geometry, directLight ); + #endif + + shadow = 1.0; + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + // COMPAT: pre-r166 + // r166 introduced shadowIntensity + #if THREE_VRM_THREE_REVISION >= 166 + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #else + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + #endif + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight ); + #else + RE_Direct( directLight, geometry, material, shadow, reflectedLight ); + #endif + + } + #pragma unroll_loop_end + + #endif + + #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + + SpotLight spotLight; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + + spotLight = spotLights[ i ]; + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #else + getSpotLightInfo( spotLight, geometry, directLight ); + #endif + + shadow = 1.0; + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + // COMPAT: pre-r166 + // r166 introduced shadowIntensity + #if THREE_VRM_THREE_REVISION >= 166 + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; + #else + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; + #endif + #endif + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight ); + #else + RE_Direct( directLight, geometry, material, shadow, reflectedLight ); + #endif + + } + #pragma unroll_loop_end + + #endif + + #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + + directionalLight = directionalLights[ i ]; + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + getDirectionalLightInfo( directionalLight, directLight ); + #else + getDirectionalLightInfo( directionalLight, geometry, directLight ); + #endif + + shadow = 1.0; + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + // COMPAT: pre-r166 + // r166 introduced shadowIntensity + #if THREE_VRM_THREE_REVISION >= 166 + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #else + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + #endif + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight ); + #else + RE_Direct( directLight, geometry, material, shadow, reflectedLight ); + #endif + + } + #pragma unroll_loop_end + + #endif + + // #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + + // RectAreaLight rectAreaLight; + + // #pragma unroll_loop_start + // for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + + // rectAreaLight = rectAreaLights[ i ]; + // RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight ); + + // } + // #pragma unroll_loop_end + + // #endif + + #if defined( RE_IndirectDiffuse ) + + vec3 iblIrradiance = vec3( 0.0 ); + + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + + // COMPAT: pre-r156 uses a struct GeometricContext + // COMPAT: pre-r156 doesn't have a define USE_LIGHT_PROBES + #if THREE_VRM_THREE_REVISION >= 157 + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #else + irradiance += getLightProbeIrradiance( lightProbe, geometry.normal ); + #endif + + #if ( NUM_HEMI_LIGHTS > 0 ) + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + #else + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); + #endif + + } + #pragma unroll_loop_end + + #endif + + #endif + + // #if defined( RE_IndirectSpecular ) + + // vec3 radiance = vec3( 0.0 ); + // vec3 clearcoatRadiance = vec3( 0.0 ); + + // #endif + + #include + #include + + // modulation + #include + + vec3 col = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + + #ifdef DEBUG_LITSHADERATE + gl_FragColor = vec4( col, diffuseColor.a ); + postCorrection(); + return; + #endif + + // -- MToon: rim lighting ----------------------------------------- + vec3 viewDir = normalize( vViewPosition ); + + #ifndef PHYSICALLY_CORRECT_LIGHTS + reflectedLight.directSpecular /= PI; + #endif + vec3 rimMix = mix( vec3( 1.0 ), reflectedLight.directSpecular, 1.0 ); + + vec3 rim = parametricRimColorFactor * pow( saturate( 1.0 - dot( viewDir, normal ) + parametricRimLiftFactor ), parametricRimFresnelPowerFactor ); + + #ifdef USE_MATCAPTEXTURE + { + vec3 x = normalize( vec3( viewDir.z, 0.0, -viewDir.x ) ); + vec3 y = cross( viewDir, x ); // guaranteed to be normalized + vec2 sphereUv = 0.5 + 0.5 * vec2( dot( x, normal ), -dot( y, normal ) ); + sphereUv = ( matcapTextureUvTransform * vec3( sphereUv, 1 ) ).xy; + vec3 matcap = texture2D( matcapTexture, sphereUv ).rgb; + rim += matcapFactor * matcap; + } + #endif + + #ifdef USE_RIMMULTIPLYTEXTURE + vec2 rimMultiplyTextureUv = ( rimMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy; + rim *= texture2D( rimMultiplyTexture, rimMultiplyTextureUv ).rgb; + #endif + + col += rimMix * rim; + + // -- MToon: Emission -------------------------------------------------------- + col += totalEmissiveRadiance; + + // #include + + // -- Almost done! ----------------------------------------------------------- + #if defined( OUTLINE ) + col = outlineColorFactor.rgb * mix( vec3( 1.0 ), col, outlineLightingMixFactor ); + #endif + + #ifdef OPAQUE + diffuseColor.a = 1.0; + #endif + + gl_FragColor = vec4( col, diffuseColor.a ); + postCorrection(); +} +`,lP={None:"none"},Og={None:"none",ScreenCoordinates:"screenCoordinates"},uP={3e3:"",3001:"srgb"};function ph(r){return parseInt(Jl,10)>=152?r.colorSpace:uP[r.encoding]}var cP=class extends v1{constructor(r={}){var t;super({vertexShader:oP,fragmentShader:aP}),this.uvAnimationScrollXSpeedFactor=0,this.uvAnimationScrollYSpeedFactor=0,this.uvAnimationRotationSpeedFactor=0,this.fog=!0,this.normalMapType=_1,this._ignoreVertexColor=!0,this._v0CompatShade=!1,this._debugMode=lP.None,this._outlineWidthMode=Og.None,this._isOutline=!1,r.transparentWithZWrite&&(r.depthWrite=!0),delete r.transparentWithZWrite,r.fog=!0,r.lights=!0,r.clipping=!0,this.uniforms=b1.merge([Ho.common,Ho.normalmap,Ho.emissivemap,Ho.fog,Ho.lights,{litFactor:{value:new qr(1,1,1)},mapUvTransform:{value:new xn},colorAlpha:{value:1},normalMapUvTransform:{value:new xn},shadeColorFactor:{value:new qr(0,0,0)},shadeMultiplyTexture:{value:null},shadeMultiplyTextureUvTransform:{value:new xn},shadingShiftFactor:{value:0},shadingShiftTexture:{value:null},shadingShiftTextureUvTransform:{value:new xn},shadingShiftTextureScale:{value:1},shadingToonyFactor:{value:.9},giEqualizationFactor:{value:.9},matcapFactor:{value:new qr(1,1,1)},matcapTexture:{value:null},matcapTextureUvTransform:{value:new xn},parametricRimColorFactor:{value:new qr(0,0,0)},rimMultiplyTexture:{value:null},rimMultiplyTextureUvTransform:{value:new xn},rimLightingMixFactor:{value:1},parametricRimFresnelPowerFactor:{value:5},parametricRimLiftFactor:{value:0},emissive:{value:new qr(0,0,0)},emissiveIntensity:{value:1},emissiveMapUvTransform:{value:new xn},outlineWidthMultiplyTexture:{value:null},outlineWidthMultiplyTextureUvTransform:{value:new xn},outlineWidthFactor:{value:0},outlineColorFactor:{value:new qr(0,0,0)},outlineLightingMixFactor:{value:1},uvAnimationMaskTexture:{value:null},uvAnimationMaskTextureUvTransform:{value:new xn},uvAnimationScrollXOffset:{value:0},uvAnimationScrollYOffset:{value:0},uvAnimationRotationPhase:{value:0}},(t=r.uniforms)!=null?t:{}]),this.setValues(r),this._uploadUniformsWorkaround(),this.customProgramCacheKey=()=>[...Object.entries(this._generateDefines()).map(([e,n])=>`${e}:${n}`),this.matcapTexture?`matcapTextureColorSpace:${ph(this.matcapTexture)}`:"",this.shadeMultiplyTexture?`shadeMultiplyTextureColorSpace:${ph(this.shadeMultiplyTexture)}`:"",this.rimMultiplyTexture?`rimMultiplyTextureColorSpace:${ph(this.rimMultiplyTexture)}`:""].join(","),this.onBeforeCompile=e=>{const n=parseInt(Jl,10),i=Object.entries(Cg(Cg({},this._generateDefines()),this.defines)).filter(([s,o])=>!!o).map(([s,o])=>`#define ${s} ${o}`).join(` +`)+` +`;e.vertexShader=i+e.vertexShader,e.fragmentShader=i+e.fragmentShader,n<154&&(e.fragmentShader=e.fragmentShader.replace("#include ","#include "))}}get color(){return this.uniforms.litFactor.value}set color(r){this.uniforms.litFactor.value=r}get map(){return this.uniforms.map.value}set map(r){this.uniforms.map.value=r}get normalMap(){return this.uniforms.normalMap.value}set normalMap(r){this.uniforms.normalMap.value=r}get normalScale(){return this.uniforms.normalScale.value}set normalScale(r){this.uniforms.normalScale.value=r}get emissive(){return this.uniforms.emissive.value}set emissive(r){this.uniforms.emissive.value=r}get emissiveIntensity(){return this.uniforms.emissiveIntensity.value}set emissiveIntensity(r){this.uniforms.emissiveIntensity.value=r}get emissiveMap(){return this.uniforms.emissiveMap.value}set emissiveMap(r){this.uniforms.emissiveMap.value=r}get shadeColorFactor(){return this.uniforms.shadeColorFactor.value}set shadeColorFactor(r){this.uniforms.shadeColorFactor.value=r}get shadeMultiplyTexture(){return this.uniforms.shadeMultiplyTexture.value}set shadeMultiplyTexture(r){this.uniforms.shadeMultiplyTexture.value=r}get shadingShiftFactor(){return this.uniforms.shadingShiftFactor.value}set shadingShiftFactor(r){this.uniforms.shadingShiftFactor.value=r}get shadingShiftTexture(){return this.uniforms.shadingShiftTexture.value}set shadingShiftTexture(r){this.uniforms.shadingShiftTexture.value=r}get shadingShiftTextureScale(){return this.uniforms.shadingShiftTextureScale.value}set shadingShiftTextureScale(r){this.uniforms.shadingShiftTextureScale.value=r}get shadingToonyFactor(){return this.uniforms.shadingToonyFactor.value}set shadingToonyFactor(r){this.uniforms.shadingToonyFactor.value=r}get giEqualizationFactor(){return this.uniforms.giEqualizationFactor.value}set giEqualizationFactor(r){this.uniforms.giEqualizationFactor.value=r}get matcapFactor(){return this.uniforms.matcapFactor.value}set matcapFactor(r){this.uniforms.matcapFactor.value=r}get matcapTexture(){return this.uniforms.matcapTexture.value}set matcapTexture(r){this.uniforms.matcapTexture.value=r}get parametricRimColorFactor(){return this.uniforms.parametricRimColorFactor.value}set parametricRimColorFactor(r){this.uniforms.parametricRimColorFactor.value=r}get rimMultiplyTexture(){return this.uniforms.rimMultiplyTexture.value}set rimMultiplyTexture(r){this.uniforms.rimMultiplyTexture.value=r}get rimLightingMixFactor(){return this.uniforms.rimLightingMixFactor.value}set rimLightingMixFactor(r){this.uniforms.rimLightingMixFactor.value=r}get parametricRimFresnelPowerFactor(){return this.uniforms.parametricRimFresnelPowerFactor.value}set parametricRimFresnelPowerFactor(r){this.uniforms.parametricRimFresnelPowerFactor.value=r}get parametricRimLiftFactor(){return this.uniforms.parametricRimLiftFactor.value}set parametricRimLiftFactor(r){this.uniforms.parametricRimLiftFactor.value=r}get outlineWidthMultiplyTexture(){return this.uniforms.outlineWidthMultiplyTexture.value}set outlineWidthMultiplyTexture(r){this.uniforms.outlineWidthMultiplyTexture.value=r}get outlineWidthFactor(){return this.uniforms.outlineWidthFactor.value}set outlineWidthFactor(r){this.uniforms.outlineWidthFactor.value=r}get outlineColorFactor(){return this.uniforms.outlineColorFactor.value}set outlineColorFactor(r){this.uniforms.outlineColorFactor.value=r}get outlineLightingMixFactor(){return this.uniforms.outlineLightingMixFactor.value}set outlineLightingMixFactor(r){this.uniforms.outlineLightingMixFactor.value=r}get uvAnimationMaskTexture(){return this.uniforms.uvAnimationMaskTexture.value}set uvAnimationMaskTexture(r){this.uniforms.uvAnimationMaskTexture.value=r}get uvAnimationScrollXOffset(){return this.uniforms.uvAnimationScrollXOffset.value}set uvAnimationScrollXOffset(r){this.uniforms.uvAnimationScrollXOffset.value=r}get uvAnimationScrollYOffset(){return this.uniforms.uvAnimationScrollYOffset.value}set uvAnimationScrollYOffset(r){this.uniforms.uvAnimationScrollYOffset.value=r}get uvAnimationRotationPhase(){return this.uniforms.uvAnimationRotationPhase.value}set uvAnimationRotationPhase(r){this.uniforms.uvAnimationRotationPhase.value=r}get ignoreVertexColor(){return this._ignoreVertexColor}set ignoreVertexColor(r){this._ignoreVertexColor=r,this.needsUpdate=!0}get v0CompatShade(){return this._v0CompatShade}set v0CompatShade(r){this._v0CompatShade=r,this.needsUpdate=!0}get debugMode(){return this._debugMode}set debugMode(r){this._debugMode=r,this.needsUpdate=!0}get outlineWidthMode(){return this._outlineWidthMode}set outlineWidthMode(r){this._outlineWidthMode=r,this.needsUpdate=!0}get isOutline(){return this._isOutline}set isOutline(r){this._isOutline=r,this.needsUpdate=!0}get isMToonMaterial(){return!0}update(r){this._uploadUniformsWorkaround(),this._updateUVAnimation(r)}copy(r){return super.copy(r),this.map=r.map,this.normalMap=r.normalMap,this.emissiveMap=r.emissiveMap,this.shadeMultiplyTexture=r.shadeMultiplyTexture,this.shadingShiftTexture=r.shadingShiftTexture,this.matcapTexture=r.matcapTexture,this.rimMultiplyTexture=r.rimMultiplyTexture,this.outlineWidthMultiplyTexture=r.outlineWidthMultiplyTexture,this.uvAnimationMaskTexture=r.uvAnimationMaskTexture,this.normalMapType=r.normalMapType,this.uvAnimationScrollXSpeedFactor=r.uvAnimationScrollXSpeedFactor,this.uvAnimationScrollYSpeedFactor=r.uvAnimationScrollYSpeedFactor,this.uvAnimationRotationSpeedFactor=r.uvAnimationRotationSpeedFactor,this.ignoreVertexColor=r.ignoreVertexColor,this.v0CompatShade=r.v0CompatShade,this.debugMode=r.debugMode,this.outlineWidthMode=r.outlineWidthMode,this.isOutline=r.isOutline,this.needsUpdate=!0,this}_updateUVAnimation(r){this.uniforms.uvAnimationScrollXOffset.value+=r*this.uvAnimationScrollXSpeedFactor,this.uniforms.uvAnimationScrollYOffset.value+=r*this.uvAnimationScrollYSpeedFactor,this.uniforms.uvAnimationRotationPhase.value+=r*this.uvAnimationRotationSpeedFactor,this.uniforms.alphaTest.value=this.alphaTest,this.uniformsNeedUpdate=!0}_uploadUniformsWorkaround(){this.uniforms.opacity.value=this.opacity,this._updateTextureMatrix(this.uniforms.map,this.uniforms.mapUvTransform),this._updateTextureMatrix(this.uniforms.normalMap,this.uniforms.normalMapUvTransform),this._updateTextureMatrix(this.uniforms.emissiveMap,this.uniforms.emissiveMapUvTransform),this._updateTextureMatrix(this.uniforms.shadeMultiplyTexture,this.uniforms.shadeMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.shadingShiftTexture,this.uniforms.shadingShiftTextureUvTransform),this._updateTextureMatrix(this.uniforms.matcapTexture,this.uniforms.matcapTextureUvTransform),this._updateTextureMatrix(this.uniforms.rimMultiplyTexture,this.uniforms.rimMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.outlineWidthMultiplyTexture,this.uniforms.outlineWidthMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.uvAnimationMaskTexture,this.uniforms.uvAnimationMaskTextureUvTransform),this.uniformsNeedUpdate=!0}_generateDefines(){const r=parseInt(Jl,10),t=this.outlineWidthMultiplyTexture!==null,e=this.map!==null||this.normalMap!==null||this.emissiveMap!==null||this.shadeMultiplyTexture!==null||this.shadingShiftTexture!==null||this.rimMultiplyTexture!==null||this.uvAnimationMaskTexture!==null;return{THREE_VRM_THREE_REVISION:r,OUTLINE:this._isOutline,MTOON_USE_UV:t||e,MTOON_UVS_VERTEX_ONLY:t&&!e,V0_COMPAT_SHADE:this._v0CompatShade,USE_SHADEMULTIPLYTEXTURE:this.shadeMultiplyTexture!==null,USE_SHADINGSHIFTTEXTURE:this.shadingShiftTexture!==null,USE_MATCAPTEXTURE:this.matcapTexture!==null,USE_RIMMULTIPLYTEXTURE:this.rimMultiplyTexture!==null,USE_OUTLINEWIDTHMULTIPLYTEXTURE:this._isOutline&&this.outlineWidthMultiplyTexture!==null,USE_UVANIMATIONMASKTEXTURE:this.uvAnimationMaskTexture!==null,IGNORE_VERTEX_COLOR:this._ignoreVertexColor===!0,DEBUG_NORMAL:this._debugMode==="normal",DEBUG_LITSHADERATE:this._debugMode==="litShadeRate",DEBUG_UV:this._debugMode==="uv",OUTLINE_WIDTH_SCREEN:this._isOutline&&this._outlineWidthMode===Og.ScreenCoordinates}}_updateTextureMatrix(r,t){r.value&&(r.value.matrixAutoUpdate&&r.value.updateMatrix(),t.value.copy(r.value.matrix))}},hP=new Set(["1.0","1.0-beta"]),xb=class zl{get name(){return zl.EXTENSION_NAME}constructor(t,e={}){var n,i,s,o;this.parser=t,this.materialType=(n=e.materialType)!=null?n:cP,this.renderOrderOffset=(i=e.renderOrderOffset)!=null?i:0,this.v0CompatShade=(s=e.v0CompatShade)!=null?s:!1,this.debugMode=(o=e.debugMode)!=null?o:"none",this._mToonMaterialSet=new Set}beforeRoot(){return gs(this,null,function*(){this._removeUnlitExtensionIfMToonExists()})}afterRoot(t){return gs(this,null,function*(){t.userData.vrmMToonMaterials=Array.from(this._mToonMaterialSet)})}getMaterialType(t){return this._getMToonExtension(t)?this.materialType:null}extendMaterialParams(t,e){const n=this._getMToonExtension(t);return n?this._extendMaterialParams(n,e):null}loadMesh(t){return gs(this,null,function*(){var e;const n=this.parser,s=(e=n.json.meshes)==null?void 0:e[t];if(s==null)throw new Error(`MToonMaterialLoaderPlugin: Attempt to use meshes[${t}] of glTF but the mesh doesn't exist`);const o=s.primitives,a=yield n.loadMesh(t);if(o.length===1){const l=a,u=o[0].material;u!=null&&this._setupPrimitive(l,u)}else{const l=a;for(let u=0;u{var o;this._getMToonExtension(s)&&((o=i.extensions)!=null&&o.KHR_materials_unlit)&&delete i.extensions.KHR_materials_unlit})}_getMToonExtension(t){var e,n;const o=(e=this.parser.json.materials)==null?void 0:e[t];if(o==null){console.warn(`MToonMaterialLoaderPlugin: Attempt to use materials[${t}] of glTF but the material doesn't exist`);return}const a=(n=o.extensions)==null?void 0:n[zl.EXTENSION_NAME];if(a==null)return;const l=a.specVersion;if(!hP.has(l)){console.warn(`MToonMaterialLoaderPlugin: Unknown ${zl.EXTENSION_NAME} specVersion "${l}"`);return}return a}_extendMaterialParams(t,e){return gs(this,null,function*(){var n;delete e.metalness,delete e.roughness;const i=new sP(this.parser,e);i.assignPrimitive("transparentWithZWrite",t.transparentWithZWrite),i.assignColor("shadeColorFactor",t.shadeColorFactor),i.assignTexture("shadeMultiplyTexture",t.shadeMultiplyTexture,!0),i.assignPrimitive("shadingShiftFactor",t.shadingShiftFactor),i.assignTexture("shadingShiftTexture",t.shadingShiftTexture,!0),i.assignPrimitive("shadingShiftTextureScale",(n=t.shadingShiftTexture)==null?void 0:n.scale),i.assignPrimitive("shadingToonyFactor",t.shadingToonyFactor),i.assignPrimitive("giEqualizationFactor",t.giEqualizationFactor),i.assignColor("matcapFactor",t.matcapFactor),i.assignTexture("matcapTexture",t.matcapTexture,!0),i.assignColor("parametricRimColorFactor",t.parametricRimColorFactor),i.assignTexture("rimMultiplyTexture",t.rimMultiplyTexture,!0),i.assignPrimitive("rimLightingMixFactor",t.rimLightingMixFactor),i.assignPrimitive("parametricRimFresnelPowerFactor",t.parametricRimFresnelPowerFactor),i.assignPrimitive("parametricRimLiftFactor",t.parametricRimLiftFactor),i.assignPrimitive("outlineWidthMode",t.outlineWidthMode),i.assignPrimitive("outlineWidthFactor",t.outlineWidthFactor),i.assignTexture("outlineWidthMultiplyTexture",t.outlineWidthMultiplyTexture,!1),i.assignColor("outlineColorFactor",t.outlineColorFactor),i.assignPrimitive("outlineLightingMixFactor",t.outlineLightingMixFactor),i.assignTexture("uvAnimationMaskTexture",t.uvAnimationMaskTexture,!1),i.assignPrimitive("uvAnimationScrollXSpeedFactor",t.uvAnimationScrollXSpeedFactor),i.assignPrimitive("uvAnimationScrollYSpeedFactor",t.uvAnimationScrollYSpeedFactor),i.assignPrimitive("uvAnimationRotationSpeedFactor",t.uvAnimationRotationSpeedFactor),i.assignPrimitive("v0CompatShade",this.v0CompatShade),i.assignPrimitive("debugMode",this.debugMode),yield i.pending})}_setupPrimitive(t,e){const n=this._getMToonExtension(e);if(n){const i=this._parseRenderOrder(n);t.renderOrder=i+this.renderOrderOffset,this._generateOutline(t),this._addToMaterialSet(t);return}}_shouldGenerateOutline(t){return typeof t.outlineWidthMode=="string"&&t.outlineWidthMode!=="none"&&typeof t.outlineWidthFactor=="number"&&t.outlineWidthFactor>0}_generateOutline(t){const e=t.material;if(!(e instanceof m1)||!this._shouldGenerateOutline(e))return;t.material=[e];const n=e.clone();n.name+=" (Outline)",n.isOutline=!0,n.side=g1,t.material.push(n);const i=t.geometry,s=i.index?i.index.count:i.attributes.position.count/3;i.addGroup(0,s,0),i.addGroup(0,s,1)}_addToMaterialSet(t){const e=t.material,n=new Set;Array.isArray(e)?e.forEach(i=>n.add(i)):n.add(e);for(const i of n)this._mToonMaterialSet.add(i)}_parseRenderOrder(t){var e;return(t.transparentWithZWrite?0:19)+((e=t.renderQueueOffsetNumber)!=null?e:0)}};xb.EXTENSION_NAME="VRMC_materials_mtoon";var dP=xb,fP=(r,t,e)=>new Promise((n,i)=>{var s=l=>{try{a(e.next(l))}catch(u){i(u)}},o=l=>{try{a(e.throw(l))}catch(u){i(u)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,o);a((e=e.apply(r,t)).next())}),Sb=class $d{get name(){return $d.EXTENSION_NAME}constructor(t){this.parser=t}extendMaterialParams(t,e){return fP(this,null,function*(){const n=this._getHDREmissiveMultiplierExtension(t);if(n==null)return;console.warn("VRMMaterialsHDREmissiveMultiplierLoaderPlugin: `VRMC_materials_hdr_emissiveMultiplier` is archived. Use `KHR_materials_emissive_strength` instead.");const i=n.emissiveMultiplier;e.emissiveIntensity=i})}_getHDREmissiveMultiplierExtension(t){var e,n;const o=(e=this.parser.json.materials)==null?void 0:e[t];if(o==null){console.warn(`VRMMaterialsHDREmissiveMultiplierLoaderPlugin: Attempt to use materials[${t}] of glTF but the material doesn't exist`);return}const a=(n=o.extensions)==null?void 0:n[$d.EXTENSION_NAME];if(a!=null)return a}};Sb.EXTENSION_NAME="VRMC_materials_hdr_emissiveMultiplier";var pP=Sb,mP=Object.defineProperty,gP=Object.defineProperties,yP=Object.getOwnPropertyDescriptors,Pg=Object.getOwnPropertySymbols,vP=Object.prototype.hasOwnProperty,_P=Object.prototype.propertyIsEnumerable,Rg=(r,t,e)=>t in r?mP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,bn=(r,t)=>{for(var e in t||(t={}))vP.call(t,e)&&Rg(r,e,t[e]);if(Pg)for(var e of Pg(t))_P.call(t,e)&&Rg(r,e,t[e]);return r},Fg=(r,t)=>gP(r,yP(t)),bP=(r,t,e)=>new Promise((n,i)=>{var s=l=>{try{a(e.next(l))}catch(u){i(u)}},o=l=>{try{a(e.throw(l))}catch(u){i(u)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,o);a((e=e.apply(r,t)).next())});function $s(r){return Math.pow(r,2.2)}var wP=class{get name(){return"VRMMaterialsV0CompatPlugin"}constructor(r){var t;this.parser=r,this._renderQueueMapTransparent=new Map,this._renderQueueMapTransparentZWrite=new Map;const e=this.parser.json;e.extensionsUsed=(t=e.extensionsUsed)!=null?t:[],e.extensionsUsed.indexOf("KHR_texture_transform")===-1&&e.extensionsUsed.push("KHR_texture_transform")}beforeRoot(){return bP(this,null,function*(){var r;const t=this.parser.json,e=(r=t.extensions)==null?void 0:r.VRM,n=e==null?void 0:e.materialProperties;n&&(this._populateRenderQueueMap(n),n.forEach((i,s)=>{var o,a;const l=(o=t.materials)==null?void 0:o[s];if(l==null){console.warn(`VRMMaterialsV0CompatPlugin: Attempt to use materials[${s}] of glTF but the material doesn't exist`);return}if(i.shader==="VRM/MToon"){const u=this._parseV0MToonProperties(i,l);t.materials[s]=u}else if((a=i.shader)!=null&&a.startsWith("VRM/Unlit")){const u=this._parseV0UnlitProperties(i,l);t.materials[s]=u}else i.shader==="VRM_USE_GLTFSHADER"||console.warn(`VRMMaterialsV0CompatPlugin: Unknown shader: ${i.shader}`)}))})}_parseV0MToonProperties(r,t){var e,n,i,s,o,a,l,u,c,h,f,d,m,g,p,y,_,S,T,v,E,w,B,N,$,it,I,Z,x,nt,P,C,R,z,U,M,O,j,et,tt,gt,_t,ct,bt,vt,Et,re,ue,b,K,Q,L,D,q,ot;const at=(n=(e=r.keywordMap)==null?void 0:e._ALPHABLEND_ON)!=null?n:!1,ht=((i=r.floatProperties)==null?void 0:i._ZWrite)===1&&at,wt=this._v0ParseRenderQueue(r),ft=(o=(s=r.keywordMap)==null?void 0:s._ALPHATEST_ON)!=null?o:!1,Mt=at?"BLEND":ft?"MASK":"OPAQUE",ge=ft?(l=(a=r.floatProperties)==null?void 0:a._Cutoff)!=null?l:.5:void 0,Ke=((c=(u=r.floatProperties)==null?void 0:u._CullMode)!=null?c:2)===0,sr=this._portTextureTransform(r),cr=((f=(h=r.vectorProperties)==null?void 0:h._Color)!=null?f:[1,1,1,1]).map((cl,hl)=>hl===3?cl:$s(cl)),ln=(d=r.textureProperties)==null?void 0:d._MainTex,Ie=ln!=null?{index:ln,extensions:bn({},sr)}:void 0,yn=(g=(m=r.floatProperties)==null?void 0:m._BumpScale)!=null?g:1,gi=(p=r.textureProperties)==null?void 0:p._BumpMap,Ir=gi!=null?{index:gi,scale:yn,extensions:bn({},sr)}:void 0,yi=((_=(y=r.vectorProperties)==null?void 0:y._EmissionColor)!=null?_:[0,0,0,1]).map($s),Gi=(S=r.textureProperties)==null?void 0:S._EmissionMap,Vo=Gi!=null?{index:Gi,extensions:bn({},sr)}:void 0,kr=((v=(T=r.vectorProperties)==null?void 0:T._ShadeColor)!=null?v:[.97,.81,.86,1]).map($s),Wi=(E=r.textureProperties)==null?void 0:E._ShadeTexture,Yn=Wi!=null?{index:Wi,extensions:bn({},sr)}:void 0;let zr=(B=(w=r.floatProperties)==null?void 0:w._ShadeShift)!=null?B:0,Ns=($=(N=r.floatProperties)==null?void 0:N._ShadeToony)!=null?$:.9;Ns=Fe.lerp(Ns,1,.5+.5*zr),zr=-zr-(1-Ns);const sl=(I=(it=r.floatProperties)==null?void 0:it._IndirectLightIntensity)!=null?I:.1,yc=sl?1-sl:void 0,jo=(Z=r.textureProperties)==null?void 0:Z._SphereAdd,vc=jo!=null?[1,1,1]:void 0,_c=jo!=null?{index:jo}:void 0,bc=(nt=(x=r.floatProperties)==null?void 0:x._RimLightingMix)!=null?nt:0,ol=(P=r.textureProperties)==null?void 0:P._RimTexture,wc=ol!=null?{index:ol,extensions:bn({},sr)}:void 0,xc=((R=(C=r.vectorProperties)==null?void 0:C._RimColor)!=null?R:[0,0,0,1]).map($s),al=(U=(z=r.floatProperties)==null?void 0:z._RimFresnelPower)!=null?U:1,Sc=(O=(M=r.floatProperties)==null?void 0:M._RimLift)!=null?O:0,Tc=["none","worldCoordinates","screenCoordinates"][(et=(j=r.floatProperties)==null?void 0:j._OutlineWidthMode)!=null?et:0];let $o=(gt=(tt=r.floatProperties)==null?void 0:tt._OutlineWidth)!=null?gt:0;$o=.01*$o;const ll=(_t=r.textureProperties)==null?void 0:_t._OutlineWidthTexture,Ic=ll!=null?{index:ll,extensions:bn({},sr)}:void 0,Ec=((bt=(ct=r.vectorProperties)==null?void 0:ct._OutlineColor)!=null?bt:[0,0,0]).map($s),Ac=((Et=(vt=r.floatProperties)==null?void 0:vt._OutlineColorMode)!=null?Et:0)===1?(ue=(re=r.floatProperties)==null?void 0:re._OutlineLightingMix)!=null?ue:1:0,ul=(b=r.textureProperties)==null?void 0:b._UvAnimMaskTexture,Mc=ul!=null?{index:ul,extensions:bn({},sr)}:void 0,Cc=(Q=(K=r.floatProperties)==null?void 0:K._UvAnimScrollX)!=null?Q:0;let Bs=(D=(L=r.floatProperties)==null?void 0:L._UvAnimScrollY)!=null?D:0;Bs!=null&&(Bs=-Bs);const Oc=(ot=(q=r.floatProperties)==null?void 0:q._UvAnimRotation)!=null?ot:0,Pc={specVersion:"1.0",transparentWithZWrite:ht,renderQueueOffsetNumber:wt,shadeColorFactor:kr,shadeMultiplyTexture:Yn,shadingShiftFactor:zr,shadingToonyFactor:Ns,giEqualizationFactor:yc,matcapFactor:vc,matcapTexture:_c,rimLightingMixFactor:bc,rimMultiplyTexture:wc,parametricRimColorFactor:xc,parametricRimFresnelPowerFactor:al,parametricRimLiftFactor:Sc,outlineWidthMode:Tc,outlineWidthFactor:$o,outlineWidthMultiplyTexture:Ic,outlineColorFactor:Ec,outlineLightingMixFactor:Ac,uvAnimationMaskTexture:Mc,uvAnimationScrollXSpeedFactor:Cc,uvAnimationScrollYSpeedFactor:Bs,uvAnimationRotationSpeedFactor:Oc};return Fg(bn({},t),{pbrMetallicRoughness:{baseColorFactor:cr,baseColorTexture:Ie},normalTexture:Ir,emissiveTexture:Vo,emissiveFactor:yi,alphaMode:Mt,alphaCutoff:ge,doubleSided:Ke,extensions:{VRMC_materials_mtoon:Pc}})}_parseV0UnlitProperties(r,t){var e,n,i,s,o;const a=r.shader==="VRM/UnlitTransparentZWrite",l=r.shader==="VRM/UnlitTransparent"||a,u=this._v0ParseRenderQueue(r),c=r.shader==="VRM/UnlitCutout",h=l?"BLEND":c?"MASK":"OPAQUE",f=c?(n=(e=r.floatProperties)==null?void 0:e._Cutoff)!=null?n:.5:void 0,d=this._portTextureTransform(r),m=((s=(i=r.vectorProperties)==null?void 0:i._Color)!=null?s:[1,1,1,1]).map($s),g=(o=r.textureProperties)==null?void 0:o._MainTex,p=g!=null?{index:g,extensions:bn({},d)}:void 0,y={specVersion:"1.0",transparentWithZWrite:a,renderQueueOffsetNumber:u,shadeColorFactor:m,shadeMultiplyTexture:p};return Fg(bn({},t),{pbrMetallicRoughness:{baseColorFactor:m,baseColorTexture:p},alphaMode:h,alphaCutoff:f,extensions:{VRMC_materials_mtoon:y}})}_portTextureTransform(r){var t,e,n,i,s;const o=(t=r.vectorProperties)==null?void 0:t._MainTex;if(o==null)return{};const a=[(e=o==null?void 0:o[0])!=null?e:0,(n=o==null?void 0:o[1])!=null?n:0],l=[(i=o==null?void 0:o[2])!=null?i:1,(s=o==null?void 0:o[3])!=null?s:1];return a[1]=1-l[1]-a[1],{KHR_texture_transform:{offset:a,scale:l}}}_v0ParseRenderQueue(r){var t,e;const n=r.shader==="VRM/UnlitTransparentZWrite",i=((t=r.keywordMap)==null?void 0:t._ALPHABLEND_ON)!=null||r.shader==="VRM/UnlitTransparent"||n,s=((e=r.floatProperties)==null?void 0:e._ZWrite)===1||n;let o=0;if(i){const a=r.renderQueue;a!=null&&(s?o=this._renderQueueMapTransparentZWrite.get(a):o=this._renderQueueMapTransparent.get(a))}return o}_populateRenderQueueMap(r){const t=new Set,e=new Set;r.forEach(n=>{var i,s;const o=n.shader==="VRM/UnlitTransparentZWrite",a=((i=n.keywordMap)==null?void 0:i._ALPHABLEND_ON)!=null||n.shader==="VRM/UnlitTransparent"||o,l=((s=n.floatProperties)==null?void 0:s._ZWrite)===1||o;if(a){const u=n.renderQueue;u!=null&&(l?e.add(u):t.add(u))}}),t.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${t.size} render queues for Transparent materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),e.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${e.size} render queues for TransparentZWrite materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),Array.from(t).sort().forEach((n,i)=>{const s=Math.min(Math.max(i-t.size+1,-9),0);this._renderQueueMapTransparent.set(n,s)}),Array.from(e).sort().forEach((n,i)=>{const s=Math.min(Math.max(i,0),9);this._renderQueueMapTransparentZWrite.set(n,s)})}},Dg=(r,t,e)=>new Promise((n,i)=>{var s=l=>{try{a(e.next(l))}catch(u){i(u)}},o=l=>{try{a(e.throw(l))}catch(u){i(u)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,o);a((e=e.apply(r,t)).next())}),_i=new mt,mh=class extends No{constructor(r){super(),this._attrPosition=new nr(new Float32Array([0,0,0,0,0,0]),3),this._attrPosition.setUsage(w1);const t=new Ui;t.setAttribute("position",this._attrPosition);const e=new ec({color:16711935,depthTest:!1,depthWrite:!1});this._line=new x1(t,e),this.add(this._line),this.constraint=r}updateMatrixWorld(r){_i.setFromMatrixPosition(this.constraint.destination.matrixWorld),this._attrPosition.setXYZ(0,_i.x,_i.y,_i.z),this.constraint.source&&_i.setFromMatrixPosition(this.constraint.source.matrixWorld),this._attrPosition.setXYZ(1,_i.x,_i.y,_i.z),this._attrPosition.needsUpdate=!0,super.updateMatrixWorld(r)}};function Lg(r,t){return t.set(r.elements[12],r.elements[13],r.elements[14])}var xP=new mt,SP=new mt;function TP(r,t){return r.decompose(xP,t,SP),t}function hu(r){return r.invert?r.invert():r.inverse(),r}var Yf=class{constructor(r,t){this.destination=r,this.source=t,this.weight=1}},IP=new mt,EP=new mt,AP=new mt,MP=new ne,CP=new ne,OP=new ne,PP=class extends Yf{get aimAxis(){return this._aimAxis}set aimAxis(r){this._aimAxis=r,this._v3AimAxis.set(r==="PositiveX"?1:r==="NegativeX"?-1:0,r==="PositiveY"?1:r==="NegativeY"?-1:0,r==="PositiveZ"?1:r==="NegativeZ"?-1:0)}get dependencies(){const r=new Set([this.source]);return this.destination.parent&&r.add(this.destination.parent),r}constructor(r,t){super(r,t),this._aimAxis="PositiveX",this._v3AimAxis=new mt(1,0,0),this._dstRestQuat=new ne}setInitState(){this._dstRestQuat.copy(this.destination.quaternion)}update(){this.destination.updateWorldMatrix(!0,!1),this.source.updateWorldMatrix(!0,!1);const r=MP.identity(),t=CP.identity();this.destination.parent&&(TP(this.destination.parent.matrixWorld,r),hu(t.copy(r)));const e=IP.copy(this._v3AimAxis).applyQuaternion(this._dstRestQuat).applyQuaternion(r),n=Lg(this.source.matrixWorld,EP).sub(Lg(this.destination.matrixWorld,AP)).normalize(),i=OP.setFromUnitVectors(e,n).premultiply(t).multiply(r).multiply(this._dstRestQuat);this.destination.quaternion.copy(this._dstRestQuat).slerp(i,this.weight)}};function RP(r,t){const e=[r];let n=r.parent;for(;n!==null;)e.unshift(n),n=n.parent;e.forEach(i=>{t(i)})}var FP=class{constructor(){this._constraints=new Set,this._objectConstraintsMap=new Map}get constraints(){return this._constraints}addConstraint(r){this._constraints.add(r);let t=this._objectConstraintsMap.get(r.destination);t==null&&(t=new Set,this._objectConstraintsMap.set(r.destination,t)),t.add(r)}deleteConstraint(r){this._constraints.delete(r),this._objectConstraintsMap.get(r.destination).delete(r)}setInitState(){const r=new Set,t=new Set;for(const e of this._constraints)this._processConstraint(e,r,t,n=>n.setInitState())}update(){const r=new Set,t=new Set;for(const e of this._constraints)this._processConstraint(e,r,t,n=>n.update())}_processConstraint(r,t,e,n){if(e.has(r))return;if(t.has(r))throw new Error("VRMNodeConstraintManager: Circular dependency detected while updating constraints");t.add(r);const i=r.dependencies;for(const s of i)RP(s,o=>{const a=this._objectConstraintsMap.get(o);if(a)for(const l of a)this._processConstraint(l,t,e,n)});n(r),e.add(r)}},DP=new ne,LP=new ne,NP=class extends Yf{get dependencies(){return new Set([this.source])}constructor(r,t){super(r,t),this._dstRestQuat=new ne,this._invSrcRestQuat=new ne}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),hu(this._invSrcRestQuat.copy(this.source.quaternion))}update(){const r=DP.copy(this._invSrcRestQuat).multiply(this.source.quaternion),t=LP.copy(this._dstRestQuat).multiply(r);this.destination.quaternion.copy(this._dstRestQuat).slerp(t,this.weight)}},BP=new mt,UP=new ne,kP=new ne,zP=class extends Yf{get rollAxis(){return this._rollAxis}set rollAxis(r){this._rollAxis=r,this._v3RollAxis.set(r==="X"?1:0,r==="Y"?1:0,r==="Z"?1:0)}get dependencies(){return new Set([this.source])}constructor(r,t){super(r,t),this._rollAxis="X",this._v3RollAxis=new mt(1,0,0),this._dstRestQuat=new ne,this._invDstRestQuat=new ne,this._invSrcRestQuatMulDstRestQuat=new ne}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),hu(this._invDstRestQuat.copy(this._dstRestQuat)),hu(this._invSrcRestQuatMulDstRestQuat.copy(this.source.quaternion)).multiply(this._dstRestQuat)}update(){const r=UP.copy(this._invDstRestQuat).multiply(this.source.quaternion).multiply(this._invSrcRestQuatMulDstRestQuat),t=BP.copy(this._v3RollAxis).applyQuaternion(r),n=kP.setFromUnitVectors(t,this._v3RollAxis).premultiply(this._dstRestQuat).multiply(r);this.destination.quaternion.copy(this._dstRestQuat).slerp(n,this.weight)}},VP=new Set(["1.0","1.0-beta"]),Tb=class da{get name(){return da.EXTENSION_NAME}constructor(t,e){this.parser=t,this.helperRoot=e==null?void 0:e.helperRoot}afterRoot(t){return Dg(this,null,function*(){t.userData.vrmNodeConstraintManager=yield this._import(t)})}_import(t){return Dg(this,null,function*(){var e;const n=this.parser.json;if(!(((e=n.extensionsUsed)==null?void 0:e.indexOf(da.EXTENSION_NAME))!==-1))return null;const s=new FP,o=yield this.parser.getDependencies("node");return o.forEach((a,l)=>{var u;const c=n.nodes[l],h=(u=c==null?void 0:c.extensions)==null?void 0:u[da.EXTENSION_NAME];if(h==null)return;const f=h.specVersion;if(!VP.has(f)){console.warn(`VRMNodeConstraintLoaderPlugin: Unknown ${da.EXTENSION_NAME} specVersion "${f}"`);return}const d=h.constraint;if(d.roll!=null){const m=this._importRollConstraint(a,o,d.roll);s.addConstraint(m)}else if(d.aim!=null){const m=this._importAimConstraint(a,o,d.aim);s.addConstraint(m)}else if(d.rotation!=null){const m=this._importRotationConstraint(a,o,d.rotation);s.addConstraint(m)}}),t.scene.updateMatrixWorld(),s.setInitState(),s})}_importRollConstraint(t,e,n){const{source:i,rollAxis:s,weight:o}=n,a=e[i],l=new zP(t,a);if(s!=null&&(l.rollAxis=s),o!=null&&(l.weight=o),this.helperRoot){const u=new mh(l);this.helperRoot.add(u)}return l}_importAimConstraint(t,e,n){const{source:i,aimAxis:s,weight:o}=n,a=e[i],l=new PP(t,a);if(s!=null&&(l.aimAxis=s),o!=null&&(l.weight=o),this.helperRoot){const u=new mh(l);this.helperRoot.add(u)}return l}_importRotationConstraint(t,e,n){const{source:i,weight:s}=n,o=e[i],a=new NP(t,o);if(s!=null&&(a.weight=s),this.helperRoot){const l=new mh(a);this.helperRoot.add(l)}return a}};Tb.EXTENSION_NAME="VRMC_node_constraint";var jP=Tb,Rl=(r,t,e)=>new Promise((n,i)=>{var s=l=>{try{a(e.next(l))}catch(u){i(u)}},o=l=>{try{a(e.throw(l))}catch(u){i(u)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,o);a((e=e.apply(r,t)).next())}),qf=class{},gh=new mt,Ji=new mt,Ib=class extends qf{get type(){return"capsule"}constructor(r){var t,e,n,i;super(),this.offset=(t=r==null?void 0:r.offset)!=null?t:new mt(0,0,0),this.tail=(e=r==null?void 0:r.tail)!=null?e:new mt(0,0,0),this.radius=(n=r==null?void 0:r.radius)!=null?n:0,this.inside=(i=r==null?void 0:r.inside)!=null?i:!1}calculateCollision(r,t,e,n){gh.setFromMatrixPosition(r),Ji.subVectors(this.tail,this.offset).applyMatrix4(r),Ji.sub(gh);const i=Ji.lengthSq();n.copy(t).sub(gh);const s=Ji.dot(n);s<=0||(i<=s||Ji.multiplyScalar(s/i),n.sub(Ji));const o=n.length(),a=this.inside?this.radius-e-o:o-e-this.radius;return a<0&&(n.multiplyScalar(1/o),this.inside&&n.negate()),a}},yh=new mt,Ng=new xn,Eb=class extends qf{get type(){return"plane"}constructor(r){var t,e;super(),this.offset=(t=r==null?void 0:r.offset)!=null?t:new mt(0,0,0),this.normal=(e=r==null?void 0:r.normal)!=null?e:new mt(0,0,1)}calculateCollision(r,t,e,n){n.setFromMatrixPosition(r),n.negate().add(t),Ng.getNormalMatrix(r),yh.copy(this.normal).applyNormalMatrix(Ng).normalize();const i=n.dot(yh)-e;return n.copy(yh),i}},$P=new mt,Ab=class extends qf{get type(){return"sphere"}constructor(r){var t,e,n;super(),this.offset=(t=r==null?void 0:r.offset)!=null?t:new mt(0,0,0),this.radius=(e=r==null?void 0:r.radius)!=null?e:0,this.inside=(n=r==null?void 0:r.inside)!=null?n:!1}calculateCollision(r,t,e,n){n.subVectors(t,$P.setFromMatrixPosition(r));const i=n.length(),s=this.inside?this.radius-e-i:i-e-this.radius;return s<0&&(n.multiplyScalar(1/i),this.inside&&n.negate()),s}},wn=new mt,GP=class extends Ui{constructor(r){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new mt,this._currentTail=new mt,this._shape=r,this._attrPos=new nr(new Float32Array(396),3),this.setAttribute("position",this._attrPos),this._attrIndex=new nr(new Uint16Array(264),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let r=!1;const t=this._shape.radius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,r=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),r=!0);const e=wn.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(e)>1e-10&&(this._currentTail.copy(e),r=!0),r&&this._buildPosition()}_buildPosition(){wn.copy(this._currentTail).sub(this._currentOffset);const r=wn.length()/this._currentRadius;for(let n=0;n<=16;n++){const i=n/16*Math.PI;this._attrPos.setXYZ(n,-Math.sin(i),-Math.cos(i),0),this._attrPos.setXYZ(17+n,r+Math.sin(i),Math.cos(i),0),this._attrPos.setXYZ(34+n,-Math.sin(i),0,-Math.cos(i)),this._attrPos.setXYZ(51+n,r+Math.sin(i),0,Math.cos(i))}for(let n=0;n<32;n++){const i=n/16*Math.PI;this._attrPos.setXYZ(68+n,0,Math.sin(i),Math.cos(i)),this._attrPos.setXYZ(100+n,r,Math.sin(i),Math.cos(i))}const t=Math.atan2(wn.y,Math.sqrt(wn.x*wn.x+wn.z*wn.z)),e=-Math.atan2(wn.z,wn.x);this.rotateZ(t),this.rotateY(e),this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let r=0;r<34;r++){const t=(r+1)%34;this._attrIndex.setXY(r*2,r,t),this._attrIndex.setXY(68+r*2,34+r,34+t)}for(let r=0;r<32;r++){const t=(r+1)%32;this._attrIndex.setXY(136+r*2,68+r,68+t),this._attrIndex.setXY(200+r*2,100+r,100+t)}this._attrIndex.needsUpdate=!0}},WP=class extends Ui{constructor(r){super(),this.worldScale=1,this._currentOffset=new mt,this._currentNormal=new mt,this._shape=r,this._attrPos=new nr(new Float32Array(6*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new nr(new Uint16Array(10),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let r=!1;this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),r=!0),this._currentNormal.equals(this._shape.normal)||(this._currentNormal.copy(this._shape.normal),r=!0),r&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,-.5,-.5,0),this._attrPos.setXYZ(1,.5,-.5,0),this._attrPos.setXYZ(2,.5,.5,0),this._attrPos.setXYZ(3,-.5,.5,0),this._attrPos.setXYZ(4,0,0,0),this._attrPos.setXYZ(5,0,0,.25),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this.lookAt(this._currentNormal),this._attrPos.needsUpdate=!0}_buildIndex(){this._attrIndex.setXY(0,0,1),this._attrIndex.setXY(2,1,2),this._attrIndex.setXY(4,2,3),this._attrIndex.setXY(6,3,0),this._attrIndex.setXY(8,4,5),this._attrIndex.needsUpdate=!0}},HP=class extends Ui{constructor(r){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new mt,this._shape=r,this._attrPos=new nr(new Float32Array(32*3*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new nr(new Uint16Array(64*3),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let r=!1;const t=this._shape.radius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,r=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),r=!0),r&&this._buildPosition()}_buildPosition(){for(let r=0;r<32;r++){const t=r/16*Math.PI;this._attrPos.setXYZ(r,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+r,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+r,Math.sin(t),0,Math.cos(t))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let r=0;r<32;r++){const t=(r+1)%32;this._attrIndex.setXY(r*2,r,t),this._attrIndex.setXY(64+r*2,32+r,32+t),this._attrIndex.setXY(128+r*2,64+r,64+t)}this._attrIndex.needsUpdate=!0}},XP=new mt,vh=class extends No{constructor(r){if(super(),this.matrixAutoUpdate=!1,this.collider=r,this.collider.shape instanceof Ab)this._geometry=new HP(this.collider.shape);else if(this.collider.shape instanceof Ib)this._geometry=new GP(this.collider.shape);else if(this.collider.shape instanceof Eb)this._geometry=new WP(this.collider.shape);else throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");const t=new ec({color:16711935,depthTest:!1,depthWrite:!1});this._line=new Ef(this._geometry,t),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(r){this.collider.updateWorldMatrix(!0,!1),this.matrix.copy(this.collider.matrixWorld);const t=this.matrix.elements;this._geometry.worldScale=XP.set(t[0],t[1],t[2]).length(),this._geometry.update(),super.updateMatrixWorld(r)}},YP=class extends Ui{constructor(r){super(),this.worldScale=1,this._currentRadius=0,this._currentTail=new mt,this._springBone=r,this._attrPos=new nr(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new nr(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let r=!1;const t=this._springBone.settings.hitRadius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,r=!0),this._currentTail.equals(this._springBone.initialLocalChildPosition)||(this._currentTail.copy(this._springBone.initialLocalChildPosition),r=!0),r&&this._buildPosition()}_buildPosition(){for(let r=0;r<32;r++){const t=r/16*Math.PI;this._attrPos.setXYZ(r,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+r,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+r,Math.sin(t),0,Math.cos(t))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let r=0;r<32;r++){const t=(r+1)%32;this._attrIndex.setXY(r*2,r,t),this._attrIndex.setXY(64+r*2,32+r,32+t),this._attrIndex.setXY(128+r*2,64+r,64+t)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}},qP=new mt,QP=class extends No{constructor(r){super(),this.matrixAutoUpdate=!1,this.springBone=r,this._geometry=new YP(this.springBone);const t=new ec({color:16776960,depthTest:!1,depthWrite:!1});this._line=new Ef(this._geometry,t),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(r){this.springBone.bone.updateWorldMatrix(!0,!1),this.matrix.copy(this.springBone.bone.matrixWorld);const t=this.matrix.elements;this._geometry.worldScale=qP.set(t[0],t[1],t[2]).length(),this._geometry.update(),super.updateMatrixWorld(r)}},_h=class extends Ca{constructor(r){super(),this.colliderMatrix=new Wn,this.shape=r}updateWorldMatrix(r,t){super.updateWorldMatrix(r,t),ZP(this.colliderMatrix,this.matrixWorld,this.shape.offset)}};function ZP(r,t,e){const n=t.elements;r.copy(t),e&&(r.elements[12]=n[0]*e.x+n[4]*e.y+n[8]*e.z+n[12],r.elements[13]=n[1]*e.x+n[5]*e.y+n[9]*e.z+n[13],r.elements[14]=n[2]*e.x+n[6]*e.y+n[10]*e.z+n[14])}var KP=new Wn;function JP(r){return r.invert?r.invert():r.getInverse(KP.copy(r)),r}var tR=class{constructor(r){this._inverseCache=new Wn,this._shouldUpdateInverse=!0,this.matrix=r;const t={set:(e,n,i)=>(this._shouldUpdateInverse=!0,e[n]=i,!0)};this._originalElements=r.elements,r.elements=new Proxy(r.elements,t)}get inverse(){return this._shouldUpdateInverse&&(JP(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}},bh=new Wn,Gs=new mt,ta=new mt,ea=new mt,ra=new mt,eR=new Wn,rR=class{constructor(r,t,e={},n=[]){this._currentTail=new mt,this._prevTail=new mt,this._boneAxis=new mt,this._worldSpaceBoneLength=0,this._center=null,this._initialLocalMatrix=new Wn,this._initialLocalRotation=new ne,this._initialLocalChildPosition=new mt;var i,s,o,a,l,u;this.bone=r,this.bone.matrixAutoUpdate=!1,this.child=t,this.settings={hitRadius:(i=e.hitRadius)!=null?i:0,stiffness:(s=e.stiffness)!=null?s:1,gravityPower:(o=e.gravityPower)!=null?o:0,gravityDir:(l=(a=e.gravityDir)==null?void 0:a.clone())!=null?l:new mt(0,-1,0),dragForce:(u=e.dragForce)!=null?u:.4},this.colliderGroups=n}get dependencies(){const r=new Set,t=this.bone.parent;t&&r.add(t);for(let e=0;e{t(i)})}function Gd(r,t){r.children.forEach(e=>{t(e)||Gd(e,t)})}function iR(r){var t;const e=new Map;for(const n of r){let i=n;do{const s=((t=e.get(i))!=null?t:0)+1;if(s===r.size)return i;e.set(i,s),i=i.parent}while(i!==null)}return null}var Bg=class{constructor(){this._joints=new Set,this._sortedJoints=[],this._hasWarnedCircularDependency=!1,this._ancestors=[],this._objectSpringBonesMap=new Map,this._isSortedJointsDirty=!1,this._relevantChildrenUpdated=this._relevantChildrenUpdated.bind(this)}get joints(){return this._joints}get springBones(){return console.warn("VRMSpringBoneManager: springBones is deprecated. use joints instead."),this._joints}get colliderGroups(){const r=new Set;return this._joints.forEach(t=>{t.colliderGroups.forEach(e=>{r.add(e)})}),Array.from(r)}get colliders(){const r=new Set;return this.colliderGroups.forEach(t=>{t.colliders.forEach(e=>{r.add(e)})}),Array.from(r)}addJoint(r){this._joints.add(r);let t=this._objectSpringBonesMap.get(r.bone);t==null&&(t=new Set,this._objectSpringBonesMap.set(r.bone,t)),t.add(r),this._isSortedJointsDirty=!0}addSpringBone(r){console.warn("VRMSpringBoneManager: addSpringBone() is deprecated. use addJoint() instead."),this.addJoint(r)}deleteJoint(r){this._joints.delete(r),this._objectSpringBonesMap.get(r.bone).delete(r),this._isSortedJointsDirty=!0}deleteSpringBone(r){console.warn("VRMSpringBoneManager: deleteSpringBone() is deprecated. use deleteJoint() instead."),this.deleteJoint(r)}setInitState(){this._sortJoints();for(let r=0;r{var o,a;return((a=(o=this._objectSpringBonesMap.get(s))==null?void 0:o.size)!=null?a:0)>0?!0:(this._ancestors.push(s),!1)})),this._isSortedJointsDirty=!1}_insertJointSort(r,t,e,n,i){if(e.has(r))return;if(t.has(r)){this._hasWarnedCircularDependency||(console.warn("VRMSpringBoneManager: Circular dependency detected"),this._hasWarnedCircularDependency=!0);return}t.add(r);const s=r.dependencies;for(const o of s){let a=!1,l=null;nR(o,u=>{const c=this._objectSpringBonesMap.get(u);if(c)for(const h of c)a=!0,this._insertJointSort(h,t,e,n,i);else a||(l=u)}),l&&i.add(l)}n.push(r),e.add(r)}_relevantChildrenUpdated(r){var t,e;return((e=(t=this._objectSpringBonesMap.get(r))==null?void 0:t.size)!=null?e:0)>0?!0:(r.updateWorldMatrix(!1,!1),!1)}},Ug="VRMC_springBone_extended_collider",sR=new Set(["1.0","1.0-beta"]),oR=new Set(["1.0"]),Mb=class Qs{get name(){return Qs.EXTENSION_NAME}constructor(t,e){var n;this.parser=t,this.jointHelperRoot=e==null?void 0:e.jointHelperRoot,this.colliderHelperRoot=e==null?void 0:e.colliderHelperRoot,this.useExtendedColliders=(n=e==null?void 0:e.useExtendedColliders)!=null?n:!0}afterRoot(t){return Rl(this,null,function*(){t.userData.vrmSpringBoneManager=yield this._import(t)})}_import(t){return Rl(this,null,function*(){const e=yield this._v1Import(t);if(e!=null)return e;const n=yield this._v0Import(t);return n??null})}_v1Import(t){return Rl(this,null,function*(){var e,n,i,s,o;const a=t.parser.json;if(!(((e=a.extensionsUsed)==null?void 0:e.indexOf(Qs.EXTENSION_NAME))!==-1))return null;const u=new Bg,c=yield t.parser.getDependencies("node"),h=(n=a.extensions)==null?void 0:n[Qs.EXTENSION_NAME];if(!h)return null;const f=h.specVersion;if(!sR.has(f))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Qs.EXTENSION_NAME} specVersion "${f}"`),null;const d=(i=h.colliders)==null?void 0:i.map((g,p)=>{var y,_,S,T,v,E,w,B,N,$,it,I,Z,x,nt;const P=c[g.node];if(P==null)return console.warn(`VRMSpringBoneLoaderPlugin: The collider #${p} attempted to use the node #${g.node} but not found`),null;const C=g.shape,R=(y=g.extensions)==null?void 0:y[Ug];if(this.useExtendedColliders&&R!=null){const z=R.specVersion;if(!oR.has(z))console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Ug} specVersion "${z}". Fallbacking to the ${Qs.EXTENSION_NAME} definition`);else{const U=R.shape;if(U.sphere)return this._importSphereCollider(P,{offset:new mt().fromArray((_=U.sphere.offset)!=null?_:[0,0,0]),radius:(S=U.sphere.radius)!=null?S:0,inside:(T=U.sphere.inside)!=null?T:!1});if(U.capsule)return this._importCapsuleCollider(P,{offset:new mt().fromArray((v=U.capsule.offset)!=null?v:[0,0,0]),radius:(E=U.capsule.radius)!=null?E:0,tail:new mt().fromArray((w=U.capsule.tail)!=null?w:[0,0,0]),inside:(B=U.capsule.inside)!=null?B:!1});if(U.plane)return this._importPlaneCollider(P,{offset:new mt().fromArray((N=U.plane.offset)!=null?N:[0,0,0]),normal:new mt().fromArray(($=U.plane.normal)!=null?$:[0,0,1])})}}if(C.sphere)return this._importSphereCollider(P,{offset:new mt().fromArray((it=C.sphere.offset)!=null?it:[0,0,0]),radius:(I=C.sphere.radius)!=null?I:0,inside:!1});if(C.capsule)return this._importCapsuleCollider(P,{offset:new mt().fromArray((Z=C.capsule.offset)!=null?Z:[0,0,0]),radius:(x=C.capsule.radius)!=null?x:0,tail:new mt().fromArray((nt=C.capsule.tail)!=null?nt:[0,0,0]),inside:!1});throw new Error(`VRMSpringBoneLoaderPlugin: The collider #${p} has no valid shape`)}),m=(s=h.colliderGroups)==null?void 0:s.map((g,p)=>{var y;return{colliders:((y=g.colliders)!=null?y:[]).flatMap(S=>{const T=d==null?void 0:d[S];return T??(console.warn(`VRMSpringBoneLoaderPlugin: The colliderGroup #${p} attempted to use a collider #${S} but not found`),[])}),name:g.name}});return(o=h.springs)==null||o.forEach((g,p)=>{var y;const _=g.joints,S=(y=g.colliderGroups)==null?void 0:y.map(E=>{const w=m==null?void 0:m[E];if(w==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${p} attempted to use a colliderGroup ${E} but not found`);return w}),T=g.center!=null?c[g.center]:void 0;let v;_.forEach(E=>{if(v){const w=v.node,B=c[w],N=E.node,$=c[N],it={hitRadius:v.hitRadius,dragForce:v.dragForce,gravityPower:v.gravityPower,stiffness:v.stiffness,gravityDir:v.gravityDir!=null?new mt().fromArray(v.gravityDir):void 0},I=this._importJoint(B,$,it,S);T&&(I.center=T),u.addJoint(I)}v=E})}),u.setInitState(),u})}_v0Import(t){return Rl(this,null,function*(){var e,n,i;const s=t.parser.json;if(!(((e=s.extensionsUsed)==null?void 0:e.indexOf("VRM"))!==-1))return null;const a=(n=s.extensions)==null?void 0:n.VRM,l=a==null?void 0:a.secondaryAnimation;if(!l)return null;const u=l==null?void 0:l.boneGroups;if(!u)return null;const c=new Bg,h=yield t.parser.getDependencies("node"),f=(i=l.colliderGroups)==null?void 0:i.map(d=>{var m;const g=h[d.node];return{colliders:((m=d.colliders)!=null?m:[]).map((y,_)=>{var S,T,v;const E=new mt(0,0,0);return y.offset&&E.set((S=y.offset.x)!=null?S:0,(T=y.offset.y)!=null?T:0,y.offset.z?-y.offset.z:0),this._importSphereCollider(g,{offset:E,radius:(v=y.radius)!=null?v:0,inside:!1})})}});return u==null||u.forEach((d,m)=>{const g=d.bones;g&&g.forEach(p=>{var y,_,S,T;const v=h[p],E=new mt;d.gravityDir?E.set((y=d.gravityDir.x)!=null?y:0,(_=d.gravityDir.y)!=null?_:0,(S=d.gravityDir.z)!=null?S:0):E.set(0,-1,0);const w=d.center!=null?h[d.center]:void 0,B={hitRadius:d.hitRadius,dragForce:d.dragForce,gravityPower:d.gravityPower,stiffness:d.stiffiness,gravityDir:E},N=(T=d.colliderGroups)==null?void 0:T.map($=>{const it=f==null?void 0:f[$];if(it==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${m} attempted to use a colliderGroup ${$} but not found`);return it});v.traverse($=>{var it;const I=(it=$.children[0])!=null?it:null,Z=this._importJoint($,I,B,N);w&&(Z.center=w),c.addJoint(Z)})})}),t.scene.updateMatrixWorld(),c.setInitState(),c})}_importJoint(t,e,n,i){const s=new rR(t,e,n,i);if(this.jointHelperRoot){const o=new QP(s);this.jointHelperRoot.add(o),o.renderOrder=this.jointHelperRoot.renderOrder}return s}_importSphereCollider(t,e){const n=new Ab(e),i=new _h(n);if(t.add(i),this.colliderHelperRoot){const s=new vh(i);this.colliderHelperRoot.add(s),s.renderOrder=this.colliderHelperRoot.renderOrder}return i}_importCapsuleCollider(t,e){const n=new Ib(e),i=new _h(n);if(t.add(i),this.colliderHelperRoot){const s=new vh(i);this.colliderHelperRoot.add(s),s.renderOrder=this.colliderHelperRoot.renderOrder}return i}_importPlaneCollider(t,e){const n=new Eb(e),i=new _h(n);if(t.add(i),this.colliderHelperRoot){const s=new vh(i);this.colliderHelperRoot.add(s),s.renderOrder=this.colliderHelperRoot.renderOrder}return i}};Mb.EXTENSION_NAME="VRMC_springBone";var aR=Mb,s3=class{get name(){return"VRMLoaderPlugin"}constructor(r,t){var e,n,i,s,o,a,l,u,c,h;this.parser=r;const f=t==null?void 0:t.helperRoot,d=t==null?void 0:t.autoUpdateHumanBones;this.expressionPlugin=(e=t==null?void 0:t.expressionPlugin)!=null?e:new TO(r),this.firstPersonPlugin=(n=t==null?void 0:t.firstPersonPlugin)!=null?n:new EO(r),this.humanoidPlugin=(i=t==null?void 0:t.humanoidPlugin)!=null?i:new FO(r,{helperRoot:f,autoUpdateHumanBones:d}),this.lookAtPlugin=(s=t==null?void 0:t.lookAtPlugin)!=null?s:new YO(r,{helperRoot:f}),this.metaPlugin=(o=t==null?void 0:t.metaPlugin)!=null?o:new ZO(r),this.mtoonMaterialPlugin=(a=t==null?void 0:t.mtoonMaterialPlugin)!=null?a:new dP(r),this.materialsHDREmissiveMultiplierPlugin=(l=t==null?void 0:t.materialsHDREmissiveMultiplierPlugin)!=null?l:new pP(r),this.materialsV0CompatPlugin=(u=t==null?void 0:t.materialsV0CompatPlugin)!=null?u:new wP(r),this.springBonePlugin=(c=t==null?void 0:t.springBonePlugin)!=null?c:new aR(r,{colliderHelperRoot:f,jointHelperRoot:f}),this.nodeConstraintPlugin=(h=t==null?void 0:t.nodeConstraintPlugin)!=null?h:new jP(r,{helperRoot:f})}beforeRoot(){return Cl(this,null,function*(){yield this.materialsV0CompatPlugin.beforeRoot(),yield this.mtoonMaterialPlugin.beforeRoot()})}loadMesh(r){return Cl(this,null,function*(){return yield this.mtoonMaterialPlugin.loadMesh(r)})}getMaterialType(r){const t=this.mtoonMaterialPlugin.getMaterialType(r);return t??null}extendMaterialParams(r,t){return Cl(this,null,function*(){yield this.materialsHDREmissiveMultiplierPlugin.extendMaterialParams(r,t),yield this.mtoonMaterialPlugin.extendMaterialParams(r,t)})}afterRoot(r){return Cl(this,null,function*(){yield this.metaPlugin.afterRoot(r),yield this.humanoidPlugin.afterRoot(r),yield this.expressionPlugin.afterRoot(r),yield this.lookAtPlugin.afterRoot(r),yield this.firstPersonPlugin.afterRoot(r),yield this.springBonePlugin.afterRoot(r),yield this.nodeConstraintPlugin.afterRoot(r),yield this.mtoonMaterialPlugin.afterRoot(r);const t=r.userData.vrmMeta,e=r.userData.vrmHumanoid;if(t&&e){const n=new JO({scene:r.scene,expressionManager:r.userData.vrmExpressionManager,firstPerson:r.userData.vrmFirstPerson,humanoid:e,lookAt:r.userData.vrmLookAt,meta:t,materials:r.userData.vrmMToonMaterials,springBoneManager:r.userData.vrmSpringBoneManager,nodeConstraintManager:r.userData.vrmNodeConstraintManager});r.userData.vrm=n}})}};function lR(r){const t=new Set;return r.traverse(e=>{if(!e.isMesh)return;const n=e;t.add(n)}),t}function kg(r,t,e){if(t.size===1){const o=t.values().next().value;if(o.weight===1)return r[o.index]}const n=new Float32Array(r[0].count*3);let i=0;if(e)i=1;else for(const o of t)i+=o.weight;for(const o of t){const a=r[o.index],l=o.weight/i;for(let u=0;uu.getOrCreate(B)).join(","),E=`${S};${p};${v}`;let w=o.get(E);w==null&&(w=_.clone(),mR(w,T,d),o.set(E,w)),y.geometry.setAttribute("skinIndex",w)}for(const y of f)y.bind(g,new Wn)}}function hR(r){const t=new Set;return r.traverse(e=>{if(!e.isSkinnedMesh)return;const n=e;t.add(n)}),t}function dR(r,t){const e=new Set;for(let n=0;ne)return!1;return!0}var wh=class{constructor(){this._objectIndexMap=new Map,this._index=0}get(r){return this._objectIndexMap.get(r)}getOrCreate(r){let t=this._objectIndexMap.get(r);return t==null&&(t=this._index,this._objectIndexMap.set(r,t),this._index++),t}};function zg(r){if(Object.values(r).forEach(t=>{t!=null&&t.isTexture&&t.dispose()}),r.isShaderMaterial){const t=r.uniforms;t&&Object.values(t).forEach(e=>{const n=e.value;n!=null&&n.isTexture&&n.dispose()})}r.dispose()}function yR(r){const t=r.geometry;t&&t.dispose();const e=r.skeleton;e&&e.dispose();const n=r.material;n&&(Array.isArray(n)?n.forEach(i=>zg(i)):n&&zg(n))}function vR(r){r.traverse(yR)}function _R(r,t){var e,n;console.warn("VRMUtils.removeUnnecessaryJoints: removeUnnecessaryJoints is deprecated. Use combineSkeletons instead. combineSkeletons contributes more to the performance improvement. This function will be removed in the next major version.");const i=(e=t==null?void 0:t.experimentalSameBoneCounts)!=null?e:!1,s=[];r.traverse(l=>{l.type==="SkinnedMesh"&&s.push(l)});const o=new Map;let a=0;for(const l of s){const c=l.geometry.getAttribute("skinIndex");if(o.has(c))continue;const h=new Map,f=new Map;for(let d=0;d{var n,i,s,o;if(!e.isMesh)return;const a=e,l=a.geometry,u=l.index;if(u==null)return;const c=t.get(l);if(c!=null){a.geometry=c;return}const h=Object.values(l.attributes)[0].count,f=new Array(h);let d=0;const m=u.array;for(let T=0;T{_.addGroup(T.start,T.count,T.materialIndex)}),_.boundingBox=(i=(n=l.boundingBox)==null?void 0:n.clone())!=null?i:null,_.boundingSphere=(o=(s=l.boundingSphere)==null?void 0:s.clone())!=null?o:null,_.setDrawRange(l.drawRange.start,l.drawRange.count),_.userData=l.userData,t.set(l,_);{const T=u.array,v=new T.constructor(T.length);for(let E=0;E{const v=l.attributes[T];if(v.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");const E=v.array,{itemSize:w,normalized:B}=v,N=new E.constructor(p.length*w);p.forEach(($,it)=>{for(let I=0;I{_.morphAttributes[T]=[];const v=l.morphAttributes[T];for(let E=0;E{for(let x=0;xI===0),_.morphAttributes[T][E]=new nr(it,N,$)}}),S&&(_.morphAttributes={}),a.geometry=_}),Array.from(t.keys()).forEach(e=>{e.dispose()})}function wR(r){var t;((t=r.meta)==null?void 0:t.metaVersion)==="0"&&(r.scene.rotation.y=Math.PI)}var Bo=class{constructor(){}};Bo.combineMorphs=uR;Bo.combineSkeletons=cR;Bo.deepDispose=vR;Bo.removeUnnecessaryJoints=_R;Bo.removeUnnecessaryVertices=bR;Bo.rotateVRM0=wR;/*! + * @pixiv/three-vrm-core v3.3.6 + * The implementation of core features of VRM, for @pixiv/three-vrm + * + * Copyright (c) 2019-2025 pixiv Inc. + * @pixiv/three-vrm-core is distributed under MIT License + * https://github.com/pixiv/three-vrm/blob/release/LICENSE + *//*! + * @pixiv/three-vrm-materials-mtoon v3.3.6 + * MToon (toon material) module for @pixiv/three-vrm + * + * Copyright (c) 2019-2025 pixiv Inc. + * @pixiv/three-vrm-materials-mtoon is distributed under MIT License + * https://github.com/pixiv/three-vrm/blob/release/LICENSE + *//*! + * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.3.6 + * Support VRMC_hdr_emissiveMultiplier for @pixiv/three-vrm + * + * Copyright (c) 2019-2025 pixiv Inc. + * @pixiv/three-vrm-materials-hdr-emissive-multiplier is distributed under MIT License + * https://github.com/pixiv/three-vrm/blob/release/LICENSE + *//*! + * @pixiv/three-vrm-materials-v0compat v3.3.6 + * VRM0.0 materials compatibility layer plugin for @pixiv/three-vrm + * + * Copyright (c) 2019-2025 pixiv Inc. + * @pixiv/three-vrm-materials-v0compat is distributed under MIT License + * https://github.com/pixiv/three-vrm/blob/release/LICENSE + *//*! + * @pixiv/three-vrm-node-constraint v3.3.6 + * Node constraint module for @pixiv/three-vrm + * + * Copyright (c) 2019-2025 pixiv Inc. + * @pixiv/three-vrm-node-constraint is distributed under MIT License + * https://github.com/pixiv/three-vrm/blob/release/LICENSE + *//*! + * @pixiv/three-vrm-springbone v3.3.6 + * Spring bone module for @pixiv/three-vrm + * + * Copyright (c) 2019-2025 pixiv Inc. + * @pixiv/three-vrm-springbone is distributed under MIT License + * https://github.com/pixiv/three-vrm/blob/release/LICENSE + *//*! + * @pixiv/three-vrm-animation v3.3.6 + * The implementation of VRM Animation + * + * Copyright (c) 2019-2025 pixiv Inc. + * @pixiv/three-vrm-animation is distributed under MIT License + * https://github.com/pixiv/three-vrm/blob/release/LICENSE + */var Vg=(r,t,e)=>new Promise((n,i)=>{var s=l=>{try{a(e.next(l))}catch(u){i(u)}},o=l=>{try{a(e.throw(l))}catch(u){i(u)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,o);a((e=e.apply(r,t)).next())}),xR={Aa:"aa",Ih:"ih",Ou:"ou",Ee:"ee",Oh:"oh",Blink:"blink",Happy:"happy",Angry:"angry",Sad:"sad",Relaxed:"relaxed",LookUp:"lookUp",Surprised:"surprised",LookDown:"lookDown",LookLeft:"lookLeft",LookRight:"lookRight",BlinkLeft:"blinkLeft",BlinkRight:"blinkRight",Neutral:"neutral"};new qr;new co;new mt;new mt;var jg={hips:null,spine:"hips",chest:"spine",upperChest:"chest",neck:"upperChest",head:"neck",leftEye:"head",rightEye:"head",jaw:"head",leftUpperLeg:"hips",leftLowerLeg:"leftUpperLeg",leftFoot:"leftLowerLeg",leftToes:"leftFoot",rightUpperLeg:"hips",rightLowerLeg:"rightUpperLeg",rightFoot:"rightLowerLeg",rightToes:"rightFoot",leftShoulder:"upperChest",leftUpperArm:"leftShoulder",leftLowerArm:"leftUpperArm",leftHand:"leftLowerArm",rightShoulder:"upperChest",rightUpperArm:"rightShoulder",rightLowerArm:"rightUpperArm",rightHand:"rightLowerArm",leftThumbMetacarpal:"leftHand",leftThumbProximal:"leftThumbMetacarpal",leftThumbDistal:"leftThumbProximal",leftIndexProximal:"leftHand",leftIndexIntermediate:"leftIndexProximal",leftIndexDistal:"leftIndexIntermediate",leftMiddleProximal:"leftHand",leftMiddleIntermediate:"leftMiddleProximal",leftMiddleDistal:"leftMiddleIntermediate",leftRingProximal:"leftHand",leftRingIntermediate:"leftRingProximal",leftRingDistal:"leftRingIntermediate",leftLittleProximal:"leftHand",leftLittleIntermediate:"leftLittleProximal",leftLittleDistal:"leftLittleIntermediate",rightThumbMetacarpal:"rightHand",rightThumbProximal:"rightThumbMetacarpal",rightThumbDistal:"rightThumbProximal",rightIndexProximal:"rightHand",rightIndexIntermediate:"rightIndexProximal",rightIndexDistal:"rightIndexIntermediate",rightMiddleProximal:"rightHand",rightMiddleIntermediate:"rightMiddleProximal",rightMiddleDistal:"rightMiddleIntermediate",rightRingProximal:"rightHand",rightRingIntermediate:"rightRingProximal",rightRingDistal:"rightRingIntermediate",rightLittleProximal:"rightHand",rightLittleIntermediate:"rightLittleProximal",rightLittleDistal:"rightLittleIntermediate"};function SR(r){return r.invert?r.invert():r.inverse(),r}new mt;new mt;new mt;new mt;new mt;new mt(0,1,0);var TR=new mt,IR=new mt;function ER(r,t){return r.matrixWorld.decompose(TR,t,IR),t}function xh(r){return[Math.atan2(-r.z,r.x),Math.atan2(r.y,Math.sqrt(r.x*r.x+r.z*r.z))]}function $g(r){const t=Math.round(r/2/Math.PI);return r-2*Math.PI*t}var Gg=new mt(0,0,1),AR=new mt,MR=new mt,CR=new mt,OR=new ne,Sh=new ne,Wg=new ne,PR=new ne,Th=new Ps,Cb=class Ob{constructor(t,e){this.offsetFromHeadBone=new mt,this.autoUpdate=!0,this.faceFront=new mt(0,0,1),this.humanoid=t,this.applier=e,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new ne)}get yaw(){return this._yaw}set yaw(t){this._yaw=t,this._needsUpdate=!0}get pitch(){return this._pitch}set pitch(t){this._pitch=t,this._needsUpdate=!0}get euler(){return console.warn("VRMLookAt: euler is deprecated. use getEuler() instead."),this.getEuler(new Ps)}getEuler(t){return t.set(Fe.DEG2RAD*this._pitch,Fe.DEG2RAD*this._yaw,0,"YXZ")}copy(t){if(this.humanoid!==t.humanoid)throw new Error("VRMLookAt: humanoid must be same in order to copy");return this.offsetFromHeadBone.copy(t.offsetFromHeadBone),this.applier=t.applier,this.autoUpdate=t.autoUpdate,this.target=t.target,this.faceFront.copy(t.faceFront),this}clone(){return new Ob(this.humanoid,this.applier).copy(this)}reset(){this._yaw=0,this._pitch=0,this._needsUpdate=!0}getLookAtWorldPosition(t){const e=this.humanoid.getRawBoneNode("head");return t.copy(this.offsetFromHeadBone).applyMatrix4(e.matrixWorld)}getLookAtWorldQuaternion(t){const e=this.humanoid.getRawBoneNode("head");return ER(e,t)}getFaceFrontQuaternion(t){if(this.faceFront.distanceToSquared(Gg)<.01)return t.copy(this._restHeadWorldQuaternion).invert();const[e,n]=xh(this.faceFront);return Th.set(0,.5*Math.PI+e,n,"YZX"),t.setFromEuler(Th).premultiply(PR.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(t){return this.getLookAtWorldQuaternion(Sh),this.getFaceFrontQuaternion(Wg),t.copy(Gg).applyQuaternion(Sh).applyQuaternion(Wg).applyEuler(this.getEuler(Th))}lookAt(t){const e=OR.copy(this._restHeadWorldQuaternion).multiply(SR(this.getLookAtWorldQuaternion(Sh))),n=this.getLookAtWorldPosition(MR),i=CR.copy(t).sub(n).applyQuaternion(e).normalize(),[s,o]=xh(this.faceFront),[a,l]=xh(i),u=$g(a-s),c=$g(o-l);this._yaw=Fe.RAD2DEG*u,this._pitch=Fe.RAD2DEG*c,this._needsUpdate=!0}update(t){this.target!=null&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(AR)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};Cb.EULER_ORDER="YXZ";var RR=Cb;new mt(0,0,1);new Ps(0,0,0,"YXZ");var Hg=180/Math.PI,Ih=new Ps,Xg=class extends Ca{constructor(r){super(),this.vrmLookAt=r,this.type="VRMLookAtQuaternionProxy";const t=this.rotation._onChangeCallback;this.rotation._onChange(()=>{t(),this._applyToLookAt()});const e=this.quaternion._onChangeCallback;this.quaternion._onChange(()=>{e(),this._applyToLookAt()})}_applyToLookAt(){Ih.setFromQuaternion(this.quaternion,RR.EULER_ORDER),this.vrmLookAt.yaw=Hg*Ih.y,this.vrmLookAt.pitch=Hg*Ih.x}};function FR(r,t,e){var n,i;const s=new Map,o=new Map;for(const[a,l]of r.humanoidTracks.rotation.entries()){const u=(n=t.getNormalizedBoneNode(a))==null?void 0:n.name;if(u!=null){const c=new A1(`${u}.quaternion`,l.times,l.values.map((h,f)=>e==="0"&&f%2===0?-h:h));o.set(a,c)}}for(const[a,l]of r.humanoidTracks.translation.entries()){const u=(i=t.getNormalizedBoneNode(a))==null?void 0:i.name;if(u!=null){const c=r.restHipsPosition.y,f=t.normalizedRestPose.hips.position[1]/c,d=l.clone();d.values=d.values.map((m,g)=>(e==="0"&&g%3!==1?-m:m)*f),d.name=`${u}.position`,s.set(a,d)}}return{translation:s,rotation:o}}function DR(r,t){const e=new Map,n=new Map;for(const[i,s]of r.expressionTracks.preset.entries()){const o=t.getExpressionTrackName(i);if(o!=null){const a=s.clone();a.name=o,e.set(i,a)}}for(const[i,s]of r.expressionTracks.custom.entries()){const o=t.getExpressionTrackName(i);if(o!=null){const a=s.clone();a.name=o,n.set(i,a)}}return{preset:e,custom:n}}function LR(r,t){if(r.lookAtTrack==null)return null;const e=r.lookAtTrack.clone();return e.name=t,e}function o3(r,t){const e=[],n=FR(r,t.humanoid,t.meta.metaVersion);if(e.push(...n.translation.values()),e.push(...n.rotation.values()),t.expressionManager!=null){const i=DR(r,t.expressionManager);e.push(...i.preset.values()),e.push(...i.custom.values())}if(t.lookAt!=null){let i=t.scene.children.find(o=>o instanceof Xg);i==null?(console.warn("createVRMAnimationClip: VRMLookAtQuaternionProxy is not found. Creating a new one automatically. To suppress this warning, create a VRMLookAtQuaternionProxy manually"),i=new Xg(t.lookAt),i.name="VRMLookAtQuaternionProxy",t.scene.add(i)):i.name==null&&(console.warn("createVRMAnimationClip: VRMLookAtQuaternionProxy is found but its name is not set. Setting the name automatically. To suppress this warning, set the name manually"),i.name="VRMLookAtQuaternionProxy");const s=LR(r,`${i.name}.quaternion`);s!=null&&e.push(s)}return new I1("Clip",r.duration,e)}var NR=class{constructor(){this.duration=0,this.restHipsPosition=new mt,this.humanoidTracks={translation:new Map,rotation:new Map},this.expressionTracks={preset:new Map,custom:new Map},this.lookAtTrack=null}};function Yg(r,t){const e=r.length,n=[];let i=[],s=0;for(let o=0;o{const y=i.animations[p],_=this._parseAnimation(g,y,l,u);return _.restHipsPosition=f,_});r.userData.vrmAnimations=m})}_createNodeMap(r){var t,e,n,i,s;const o=new Map,a=new Map,l=(t=r.humanoid)==null?void 0:t.humanBones;l&&Object.entries(l).forEach(([f,d])=>{const m=d==null?void 0:d.node;m!=null&&o.set(m,f)});const u=(e=r.expressions)==null?void 0:e.preset;u&&Object.entries(u).forEach(([f,d])=>{const m=d==null?void 0:d.node;m!=null&&a.set(m,f)});const c=(n=r.expressions)==null?void 0:n.custom;c&&Object.entries(c).forEach(([f,d])=>{const{node:m}=d;a.set(m,f)});const h=(s=(i=r.lookAt)==null?void 0:i.node)!=null?s:null;return{humanoidIndexToName:o,expressionsIndexToName:a,lookAtIndex:h}}_createBoneWorldMatrixMap(r,t){return Vg(this,null,function*(){var e,n;r.scene.updateWorldMatrix(!1,!0);const i=yield r.parser.getDependencies("node"),s=new Map;if(t.humanoid==null)return s;for(const[o,a]of Object.entries(t.humanoid.humanBones)){const l=a==null?void 0:a.node;if(l!=null){const u=i[l];s.set(o,u.matrixWorld),o==="hips"&&s.set("hipsParent",(n=(e=u.parent)==null?void 0:e.matrixWorld)!=null?n:BR)}}return s})}_parseAnimation(r,t,e,n){const i=r.tracks,s=t.channels,o=new NR;return o.duration=r.duration,s.forEach((a,l)=>{const{node:u,path:c}=a.target,h=i[l];if(u==null)return;const f=e.humanoidIndexToName.get(u);if(f!=null){let m=jg[f];for(;m!=null&&n.get(m)==null;)m=jg[m];if(m==null&&(m="hipsParent"),c==="translation")if(f!=="hips")console.warn(`The loading animation contains a translation track for ${f}, which is not permitted in the VRMC_vrm_animation spec. ignoring the track`);else{const g=n.get("hipsParent"),p=Yg(h.values,3).flatMap(_=>na.fromArray(_).applyMatrix4(g).toArray()),y=h.clone();y.values=new Float32Array(p),o.humanoidTracks.translation.set(f,y)}else if(c==="rotation"){const g=n.get(f),p=n.get(m);g.decompose(na,Eh,na),Eh.invert(),p.decompose(na,qg,na);const y=Yg(h.values,4).flatMap(S=>UR.fromArray(S).premultiply(qg).multiply(Eh).toArray()),_=h.clone();_.values=new Float32Array(y),o.humanoidTracks.rotation.set(f,_)}else throw new Error(`Invalid path "${c}"`);return}const d=e.expressionsIndexToName.get(u);if(d!=null){if(c==="translation"){const m=h.times,g=new Float32Array(h.values.length/3);for(let y=0;y=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Rt(r){return this instanceof Rt?(this.v=r,this):new Rt(r)}function br(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(r,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(d){return function(m){return Promise.resolve(m).then(d,h)}}function a(d,m){n[d]&&(i[d]=function(g){return new Promise(function(p,y){s.push([d,g,p,y])>1||l(d,g)})},m&&(i[d]=m(i[d])))}function l(d,m){try{u(n[d](m))}catch(g){f(s[0][3],g)}}function u(d){d.value instanceof Rt?Promise.resolve(d.value.v).then(c,h):f(s[0][2],d)}function c(d){l("next",d)}function h(d){l("throw",d)}function f(d,m){d(m),s.shift(),s.length&&l(s[0][0],s[0][1])}}function Ss(r){var t,e;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,s){t[i]=r[i]?function(o){return(e=!e)?{value:Rt(r[i](o)),done:!1}:s?s(o):o}:s}}function Bn(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof Qg=="function"?Qg(r):r[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(s){e[s]=r[s]&&function(o){return new Promise(function(a,l){o=r[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(u){s({value:u,done:a})},o)}}const VR=new TextDecoder("utf-8"),Wd=r=>VR.decode(r),jR=new TextEncoder,Qf=r=>jR.encode(r),$R=r=>typeof r=="number",Pb=r=>typeof r=="boolean",Ye=r=>typeof r=="function",wr=r=>r!=null&&Object(r)===r,Is=r=>wr(r)&&Ye(r.then),Qa=r=>wr(r)&&Ye(r[Symbol.iterator]),Uo=r=>wr(r)&&Ye(r[Symbol.asyncIterator]),Hd=r=>wr(r)&&wr(r.schema),Rb=r=>wr(r)&&"done"in r&&"value"in r,Fb=r=>wr(r)&&Ye(r.stat)&&$R(r.fd),Db=r=>wr(r)&&Zf(r.body),oc=r=>"_getDOMStream"in r&&"_getNodeStream"in r,GR=r=>wr(r)&&Ye(r.abort)&&Ye(r.getWriter)&&!oc(r),Zf=r=>wr(r)&&Ye(r.cancel)&&Ye(r.getReader)&&!oc(r),WR=r=>wr(r)&&Ye(r.end)&&Ye(r.write)&&Pb(r.writable)&&!oc(r),Lb=r=>wr(r)&&Ye(r.read)&&Ye(r.pipe)&&Pb(r.readable)&&!oc(r),HR=r=>wr(r)&&Ye(r.clear)&&Ye(r.bytes)&&Ye(r.position)&&Ye(r.setPosition)&&Ye(r.capacity)&&Ye(r.getBufferIdentifier)&&Ye(r.createLong),Kf=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function XR(r){const t=r[0]?[r[0]]:[];let e,n,i,s;for(let o,a,l=0,u=0,c=r.length;++lc+h.byteLength,0);let i,s,o,a=0,l=-1;const u=Math.min(t||Number.POSITIVE_INFINITY,n);for(const c=e.length;++lxe(Int32Array,r),Kg=r=>xe(BigInt64Array,r),ce=r=>xe(Uint8Array,r),Xd=r=>(r.next(),r);function*YR(r,t){const e=function*(i){yield i},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Kf?e(t):Qa(t)?t:e(t);return yield*Xd(function*(i){let s=null;do s=i.next(yield xe(r,s));while(!s.done)}(n[Symbol.iterator]())),new r}const qR=r=>YR(Uint8Array,r);function Nb(r,t){return br(this,arguments,function*(){if(Is(t))return yield Rt(yield Rt(yield*Ss(Bn(Nb(r,yield Rt(t))))));const n=function(o){return br(this,arguments,function*(){yield yield Rt(yield Rt(o))})},i=function(o){return br(this,arguments,function*(){yield Rt(yield*Ss(Bn(Xd(function*(a){let l=null;do l=a.next(yield l==null?void 0:l.value);while(!l.done)}(o[Symbol.iterator]())))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Kf?n(t):Qa(t)?i(t):Uo(t)?t:n(t);return yield Rt(yield*Ss(Bn(Xd(function(o){return br(this,arguments,function*(){let a=null;do a=yield Rt(o.next(yield yield Rt(xe(r,a))));while(!a.done)})}(s[Symbol.asyncIterator]()))))),yield Rt(new r)})}const QR=r=>Nb(Uint8Array,r);function Bb(r,t,e){if(r!==0){e=e.slice(0,t);for(let n=-1,i=e.length;++n0)do if(r[e]!==t[e])return!1;while(++e(r.next(),r);function*KR(r){let t,e=!1,n=[],i,s,o,a=0;function l(){return s==="peek"?kn(n,o)[0]:([i,n,a]=kn(n,o),i)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});const u=qR(r)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(o-a)?u.next():u.next(o-a),!t&&i.byteLength>0&&(n.push(i),a+=i.byteLength),t||o<=a)do({cmd:s,size:o}=yield l());while(o0&&(i.push(s),l+=s.byteLength),e||a<=l)do({cmd:o,size:a}=yield yield Rt(u()));while(a0&&(i.push(ce(s)),l+=s.byteLength),e||a<=l)do({cmd:o,size:a}=yield yield Rt(u()));while(a{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return Jt(this,void 0,void 0,function*(){const{reader:e,source:n}=this;e&&(yield e.cancel(t).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(t){return Jt(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};const e=yield this.reader.read();return!e.done&&(e.value=ce(e)),e})}}const Ah=(r,t)=>{const e=i=>n([t,i]);let n;return[t,e,new Promise(i=>(n=i)&&r.once(t,e))]};function rF(r){return br(this,arguments,function*(){const e=[];let n="error",i=!1,s=null,o,a,l=0,u=[],c;function h(){return o==="peek"?kn(u,a)[0]:([c,u,l]=kn(u,a),c)}if({cmd:o,size:a}=(yield yield Rt(null))||{cmd:"read",size:0},r.isTTY)return yield yield Rt(new Uint8Array(0)),yield Rt(null);try{e[0]=Ah(r,"end"),e[1]=Ah(r,"error");do{if(e[2]=Ah(r,"readable"),[n,s]=yield Rt(Promise.race(e.map(d=>d[2]))),n==="error")break;if((i=n==="end")||(Number.isFinite(a-l)?(c=ce(r.read(a-l)),c.byteLength0&&(u.push(c),l+=c.byteLength)),i||a<=l)do({cmd:o,size:a}=yield yield Rt(h()));while(a{for(const[y,_]of d)r.off(y,_);try{const y=r.destroy;y&&y.call(r,m),m=void 0}catch(y){m=y||m}finally{m!=null?p(m):g()}})}})}var je;(function(r){r[r.V1=0]="V1",r[r.V2=1]="V2",r[r.V3=2]="V3",r[r.V4=3]="V4",r[r.V5=4]="V5"})(je||(je={}));var lr;(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(lr||(lr={}));var ar;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(ar||(ar={}));var nn;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(nn||(nn={}));var Vt;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(Vt||(Vt={}));var zn;(function(r){r[r.YEAR_MONTH=0]="YEAR_MONTH",r[r.DAY_TIME=1]="DAY_TIME",r[r.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(zn||(zn={}));const Mh=2,Pn=4,oi=4,_e=4,Ti=new Int32Array(2),Jg=new Float32Array(Ti.buffer),ty=new Float64Array(Ti.buffer),Dl=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Yd;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(Yd||(Yd={}));let Mo=class Ub{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new Ub(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){Jg[0]=e,this.writeInt32(t,Ti[0])}writeFloat64(t,e){ty[0]=e,this.writeInt32(t,Ti[Dl?0:1]),this.writeInt32(t+4,Ti[Dl?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=t);const n=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space=0&&this.vtable[e]==0;e--);const n=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);const i=2;this.addInt16(t-this.object_start);const s=(n+i)*Mh;this.addInt16(s);let o=0;const a=this.space;t:for(e=0;e=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,Pn+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const n=this.bb.capacity()-t,i=n-this.bb.readInt32(n);if(!(e=0;n--)t.addInt32(e[n]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,n){return vr.startUnion(t),vr.addMode(t,e),vr.addTypeIds(t,n),vr.endUnion(t)}}let ay=class _a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8(t,e){return(e||new _a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+_e),(e||new _a).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return _a.startUtf8(t),_a.endUtf8(t)}};var Ee;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.FloatingPoint=3]="FloatingPoint",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct_=13]="Struct_",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.LargeList=21]="LargeList",r[r.RunEndEncoded=22]="RunEndEncoded"})(Ee||(Ee={}));let Wr=class Hl{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsField(t,e){return(e||new Hl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+_e),(e||new Hl).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}nullable(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):Ee.NONE}type(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){const e=this.bb.__offset(this.bb_pos,12);return e?(t||new ai).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){const n=this.bb.__offset(this.bb_pos,14);return n?(e||new Hl).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}childrenLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,16);return n?(e||new qe).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,e){t.addFieldOffset(0,e,0)}static addNullable(t,e){t.addFieldInt8(1,+e,0)}static addTypeType(t,e){t.addFieldInt8(2,e,Ee.NONE)}static addType(t,e){t.addFieldOffset(3,e,0)}static addDictionary(t,e){t.addFieldOffset(4,e,0)}static addChildren(t,e){t.addFieldOffset(5,e,0)}static createChildrenVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startChildrenVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(6,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endField(t){return t.endObject()}},In=class Zn{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(t,e){return(e||new Zn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+_e),(e||new Zn).__init(t.readInt32(t.position())+t.position(),t)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Co.Little}fields(t,e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new Wr).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}fieldsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new qe).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+t*8):BigInt(0)}featuresLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,e){t.addFieldInt16(0,e,Co.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startFieldsVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(2,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static addFeatures(t,e){t.addFieldOffset(3,e,0)}static createFeaturesVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startFeaturesVector(t,e){t.startVector(8,e,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,e){t.finish(e)}static finishSizePrefixedSchemaBuffer(t,e){t.finish(e,void 0,!0)}static createSchema(t,e,n,i,s){return Zn.startSchema(t),Zn.addEndianness(t,e),Zn.addFields(t,n),Zn.addCustomMetadata(t,i),Zn.addFeatures(t,s),Zn.endSchema(t)}};var me;(function(r){r[r.NONE=0]="NONE",r[r.Schema=1]="Schema",r[r.DictionaryBatch=2]="DictionaryBatch",r[r.RecordBatch=3]="RecordBatch",r[r.Tensor=4]="Tensor",r[r.SparseTensor=5]="SparseTensor"})(me||(me={}));var k;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.Float=3]="Float",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct=13]="Struct",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.Dictionary=-1]="Dictionary",r[r.Int8=-2]="Int8",r[r.Int16=-3]="Int16",r[r.Int32=-4]="Int32",r[r.Int64=-5]="Int64",r[r.Uint8=-6]="Uint8",r[r.Uint16=-7]="Uint16",r[r.Uint32=-8]="Uint32",r[r.Uint64=-9]="Uint64",r[r.Float16=-10]="Float16",r[r.Float32=-11]="Float32",r[r.Float64=-12]="Float64",r[r.DateDay=-13]="DateDay",r[r.DateMillisecond=-14]="DateMillisecond",r[r.TimestampSecond=-15]="TimestampSecond",r[r.TimestampMillisecond=-16]="TimestampMillisecond",r[r.TimestampMicrosecond=-17]="TimestampMicrosecond",r[r.TimestampNanosecond=-18]="TimestampNanosecond",r[r.TimeSecond=-19]="TimeSecond",r[r.TimeMillisecond=-20]="TimeMillisecond",r[r.TimeMicrosecond=-21]="TimeMicrosecond",r[r.TimeNanosecond=-22]="TimeNanosecond",r[r.DenseUnion=-23]="DenseUnion",r[r.SparseUnion=-24]="SparseUnion",r[r.IntervalDayTime=-25]="IntervalDayTime",r[r.IntervalYearMonth=-26]="IntervalYearMonth",r[r.DurationSecond=-27]="DurationSecond",r[r.DurationMillisecond=-28]="DurationMillisecond",r[r.DurationMicrosecond=-29]="DurationMicrosecond",r[r.DurationNanosecond=-30]="DurationNanosecond"})(k||(k={}));var ni;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(ni||(ni={}));const nF=void 0;function Ba(r){if(r===null)return"null";if(r===nF)return"undefined";switch(typeof r){case"number":return`${r}`;case"bigint":return`${r}`;case"string":return`"${r}"`}return typeof r[Symbol.toPrimitive]=="function"?r[Symbol.toPrimitive]("string"):ArrayBuffer.isView(r)?r instanceof BigInt64Array||r instanceof BigUint64Array?`[${[...r].map(t=>Ba(t))}]`:`[${r}]`:ArrayBuffer.isView(r)?`[${r}]`:JSON.stringify(r,(t,e)=>typeof e=="bigint"?`${e}`:e)}function Te(r){if(typeof r=="bigint"&&(rNumber.MAX_SAFE_INTEGER))throw new TypeError(`${r} is not safe to convert to a number.`);return Number(r)}function $b(r,t){return Te(r/t)+Te(r%t)/Te(t)}const iF=Symbol.for("isArrowBigNum");function pn(r,...t){return t.length===0?Object.setPrototypeOf(xe(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}pn.prototype[iF]=!0;pn.prototype.toJSON=function(){return`"${ka(this)}"`};pn.prototype.valueOf=function(r){return Gb(this,r)};pn.prototype.toString=function(){return ka(this)};pn.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return Gb(this);case"string":return ka(this);case"default":return aF(this)}return ka(this)};function vo(...r){return pn.apply(this,r)}function _o(...r){return pn.apply(this,r)}function Ua(...r){return pn.apply(this,r)}Object.setPrototypeOf(vo.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(_o.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Ua.prototype,Object.create(Uint32Array.prototype));Object.assign(vo.prototype,pn.prototype,{constructor:vo,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(_o.prototype,pn.prototype,{constructor:_o,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Ua.prototype,pn.prototype,{constructor:Ua,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const sF=BigInt(4294967296)*BigInt(4294967296),oF=sF-BigInt(1);function Gb(r,t){const{buffer:e,byteOffset:n,byteLength:i,signed:s}=r,o=new BigUint64Array(e,n,i/8),a=s&&o.at(-1)&BigInt(1)<=0)return Ch(r);t=t.slice();let n=1;for(let s=0;s(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(Ot.prototype);let Ri=class extends Ot{constructor(){super(k.Null)}toString(){return"Null"}};Xb=Symbol.toStringTag;Ri[Xb]=(r=>r[Symbol.toStringTag]="Null")(Ri.prototype);let Es=class extends Ot{constructor(t,e){super(k.Int),this.isSigned=t,this.bitWidth=e}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}};Yb=Symbol.toStringTag;Es[Yb]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(Es.prototype);class za extends Es{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(za.prototype,"ArrayType",{value:Int32Array});let mu=class extends Ot{constructor(t){super(k.Float),this.precision=t}get ArrayType(){switch(this.precision){case ar.HALF:return Uint16Array;case ar.SINGLE:return Float32Array;case ar.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};qb=Symbol.toStringTag;mu[qb]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(mu.prototype);let gu=class extends Ot{constructor(){super(k.Binary)}toString(){return"Binary"}};Qb=Symbol.toStringTag;gu[Qb]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(gu.prototype);let yu=class extends Ot{constructor(){super(k.LargeBinary)}toString(){return"LargeBinary"}};Zb=Symbol.toStringTag;yu[Zb]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(yu.prototype);let vu=class extends Ot{constructor(){super(k.Utf8)}toString(){return"Utf8"}};Kb=Symbol.toStringTag;vu[Kb]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(vu.prototype);let _u=class extends Ot{constructor(){super(k.LargeUtf8)}toString(){return"LargeUtf8"}};Jb=Symbol.toStringTag;_u[Jb]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(_u.prototype);let bu=class extends Ot{constructor(){super(k.Bool)}toString(){return"Bool"}};tw=Symbol.toStringTag;bu[tw]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(bu.prototype);let wu=class extends Ot{constructor(t,e,n=128){super(k.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};ew=Symbol.toStringTag;wu[ew]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(wu.prototype);let xu=class extends Ot{constructor(t){super(k.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${nn[this.unit]}>`}get ArrayType(){return this.unit===nn.DAY?Int32Array:BigInt64Array}};rw=Symbol.toStringTag;xu[rw]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(xu.prototype);let Su=class extends Ot{constructor(t,e){super(k.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${Vt[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};nw=Symbol.toStringTag;Su[nw]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(Su.prototype);let Tu=class extends Ot{constructor(t,e){super(k.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${Vt[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};iw=Symbol.toStringTag;Tu[iw]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(Tu.prototype);let Iu=class extends Ot{constructor(t){super(k.Interval),this.unit=t}toString(){return`Interval<${zn[this.unit]}>`}};sw=Symbol.toStringTag;Iu[sw]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(Iu.prototype);let Eu=class extends Ot{constructor(t){super(k.Duration),this.unit=t}toString(){return`Duration<${Vt[this.unit]}>`}};ow=Symbol.toStringTag;Eu[ow]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(Eu.prototype);let Au=class extends Ot{constructor(t){super(k.List),this.children=[t]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};aw=Symbol.toStringTag;Au[aw]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(Au.prototype);let dr=class extends Ot{constructor(t){super(k.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};lw=Symbol.toStringTag;dr[lw]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(dr.prototype);let Mu=class extends Ot{constructor(t,e,n){super(k.Union),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}};uw=Symbol.toStringTag;Mu[uw]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(Mu.prototype);let Cu=class extends Ot{constructor(t){super(k.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};cw=Symbol.toStringTag;Cu[cw]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(Cu.prototype);let Ou=class extends Ot{constructor(t,e){super(k.FixedSizeList),this.listSize=t,this.children=[e]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};hw=Symbol.toStringTag;Ou[hw]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(Ou.prototype);let Pu=class extends Ot{constructor(t,e=!1){var n,i,s;if(super(k.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((n=t==null?void 0:t.type)===null||n===void 0)&&n.children)){const o=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");const a=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};dw=Symbol.toStringTag;Pu[dw]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(Pu.prototype);const uF=(r=>()=>++r)(-1);let Oo=class extends Ot{constructor(t,e,n,i){super(k.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=n==null?uF():Te(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}>`}};fw=Symbol.toStringTag;Oo[fw]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(Oo.prototype);function ii(r){const t=r;switch(r.typeId){case k.Decimal:return r.bitWidth/32;case k.Interval:return 1+t.unit;case k.FixedSizeList:return t.listSize;case k.FixedSizeBinary:return t.byteWidth;default:return 1}}let se=class{visitMany(t,...e){return t.map((n,i)=>this.visit(n,...e.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return cF(this,t,e)}getVisitFnByTypeId(t,e=!0){return io(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitLargeUtf8(t,...e){return null}visitBinary(t,...e){return null}visitLargeBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitDuration(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}};function cF(r,t,e=!0){return typeof t=="number"?io(r,t,e):typeof t=="string"&&t in k?io(r,k[t],e):t&&t instanceof Ot?io(r,ly(t),e):t!=null&&t.type&&t.type instanceof Ot?io(r,ly(t.type),e):io(r,k.NONE,e)}function io(r,t,e=!0){let n=null;switch(t){case k.Null:n=r.visitNull;break;case k.Bool:n=r.visitBool;break;case k.Int:n=r.visitInt;break;case k.Int8:n=r.visitInt8||r.visitInt;break;case k.Int16:n=r.visitInt16||r.visitInt;break;case k.Int32:n=r.visitInt32||r.visitInt;break;case k.Int64:n=r.visitInt64||r.visitInt;break;case k.Uint8:n=r.visitUint8||r.visitInt;break;case k.Uint16:n=r.visitUint16||r.visitInt;break;case k.Uint32:n=r.visitUint32||r.visitInt;break;case k.Uint64:n=r.visitUint64||r.visitInt;break;case k.Float:n=r.visitFloat;break;case k.Float16:n=r.visitFloat16||r.visitFloat;break;case k.Float32:n=r.visitFloat32||r.visitFloat;break;case k.Float64:n=r.visitFloat64||r.visitFloat;break;case k.Utf8:n=r.visitUtf8;break;case k.LargeUtf8:n=r.visitLargeUtf8;break;case k.Binary:n=r.visitBinary;break;case k.LargeBinary:n=r.visitLargeBinary;break;case k.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case k.Date:n=r.visitDate;break;case k.DateDay:n=r.visitDateDay||r.visitDate;break;case k.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case k.Timestamp:n=r.visitTimestamp;break;case k.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case k.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case k.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case k.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case k.Time:n=r.visitTime;break;case k.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case k.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case k.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case k.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case k.Decimal:n=r.visitDecimal;break;case k.List:n=r.visitList;break;case k.Struct:n=r.visitStruct;break;case k.Union:n=r.visitUnion;break;case k.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case k.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case k.Dictionary:n=r.visitDictionary;break;case k.Interval:n=r.visitInterval;break;case k.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case k.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case k.Duration:n=r.visitDuration;break;case k.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case k.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case k.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case k.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case k.FixedSizeList:n=r.visitFixedSizeList;break;case k.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error(`Unrecognized type '${k[t]}'`)}function ly(r){switch(r.typeId){case k.Null:return k.Null;case k.Int:{const{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?k.Int8:k.Uint8;case 16:return e?k.Int16:k.Uint16;case 32:return e?k.Int32:k.Uint32;case 64:return e?k.Int64:k.Uint64}return k.Int}case k.Float:switch(r.precision){case ar.HALF:return k.Float16;case ar.SINGLE:return k.Float32;case ar.DOUBLE:return k.Float64}return k.Float;case k.Binary:return k.Binary;case k.LargeBinary:return k.LargeBinary;case k.Utf8:return k.Utf8;case k.LargeUtf8:return k.LargeUtf8;case k.Bool:return k.Bool;case k.Decimal:return k.Decimal;case k.Time:switch(r.unit){case Vt.SECOND:return k.TimeSecond;case Vt.MILLISECOND:return k.TimeMillisecond;case Vt.MICROSECOND:return k.TimeMicrosecond;case Vt.NANOSECOND:return k.TimeNanosecond}return k.Time;case k.Timestamp:switch(r.unit){case Vt.SECOND:return k.TimestampSecond;case Vt.MILLISECOND:return k.TimestampMillisecond;case Vt.MICROSECOND:return k.TimestampMicrosecond;case Vt.NANOSECOND:return k.TimestampNanosecond}return k.Timestamp;case k.Date:switch(r.unit){case nn.DAY:return k.DateDay;case nn.MILLISECOND:return k.DateMillisecond}return k.Date;case k.Interval:switch(r.unit){case zn.DAY_TIME:return k.IntervalDayTime;case zn.YEAR_MONTH:return k.IntervalYearMonth}return k.Interval;case k.Duration:switch(r.unit){case Vt.SECOND:return k.DurationSecond;case Vt.MILLISECOND:return k.DurationMillisecond;case Vt.MICROSECOND:return k.DurationMicrosecond;case Vt.NANOSECOND:return k.DurationNanosecond}return k.Duration;case k.Map:return k.Map;case k.List:return k.List;case k.Struct:return k.Struct;case k.Union:switch(r.mode){case lr.Dense:return k.DenseUnion;case lr.Sparse:return k.SparseUnion}return k.Union;case k.FixedSizeBinary:return k.FixedSizeBinary;case k.FixedSizeList:return k.FixedSizeList;case k.Dictionary:return k.Dictionary}throw new Error(`Unrecognized type '${k[r.typeId]}'`)}se.prototype.visitInt8=null;se.prototype.visitInt16=null;se.prototype.visitInt32=null;se.prototype.visitInt64=null;se.prototype.visitUint8=null;se.prototype.visitUint16=null;se.prototype.visitUint32=null;se.prototype.visitUint64=null;se.prototype.visitFloat16=null;se.prototype.visitFloat32=null;se.prototype.visitFloat64=null;se.prototype.visitDateDay=null;se.prototype.visitDateMillisecond=null;se.prototype.visitTimestampSecond=null;se.prototype.visitTimestampMillisecond=null;se.prototype.visitTimestampMicrosecond=null;se.prototype.visitTimestampNanosecond=null;se.prototype.visitTimeSecond=null;se.prototype.visitTimeMillisecond=null;se.prototype.visitTimeMicrosecond=null;se.prototype.visitTimeNanosecond=null;se.prototype.visitDenseUnion=null;se.prototype.visitSparseUnion=null;se.prototype.visitIntervalDayTime=null;se.prototype.visitIntervalYearMonth=null;se.prototype.visitDuration=null;se.prototype.visitDurationSecond=null;se.prototype.visitDurationMillisecond=null;se.prototype.visitDurationMicrosecond=null;se.prototype.visitDurationNanosecond=null;const pw=new Float64Array(1),Ws=new Uint32Array(pw.buffer);function mw(r){const t=(r&31744)>>10,e=(r&1023)/1024,n=Math.pow(-1,(r&32768)>>15);switch(t){case 31:return n*(e?Number.NaN:1/0);case 0:return n*(e?6103515625e-14*e:0)}return n*Math.pow(2,t-15)*(1+e)}function hF(r){if(r!==r)return 32256;pw[0]=r;const t=(Ws[1]&2147483648)>>16&65535;let e=Ws[1]&2146435072,n=0;return e>=1089470464?Ws[0]>0?e=31744:(e=(e&2080374784)>>16,n=(Ws[1]&1048575)>>10):e<=1056964608?(n=1048576+(Ws[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(Ws[1]&1048575)+512>>10),t|e|n&65535}let jt=class extends se{};function Yt(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}const dF=(r,t,e)=>{r[t]=Math.floor(e/864e5)},gw=(r,t,e,n)=>{if(e+1{const i=r+e;n?t[i>>3]|=1<>3]&=~(1<{r[t]=e},Jf=({values:r},t,e)=>{r[t]=e},yw=({values:r},t,e)=>{r[t]=hF(e)},pF=(r,t,e)=>{switch(r.type.precision){case ar.HALF:return yw(r,t,e);case ar.SINGLE:case ar.DOUBLE:return Jf(r,t,e)}},vw=({values:r},t,e)=>{dF(r,t,e.valueOf())},_w=({values:r},t,e)=>{r[t]=BigInt(e)},mF=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},bw=({values:r,valueOffsets:t},e,n)=>gw(r,t,e,n),ww=({values:r,valueOffsets:t},e,n)=>gw(r,t,e,Qf(n)),gF=(r,t,e)=>{r.type.unit===nn.DAY?vw(r,t,e):_w(r,t,e)},xw=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},Sw=({values:r},t,e)=>{r[t]=BigInt(e)},Tw=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},Iw=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},yF=(r,t,e)=>{switch(r.type.unit){case Vt.SECOND:return xw(r,t,e);case Vt.MILLISECOND:return Sw(r,t,e);case Vt.MICROSECOND:return Tw(r,t,e);case Vt.NANOSECOND:return Iw(r,t,e)}},Ew=({values:r},t,e)=>{r[t]=e},Aw=({values:r},t,e)=>{r[t]=e},Mw=({values:r},t,e)=>{r[t]=e},Cw=({values:r},t,e)=>{r[t]=e},vF=(r,t,e)=>{switch(r.type.unit){case Vt.SECOND:return Ew(r,t,e);case Vt.MILLISECOND:return Aw(r,t,e);case Vt.MICROSECOND:return Mw(r,t,e);case Vt.NANOSECOND:return Cw(r,t,e)}},_F=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},bF=(r,t,e)=>{const n=r.children[0],i=r.valueOffsets,s=sn.getVisitFn(n);if(Array.isArray(e))for(let o=-1,a=i[t],l=i[t+1];a{const n=r.children[0],{valueOffsets:i}=r,s=sn.getVisitFn(n);let{[t]:o,[t+1]:a}=i;const l=e instanceof Map?e.entries():Object.entries(e);for(const u of l)if(s(n,o,u),++o>=a)break},xF=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[s]),SF=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(s)),TF=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(i.name)),IF=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[i.name]),EF=(r,t,e)=>{const n=r.type.children.map(s=>sn.getVisitFn(s.type)),i=e instanceof Map?TF(t,e):e instanceof Ne?SF(t,e):Array.isArray(e)?xF(t,e):IF(t,e);r.type.children.forEach((s,o)=>i(n[o],r.children[o],s,o))},AF=(r,t,e)=>{r.type.mode===lr.Dense?Ow(r,t,e):Pw(r,t,e)},Ow=(r,t,e)=>{const n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];sn.visit(i,r.valueOffsets[t],e)},Pw=(r,t,e)=>{const n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];sn.visit(i,t,e)},MF=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},CF=(r,t,e)=>{r.type.unit===zn.DAY_TIME?Rw(r,t,e):Fw(r,t,e)},Rw=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},Fw=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},Dw=({values:r},t,e)=>{r[t]=e},Lw=({values:r},t,e)=>{r[t]=e},Nw=({values:r},t,e)=>{r[t]=e},Bw=({values:r},t,e)=>{r[t]=e},OF=(r,t,e)=>{switch(r.type.unit){case Vt.SECOND:return Dw(r,t,e);case Vt.MILLISECOND:return Lw(r,t,e);case Vt.MICROSECOND:return Nw(r,t,e);case Vt.NANOSECOND:return Bw(r,t,e)}},PF=(r,t,e)=>{const{stride:n}=r,i=r.children[0],s=sn.getVisitFn(i);if(Array.isArray(e))for(let o=-1,a=t*n;++o`${Ba(t)}: ${Ba(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new RF(this[un],this[bo])}},RF=class{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return te.name)}has(t,e){return t[un].type.children.findIndex(n=>n.name===e)!==-1}getOwnPropertyDescriptor(t,e){if(t[un].type.children.findIndex(n=>n.name===e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const n=t[un].type.children.findIndex(i=>i.name===e);if(n!==-1){const i=xr.visit(t[un].children[n],t[bo]);return Reflect.set(t,e,i),i}}set(t,e,n){const i=t[un].type.children.findIndex(s=>s.name===e);return i!==-1?(sn.visit(t[un].children[i],t[bo],n),Reflect.set(t,e,n)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,n):!1}},Ft=class extends se{};function $t(r){return(t,e)=>t.getValid(e)?r(t,e):null}const DF=(r,t)=>864e5*r[t],LF=(r,t)=>null,Uw=(r,t,e)=>{if(e+1>=t.length)return null;const n=Te(t[e]),i=Te(t[e+1]);return r.subarray(n,i)},NF=({offset:r,values:t},e)=>{const n=r+e;return(t[n>>3]&1<DF(r,t),zw=({values:r},t)=>Te(r[t]),zi=({stride:r,values:t},e)=>t[r*e],BF=({stride:r,values:t},e)=>mw(t[r*e]),Vw=({values:r},t)=>r[t],UF=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),jw=({values:r,valueOffsets:t},e)=>Uw(r,t,e),$w=({values:r,valueOffsets:t},e)=>{const n=Uw(r,t,e);return n!==null?Wd(n):null},kF=({values:r},t)=>r[t],zF=({type:r,values:t},e)=>r.precision!==ar.HALF?t[e]:mw(t[e]),VF=(r,t)=>r.type.unit===nn.DAY?kw(r,t):zw(r,t),Gw=({values:r},t)=>1e3*Te(r[t]),Ww=({values:r},t)=>Te(r[t]),Hw=({values:r},t)=>$b(r[t],BigInt(1e3)),Xw=({values:r},t)=>$b(r[t],BigInt(1e6)),jF=(r,t)=>{switch(r.type.unit){case Vt.SECOND:return Gw(r,t);case Vt.MILLISECOND:return Ww(r,t);case Vt.MICROSECOND:return Hw(r,t);case Vt.NANOSECOND:return Xw(r,t)}},Yw=({values:r},t)=>r[t],qw=({values:r},t)=>r[t],Qw=({values:r},t)=>r[t],Zw=({values:r},t)=>r[t],$F=(r,t)=>{switch(r.type.unit){case Vt.SECOND:return Yw(r,t);case Vt.MILLISECOND:return qw(r,t);case Vt.MICROSECOND:return Qw(r,t);case Vt.NANOSECOND:return Zw(r,t)}},GF=({values:r,stride:t},e)=>lF.decimal(r.subarray(t*e,t*(e+1))),WF=(r,t)=>{const{valueOffsets:e,stride:n,children:i}=r,{[t*n]:s,[t*n+1]:o}=e,l=i[0].slice(s,o-s);return new Ne([l])},HF=(r,t)=>{const{valueOffsets:e,children:n}=r,{[t]:i,[t+1]:s}=e,o=n[0];return new ep(o.slice(i,s-i))},XF=(r,t)=>new tp(r,t),YF=(r,t)=>r.type.mode===lr.Dense?Kw(r,t):Jw(r,t),Kw=(r,t)=>{const e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return xr.visit(n,r.valueOffsets[t])},Jw=(r,t)=>{const e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return xr.visit(n,t)},qF=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},QF=(r,t)=>r.type.unit===zn.DAY_TIME?tx(r,t):ex(r,t),tx=({values:r},t)=>r.subarray(2*t,2*(t+1)),ex=({values:r},t)=>{const e=r[t],n=new Int32Array(2);return n[0]=Math.trunc(e/12),n[1]=Math.trunc(e%12),n},rx=({values:r},t)=>r[t],nx=({values:r},t)=>r[t],ix=({values:r},t)=>r[t],sx=({values:r},t)=>r[t],ZF=(r,t)=>{switch(r.type.unit){case Vt.SECOND:return rx(r,t);case Vt.MILLISECOND:return nx(r,t);case Vt.MICROSECOND:return ix(r,t);case Vt.NANOSECOND:return sx(r,t)}},KF=(r,t)=>{const{stride:e,children:n}=r,s=n[0].slice(t*e,e);return new Ne([s])};Ft.prototype.visitNull=$t(LF);Ft.prototype.visitBool=$t(NF);Ft.prototype.visitInt=$t(kF);Ft.prototype.visitInt8=$t(zi);Ft.prototype.visitInt16=$t(zi);Ft.prototype.visitInt32=$t(zi);Ft.prototype.visitInt64=$t(Vw);Ft.prototype.visitUint8=$t(zi);Ft.prototype.visitUint16=$t(zi);Ft.prototype.visitUint32=$t(zi);Ft.prototype.visitUint64=$t(Vw);Ft.prototype.visitFloat=$t(zF);Ft.prototype.visitFloat16=$t(BF);Ft.prototype.visitFloat32=$t(zi);Ft.prototype.visitFloat64=$t(zi);Ft.prototype.visitUtf8=$t($w);Ft.prototype.visitLargeUtf8=$t($w);Ft.prototype.visitBinary=$t(jw);Ft.prototype.visitLargeBinary=$t(jw);Ft.prototype.visitFixedSizeBinary=$t(UF);Ft.prototype.visitDate=$t(VF);Ft.prototype.visitDateDay=$t(kw);Ft.prototype.visitDateMillisecond=$t(zw);Ft.prototype.visitTimestamp=$t(jF);Ft.prototype.visitTimestampSecond=$t(Gw);Ft.prototype.visitTimestampMillisecond=$t(Ww);Ft.prototype.visitTimestampMicrosecond=$t(Hw);Ft.prototype.visitTimestampNanosecond=$t(Xw);Ft.prototype.visitTime=$t($F);Ft.prototype.visitTimeSecond=$t(Yw);Ft.prototype.visitTimeMillisecond=$t(qw);Ft.prototype.visitTimeMicrosecond=$t(Qw);Ft.prototype.visitTimeNanosecond=$t(Zw);Ft.prototype.visitDecimal=$t(GF);Ft.prototype.visitList=$t(WF);Ft.prototype.visitStruct=$t(XF);Ft.prototype.visitUnion=$t(YF);Ft.prototype.visitDenseUnion=$t(Kw);Ft.prototype.visitSparseUnion=$t(Jw);Ft.prototype.visitDictionary=$t(qF);Ft.prototype.visitInterval=$t(QF);Ft.prototype.visitIntervalDayTime=$t(tx);Ft.prototype.visitIntervalYearMonth=$t(ex);Ft.prototype.visitDuration=$t(ZF);Ft.prototype.visitDurationSecond=$t(rx);Ft.prototype.visitDurationMillisecond=$t(nx);Ft.prototype.visitDurationMicrosecond=$t(ix);Ft.prototype.visitDurationNanosecond=$t(sx);Ft.prototype.visitFixedSizeList=$t(KF);Ft.prototype.visitMap=$t(HF);const xr=new Ft,so=Symbol.for("keys"),wo=Symbol.for("vals"),oo=Symbol.for("kKeysAsStrings"),Kd=Symbol.for("_kKeysAsStrings");let ep=class{constructor(t){return this[so]=new Ne([t.children[0]]).memoize(),this[wo]=t.children[1],new Proxy(this,new t2)}get[oo](){return this[Kd]||(this[Kd]=Array.from(this[so].toArray(),String))}[Symbol.iterator](){return new JF(this[so],this[wo])}get size(){return this[so].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[so],e=this[wo],n={};for(let i=-1,s=t.length;++i`${Ba(t)}: ${Ba(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},JF=class{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),xr.visit(this.vals,t)]})}},t2=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[oo]}has(t,e){return t[oo].includes(e)}getOwnPropertyDescriptor(t,e){if(t[oo].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const n=t[oo].indexOf(e);if(n!==-1){const i=xr.visit(Reflect.get(t,wo),n);return Reflect.set(t,e,i),i}}set(t,e,n){const i=t[oo].indexOf(e);return i!==-1?(sn.visit(Reflect.get(t,wo),i,n),Reflect.set(t,e,n)):Reflect.has(t,e)?Reflect.set(t,e,n):!1}};Object.defineProperties(ep.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[so]:{writable:!0,enumerable:!1,configurable:!1,value:null},[wo]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Kd]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let uy;function ox(r,t,e,n){const{length:i=0}=r;let s=typeof t!="number"?0:t,o=typeof e!="number"?i:e;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),oi&&(o=i),n?n(r,s,o):[s,o]}const rp=(r,t)=>r<0?t+r:r,cy=r=>r!==r;function ko(r){if(typeof r!=="object"||r===null)return cy(r)?cy:e=>e===r;if(r instanceof Date){const e=r.valueOf();return n=>n instanceof Date?n.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?ZR(r,e):!1:r instanceof Map?r2(r):Array.isArray(r)?e2(r):r instanceof Ne?n2(r):i2(r,!0)}function e2(r){const t=[];for(let e=-1,n=r.length;++e!1;const n=[];for(let i=-1,s=e.length;++i{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return s2(r,e);case Map:return hy(r,e,e.keys());case ep:case tp:case Object:case void 0:return hy(r,e,t||Object.keys(e))}return e instanceof Ne?o2(r,e):!1}}function s2(r,t){const e=r.length;if(t.length!==e)return!1;for(let n=-1;++n>n}function Ru(r,t,e){const n=e.byteLength+7&-8;if(r>0||e.byteLength>3):Fu(new np(e,r,t,null,ax)).subarray(0,n)),i}return e}function Fu(r){const t=[];let e=0,n=0,i=0;for(const o of r)o&&(i|=1<0)&&(t[e++]=i);const s=new Uint8Array(t.length+7&-8);return s.set(t),s}let np=class{constructor(t,e,n,i,s){this.bytes=t,this.length=n,this.context=i,this.get=s,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=t+(t%8===0?0:8-t%8);return Jd(r,t,i)+Jd(r,n,e)+l2(r,i>>3,n-i>>3)}function l2(r,t,e){let n=0,i=Math.trunc(t);const s=new DataView(r.buffer,r.byteOffset,r.byteLength),o=e===void 0?r.byteLength:i+e;for(;o-i>=4;)n+=Oh(s.getUint32(i)),i+=4;for(;o-i>=2;)n+=Oh(s.getUint16(i)),i+=2;for(;o-i>=1;)n+=Oh(s.getUint8(i)),i+=1;return n}function Oh(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const u2=-1;let Ae=class tf{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:t}=this;return Ot.isSparseUnion(t)?this.children.some(e=>e.nullable):Ot.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:e,values:n,nullBitmap:i,typeIds:s}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,t)}get nullCount(){if(Ot.isUnion(this.type))return this.children.reduce((n,i)=>n+i.nullCount,0);let t=this._nullCount,e;return t<=u2&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-Jd(e,this.offset,this.offset+this.length)),t}constructor(t,e,n,i,s,o=[],a){this.type=t,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof tf?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=ii(t),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(t){const{type:e}=this;if(Ot.isUnion(e)){const n=e,i=this.children[n.typeIdToChildIndex[this.typeIds[t]]],s=n.mode===lr.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){const n=this.offset+t;return(this.nullBitmap[n>>3]&1<>3;(!s||s.byteLength<=c)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(Ru(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const h=s[c];n=(h&u)!==0,s[c]=e?h|u:h&~u}return n!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,n=this.length,i=this._nullCount,s=this,o=this.children){return new tf(t,e,n,i,s,o,this.dictionary)}slice(t,e){const{stride:n,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,a=i===16?n:1,l=this._sliceBuffers(t,e,n,i);return this.clone(this.type,this.offset+t,e,o,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*t,a*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===k.Null)return this.clone(this.type,0,t,0);const{length:e,nullCount:n}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);i[e>>3]=(1<0&&i.set(Ru(this.offset,e,this.nullBitmap),0);const s=this.buffers;return s[ni.VALIDITY]=i,this.clone(this.type,0,t,n+(t-e),s)}_sliceBuffers(t,e,n,i){let s;const{buffers:o}=this;return(s=o[ni.TYPE])&&(o[ni.TYPE]=s.subarray(t,t+e)),(s=o[ni.OFFSET])&&(o[ni.OFFSET]=s.subarray(t,t+e+1))||(s=o[ni.DATA])&&(o[ni.DATA]=i===6?s:s.subarray(n*t,n*(t+e))),o}_sliceChildren(t,e,n){return t.map(i=>i.slice(e,n))}};Ae.prototype.children=Object.freeze([]);class Sa extends se{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:e,["offset"]:n=0,["length"]:i=0}=t;return new Ae(e,n,i,i)}visitBool(t){const{["type"]:e,["offset"]:n=0}=t,i=ce(t.nullBitmap),s=xe(e.ArrayType,t.data),{["length"]:o=s.length>>3,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Ae(e,n,o,a,[void 0,s,i])}visitInt(t){const{["type"]:e,["offset"]:n=0}=t,i=ce(t.nullBitmap),s=xe(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Ae(e,n,o,a,[void 0,s,i])}visitFloat(t){const{["type"]:e,["offset"]:n=0}=t,i=ce(t.nullBitmap),s=xe(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Ae(e,n,o,a,[void 0,s,i])}visitUtf8(t){const{["type"]:e,["offset"]:n=0}=t,i=ce(t.data),s=ce(t.nullBitmap),o=ia(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Ae(e,n,a,l,[o,i,s])}visitLargeUtf8(t){const{["type"]:e,["offset"]:n=0}=t,i=ce(t.data),s=ce(t.nullBitmap),o=Kg(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Ae(e,n,a,l,[o,i,s])}visitBinary(t){const{["type"]:e,["offset"]:n=0}=t,i=ce(t.data),s=ce(t.nullBitmap),o=ia(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Ae(e,n,a,l,[o,i,s])}visitLargeBinary(t){const{["type"]:e,["offset"]:n=0}=t,i=ce(t.data),s=ce(t.nullBitmap),o=Kg(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Ae(e,n,a,l,[o,i,s])}visitFixedSizeBinary(t){const{["type"]:e,["offset"]:n=0}=t,i=ce(t.nullBitmap),s=xe(e.ArrayType,t.data),{["length"]:o=s.length/ii(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Ae(e,n,o,a,[void 0,s,i])}visitDate(t){const{["type"]:e,["offset"]:n=0}=t,i=ce(t.nullBitmap),s=xe(e.ArrayType,t.data),{["length"]:o=s.length/ii(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Ae(e,n,o,a,[void 0,s,i])}visitTimestamp(t){const{["type"]:e,["offset"]:n=0}=t,i=ce(t.nullBitmap),s=xe(e.ArrayType,t.data),{["length"]:o=s.length/ii(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Ae(e,n,o,a,[void 0,s,i])}visitTime(t){const{["type"]:e,["offset"]:n=0}=t,i=ce(t.nullBitmap),s=xe(e.ArrayType,t.data),{["length"]:o=s.length/ii(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Ae(e,n,o,a,[void 0,s,i])}visitDecimal(t){const{["type"]:e,["offset"]:n=0}=t,i=ce(t.nullBitmap),s=xe(e.ArrayType,t.data),{["length"]:o=s.length/ii(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Ae(e,n,o,a,[void 0,s,i])}visitList(t){const{["type"]:e,["offset"]:n=0,["child"]:i}=t,s=ce(t.nullBitmap),o=ia(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Ae(e,n,a,l,[o,void 0,s],[i])}visitStruct(t){const{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=ce(t.nullBitmap),{length:o=i.reduce((l,{length:u})=>Math.max(l,u),0),nullCount:a=t.nullBitmap?-1:0}=t;return new Ae(e,n,o,a,[void 0,void 0,s],i)}visitUnion(t){const{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=xe(e.ArrayType,t.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=t;if(Ot.isSparseUnion(e))return new Ae(e,n,o,a,[void 0,void 0,void 0,s],i);const l=ia(t.valueOffsets);return new Ae(e,n,o,a,[l,void 0,void 0,s],i)}visitDictionary(t){const{["type"]:e,["offset"]:n=0}=t,i=ce(t.nullBitmap),s=xe(e.indices.ArrayType,t.data),{["dictionary"]:o=new Ne([new Sa().visit({type:e.dictionary})])}=t,{["length"]:a=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Ae(e,n,a,l,[void 0,s,i],[],o)}visitInterval(t){const{["type"]:e,["offset"]:n=0}=t,i=ce(t.nullBitmap),s=xe(e.ArrayType,t.data),{["length"]:o=s.length/ii(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Ae(e,n,o,a,[void 0,s,i])}visitDuration(t){const{["type"]:e,["offset"]:n=0}=t,i=ce(t.nullBitmap),s=xe(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Ae(e,n,o,a,[void 0,s,i])}visitFixedSizeList(t){const{["type"]:e,["offset"]:n=0,["child"]:i=new Sa().visit({type:e.valueType})}=t,s=ce(t.nullBitmap),{["length"]:o=i.length/ii(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Ae(e,n,o,a,[void 0,void 0,s],[i])}visitMap(t){const{["type"]:e,["offset"]:n=0,["child"]:i=new Sa().visit({type:e.childType})}=t,s=ce(t.nullBitmap),o=ia(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Ae(e,n,a,l,[o,void 0,s],[i])}}const c2=new Sa;function le(r){return c2.visit(r)}let dy=class{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndext.nullable)}function lx(r){return r.reduce((t,e)=>t+e.nullCount,0)}function ux(r){return r.reduce((t,e,n)=>(t[n+1]=t[n]+e.length,t),new Uint32Array(r.length+1))}function cx(r,t,e,n){const i=[];for(let s=-1,o=r.length;++s=n)break;if(e>=l+u)continue;if(l>=e&&l+u<=n){i.push(a);continue}const c=Math.max(0,e-l),h=Math.min(n-l,u);i.push(a.slice(c,h-c))}return i.length===0&&i.push(r[0].slice(0,0)),i}function ip(r,t,e,n){let i=0,s=0,o=t.length-1;do{if(i>=o-1)return e0?0:-1}function f2(r,t){const{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(const i of new np(e,r.offset+(t||0),r.length,e,ax)){if(!i)return n;++n}return-1}function Zt(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case k.Union:break;case k.Dictionary:break;default:return f2(r,e)}const n=xr.getVisitFn(r),i=ko(t);for(let s=(e||0)-1,o=r.length;++s{const i=r.data[n];return i.values.subarray(0,i.length)[Symbol.iterator]()});let e=0;return new dy(r.data.length,n=>{const s=r.data[n].length,o=r.slice(e,e+s);return e+=s,new p2(o)})}let p2=class{constructor(t){this.vector=t,this.index=0}next(){return this.indexa.data):t;if(s.length===0||s.some(a=>!(a instanceof Ae)))throw new TypeError("Vector constructor expects an Array of Data instances.");const o=(e=s[0])===null||e===void 0?void 0:e.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:a,set:l,indexOf:u}=mx[o.typeId],c=s[0];this.isValid=h=>sp(c,h),this.get=h=>a(c,h),this.set=(h,f)=>l(c,h,f),this.indexOf=h=>u(c,h),this._offsets=[0,c.length];break}default:Object.setPrototypeOf(this,gx[o.typeId]),this._offsets=ux(s);break}this.data=s,this.type=o,this.stride=ii(o),this.numChildren=(i=(n=o.children)===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,e)=>t+e.byteLength,0)}get nullable(){return h2(this.data)}get nullCount(){return lx(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${k[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(rp(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return op.visit(this)}concat(...t){return new ls(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new ls(ox(this,t,e,({data:n,_offsets:i},s,o)=>cx(n,i,s,o)))}toJSON(){return[...this]}toArray(){const{type:t,data:e,length:n,stride:i,ArrayType:s}=this;switch(t.typeId){case k.Int:case k.Float:case k.Decimal:case k.Time:case k.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,n*i);default:return e.reduce((o,{values:a,length:l})=>(o.array.set(a.subarray(0,l*i),o.offset),o.offset+=l*i,o),{array:new s(n*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var e;return this.getChildAt((e=this.type.children)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&te[t])):null}get isMemoized(){return Ot.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(Ot.isDictionary(this.type)){const t=new fy(this.data[0].dictionary),e=this.data.map(n=>{const i=n.clone();return i.dictionary=t,i});return new ls(e)}return new fy(this)}unmemoize(){if(Ot.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),e=this.data.map(n=>{const i=n.clone();return i.dictionary=t,i});return new ls(e)}return this}};px=Symbol.toStringTag;Ne[px]=(r=>{r.type=Ot.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0;const t=Object.keys(k).map(e=>k[e]).filter(e=>typeof e=="number"&&e!==k.NONE);for(const e of t){const n=xr.getVisitFnByTypeId(e),i=sn.getVisitFnByTypeId(e),s=Lu.getVisitFnByTypeId(e);mx[e]={get:n,set:i,indexOf:s},gx[e]=Object.create(r,{isValid:{value:Du(sp)},get:{value:Du(xr.getVisitFnByTypeId(e))},set:{value:hx(sn.getVisitFnByTypeId(e))},indexOf:{value:dx(Lu.getVisitFnByTypeId(e))}})}return"Vector"})(Ne.prototype);let fy=class yx extends Ne{constructor(t){super(t.data);const e=this.get,n=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){const a=s[o];if(a!==void 0)return a;const l=e.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,a){n.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new yx(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Ne(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};class ef{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,n,i){return t.prep(8,24),t.writeInt64(BigInt(i??0)),t.pad(4),t.writeInt32(n),t.writeInt64(BigInt(e??0)),t.offset()}}class Er{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new Er).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+_e),(e||new Er).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):je.V1}schema(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new In).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new ef).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}dictionariesLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,e){const n=this.bb.__offset(this.bb_pos,10);return n?(e||new ef).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}recordBatchesLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,12);return n?(e||new qe).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,je.V1)}static addSchema(t,e){t.addFieldOffset(1,e,0)}static addDictionaries(t,e){t.addFieldOffset(2,e,0)}static startDictionariesVector(t,e){t.startVector(24,e,8)}static addRecordBatches(t,e){t.addFieldOffset(3,e,0)}static startRecordBatchesVector(t,e){t.startVector(24,e,8)}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}}let Le=class us{constructor(t=[],e,n,i=je.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=rf(this.fields)),this.dictionaries=n,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,e)=>`${e}: ${t}`).join(", ")} }>`}select(t){const e=new Set(t),n=this.fields.filter(i=>e.has(i.name));return new us(n,this.metadata)}selectAt(t){const e=t.map(n=>this.fields[n]).filter(Boolean);return new us(e,this.metadata)}assign(...t){const e=t[0]instanceof us?t[0]:Array.isArray(t[0])?new us(t[0]):new us(t),n=[...this.fields],i=Ll(Ll(new Map,this.metadata),e.metadata),s=e.fields.filter(a=>{const l=n.findIndex(u=>u.name===a.name);return~l?(n[l]=a.clone({metadata:Ll(Ll(new Map,n[l].metadata),a.metadata)}))&&!1:!0}),o=rf(s,new Map);return new us([...n,...s],i,new Map([...this.dictionaries,...o]))}};Le.prototype.fields=null;Le.prototype.metadata=null;Le.prototype.dictionaries=null;class Pe{static new(...t){let[e,n,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:e}=t[0],n===void 0&&(n=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new Pe(`${e}`,n,i,s)}constructor(t,e,n=!1,i){this.name=t,this.type=e,this.nullable=n,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,n,i,s]=t;return!t[0]||typeof t[0]!="object"?[e=this.name,n=this.type,i=this.nullable,s=this.metadata]=t:{name:e=this.name,type:n=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],Pe.new(e,n,i,s)}}Pe.prototype.type=null;Pe.prototype.name=null;Pe.prototype.nullable=null;Pe.prototype.metadata=null;function Ll(r,t){return new Map([...r||new Map,...t||new Map])}function rf(r,t=new Map){for(let e=-1,n=r.length;++e0&&rf(s.children,t)}return t}var m2=kb,g2=Mo;class Va{static decode(t){t=new g2(ce(t));const e=Er.getRootAsFooter(t),n=Le.decode(e.schema(),new Map,e.version());return new y2(n,e)}static encode(t){const e=new m2,n=Le.encode(e,t.schema);Er.startRecordBatchesVector(e,t.numRecordBatches);for(const o of[...t.recordBatches()].slice().reverse())Fi.encode(e,o);const i=e.endVector();Er.startDictionariesVector(e,t.numDictionaries);for(const o of[...t.dictionaryBatches()].slice().reverse())Fi.encode(e,o);const s=e.endVector();return Er.startFooter(e),Er.addSchema(e,n),Er.addVersion(e,je.V5),Er.addRecordBatches(e,i),Er.addDictionaries(e,s),Er.finishFooterBuffer(e,Er.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=je.V5,n,i){this.schema=t,this.version=e,n&&(this._recordBatches=n),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,e=-1,n=this.numRecordBatches;++e=0&&t=0&&t=0&&t=0&&tthis._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return Jt(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){const{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(Be);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Yr.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Yr.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return Jt(this,void 0,void 0,function*(){return yield this.abort(t),Be})}return(t){return Jt(this,void 0,void 0,function*(){return yield this.close(),Be})}read(t){return Jt(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Jt(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((e,n)=>{this.resolvers.push({resolve:e,reject:n})}):Promise.resolve(Be)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class Xl extends v2{write(t){if((t=ce(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Wd(this.toUint8Array(!0)):this.toUint8Array(!1).then(Wd)}toUint8Array(t=!1){return t?kn(this._values)[0]:Jt(this,void 0,void 0,function*(){var e,n,i,s;const o=[];let a=0;try{for(var l=!0,u=Bn(this),c;c=yield u.next(),e=c.done,!e;l=!0){s=c.value,l=!1;const h=s;o.push(h),a+=h.byteLength}}catch(h){n={error:h}}finally{try{!l&&!e&&(i=u.return)&&(yield i.call(u))}finally{if(n)throw n.error}}return kn(o,a)[0]})}}class Nu{constructor(t){t&&(this.source=new _2(Yr.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class Po{constructor(t){t instanceof Po?this.source=t.source:t instanceof Xl?this.source=new ts(Yr.fromAsyncIterable(t)):Lb(t)?this.source=new ts(Yr.fromNodeStream(t)):Zf(t)?this.source=new ts(Yr.fromDOMStream(t)):Db(t)?this.source=new ts(Yr.fromDOMStream(t.body)):Qa(t)?this.source=new ts(Yr.fromIterable(t)):Is(t)?this.source=new ts(Yr.fromAsyncIterable(t)):Uo(t)&&(this.source=new ts(Yr.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class _2{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,e="read"){return this.source.next({cmd:e,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||Be)}return(t){return Object.create(this.source.return&&this.source.return(t)||Be)}}class ts{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return Jt(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return Jt(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Jt(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return Jt(this,arguments,void 0,function*(e,n="read"){return yield this.source.next({cmd:n,size:e})})}throw(t){return Jt(this,void 0,void 0,function*(){const e=this.source.throw&&(yield this.source.throw(t))||Be;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return Jt(this,void 0,void 0,function*(){const e=this.source.return&&(yield this.source.return(t))||Be;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}}class my extends Nu{constructor(t,e){super(),this.position=0,this.buffer=ce(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){const{buffer:e,byteOffset:n}=this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let i=e[3]*n[3];this.buffer[0]=i&65535;let s=i>>>16;return i=e[2]*n[3],s+=i,i=e[3]*n[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0>>16,this.buffer[1]+=e[1]*n[3]+e[2]*n[2]+e[3]*n[1],this.buffer[1]+=e[0]*n[3]+e[1]*n[2]+e[2]*n[1]+e[3]*n[0]<<16,this}_plus(t){const e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]>>0&&++e[1],e[1]>>0&&++e[2],e[2]>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return`${fo(this.buffer[3])} ${fo(this.buffer[2])} ${fo(this.buffer[1])} ${fo(this.buffer[0])}`}static multiply(t,e){return new ti(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new ti(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return ti.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return ti.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){const n=t.startsWith("-"),i=t.length,s=new ti(e);for(let o=n?1:0;o0&&this.readData(t,n)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+e)}readDictionary(t){return this.dictionaries.get(t.id)}}class x2 extends _x{constructor(t,e,n,i,s){super(new Uint8Array(0),e,n,i,s),this.sources=t}readNullBitmap(t,e,{offset:n}=this.nextBufferRange()){return e<=0?new Uint8Array(0):Fu(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return xe(Uint8Array,xe(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return xe(Uint8Array,xe(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){const{sources:n}=this;return Ot.isTimestamp(t)||(Ot.isInt(t)||Ot.isTime(t))&&t.bitWidth===64||Ot.isDuration(t)||Ot.isDate(t)&&t.unit===nn.MILLISECOND?xe(Uint8Array,Ta.convertArray(n[e])):Ot.isDecimal(t)?xe(Uint8Array,w2.convertArray(n[e])):Ot.isBinary(t)||Ot.isLargeBinary(t)||Ot.isFixedSizeBinary(t)?S2(n[e]):Ot.isBool(t)?Fu(n[e]):Ot.isUtf8(t)||Ot.isLargeUtf8(t)?Qf(n[e].join("")):xe(Uint8Array,xe(t.ArrayType,n[e].map(i=>+i)))}}function S2(r){const t=r.join(""),e=new Uint8Array(t.length/2);for(let n=0;n>1]=Number.parseInt(t.slice(n,n+2),16);return e}let Nt=class extends se{compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every((n,i)=>this.compareFields(n,e[i]))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}};function mr(r,t){return t instanceof r.constructor}function Fs(r,t){return r===t||mr(r,t)}function di(r,t){return r===t||mr(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function lc(r,t){return r===t||mr(r,t)&&r.precision===t.precision}function T2(r,t){return r===t||mr(r,t)&&r.byteWidth===t.byteWidth}function up(r,t){return r===t||mr(r,t)&&r.unit===t.unit}function Za(r,t){return r===t||mr(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function Ka(r,t){return r===t||mr(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function I2(r,t){return r===t||mr(r,t)&&r.children.length===t.children.length&&Di.compareManyFields(r.children,t.children)}function E2(r,t){return r===t||mr(r,t)&&r.children.length===t.children.length&&Di.compareManyFields(r.children,t.children)}function cp(r,t){return r===t||mr(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&Di.compareManyFields(r.children,t.children)}function A2(r,t){return r===t||mr(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&Di.visit(r.indices,t.indices)&&Di.visit(r.dictionary,t.dictionary)}function hp(r,t){return r===t||mr(r,t)&&r.unit===t.unit}function Ja(r,t){return r===t||mr(r,t)&&r.unit===t.unit}function M2(r,t){return r===t||mr(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&Di.compareManyFields(r.children,t.children)}function C2(r,t){return r===t||mr(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&Di.compareManyFields(r.children,t.children)}Nt.prototype.visitNull=Fs;Nt.prototype.visitBool=Fs;Nt.prototype.visitInt=di;Nt.prototype.visitInt8=di;Nt.prototype.visitInt16=di;Nt.prototype.visitInt32=di;Nt.prototype.visitInt64=di;Nt.prototype.visitUint8=di;Nt.prototype.visitUint16=di;Nt.prototype.visitUint32=di;Nt.prototype.visitUint64=di;Nt.prototype.visitFloat=lc;Nt.prototype.visitFloat16=lc;Nt.prototype.visitFloat32=lc;Nt.prototype.visitFloat64=lc;Nt.prototype.visitUtf8=Fs;Nt.prototype.visitLargeUtf8=Fs;Nt.prototype.visitBinary=Fs;Nt.prototype.visitLargeBinary=Fs;Nt.prototype.visitFixedSizeBinary=T2;Nt.prototype.visitDate=up;Nt.prototype.visitDateDay=up;Nt.prototype.visitDateMillisecond=up;Nt.prototype.visitTimestamp=Za;Nt.prototype.visitTimestampSecond=Za;Nt.prototype.visitTimestampMillisecond=Za;Nt.prototype.visitTimestampMicrosecond=Za;Nt.prototype.visitTimestampNanosecond=Za;Nt.prototype.visitTime=Ka;Nt.prototype.visitTimeSecond=Ka;Nt.prototype.visitTimeMillisecond=Ka;Nt.prototype.visitTimeMicrosecond=Ka;Nt.prototype.visitTimeNanosecond=Ka;Nt.prototype.visitDecimal=Fs;Nt.prototype.visitList=I2;Nt.prototype.visitStruct=E2;Nt.prototype.visitUnion=cp;Nt.prototype.visitDenseUnion=cp;Nt.prototype.visitSparseUnion=cp;Nt.prototype.visitDictionary=A2;Nt.prototype.visitInterval=hp;Nt.prototype.visitIntervalDayTime=hp;Nt.prototype.visitIntervalYearMonth=hp;Nt.prototype.visitDuration=Ja;Nt.prototype.visitDurationSecond=Ja;Nt.prototype.visitDurationMillisecond=Ja;Nt.prototype.visitDurationMicrosecond=Ja;Nt.prototype.visitDurationNanosecond=Ja;Nt.prototype.visitFixedSizeList=M2;Nt.prototype.visitMap=C2;const Di=new Nt;function nf(r,t){return Di.compareSchemas(r,t)}function Ph(r,t){return O2(r,t.map(e=>e.data.concat()))}function O2(r,t){const e=[...r.fields],n=[],i={numBatches:t.reduce((h,f)=>Math.max(h,f.length),0)};let s=0,o=0,a=-1;const l=t.length;let u,c=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a0&&(n[s++]=le({type:new dr(e),length:o,nullCount:0,children:c.slice()})))}return[r=r.assign(e),n.map(h=>new _r(r,h))]}function P2(r,t,e,n,i){var s;const o=(t+63&-64)>>3;for(let a=-1,l=n.length;++a=t)c===t?e[a]=u:(e[a]=u.slice(0,t),i.numBatches=Math.max(i.numBatches,n[a].unshift(u.slice(t,c-t))));else{const h=r[a];r[a]=h.clone({nullable:!0}),e[a]=(s=u==null?void 0:u._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:le({type:h.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var bx;let Li=class cs{constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new Le([]),this._offsets=[0],this;let i,s;t[0]instanceof Le&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());const o=l=>{if(l){if(l instanceof _r)return[l];if(l instanceof cs)return l.batches;if(l instanceof Ae){if(l.type instanceof dr)return[new _r(new Le(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(u=>o(u));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(u=>o(u));if(typeof l=="object"){const u=Object.keys(l),c=u.map(d=>new Ne([l[d]])),h=i??new Le(u.map((d,m)=>new Pe(String(d),c[m].type,c[m].nullable))),[,f]=Ph(h,c);return f.length===0?[new _r(l)]:f}}}return[]},a=t.flatMap(l=>o(l));if(i=(n=i??((e=a[0])===null||e===void 0?void 0:e.schema))!==null&&n!==void 0?n:new Le([]),!(i instanceof Le))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const l of a){if(!(l instanceof _r))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!nf(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??ux(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,e)=>t+e.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=lx(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(rp(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?op.visit(new Ne(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ + ${this.toArray().join(`, + `)} +]`}concat(...t){const e=this.schema,n=this.data.concat(t.flatMap(({data:i})=>i));return new cs(e,n.map(i=>new _r(e,i)))}slice(t,e){const n=this.schema;[t,e]=ox({length:this.numRows},t,e);const i=cx(this.data,this._offsets,t,e);return new cs(n,i.map(s=>new _r(n,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&tn.children[t]);if(e.length===0){const{type:n}=this.schema.fields[t],i=le({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new Ne(e)}return null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=[...this.batches];if(t>-1&&tthis.getChildAt(u));[s[t],a[t]]=[o,e],[n,i]=Ph(n,a)}return new cs(n,i)}select(t){const e=this.schema.fields.reduce((n,i,s)=>n.set(i.name,s),new Map);return this.selectAt(t.map(n=>e.get(n)).filter(n=>n>-1))}selectAt(t){const e=this.schema.selectAt(t),n=this.batches.map(i=>i.selectAt(t));return new cs(e,n)}assign(t){const e=this.schema.fields,[n,i]=t.schema.fields.reduce((a,l,u)=>{const[c,h]=a,f=e.findIndex(d=>d.name===l.name);return~f?h[f]=u:c.push(u),a},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((a,l)=>[l,i[l]]).map(([a,l])=>l===void 0?this.getChildAt(a):t.getChildAt(l)),...n.map(a=>t.getChildAt(a))].filter(Boolean);return new cs(...Ph(s,o))}};bx=Symbol.toStringTag;Li[bx]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=Du(sp),r.get=Du(xr.getVisitFn(k.Struct)),r.set=hx(sn.getVisitFn(k.Struct)),r.indexOf=dx(Lu.getVisitFn(k.Struct)),"Table"))(Li.prototype);var wx;let _r=class ba{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof Le))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=le({nullCount:0,type:new dr(this.schema.fields),children:this.schema.fields.map(e=>le({type:e.type,nullCount:0}))})]=t,!(this.data instanceof Ae))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=gy(this.schema,this.data.children);break}case 1:{const[e]=t,{fields:n,children:i,length:s}=Object.keys(e).reduce((l,u,c)=>(l.children[c]=e[u],l.length=Math.max(l.length,e[u].length),l.fields[c]=Pe.new({name:u,type:e[u].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),o=new Le(n),a=le({type:new dr(n),length:s,children:i,nullCount:0});[this.schema,this.data]=gy(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=xx(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return xr.visit(this.data,t)}at(t){return this.get(rp(t,this.numRows))}set(t,e){return sn.visit(this.data,t,e)}indexOf(t,e){return Lu.visit(this.data,t,e)}[Symbol.iterator](){return op.visit(new Ne([this.data]))}toArray(){return[...this]}concat(...t){return new Li(this.schema,[this,...t])}slice(t,e){const[n]=new Ne([this.data]).slice(t,e).data;return new ba(this.schema,n)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&ti.name===t),e)}setChildAt(t,e){let n=this.schema,i=this.data;if(t>-1&&ta.name===s);~o&&(i[o]=this.data.children[o])}return new ba(e,le({type:n,length:this.numRows,children:i}))}selectAt(t){const e=this.schema.selectAt(t),n=t.map(s=>this.data.children[s]).filter(Boolean),i=le({type:new dr(e.fields),length:this.numRows,children:n});return new ba(e,i)}};wx=Symbol.toStringTag;_r[wx]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(_r.prototype);function gy(r,t,e=t.reduce((n,i)=>Math.max(n,i.length),0)){var n;const i=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(const[a,l]of r.fields.entries()){const u=t[a];(!u||u.length!==e)&&(i[a]=l.clone({nullable:!0}),s[a]=(n=u==null?void 0:u._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:le({type:l.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(i),le({type:new dr(i),length:e,children:s})]}function xx(r,t,e=new Map){var n,i;if(((n=r==null?void 0:r.length)!==null&&n!==void 0?n:0)>0&&(r==null?void 0:r.length)===(t==null?void 0:t.length))for(let s=-1,o=r.length;++sle({type:i.type})),n=le({type:new dr(t.fields),nullCount:0,children:e});super(t,n)}}let bi=class Sn{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new Sn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+_e),(e||new Sn).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):je.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):me.NONE}header(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,12);return n?(e||new qe).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,je.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,me.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,n,i,s,o){return Sn.startMessage(t),Sn.addVersion(t,e),Sn.addHeaderType(t,n),Sn.addHeader(t,i),Sn.addBodyLength(t,s),Sn.addCustomMetadata(t,o),Sn.endMessage(t)}};class R2 extends se{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return oy.startNull(e),oy.endNull(e)}visitInt(t,e){return Cr.startInt(e),Cr.addBitWidth(e,t.bitWidth),Cr.addIsSigned(e,t.isSigned),Cr.endInt(e)}visitFloat(t,e){return Rn.startFloatingPoint(e),Rn.addPrecision(e,t.precision),Rn.endFloatingPoint(e)}visitBinary(t,e){return ey.startBinary(e),ey.endBinary(e)}visitLargeBinary(t,e){return ny.startLargeBinary(e),ny.endLargeBinary(e)}visitBool(t,e){return ry.startBool(e),ry.endBool(e)}visitUtf8(t,e){return ay.startUtf8(e),ay.endUtf8(e)}visitLargeUtf8(t,e){return iy.startLargeUtf8(e),iy.endLargeUtf8(e)}visitDecimal(t,e){return Js.startDecimal(e),Js.addScale(e,t.scale),Js.addPrecision(e,t.precision),Js.addBitWidth(e,t.bitWidth),Js.endDecimal(e)}visitDate(t,e){return Vl.startDate(e),Vl.addUnit(e,t.unit),Vl.endDate(e)}visitTime(t,e){return Zr.startTime(e),Zr.addUnit(e,t.unit),Zr.addBitWidth(e,t.bitWidth),Zr.endTime(e)}visitTimestamp(t,e){const n=t.timezone&&e.createString(t.timezone)||void 0;return Kr.startTimestamp(e),Kr.addUnit(e,t.unit),n!==void 0&&Kr.addTimezone(e,n),Kr.endTimestamp(e)}visitInterval(t,e){return Fn.startInterval(e),Fn.addUnit(e,t.unit),Fn.endInterval(e)}visitDuration(t,e){return jl.startDuration(e),jl.addUnit(e,t.unit),jl.endDuration(e)}visitList(t,e){return sy.startList(e),sy.endList(e)}visitStruct(t,e){return ys.startStruct_(e),ys.endStruct_(e)}visitUnion(t,e){vr.startTypeIdsVector(e,t.typeIds.length);const n=vr.createTypeIdsVector(e,t.typeIds);return vr.startUnion(e),vr.addMode(e,t.mode),vr.addTypeIds(e,n),vr.endUnion(e)}visitDictionary(t,e){const n=this.visit(t.indices,e);return ai.startDictionaryEncoding(e),ai.addId(e,BigInt(t.id)),ai.addIsOrdered(e,t.isOrdered),n!==void 0&&ai.addIndexType(e,n),ai.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return $l.startFixedSizeBinary(e),$l.addByteWidth(e,t.byteWidth),$l.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Gl.startFixedSizeList(e),Gl.addListSize(e,t.listSize),Gl.endFixedSizeList(e)}visitMap(t,e){return Wl.startMap(e),Wl.addKeysSorted(e,t.keysSorted),Wl.endMap(e)}}const Rh=new R2;function F2(r,t=new Map){return new Le(L2(r,t),Yl(r.metadata),t)}function Sx(r){return new Br(r.count,Tx(r.columns),Ix(r.columns))}function D2(r){return new Vn(Sx(r.data),r.id,r.isDelta)}function L2(r,t){return(r.fields||[]).filter(Boolean).map(e=>Pe.fromJSON(e,t))}function yy(r,t){return(r.children||[]).filter(Boolean).map(e=>Pe.fromJSON(e,t))}function Tx(r){return(r||[]).reduce((t,e)=>[...t,new Ni(e.count,N2(e.VALIDITY)),...Tx(e.children)],[])}function Ix(r,t=[]){for(let e=-1,n=(r||[]).length;++et+ +(e===0),0)}function B2(r,t){let e,n,i,s,o,a;return!t||!(s=r.dictionary)?(o=_y(r,yy(r,t)),i=new Pe(r.name,o,r.nullable,Yl(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?vy(n):new za,a=new Oo(t.get(e),n,e,s.isOrdered),i=new Pe(r.name,a,r.nullable,Yl(r.metadata))):(n=(n=s.indexType)?vy(n):new za,t.set(e,o=_y(r,yy(r,t))),a=new Oo(o,n,e,s.isOrdered),i=new Pe(r.name,a,r.nullable,Yl(r.metadata))),i||null}function Yl(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function vy(r){return new Es(r.isSigned,r.bitWidth)}function _y(r,t){const e=r.type.name;switch(e){case"NONE":return new Ri;case"null":return new Ri;case"binary":return new gu;case"largebinary":return new yu;case"utf8":return new vu;case"largeutf8":return new _u;case"bool":return new bu;case"list":return new Au((t||[])[0]);case"struct":return new dr(t||[]);case"struct_":return new dr(t||[])}switch(e){case"int":{const n=r.type;return new Es(n.isSigned,n.bitWidth)}case"floatingpoint":{const n=r.type;return new mu(ar[n.precision])}case"decimal":{const n=r.type;return new wu(n.scale,n.precision,n.bitWidth)}case"date":{const n=r.type;return new xu(nn[n.unit])}case"time":{const n=r.type;return new Su(Vt[n.unit],n.bitWidth)}case"timestamp":{const n=r.type;return new Tu(Vt[n.unit],n.timezone)}case"interval":{const n=r.type;return new Iu(zn[n.unit])}case"duration":{const n=r.type;return new Eu(Vt[n.unit])}case"union":{const n=r.type,[i,...s]=(n.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new Mu(lr[o],n.typeIds||[],t||[])}case"fixedsizebinary":{const n=r.type;return new Cu(n.byteWidth)}case"fixedsizelist":{const n=r.type;return new Ou(n.listSize,(t||[])[0])}case"map":{const n=r.type;return new Pu((t||[])[0],n.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var U2=kb,k2=Mo;class fr{static fromJSON(t,e){const n=new fr(0,je.V5,e);return n._createHeader=z2(t,e),n}static decode(t){t=new k2(ce(t));const e=bi.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),o=new fr(n,i,s);return o._createHeader=V2(e,s),o}static encode(t){const e=new U2;let n=-1;return t.isSchema()?n=Le.encode(e,t.header()):t.isRecordBatch()?n=Br.encode(e,t.header()):t.isDictionaryBatch()&&(n=Vn.encode(e,t.header())),bi.startMessage(e),bi.addVersion(e,je.V5),bi.addHeader(e,n),bi.addHeaderType(e,t.headerType),bi.addBodyLength(e,BigInt(t.bodyLength)),bi.finishMessageBuffer(e,bi.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof Le)return new fr(0,je.V5,me.Schema,t);if(t instanceof Br)return new fr(e,je.V5,me.RecordBatch,t);if(t instanceof Vn)return new fr(e,je.V5,me.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===me.Schema}isRecordBatch(){return this.headerType===me.RecordBatch}isDictionaryBatch(){return this.headerType===me.DictionaryBatch}constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=Te(t)}}class Br{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,n){this._nodes=e,this._buffers=n,this._length=Te(t)}}class Vn{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,e,n=!1){this._data=t,this._isDelta=n,this._id=Te(e)}}class Ln{constructor(t,e){this.offset=Te(t),this.length=Te(e)}}class Ni{constructor(t,e){this.length=Te(t),this.nullCount=Te(e)}}function z2(r,t){return()=>{switch(t){case me.Schema:return Le.fromJSON(r);case me.RecordBatch:return Br.fromJSON(r);case me.DictionaryBatch:return Vn.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${me[t]}, type: ${t} }`)}}function V2(r,t){return()=>{switch(t){case me.Schema:return Le.decode(r.header(new In),new Map,r.version());case me.RecordBatch:return Br.decode(r.header(new ri),r.version());case me.DictionaryBatch:return Vn.decode(r.header(new Zs),r.version())}throw new Error(`Unrecognized Message type: { name: ${me[t]}, type: ${t} }`)}}Pe.encode=K2;Pe.decode=Q2;Pe.fromJSON=B2;Le.encode=Z2;Le.decode=j2;Le.fromJSON=F2;Br.encode=J2;Br.decode=$2;Br.fromJSON=Sx;Vn.encode=tD;Vn.decode=G2;Vn.fromJSON=D2;Ni.encode=eD;Ni.decode=H2;Ln.encode=rD;Ln.decode=W2;function j2(r,t=new Map,e=je.V5){const n=q2(r,t);return new Le(n,ql(r),t,e)}function $2(r,t=je.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new Br(r.length(),X2(r),Y2(r,t))}function G2(r,t=je.V5){return new Vn(Br.decode(r.data(),t),r.id(),r.isDelta())}function W2(r){return new Ln(r.offset(),r.length())}function H2(r){return new Ni(r.length(),r.nullCount())}function X2(r){const t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++nPe.encode(r,s));In.startFieldsVector(r,e.length);const n=In.createFieldsVector(r,e),i=t.metadata&&t.metadata.size>0?In.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{const a=r.createString(`${s}`),l=r.createString(`${o}`);return qe.startKeyValue(r),qe.addKey(r,a),qe.addValue(r,l),qe.endKeyValue(r)})):-1;return In.startSchema(r),In.addFields(r,n),In.addEndianness(r,nD?Co.Little:Co.Big),i!==-1&&In.addCustomMetadata(r,i),In.endSchema(r)}function K2(r,t){let e=-1,n=-1,i=-1;const s=t.type;let o=t.typeId;Ot.isDictionary(s)?(o=s.dictionary.typeId,i=Rh.visit(s,r),n=Rh.visit(s.dictionary,r)):n=Rh.visit(s,r);const a=(s.children||[]).map(c=>Pe.encode(r,c)),l=Wr.createChildrenVector(r,a),u=t.metadata&&t.metadata.size>0?Wr.createCustomMetadataVector(r,[...t.metadata].map(([c,h])=>{const f=r.createString(`${c}`),d=r.createString(`${h}`);return qe.startKeyValue(r),qe.addKey(r,f),qe.addValue(r,d),qe.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),Wr.startField(r),Wr.addType(r,n),Wr.addTypeType(r,o),Wr.addChildren(r,l),Wr.addNullable(r,!!t.nullable),e!==-1&&Wr.addName(r,e),i!==-1&&Wr.addDictionary(r,i),u!==-1&&Wr.addCustomMetadata(r,u),Wr.endField(r)}function J2(r,t){const e=t.nodes||[],n=t.buffers||[];ri.startNodesVector(r,e.length);for(const o of e.slice().reverse())Ni.encode(r,o);const i=r.endVector();ri.startBuffersVector(r,n.length);for(const o of n.slice().reverse())Ln.encode(r,o);const s=r.endVector();return ri.startRecordBatch(r),ri.addLength(r,BigInt(t.length)),ri.addNodes(r,i),ri.addBuffers(r,s),ri.endRecordBatch(r)}function tD(r,t){const e=Br.encode(r,t.data);return Zs.startDictionaryBatch(r),Zs.addId(r,BigInt(t.id)),Zs.addIsDelta(r,t.isDelta),Zs.addData(r,e),Zs.endDictionaryBatch(r)}function eD(r,t){return jb.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function rD(r,t){return Vb.createBuffer(r,BigInt(t.offset),BigInt(t.length))}const nD=(()=>{const r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})(),fp=r=>`Expected ${me[r]} Message in stream, but was null or length 0.`,pp=r=>`Header pointer of flatbuffer-encoded ${me[r]} Message is null or length 0.`,Ex=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,Ax=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`;class Mx{constructor(t){this.source=t instanceof Nu?t:new Nu(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done||t.value===-1&&(t=this.readMetadataLength()).done||(t=this.readMetadata(t.value)).done?Be:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(fp(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const e=ce(this.source.read(t));if(e.byteLength[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...e(s.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(fp(t));return e.value}readSchema(){const t=me.Schema,e=this.readMessage(t),n=e==null?void 0:e.header();if(!e||!n)throw new Error(pp(t));return n}}const uc=4,sf="ARROW1",ja=new Uint8Array(sf.length);for(let r=0;rthis):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Yr.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Yr.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof tn?t:Hd(t)?cD(t):Fb(t)?fD(t):Is(t)?Jt(this,void 0,void 0,function*(){return yield tn.from(yield t)}):Db(t)||Zf(t)||Lb(t)||Uo(t)?dD(new Po(t)):hD(new Nu(t))}static readAll(t){return t instanceof tn?t.isSync()?Sy(t):Ty(t):Hd(t)||ArrayBuffer.isView(t)||Qa(t)||Rb(t)?Sy(t):Ty(t)}}class Uu extends tn{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return br(this,arguments,function*(){yield Rt(yield*Ss(Bn(this[Symbol.iterator]())))})}}class ku extends tn{constructor(t){super(t),this._impl=t}readAll(){return Jt(this,void 0,void 0,function*(){var t,e,n,i;const s=new Array;try{for(var o=!0,a=Bn(this),l;l=yield a.next(),t=l.done,!t;o=!0){i=l.value,o=!1;const u=i;s.push(u)}}catch(u){e={error:u}}finally{try{!o&&!t&&(n=a.return)&&(yield n.call(a))}finally{if(e)throw e.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class Ox extends Uu{constructor(t){super(t),this._impl=t}}class aD extends ku{constructor(t){super(t),this._impl=t}}class Px{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){const n=this._loadVectors(t,e,this.schema.fields),i=le({type:new dr(this.schema.fields),length:t.length,children:n});return new _r(this.schema,i)}_loadDictionaryBatch(t,e){const{id:n,isDelta:i}=t,{dictionaries:s,schema:o}=this,a=s.get(n),l=o.dictionaries.get(n),u=this._loadVectors(t.data,e,[l]);return(a&&i?a.concat(new Ne(u)):new Ne(u)).memoize()}_loadVectors(t,e,n){return new _x(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}}class zu extends Px{constructor(t,e){super(e),this._reader=Hd(t)?new sD(this._handle=t):new Mx(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=Fx(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):Be}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Be}next(){if(this.closed)return Be;let t;const{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const n=t.header(),i=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const n=t.header(),i=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new dp(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class Vu extends Px{constructor(t,e){super(e),this._reader=new iD(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Jt(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return Jt(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Fx(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return Jt(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):Be})}return(t){return Jt(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Be})}next(){return Jt(this,void 0,void 0,function*(){if(this.closed)return Be;let t;const{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const n=t.header(),i=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const n=t.header(),i=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new dp(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return Jt(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class Rx extends zu{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,e){super(t instanceof my?t:new my(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();const n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){const i=this._reader.readMessage(me.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;const n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){const i=this._reader.readMessage(me.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){const{_handle:t}=this,e=t.size-Cx,n=t.readInt32(e),i=t.readAt(e-n,n);return Va.decode(i)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Jt(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return Jt(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());const n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){const i=yield this._reader.readMessage(me.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return Jt(this,void 0,void 0,function*(){var e;const n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){const i=yield this._reader.readMessage(me.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return Jt(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const e=t.size-Cx,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return Va.decode(i)})}_readNextMessageAndValidate(t){return Jt(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?mp(t)?new Ox(new Rx(r.read())):new Uu(new zu(r)):new Uu(new zu(function*(){}()))}function dD(r){return Jt(this,void 0,void 0,function*(){const t=yield r.peek(tl+7&-8);return t&&t.byteLength>=4?mp(t)?new Ox(new Rx(yield r.read())):new ku(new Vu(r)):new ku(new Vu(function(){return br(this,arguments,function*(){})}()))})}function fD(r){return Jt(this,void 0,void 0,function*(){const{size:t}=yield r.stat(),e=new Bu(r,t);return t>=oD&&mp(yield e.readAt(0,tl+7&-8))?new aD(new lD(e)):new ku(new Vu(e))})}class ke extends se{static assemble(...t){const e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof _r?s.data.children:s.data),n=new ke;return n.visitMany(e(t)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof Ne)return this.visitMany(t.data),this;const{type:e}=t;if(!Ot.isDictionary(e)){const{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(Ot.isUnion(e))this.nodes.push(new Ni(n,0));else{const{nullCount:i}=t;Ot.isNull(e)||dn.call(this,i<=0?new Uint8Array(0):Ru(t.offset,n,t.nullBitmap)),this.nodes.push(new Ni(n,i))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}}function dn(r){const t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new Ln(this._byteLength,t)),this._byteLength+=t,this}function pD(r){var t;const{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(dn.call(this,i),e.mode===lr.Sparse)return of.call(this,r);if(e.mode===lr.Dense){if(r.offset<=0)return dn.call(this,s),of.call(this,r);{const o=new Int32Array(n),a=Object.create(null),l=Object.create(null);for(let u,c,h=-1;++h{const h=e.typeIds[c],f=a[h],d=l[h];return u.slice(f,Math.min(n,d))}))}}return this}function mD(r){let t;return r.nullCount>=r.length?dn.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?dn.call(this,Ru(r.offset,r.length,t)):dn.call(this,Fu(r.values))}function fi(r){return dn.call(this,r.values.subarray(0,r.length*r.stride))}function cc(r){const{length:t,values:e,valueOffsets:n}=r,i=Te(n[0]),s=Te(n[t]),o=Math.min(s-i,e.byteLength-i);return dn.call(this,Bb(-i,t+1,n)),dn.call(this,e.subarray(i,i+o)),this}function gp(r){const{length:t,valueOffsets:e}=r;if(e){const{[0]:n,[t]:i}=e;return dn.call(this,Bb(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function of(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}ke.prototype.visitBool=mD;ke.prototype.visitInt=fi;ke.prototype.visitFloat=fi;ke.prototype.visitUtf8=cc;ke.prototype.visitLargeUtf8=cc;ke.prototype.visitBinary=cc;ke.prototype.visitLargeBinary=cc;ke.prototype.visitFixedSizeBinary=fi;ke.prototype.visitDate=fi;ke.prototype.visitTimestamp=fi;ke.prototype.visitTime=fi;ke.prototype.visitDecimal=fi;ke.prototype.visitList=gp;ke.prototype.visitStruct=of;ke.prototype.visitUnion=pD;ke.prototype.visitInterval=fi;ke.prototype.visitDuration=fi;ke.prototype.visitFixedSizeList=gp;ke.prototype.visitMap=gp;class Dx extends ap{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new Xl,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,wr(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return Is(t)?t.then(e=>this.writeAll(e)):Uo(t)?bp(this,t):_p(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){return t===this._sink||t instanceof Xl?this._sink=t:(this._sink=new Xl,t&&GR(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&WR(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!e||!nf(e,this._schema))&&(e==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof Li&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof _r&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!nf(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof _r?t instanceof dp||this._writeRecordBatch(t):t instanceof Li?this.writeAll(t.batches):Qa(t)&&this.writeAll(t)}_writeMessage(t,e=8){const n=e-1,i=fr.encode(t),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+n&~n,l=a-s-o;return t.headerType===me.RecordBatch?this._recordBatchBlocks.push(new Fi(a,t.bodyLength,this._position)):t.headerType===me.DictionaryBatch&&this._dictionaryBlocks.push(new Fi(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(l)}_write(t){if(this._started){const e=ce(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(fr.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(ja)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=ke.assemble(t),o=new Br(t.numRows,n,i),a=fr.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,n=!1){const{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=ke.assemble(new Ne([t])),l=new Br(t.length,s,o),u=new Vn(l,e,n),c=fr.from(u,i);return this._writeMessage(c)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,n,i;for(let s=-1,o=t.length;++s0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));return this}_writeDictionaries(t){var e,n;for(const[i,s]of t.dictionaries){const o=(e=s==null?void 0:s.data)!==null&&e!==void 0?e:[],a=this._seenDictionaries.get(i),l=(n=this._dictionaryDeltaOffsets.get(i))!==null&&n!==void 0?n:0;if(!a||a.data[0]!==o[0])for(const[u,c]of o.entries())this._writeDictionaryBatch(c,i,u>0);else if(ln.writeAll(i)):Uo(t)?bp(n,t):_p(n,t)}}class vp extends Dx{static writeAll(t){const e=new vp;return Is(t)?t.then(n=>e.writeAll(n)):Uo(t)?bp(e,t):_p(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,n=!1){if(!n&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,n)}_writeFooter(t){const e=Va.encode(new Va(t,je.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}}function _p(r,t){let e=t;t instanceof Li&&(e=t.batches,r.reset(void 0,t.schema));for(const n of e)r.write(n);return r.finish()}function bp(r,t){return Jt(this,void 0,void 0,function*(){var e,n,i,s,o,a,l;try{for(e=!0,n=Bn(t);i=yield n.next(),s=i.done,!s;e=!0){l=i.value,e=!1;const u=l;r.write(u)}}catch(u){o={error:u}}finally{try{!e&&!s&&(a=n.return)&&(yield a.call(n))}finally{if(o)throw o.error}}return r.finish()})}function gD(r,t="stream"){return(t==="stream"?yp:vp).writeAll(r).toUint8Array(!0)}var yD=Object.create,Lx=Object.defineProperty,vD=Object.getOwnPropertyDescriptor,_D=Object.getOwnPropertyNames,bD=Object.getPrototypeOf,wD=Object.prototype.hasOwnProperty,xD=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),SD=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of _D(t))!wD.call(r,i)&&i!==e&&Lx(r,i,{get:()=>t[i],enumerable:!(n=vD(t,i))||n.enumerable});return r},TD=(r,t,e)=>(e=r!=null?yD(bD(r)):{},SD(!r||!r.__esModule?Lx(e,"default",{value:r,enumerable:!0}):e,r)),ID=xD((r,t)=>{t.exports=Worker}),Nx=(r=>(r[r.UNDEFINED=0]="UNDEFINED",r[r.AUTOMATIC=1]="AUTOMATIC",r[r.READ_ONLY=2]="READ_ONLY",r[r.READ_WRITE=3]="READ_WRITE",r))(Nx||{}),ED=(r=>(r[r.IDENTIFIER=0]="IDENTIFIER",r[r.NUMERIC_CONSTANT=1]="NUMERIC_CONSTANT",r[r.STRING_CONSTANT=2]="STRING_CONSTANT",r[r.OPERATOR=3]="OPERATOR",r[r.KEYWORD=4]="KEYWORD",r[r.COMMENT=5]="COMMENT",r))(ED||{}),AD=(r=>(r[r.NONE=0]="NONE",r[r.DEBUG=1]="DEBUG",r[r.INFO=2]="INFO",r[r.WARNING=3]="WARNING",r[r.ERROR=4]="ERROR",r))(AD||{}),MD=(r=>(r[r.NONE=0]="NONE",r[r.CONNECT=1]="CONNECT",r[r.DISCONNECT=2]="DISCONNECT",r[r.OPEN=3]="OPEN",r[r.QUERY=4]="QUERY",r[r.INSTANTIATE=5]="INSTANTIATE",r))(MD||{}),CD=(r=>(r[r.NONE=0]="NONE",r[r.OK=1]="OK",r[r.ERROR=2]="ERROR",r[r.START=3]="START",r[r.RUN=4]="RUN",r[r.CAPTURE=5]="CAPTURE",r))(CD||{}),OD=(r=>(r[r.NONE=0]="NONE",r[r.WEB_WORKER=1]="WEB_WORKER",r[r.NODE_WORKER=2]="NODE_WORKER",r[r.BINDINGS=3]="BINDINGS",r[r.ASYNC_DUCKDB=4]="ASYNC_DUCKDB",r))(OD||{}),PD=class{log(r){}},Bx=class{constructor(r=2){this.level=r}log(r){r.level>=this.level&&console.log(r)}},RD=(r=>(r[r.SUCCESS=0]="SUCCESS",r))(RD||{}),FD=class{constructor(r,t){this._bindings=r,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(r){return r(this._bindings,this._conn)}async query(r){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:r});let t=await this._bindings.runQuery(this._conn,r),e=tn.from(t);return console.assert(e.isSync(),"Reader is not sync"),console.assert(e.isFile(),"Reader is not file"),new Li(e)}async send(r,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:r});let e=await this._bindings.startPendingQuery(this._conn,r,t);for(;e==null;)e=await this._bindings.pollPendingQuery(this._conn);let n=new Ux(this._bindings,this._conn,e),i=await tn.from(n);return console.assert(i.isAsync()),console.assert(i.isStream()),i}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(r){return await this._bindings.getTableNames(this._conn,r)}async prepare(r){let t=await this._bindings.createPrepared(this._conn,r);return new DD(this._bindings,this._conn,t)}async insertArrowTable(r,t){let e=gD(r,"stream");await this.insertArrowFromIPCStream(e,t)}async insertArrowFromIPCStream(r,t){await this._bindings.insertArrowFromIPCStream(this._conn,r,t)}async insertCSVFromPath(r,t){await this._bindings.insertCSVFromPath(this._conn,r,t)}async insertJSONFromPath(r,t){await this._bindings.insertJSONFromPath(this._conn,r,t)}},Ux=class{constructor(r,t,e){this.db=r,this.conn=t,this.header=e,this._first=!0,this._depleted=!1,this._inFlight=null}async next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let r;return this._inFlight!=null?(r=await this._inFlight,this._inFlight=null):r=await this.db.fetchQueryResults(this.conn),this._depleted=r.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:r}}[Symbol.asyncIterator](){return this}},DD=class{constructor(r,t,e){this.bindings=r,this.connectionId=t,this.statementId=e}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...r){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,r),e=tn.from(t);return console.assert(e.isSync()),console.assert(e.isFile()),new Li(e)}async send(...r){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,r),e=new Ux(this.bindings,this.connectionId,t),n=await tn.from(e);return console.assert(n.isAsync()),console.assert(n.isStream()),n}},LD=(r=>(r.CANCEL_PENDING_QUERY="CANCEL_PENDING_QUERY",r.CLOSE_PREPARED="CLOSE_PREPARED",r.COLLECT_FILE_STATISTICS="COLLECT_FILE_STATISTICS",r.REGISTER_OPFS_FILE_NAME="REGISTER_OPFS_FILE_NAME",r.CONNECT="CONNECT",r.COPY_FILE_TO_BUFFER="COPY_FILE_TO_BUFFER",r.COPY_FILE_TO_PATH="COPY_FILE_TO_PATH",r.CREATE_PREPARED="CREATE_PREPARED",r.DISCONNECT="DISCONNECT",r.DROP_FILE="DROP_FILE",r.DROP_FILES="DROP_FILES",r.EXPORT_FILE_STATISTICS="EXPORT_FILE_STATISTICS",r.FETCH_QUERY_RESULTS="FETCH_QUERY_RESULTS",r.FLUSH_FILES="FLUSH_FILES",r.GET_FEATURE_FLAGS="GET_FEATURE_FLAGS",r.GET_TABLE_NAMES="GET_TABLE_NAMES",r.GET_VERSION="GET_VERSION",r.GLOB_FILE_INFOS="GLOB_FILE_INFOS",r.INSERT_ARROW_FROM_IPC_STREAM="INSERT_ARROW_FROM_IPC_STREAM",r.INSERT_CSV_FROM_PATH="IMPORT_CSV_FROM_PATH",r.INSERT_JSON_FROM_PATH="IMPORT_JSON_FROM_PATH",r.INSTANTIATE="INSTANTIATE",r.OPEN="OPEN",r.PING="PING",r.POLL_PENDING_QUERY="POLL_PENDING_QUERY",r.REGISTER_FILE_BUFFER="REGISTER_FILE_BUFFER",r.REGISTER_FILE_HANDLE="REGISTER_FILE_HANDLE",r.REGISTER_FILE_URL="REGISTER_FILE_URL",r.RESET="RESET",r.RUN_PREPARED="RUN_PREPARED",r.RUN_QUERY="RUN_QUERY",r.SEND_PREPARED="SEND_PREPARED",r.START_PENDING_QUERY="START_PENDING_QUERY",r.TOKENIZE="TOKENIZE",r))(LD||{}),ND=(r=>(r.CONNECTION_INFO="CONNECTION_INFO",r.ERROR="ERROR",r.FEATURE_FLAGS="FEATURE_FLAGS",r.FILE_BUFFER="FILE_BUFFER",r.FILE_INFOS="FILE_INFOS",r.FILE_SIZE="FILE_SIZE",r.FILE_STATISTICS="FILE_STATISTICS",r.INSTANTIATE_PROGRESS="INSTANTIATE_PROGRESS",r.LOG="LOG",r.OK="OK",r.PREPARED_STATEMENT_ID="PREPARED_STATEMENT_ID",r.QUERY_PLAN="QUERY_PLAN",r.QUERY_RESULT="QUERY_RESULT",r.QUERY_RESULT_CHUNK="QUERY_RESULT_CHUNK",r.QUERY_RESULT_HEADER="QUERY_RESULT_HEADER",r.QUERY_RESULT_HEADER_OR_NULL="QUERY_RESULT_HEADER_OR_NULL",r.REGISTERED_FILE="REGISTERED_FILE",r.SCRIPT_TOKENS="SCRIPT_TOKENS",r.SUCCESS="SUCCESS",r.TABLE_NAMES="TABLE_NAMES",r.VERSION_STRING="VERSION_STRING",r))(ND||{}),de=class{constructor(r,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=r,this.data=t,this.promise=new Promise((e,n)=>{this.promiseResolver=e,this.promiseRejecter=n})}};function Ql(r){switch(r.typeId){case k.Binary:return{sqlType:"binary"};case k.Bool:return{sqlType:"bool"};case k.Date:return{sqlType:"date"};case k.DateDay:return{sqlType:"date32[d]"};case k.DateMillisecond:return{sqlType:"date64[ms]"};case k.Decimal:{let t=r;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case k.Float:return{sqlType:"float"};case k.Float16:return{sqlType:"float16"};case k.Float32:return{sqlType:"float32"};case k.Float64:return{sqlType:"float64"};case k.Int:return{sqlType:"int32"};case k.Int16:return{sqlType:"int16"};case k.Int32:return{sqlType:"int32"};case k.Int64:return{sqlType:"int64"};case k.Uint16:return{sqlType:"uint16"};case k.Uint32:return{sqlType:"uint32"};case k.Uint64:return{sqlType:"uint64"};case k.Uint8:return{sqlType:"uint8"};case k.IntervalDayTime:return{sqlType:"interval[dt]"};case k.IntervalYearMonth:return{sqlType:"interval[m]"};case k.List:return{sqlType:"list",valueType:Ql(r.valueType)};case k.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:r.byteWidth};case k.Null:return{sqlType:"null"};case k.Utf8:return{sqlType:"utf8"};case k.Struct:return{sqlType:"struct",fields:r.children.map(t=>af(t.name,t.type))};case k.Map:{let t=r;return{sqlType:"map",keyType:Ql(t.keyType),valueType:Ql(t.valueType)}}case k.Time:return{sqlType:"time[s]"};case k.TimeMicrosecond:return{sqlType:"time[us]"};case k.TimeMillisecond:return{sqlType:"time[ms]"};case k.TimeNanosecond:return{sqlType:"time[ns]"};case k.TimeSecond:return{sqlType:"time[s]"};case k.Timestamp:return{sqlType:"timestamp",timezone:r.timezone||void 0};case k.TimestampSecond:return{sqlType:"timestamp[s]",timezone:r.timezone||void 0};case k.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:r.timezone||void 0};case k.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:r.timezone||void 0};case k.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:r.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(r.toString()))}function af(r,t){let e=Ql(t);return e.name=r,e}var BD=new TextEncoder,UD=class{constructor(r,t=null){this._onInstantiationProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._logger=r,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(r){this._worker=r,this._worker.addEventListener("message",this._onMessageHandler),this._worker.addEventListener("error",this._onErrorHandler),this._worker.addEventListener("close",this._onCloseHandler),this._workerShutdownPromise=new Promise((t,e)=>{this._workerShutdownResolver=t})}detach(){this._worker&&(this._worker.removeEventListener("message",this._onMessageHandler),this._worker.removeEventListener("error",this._onErrorHandler),this._worker.removeEventListener("close",this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(r,t=[]){if(!this._worker){console.error("cannot send a message since the worker is not set!");return}let e=this._nextMessageId++;return this._pendingRequests.set(e,r),this._worker.postMessage({messageId:e,type:r.type,data:r.data},t),await r.promise}onMessage(r){var t;let e=r.data;switch(e.type){case"LOG":{this._logger.log(e.data);return}case"INSTANTIATE_PROGRESS":{for(let i of this._onInstantiationProgress)i(e.data);return}}let n=this._pendingRequests.get(e.requestId);if(!n){console.warn("unassociated response: [".concat(e.requestId,", ").concat(e.type.toString(),"]"));return}if(this._pendingRequests.delete(e.requestId),e.type=="ERROR"){let i=new Error(e.data.message);i.name=e.data.name,(t=Object.getOwnPropertyDescriptor(i,"stack"))!=null&&t.writable&&(i.stack=e.data.stack),n.promiseRejecter(i);return}switch(n.type){case"CLOSE_PREPARED":case"COLLECT_FILE_STATISTICS":case"REGISTER_OPFS_FILE_NAME":case"COPY_FILE_TO_PATH":case"DISCONNECT":case"DROP_FILE":case"DROP_FILES":case"FLUSH_FILES":case"INSERT_ARROW_FROM_IPC_STREAM":case"IMPORT_CSV_FROM_PATH":case"IMPORT_JSON_FROM_PATH":case"OPEN":case"PING":case"REGISTER_FILE_BUFFER":case"REGISTER_FILE_HANDLE":case"REGISTER_FILE_URL":case"RESET":if(e.type=="OK"){n.promiseResolver(e.data);return}break;case"INSTANTIATE":if(this._onInstantiationProgress=[],e.type=="OK"){n.promiseResolver(e.data);return}break;case"GLOB_FILE_INFOS":if(e.type=="FILE_INFOS"){n.promiseResolver(e.data);return}break;case"GET_VERSION":if(e.type=="VERSION_STRING"){n.promiseResolver(e.data);return}break;case"GET_FEATURE_FLAGS":if(e.type=="FEATURE_FLAGS"){n.promiseResolver(e.data);return}break;case"GET_TABLE_NAMES":if(e.type=="TABLE_NAMES"){n.promiseResolver(e.data);return}break;case"TOKENIZE":if(e.type=="SCRIPT_TOKENS"){n.promiseResolver(e.data);return}break;case"COPY_FILE_TO_BUFFER":if(e.type=="FILE_BUFFER"){n.promiseResolver(e.data);return}break;case"EXPORT_FILE_STATISTICS":if(e.type=="FILE_STATISTICS"){n.promiseResolver(e.data);return}break;case"CONNECT":if(e.type=="CONNECTION_INFO"){n.promiseResolver(e.data);return}break;case"RUN_PREPARED":case"RUN_QUERY":if(e.type=="QUERY_RESULT"){n.promiseResolver(e.data);return}break;case"SEND_PREPARED":if(e.type=="QUERY_RESULT_HEADER"){n.promiseResolver(e.data);return}break;case"START_PENDING_QUERY":if(e.type=="QUERY_RESULT_HEADER_OR_NULL"){n.promiseResolver(e.data);return}break;case"POLL_PENDING_QUERY":if(e.type=="QUERY_RESULT_HEADER_OR_NULL"){n.promiseResolver(e.data);return}break;case"CANCEL_PENDING_QUERY":if(this._onInstantiationProgress=[],e.type=="SUCCESS"){n.promiseResolver(e.data);return}break;case"FETCH_QUERY_RESULTS":if(e.type=="QUERY_RESULT_CHUNK"){n.promiseResolver(e.data);return}break;case"CREATE_PREPARED":if(e.type=="PREPARED_STATEMENT_ID"){n.promiseResolver(e.data);return}break}n.promiseRejecter(new Error("unexpected response type: ".concat(e.type.toString())))}onError(r){console.error(r),console.error("error in duckdb worker: ".concat(r.message)),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn("worker terminated with ".concat(this._pendingRequests.size," pending requests"));return}this._pendingRequests.clear()}async reset(){let r=new de("RESET",null);return await this.postTask(r)}async ping(){let r=new de("PING",null);await this.postTask(r)}async dropFile(r){let t=new de("DROP_FILE",r);return await this.postTask(t)}async dropFiles(){let r=new de("DROP_FILES",null);return await this.postTask(r)}async flushFiles(){let r=new de("FLUSH_FILES",null);return await this.postTask(r)}async instantiate(r,t=null,e=n=>{}){this._onInstantiationProgress.push(e);let n=new de("INSTANTIATE",[r,t]);return await this.postTask(n)}async getVersion(){let r=new de("GET_VERSION",null);return await this.postTask(r)}async getFeatureFlags(){let r=new de("GET_FEATURE_FLAGS",null);return await this.postTask(r)}async open(r){let t=new de("OPEN",r);await this.postTask(t)}async tokenize(r){let t=new de("TOKENIZE",r);return await this.postTask(t)}async connectInternal(){let r=new de("CONNECT",null);return await this.postTask(r)}async connect(){let r=await this.connectInternal();return new FD(this,r)}async disconnect(r){let t=new de("DISCONNECT",r);await this.postTask(t)}async runQuery(r,t){let e=new de("RUN_QUERY",[r,t]);return await this.postTask(e)}async startPendingQuery(r,t,e=!1){let n=new de("START_PENDING_QUERY",[r,t,e]);return await this.postTask(n)}async pollPendingQuery(r){let t=new de("POLL_PENDING_QUERY",r);return await this.postTask(t)}async cancelPendingQuery(r){let t=new de("CANCEL_PENDING_QUERY",r);return await this.postTask(t)}async fetchQueryResults(r){let t=new de("FETCH_QUERY_RESULTS",r);return await this.postTask(t)}async getTableNames(r,t){let e=new de("GET_TABLE_NAMES",[r,t]);return await this.postTask(e)}async createPrepared(r,t){let e=new de("CREATE_PREPARED",[r,t]);return await this.postTask(e)}async closePrepared(r,t){let e=new de("CLOSE_PREPARED",[r,t]);await this.postTask(e)}async runPrepared(r,t,e){let n=new de("RUN_PREPARED",[r,t,e]);return await this.postTask(n)}async sendPrepared(r,t,e){let n=new de("SEND_PREPARED",[r,t,e]);return await this.postTask(n)}async globFiles(r){let t=new de("GLOB_FILE_INFOS",r);return await this.postTask(t)}async registerFileText(r,t){let e=BD.encode(t);await this.registerFileBuffer(r,e)}async registerFileURL(r,t,e,n){t===void 0&&(t=r);let i=new de("REGISTER_FILE_URL",[r,t,e,n]);await this.postTask(i)}async registerEmptyFileBuffer(r){}async registerFileBuffer(r,t){let e=new de("REGISTER_FILE_BUFFER",[r,t]);await this.postTask(e,[t.buffer])}async registerFileHandle(r,t,e,n){let i=new de("REGISTER_FILE_HANDLE",[r,t,e,n]);await this.postTask(i,[])}async registerOPFSFileName(r){let t=new de("REGISTER_OPFS_FILE_NAME",[r]);await this.postTask(t,[])}async collectFileStatistics(r,t){let e=new de("COLLECT_FILE_STATISTICS",[r,t]);await this.postTask(e,[])}async exportFileStatistics(r){let t=new de("EXPORT_FILE_STATISTICS",r);return await this.postTask(t,[])}async copyFileToBuffer(r){let t=new de("COPY_FILE_TO_BUFFER",r);return await this.postTask(t)}async copyFileToPath(r,t){let e=new de("COPY_FILE_TO_PATH",[r,t]);await this.postTask(e)}async insertArrowFromIPCStream(r,t,e){if(t.length==0)return;let n=new de("INSERT_ARROW_FROM_IPC_STREAM",[r,t,e]);await this.postTask(n,[t.buffer])}async insertCSVFromPath(r,t,e){if(e.columns!==void 0){let i=[];for(let s in e.columns){let o=e.columns[s];i.push(af(s,o))}e.columnsFlat=i,delete e.columns}let n=new de("IMPORT_CSV_FROM_PATH",[r,t,e]);await this.postTask(n)}async insertJSONFromPath(r,t,e){if(e.columns!==void 0){let i=[];for(let s in e.columns){let o=e.columns[s];i.push(af(s,o))}e.columnsFlat=i,delete e.columns}let n=new de("IMPORT_JSON_FROM_PATH",[r,t,e]);await this.postTask(n)}};function kD(){let r=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),r.decode(t))}kD();var zD=(r=>(r[r.BUFFER=0]="BUFFER",r[r.NODE_FS=1]="NODE_FS",r[r.BROWSER_FILEREADER=2]="BROWSER_FILEREADER",r[r.BROWSER_FSACCESS=3]="BROWSER_FSACCESS",r[r.HTTP=4]="HTTP",r[r.S3=5]="S3",r))(zD||{}),VD=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])),jD=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])),$D=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])),GD=()=>(async r=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(r)}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])),WD={version:"1.29.1-dev68.0"},wp=WD.version.split(".");wp[0];wp[1];wp[2];var HD=()=>typeof navigator>"u",Fh=null,Dh=null,Lh=null,Nh=null,Bh=null;async function XD(){return Fh==null&&(Fh=typeof BigInt64Array<"u"),Dh==null&&(Dh=await jD()),Lh==null&&(Lh=await GD()),Nh==null&&(Nh=await $D()),Bh==null&&(Bh=await VD()),{bigInt64Array:Fh,crossOriginIsolated:HD()||globalThis.crossOriginIsolated||!1,wasmExceptions:Dh,wasmSIMD:Nh,wasmThreads:Lh,wasmBulkMemory:Bh}}async function Iy(r){let t=await XD();if(t.wasmExceptions){if(t.wasmSIMD&&t.wasmThreads&&t.crossOriginIsolated&&r.coi)return{mainModule:r.coi.mainModule,mainWorker:r.coi.mainWorker,pthreadWorker:r.coi.pthreadWorker};if(r.eh)return{mainModule:r.eh.mainModule,mainWorker:r.eh.mainWorker,pthreadWorker:null}}return{mainModule:r.mvp.mainModule,mainWorker:r.mvp.mainWorker,pthreadWorker:null}}TD(ID());const Uh={},wa={};function Ia(r,t){try{const n=(Uh[r]||(Uh[r]=new Intl.DateTimeFormat("en-GB",{timeZone:r,hour:"numeric",timeZoneName:"longOffset"}).format))(t).split("GMT")[1]||"";return n in wa?wa[n]:Ey(n,n.split(":"))}catch{if(r in wa)return wa[r];const e=r==null?void 0:r.match(YD);return e?Ey(r,e.slice(1)):NaN}}const YD=/([+-]\d\d):?(\d\d)?/;function Ey(r,t){const e=+t[0],n=+(t[1]||0);return wa[r]=e>0?e*60+n:e*60-n}class Fr extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(Ia(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),kx(this),lf(this)):this.setTime(Date.now())}static tz(t,...e){return e.length?new Fr(...e,t):new Fr(Date.now(),t)}withTimeZone(t){return new Fr(+this,t)}getTimezoneOffset(){return-Ia(this.timeZone,this)}setTime(t){return Date.prototype.setTime.apply(this,arguments),lf(this),+this}[Symbol.for("constructDateFrom")](t){return new Fr(+new Date(t),this.timeZone)}}const Ay=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(r=>{if(!Ay.test(r))return;const t=r.replace(Ay,"$1UTC");Fr.prototype[t]&&(r.startsWith("get")?Fr.prototype[r]=function(){return this.internal[t]()}:(Fr.prototype[r]=function(){return Date.prototype[t].apply(this.internal,arguments),qD(this),+this},Fr.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),lf(this),+this}))});function lf(r){r.internal.setTime(+r),r.internal.setUTCMinutes(r.internal.getUTCMinutes()-r.getTimezoneOffset())}function qD(r){Date.prototype.setFullYear.call(r,r.internal.getUTCFullYear(),r.internal.getUTCMonth(),r.internal.getUTCDate()),Date.prototype.setHours.call(r,r.internal.getUTCHours(),r.internal.getUTCMinutes(),r.internal.getUTCSeconds(),r.internal.getUTCMilliseconds()),kx(r)}function kx(r){const t=Ia(r.timeZone,r),e=new Date(+r);e.setUTCHours(e.getUTCHours()-1);const n=-new Date(+r).getTimezoneOffset(),i=-new Date(+e).getTimezoneOffset(),s=n-i,o=Date.prototype.getHours.apply(r)!==r.internal.getUTCHours();s&&o&&r.internal.setUTCMinutes(r.internal.getUTCMinutes()+s);const a=n-t;a&&Date.prototype.setUTCMinutes.call(r,Date.prototype.getUTCMinutes.call(r)+a);const l=Ia(r.timeZone,r),c=-new Date(+r).getTimezoneOffset()-l,h=l!==t,f=c-a;if(h&&f){Date.prototype.setUTCMinutes.call(r,Date.prototype.getUTCMinutes.call(r)+f);const d=Ia(r.timeZone,r),m=l-d;m&&(r.internal.setUTCMinutes(r.internal.getUTCMinutes()+m),Date.prototype.setUTCMinutes.call(r,Date.prototype.getUTCMinutes.call(r)+m))}}const QD=new TextDecoder("utf-8"),ZD=r=>QD.decode(r),KD=new TextEncoder,zx=r=>KD.encode(r),An=r=>typeof r=="function",el=r=>r!=null&&Object(r)===r,JD=r=>el(r)&&An(r.then),Vx=r=>el(r)&&An(r[Symbol.iterator]),tL=r=>el(r)&&An(r[Symbol.asyncIterator]),eL=r=>el(r)&&"done"in r&&"value"in r,rL=r=>el(r)&&An(r.clear)&&An(r.bytes)&&An(r.position)&&An(r.setPosition)&&An(r.capacity)&&An(r.getBufferIdentifier)&&An(r.createLong),xp=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function nL(r){const t=r[0]?[r[0]]:[];let e,n,i,s;for(let o,a,l=0,u=0,c=r.length;++lc+h.byteLength,0);let i,s,o,a=0,l=-1;const u=Math.min(t||Number.POSITIVE_INFINITY,n);for(const c=e.length;++lur(Int8Array,r),oL=r=>ur(Int16Array,r),aL=r=>ur(Int32Array,r),lL=r=>ur(BigInt64Array,r),uL=r=>ur(Uint8Array,r),cL=r=>ur(Uint16Array,r),hL=r=>ur(Uint32Array,r),dL=r=>ur(BigUint64Array,r),fL=r=>ur(Float32Array,r),pL=r=>ur(Float64Array,r),mL=r=>ur(Uint8ClampedArray,r),cf=r=>(r.next(),r);function*Xn(r,t){const e=function*(i){yield i},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof xp?e(t):Vx(t)?t:e(t);return yield*cf(function*(i){let s=null;do s=i.next(yield ur(r,s));while(!s.done)}(n[Symbol.iterator]())),new r}const gL=r=>Xn(Int8Array,r),yL=r=>Xn(Int16Array,r),vL=r=>Xn(Int32Array,r),_L=r=>Xn(Uint8Array,r),bL=r=>Xn(Uint16Array,r),wL=r=>Xn(Uint32Array,r),xL=r=>Xn(Float32Array,r),SL=r=>Xn(Float64Array,r),TL=r=>Xn(Uint8ClampedArray,r);function mn(r,t){return br(this,arguments,function*(){if(JD(t))return yield Rt(yield Rt(yield*Ss(Bn(mn(r,yield Rt(t))))));const n=function(o){return br(this,arguments,function*(){yield yield Rt(yield Rt(o))})},i=function(o){return br(this,arguments,function*(){yield Rt(yield*Ss(Bn(cf(function*(a){let l=null;do l=a.next(yield l==null?void 0:l.value);while(!l.done)}(o[Symbol.iterator]())))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof xp?n(t):Vx(t)?i(t):tL(t)?t:n(t);return yield Rt(yield*Ss(Bn(cf(function(o){return br(this,arguments,function*(){let a=null;do a=yield Rt(o.next(yield yield Rt(ur(r,a))));while(!a.done)})}(s[Symbol.asyncIterator]()))))),yield Rt(new r)})}const IL=r=>mn(Int8Array,r),EL=r=>mn(Int16Array,r),AL=r=>mn(Int32Array,r),ML=r=>mn(Uint8Array,r),CL=r=>mn(Uint16Array,r),OL=r=>mn(Uint32Array,r),PL=r=>mn(Float32Array,r),RL=r=>mn(Float64Array,r),FL=r=>mn(Uint8ClampedArray,r);function DL(r,t,e){if(r!==0){e=e.slice(0,t);for(let n=-1,i=e.length;++n0)do if(r[e]!==t[e])return!1;while(++eFo(t))}]`:`[${r}]`:ArrayBuffer.isView(r)?`[${r}]`:JSON.stringify(r,(t,e)=>typeof e=="bigint"?`${e}`:e)}const BL=Object.freeze(Object.defineProperty({__proto__:null,valueToString:Fo},Symbol.toStringTag,{value:"Module"}));function pr(r){if(typeof r=="bigint"&&(rNumber.MAX_SAFE_INTEGER))throw new TypeError(`${r} is not safe to convert to a number.`);return Number(r)}function $x(r,t){return pr(r/t)+pr(r%t)/pr(t)}const Gx=Symbol.for("isArrowBigNum");function gn(r,...t){return t.length===0?Object.setPrototypeOf(ur(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}gn.prototype[Gx]=!0;gn.prototype.toJSON=function(){return`"${Do(this)}"`};gn.prototype.valueOf=function(r){return Sp(this,r)};gn.prototype.toString=function(){return Do(this)};gn.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return Sp(this);case"string":return Do(this);case"default":return Wx(this)}return Do(this)};function xo(...r){return gn.apply(this,r)}function So(...r){return gn.apply(this,r)}function $a(...r){return gn.apply(this,r)}Object.setPrototypeOf(xo.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(So.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf($a.prototype,Object.create(Uint32Array.prototype));Object.assign(xo.prototype,gn.prototype,{constructor:xo,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(So.prototype,gn.prototype,{constructor:So,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign($a.prototype,gn.prototype,{constructor:$a,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const UL=BigInt(4294967296)*BigInt(4294967296),kL=UL-BigInt(1);function Sp(r,t){const{buffer:e,byteOffset:n,byteLength:i,signed:s}=r,o=new BigUint64Array(e,n,i/8),a=s&&o.at(-1)&BigInt(1)<=0)return kh(r);t=t.slice();let n=1;for(let s=0;s(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(Ct.prototype);class My extends Ct{constructor(){super(H.Null)}toString(){return"Null"}}Xx=Symbol.toStringTag;My[Xx]=(r=>r[Symbol.toStringTag]="Null")(My.prototype);class Cy extends Ct{constructor(t,e){super(H.Int),this.isSigned=t,this.bitWidth=e}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}Yx=Symbol.toStringTag;Cy[Yx]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(Cy.prototype);class Oy extends Ct{constructor(t){super(H.Float),this.precision=t}get ArrayType(){switch(this.precision){case Dr.HALF:return Uint16Array;case Dr.SINGLE:return Float32Array;case Dr.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}qx=Symbol.toStringTag;Oy[qx]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(Oy.prototype);class Py extends Ct{constructor(){super(H.Binary)}toString(){return"Binary"}}Qx=Symbol.toStringTag;Py[Qx]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(Py.prototype);class Ry extends Ct{constructor(){super(H.LargeBinary)}toString(){return"LargeBinary"}}Zx=Symbol.toStringTag;Ry[Zx]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(Ry.prototype);class Fy extends Ct{constructor(){super(H.Utf8)}toString(){return"Utf8"}}Kx=Symbol.toStringTag;Fy[Kx]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(Fy.prototype);class Dy extends Ct{constructor(){super(H.LargeUtf8)}toString(){return"LargeUtf8"}}Jx=Symbol.toStringTag;Dy[Jx]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(Dy.prototype);class Ly extends Ct{constructor(){super(H.Bool)}toString(){return"Bool"}}tS=Symbol.toStringTag;Ly[tS]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(Ly.prototype);class Ny extends Ct{constructor(t,e,n=128){super(H.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}eS=Symbol.toStringTag;Ny[eS]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(Ny.prototype);class By extends Ct{constructor(t){super(H.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${Bi[this.unit]}>`}get ArrayType(){return this.unit===Bi.DAY?Int32Array:BigInt64Array}}rS=Symbol.toStringTag;By[rS]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(By.prototype);class Uy extends Ct{constructor(t,e){super(H.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${te[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}nS=Symbol.toStringTag;Uy[nS]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(Uy.prototype);class ky extends Ct{constructor(t,e){super(H.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${te[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}iS=Symbol.toStringTag;ky[iS]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(ky.prototype);class zy extends Ct{constructor(t){super(H.Interval),this.unit=t}toString(){return`Interval<${As[this.unit]}>`}}sS=Symbol.toStringTag;zy[sS]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(zy.prototype);class Vy extends Ct{constructor(t){super(H.Duration),this.unit=t}toString(){return`Duration<${te[this.unit]}>`}}oS=Symbol.toStringTag;Vy[oS]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(Vy.prototype);class jy extends Ct{constructor(t){super(H.List),this.children=[t]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}aS=Symbol.toStringTag;jy[aS]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(jy.prototype);class hf extends Ct{constructor(t){super(H.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}lS=Symbol.toStringTag;hf[lS]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(hf.prototype);class $y extends Ct{constructor(t,e,n){super(H.Union),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}uS=Symbol.toStringTag;$y[uS]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))($y.prototype);class Gy extends Ct{constructor(t){super(H.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}cS=Symbol.toStringTag;Gy[cS]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(Gy.prototype);class Wy extends Ct{constructor(t,e){super(H.FixedSizeList),this.listSize=t,this.children=[e]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}hS=Symbol.toStringTag;Wy[hS]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(Wy.prototype);class Hy extends Ct{constructor(t,e=!1){var n,i,s;if(super(H.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((n=t==null?void 0:t.type)===null||n===void 0)&&n.children)){const o=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");const a=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}dS=Symbol.toStringTag;Hy[dS]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(Hy.prototype);const VL=(r=>()=>++r)(-1);class Xy extends Ct{constructor(t,e,n,i){super(H.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=n==null?VL():pr(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}>`}}fS=Symbol.toStringTag;Xy[fS]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(Xy.prototype);function pS(r){const t=r;switch(r.typeId){case H.Decimal:return r.bitWidth/32;case H.Interval:return 1+t.unit;case H.FixedSizeList:return t.listSize;case H.FixedSizeBinary:return t.byteWidth;default:return 1}}class he{visitMany(t,...e){return t.map((n,i)=>this.visit(n,...e.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return jL(this,t,e)}getVisitFnByTypeId(t,e=!0){return ao(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitLargeUtf8(t,...e){return null}visitBinary(t,...e){return null}visitLargeBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitDuration(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}}function jL(r,t,e=!0){return typeof t=="number"?ao(r,t,e):typeof t=="string"&&t in H?ao(r,H[t],e):t&&t instanceof Ct?ao(r,Yy(t),e):t!=null&&t.type&&t.type instanceof Ct?ao(r,Yy(t.type),e):ao(r,H.NONE,e)}function ao(r,t,e=!0){let n=null;switch(t){case H.Null:n=r.visitNull;break;case H.Bool:n=r.visitBool;break;case H.Int:n=r.visitInt;break;case H.Int8:n=r.visitInt8||r.visitInt;break;case H.Int16:n=r.visitInt16||r.visitInt;break;case H.Int32:n=r.visitInt32||r.visitInt;break;case H.Int64:n=r.visitInt64||r.visitInt;break;case H.Uint8:n=r.visitUint8||r.visitInt;break;case H.Uint16:n=r.visitUint16||r.visitInt;break;case H.Uint32:n=r.visitUint32||r.visitInt;break;case H.Uint64:n=r.visitUint64||r.visitInt;break;case H.Float:n=r.visitFloat;break;case H.Float16:n=r.visitFloat16||r.visitFloat;break;case H.Float32:n=r.visitFloat32||r.visitFloat;break;case H.Float64:n=r.visitFloat64||r.visitFloat;break;case H.Utf8:n=r.visitUtf8;break;case H.LargeUtf8:n=r.visitLargeUtf8;break;case H.Binary:n=r.visitBinary;break;case H.LargeBinary:n=r.visitLargeBinary;break;case H.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case H.Date:n=r.visitDate;break;case H.DateDay:n=r.visitDateDay||r.visitDate;break;case H.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case H.Timestamp:n=r.visitTimestamp;break;case H.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case H.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case H.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case H.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case H.Time:n=r.visitTime;break;case H.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case H.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case H.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case H.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case H.Decimal:n=r.visitDecimal;break;case H.List:n=r.visitList;break;case H.Struct:n=r.visitStruct;break;case H.Union:n=r.visitUnion;break;case H.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case H.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case H.Dictionary:n=r.visitDictionary;break;case H.Interval:n=r.visitInterval;break;case H.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case H.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case H.Duration:n=r.visitDuration;break;case H.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case H.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case H.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case H.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case H.FixedSizeList:n=r.visitFixedSizeList;break;case H.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error(`Unrecognized type '${H[t]}'`)}function Yy(r){switch(r.typeId){case H.Null:return H.Null;case H.Int:{const{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?H.Int8:H.Uint8;case 16:return e?H.Int16:H.Uint16;case 32:return e?H.Int32:H.Uint32;case 64:return e?H.Int64:H.Uint64}return H.Int}case H.Float:switch(r.precision){case Dr.HALF:return H.Float16;case Dr.SINGLE:return H.Float32;case Dr.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(r.unit){case te.SECOND:return H.TimeSecond;case te.MILLISECOND:return H.TimeMillisecond;case te.MICROSECOND:return H.TimeMicrosecond;case te.NANOSECOND:return H.TimeNanosecond}return H.Time;case H.Timestamp:switch(r.unit){case te.SECOND:return H.TimestampSecond;case te.MILLISECOND:return H.TimestampMillisecond;case te.MICROSECOND:return H.TimestampMicrosecond;case te.NANOSECOND:return H.TimestampNanosecond}return H.Timestamp;case H.Date:switch(r.unit){case Bi.DAY:return H.DateDay;case Bi.MILLISECOND:return H.DateMillisecond}return H.Date;case H.Interval:switch(r.unit){case As.DAY_TIME:return H.IntervalDayTime;case As.YEAR_MONTH:return H.IntervalYearMonth}return H.Interval;case H.Duration:switch(r.unit){case te.SECOND:return H.DurationSecond;case te.MILLISECOND:return H.DurationMillisecond;case te.MICROSECOND:return H.DurationMicrosecond;case te.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(r.mode){case jn.Dense:return H.DenseUnion;case jn.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 new Error(`Unrecognized type '${H[r.typeId]}'`)}he.prototype.visitInt8=null;he.prototype.visitInt16=null;he.prototype.visitInt32=null;he.prototype.visitInt64=null;he.prototype.visitUint8=null;he.prototype.visitUint16=null;he.prototype.visitUint32=null;he.prototype.visitUint64=null;he.prototype.visitFloat16=null;he.prototype.visitFloat32=null;he.prototype.visitFloat64=null;he.prototype.visitDateDay=null;he.prototype.visitDateMillisecond=null;he.prototype.visitTimestampSecond=null;he.prototype.visitTimestampMillisecond=null;he.prototype.visitTimestampMicrosecond=null;he.prototype.visitTimestampNanosecond=null;he.prototype.visitTimeSecond=null;he.prototype.visitTimeMillisecond=null;he.prototype.visitTimeMicrosecond=null;he.prototype.visitTimeNanosecond=null;he.prototype.visitDenseUnion=null;he.prototype.visitSparseUnion=null;he.prototype.visitIntervalDayTime=null;he.prototype.visitIntervalYearMonth=null;he.prototype.visitDuration=null;he.prototype.visitDurationSecond=null;he.prototype.visitDurationMillisecond=null;he.prototype.visitDurationMicrosecond=null;he.prototype.visitDurationNanosecond=null;const mS=new Float64Array(1),Hs=new Uint32Array(mS.buffer);function Tp(r){const t=(r&31744)>>10,e=(r&1023)/1024,n=Math.pow(-1,(r&32768)>>15);switch(t){case 31:return n*(e?Number.NaN:1/0);case 0:return n*(e?6103515625e-14*e:0)}return n*Math.pow(2,t-15)*(1+e)}function gS(r){if(r!==r)return 32256;mS[0]=r;const t=(Hs[1]&2147483648)>>16&65535;let e=Hs[1]&2146435072,n=0;return e>=1089470464?Hs[0]>0?e=31744:(e=(e&2080374784)>>16,n=(Hs[1]&1048575)>>10):e<=1056964608?(n=1048576+(Hs[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(Hs[1]&1048575)+512>>10),t|e|n&65535}const $L=Object.freeze(Object.defineProperty({__proto__:null,float64ToUint16:gS,uint16ToFloat64:Tp},Symbol.toStringTag,{value:"Module"}));class Wt extends he{}function qt(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}const GL=(r,t,e)=>{r[t]=Math.floor(e/864e5)},yS=(r,t,e,n)=>{if(e+1{const i=r+e;n?t[i>>3]|=1<>3]&=~(1<{r[t]=e},Ip=({values:r},t,e)=>{r[t]=e},vS=({values:r},t,e)=>{r[t]=gS(e)},HL=(r,t,e)=>{switch(r.type.precision){case Dr.HALF:return vS(r,t,e);case Dr.SINGLE:case Dr.DOUBLE:return Ip(r,t,e)}},_S=({values:r},t,e)=>{GL(r,t,e.valueOf())},bS=({values:r},t,e)=>{r[t]=BigInt(e)},XL=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},wS=({values:r,valueOffsets:t},e,n)=>yS(r,t,e,n),xS=({values:r,valueOffsets:t},e,n)=>yS(r,t,e,zx(n)),YL=(r,t,e)=>{r.type.unit===Bi.DAY?_S(r,t,e):bS(r,t,e)},SS=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},TS=({values:r},t,e)=>{r[t]=BigInt(e)},IS=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},ES=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},qL=(r,t,e)=>{switch(r.type.unit){case te.SECOND:return SS(r,t,e);case te.MILLISECOND:return TS(r,t,e);case te.MICROSECOND:return IS(r,t,e);case te.NANOSECOND:return ES(r,t,e)}},AS=({values:r},t,e)=>{r[t]=e},MS=({values:r},t,e)=>{r[t]=e},CS=({values:r},t,e)=>{r[t]=e},OS=({values:r},t,e)=>{r[t]=e},QL=(r,t,e)=>{switch(r.type.unit){case te.SECOND:return AS(r,t,e);case te.MILLISECOND:return MS(r,t,e);case te.MICROSECOND:return CS(r,t,e);case te.NANOSECOND:return OS(r,t,e)}},ZL=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},KL=(r,t,e)=>{const n=r.children[0],i=r.valueOffsets,s=$n.getVisitFn(n);if(Array.isArray(e))for(let o=-1,a=i[t],l=i[t+1];a{const n=r.children[0],{valueOffsets:i}=r,s=$n.getVisitFn(n);let{[t]:o,[t+1]:a}=i;const l=e instanceof Map?e.entries():Object.entries(e);for(const u of l)if(s(n,o,u),++o>=a)break},tN=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[s]),eN=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(s)),rN=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(i.name)),nN=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[i.name]),iN=(r,t,e)=>{const n=r.type.children.map(s=>$n.getVisitFn(s.type)),i=e instanceof Map?rN(t,e):e instanceof er?eN(t,e):Array.isArray(e)?tN(t,e):nN(t,e);r.type.children.forEach((s,o)=>i(n[o],r.children[o],s,o))},sN=(r,t,e)=>{r.type.mode===jn.Dense?PS(r,t,e):RS(r,t,e)},PS=(r,t,e)=>{const n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];$n.visit(i,r.valueOffsets[t],e)},RS=(r,t,e)=>{const n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];$n.visit(i,t,e)},oN=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},aN=(r,t,e)=>{r.type.unit===As.DAY_TIME?FS(r,t,e):DS(r,t,e)},FS=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},DS=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},LS=({values:r},t,e)=>{r[t]=e},NS=({values:r},t,e)=>{r[t]=e},BS=({values:r},t,e)=>{r[t]=e},US=({values:r},t,e)=>{r[t]=e},lN=(r,t,e)=>{switch(r.type.unit){case te.SECOND:return LS(r,t,e);case te.MILLISECOND:return NS(r,t,e);case te.MICROSECOND:return BS(r,t,e);case te.NANOSECOND:return US(r,t,e)}},uN=(r,t,e)=>{const{stride:n}=r,i=r.children[0],s=$n.getVisitFn(i);if(Array.isArray(e))for(let o=-1,a=t*n;++o`${Fo(t)}: ${Fo(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new cN(this[cn],this[To])}}class cN{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return te.name)}has(t,e){return t[cn].type.children.some(n=>n.name===e)}getOwnPropertyDescriptor(t,e){if(t[cn].type.children.some(n=>n.name===e))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const n=t[cn].type.children.findIndex(i=>i.name===e);if(n!==-1){const i=on.visit(t[cn].children[n],t[To]);return Reflect.set(t,e,i),i}}set(t,e,n){const i=t[cn].type.children.findIndex(s=>s.name===e);return i!==-1?($n.visit(t[cn].children[i],t[To],n),Reflect.set(t,e,n)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,n):!1}}const dN=new hN;class Bt extends he{}function Ht(r){return(t,e)=>t.getValid(e)?r(t,e):null}const fN=(r,t)=>864e5*r[t],pN=(r,t)=>null,kS=(r,t,e)=>{if(e+1>=t.length)return null;const n=pr(t[e]),i=pr(t[e+1]);return r.subarray(n,i)},mN=({offset:r,values:t},e)=>{const n=r+e;return(t[n>>3]&1<fN(r,t),VS=({values:r},t)=>pr(r[t]),Vi=({stride:r,values:t},e)=>t[r*e],gN=({stride:r,values:t},e)=>Tp(t[r*e]),jS=({values:r},t)=>r[t],yN=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),$S=({values:r,valueOffsets:t},e)=>kS(r,t,e),GS=({values:r,valueOffsets:t},e)=>{const n=kS(r,t,e);return n!==null?ZD(n):null},vN=({values:r},t)=>r[t],_N=({type:r,values:t},e)=>r.precision!==Dr.HALF?t[e]:Tp(t[e]),bN=(r,t)=>r.type.unit===Bi.DAY?zS(r,t):VS(r,t),WS=({values:r},t)=>1e3*pr(r[t]),HS=({values:r},t)=>pr(r[t]),XS=({values:r},t)=>$x(r[t],BigInt(1e3)),YS=({values:r},t)=>$x(r[t],BigInt(1e6)),wN=(r,t)=>{switch(r.type.unit){case te.SECOND:return WS(r,t);case te.MILLISECOND:return HS(r,t);case te.MICROSECOND:return XS(r,t);case te.NANOSECOND:return YS(r,t)}},qS=({values:r},t)=>r[t],QS=({values:r},t)=>r[t],ZS=({values:r},t)=>r[t],KS=({values:r},t)=>r[t],xN=(r,t)=>{switch(r.type.unit){case te.SECOND:return qS(r,t);case te.MILLISECOND:return QS(r,t);case te.MICROSECOND:return ZS(r,t);case te.NANOSECOND:return KS(r,t)}},SN=({values:r,stride:t},e)=>hc.decimal(r.subarray(t*e,t*(e+1))),TN=(r,t)=>{const{valueOffsets:e,stride:n,children:i}=r,{[t*n]:s,[t*n+1]:o}=e,l=i[0].slice(s,o-s);return new er([l])},IN=(r,t)=>{const{valueOffsets:e,children:n}=r,{[t]:i,[t+1]:s}=e,o=n[0];return new Ap(o.slice(i,s-i))},EN=(r,t)=>new Ep(r,t),AN=(r,t)=>r.type.mode===jn.Dense?JS(r,t):tT(r,t),JS=(r,t)=>{const e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return on.visit(n,r.valueOffsets[t])},tT=(r,t)=>{const e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return on.visit(n,t)},MN=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},CN=(r,t)=>r.type.unit===As.DAY_TIME?eT(r,t):rT(r,t),eT=({values:r},t)=>r.subarray(2*t,2*(t+1)),rT=({values:r},t)=>{const e=r[t],n=new Int32Array(2);return n[0]=Math.trunc(e/12),n[1]=Math.trunc(e%12),n},nT=({values:r},t)=>r[t],iT=({values:r},t)=>r[t],sT=({values:r},t)=>r[t],oT=({values:r},t)=>r[t],ON=(r,t)=>{switch(r.type.unit){case te.SECOND:return nT(r,t);case te.MILLISECOND:return iT(r,t);case te.MICROSECOND:return sT(r,t);case te.NANOSECOND:return oT(r,t)}},PN=(r,t)=>{const{stride:e,children:n}=r,s=n[0].slice(t*e,e);return new er([s])};Bt.prototype.visitNull=Ht(pN);Bt.prototype.visitBool=Ht(mN);Bt.prototype.visitInt=Ht(vN);Bt.prototype.visitInt8=Ht(Vi);Bt.prototype.visitInt16=Ht(Vi);Bt.prototype.visitInt32=Ht(Vi);Bt.prototype.visitInt64=Ht(jS);Bt.prototype.visitUint8=Ht(Vi);Bt.prototype.visitUint16=Ht(Vi);Bt.prototype.visitUint32=Ht(Vi);Bt.prototype.visitUint64=Ht(jS);Bt.prototype.visitFloat=Ht(_N);Bt.prototype.visitFloat16=Ht(gN);Bt.prototype.visitFloat32=Ht(Vi);Bt.prototype.visitFloat64=Ht(Vi);Bt.prototype.visitUtf8=Ht(GS);Bt.prototype.visitLargeUtf8=Ht(GS);Bt.prototype.visitBinary=Ht($S);Bt.prototype.visitLargeBinary=Ht($S);Bt.prototype.visitFixedSizeBinary=Ht(yN);Bt.prototype.visitDate=Ht(bN);Bt.prototype.visitDateDay=Ht(zS);Bt.prototype.visitDateMillisecond=Ht(VS);Bt.prototype.visitTimestamp=Ht(wN);Bt.prototype.visitTimestampSecond=Ht(WS);Bt.prototype.visitTimestampMillisecond=Ht(HS);Bt.prototype.visitTimestampMicrosecond=Ht(XS);Bt.prototype.visitTimestampNanosecond=Ht(YS);Bt.prototype.visitTime=Ht(xN);Bt.prototype.visitTimeSecond=Ht(qS);Bt.prototype.visitTimeMillisecond=Ht(QS);Bt.prototype.visitTimeMicrosecond=Ht(ZS);Bt.prototype.visitTimeNanosecond=Ht(KS);Bt.prototype.visitDecimal=Ht(SN);Bt.prototype.visitList=Ht(TN);Bt.prototype.visitStruct=Ht(EN);Bt.prototype.visitUnion=Ht(AN);Bt.prototype.visitDenseUnion=Ht(JS);Bt.prototype.visitSparseUnion=Ht(tT);Bt.prototype.visitDictionary=Ht(MN);Bt.prototype.visitInterval=Ht(CN);Bt.prototype.visitIntervalDayTime=Ht(eT);Bt.prototype.visitIntervalYearMonth=Ht(rT);Bt.prototype.visitDuration=Ht(ON);Bt.prototype.visitDurationSecond=Ht(nT);Bt.prototype.visitDurationMillisecond=Ht(iT);Bt.prototype.visitDurationMicrosecond=Ht(sT);Bt.prototype.visitDurationNanosecond=Ht(oT);Bt.prototype.visitFixedSizeList=Ht(PN);Bt.prototype.visitMap=Ht(IN);const on=new Bt,lo=Symbol.for("keys"),Io=Symbol.for("vals"),uo=Symbol.for("kKeysAsStrings"),df=Symbol.for("_kKeysAsStrings");class Ap{constructor(t){return this[lo]=new er([t.children[0]]).memoize(),this[Io]=t.children[1],new Proxy(this,new FN)}get[uo](){return this[df]||(this[df]=Array.from(this[lo].toArray(),String))}[Symbol.iterator](){return new RN(this[lo],this[Io])}get size(){return this[lo].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[lo],e=this[Io],n={};for(let i=-1,s=t.length;++i`${Fo(t)}: ${Fo(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class RN{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),on.visit(this.vals,t)]})}}class FN{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[uo]}has(t,e){return t[uo].includes(e)}getOwnPropertyDescriptor(t,e){if(t[uo].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const n=t[uo].indexOf(e);if(n!==-1){const i=on.visit(Reflect.get(t,Io),n);return Reflect.set(t,e,i),i}}set(t,e,n){const i=t[uo].indexOf(e);return i!==-1?($n.visit(Reflect.get(t,Io),i,n),Reflect.set(t,e,n)):Reflect.has(t,e)?Reflect.set(t,e,n):!1}}Object.defineProperties(Ap.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[lo]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Io]:{writable:!0,enumerable:!1,configurable:!1,value:null},[df]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let qy;function aT(r,t,e,n){const{length:i=0}=r;let s=typeof t!="number"?0:t,o=typeof e!="number"?i:e;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),oi&&(o=i),n?n(r,s,o):[s,o]}const lT=(r,t)=>r<0?t+r:r,Qy=r=>r!==r;function Ds(r){if(typeof r!=="object"||r===null)return Qy(r)?Qy:e=>e===r;if(r instanceof Date){const e=r.valueOf();return n=>n instanceof Date?n.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?jx(r,e):!1:r instanceof Map?LN(r):Array.isArray(r)?DN(r):r instanceof er?NN(r):BN(r,!0)}function DN(r){const t=[];for(let e=-1,n=r.length;++e!1;const n=[];for(let i=-1,s=e.length;++i{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return UN(r,e);case Map:return Zy(r,e,e.keys());case Ap:case Ep:case Object:case void 0:return Zy(r,e,t||Object.keys(e))}return e instanceof er?kN(r,e):!1}}function UN(r,t){const e=r.length;if(t.length!==e)return!1;for(let n=-1;++n>n}function VN(r,t,e){return e?!!(r[t>>3]|=1<>3]&=~(1<0||e.byteLength>3):cT(new fc(e,r,t,null,Mp)).subarray(0,n)),i}return e}function cT(r){const t=[];let e=0,n=0,i=0;for(const o of r)o&&(i|=1<0)&&(t[e++]=i);const s=new Uint8Array(t.length+7&-8);return s.set(t),s}class fc{constructor(t,e,n,i,s){this.bytes=t,this.length=n,this.context=i,this.get=s,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=t+(t%8===0?0:8-t%8);return ju(r,t,i)+ju(r,n,e)+hT(r,i>>3,n-i>>3)}function hT(r,t,e){let n=0,i=Math.trunc(t);const s=new DataView(r.buffer,r.byteOffset,r.byteLength),o=e===void 0?r.byteLength:i+e;for(;o-i>=4;)n+=Zl(s.getUint32(i)),i+=4;for(;o-i>=2;)n+=Zl(s.getUint16(i)),i+=2;for(;o-i>=1;)n+=Zl(s.getUint8(i)),i+=1;return n}function Zl(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const jN=Object.freeze(Object.defineProperty({__proto__:null,BitIterator:fc,getBit:uT,getBool:Mp,packBools:cT,popcnt_array:hT,popcnt_bit_range:ju,popcnt_uint32:Zl,setBool:VN,truncateBitmap:ff},Symbol.toStringTag,{value:"Module"})),$N=-1;class Ga{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:t}=this;return Ct.isSparseUnion(t)?this.children.some(e=>e.nullable):Ct.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:e,values:n,nullBitmap:i,typeIds:s}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,t)}get nullCount(){if(Ct.isUnion(this.type))return this.children.reduce((n,i)=>n+i.nullCount,0);let t=this._nullCount,e;return t<=$N&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-ju(e,this.offset,this.offset+this.length)),t}constructor(t,e,n,i,s,o=[],a){this.type=t,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof Ga?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=pS(t),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(t){const{type:e}=this;if(Ct.isUnion(e)){const n=e,i=this.children[n.typeIdToChildIndex[this.typeIds[t]]],s=n.mode===jn.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){const n=this.offset+t;return(this.nullBitmap[n>>3]&1<>3;(!s||s.byteLength<=c)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(ff(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const h=s[c];n=(h&u)!==0,s[c]=e?h|u:h&~u}return n!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,n=this.length,i=this._nullCount,s=this,o=this.children){return new Ga(t,e,n,i,s,o,this.dictionary)}slice(t,e){const{stride:n,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,a=i===16?n:1,l=this._sliceBuffers(t,e,n,i);return this.clone(this.type,this.offset+t,e,o,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*t,a*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===H.Null)return this.clone(this.type,0,t,0);const{length:e,nullCount:n}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);i[e>>3]=(1<0&&i.set(ff(this.offset,e,this.nullBitmap),0);const s=this.buffers;return s[si.VALIDITY]=i,this.clone(this.type,0,t,n+(t-e),s)}_sliceBuffers(t,e,n,i){let s;const{buffers:o}=this;return(s=o[si.TYPE])&&(o[si.TYPE]=s.subarray(t,t+e)),(s=o[si.OFFSET])&&(o[si.OFFSET]=s.subarray(t,t+e+1))||(s=o[si.DATA])&&(o[si.DATA]=i===6?s:s.subarray(n*t,n*(t+e))),o}_sliceChildren(t,e,n){return t.map(i=>i.slice(e,n))}}Ga.prototype.children=Object.freeze([]);class Ky{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndext.nullable)}function WN(r){return r.reduce((t,e)=>t+e.nullCount,0)}function HN(r){return r.reduce((t,e,n)=>(t[n+1]=t[n]+e.length,t),new Uint32Array(r.length+1))}function XN(r,t,e,n){const i=[];for(let s=-1,o=r.length;++s=n)break;if(e>=l+u)continue;if(l>=e&&l+u<=n){i.push(a);continue}const c=Math.max(0,e-l),h=Math.min(n-l,u);i.push(a.slice(c,h-c))}return i.length===0&&i.push(r[0].slice(0,0)),i}function Cp(r,t,e,n){let i=0,s=0,o=t.length-1;do{if(i>=o-1)return e0?0:-1}function ZN(r,t){const{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(const i of new fc(e,r.offset+(t||0),r.length,e,Mp)){if(!i)return n;++n}return-1}function Kt(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case H.Union:break;case H.Dictionary:break;default:return ZN(r,e)}const n=on.getVisitFn(r),i=Ds(t);for(let s=(e||0)-1,o=r.length;++s{const i=r.data[n];return i.values.subarray(0,i.length)[Symbol.iterator]()});let e=0;return new Ky(r.data.length,n=>{const s=r.data[n].length,o=r.slice(e,e+s);return e+=s,new KN(o)})}class KN{constructor(t){this.vector=t,this.index=0}next(){return this.indexa.data):t;if(s.length===0||s.some(a=>!(a instanceof Ga)))throw new TypeError("Vector constructor expects an Array of Data instances.");const o=(e=s[0])===null||e===void 0?void 0:e.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:a,set:l,indexOf:u}=mT[o.typeId],c=s[0];this.isValid=h=>dT(c,h),this.get=h=>a(c,h),this.set=(h,f)=>l(c,h,f),this.indexOf=h=>u(c,h),this._offsets=[0,c.length];break}default:Object.setPrototypeOf(this,gT[o.typeId]),this._offsets=HN(s);break}this.data=s,this.type=o,this.stride=pS(o),this.numChildren=(i=(n=o.children)===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,e)=>t+e.byteLength,0)}get nullable(){return GN(this.data)}get nullCount(){return WN(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(t){return!1}get(t){return null}at(t){return this.get(lT(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return JN.visit(this)}concat(...t){return new er(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new er(aT(this,t,e,({data:n,_offsets:i},s,o)=>XN(n,i,s,o)))}toJSON(){return[...this]}toArray(){const{type:t,data:e,length:n,stride:i,ArrayType:s}=this;switch(t.typeId){case H.Int:case H.Float:case H.Decimal:case H.Time:case H.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,n*i);default:return e.reduce((o,{values:a,length:l})=>(o.array.set(a.subarray(0,l*i),o.offset),o.offset+=l*i,o),{array:new s(n*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var e;return this.getChildAt((e=this.type.children)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&te[t])):null}get isMemoized(){return Ct.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(Ct.isDictionary(this.type)){const t=new $u(this.data[0].dictionary),e=this.data.map(n=>{const i=n.clone();return i.dictionary=t,i});return new er(e)}return new $u(this)}unmemoize(){if(Ct.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),e=this.data.map(n=>{const i=n.clone();return i.dictionary=t,i});return new er(e)}return this}}pT=Symbol.toStringTag;er[pT]=(r=>{r.type=Ct.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0;const t=Object.keys(H).map(e=>H[e]).filter(e=>typeof e=="number"&&e!==H.NONE);for(const e of t){const n=on.getVisitFnByTypeId(e),i=$n.getVisitFnByTypeId(e),s=tv.getVisitFnByTypeId(e);mT[e]={get:n,set:i,indexOf:s},gT[e]=Object.create(r,{isValid:{value:Jy(dT)},get:{value:Jy(on.getVisitFnByTypeId(e))},set:{value:YN($n.getVisitFnByTypeId(e))},indexOf:{value:qN(tv.getVisitFnByTypeId(e))}})}return"Vector"})(er.prototype);class $u extends er{constructor(t){super(t.data);const e=this.get,n=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){const a=s[o];if(a!==void 0)return a;const l=e.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,a){n.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new $u(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new er(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}const tB=65536;function po(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}const Lo=8,Op=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class Pp{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){const e=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let i=e[3]*n[3];this.buffer[0]=i&65535;let s=i>>>16;return i=e[2]*n[3],s+=i,i=e[3]*n[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0>>16,this.buffer[1]+=e[1]*n[3]+e[2]*n[2]+e[3]*n[1],this.buffer[1]+=e[0]*n[3]+e[1]*n[2]+e[2]*n[1]+e[3]*n[0]<<16,this}_plus(t){const e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]>>0&&++e[1],e[1]>>0&&++e[2],e[2]>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return`${po(this.buffer[3])} ${po(this.buffer[2])} ${po(this.buffer[1])} ${po(this.buffer[0])}`}static multiply(t,e){return new En(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new En(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return En.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return En.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){const n=t.startsWith("-"),i=t.length,s=new En(e);for(let o=n?1:0;othis.compareFields(n,e[i]))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}}function gr(r,t){return t instanceof r.constructor}function Ls(r,t){return r===t||gr(r,t)}function mi(r,t){return r===t||gr(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function pc(r,t){return r===t||gr(r,t)&&r.precision===t.precision}function rB(r,t){return r===t||gr(r,t)&&r.byteWidth===t.byteWidth}function Rp(r,t){return r===t||gr(r,t)&&r.unit===t.unit}function rl(r,t){return r===t||gr(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function nl(r,t){return r===t||gr(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function nB(r,t){return r===t||gr(r,t)&&r.children.length===t.children.length&&Gn.compareManyFields(r.children,t.children)}function iB(r,t){return r===t||gr(r,t)&&r.children.length===t.children.length&&Gn.compareManyFields(r.children,t.children)}function Fp(r,t){return r===t||gr(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&Gn.compareManyFields(r.children,t.children)}function sB(r,t){return r===t||gr(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&Gn.visit(r.indices,t.indices)&&Gn.visit(r.dictionary,t.dictionary)}function Dp(r,t){return r===t||gr(r,t)&&r.unit===t.unit}function il(r,t){return r===t||gr(r,t)&&r.unit===t.unit}function oB(r,t){return r===t||gr(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&Gn.compareManyFields(r.children,t.children)}function aB(r,t){return r===t||gr(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&Gn.compareManyFields(r.children,t.children)}zt.prototype.visitNull=Ls;zt.prototype.visitBool=Ls;zt.prototype.visitInt=mi;zt.prototype.visitInt8=mi;zt.prototype.visitInt16=mi;zt.prototype.visitInt32=mi;zt.prototype.visitInt64=mi;zt.prototype.visitUint8=mi;zt.prototype.visitUint16=mi;zt.prototype.visitUint32=mi;zt.prototype.visitUint64=mi;zt.prototype.visitFloat=pc;zt.prototype.visitFloat16=pc;zt.prototype.visitFloat32=pc;zt.prototype.visitFloat64=pc;zt.prototype.visitUtf8=Ls;zt.prototype.visitLargeUtf8=Ls;zt.prototype.visitBinary=Ls;zt.prototype.visitLargeBinary=Ls;zt.prototype.visitFixedSizeBinary=rB;zt.prototype.visitDate=Rp;zt.prototype.visitDateDay=Rp;zt.prototype.visitDateMillisecond=Rp;zt.prototype.visitTimestamp=rl;zt.prototype.visitTimestampSecond=rl;zt.prototype.visitTimestampMillisecond=rl;zt.prototype.visitTimestampMicrosecond=rl;zt.prototype.visitTimestampNanosecond=rl;zt.prototype.visitTime=nl;zt.prototype.visitTimeSecond=nl;zt.prototype.visitTimeMillisecond=nl;zt.prototype.visitTimeMicrosecond=nl;zt.prototype.visitTimeNanosecond=nl;zt.prototype.visitDecimal=Ls;zt.prototype.visitList=nB;zt.prototype.visitStruct=iB;zt.prototype.visitUnion=Fp;zt.prototype.visitDenseUnion=Fp;zt.prototype.visitSparseUnion=Fp;zt.prototype.visitDictionary=sB;zt.prototype.visitInterval=Dp;zt.prototype.visitIntervalDayTime=Dp;zt.prototype.visitIntervalYearMonth=Dp;zt.prototype.visitDuration=il;zt.prototype.visitDurationSecond=il;zt.prototype.visitDurationMillisecond=il;zt.prototype.visitDurationMicrosecond=il;zt.prototype.visitDurationNanosecond=il;zt.prototype.visitFixedSizeList=oB;zt.prototype.visitMap=aB;const Gn=new zt;function lB(r,t){return Gn.compareSchemas(r,t)}function uB(r,t){return Gn.compareFields(r,t)}function cB(r,t){return Gn.visit(r,t)}const ev=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},zL),eB),jN),$L),LL),zN),BL),{compareSchemas:lB,compareFields:uB,compareTypes:cB}),yT=6048e5,hB=864e5,rv=Symbol.for("constructDateFrom");function ui(r,t){return typeof r=="function"?r(t):r&&typeof r=="object"&&rv in r?r[rv](t):r instanceof Date?new r.constructor(t):new Date(t)}function an(r,t){return ui(t||r,r)}let dB={};function mc(){return dB}function Wa(r,t){var a,l,u,c;const e=mc(),n=(t==null?void 0:t.weekStartsOn)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.weekStartsOn)??e.weekStartsOn??((c=(u=e.locale)==null?void 0:u.options)==null?void 0:c.weekStartsOn)??0,i=an(r,t==null?void 0:t.in),s=i.getDay(),o=(s=s.getTime()?n+1:e.getTime()>=a.getTime()?n:n-1}function nv(r){const t=an(r),e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return e.setUTCFullYear(t.getFullYear()),+r-+e}function fB(r,...t){const e=ui.bind(null,t.find(n=>typeof n=="object"));return t.map(e)}function iv(r,t){const e=an(r,t==null?void 0:t.in);return e.setHours(0,0,0,0),e}function pB(r,t,e){const[n,i]=fB(e==null?void 0:e.in,r,t),s=iv(n),o=iv(i),a=+s-nv(s),l=+o-nv(o);return Math.round((a-l)/hB)}function mB(r,t){const e=vT(r,t),n=ui(r,0);return n.setFullYear(e,0,4),n.setHours(0,0,0,0),Gu(n)}function gB(r){return r instanceof Date||typeof r=="object"&&Object.prototype.toString.call(r)==="[object Date]"}function yB(r){return!(!gB(r)&&typeof r!="number"||isNaN(+an(r)))}function vB(r,t){const e=an(r,t==null?void 0:t.in);return e.setFullYear(e.getFullYear(),0,1),e.setHours(0,0,0,0),e}const _B={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"}},bB=(r,t,e)=>{let n;const i=_B[r];return typeof i=="string"?n=i:t===1?n=i.one:n=i.other.replace("{{count}}",t.toString()),e!=null&&e.addSuffix?e.comparison&&e.comparison>0?"in "+n:n+" ago":n};function zh(r){return(t={})=>{const e=t.width?String(t.width):r.defaultWidth;return r.formats[e]||r.formats[r.defaultWidth]}}const wB={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},xB={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},SB={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},TB={date:zh({formats:wB,defaultWidth:"full"}),time:zh({formats:xB,defaultWidth:"full"}),dateTime:zh({formats:SB,defaultWidth:"full"})},IB={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},EB=(r,t,e,n)=>IB[r];function sa(r){return(t,e)=>{const n=e!=null&&e.context?String(e.context):"standalone";let i;if(n==="formatting"&&r.formattingValues){const o=r.defaultFormattingWidth||r.defaultWidth,a=e!=null&&e.width?String(e.width):o;i=r.formattingValues[a]||r.formattingValues[o]}else{const o=r.defaultWidth,a=e!=null&&e.width?String(e.width):r.defaultWidth;i=r.values[a]||r.values[o]}const s=r.argumentCallback?r.argumentCallback(t):t;return i[s]}}const AB={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},MB={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},CB={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"]},OB={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"]},PB={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"}},RB={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"}},FB=(r,t)=>{const e=Number(r),n=e%100;if(n>20||n<10)switch(n%10){case 1:return e+"st";case 2:return e+"nd";case 3:return e+"rd"}return e+"th"},DB={ordinalNumber:FB,era:sa({values:AB,defaultWidth:"wide"}),quarter:sa({values:MB,defaultWidth:"wide",argumentCallback:r=>r-1}),month:sa({values:CB,defaultWidth:"wide"}),day:sa({values:OB,defaultWidth:"wide"}),dayPeriod:sa({values:PB,defaultWidth:"wide",formattingValues:RB,defaultFormattingWidth:"wide"})};function oa(r){return(t,e={})=>{const n=e.width,i=n&&r.matchPatterns[n]||r.matchPatterns[r.defaultMatchWidth],s=t.match(i);if(!s)return null;const o=s[0],a=n&&r.parsePatterns[n]||r.parsePatterns[r.defaultParseWidth],l=Array.isArray(a)?NB(a,h=>h.test(o)):LB(a,h=>h.test(o));let u;u=r.valueCallback?r.valueCallback(l):l,u=e.valueCallback?e.valueCallback(u):u;const c=t.slice(o.length);return{value:u,rest:c}}}function LB(r,t){for(const e in r)if(Object.prototype.hasOwnProperty.call(r,e)&&t(r[e]))return e}function NB(r,t){for(let e=0;e{const n=t.match(r.matchPattern);if(!n)return null;const i=n[0],s=t.match(r.parsePattern);if(!s)return null;let o=r.valueCallback?r.valueCallback(s[0]):s[0];o=e.valueCallback?e.valueCallback(o):o;const a=t.slice(i.length);return{value:o,rest:a}}}const UB=/^(\d+)(th|st|nd|rd)?/i,kB=/\d+/i,zB={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},VB={any:[/^b/i,/^(a|c)/i]},jB={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},$B={any:[/1/i,/2/i,/3/i,/4/i]},GB={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},WB={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]},HB={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},XB={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]},YB={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},qB={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}},QB={ordinalNumber:BB({matchPattern:UB,parsePattern:kB,valueCallback:r=>parseInt(r,10)}),era:oa({matchPatterns:zB,defaultMatchWidth:"wide",parsePatterns:VB,defaultParseWidth:"any"}),quarter:oa({matchPatterns:jB,defaultMatchWidth:"wide",parsePatterns:$B,defaultParseWidth:"any",valueCallback:r=>r+1}),month:oa({matchPatterns:GB,defaultMatchWidth:"wide",parsePatterns:WB,defaultParseWidth:"any"}),day:oa({matchPatterns:HB,defaultMatchWidth:"wide",parsePatterns:XB,defaultParseWidth:"any"}),dayPeriod:oa({matchPatterns:YB,defaultMatchWidth:"any",parsePatterns:qB,defaultParseWidth:"any"})},ZB={code:"en-US",formatDistance:bB,formatLong:TB,formatRelative:EB,localize:DB,match:QB,options:{weekStartsOn:0,firstWeekContainsDate:1}};function KB(r,t){const e=an(r,t==null?void 0:t.in);return pB(e,vB(e))+1}function JB(r,t){const e=an(r,t==null?void 0:t.in),n=+Gu(e)-+mB(e);return Math.round(n/yT)+1}function _T(r,t){var c,h,f,d;const e=an(r,t==null?void 0:t.in),n=e.getFullYear(),i=mc(),s=(t==null?void 0:t.firstWeekContainsDate)??((h=(c=t==null?void 0:t.locale)==null?void 0:c.options)==null?void 0:h.firstWeekContainsDate)??i.firstWeekContainsDate??((d=(f=i.locale)==null?void 0:f.options)==null?void 0:d.firstWeekContainsDate)??1,o=ui((t==null?void 0:t.in)||r,0);o.setFullYear(n+1,0,s),o.setHours(0,0,0,0);const a=Wa(o,t),l=ui((t==null?void 0:t.in)||r,0);l.setFullYear(n,0,s),l.setHours(0,0,0,0);const u=Wa(l,t);return+e>=+a?n+1:+e>=+u?n:n-1}function tU(r,t){var a,l,u,c;const e=mc(),n=(t==null?void 0:t.firstWeekContainsDate)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.firstWeekContainsDate)??e.firstWeekContainsDate??((c=(u=e.locale)==null?void 0:u.options)==null?void 0:c.firstWeekContainsDate)??1,i=_T(r,t),s=ui((t==null?void 0:t.in)||r,0);return s.setFullYear(i,0,n),s.setHours(0,0,0,0),Wa(s,t)}function eU(r,t){const e=an(r,t==null?void 0:t.in),n=+Wa(e,t)-+tU(e,t);return Math.round(n/yT)+1}function we(r,t){const e=r<0?"-":"",n=Math.abs(r).toString().padStart(t,"0");return e+n}const wi={y(r,t){const e=r.getFullYear(),n=e>0?e:1-e;return we(t==="yy"?n%100:n,t.length)},M(r,t){const e=r.getMonth();return t==="M"?String(e+1):we(e+1,2)},d(r,t){return we(r.getDate(),t.length)},a(r,t){const e=r.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return e.toUpperCase();case"aaa":return e;case"aaaaa":return e[0];case"aaaa":default:return e==="am"?"a.m.":"p.m."}},h(r,t){return we(r.getHours()%12||12,t.length)},H(r,t){return we(r.getHours(),t.length)},m(r,t){return we(r.getMinutes(),t.length)},s(r,t){return we(r.getSeconds(),t.length)},S(r,t){const e=t.length,n=r.getMilliseconds(),i=Math.trunc(n*Math.pow(10,e-3));return we(i,t.length)}},Xs={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},sv={G:function(r,t,e){const n=r.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return e.era(n,{width:"abbreviated"});case"GGGGG":return e.era(n,{width:"narrow"});case"GGGG":default:return e.era(n,{width:"wide"})}},y:function(r,t,e){if(t==="yo"){const n=r.getFullYear(),i=n>0?n:1-n;return e.ordinalNumber(i,{unit:"year"})}return wi.y(r,t)},Y:function(r,t,e,n){const i=_T(r,n),s=i>0?i:1-i;if(t==="YY"){const o=s%100;return we(o,2)}return t==="Yo"?e.ordinalNumber(s,{unit:"year"}):we(s,t.length)},R:function(r,t){const e=vT(r);return we(e,t.length)},u:function(r,t){const e=r.getFullYear();return we(e,t.length)},Q:function(r,t,e){const n=Math.ceil((r.getMonth()+1)/3);switch(t){case"Q":return String(n);case"QQ":return we(n,2);case"Qo":return e.ordinalNumber(n,{unit:"quarter"});case"QQQ":return e.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return e.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return e.quarter(n,{width:"wide",context:"formatting"})}},q:function(r,t,e){const n=Math.ceil((r.getMonth()+1)/3);switch(t){case"q":return String(n);case"qq":return we(n,2);case"qo":return e.ordinalNumber(n,{unit:"quarter"});case"qqq":return e.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return e.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return e.quarter(n,{width:"wide",context:"standalone"})}},M:function(r,t,e){const n=r.getMonth();switch(t){case"M":case"MM":return wi.M(r,t);case"Mo":return e.ordinalNumber(n+1,{unit:"month"});case"MMM":return e.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return e.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return e.month(n,{width:"wide",context:"formatting"})}},L:function(r,t,e){const n=r.getMonth();switch(t){case"L":return String(n+1);case"LL":return we(n+1,2);case"Lo":return e.ordinalNumber(n+1,{unit:"month"});case"LLL":return e.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return e.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return e.month(n,{width:"wide",context:"standalone"})}},w:function(r,t,e,n){const i=eU(r,n);return t==="wo"?e.ordinalNumber(i,{unit:"week"}):we(i,t.length)},I:function(r,t,e){const n=JB(r);return t==="Io"?e.ordinalNumber(n,{unit:"week"}):we(n,t.length)},d:function(r,t,e){return t==="do"?e.ordinalNumber(r.getDate(),{unit:"date"}):wi.d(r,t)},D:function(r,t,e){const n=KB(r);return t==="Do"?e.ordinalNumber(n,{unit:"dayOfYear"}):we(n,t.length)},E:function(r,t,e){const n=r.getDay();switch(t){case"E":case"EE":case"EEE":return e.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return e.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return e.day(n,{width:"short",context:"formatting"});case"EEEE":default:return e.day(n,{width:"wide",context:"formatting"})}},e:function(r,t,e,n){const i=r.getDay(),s=(i-n.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return we(s,2);case"eo":return e.ordinalNumber(s,{unit:"day"});case"eee":return e.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return e.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return e.day(i,{width:"short",context:"formatting"});case"eeee":default:return e.day(i,{width:"wide",context:"formatting"})}},c:function(r,t,e,n){const i=r.getDay(),s=(i-n.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return we(s,t.length);case"co":return e.ordinalNumber(s,{unit:"day"});case"ccc":return e.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return e.day(i,{width:"narrow",context:"standalone"});case"cccccc":return e.day(i,{width:"short",context:"standalone"});case"cccc":default:return e.day(i,{width:"wide",context:"standalone"})}},i:function(r,t,e){const n=r.getDay(),i=n===0?7:n;switch(t){case"i":return String(i);case"ii":return we(i,t.length);case"io":return e.ordinalNumber(i,{unit:"day"});case"iii":return e.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return e.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return e.day(n,{width:"short",context:"formatting"});case"iiii":default:return e.day(n,{width:"wide",context:"formatting"})}},a:function(r,t,e){const i=r.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return e.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return e.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return e.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return e.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(r,t,e){const n=r.getHours();let i;switch(n===12?i=Xs.noon:n===0?i=Xs.midnight:i=n/12>=1?"pm":"am",t){case"b":case"bb":return e.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return e.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return e.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return e.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(r,t,e){const n=r.getHours();let i;switch(n>=17?i=Xs.evening:n>=12?i=Xs.afternoon:n>=4?i=Xs.morning:i=Xs.night,t){case"B":case"BB":case"BBB":return e.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return e.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return e.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(r,t,e){if(t==="ho"){let n=r.getHours()%12;return n===0&&(n=12),e.ordinalNumber(n,{unit:"hour"})}return wi.h(r,t)},H:function(r,t,e){return t==="Ho"?e.ordinalNumber(r.getHours(),{unit:"hour"}):wi.H(r,t)},K:function(r,t,e){const n=r.getHours()%12;return t==="Ko"?e.ordinalNumber(n,{unit:"hour"}):we(n,t.length)},k:function(r,t,e){let n=r.getHours();return n===0&&(n=24),t==="ko"?e.ordinalNumber(n,{unit:"hour"}):we(n,t.length)},m:function(r,t,e){return t==="mo"?e.ordinalNumber(r.getMinutes(),{unit:"minute"}):wi.m(r,t)},s:function(r,t,e){return t==="so"?e.ordinalNumber(r.getSeconds(),{unit:"second"}):wi.s(r,t)},S:function(r,t){return wi.S(r,t)},X:function(r,t,e){const n=r.getTimezoneOffset();if(n===0)return"Z";switch(t){case"X":return av(n);case"XXXX":case"XX":return hs(n);case"XXXXX":case"XXX":default:return hs(n,":")}},x:function(r,t,e){const n=r.getTimezoneOffset();switch(t){case"x":return av(n);case"xxxx":case"xx":return hs(n);case"xxxxx":case"xxx":default:return hs(n,":")}},O:function(r,t,e){const n=r.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+ov(n,":");case"OOOO":default:return"GMT"+hs(n,":")}},z:function(r,t,e){const n=r.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+ov(n,":");case"zzzz":default:return"GMT"+hs(n,":")}},t:function(r,t,e){const n=Math.trunc(+r/1e3);return we(n,t.length)},T:function(r,t,e){return we(+r,t.length)}};function ov(r,t=""){const e=r>0?"-":"+",n=Math.abs(r),i=Math.trunc(n/60),s=n%60;return s===0?e+String(i):e+String(i)+t+we(s,2)}function av(r,t){return r%60===0?(r>0?"-":"+")+we(Math.abs(r)/60,2):hs(r,t)}function hs(r,t=""){const e=r>0?"-":"+",n=Math.abs(r),i=we(Math.trunc(n/60),2),s=we(n%60,2);return e+i+t+s}const lv=(r,t)=>{switch(r){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"})}},bT=(r,t)=>{switch(r){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"})}},rU=(r,t)=>{const e=r.match(/(P+)(p+)?/)||[],n=e[1],i=e[2];if(!i)return lv(r,t);let s;switch(n){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",lv(n,t)).replace("{{time}}",bT(i,t))},nU={p:bT,P:rU},iU=/^D+$/,sU=/^Y+$/,oU=["D","DD","YY","YYYY"];function aU(r){return iU.test(r)}function lU(r){return sU.test(r)}function uU(r,t,e){const n=cU(r,t,e);if(console.warn(n),oU.includes(r))throw new RangeError(n)}function cU(r,t,e){const n=r[0]==="Y"?"years":"days of the month";return`Use \`${r.toLowerCase()}\` instead of \`${r}\` (in \`${t}\`) for formatting ${n} to the input \`${e}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const hU=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,dU=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,fU=/^'([^]*?)'?$/,pU=/''/g,mU=/[a-zA-Z]/;function wT(r,t,e){var c,h,f,d;const n=mc(),i=n.locale??ZB,s=n.firstWeekContainsDate??((h=(c=n.locale)==null?void 0:c.options)==null?void 0:h.firstWeekContainsDate)??1,o=n.weekStartsOn??((d=(f=n.locale)==null?void 0:f.options)==null?void 0:d.weekStartsOn)??0,a=an(r,e==null?void 0:e.in);if(!yB(a))throw new RangeError("Invalid time value");let l=t.match(dU).map(m=>{const g=m[0];if(g==="p"||g==="P"){const p=nU[g];return p(m,i.formatLong)}return m}).join("").match(hU).map(m=>{if(m==="''")return{isToken:!1,value:"'"};const g=m[0];if(g==="'")return{isToken:!1,value:gU(m)};if(sv[g])return{isToken:!0,value:m};if(g.match(mU))throw new RangeError("Format string contains an unescaped latin alphabet character `"+g+"`");return{isToken:!1,value:m}});i.localize.preprocessor&&(l=i.localize.preprocessor(a,l));const u={firstWeekContainsDate:s,weekStartsOn:o,locale:i};return l.map(m=>{if(!m.isToken)return m.value;const g=m.value;(lU(g)||aU(g))&&uU(g,t,String(r));const p=sv[g[0]];return p(a,g,i.localize,u)}).join("")}function gU(r){const t=r.match(fU);return t?t[1].replace(pU,"'"):r}function yU(r,t){return an(r*1e3,t==null?void 0:t.in)}function vU(r,t){const e=_U(t)?new t(0):ui(t,0);return e.setFullYear(r.getFullYear(),r.getMonth(),r.getDate()),e.setHours(r.getHours(),r.getMinutes(),r.getSeconds(),r.getMilliseconds()),e}function _U(r){var t;return typeof r=="function"&&((t=r.prototype)==null?void 0:t.constructor)===r}function bU(r,t){let e=r.length;switch("string"){case"string":{for(;e>0&&r[e-1]===t;)e--;break}}return r.substring(0,e)}function Tr(r){return r==null}function wU(r){return r!=null}async function xT(){if(typeof window<"u"&&window!==null)return"browser";try{const r=await Ei(()=>import("./__vite-browser-external-FmFgRqLi.js"),[]);return typeof r<"u"&&r.versions!=null&&r.versions.node!=null?"node":"unknown"}catch{return"unknown"}}function xU(r){return Tr(r)?!1:Ct.isInt(r.type)&&!ST(r)||SU(r)}function SU(r){return Tr(r)?!1:Ct.isInt(r.type)&&r.type.isSigned===!1}function TU(r){return Tr(r)?!1:Ct.isFloat(r.type)??!1}function IU(r){return Tr(r)?!1:Ct.isDecimal(r.type)}function EU(r){return Tr(r)?!1:Ct.isBool(r.type)}function AU(r){return Tr(r)?!1:Ct.isDuration(r.type)}function ST(r){return Tr(r)?!1:Ct.isInt(r.type)&&r.metadata.get("ARROW:extension:name")==="period"}function MU(r){return Tr(r)?!1:Ct.isTimestamp(r.type)}function CU(r){return Tr(r)?!1:Ct.isDate(r.type)}function OU(r){return Tr(r)?!1:Ct.isTime(r.type)}function PU(r){return Tr(r)?!1:Ct.isList(r.type)||Ct.isFixedSizeList(r.type)}function RU(r){return Tr(r)?!1:Ct.isStruct(r.type)||Ct.isMap(r.type)}function FU(r){return Tr(r)?!1:Ct.isStruct(r.type)&&r.metadata.get("ARROW:extension:name")==="interval"||Ct.isInterval(r.type)}function DU(r,t){let e;if(t===te.MILLISECOND)e=1e3;else if(t===te.MICROSECOND)e=1e3*1e3;else if(t===te.NANOSECOND)e=1e3*1e3*1e3;else return Number(r);return typeof r=="bigint"&&!Number.isSafeInteger(Number(r))?Number(r/BigInt(e)):Number(r)/e}function LU(r,t){var n;const e=DU(r,((n=t==null?void 0:t.type)==null?void 0:n.unit)??te.SECOND);return yU(e)}function NU(r,t){const e=LU(r,t);return wT(e,e.getMilliseconds()===0?"HH:mm:ss":"HH:mm:ss.SSS")}function BU(r){const t="yyyy-MM-dd";return r instanceof Date||typeof r=="number"&&Number.isFinite(r)?wT(r,t):(console.warn(`Unsupported date value: ${r}`),String(r))}function UU(r,t){var i;if(!(r instanceof Date||typeof r=="number"&&Number.isFinite(r)))return console.warn(`Unsupported datetime value: ${r}`),null;let e;const n=(i=t==null?void 0:t.type)==null?void 0:i.timezone;return typeof r=="number"?n?e=new Fr(r,n):e=new Fr(r):n?e=new Fr(r,n):e=new Fr(r),vU(e,Date)}function kU(r,t){var a;const e=((a=t==null?void 0:t.type)==null?void 0:a.scale)||0;let n=ev.bigNumToString(new ev.BN(r)).padStart(e,"0");if(e===0)return n;let i="";n.startsWith("-")&&(i="-",n=n.slice(1));const s=n.slice(0,-e)||"0",o=bU(n.slice(-e),"0")||"";return`${i}${s}${o?`.${o}`:""}`}function zU(r){const t=r[0],e=r[1],n=[];return t!==0&&n.push(`${t} year${t>1?"s":""}`),e!==0&&n.push(`${e} month${e>1?"s":""}`),n.length?n.join(" "):"0 months"}function VU(r,t){var n,i,s,o;if(Ct.isInterval(t==null?void 0:t.type))return zU(r);const e=t&&t.metadata.get("ARROW:extension:name");if(e&&e==="pandas.interval"){const a=JSON.parse(t.metadata.get("ARROW:extension:metadata")),{closed:l}=a,u=r.toJSON(),c=l==="both"||l==="left"?"[":"(",h=l==="both"||l==="right"?"]":")",f=pf(u.left,(i=(n=t.type)==null?void 0:n.children)==null?void 0:i[0]),d=pf(u.right,(o=(s=t.type)==null?void 0:s.children)==null?void 0:o[1]);return`${c+f}, ${d+h}`}return String(r)}function jU(r,t){return(t==null?void 0:t.type)instanceof hf?JSON.parse(JSON.stringify(r,(e,n)=>{if(wU(n))return typeof n=="bigint"?Number(n):n})):JSON.parse(JSON.stringify(r,(e,n)=>typeof n=="bigint"?Number(n):n))}function pf(r,t){if(Tr(r))return null;const e=r instanceof Date||Number.isFinite(r);if(e&&CU(t))return BU(r);if(typeof r=="bigint"&&OU(t))return NU(Number(r),t);if(e&&MU(t))return UU(r,t);if(ST(t))throw new Error("Period type is not supported yet");if(FU(t))return VU(r,t);if(AU(t))throw new Error("Duration type is not supported yet");return IU(t)?kU(r,t):TU(t)&&Number.isFinite(r)||xU(t)?r:RU(t)||PU(t)?jU(r,t):EU(t)?!!r:String(r)}function uv(r){return((r.toArray()||[]).map(n=>n.toJSON())||[]).map(n=>(r.schema.fields.forEach(i=>n[i.name]=pf(n[i.name],i)),n))}var Ha=(r=>(r.ORIGIN_PRIVATE_FS="origin-private-fs",r.NODE_FS="node-fs",r))(Ha||{});async function TT(r){const t=M1(r,{logger:!1});let e,n;const i=await xT();if(i==="browser"){if(typeof t.bundles>"u"){const{getBundles:l}=await Ei(async()=>{const{getBundles:u}=await import("./default-browser-BrgSDbLD.js");return{getBundles:u}},[]);t.bundles=await l()}n=await Iy(await t.bundles),e=new Worker(n.mainWorker)}else if(i==="node"){if(typeof t.bundles>"u"){const{getBundles:c}=await Ei(async()=>{const{getBundles:h}=await import("./default-node-BIhtlSJe.js");return{getBundles:h}},__vite__mapDeps([0,1,2]));t.bundles=await c()}n=await Iy(await t.bundles);let l=n.mainWorker;l.startsWith("/@fs/")&&(l=l.replace("/@fs/","file://"));const u=await Ei(()=>import("./index-Cp8iQ_hy.js"),[]);e=new u.default(l,{type:"module"})}else throw new Error(`Unsupported environment: ${i}`);let s;t.logger===!0?s=new Bx:t.logger===!1?s=new PD:s=t.logger;const o=new UD(s,e);if(await o.instantiate(n.mainModule,n.pthreadWorker),t.storage)switch(t.storage.type){case Ha.ORIGIN_PRIVATE_FS:{try{let l=t.storage.path;l.startsWith("/")&&(l=l.slice(1)),await o.open({path:`opfs://${l}`,accessMode:t.storage.accessMode})}catch(l){throw await o.terminate(),await e.terminate(),l}break}case Ha.NODE_FS:{try{await o.open({path:t.storage.path,accessMode:t.storage.accessMode,useDirectIO:!0})}catch(l){throw await o.terminate(),await e.terminate(),l}break}}const a=await o.connect();return{worker:e,db:o,conn:a,query:async(l,u=[])=>{if(!u||u.length===0){const d=await a.query(l);return uv(d)}const c=await a.prepare(l),h=await c.query(...u),f=uv(h);return c.close(),f},close:async()=>{await a.close(),await o.terminate(),await e.terminate()}}}async function $U(r,t){await(await r).conn.send("BEGIN TRANSACTION");try{const e=await t(r);return await(await r).conn.send("COMMIT"),e}catch(e){throw await(await r).conn.send("ROLLBACK"),e}}async function GU(r,t,e){await(await r).conn.send(`SAVEPOINT ${t}`);try{const n=await e(r);return await(await r).conn.send(`RELEASE SAVEPOINT ${t}`),n}catch(n){throw await(await r).conn.send(`ROLLBACK TO SAVEPOINT ${t}`),n}}const St=Symbol.for("drizzle:entityKind");function lt(r,t){if(!r||typeof r!="object")return!1;if(r instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,St))throw new 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 e=Object.getPrototypeOf(r).constructor;if(e)for(;e;){if(St in e&&e[St]===t[St])return!0;e=Object.getPrototypeOf(e)}return!1}var bv;bv=St;class rr{constructor(t,e){W(this,"name");W(this,"keyAsName");W(this,"primary");W(this,"notNull");W(this,"default");W(this,"defaultFn");W(this,"onUpdateFn");W(this,"hasDefault");W(this,"isUnique");W(this,"uniqueName");W(this,"uniqueType");W(this,"dataType");W(this,"columnType");W(this,"enumValues");W(this,"generated");W(this,"generatedIdentity");W(this,"config");this.table=t,this.config=e,this.name=e.name,this.keyAsName=e.keyAsName,this.notNull=e.notNull,this.default=e.default,this.defaultFn=e.defaultFn,this.onUpdateFn=e.onUpdateFn,this.hasDefault=e.hasDefault,this.primary=e.primaryKey,this.isUnique=e.isUnique,this.uniqueName=e.uniqueName,this.uniqueType=e.uniqueType,this.dataType=e.dataType,this.columnType=e.columnType,this.generated=e.generated,this.generatedIdentity=e.generatedIdentity}mapFromDriverValue(t){return t}mapToDriverValue(t){return t}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}W(rr,bv,"Column");const Eo=Symbol.for("drizzle:Name");function WU(r,t){return`${r[Eo]}_${t.join("_")}_unique`}var wv,xv;class Lr extends(xv=rr,wv=St,xv){constructor(t,e){e.uniqueName||(e.uniqueName=WU(t,[e.name])),super(t,e),this.table=t}}W(Lr,wv,"PgColumn");const cv=Symbol.for("drizzle:isPgEnum");function HU(r){return!!r&&typeof r=="function"&&cv in r&&r[cv]===!0}var Sv;Sv=St;class Nr{constructor(t,e,n,i=!1){this._={brand:"Subquery",sql:t,selectedFields:e,alias:n,isWith:i}}}W(Nr,Sv,"Subquery");var Tv,Iv;class Lp extends(Iv=Nr,Tv=St,Iv){}W(Lp,Tv,"WithSubquery");const Ur={startActiveSpan(r,t){return t()}},Qe=Symbol.for("drizzle:ViewBaseConfig"),Kl=Symbol.for("drizzle:Schema"),mf=Symbol.for("drizzle:Columns"),hv=Symbol.for("drizzle:ExtraConfigColumns"),Vh=Symbol.for("drizzle:OriginalName"),jh=Symbol.for("drizzle:BaseName"),Wu=Symbol.for("drizzle:IsAlias"),dv=Symbol.for("drizzle:ExtraConfigBuilder"),XU=Symbol.for("drizzle:IsDrizzleTable");var Ev,Av,Mv,Cv,Ov,Pv,Rv,Fv,Dv,Lv;Lv=St,Dv=Eo,Fv=Vh,Rv=Kl,Pv=mf,Ov=hv,Cv=jh,Mv=Wu,Av=XU,Ev=dv;class It{constructor(t,e,n){W(this,Dv);W(this,Fv);W(this,Rv);W(this,Pv);W(this,Ov);W(this,Cv);W(this,Mv,!1);W(this,Av,!0);W(this,Ev);this[Eo]=this[Vh]=t,this[Kl]=e,this[jh]=n}}W(It,Lv,"Table"),W(It,"Symbol",{Name:Eo,Schema:Kl,OriginalName:Vh,Columns:mf,ExtraConfigColumns:hv,BaseName:jh,IsAlias:Wu,ExtraConfigBuilder:dv});function vs(r){return r[Eo]}function Xa(r){return`${r[Kl]??"public"}.${r[Eo]}`}function IT(r){return r!=null&&typeof r.getSQL=="function"}function YU(r){var e;const t={sql:"",params:[]};for(const n of r)t.sql+=n.sql,t.params.push(...n.params),(e=n.typings)!=null&&e.length&&(t.typings||(t.typings=[]),t.typings.push(...n.typings));return t}var Nv;Nv=St;class Ze{constructor(t){W(this,"value");this.value=Array.isArray(t)?t:[t]}getSQL(){return new Pt([this])}}W(Ze,Nv,"StringChunk");var Bv;Bv=St;const ps=class ps{constructor(t){W(this,"decoder",ET);W(this,"shouldInlineParams",!1);this.queryChunks=t}append(t){return this.queryChunks.push(...t.queryChunks),this}toQuery(t){return Ur.startActiveSpan("drizzle.buildSQL",e=>{const n=this.buildQueryFromSourceParams(this.queryChunks,t);return e==null||e.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(t,e){const n=Object.assign({},e,{inlineParams:e.inlineParams||this.shouldInlineParams,paramStartIndex:e.paramStartIndex||{value:0}}),{casing:i,escapeName:s,escapeParam:o,prepareTyping:a,inlineParams:l,paramStartIndex:u}=n;return YU(t.map(c=>{var h;if(lt(c,Ze))return{sql:c.value.join(""),params:[]};if(lt(c,Hu))return{sql:s(c.value),params:[]};if(c===void 0)return{sql:"",params:[]};if(Array.isArray(c)){const f=[new Ze("(")];for(const[d,m]of c.entries())f.push(m),dr},AT={mapToDriverValue:r=>r};({...ET,...AT});var kv;kv=St;class ci{constructor(t,e=AT){W(this,"brand");this.value=t,this.encoder=e}getSQL(){return new Pt([this])}}W(ci,kv,"Param");function Y(r,...t){const e=[];(t.length>0||r.length>0&&r[0]!=="")&&e.push(new Ze(r[0]));for(const[n,i]of t.entries())e.push(i,new Ze(r[n+1]));return new Pt(e)}(r=>{function t(){return new Pt([])}r.empty=t;function e(l){return new Pt(l)}r.fromList=e;function n(l){return new Pt([new Ze(l)])}r.raw=n;function i(l,u){const c=[];for(const[h,f]of l.entries())h>0&&u!==void 0&&c.push(u),c.push(f);return new Pt(c)}r.join=i;function s(l){return new Hu(l)}r.identifier=s;function o(l){return new Ms(l)}r.placeholder=o;function a(l,u){return new ci(l,u)}r.param=a})(Y||(Y={}));(r=>{var e;e=St;const n=class n{constructor(s,o){W(this,"isSelectionField",!1);this.sql=s,this.fieldAlias=o}getSQL(){return this.sql}clone(){return new n(this.sql,this.fieldAlias)}};W(n,e,"SQL.Aliased");let t=n;r.Aliased=t})(Pt||(Pt={}));var zv;zv=St;class Ms{constructor(t){this.name=t}getSQL(){return new Pt([this])}}W(Ms,zv,"Placeholder");function fv(r,t){return r.map(e=>{if(lt(e,Ms)){if(!(e.name in t))throw new Error(`No value for placeholder "${e.name}" was provided`);return t[e.name]}if(lt(e,ci)&<(e.value,Ms)){if(!(e.value.name in t))throw new Error(`No value for placeholder "${e.value.name}" was provided`);return e.encoder.mapToDriverValue(t[e.value.name])}return e})}const QU=Symbol.for("drizzle:IsDrizzleView");var Vv,jv,$v;$v=St,jv=Qe,Vv=QU;class ji{constructor({name:t,schema:e,selectedFields:n,query:i}){W(this,jv);W(this,Vv,!0);this[Qe]={name:t,originalName:t,schema:e,selectedFields:n,query:i,isExisting:!i,isAlias:!1}}getSQL(){return new Pt([this])}}W(ji,$v,"View");rr.prototype.getSQL=function(){return new Pt([this])};It.prototype.getSQL=function(){return new Pt([this])};Nr.prototype.getSQL=function(){return new Pt([this])};var Gv;Gv=St;class Ya{constructor(t){this.table=t}get(t,e){return e==="table"?this.table:t[e]}}W(Ya,Gv,"ColumnAliasProxyHandler");var Wv;Wv=St;class gc{constructor(t,e){this.alias=t,this.replaceOriginalName=e}get(t,e){if(e===It.Symbol.IsAlias)return!0;if(e===It.Symbol.Name)return this.alias;if(this.replaceOriginalName&&e===It.Symbol.OriginalName)return this.alias;if(e===Qe)return{...t[Qe],name:this.alias,isAlias:!0};if(e===It.Symbol.Columns){const i=t[It.Symbol.Columns];if(!i)return i;const s={};return Object.keys(i).map(o=>{s[o]=new Proxy(i[o],new Ya(new Proxy(t,this)))}),s}const n=t[e];return lt(n,rr)?new Proxy(n,new Ya(new Proxy(t,this))):n}}W(gc,Wv,"TableAliasProxyHandler");function $h(r,t){return new Proxy(r,new gc(t,!1))}function ei(r,t){return new Proxy(r,new Ya(new Proxy(r.table,new gc(t,!1))))}function MT(r,t){return new Pt.Aliased(Xu(r.sql,t),r.fieldAlias)}function Xu(r,t){return Y.join(r.queryChunks.map(e=>lt(e,rr)?ei(e,t):lt(e,Pt)?Xu(e,t):lt(e,Pt.Aliased)?MT(e,t):e))}var Hv,Xv;class Np extends(Xv=Error,Hv=St,Xv){constructor({message:t,cause:e}){super(t),this.name="DrizzleError",this.cause=e}}W(Np,Hv,"DrizzleError");var Yv,qv;class CT extends(qv=Np,Yv=St,qv){constructor(){super({message:"Rollback"})}}W(CT,Yv,"TransactionRollbackError");function Sr(r,t){return qU(t)&&!IT(r)&&!lt(r,ci)&&!lt(r,Ms)&&!lt(r,rr)&&!lt(r,It)&&!lt(r,ji)?new ci(r,t):r}const OT=(r,t)=>Y`${r} = ${Sr(t,r)}`,ZU=(r,t)=>Y`${r} <> ${Sr(t,r)}`;function gf(...r){const t=r.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new Pt(t):new Pt([new Ze("("),Y.join(t,new Ze(" and ")),new Ze(")")])}function KU(...r){const t=r.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new Pt(t):new Pt([new Ze("("),Y.join(t,new Ze(" or ")),new Ze(")")])}function JU(r){return Y`not ${r}`}const tk=(r,t)=>Y`${r} > ${Sr(t,r)}`,ek=(r,t)=>Y`${r} >= ${Sr(t,r)}`,rk=(r,t)=>Y`${r} < ${Sr(t,r)}`,nk=(r,t)=>Y`${r} <= ${Sr(t,r)}`;function ik(r,t){return Array.isArray(t)?t.length===0?Y`false`:Y`${r} in ${t.map(e=>Sr(e,r))}`:Y`${r} in ${Sr(t,r)}`}function sk(r,t){return Array.isArray(t)?t.length===0?Y`true`:Y`${r} not in ${t.map(e=>Sr(e,r))}`:Y`${r} not in ${Sr(t,r)}`}function ok(r){return Y`${r} is null`}function ak(r){return Y`${r} is not null`}function lk(r){return Y`exists ${r}`}function uk(r){return Y`not exists ${r}`}function ck(r,t,e){return Y`${r} between ${Sr(t,r)} and ${Sr(e,r)}`}function hk(r,t,e){return Y`${r} not between ${Sr(t,r)} and ${Sr(e,r)}`}function dk(r,t){return Y`${r} like ${t}`}function fk(r,t){return Y`${r} not like ${t}`}function pk(r,t){return Y`${r} ilike ${t}`}function mk(r,t){return Y`${r} not ilike ${t}`}function gk(r){return Y`${r} asc`}function yk(r){return Y`${r} desc`}var Qv;Qv=St;class PT{write(t){console.log(t)}}W(PT,Qv,"ConsoleLogWriter");var Zv;Zv=St;class RT{constructor(t){W(this,"writer");this.writer=(t==null?void 0:t.writer)??new PT}logQuery(t,e){const n=e.map(s=>{try{return JSON.stringify(s)}catch{return String(s)}}),i=n.length?` -- params: [${n.join(", ")}]`:"";this.writer.write(`Query: ${t}${i}`)}}W(RT,Zv,"DefaultLogger");var Kv;Kv=St;class FT{logQuery(){}}W(FT,Kv,"NoopLogger");var Jv,t_;t_=St,Jv=Symbol.toStringTag;class $i{constructor(){W(this,Jv,"QueryPromise")}catch(t){return this.then(void 0,t)}finally(t){return this.then(e=>(t==null||t(),e),e=>{throw t==null||t(),e})}then(t,e){return this.execute().then(t,e)}}W($i,t_,"QueryPromise");function Cs(r,t){return Object.entries(r).reduce((e,[n,i])=>{if(typeof n!="string")return e;const s=t?[...t,n]:[n];return lt(i,rr)||lt(i,Pt)||lt(i,Pt.Aliased)?e.push({path:s,field:i}):lt(i,It)?e.push(...Cs(i[It.Symbol.Columns],s)):e.push(...Cs(i,s)),e},[])}function Bp(r,t){const e=Object.keys(r),n=Object.keys(t);if(e.length!==n.length)return!1;for(const[i,s]of e.entries())if(s!==n[i])return!1;return!0}function DT(r,t){const e=Object.entries(t).filter(([,n])=>n!==void 0).map(([n,i])=>lt(i,Pt)||lt(i,rr)?[n,i]:[n,new ci(i,r[It.Symbol.Columns][n])]);if(e.length===0)throw new Error("No values to set");return Object.fromEntries(e)}function vk(r,t){for(const e of t)for(const n of Object.getOwnPropertyNames(e.prototype))n!=="constructor"&&Object.defineProperty(r.prototype,n,Object.getOwnPropertyDescriptor(e.prototype,n)||Object.create(null))}function _k(r){return r[It.Symbol.Columns]}function fs(r){return lt(r,Nr)?r._.alias:lt(r,ji)?r[Qe].name:lt(r,Pt)?void 0:r[It.Symbol.IsAlias]?r[It.Symbol.Name]:r[It.Symbol.BaseName]}function bk(r){if(typeof r!="object"||r===null||r.constructor.name!=="Object")return!1;if("logger"in r){const t=typeof r.logger;return!(t!=="boolean"&&(t!=="object"||typeof r.logger.logQuery!="function")&&t!=="undefined")}if("schema"in r){const t=typeof r.schema;return!(t!=="object"&&t!=="undefined")}if("casing"in r){const t=typeof r.casing;return!(t!=="string"&&t!=="undefined")}if("mode"in r)return!(r.mode!=="default"||r.mode!=="planetscale"||r.mode!==void 0);if("connection"in r){const t=typeof r.connection;return!(t!=="string"&&t!=="object"&&t!=="undefined")}if("client"in r){const t=typeof r.client;return!(t!=="object"&&t!=="function"&&t!=="undefined")}return Object.keys(r).length===0}var e_,r_;class LT extends(r_=Lr,e_=St,r_){getSQLType(){return"date"}mapFromDriverValue(t){return new Date(t)}mapToDriverValue(t){return t.toISOString()}}W(LT,e_,"PgDate");var n_,i_;class NT extends(i_=Lr,n_=St,i_){getSQLType(){return"date"}}W(NT,n_,"PgDateString");var s_,o_;class BT extends(o_=Lr,s_=St,o_){constructor(t,e){super(t,e)}getSQLType(){return"json"}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t}}W(BT,s_,"PgJson");var a_,l_;class UT extends(l_=Lr,a_=St,l_){constructor(t,e){super(t,e)}getSQLType(){return"jsonb"}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t}}W(UT,a_,"PgJsonb");var u_,c_;class kT extends(c_=Lr,u_=St,c_){constructor(e,n){super(e,n);W(this,"precision");W(this,"scale");this.precision=n.precision,this.scale=n.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})`}}W(kT,u_,"PgNumeric");var h_,d_;class zT extends(d_=Lr,h_=St,d_){constructor(e,n){super(e,n);W(this,"withTimezone");W(this,"precision");this.withTimezone=n.withTimezone,this.precision=n.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}W(zT,h_,"PgTime");var f_,p_;class VT extends(p_=Lr,f_=St,p_){constructor(e,n){super(e,n);W(this,"withTimezone");W(this,"precision");W(this,"mapFromDriverValue",e=>new Date(this.withTimezone?e:e+"+0000"));W(this,"mapToDriverValue",e=>e.toISOString());this.withTimezone=n.withTimezone,this.precision=n.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}}W(VT,f_,"PgTimestamp");var m_,g_;class jT extends(g_=Lr,m_=St,g_){constructor(e,n){super(e,n);W(this,"withTimezone");W(this,"precision");this.withTimezone=n.withTimezone,this.precision=n.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}W(jT,m_,"PgTimestampString");var y_,v_;class $T extends(v_=Lr,y_=St,v_){getSQLType(){return"uuid"}}W($T,y_,"PgUUID");const pv=Symbol.for("drizzle:PgInlineForeignKeys"),mv=Symbol.for("drizzle:EnableRLS");var __,b_,w_,x_,S_,T_;class Xr extends(T_=It,S_=St,x_=pv,w_=mv,b_=It.Symbol.ExtraConfigBuilder,__=It.Symbol.ExtraConfigColumns,T_){constructor(){super(...arguments);W(this,x_,[]);W(this,w_,!1);W(this,b_);W(this,__,{})}}W(Xr,S_,"PgTable"),W(Xr,"Symbol",Object.assign({},It.Symbol,{InlineForeignKeys:pv,EnableRLS:mv}));var I_;I_=St;class GT{constructor(t,e){W(this,"columns");W(this,"name");this.columns=t,this.name=e}build(t){return new WT(t,this.columns,this.name)}}W(GT,I_,"PgPrimaryKeyBuilder");var E_;E_=St;class WT{constructor(t,e,n){W(this,"columns");W(this,"name");this.table=t,this.columns=e,this.name=n}getName(){return this.name??`${this.table[Xr.Symbol.Name]}_${this.columns.map(t=>t.name).join("_")}_pk`}}W(WT,E_,"PgPrimaryKey");var A_;A_=St;class Up{constructor(t,e,n){W(this,"referencedTableName");W(this,"fieldName");this.sourceTable=t,this.referencedTable=e,this.relationName=n,this.referencedTableName=e[It.Symbol.Name]}}W(Up,A_,"Relation");var M_;M_=St;class HT{constructor(t,e){this.table=t,this.config=e}}W(HT,M_,"Relations");var C_,O_;const Qu=class Qu extends(O_=Up,C_=St,O_){constructor(t,e,n,i){super(t,e,n==null?void 0:n.relationName),this.config=n,this.isNullable=i}withFieldName(t){const e=new Qu(this.sourceTable,this.referencedTable,this.config,this.isNullable);return e.fieldName=t,e}};W(Qu,C_,"One");let Os=Qu;var P_,R_;const Zu=class Zu extends(R_=Up,P_=St,R_){constructor(t,e,n){super(t,e,n==null?void 0:n.relationName),this.config=n}withFieldName(t){const e=new Zu(this.sourceTable,this.referencedTable,this.config);return e.fieldName=t,e}};W(Zu,P_,"Many");let Yu=Zu;function wk(){return{and:gf,between:ck,eq:OT,exists:lk,gt:tk,gte:ek,ilike:pk,inArray:ik,isNull:ok,isNotNull:ak,like:dk,lt:rk,lte:nk,ne:ZU,not:JU,notBetween:hk,notExists:uk,notLike:fk,notIlike:mk,notInArray:sk,or:KU,sql:Y}}function xk(){return{sql:Y,asc:gk,desc:yk}}function Sk(r,t){var s;Object.keys(r).length===1&&"default"in r&&!lt(r.default,It)&&(r=r.default);const e={},n={},i={};for(const[o,a]of Object.entries(r))if(lt(a,It)){const l=Xa(a),u=n[l];e[l]=o,i[o]={tsName:o,dbName:a[It.Symbol.Name],schema:a[It.Symbol.Schema],columns:a[It.Symbol.Columns],relations:(u==null?void 0:u.relations)??{},primaryKey:(u==null?void 0:u.primaryKey)??[]};for(const h of Object.values(a[It.Symbol.Columns]))h.primary&&i[o].primaryKey.push(h);const c=(s=a[It.Symbol.ExtraConfigBuilder])==null?void 0:s.call(a,a[It.Symbol.ExtraConfigColumns]);if(c)for(const h of Object.values(c))lt(h,GT)&&i[o].primaryKey.push(...h.columns)}else if(lt(a,HT)){const l=Xa(a.table),u=e[l],c=a.config(t(a.table));let h;for(const[f,d]of Object.entries(c))if(u){const m=i[u];m.relations[f]=d}else l in n||(n[l]={relations:{},primaryKey:h}),n[l].relations[f]=d}return{tables:i,tableNamesMap:e}}function Tk(r){return function(e,n){return new Os(r,e,n,(n==null?void 0:n.fields.reduce((i,s)=>i&&s.notNull,!0))??!1)}}function Ik(r){return function(e,n){return new Yu(r,e,n)}}function Ek(r,t,e){if(lt(e,Os)&&e.config)return{fields:e.config.fields,references:e.config.references};const n=t[Xa(e.referencedTable)];if(!n)throw new Error(`Table "${e.referencedTable[It.Symbol.Name]}" not found in schema`);const i=r[n];if(!i)throw new Error(`Table "${n}" not found in schema`);const s=e.sourceTable,o=t[Xa(s)];if(!o)throw new Error(`Table "${s[It.Symbol.Name]}" not found in schema`);const a=[];for(const l of Object.values(i.relations))(e.relationName&&e!==l&&l.relationName===e.relationName||!e.relationName&&l.referencedTable===e.sourceTable)&&a.push(l);if(a.length>1)throw e.relationName?new Error(`There are multiple relations with name "${e.relationName}" in table "${n}"`):new Error(`There are multiple relations between "${n}" and "${e.sourceTable[It.Symbol.Name]}". Please specify relation name`);if(a[0]&<(a[0],Os)&&a[0].config)return{fields:a[0].config.references,references:a[0].config.fields};throw new Error(`There is not enough information to infer relation "${o}.${e.fieldName}"`)}function Ak(r){return{one:Tk(r),many:Ik(r)}}function yf(r,t,e,n,i=s=>s){const s={};for(const[o,a]of n.entries())if(a.isJson){const l=t.relations[a.tsKey],u=e[o],c=typeof u=="string"?JSON.parse(u):u;s[a.tsKey]=lt(l,Os)?c&&yf(r,r[a.relationTableTsKey],c,a.selection,i):c.map(h=>yf(r,r[a.relationTableTsKey],h,a.selection,i))}else{const l=i(e[o]),u=a.field;let c;lt(u,rr)?c=u:lt(u,Pt)?c=u.decoder:c=u.sql.decoder,s[a.tsKey]=l===null?null:c.mapFromDriverValue(l)}return s}var F_;F_=St;const Ku=class Ku{constructor(t){W(this,"config");this.config={...t}}get(t,e){if(e==="_")return{...t._,selectedFields:new Proxy(t._.selectedFields,this)};if(e===Qe)return{...t[Qe],selectedFields:new Proxy(t[Qe].selectedFields,this)};if(typeof e=="symbol")return t[e];const i=(lt(t,Nr)?t._.selectedFields:lt(t,ji)?t[Qe].selectedFields:t)[e];if(lt(i,Pt.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!i.isSelectionField)return i.sql;const s=i.clone();return s.isSelectionField=!0,s}if(lt(i,Pt)){if(this.config.sqlBehavior==="sql")return i;throw new Error(`You tried to reference "${e}" 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 lt(i,rr)?this.config.alias?new Proxy(i,new Ya(new Proxy(i.table,new gc(this.config.alias,this.config.replaceOriginalName??!1)))):i:typeof i!="object"||i===null?i:new Proxy(i,new Ku(this.config))}};W(Ku,F_,"SelectionProxyHandler");let or=Ku;var D_,L_;class vf extends(L_=$i,D_=St,L_){constructor(e,n,i,s){super();W(this,"config");W(this,"authToken");W(this,"execute",e=>Ur.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken)));this.session=n,this.dialect=i,this.config={table:e,withList:s}}where(e){return this.config.where=e,this}returning(e=this.config.table[It.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=Cs(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){const{typings:e,...n}=this.dialect.sqlToQuery(this.getSQL());return n}_prepare(e){return Ur.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0))}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new or({alias:vs(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}W(vf,D_,"PgDelete");function Mk(r){return(r.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join("_")}function Ck(r){return(r.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((e,n,i)=>{const s=i===0?n.toLowerCase():`${n[0].toUpperCase()}${n.slice(1)}`;return e+s},"")}function Ok(r){return r}var N_;N_=St;class XT{constructor(t){W(this,"cache",{});W(this,"cachedTables",{});W(this,"convert");this.convert=t==="snake_case"?Mk:t==="camelCase"?Ck:Ok}getColumnCasing(t){if(!t.keyAsName)return t.name;const e=t.table[It.Symbol.Schema]??"public",n=t.table[It.Symbol.OriginalName],i=`${e}.${n}.${t.name}`;return this.cache[i]||this.cacheTable(t.table),this.cache[i]}cacheTable(t){const e=t[It.Symbol.Schema]??"public",n=t[It.Symbol.OriginalName],i=`${e}.${n}`;if(!this.cachedTables[i]){for(const s of Object.values(t[It.Symbol.Columns])){const o=`${i}.${s.name}`;this.cache[o]=this.convert(s.name)}this.cachedTables[i]=!0}}clearCache(){this.cache={},this.cachedTables={}}}W(XT,N_,"CasingCache");var B_,U_;class kp extends(U_=ji,B_=St,U_){}W(kp,B_,"PgViewBase");var k_;k_=St;class Ea{constructor(t){W(this,"casing");this.casing=new XT(t==null?void 0:t.casing)}async migrate(t,e,n){const i=typeof n=="string"?"__drizzle_migrations":n.migrationsTable??"__drizzle_migrations",s=typeof n=="string"?"drizzle":n.migrationsSchema??"drizzle",o=Y` + CREATE TABLE IF NOT EXISTS ${Y.identifier(s)}.${Y.identifier(i)} ( + id SERIAL PRIMARY KEY, + hash text NOT NULL, + created_at bigint + ) + `;await e.execute(Y`CREATE SCHEMA IF NOT EXISTS ${Y.identifier(s)}`),await e.execute(o);const l=(await e.all(Y`select id, hash, created_at from ${Y.identifier(s)}.${Y.identifier(i)} order by created_at desc limit 1`))[0];await e.transaction(async u=>{for await(const c of t)if(!l||Number(l.created_at){var a;return e[o]!==void 0||((a=n[o])==null?void 0:a.onUpdateFn)!==void 0}),s=i.length;return Y.join(i.flatMap((o,a)=>{const l=n[o],u=e[o]??Y.param(l.onUpdateFn(),l),c=Y`${Y.identifier(this.casing.getColumnCasing(l))} = ${u}`;return a{const a=[];if(lt(s,Pt.Aliased)&&s.isSelectionField)a.push(Y.identifier(s.fieldAlias));else if(lt(s,Pt.Aliased)||lt(s,Pt)){const l=lt(s,Pt.Aliased)?s.sql:s;e?a.push(new Pt(l.queryChunks.map(u=>lt(u,Lr)?Y.identifier(this.casing.getColumnCasing(u)):u))):a.push(l),lt(s,Pt.Aliased)&&a.push(Y` as ${Y.identifier(s.fieldAlias)}`)}else lt(s,rr)&&(e?a.push(Y.identifier(this.casing.getColumnCasing(s))):a.push(s));return oa==null?void 0:a.some(({alias:P})=>P===(nt[It.Symbol.IsAlias]?vs(nt):nt[It.Symbol.BaseName])))(x.field.table)){const nt=vs(x.field.table);throw new Error(`Your "${x.path.join("->")}" field references a column "${nt}"."${x.field.name}", but the table "${nt}" is not part of the query! Did you forget to join it?`)}const p=!a||a.length===0,y=this.buildWithCTE(t);let _;d&&(_=d===!0?Y` distinct`:Y` distinct on (${Y.join(d.on,Y`, `)})`);const S=this.buildSelection(g,{isSingleTable:p}),T=this.buildFromTable(o),v=this.buildJoins(a),E=i?Y` where ${i}`:void 0,w=s?Y` having ${s}`:void 0;let B;l&&l.length>0&&(B=Y` order by ${Y.join(l,Y`, `)}`);let N;u&&u.length>0&&(N=Y` group by ${Y.join(u,Y`, `)}`);const $=typeof c=="object"||typeof c=="number"&&c>=0?Y` limit ${c}`:void 0,it=h?Y` offset ${h}`:void 0,I=Y.empty();if(f){const x=Y` for ${Y.raw(f.strength)}`;f.config.of&&x.append(Y` of ${Y.join(Array.isArray(f.config.of)?f.config.of:[f.config.of],Y`, `)}`),f.config.noWait?x.append(Y` no wait`):f.config.skipLocked&&x.append(Y` skip locked`),I.append(x)}const Z=Y`${y}select${_} ${S} from ${T}${v}${E}${N}${w}${B}${$}${it}${I}`;return m.length>0?this.buildSetOperations(Z,m):Z}buildSetOperations(t,e){const[n,...i]=e;if(!n)throw new Error("Cannot pass undefined values to any set operator");return i.length===0?this.buildSetOperationQuery({leftSelect:t,setOperator:n}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:t,setOperator:n}),i)}buildSetOperationQuery({leftSelect:t,setOperator:{type:e,isAll:n,rightSelect:i,limit:s,orderBy:o,offset:a}}){const l=Y`(${t.getSQL()}) `,u=Y`(${i.getSQL()})`;let c;if(o&&o.length>0){const m=[];for(const g of o)if(lt(g,Lr))m.push(Y.identifier(g.name));else if(lt(g,Pt)){for(let p=0;p=0?Y` limit ${s}`:void 0,f=Y.raw(`${e} ${n?"all ":""}`),d=a?Y` offset ${a}`:void 0;return Y`${l}${f}${u}${c}${h}${d}`}buildInsertQuery({table:t,values:e,onConflict:n,returning:i,withList:s,select:o,overridingSystemValue_:a}){const l=[],u=t[It.Symbol.Columns],c=Object.entries(u).filter(([y,_])=>!_.shouldDisableInsert()),h=c.map(([,y])=>Y.identifier(this.casing.getColumnCasing(y)));if(o){const y=e;lt(y,Pt)?l.push(y):l.push(y.getSQL())}else{const y=e;l.push(Y.raw("values "));for(const[_,S]of y.entries()){const T=[];for(const[v,E]of c){const w=S[v];if(w===void 0||lt(w,ci)&&w.value===void 0)if(E.defaultFn!==void 0){const B=E.defaultFn(),N=lt(B,Pt)?B:Y.param(B,E);T.push(N)}else if(!E.default&&E.onUpdateFn!==void 0){const B=E.onUpdateFn(),N=lt(B,Pt)?B:Y.param(B,E);T.push(N)}else T.push(Y`default`);else T.push(w)}l.push(T),_({dbKey:S.name,tsKey:_,field:ei(S,a),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{const y=Object.fromEntries(Object.entries(s.columns).map(([w,B])=>[w,ei(B,a)]));if(o.where){const w=typeof o.where=="function"?o.where(y,wk()):o.where;m=w&&Xu(w,a)}const _=[];let S=[];if(o.columns){let w=!1;for(const[B,N]of Object.entries(o.columns))N!==void 0&&B in s.columns&&(!w&&N===!0&&(w=!0),S.push(B));S.length>0&&(S=w?S.filter(B=>{var N;return((N=o.columns)==null?void 0:N[B])===!0}):Object.keys(s.columns).filter(B=>!S.includes(B)))}else S=Object.keys(s.columns);for(const w of S){const B=s.columns[w];_.push({tsKey:w,value:B})}let T=[];o.with&&(T=Object.entries(o.with).filter(w=>!!w[1]).map(([w,B])=>({tsKey:w,queryConfig:B,relation:s.relations[w]})));let v;if(o.extras){v=typeof o.extras=="function"?o.extras(y,{sql:Y}):o.extras;for(const[w,B]of Object.entries(v))_.push({tsKey:w,value:MT(B,a)})}for(const{tsKey:w,value:B}of _)c.push({dbKey:lt(B,Pt.Aliased)?B.fieldAlias:s.columns[w].name,tsKey:w,field:lt(B,rr)?ei(B,a):B,relationTableTsKey:void 0,isJson:!1,selection:[]});let E=typeof o.orderBy=="function"?o.orderBy(y,xk()):o.orderBy??[];Array.isArray(E)||(E=[E]),d=E.map(w=>lt(w,rr)?ei(w,a):Xu(w,a)),h=o.limit,f=o.offset;for(const{tsKey:w,queryConfig:B,relation:N}of T){const $=Ek(e,n,N),it=Xa(N.referencedTable),I=n[it],Z=`${a}_${w}`,x=gf(...$.fields.map((C,R)=>OT(ei($.references[R],Z),ei(C,a)))),nt=this.buildRelationalQueryWithoutPK({fullSchema:t,schema:e,tableNamesMap:n,table:t[I],tableConfig:e[I],queryConfig:lt(N,Os)?B===!0?{limit:1}:{...B,limit:1}:B,tableAlias:Z,joinOn:x,nestedQueryRelation:N}),P=Y`${Y.identifier(Z)}.${Y.identifier("data")}`.as(w);g.push({on:Y`true`,table:new Nr(nt.sql,{},Z),alias:Z,joinType:"left",lateral:!0}),c.push({dbKey:w,tsKey:w,field:P,relationTableTsKey:I,isJson:!0,selection:nt.selection})}}if(c.length===0)throw new Np({message:`No fields selected for table "${s.tsName}" ("${a}")`});let p;if(m=gf(u,m),l){let y=Y`json_build_array(${Y.join(c.map(({field:T,tsKey:v,isJson:E})=>E?Y`${Y.identifier(`${a}_${v}`)}.${Y.identifier("data")}`:lt(T,Pt.Aliased)?T.sql:T),Y`, `)})`;lt(l,Yu)&&(y=Y`coalesce(json_agg(${y}${d.length>0?Y` order by ${Y.join(d,Y`, `)}`:void 0}), '[]'::json)`);const _=[{dbKey:"data",tsKey:"data",field:y.as("data"),isJson:!0,relationTableTsKey:s.tsName,selection:c}];h!==void 0||f!==void 0||d.length>0?(p=this.buildSelectQuery({table:$h(i,a),fields:{},fieldsFlat:[{path:[],field:Y.raw("*")}],where:m,limit:h,offset:f,orderBy:d,setOperators:[]}),m=void 0,h=void 0,f=void 0,d=[]):p=$h(i,a),p=this.buildSelectQuery({table:lt(p,Xr)?p:new Nr(p,{},a),fields:{},fieldsFlat:_.map(({field:T})=>({path:[],field:lt(T,rr)?ei(T,a):T})),joins:g,where:m,limit:h,offset:f,orderBy:d,setOperators:[]})}else p=this.buildSelectQuery({table:$h(i,a),fields:{},fieldsFlat:c.map(({field:y})=>({path:[],field:lt(y,rr)?ei(y,a):y})),joins:g,where:m,limit:h,offset:f,orderBy:d,setOperators:[]});return{tableTsKey:s.tsName,sql:p,selection:c}}}W(Ea,k_,"PgDialect");var z_;z_=St;class YT{getSelectedFields(){return this._.selectedFields}}W(YT,z_,"TypedQueryBuilder");var V_;V_=St;class Or{constructor(t){W(this,"fields");W(this,"session");W(this,"dialect");W(this,"withList",[]);W(this,"distinct");W(this,"authToken");this.fields=t.fields,this.session=t.session,this.dialect=t.dialect,t.withList&&(this.withList=t.withList),this.distinct=t.distinct}setToken(t){return this.authToken=t,this}from(t){const e=!!this.fields,n=t;let i;return this.fields?i=this.fields:lt(n,Nr)?i=Object.fromEntries(Object.keys(n._.selectedFields).map(s=>[s,n[s]])):lt(n,kp)?i=n[Qe].selectedFields:lt(n,Pt)?i={}:i=_k(n),new zp({table:n,fields:i,isPartialSelect:e,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}W(Or,V_,"PgSelectBuilder");var j_,$_;class qT extends($_=YT,j_=St,$_){constructor({table:e,fields:n,isPartialSelect:i,session:s,dialect:o,withList:a,distinct:l}){super();W(this,"_");W(this,"config");W(this,"joinsNotNullableMap");W(this,"tableName");W(this,"isPartialSelect");W(this,"session");W(this,"dialect");W(this,"leftJoin",this.createJoin("left"));W(this,"rightJoin",this.createJoin("right"));W(this,"innerJoin",this.createJoin("inner"));W(this,"fullJoin",this.createJoin("full"));W(this,"union",this.createSetOperator("union",!1));W(this,"unionAll",this.createSetOperator("union",!0));W(this,"intersect",this.createSetOperator("intersect",!1));W(this,"intersectAll",this.createSetOperator("intersect",!0));W(this,"except",this.createSetOperator("except",!1));W(this,"exceptAll",this.createSetOperator("except",!0));this.config={withList:a,table:e,fields:{...n},distinct:l,setOperators:[]},this.isPartialSelect=i,this.session=s,this.dialect=o,this._={selectedFields:n},this.tableName=fs(e),this.joinsNotNullableMap=typeof this.tableName=="string"?{[this.tableName]:!0}:{}}createJoin(e){return(n,i)=>{var a;const s=this.tableName,o=fs(n);if(typeof o=="string"&&((a=this.config.joins)!=null&&a.some(l=>l.alias===o)))throw new Error(`Alias "${o}" is already used in this query`);if(!this.isPartialSelect&&(Object.keys(this.joinsNotNullableMap).length===1&&typeof s=="string"&&(this.config.fields={[s]:this.config.fields}),typeof o=="string"&&!lt(n,Pt))){const l=lt(n,Nr)?n._.selectedFields:lt(n,ji)?n[Qe].selectedFields:n[It.Symbol.Columns];this.config.fields[o]=l}if(typeof i=="function"&&(i=i(new Proxy(this.config.fields,new or({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:i,table:n,joinType:e,alias:o}),typeof o=="string")switch(e){case"left":{this.joinsNotNullableMap[o]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([l])=>[l,!1])),this.joinsNotNullableMap[o]=!0;break}case"inner":{this.joinsNotNullableMap[o]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([l])=>[l,!1])),this.joinsNotNullableMap[o]=!1;break}}return this}}createSetOperator(e,n){return i=>{const s=typeof i=="function"?i(Pk()):i;if(!Bp(this.getSelectedFields(),s.getSelectedFields()))throw new 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:n,rightSelect:s}),this}}addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return typeof e=="function"&&(e=e(new Proxy(this.config.fields,new or({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return typeof e=="function"&&(e=e(new Proxy(this.config.fields,new or({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=e,this}groupBy(...e){if(typeof e[0]=="function"){const n=e[0](new Proxy(this.config.fields,new or({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(n)?n:[n]}else this.config.groupBy=e;return this}orderBy(...e){if(typeof e[0]=="function"){const n=e[0](new Proxy(this.config.fields,new or({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(n)?n:[n];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=i:this.config.orderBy=i}else{const n=e;this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=n:this.config.orderBy=n}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,n={}){return this.config.lockingClause={strength:e,config:n},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){const{typings:e,...n}=this.dialect.sqlToQuery(this.getSQL());return n}as(e){return new Proxy(new Nr(this.getSQL(),this.config.fields,e),new or({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new or({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}}W(qT,j_,"PgSelectQueryBuilder");var G_,W_;class zp extends(W_=qT,G_=St,W_){constructor(){super(...arguments);W(this,"authToken");W(this,"execute",e=>Ur.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken)))}_prepare(e){const{session:n,config:i,dialect:s,joinsNotNullableMap:o,authToken:a}=this;if(!n)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");return Ur.startActiveSpan("drizzle.prepareQuery",()=>{const l=Cs(i.fields),u=n.prepareQuery(s.sqlToQuery(this.getSQL()),l,e,!0);return u.joinsNotNullableMap=o,u.setToken(a)})}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}}W(zp,G_,"PgSelect");vk(zp,[$i]);function zo(r,t){return(e,n,...i)=>{const s=[n,...i].map(o=>({type:r,isAll:t,rightSelect:o}));for(const o of s)if(!Bp(e.getSelectedFields(),o.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return e.addSetOperators(s)}}const Pk=()=>({union:Rk,unionAll:Fk,intersect:Dk,intersectAll:Lk,except:Nk,exceptAll:Bk}),Rk=zo("union",!1),Fk=zo("union",!0),Dk=zo("intersect",!1),Lk=zo("intersect",!0),Nk=zo("except",!1),Bk=zo("except",!0);var H_;H_=St;class Vp{constructor(t){W(this,"dialect");W(this,"dialectConfig");W(this,"$with",(t,e)=>{const n=this;return{as:s=>(typeof s=="function"&&(s=s(n)),new Proxy(new Lp(s.getSQL(),e??("getSelectedFields"in s?s.getSelectedFields()??{}:{}),t,!0),new or({alias:t,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}});this.dialect=lt(t,Ea)?t:void 0,this.dialectConfig=lt(t,Ea)?void 0:t}with(...t){const e=this;function n(o){return new Or({fields:o??void 0,session:void 0,dialect:e.getDialect(),withList:t})}function i(o){return new Or({fields:o??void 0,session:void 0,dialect:e.getDialect(),distinct:!0})}function s(o,a){return new Or({fields:a??void 0,session:void 0,dialect:e.getDialect(),distinct:{on:o}})}return{select:n,selectDistinct:i,selectDistinctOn:s}}select(t){return new Or({fields:t??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(t){return new Or({fields:t??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn(t,e){return new Or({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:t}})}getDialect(){return this.dialect||(this.dialect=new Ea(this.dialectConfig)),this.dialect}}W(Vp,H_,"PgQueryBuilder");var X_;X_=St;class _f{constructor(t,e,n,i,s){W(this,"authToken");this.table=t,this.session=e,this.dialect=n,this.withList=i,this.overridingSystemValue_=s}setToken(t){return this.authToken=t,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values(t){if(t=Array.isArray(t)?t:[t],t.length===0)throw new Error("values() must be called with at least one value");const e=t.map(n=>{const i={},s=this.table[It.Symbol.Columns];for(const o of Object.keys(n)){const a=n[o];i[o]=lt(a,Pt)?a:new ci(a,s[o])}return i});return new bf(this.table,e,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select(t){const e=typeof t=="function"?t(new Vp):t;if(!lt(e,Pt)&&!Bp(this.table[mf],e._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new bf(this.table,e,this.session,this.dialect,this.withList,!0)}}W(_f,X_,"PgInsertBuilder");var Y_,q_;class bf extends(q_=$i,Y_=St,q_){constructor(e,n,i,s,o,a,l){super();W(this,"config");W(this,"authToken");W(this,"execute",e=>Ur.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken)));this.session=i,this.dialect=s,this.config={table:e,values:n,withList:o,select:a,overridingSystemValue_:l}}returning(e=this.config.table[It.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=Cs(e),this}onConflictDoNothing(e={}){if(e.target===void 0)this.config.onConflict=Y`do nothing`;else{let n="";n=Array.isArray(e.target)?e.target.map(s=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(s))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target));const i=e.where?Y` where ${e.where}`:void 0;this.config.onConflict=Y`(${Y.raw(n)})${i} do nothing`}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');const n=e.where?Y` where ${e.where}`:void 0,i=e.targetWhere?Y` where ${e.targetWhere}`:void 0,s=e.setWhere?Y` where ${e.setWhere}`:void 0,o=this.dialect.buildUpdateSet(this.config.table,DT(this.config.table,e.set));let a="";return a=Array.isArray(e.target)?e.target.map(l=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(l))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target)),this.config.onConflict=Y`(${Y.raw(a)})${i} do update set ${o}${n}${s}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){const{typings:e,...n}=this.dialect.sqlToQuery(this.getSQL());return n}_prepare(e){return Ur.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0))}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new or({alias:vs(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}W(bf,Y_,"PgInsert");var Q_,Z_;class QT extends(Z_=$i,Q_=St,Z_){constructor(e,n,i){super();W(this,"config");W(this,"authToken");W(this,"execute",e=>Ur.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken)));this.session=n,this.dialect=i,this.config={view:e}}concurrently(){if(this.config.withNoData!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){const{typings:e,...n}=this.dialect.sqlToQuery(this.getSQL());return n}_prepare(e){return Ur.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,e,!0))}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}}W(QT,Q_,"PgRefreshMaterializedView");var K_;K_=St;class wf{constructor(t,e,n,i){W(this,"authToken");this.table=t,this.session=e,this.dialect=n,this.withList=i}setToken(t){return this.authToken=t,this}set(t){return new ZT(this.table,DT(this.table,t),this.session,this.dialect,this.withList).setToken(this.authToken)}}W(wf,K_,"PgUpdateBuilder");var J_,t0;class ZT extends(t0=$i,J_=St,t0){constructor(e,n,i,s,o){super();W(this,"config");W(this,"tableName");W(this,"joinsNotNullableMap");W(this,"leftJoin",this.createJoin("left"));W(this,"rightJoin",this.createJoin("right"));W(this,"innerJoin",this.createJoin("inner"));W(this,"fullJoin",this.createJoin("full"));W(this,"authToken");W(this,"execute",e=>this._prepare().execute(e,this.authToken));this.session=i,this.dialect=s,this.config={set:n,table:e,withList:o,joins:[]},this.tableName=fs(e),this.joinsNotNullableMap=typeof this.tableName=="string"?{[this.tableName]:!0}:{}}from(e){const n=e,i=fs(n);return typeof i=="string"&&(this.joinsNotNullableMap[i]=!0),this.config.from=n,this}getTableLikeFields(e){return lt(e,Xr)?e[It.Symbol.Columns]:lt(e,Nr)?e._.selectedFields:e[Qe].selectedFields}createJoin(e){return(n,i)=>{const s=fs(n);if(typeof s=="string"&&this.config.joins.some(o=>o.alias===s))throw new Error(`Alias "${s}" is already used in this query`);if(typeof i=="function"){const o=this.config.from&&!lt(this.config.from,Pt)?this.getTableLikeFields(this.config.from):void 0;i=i(new Proxy(this.config.table[It.Symbol.Columns],new or({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),o&&new Proxy(o,new or({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:i,table:n,joinType:e,alias:s}),typeof s=="string")switch(e){case"left":{this.joinsNotNullableMap[s]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([o])=>[o,!1])),this.joinsNotNullableMap[s]=!0;break}case"inner":{this.joinsNotNullableMap[s]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([o])=>[o,!1])),this.joinsNotNullableMap[s]=!1;break}}return this}}where(e){return this.config.where=e,this}returning(e){if(!e&&(e=Object.assign({},this.config.table[It.Symbol.Columns]),this.config.from)){const n=fs(this.config.from);if(typeof n=="string"&&this.config.from&&!lt(this.config.from,Pt)){const i=this.getTableLikeFields(this.config.from);e[n]=i}for(const i of this.config.joins){const s=fs(i.table);if(typeof s=="string"&&!lt(i.table,Pt)){const o=this.getTableLikeFields(i.table);e[s]=o}}}return this.config.returningFields=e,this.config.returning=Cs(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){const{typings:e,...n}=this.dialect.sqlToQuery(this.getSQL());return n}_prepare(e){const n=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0);return n.joinsNotNullableMap=this.joinsNotNullableMap,n}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new or({alias:vs(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}W(ZT,J_,"PgUpdate");var e0,r0,n0;const Ma=class Ma extends(n0=Pt,r0=St,e0=Symbol.toStringTag,n0){constructor(e){super(Ma.buildEmbeddedCount(e.source,e.filters).queryChunks);W(this,"sql");W(this,"token");W(this,e0,"PgCountBuilder");W(this,"session");this.params=e,this.mapWith(Number),this.session=e.session,this.sql=Ma.buildCount(e.source,e.filters)}static buildEmbeddedCount(e,n){return Y`(select count(*) from ${e}${Y.raw(" where ").if(n)}${n})`}static buildCount(e,n){return Y`select count(*) as count from ${e}${Y.raw(" where ").if(n)}${n};`}setToken(e){return this.token=e,this}then(e,n){return Promise.resolve(this.session.count(this.sql,this.token)).then(e,n)}catch(e){return this.then(void 0,e)}finally(e){return this.then(n=>(e==null||e(),n),n=>{throw e==null||e(),n})}};W(Ma,r0,"PgCountBuilder");let xf=Ma;var i0;i0=St;class KT{constructor(t,e,n,i,s,o,a){this.fullSchema=t,this.schema=e,this.tableNamesMap=n,this.table=i,this.tableConfig=s,this.dialect=o,this.session=a}findMany(t){return new Sf(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,t||{},"many")}findFirst(t){return new Sf(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,t?{...t,limit:1}:{limit:1},"first")}}W(KT,i0,"PgRelationalQueryBuilder");var s0,o0;class Sf extends(o0=$i,s0=St,o0){constructor(e,n,i,s,o,a,l,u,c){super();W(this,"authToken");this.fullSchema=e,this.schema=n,this.tableNamesMap=i,this.table=s,this.tableConfig=o,this.dialect=a,this.session=l,this.config=u,this.mode=c}_prepare(e){return Ur.startActiveSpan("drizzle.prepareQuery",()=>{const{query:n,builtQuery:i}=this._toSQL();return this.session.prepareQuery(i,void 0,e,!0,(s,o)=>{const a=s.map(l=>yf(this.schema,this.tableConfig,l,n.selection,o));return this.mode==="first"?a[0]:a})})}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(){const e=this._getQuery(),n=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:n}}toSQL(){return this._toSQL().builtQuery}setToken(e){return this.authToken=e,this}execute(){return Ur.startActiveSpan("drizzle.operation",()=>this._prepare().execute(void 0,this.authToken))}}W(Sf,s0,"PgRelationalQuery");var a0,l0;class JT extends(l0=$i,a0=St,l0){constructor(t,e,n,i){super(),this.execute=t,this.sql=e,this.query=n,this.mapBatchResult=i}getSQL(){return this.sql}getQuery(){return this.query}mapResult(t,e){return e?this.mapBatchResult(t):t}_prepare(){return this}isResponseInArrayMode(){return!1}}W(JT,a0,"PgRaw");var u0;u0=St;class jp{constructor(t,e,n){W(this,"query");W(this,"$with",(t,e)=>{const n=this;return{as:s=>(typeof s=="function"&&(s=s(new Vp(n.dialect))),new Proxy(new Lp(s.getSQL(),e??("getSelectedFields"in s?s.getSelectedFields()??{}:{}),t,!0),new or({alias:t,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}});W(this,"authToken");if(this.dialect=t,this.session=e,this._=n?{schema:n.schema,fullSchema:n.fullSchema,tableNamesMap:n.tableNamesMap,session:e}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:e},this.query={},this._.schema)for(const[i,s]of Object.entries(this._.schema))this.query[i]=new KT(n.fullSchema,this._.schema,this._.tableNamesMap,n.fullSchema[i],s,t,e)}$count(t,e){return new xf({source:t,filters:e,session:this.session})}with(...t){const e=this;function n(u){return new Or({fields:u??void 0,session:e.session,dialect:e.dialect,withList:t})}function i(u){return new Or({fields:u??void 0,session:e.session,dialect:e.dialect,withList:t,distinct:!0})}function s(u,c){return new Or({fields:c??void 0,session:e.session,dialect:e.dialect,withList:t,distinct:{on:u}})}function o(u){return new wf(u,e.session,e.dialect,t)}function a(u){return new _f(u,e.session,e.dialect,t)}function l(u){return new vf(u,e.session,e.dialect,t)}return{select:n,selectDistinct:i,selectDistinctOn:s,update:o,insert:a,delete:l}}select(t){return new Or({fields:t??void 0,session:this.session,dialect:this.dialect})}selectDistinct(t){return new Or({fields:t??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn(t,e){return new Or({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:{on:t}})}update(t){return new wf(t,this.session,this.dialect)}insert(t){return new _f(t,this.session,this.dialect)}delete(t){return new vf(t,this.session,this.dialect)}refreshMaterializedView(t){return new QT(t,this.session,this.dialect)}execute(t){const e=typeof t=="string"?Y.raw(t):t.getSQL(),n=this.dialect.sqlToQuery(e),i=this.session.prepareQuery(n,void 0,void 0,!1);return new JT(()=>i.execute(void 0,this.authToken),e,n,s=>i.mapResult(s,!0))}transaction(t,e){return this.session.transaction(t,e)}}W(jp,u0,"PgDatabase");var c0;c0=St;class t1{constructor(t){W(this,"authToken");W(this,"joinsNotNullableMap");this.query=t}getQuery(){return this.query}mapResult(t,e){return t}setToken(t){return this.authToken=t,this}}W(t1,c0,"PgPreparedQuery");var h0;h0=St;class e1{constructor(t){this.dialect=t}execute(t,e){return Ur.startActiveSpan("drizzle.operation",()=>Ur.startActiveSpan("drizzle.prepareQuery",()=>this.prepareQuery(this.dialect.sqlToQuery(t),void 0,void 0,!1)).setToken(e).execute(void 0,e))}all(t){return this.prepareQuery(this.dialect.sqlToQuery(t),void 0,void 0,!1).all()}async count(t,e){const n=await this.execute(t,e);return Number(n[0].count)}}W(e1,h0,"PgSession");var d0,f0;class r1 extends(f0=jp,d0=St,f0){constructor(t,e,n,i=0){super(t,e,n),this.schema=n,this.nestedIndex=i}rollback(){throw new CT}getTransactionConfigSQL(t){const e=[];return t.isolationLevel&&e.push(`isolation level ${t.isolationLevel}`),t.accessMode&&e.push(t.accessMode),typeof t.deferrable=="boolean"&&e.push(t.deferrable?"deferrable":"not deferrable"),Y.raw(e.join(" "))}setTransaction(t){return this.session.execute(Y`set transaction ${this.getTransactionConfigSQL(t)}`)}}W(r1,d0,"PgTransaction");function gv(r){return typeof r=="string"&&/^true$/i.test(r)}function Uk(r){const t={scheme:"duckdb-wasm:"},e=new URL(r);if(!e.protocol.startsWith("duckdb-wasm:"))throw new Error(`Expected scheme to be "duckdb-wasm:" but got "${e.protocol}"`);e.searchParams.get("bundles")==="import-url"&&(t.bundles="import-url");const n=e.searchParams.get("logger");n&&gv(n)&&(t.logger=!0);const i=e.searchParams.get("storage");switch(i){case Ha.ORIGIN_PRIVATE_FS:{e.host.length>0&&console.warn(`Host "${e.host}" will be ignored while using Origin Private FS`);const s=e.searchParams.get("write");t.storage={type:Ha.ORIGIN_PRIVATE_FS,path:e.pathname.startsWith("/")?e.pathname.slice(1):e.pathname,...s&&gv(s)&&{accessMode:Nx.READ_WRITE}};break}case null:break;default:console.warn(`Unknown storage type "${i}"`);break}return t}var p0,m0;class n1 extends(m0=t1,p0=St,m0){constructor(t,e,n,i,s,o){super({sql:e,params:n}),this.client=t,this.queryString=e,this.params=n,this.logger=i,this.fields=s,this.customResultMapper=o}async execute(t={}){const e=fv(this.params,t);this.logger.logQuery(this.queryString,e);const{fields:n,queryString:i,client:s,customResultMapper:o}=this,a=await s;return a.query(i,e)}async all(t={}){const e=fv(this.params,t);return this.logger.logQuery(this.queryString,e),(await this.client).query(this.queryString,e)}}W(n1,p0,"DuckDBWasmPreparedQuery");var g0,y0;const Ju=class Ju extends(y0=e1,g0=St,y0){constructor(e,n,i,s={}){super(n);W(this,"logger");this.client=e,this.schema=i,this.options=s,this.logger=s.logger??new FT}prepareQuery(e,n,i,s,o){return new n1(this.client,e.sql,e.params,this.logger,n,o)}async query(e,n){return this.logger.logQuery(e,n),(await this.client).query(e,n)}async queryObjects(e,n){return this.logger.logQuery(e,n),(await this.client).query(e,n)}transaction(e,n){return $U(this.client,async i=>{const s=new Ju(i,this.dialect,this.schema,this.options),o=new Tf(this.dialect,s,this.schema);return n&&await o.setTransaction(n),e(o)})}};W(Ju,g0,"DuckDBWasmSession");let qu=Ju;var v0,_0;const tc=class tc extends(_0=r1,v0=St,_0){constructor(e,n,i,s=0){super(e,n,i,s);W(this,"dialect");W(this,"session");this.dialect=e,this.session=n}async transaction(e){return GU(this.session.client,"",async n=>{const i=new qu(n,this.dialect,this.schema,this.session.options),s=new tc(this.dialect,i,this.schema);return e(s)})}};W(tc,v0,"DuckDBWasmTransaction");let Tf=tc;var b0,w0;class i1 extends(w0=jp,b0=St,w0){}W(i1,b0,"DuckDBWasmDatabase");function Aa(r,t={}){const e=new Ea({casing:t.casing});let n;t.logger===!0?n=new RT:t.logger!==!1&&(n=t.logger);let i;if(t.schema){const a=Sk(t.schema,Ak);i={fullSchema:t.schema,schema:a.tables,tableNamesMap:a.tableNamesMap}}const s=new qu(r,e,i,{logger:n}),o=new i1(e,s,i);return o.$client=r,o}async function kk(r=!1){const t=await xT();switch(t){case"browser":return r?(await Ei(async()=>{const{getImportUrlBundles:e}=await import("./import-url-browser-CPN8ipMD.js");return{getImportUrlBundles:e}},__vite__mapDeps([3,4]))).getImportUrlBundles():(await Ei(async()=>{const{getBundles:e}=await import("./default-browser-BrgSDbLD.js");return{getBundles:e}},[])).getBundles();case"node":return r?await(await Ei(async()=>{const{getImportUrlBundles:e}=await import("./import-url-node-BfNoxhRr.js");return{getImportUrlBundles:e}},__vite__mapDeps([5,4]))).getImportUrlBundles():await(await Ei(async()=>{const{getBundles:e}=await import("./default-node-BIhtlSJe.js");return{getBundles:e}},__vite__mapDeps([0,1,2]))).getBundles();default:throw new Error(`Unsupported environment: "${t}"`)}}function yv(r,t){const e=Uk(r);return Aa(TT({bundles:kk(e.bundles==="import-url"),logger:e.logger?new Bx:void 0,storage:e.storage}),t)}function vv(...r){if(typeof r[0]=="string")return yv(r[0],r[1]);if(bk(r[0])){const{connection:t,client:e,...n}=r[0];if(e)return Aa(e,n);if(typeof t=="string")return yv(t,n);if(typeof t>"u")throw new Error("connection option is required");return Aa(TT({bundles:t.bundles,logger:t.logger,storage:t.storage}),n)}return Aa(r[0],r[1])}(r=>{function t(e){return Aa({options:{parsers:{},serializers:{}}},e)}r.mock=t})(vv||(vv={}));var Gh={exports:{}};/*! + +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 +*/var _v;function zk(){return _v||(_v=1,function(r,t){(function(e){r.exports=e()})(function(){return function e(n,i,s){function o(u,c){if(!i[u]){if(!n[u]){var h=typeof Ai=="function"&&Ai;if(!c&&h)return h(u,!0);if(a)return a(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var d=i[u]={exports:{}};n[u][0].call(d.exports,function(m){var g=n[u][1][m];return o(g||m)},d,d.exports,e,n,i,s)}return i[u].exports}for(var a=typeof Ai=="function"&&Ai,l=0;l>2,d=(3&u)<<4|c>>4,m=1>6:64,g=2>4,c=(15&f)<<4|(d=a.indexOf(l.charAt(g++)))>>2,h=(3&d)<<6|(m=a.indexOf(l.charAt(g++))),_[p++]=u,d!==64&&(_[p++]=c),m!==64&&(_[p++]=h);return _}},{"./support":30,"./utils":32}],2:[function(e,n,i){var s=e("./external"),o=e("./stream/DataWorker"),a=e("./stream/Crc32Probe"),l=e("./stream/DataLengthProbe");function u(c,h,f,d,m){this.compressedSize=c,this.uncompressedSize=h,this.crc32=f,this.compression=d,this.compressedContent=m}u.prototype={getContentWorker:function(){var c=new o(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),h=this;return c.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),c},getCompressedWorker:function(){return new o(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(c,h,f){return c.pipe(new a).pipe(new l("uncompressedSize")).pipe(h.compressWorker(f)).pipe(new l("compressedSize")).withStreamInfo("compression",h)},n.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,n,i){var s=e("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,n,i){var s=e("./utils"),o=function(){for(var a,l=[],u=0;u<256;u++){a=u;for(var c=0;c<8;c++)a=1&a?3988292384^a>>>1:a>>>1;l[u]=a}return l}();n.exports=function(a,l){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?function(u,c,h,f){var d=o,m=f+h;u^=-1;for(var g=f;g>>8^d[255&(u^c[g])];return-1^u}(0|l,a,a.length,0):function(u,c,h,f){var d=o,m=f+h;u^=-1;for(var g=f;g>>8^d[255&(u^c.charCodeAt(g))];return-1^u}(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(e,n,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(e,n,i){var s=null;s=typeof Promise<"u"?Promise:e("lie"),n.exports={Promise:s}},{lie:37}],7:[function(e,n,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=e("pako"),a=e("./utils"),l=e("./stream/GenericWorker"),u=s?"uint8array":"array";function c(h,f){l.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=f,this.meta={}}i.magic="\b\0",a.inherits(c,l),c.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(u,h.data),!1)},c.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var h=this;this._pako.onData=function(f){h.push({data:f,meta:h.meta})}},i.compressWorker=function(h){return new c("Deflate",h)},i.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,n,i){function s(d,m){var g,p="";for(g=0;g>>=8;return p}function o(d,m,g,p,y,_){var S,T,v=d.file,E=d.compression,w=_!==u.utf8encode,B=a.transformTo("string",_(v.name)),N=a.transformTo("string",u.utf8encode(v.name)),$=v.comment,it=a.transformTo("string",_($)),I=a.transformTo("string",u.utf8encode($)),Z=N.length!==v.name.length,x=I.length!==$.length,nt="",P="",C="",R=v.dir,z=v.date,U={crc32:0,compressedSize:0,uncompressedSize:0};m&&!g||(U.crc32=d.crc32,U.compressedSize=d.compressedSize,U.uncompressedSize=d.uncompressedSize);var M=0;m&&(M|=8),w||!Z&&!x||(M|=2048);var O=0,j=0;R&&(O|=16),y==="UNIX"?(j=798,O|=function(tt,gt){var _t=tt;return tt||(_t=gt?16893:33204),(65535&_t)<<16}(v.unixPermissions,R)):(j=20,O|=function(tt){return 63&(tt||0)}(v.dosPermissions)),S=z.getUTCHours(),S<<=6,S|=z.getUTCMinutes(),S<<=5,S|=z.getUTCSeconds()/2,T=z.getUTCFullYear()-1980,T<<=4,T|=z.getUTCMonth()+1,T<<=5,T|=z.getUTCDate(),Z&&(P=s(1,1)+s(c(B),4)+N,nt+="up"+s(P.length,2)+P),x&&(C=s(1,1)+s(c(it),4)+I,nt+="uc"+s(C.length,2)+C);var et="";return et+=` +\0`,et+=s(M,2),et+=E.magic,et+=s(S,2),et+=s(T,2),et+=s(U.crc32,4),et+=s(U.compressedSize,4),et+=s(U.uncompressedSize,4),et+=s(B.length,2),et+=s(nt.length,2),{fileRecord:h.LOCAL_FILE_HEADER+et+B+nt,dirRecord:h.CENTRAL_FILE_HEADER+s(j,2)+et+s(it.length,2)+"\0\0\0\0"+s(O,4)+s(p,4)+B+nt+it}}var a=e("../utils"),l=e("../stream/GenericWorker"),u=e("../utf8"),c=e("../crc32"),h=e("../signature");function f(d,m,g,p){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=g,this.encodeFileName=p,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(f,l),f.prototype.push=function(d){var m=d.meta.percent||0,g=this.entriesCount,p=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,l.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:g?(m+100*(g-p-1))/g:100}}))},f.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var m=this.streamFiles&&!d.file.dir;if(m){var g=o(d,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(d){this.accumulate=!1;var m=this.streamFiles&&!d.file.dir,g=o(d,m,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),m)this.push({data:function(p){return h.DATA_DESCRIPTOR+s(p.crc32,4)+s(p.compressedSize,4)+s(p.uncompressedSize,4)}(d),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var d=this.bytesWritten,m=0;m=this.index;l--)u=(u<<8)+this.byteAt(l);return this.index+=a,u},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},n.exports=o},{"../utils":32}],19:[function(e,n,i){var s=e("./Uint8ArrayReader");function o(a){s.call(this,a)}e("../utils").inherits(o,s),o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,n,i){var s=e("./DataReader");function o(a){s.call(this,a)}e("../utils").inherits(o,s),o.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},o.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},o.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./DataReader":18}],21:[function(e,n,i){var s=e("./ArrayReader");function o(a){s.call(this,a)}e("../utils").inherits(o,s),o.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(e,n,i){var s=e("../utils"),o=e("../support"),a=e("./ArrayReader"),l=e("./StringReader"),u=e("./NodeBufferReader"),c=e("./Uint8ArrayReader");n.exports=function(h){var f=s.getTypeOf(h);return s.checkSupport(f),f!=="string"||o.uint8array?f==="nodebuffer"?new u(h):o.uint8array?new c(s.transformTo("uint8array",h)):new a(s.transformTo("array",h)):new l(h)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,n,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(e,n,i){var s=e("./GenericWorker"),o=e("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}o.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:o.transformTo(this.destType,l.data),meta:l.meta})},n.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(e,n,i){var s=e("./GenericWorker"),o=e("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(a,s),a.prototype.processChunk=function(l){this.streamInfo.crc32=o(l.data,this.streamInfo.crc32||0),this.push(l)},n.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,n,i){var s=e("../utils"),o=e("./GenericWorker");function a(l){o.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,o),a.prototype.processChunk=function(l){if(l){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+l.data.length}o.prototype.processChunk.call(this,l)},n.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(e,n,i){var s=e("../utils"),o=e("./GenericWorker");function a(l){o.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(c){u.dataIsReady=!0,u.data=c,u.max=c&&c.length||0,u.type=s.getTypeOf(c),u.isPaused||u._tickAndRepeat()},function(c){u.error(c)})}s.inherits(a,o),a.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,u);break;case"uint8array":l=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":l=this.data.slice(this.index,u)}return this.index=u,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(e,n,i){function s(o){this.name=o||"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}s.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,a){return this._listeners[o].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,a){if(this._listeners[o])for(var l=0;l "+o:o}},n.exports=s},{}],29:[function(e,n,i){var s=e("../utils"),o=e("./ConvertWorker"),a=e("./GenericWorker"),l=e("../base64"),u=e("../support"),c=e("../external"),h=null;if(u.nodestream)try{h=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function f(m,g){return new c.Promise(function(p,y){var _=[],S=m._internalType,T=m._outputType,v=m._mimeType;m.on("data",function(E,w){_.push(E),g&&g(w)}).on("error",function(E){_=[],y(E)}).on("end",function(){try{var E=function(w,B,N){switch(w){case"blob":return s.newBlob(s.transformTo("arraybuffer",B),N);case"base64":return l.encode(B);default:return s.transformTo(w,B)}}(T,function(w,B){var N,$=0,it=null,I=0;for(N=0;N"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(s),i.blob=o.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!e("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(e,n,i){for(var s=e("./utils"),o=e("./support"),a=e("./nodejsUtils"),l=e("./stream/GenericWorker"),u=new Array(256),c=0;c<256;c++)u[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;u[254]=u[254]=1;function h(){l.call(this,"utf-8 decode"),this.leftOver=null}function f(){l.call(this,"utf-8 encode")}i.utf8encode=function(d){return o.nodebuffer?a.newBufferFrom(d,"utf-8"):function(m){var g,p,y,_,S,T=m.length,v=0;for(_=0;_>>6:(p<65536?g[S++]=224|p>>>12:(g[S++]=240|p>>>18,g[S++]=128|p>>>12&63),g[S++]=128|p>>>6&63),g[S++]=128|63&p);return g}(d)},i.utf8decode=function(d){return o.nodebuffer?s.transformTo("nodebuffer",d).toString("utf-8"):function(m){var g,p,y,_,S=m.length,T=new Array(2*S);for(g=p=0;g>10&1023,T[p++]=56320|1023&y)}return T.length!==p&&(T.subarray?T=T.subarray(0,p):T.length=p),s.applyFromCharCode(T)}(d=s.transformTo(o.uint8array?"uint8array":"array",d))},s.inherits(h,l),h.prototype.processChunk=function(d){var m=s.transformTo(o.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var g=m;(m=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),m.set(g,this.leftOver.length)}else m=this.leftOver.concat(m);this.leftOver=null}var p=function(_,S){var T;for((S=S||_.length)>_.length&&(S=_.length),T=S-1;0<=T&&(192&_[T])==128;)T--;return T<0||T===0?S:T+u[_[T]]>S?T:S}(m),y=m;p!==m.length&&(o.uint8array?(y=m.subarray(0,p),this.leftOver=m.subarray(p,m.length)):(y=m.slice(0,p),this.leftOver=m.slice(p,m.length))),this.push({data:i.utf8decode(y),meta:d.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=h,s.inherits(f,l),f.prototype.processChunk=function(d){this.push({data:i.utf8encode(d.data),meta:d.meta})},i.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,n,i){var s=e("./support"),o=e("./base64"),a=e("./nodejsUtils"),l=e("./external");function u(g){return g}function c(g,p){for(var y=0;y>8;this.dir=!!(16&this.externalFileAttributes),d==0&&(this.dosPermissions=63&this.externalFileAttributes),d==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var d=s(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var m,g,p,y=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4>>6:(d<65536?f[p++]=224|d>>>12:(f[p++]=240|d>>>18,f[p++]=128|d>>>12&63),f[p++]=128|d>>>6&63),f[p++]=128|63&d);return f},i.buf2binstring=function(h){return c(h,h.length)},i.binstring2buf=function(h){for(var f=new s.Buf8(h.length),d=0,m=f.length;d>10&1023,_[m++]=56320|1023&g)}return c(_,m)},i.utf8border=function(h,f){var d;for((f=f||h.length)>h.length&&(f=h.length),d=f-1;0<=d&&(192&h[d])==128;)d--;return d<0||d===0?f:d+l[h[d]]>f?d:f}},{"./common":41}],43:[function(e,n,i){n.exports=function(s,o,a,l){for(var u=65535&s|0,c=s>>>16&65535|0,h=0;a!==0;){for(a-=h=2e3>>1:o>>>1;a[l]=o}return a}();n.exports=function(o,a,l,u){var c=s,h=u+l;o^=-1;for(var f=u;f>>8^c[255&(o^a[f])];return-1^o}},{}],46:[function(e,n,i){var s,o=e("../utils/common"),a=e("./trees"),l=e("./adler32"),u=e("./crc32"),c=e("./messages"),h=0,f=4,d=0,m=-2,g=-1,p=4,y=2,_=8,S=9,T=286,v=30,E=19,w=2*T+1,B=15,N=3,$=258,it=$+N+1,I=42,Z=113,x=1,nt=2,P=3,C=4;function R(b,K){return b.msg=c[K],K}function z(b){return(b<<1)-(4b.avail_out&&(Q=b.avail_out),Q!==0&&(o.arraySet(b.output,K.pending_buf,K.pending_out,Q,b.next_out),b.next_out+=Q,K.pending_out+=Q,b.total_out+=Q,b.avail_out-=Q,K.pending-=Q,K.pending===0&&(K.pending_out=0))}function O(b,K){a._tr_flush_block(b,0<=b.block_start?b.block_start:-1,b.strstart-b.block_start,K),b.block_start=b.strstart,M(b.strm)}function j(b,K){b.pending_buf[b.pending++]=K}function et(b,K){b.pending_buf[b.pending++]=K>>>8&255,b.pending_buf[b.pending++]=255&K}function tt(b,K){var Q,L,D=b.max_chain_length,q=b.strstart,ot=b.prev_length,at=b.nice_match,rt=b.strstart>b.w_size-it?b.strstart-(b.w_size-it):0,ht=b.window,wt=b.w_mask,ft=b.prev,Mt=b.strstart+$,ge=ht[q+ot-1],oe=ht[q+ot];b.prev_length>=b.good_match&&(D>>=2),at>b.lookahead&&(at=b.lookahead);do if(ht[(Q=K)+ot]===oe&&ht[Q+ot-1]===ge&&ht[Q]===ht[q]&&ht[++Q]===ht[q+1]){q+=2,Q++;do;while(ht[++q]===ht[++Q]&&ht[++q]===ht[++Q]&&ht[++q]===ht[++Q]&&ht[++q]===ht[++Q]&&ht[++q]===ht[++Q]&&ht[++q]===ht[++Q]&&ht[++q]===ht[++Q]&&ht[++q]===ht[++Q]&&qrt&&--D!=0);return ot<=b.lookahead?ot:b.lookahead}function gt(b){var K,Q,L,D,q,ot,at,rt,ht,wt,ft=b.w_size;do{if(D=b.window_size-b.lookahead-b.strstart,b.strstart>=ft+(ft-it)){for(o.arraySet(b.window,b.window,ft,ft,0),b.match_start-=ft,b.strstart-=ft,b.block_start-=ft,K=Q=b.hash_size;L=b.head[--K],b.head[K]=ft<=L?L-ft:0,--Q;);for(K=Q=ft;L=b.prev[--K],b.prev[K]=ft<=L?L-ft:0,--Q;);D+=ft}if(b.strm.avail_in===0)break;if(ot=b.strm,at=b.window,rt=b.strstart+b.lookahead,ht=D,wt=void 0,wt=ot.avail_in,ht=N)for(q=b.strstart-b.insert,b.ins_h=b.window[q],b.ins_h=(b.ins_h<=N&&(b.ins_h=(b.ins_h<=N)if(L=a._tr_tally(b,b.strstart-b.match_start,b.match_length-N),b.lookahead-=b.match_length,b.match_length<=b.max_lazy_match&&b.lookahead>=N){for(b.match_length--;b.strstart++,b.ins_h=(b.ins_h<=N&&(b.ins_h=(b.ins_h<=N&&b.match_length<=b.prev_length){for(D=b.strstart+b.lookahead-N,L=a._tr_tally(b,b.strstart-1-b.prev_match,b.prev_length-N),b.lookahead-=b.prev_length-1,b.prev_length-=2;++b.strstart<=D&&(b.ins_h=(b.ins_h<b.pending_buf_size-5&&(Q=b.pending_buf_size-5);;){if(b.lookahead<=1){if(gt(b),b.lookahead===0&&K===h)return x;if(b.lookahead===0)break}b.strstart+=b.lookahead,b.lookahead=0;var L=b.block_start+Q;if((b.strstart===0||b.strstart>=L)&&(b.lookahead=b.strstart-L,b.strstart=L,O(b,!1),b.strm.avail_out===0)||b.strstart-b.block_start>=b.w_size-it&&(O(b,!1),b.strm.avail_out===0))return x}return b.insert=0,K===f?(O(b,!0),b.strm.avail_out===0?P:C):(b.strstart>b.block_start&&(O(b,!1),b.strm.avail_out),x)}),new bt(4,4,8,4,_t),new bt(4,5,16,8,_t),new bt(4,6,32,32,_t),new bt(4,4,16,16,ct),new bt(8,16,32,32,ct),new bt(8,16,128,128,ct),new bt(8,32,128,256,ct),new bt(32,128,258,1024,ct),new bt(32,258,258,4096,ct)],i.deflateInit=function(b,K){return ue(b,K,_,15,8,0)},i.deflateInit2=ue,i.deflateReset=re,i.deflateResetKeep=Et,i.deflateSetHeader=function(b,K){return b&&b.state?b.state.wrap!==2?m:(b.state.gzhead=K,d):m},i.deflate=function(b,K){var Q,L,D,q;if(!b||!b.state||5>8&255),j(L,L.gzhead.time>>16&255),j(L,L.gzhead.time>>24&255),j(L,L.level===9?2:2<=L.strategy||L.level<2?4:0),j(L,255&L.gzhead.os),L.gzhead.extra&&L.gzhead.extra.length&&(j(L,255&L.gzhead.extra.length),j(L,L.gzhead.extra.length>>8&255)),L.gzhead.hcrc&&(b.adler=u(b.adler,L.pending_buf,L.pending,0)),L.gzindex=0,L.status=69):(j(L,0),j(L,0),j(L,0),j(L,0),j(L,0),j(L,L.level===9?2:2<=L.strategy||L.level<2?4:0),j(L,3),L.status=Z);else{var ot=_+(L.w_bits-8<<4)<<8;ot|=(2<=L.strategy||L.level<2?0:L.level<6?1:L.level===6?2:3)<<6,L.strstart!==0&&(ot|=32),ot+=31-ot%31,L.status=Z,et(L,ot),L.strstart!==0&&(et(L,b.adler>>>16),et(L,65535&b.adler)),b.adler=1}if(L.status===69)if(L.gzhead.extra){for(D=L.pending;L.gzindex<(65535&L.gzhead.extra.length)&&(L.pending!==L.pending_buf_size||(L.gzhead.hcrc&&L.pending>D&&(b.adler=u(b.adler,L.pending_buf,L.pending-D,D)),M(b),D=L.pending,L.pending!==L.pending_buf_size));)j(L,255&L.gzhead.extra[L.gzindex]),L.gzindex++;L.gzhead.hcrc&&L.pending>D&&(b.adler=u(b.adler,L.pending_buf,L.pending-D,D)),L.gzindex===L.gzhead.extra.length&&(L.gzindex=0,L.status=73)}else L.status=73;if(L.status===73)if(L.gzhead.name){D=L.pending;do{if(L.pending===L.pending_buf_size&&(L.gzhead.hcrc&&L.pending>D&&(b.adler=u(b.adler,L.pending_buf,L.pending-D,D)),M(b),D=L.pending,L.pending===L.pending_buf_size)){q=1;break}q=L.gzindexD&&(b.adler=u(b.adler,L.pending_buf,L.pending-D,D)),q===0&&(L.gzindex=0,L.status=91)}else L.status=91;if(L.status===91)if(L.gzhead.comment){D=L.pending;do{if(L.pending===L.pending_buf_size&&(L.gzhead.hcrc&&L.pending>D&&(b.adler=u(b.adler,L.pending_buf,L.pending-D,D)),M(b),D=L.pending,L.pending===L.pending_buf_size)){q=1;break}q=L.gzindexD&&(b.adler=u(b.adler,L.pending_buf,L.pending-D,D)),q===0&&(L.status=103)}else L.status=103;if(L.status===103&&(L.gzhead.hcrc?(L.pending+2>L.pending_buf_size&&M(b),L.pending+2<=L.pending_buf_size&&(j(L,255&b.adler),j(L,b.adler>>8&255),b.adler=0,L.status=Z)):L.status=Z),L.pending!==0){if(M(b),b.avail_out===0)return L.last_flush=-1,d}else if(b.avail_in===0&&z(K)<=z(Q)&&K!==f)return R(b,-5);if(L.status===666&&b.avail_in!==0)return R(b,-5);if(b.avail_in!==0||L.lookahead!==0||K!==h&&L.status!==666){var at=L.strategy===2?function(rt,ht){for(var wt;;){if(rt.lookahead===0&&(gt(rt),rt.lookahead===0)){if(ht===h)return x;break}if(rt.match_length=0,wt=a._tr_tally(rt,0,rt.window[rt.strstart]),rt.lookahead--,rt.strstart++,wt&&(O(rt,!1),rt.strm.avail_out===0))return x}return rt.insert=0,ht===f?(O(rt,!0),rt.strm.avail_out===0?P:C):rt.last_lit&&(O(rt,!1),rt.strm.avail_out===0)?x:nt}(L,K):L.strategy===3?function(rt,ht){for(var wt,ft,Mt,ge,oe=rt.window;;){if(rt.lookahead<=$){if(gt(rt),rt.lookahead<=$&&ht===h)return x;if(rt.lookahead===0)break}if(rt.match_length=0,rt.lookahead>=N&&0rt.lookahead&&(rt.match_length=rt.lookahead)}if(rt.match_length>=N?(wt=a._tr_tally(rt,1,rt.match_length-N),rt.lookahead-=rt.match_length,rt.strstart+=rt.match_length,rt.match_length=0):(wt=a._tr_tally(rt,0,rt.window[rt.strstart]),rt.lookahead--,rt.strstart++),wt&&(O(rt,!1),rt.strm.avail_out===0))return x}return rt.insert=0,ht===f?(O(rt,!0),rt.strm.avail_out===0?P:C):rt.last_lit&&(O(rt,!1),rt.strm.avail_out===0)?x:nt}(L,K):s[L.level].func(L,K);if(at!==P&&at!==C||(L.status=666),at===x||at===P)return b.avail_out===0&&(L.last_flush=-1),d;if(at===nt&&(K===1?a._tr_align(L):K!==5&&(a._tr_stored_block(L,0,0,!1),K===3&&(U(L.head),L.lookahead===0&&(L.strstart=0,L.block_start=0,L.insert=0))),M(b),b.avail_out===0))return L.last_flush=-1,d}return K!==f?d:L.wrap<=0?1:(L.wrap===2?(j(L,255&b.adler),j(L,b.adler>>8&255),j(L,b.adler>>16&255),j(L,b.adler>>24&255),j(L,255&b.total_in),j(L,b.total_in>>8&255),j(L,b.total_in>>16&255),j(L,b.total_in>>24&255)):(et(L,b.adler>>>16),et(L,65535&b.adler)),M(b),0=Q.w_size&&(q===0&&(U(Q.head),Q.strstart=0,Q.block_start=0,Q.insert=0),ht=new o.Buf8(Q.w_size),o.arraySet(ht,K,wt-Q.w_size,Q.w_size,0),K=ht,wt=Q.w_size),ot=b.avail_in,at=b.next_in,rt=b.input,b.avail_in=wt,b.next_in=0,b.input=K,gt(Q);Q.lookahead>=N;){for(L=Q.strstart,D=Q.lookahead-(N-1);Q.ins_h=(Q.ins_h<>>=N=B>>>24,S-=N,(N=B>>>16&255)===0)nt[c++]=65535&B;else{if(!(16&N)){if((64&N)==0){B=T[(65535&B)+(_&(1<>>=N,S-=N),S<15&&(_+=x[l++]<>>=N=B>>>24,S-=N,!(16&(N=B>>>16&255))){if((64&N)==0){B=v[(65535&B)+(_&(1<>>=N,S-=N,(N=c-h)>3,_&=(1<<(S-=$<<3))-1,s.next_in=l,s.next_out=c,s.avail_in=l>>24&255)+(I>>>8&65280)+((65280&I)<<8)+((255&I)<<24)}function _(){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 s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function S(I){var Z;return I&&I.state?(Z=I.state,I.total_in=I.total_out=Z.total=0,I.msg="",Z.wrap&&(I.adler=1&Z.wrap),Z.mode=m,Z.last=0,Z.havedict=0,Z.dmax=32768,Z.head=null,Z.hold=0,Z.bits=0,Z.lencode=Z.lendyn=new s.Buf32(g),Z.distcode=Z.distdyn=new s.Buf32(p),Z.sane=1,Z.back=-1,f):d}function T(I){var Z;return I&&I.state?((Z=I.state).wsize=0,Z.whave=0,Z.wnext=0,S(I)):d}function v(I,Z){var x,nt;return I&&I.state?(nt=I.state,Z<0?(x=0,Z=-Z):(x=1+(Z>>4),Z<48&&(Z&=15)),Z&&(Z<8||15=C.wsize?(s.arraySet(C.window,Z,x-C.wsize,C.wsize,0),C.wnext=0,C.whave=C.wsize):(nt<(P=C.wsize-C.wnext)&&(P=nt),s.arraySet(C.window,Z,x-nt,P,C.wnext),(nt-=P)?(s.arraySet(C.window,Z,x-nt,nt,0),C.wnext=nt,C.whave=C.wsize):(C.wnext+=P,C.wnext===C.wsize&&(C.wnext=0),C.whave>>8&255,x.check=a(x.check,q,2,0),O=M=0,x.mode=2;break}if(x.flags=0,x.head&&(x.head.done=!1),!(1&x.wrap)||(((255&M)<<8)+(M>>8))%31){I.msg="incorrect header check",x.mode=30;break}if((15&M)!=8){I.msg="unknown compression method",x.mode=30;break}if(O-=4,b=8+(15&(M>>>=4)),x.wbits===0)x.wbits=b;else if(b>x.wbits){I.msg="invalid window size",x.mode=30;break}x.dmax=1<>8&1),512&x.flags&&(q[0]=255&M,q[1]=M>>>8&255,x.check=a(x.check,q,2,0)),O=M=0,x.mode=3;case 3:for(;O<32;){if(z===0)break t;z--,M+=nt[C++]<>>8&255,q[2]=M>>>16&255,q[3]=M>>>24&255,x.check=a(x.check,q,4,0)),O=M=0,x.mode=4;case 4:for(;O<16;){if(z===0)break t;z--,M+=nt[C++]<>8),512&x.flags&&(q[0]=255&M,q[1]=M>>>8&255,x.check=a(x.check,q,2,0)),O=M=0,x.mode=5;case 5:if(1024&x.flags){for(;O<16;){if(z===0)break t;z--,M+=nt[C++]<>>8&255,x.check=a(x.check,q,2,0)),O=M=0}else x.head&&(x.head.extra=null);x.mode=6;case 6:if(1024&x.flags&&(z<(tt=x.length)&&(tt=z),tt&&(x.head&&(b=x.head.extra_len-x.length,x.head.extra||(x.head.extra=new Array(x.head.extra_len)),s.arraySet(x.head.extra,nt,C,tt,b)),512&x.flags&&(x.check=a(x.check,nt,tt,C)),z-=tt,C+=tt,x.length-=tt),x.length))break t;x.length=0,x.mode=7;case 7:if(2048&x.flags){if(z===0)break t;for(tt=0;b=nt[C+tt++],x.head&&b&&x.length<65536&&(x.head.name+=String.fromCharCode(b)),b&&tt>9&1,x.head.done=!0),I.adler=x.check=0,x.mode=12;break;case 10:for(;O<32;){if(z===0)break t;z--,M+=nt[C++]<>>=7&O,O-=7&O,x.mode=27;break}for(;O<3;){if(z===0)break t;z--,M+=nt[C++]<>>=1)){case 0:x.mode=14;break;case 1:if($(x),x.mode=20,Z!==6)break;M>>>=2,O-=2;break t;case 2:x.mode=17;break;case 3:I.msg="invalid block type",x.mode=30}M>>>=2,O-=2;break;case 14:for(M>>>=7&O,O-=7&O;O<32;){if(z===0)break t;z--,M+=nt[C++]<>>16^65535)){I.msg="invalid stored block lengths",x.mode=30;break}if(x.length=65535&M,O=M=0,x.mode=15,Z===6)break t;case 15:x.mode=16;case 16:if(tt=x.length){if(z>>=5,O-=5,x.ndist=1+(31&M),M>>>=5,O-=5,x.ncode=4+(15&M),M>>>=4,O-=4,286>>=3,O-=3}for(;x.have<19;)x.lens[ot[x.have++]]=0;if(x.lencode=x.lendyn,x.lenbits=7,Q={bits:x.lenbits},K=u(0,x.lens,0,19,x.lencode,0,x.work,Q),x.lenbits=Q.bits,K){I.msg="invalid code lengths set",x.mode=30;break}x.have=0,x.mode=19;case 19:for(;x.have>>16&255,vt=65535&D,!((ct=D>>>24)<=O);){if(z===0)break t;z--,M+=nt[C++]<>>=ct,O-=ct,x.lens[x.have++]=vt;else{if(vt===16){for(L=ct+2;O>>=ct,O-=ct,x.have===0){I.msg="invalid bit length repeat",x.mode=30;break}b=x.lens[x.have-1],tt=3+(3&M),M>>>=2,O-=2}else if(vt===17){for(L=ct+3;O>>=ct)),M>>>=3,O-=3}else{for(L=ct+7;O>>=ct)),M>>>=7,O-=7}if(x.have+tt>x.nlen+x.ndist){I.msg="invalid bit length repeat",x.mode=30;break}for(;tt--;)x.lens[x.have++]=b}}if(x.mode===30)break;if(x.lens[256]===0){I.msg="invalid code -- missing end-of-block",x.mode=30;break}if(x.lenbits=9,Q={bits:x.lenbits},K=u(c,x.lens,0,x.nlen,x.lencode,0,x.work,Q),x.lenbits=Q.bits,K){I.msg="invalid literal/lengths set",x.mode=30;break}if(x.distbits=6,x.distcode=x.distdyn,Q={bits:x.distbits},K=u(h,x.lens,x.nlen,x.ndist,x.distcode,0,x.work,Q),x.distbits=Q.bits,K){I.msg="invalid distances set",x.mode=30;break}if(x.mode=20,Z===6)break t;case 20:x.mode=21;case 21:if(6<=z&&258<=U){I.next_out=R,I.avail_out=U,I.next_in=C,I.avail_in=z,x.hold=M,x.bits=O,l(I,et),R=I.next_out,P=I.output,U=I.avail_out,C=I.next_in,nt=I.input,z=I.avail_in,M=x.hold,O=x.bits,x.mode===12&&(x.back=-1);break}for(x.back=0;bt=(D=x.lencode[M&(1<>>16&255,vt=65535&D,!((ct=D>>>24)<=O);){if(z===0)break t;z--,M+=nt[C++]<>Et)])>>>16&255,vt=65535&D,!(Et+(ct=D>>>24)<=O);){if(z===0)break t;z--,M+=nt[C++]<>>=Et,O-=Et,x.back+=Et}if(M>>>=ct,O-=ct,x.back+=ct,x.length=vt,bt===0){x.mode=26;break}if(32&bt){x.back=-1,x.mode=12;break}if(64&bt){I.msg="invalid literal/length code",x.mode=30;break}x.extra=15&bt,x.mode=22;case 22:if(x.extra){for(L=x.extra;O>>=x.extra,O-=x.extra,x.back+=x.extra}x.was=x.length,x.mode=23;case 23:for(;bt=(D=x.distcode[M&(1<>>16&255,vt=65535&D,!((ct=D>>>24)<=O);){if(z===0)break t;z--,M+=nt[C++]<>Et)])>>>16&255,vt=65535&D,!(Et+(ct=D>>>24)<=O);){if(z===0)break t;z--,M+=nt[C++]<>>=Et,O-=Et,x.back+=Et}if(M>>>=ct,O-=ct,x.back+=ct,64&bt){I.msg="invalid distance code",x.mode=30;break}x.offset=vt,x.extra=15&bt,x.mode=24;case 24:if(x.extra){for(L=x.extra;O>>=x.extra,O-=x.extra,x.back+=x.extra}if(x.offset>x.dmax){I.msg="invalid distance too far back",x.mode=30;break}x.mode=25;case 25:if(U===0)break t;if(tt=et-U,x.offset>tt){if((tt=x.offset-tt)>x.whave&&x.sane){I.msg="invalid distance too far back",x.mode=30;break}gt=tt>x.wnext?(tt-=x.wnext,x.wsize-tt):x.wnext-tt,tt>x.length&&(tt=x.length),_t=x.window}else _t=P,gt=R-x.offset,tt=x.length;for(Uw?(N=gt[_t+p[Z]],O[j+p[Z]]):(N=96,0),_=1<>R)+(S-=_)]=B<<24|N<<16|$|0,S!==0;);for(_=1<>=1;if(_!==0?(M&=_-1,M+=_):M=0,Z++,--et[I]==0){if(I===nt)break;I=h[f+p[Z]]}if(P>>7)]}function j(D,q){D.pending_buf[D.pending++]=255&q,D.pending_buf[D.pending++]=q>>>8&255}function et(D,q,ot){D.bi_valid>y-ot?(D.bi_buf|=q<>y-D.bi_valid,D.bi_valid+=ot-y):(D.bi_buf|=q<>>=1,ot<<=1,0<--q;);return ot>>>1}function _t(D,q,ot){var at,rt,ht=new Array(p+1),wt=0;for(at=1;at<=p;at++)ht[at]=wt=wt+ot[at-1]<<1;for(rt=0;rt<=q;rt++){var ft=D[2*rt+1];ft!==0&&(D[2*rt]=gt(ht[ft]++,ft))}}function ct(D){var q;for(q=0;q>1;1<=ot;ot--)Et(D,ht,ot);for(rt=Mt;ot=D.heap[1],D.heap[1]=D.heap[D.heap_len--],Et(D,ht,1),at=D.heap[1],D.heap[--D.heap_max]=ot,D.heap[--D.heap_max]=at,ht[2*rt]=ht[2*ot]+ht[2*at],D.depth[rt]=(D.depth[ot]>=D.depth[at]?D.depth[ot]:D.depth[at])+1,ht[2*ot+1]=ht[2*at+1]=rt,D.heap[1]=rt++,Et(D,ht,1),2<=D.heap_len;);D.heap[--D.heap_max]=D.heap[1],function(oe,Ke){var sr,cr,ln,Ie,yn,gi,Ir=Ke.dyn_tree,yi=Ke.max_code,Gi=Ke.stat_desc.static_tree,Vo=Ke.stat_desc.has_stree,kr=Ke.stat_desc.extra_bits,Wi=Ke.stat_desc.extra_base,Yn=Ke.stat_desc.max_length,zr=0;for(Ie=0;Ie<=p;Ie++)oe.bl_count[Ie]=0;for(Ir[2*oe.heap[oe.heap_max]+1]=0,sr=oe.heap_max+1;sr>=7;rt>>=1)if(1&ge&&ft.dyn_ltree[2*Mt]!==0)return o;if(ft.dyn_ltree[18]!==0||ft.dyn_ltree[20]!==0||ft.dyn_ltree[26]!==0)return a;for(Mt=32;Mt>>3,(ht=D.static_len+3+7>>>3)<=rt&&(rt=ht)):rt=ht=ot+5,ot+4<=rt&&q!==-1?L(D,q,ot,at):D.strategy===4||ht===rt?(et(D,2+(at?1:0),3),re(D,it,I)):(et(D,4+(at?1:0),3),function(ft,Mt,ge,oe){var Ke;for(et(ft,Mt-257,5),et(ft,ge-1,5),et(ft,oe-4,4),Ke=0;Ke>>8&255,D.pending_buf[D.d_buf+2*D.last_lit+1]=255&q,D.pending_buf[D.l_buf+D.last_lit]=255&ot,D.last_lit++,q===0?D.dyn_ltree[2*ot]++:(D.matches++,q--,D.dyn_ltree[2*(x[ot]+h+1)]++,D.dyn_dtree[2*O(q)]++),D.last_lit===D.lit_bufsize-1},i._tr_align=function(D){et(D,2,3),tt(D,S,it),function(q){q.bi_valid===16?(j(q,q.bi_buf),q.bi_buf=0,q.bi_valid=0):8<=q.bi_valid&&(q.pending_buf[q.pending++]=255&q.bi_buf,q.bi_buf>>=8,q.bi_valid-=8)}(D)}},{"../utils/common":41}],53:[function(e,n,i){n.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,n,i){(function(s){(function(o,a){if(!o.setImmediate){var l,u,c,h,f=1,d={},m=!1,g=o.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(o);p=p&&p.setTimeout?p:o,l={}.toString.call(o.process)==="[object process]"?function(T){process.nextTick(function(){_(T)})}:function(){if(o.postMessage&&!o.importScripts){var T=!0,v=o.onmessage;return o.onmessage=function(){T=!1},o.postMessage("","*"),o.onmessage=v,T}}()?(h="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",S,!1):o.attachEvent("onmessage",S),function(T){o.postMessage(h+T,"*")}):o.MessageChannel?((c=new MessageChannel).port1.onmessage=function(T){_(T.data)},function(T){c.port2.postMessage(T)}):g&&"onreadystatechange"in g.createElement("script")?(u=g.documentElement,function(T){var v=g.createElement("script");v.onreadystatechange=function(){_(T),v.onreadystatechange=null,u.removeChild(v),v=null},u.appendChild(v)}):function(T){setTimeout(_,0,T)},p.setImmediate=function(T){typeof T!="function"&&(T=new Function(""+T));for(var v=new Array(arguments.length-1),E=0;E"u"?s===void 0?this:s:self)}).call(this,typeof Dn<"u"?Dn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})}(Gh)),Gh.exports}var Vk=zk();const jk=If(Vk);Hn.zipReader=(r,t)=>jk.loadAsync(r);const $k=Hn.createSettings;Hn.createSettings=async r=>{const t=Object.keys(r.files);return t.find(e=>Gk(e))?$k(r):Xk(t)};function Gk(r){return r.endsWith("model3.json")}function Wk(r){return r.endsWith(".moc3")}function Hk(r){return r.split(/[\\/]/).pop()}function Xk(r){const t=r.filter(u=>Wk(u));if(t.length!==1){const u=t.length?`(${t.map(c=>`"${c}"`).join(",")})`:"";throw new Error(`Expected exactly one moc file, got ${t.length} ${u}`)}const e=t[0],n=Hk(e).replace(/\.moc3?/,""),i=r.filter(u=>u.endsWith(".png"));if(!i.length)throw new Error("Textures not found");const s=r.filter(u=>u.endsWith(".mtn")||u.endsWith(".motion3.json")),o=r.find(u=>u.includes("physics")),a=r.find(u=>u.includes("pose")),l=new xs({url:`${n}.model3.json`,Version:3,FileReferences:{Moc:e,Textures:i,Physics:o,Pose:a,Motions:s.length?{"":s.map(u=>({File:u}))}:void 0}});return l.name=n,l._objectURL=`example://${l.url}`,l}Hn.readText=(r,t)=>{const e=r.file(t);if(!e)throw new Error(`Cannot find file: ${t}`);return e.async("text")};Hn.getFilePaths=r=>{const t=[];return r.forEach(e=>t.push(e)),Promise.resolve(t)};Hn.getFiles=(r,t)=>Promise.all(t.map(async e=>{const n=e.slice(e.lastIndexOf("/")+1),i=await r.file(e).async("blob");return new File([i],n)}));export{BE as A,t3 as D,r3 as E,Kk as I,jk as J,rM as L,rd as M,Zk as T,s3 as V,a3 as a,Bo as b,o3 as c,Xg as d,yO as e,mO as f,fO as g,vv as h,i3 as i,n3 as j,ab as k,bO as l,Jk as m,qa as n,Mn as o,Ue as p,e3 as r,Y as s};