@doki-land/live2d 0.0.0 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/l2d.umd.js CHANGED
@@ -1,77 +1,89 @@
1
- (function(re,Ut){typeof exports=="object"&&typeof module<"u"?Ut(exports):typeof define=="function"&&define.amd?define(["exports"],Ut):(re=typeof globalThis<"u"?globalThis:re||self,Ut(re.l2d={}))})(this,function(re){"use strict";var Ut;(function(i){i[i.WEBGL_LEGACY=0]="WEBGL_LEGACY",i[i.WEBGL=1]="WEBGL",i[i.WEBGL2=2]="WEBGL2"})(Ut||(Ut={}));var cr;(function(i){i[i.UNKNOWN=0]="UNKNOWN",i[i.WEBGL=1]="WEBGL",i[i.CANVAS=2]="CANVAS"})(cr||(cr={}));var Fr;(function(i){i[i.COLOR=16384]="COLOR",i[i.DEPTH=256]="DEPTH",i[i.STENCIL=1024]="STENCIL"})(Fr||(Fr={}));var tt;(function(i){i[i.NORMAL=0]="NORMAL",i[i.ADD=1]="ADD",i[i.MULTIPLY=2]="MULTIPLY",i[i.SCREEN=3]="SCREEN",i[i.OVERLAY=4]="OVERLAY",i[i.DARKEN=5]="DARKEN",i[i.LIGHTEN=6]="LIGHTEN",i[i.COLOR_DODGE=7]="COLOR_DODGE",i[i.COLOR_BURN=8]="COLOR_BURN",i[i.HARD_LIGHT=9]="HARD_LIGHT",i[i.SOFT_LIGHT=10]="SOFT_LIGHT",i[i.DIFFERENCE=11]="DIFFERENCE",i[i.EXCLUSION=12]="EXCLUSION",i[i.HUE=13]="HUE",i[i.SATURATION=14]="SATURATION",i[i.COLOR=15]="COLOR",i[i.LUMINOSITY=16]="LUMINOSITY",i[i.NORMAL_NPM=17]="NORMAL_NPM",i[i.ADD_NPM=18]="ADD_NPM",i[i.SCREEN_NPM=19]="SCREEN_NPM",i[i.NONE=20]="NONE",i[i.SRC_OVER=0]="SRC_OVER",i[i.SRC_IN=21]="SRC_IN",i[i.SRC_OUT=22]="SRC_OUT",i[i.SRC_ATOP=23]="SRC_ATOP",i[i.DST_OVER=24]="DST_OVER",i[i.DST_IN=25]="DST_IN",i[i.DST_OUT=26]="DST_OUT",i[i.DST_ATOP=27]="DST_ATOP",i[i.ERASE=26]="ERASE",i[i.SUBTRACT=28]="SUBTRACT",i[i.XOR=29]="XOR"})(tt||(tt={}));var jt;(function(i){i[i.POINTS=0]="POINTS",i[i.LINES=1]="LINES",i[i.LINE_LOOP=2]="LINE_LOOP",i[i.LINE_STRIP=3]="LINE_STRIP",i[i.TRIANGLES=4]="TRIANGLES",i[i.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",i[i.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(jt||(jt={}));var H;(function(i){i[i.RGBA=6408]="RGBA",i[i.RGB=6407]="RGB",i[i.RG=33319]="RG",i[i.RED=6403]="RED",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.ALPHA=6406]="ALPHA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL"})(H||(H={}));var Ce;(function(i){i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z"})(Ce||(Ce={}));var Q;(function(i){i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.BYTE=5120]="BYTE",i[i.SHORT=5122]="SHORT",i[i.INT=5124]="INT",i[i.FLOAT=5126]="FLOAT",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.HALF_FLOAT=36193]="HALF_FLOAT"})(Q||(Q={}));var Lr;(function(i){i[i.FLOAT=0]="FLOAT",i[i.INT=1]="INT",i[i.UINT=2]="UINT"})(Lr||(Lr={}));var ie;(function(i){i[i.NEAREST=0]="NEAREST",i[i.LINEAR=1]="LINEAR"})(ie||(ie={}));var ne;(function(i){i[i.CLAMP=33071]="CLAMP",i[i.REPEAT=10497]="REPEAT",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"})(ne||(ne={}));var zt;(function(i){i[i.OFF=0]="OFF",i[i.POW2=1]="POW2",i[i.ON=2]="ON",i[i.ON_MANUAL=3]="ON_MANUAL"})(zt||(zt={}));var Wt;(function(i){i[i.NPM=0]="NPM",i[i.UNPACK=1]="UNPACK",i[i.PMA=2]="PMA",i[i.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",i[i.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",i[i.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA",i[i.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA"})(Wt||(Wt={}));var Yt;(function(i){i[i.NO=0]="NO",i[i.YES=1]="YES",i[i.AUTO=2]="AUTO",i[i.BLEND=0]="BLEND",i[i.CLEAR=1]="CLEAR",i[i.BLIT=2]="BLIT"})(Yt||(Yt={}));var Br;(function(i){i[i.AUTO=0]="AUTO",i[i.MANUAL=1]="MANUAL"})(Br||(Br={}));var kt;(function(i){i.LOW="lowp",i.MEDIUM="mediump",i.HIGH="highp"})(kt||(kt={}));var It;(function(i){i[i.NONE=0]="NONE",i[i.SCISSOR=1]="SCISSOR",i[i.STENCIL=2]="STENCIL",i[i.SPRITE=3]="SPRITE",i[i.COLOR=4]="COLOR"})(It||(It={}));var Pn;(function(i){i[i.RED=1]="RED",i[i.GREEN=2]="GREEN",i[i.BLUE=4]="BLUE",i[i.ALPHA=8]="ALPHA"})(Pn||(Pn={}));var xt;(function(i){i[i.NONE=0]="NONE",i[i.LOW=2]="LOW",i[i.MEDIUM=4]="MEDIUM",i[i.HIGH=8]="HIGH"})(xt||(xt={}));var se;(function(i){i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER"})(se||(se={}));var Vo={createCanvas:function(i,t){var e=document.createElement("canvas");return e.width=i,e.height=t,e},getWebGLRenderingContext:function(){return WebGLRenderingContext},getNavigator:function(){return navigator},getBaseUrl:function(){var i;return(i=document.baseURI)!==null&&i!==void 0?i:window.location.href},fetch:function(i,t){return fetch(i,t)}},wn=/iPhone/i,jo=/iPod/i,zo=/iPad/i,Wo=/\biOS-universal(?:.+)Mac\b/i,Cn=/\bAndroid(?:.+)Mobile\b/i,Yo=/Android/i,dr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Ei=/Silk/i,ye=/Windows Phone/i,qo=/\bWindows(?:.+)ARM\b/i,$o=/BlackBerry/i,Ko=/BB10/i,Zo=/Opera Mini/i,Jo=/\b(CriOS|Chrome)(?:.+)Mobile/i,Qo=/Mobile(?:.+)Firefox\b/i,th=function(i){return typeof i<"u"&&i.platform==="MacIntel"&&typeof i.maxTouchPoints=="number"&&i.maxTouchPoints>1&&typeof MSStream>"u"};function Yf(i){return function(t){return t.test(i)}}function qf(i){var t={userAgent:"",platform:"",maxTouchPoints:0};!i&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof i=="string"?t.userAgent=i:i&&i.userAgent&&(t={userAgent:i.userAgent,platform:i.platform,maxTouchPoints:i.maxTouchPoints||0});var e=t.userAgent,r=e.split("[FBAN");typeof r[1]<"u"&&(e=r[0]),r=e.split("Twitter"),typeof r[1]<"u"&&(e=r[0]);var n=Yf(e),s={apple:{phone:n(wn)&&!n(ye),ipod:n(jo),tablet:!n(wn)&&(n(zo)||th(t))&&!n(ye),universal:n(Wo),device:(n(wn)||n(jo)||n(zo)||n(Wo)||th(t))&&!n(ye)},amazon:{phone:n(dr),tablet:!n(dr)&&n(Ei),device:n(dr)||n(Ei)},android:{phone:!n(ye)&&n(dr)||!n(ye)&&n(Cn),tablet:!n(ye)&&!n(dr)&&!n(Cn)&&(n(Ei)||n(Yo)),device:!n(ye)&&(n(dr)||n(Ei)||n(Cn)||n(Yo))||n(/\bokhttp\b/i)},windows:{phone:n(ye),tablet:n(qo),device:n(ye)||n(qo)},other:{blackberry:n($o),blackberry10:n(Ko),opera:n(Zo),firefox:n(Qo),chrome:n(Jo),device:n($o)||n(Ko)||n(Zo)||n(Qo)||n(Jo)},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 qt=qf(globalThis.navigator);function $f(){return!qt.apple.device}function Kf(i){var t=!0;if(qt.tablet||qt.phone){if(qt.apple.device){var e=navigator.userAgent.match(/OS (\d+)_(\d+)?/);if(e){var r=parseInt(e[1],10);r<11&&(t=!1)}}if(qt.android.device){var e=navigator.userAgent.match(/Android\s([0-9.]*)/);if(e){var r=parseInt(e[1],10);r<7&&(t=!1)}}}return t?i:4}var z={ADAPTER:Vo,MIPMAP_TEXTURES:zt.POW2,ANISOTROPIC_LEVEL:0,RESOLUTION:1,FILTER_RESOLUTION:1,FILTER_MULTISAMPLE:xt.NONE,SPRITE_MAX_TEXTURES:Kf(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:Br.AUTO,GC_MAX_IDLE:60*60,GC_MAX_CHECK_COUNT:60*10,WRAP_MODE:ne.CLAMP,SCALE_MODE:ie.LINEAR,PRECISION_VERTEX:kt.HIGH,PRECISION_FRAGMENT:qt.apple.device?kt.HIGH:kt.MEDIUM,CAN_UPLOAD_SAME_BUFFER:$f(),CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1},In=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function An(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Zf(i){if(Object.prototype.hasOwnProperty.call(i,"__esModule"))return i;var t=i.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(i).forEach(function(r){var n=Object.getOwnPropertyDescriptor(i,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return i[r]}})}),e}var Mn={exports:{}},eh;function Jf(){return eh||(eh=1,function(i){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function n(h,u,l){this.fn=h,this.context=u,this.once=l||!1}function s(h,u,l,c,f){if(typeof l!="function")throw new TypeError("The listener must be a function");var d=new n(l,c||h,f),v=e?e+u:u;return h._events[v]?h._events[v].fn?h._events[v]=[h._events[v],d]:h._events[v].push(d):(h._events[v]=d,h._eventsCount++),h}function a(h,u){--h._eventsCount===0?h._events=new r:delete h._events[u]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],l,c;if(this._eventsCount===0)return u;for(c in l=this._events)t.call(l,c)&&u.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(l)):u},o.prototype.listeners=function(u){var l=e?e+u:u,c=this._events[l];if(!c)return[];if(c.fn)return[c.fn];for(var f=0,d=c.length,v=new Array(d);f<d;f++)v[f]=c[f].fn;return v},o.prototype.listenerCount=function(u){var l=e?e+u:u,c=this._events[l];return c?c.fn?1:c.length:0},o.prototype.emit=function(u,l,c,f,d,v){var _=e?e+u:u;if(!this._events[_])return!1;var p=this._events[_],g=arguments.length,y,T;if(p.fn){switch(p.once&&this.removeListener(u,p.fn,void 0,!0),g){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,l),!0;case 3:return p.fn.call(p.context,l,c),!0;case 4:return p.fn.call(p.context,l,c,f),!0;case 5:return p.fn.call(p.context,l,c,f,d),!0;case 6:return p.fn.call(p.context,l,c,f,d,v),!0}for(T=1,y=new Array(g-1);T<g;T++)y[T-1]=arguments[T];p.fn.apply(p.context,y)}else{var I=p.length,m;for(T=0;T<I;T++)switch(p[T].once&&this.removeListener(u,p[T].fn,void 0,!0),g){case 1:p[T].fn.call(p[T].context);break;case 2:p[T].fn.call(p[T].context,l);break;case 3:p[T].fn.call(p[T].context,l,c);break;case 4:p[T].fn.call(p[T].context,l,c,f);break;default:if(!y)for(m=1,y=new Array(g-1);m<g;m++)y[m-1]=arguments[m];p[T].fn.apply(p[T].context,y)}}return!0},o.prototype.on=function(u,l,c){return s(this,u,l,c,!1)},o.prototype.once=function(u,l,c){return s(this,u,l,c,!0)},o.prototype.removeListener=function(u,l,c,f){var d=e?e+u:u;if(!this._events[d])return this;if(!l)return a(this,d),this;var v=this._events[d];if(v.fn)v.fn===l&&(!f||v.once)&&(!c||v.context===c)&&a(this,d);else{for(var _=0,p=[],g=v.length;_<g;_++)(v[_].fn!==l||f&&!v[_].once||c&&v[_].context!==c)&&p.push(v[_]);p.length?this._events[d]=p.length===1?p[0]:p:a(this,d)}return this},o.prototype.removeAllListeners=function(u){var l;return u?(l=e?e+u:u,this._events[l]&&a(this,l)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,i.exports=o}(Mn)),Mn.exports}var Qf=Jf();const xe=An(Qf);var Si={exports:{}},rh;function tc(){if(rh)return Si.exports;rh=1,Si.exports=i,Si.exports.default=i;function i(b,P,E){E=E||2;var A=P&&P.length,C=A?P[0]*E:b.length,w=t(b,0,C,E,!0),M=[];if(!w||w.next===w.prev)return M;var R,U,X,W,V,Y,K;if(A&&(w=h(b,P,w,E)),b.length>80*E){R=X=b[0],U=W=b[1];for(var j=E;j<C;j+=E)V=b[j],Y=b[j+1],V<R&&(R=V),Y<U&&(U=Y),V>X&&(X=V),Y>W&&(W=Y);K=Math.max(X-R,W-U),K=K!==0?32767/K:0}return r(w,M,E,R,U,K,0),M}function t(b,P,E,A,C){var w,M;if(C===G(b,P,E,A)>0)for(w=P;w<E;w+=A)M=L(w,b[w],b[w+1],M);else for(w=E-A;w>=P;w-=A)M=L(w,b[w],b[w+1],M);return M&&I(M,M.next)&&(q(M),M=M.next),M}function e(b,P){if(!b)return b;P||(P=b);var E=b,A;do if(A=!1,!E.steiner&&(I(E,E.next)||T(E.prev,E,E.next)===0)){if(q(E),E=P=E.prev,E===E.next)break;A=!0}else E=E.next;while(A||E!==P);return P}function r(b,P,E,A,C,w,M){if(b){!M&&w&&d(b,A,C,w);for(var R=b,U,X;b.prev!==b.next;){if(U=b.prev,X=b.next,w?s(b,A,C,w):n(b)){P.push(U.i/E|0),P.push(b.i/E|0),P.push(X.i/E|0),q(b),b=X.next,R=X.next;continue}if(b=X,b===R){M?M===1?(b=a(e(b),P,E),r(b,P,E,A,C,w,2)):M===2&&o(b,P,E,A,C,w):r(e(b),P,E,A,C,w,1);break}}}}function n(b){var P=b.prev,E=b,A=b.next;if(T(P,E,A)>=0)return!1;for(var C=P.x,w=E.x,M=A.x,R=P.y,U=E.y,X=A.y,W=C<w?C<M?C:M:w<M?w:M,V=R<U?R<X?R:X:U<X?U:X,Y=C>w?C>M?C:M:w>M?w:M,K=R>U?R>X?R:X:U>X?U:X,j=A.next;j!==P;){if(j.x>=W&&j.x<=Y&&j.y>=V&&j.y<=K&&g(C,R,w,U,M,X,j.x,j.y)&&T(j.prev,j,j.next)>=0)return!1;j=j.next}return!0}function s(b,P,E,A){var C=b.prev,w=b,M=b.next;if(T(C,w,M)>=0)return!1;for(var R=C.x,U=w.x,X=M.x,W=C.y,V=w.y,Y=M.y,K=R<U?R<X?R:X:U<X?U:X,j=W<V?W<Y?W:Y:V<Y?V:Y,et=R>U?R>X?R:X:U>X?U:X,nt=W>V?W>Y?W:Y:V>Y?V:Y,ft=_(K,j,P,E,A),J=_(et,nt,P,E,A),$=b.prevZ,rt=b.nextZ;$&&$.z>=ft&&rt&&rt.z<=J;){if($.x>=K&&$.x<=et&&$.y>=j&&$.y<=nt&&$!==C&&$!==M&&g(R,W,U,V,X,Y,$.x,$.y)&&T($.prev,$,$.next)>=0||($=$.prevZ,rt.x>=K&&rt.x<=et&&rt.y>=j&&rt.y<=nt&&rt!==C&&rt!==M&&g(R,W,U,V,X,Y,rt.x,rt.y)&&T(rt.prev,rt,rt.next)>=0))return!1;rt=rt.nextZ}for(;$&&$.z>=ft;){if($.x>=K&&$.x<=et&&$.y>=j&&$.y<=nt&&$!==C&&$!==M&&g(R,W,U,V,X,Y,$.x,$.y)&&T($.prev,$,$.next)>=0)return!1;$=$.prevZ}for(;rt&&rt.z<=J;){if(rt.x>=K&&rt.x<=et&&rt.y>=j&&rt.y<=nt&&rt!==C&&rt!==M&&g(R,W,U,V,X,Y,rt.x,rt.y)&&T(rt.prev,rt,rt.next)>=0)return!1;rt=rt.nextZ}return!0}function a(b,P,E){var A=b;do{var C=A.prev,w=A.next.next;!I(C,w)&&m(C,A,A.next,w)&&D(C,w)&&D(w,C)&&(P.push(C.i/E|0),P.push(A.i/E|0),P.push(w.i/E|0),q(A),q(A.next),A=b=w),A=A.next}while(A!==b);return e(A)}function o(b,P,E,A,C,w){var M=b;do{for(var R=M.next.next;R!==M.prev;){if(M.i!==R.i&&y(M,R)){var U=k(M,R);M=e(M,M.next),U=e(U,U.next),r(M,P,E,A,C,w,0),r(U,P,E,A,C,w,0);return}R=R.next}M=M.next}while(M!==b)}function h(b,P,E,A){var C=[],w,M,R,U,X;for(w=0,M=P.length;w<M;w++)R=P[w]*A,U=w<M-1?P[w+1]*A:b.length,X=t(b,R,U,A,!1),X===X.next&&(X.steiner=!0),C.push(p(X));for(C.sort(u),w=0;w<C.length;w++)E=l(C[w],E);return E}function u(b,P){return b.x-P.x}function l(b,P){var E=c(b,P);if(!E)return P;var A=k(E,b);return e(A,A.next),e(E,E.next)}function c(b,P){var E=P,A=b.x,C=b.y,w=-1/0,M;do{if(C<=E.y&&C>=E.next.y&&E.next.y!==E.y){var R=E.x+(C-E.y)*(E.next.x-E.x)/(E.next.y-E.y);if(R<=A&&R>w&&(w=R,M=E.x<E.next.x?E:E.next,R===A))return M}E=E.next}while(E!==P);if(!M)return null;var U=M,X=M.x,W=M.y,V=1/0,Y;E=M;do A>=E.x&&E.x>=X&&A!==E.x&&g(C<W?A:w,C,X,W,C<W?w:A,C,E.x,E.y)&&(Y=Math.abs(C-E.y)/(A-E.x),D(E,b)&&(Y<V||Y===V&&(E.x>M.x||E.x===M.x&&f(M,E)))&&(M=E,V=Y)),E=E.next;while(E!==U);return M}function f(b,P){return T(b.prev,b,P.prev)<0&&T(P.next,b,b.next)<0}function d(b,P,E,A){var C=b;do C.z===0&&(C.z=_(C.x,C.y,P,E,A)),C.prevZ=C.prev,C.nextZ=C.next,C=C.next;while(C!==b);C.prevZ.nextZ=null,C.prevZ=null,v(C)}function v(b){var P,E,A,C,w,M,R,U,X=1;do{for(E=b,b=null,w=null,M=0;E;){for(M++,A=E,R=0,P=0;P<X&&(R++,A=A.nextZ,!!A);P++);for(U=X;R>0||U>0&&A;)R!==0&&(U===0||!A||E.z<=A.z)?(C=E,E=E.nextZ,R--):(C=A,A=A.nextZ,U--),w?w.nextZ=C:b=C,C.prevZ=w,w=C;E=A}w.nextZ=null,X*=2}while(M>1);return b}function _(b,P,E,A,C){return b=(b-E)*C|0,P=(P-A)*C|0,b=(b|b<<8)&16711935,b=(b|b<<4)&252645135,b=(b|b<<2)&858993459,b=(b|b<<1)&1431655765,P=(P|P<<8)&16711935,P=(P|P<<4)&252645135,P=(P|P<<2)&858993459,P=(P|P<<1)&1431655765,b|P<<1}function p(b){var P=b,E=b;do(P.x<E.x||P.x===E.x&&P.y<E.y)&&(E=P),P=P.next;while(P!==b);return E}function g(b,P,E,A,C,w,M,R){return(C-M)*(P-R)>=(b-M)*(w-R)&&(b-M)*(A-R)>=(E-M)*(P-R)&&(E-M)*(w-R)>=(C-M)*(A-R)}function y(b,P){return b.next.i!==P.i&&b.prev.i!==P.i&&!N(b,P)&&(D(b,P)&&D(P,b)&&F(b,P)&&(T(b.prev,b,P.prev)||T(b,P.prev,P))||I(b,P)&&T(b.prev,b,b.next)>0&&T(P.prev,P,P.next)>0)}function T(b,P,E){return(P.y-b.y)*(E.x-P.x)-(P.x-b.x)*(E.y-P.y)}function I(b,P){return b.x===P.x&&b.y===P.y}function m(b,P,E,A){var C=x(T(b,P,E)),w=x(T(b,P,A)),M=x(T(E,A,b)),R=x(T(E,A,P));return!!(C!==w&&M!==R||C===0&&S(b,E,P)||w===0&&S(b,A,P)||M===0&&S(E,b,A)||R===0&&S(E,P,A))}function S(b,P,E){return P.x<=Math.max(b.x,E.x)&&P.x>=Math.min(b.x,E.x)&&P.y<=Math.max(b.y,E.y)&&P.y>=Math.min(b.y,E.y)}function x(b){return b>0?1:b<0?-1:0}function N(b,P){var E=b;do{if(E.i!==b.i&&E.next.i!==b.i&&E.i!==P.i&&E.next.i!==P.i&&m(E,E.next,b,P))return!0;E=E.next}while(E!==b);return!1}function D(b,P){return T(b.prev,b,b.next)<0?T(b,P,b.next)>=0&&T(b,b.prev,P)>=0:T(b,P,b.prev)<0||T(b,b.next,P)<0}function F(b,P){var E=b,A=!1,C=(b.x+P.x)/2,w=(b.y+P.y)/2;do E.y>w!=E.next.y>w&&E.next.y!==E.y&&C<(E.next.x-E.x)*(w-E.y)/(E.next.y-E.y)+E.x&&(A=!A),E=E.next;while(E!==b);return A}function k(b,P){var E=new Z(b.i,b.x,b.y),A=new Z(P.i,P.x,P.y),C=b.next,w=P.prev;return b.next=P,P.prev=b,E.next=C,C.prev=E,A.next=E,E.prev=A,w.next=A,A.prev=w,A}function L(b,P,E,A){var C=new Z(b,P,E);return A?(C.next=A.next,C.prev=A,A.next.prev=C,A.next=C):(C.prev=C,C.next=C),C}function q(b){b.next.prev=b.prev,b.prev.next=b.next,b.prevZ&&(b.prevZ.nextZ=b.nextZ),b.nextZ&&(b.nextZ.prevZ=b.prevZ)}function Z(b,P,E){this.i=b,this.x=P,this.y=E,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}i.deviation=function(b,P,E,A){var C=P&&P.length,w=C?P[0]*E:b.length,M=Math.abs(G(b,0,w,E));if(C)for(var R=0,U=P.length;R<U;R++){var X=P[R]*E,W=R<U-1?P[R+1]*E:b.length;M-=Math.abs(G(b,X,W,E))}var V=0;for(R=0;R<A.length;R+=3){var Y=A[R]*E,K=A[R+1]*E,j=A[R+2]*E;V+=Math.abs((b[Y]-b[j])*(b[K+1]-b[Y+1])-(b[Y]-b[K])*(b[j+1]-b[Y+1]))}return M===0&&V===0?0:Math.abs((V-M)/M)};function G(b,P,E,A){for(var C=0,w=P,M=E-A;w<E;w+=A)C+=(b[M]-b[w])*(b[w+1]+b[M+1]),M=w;return C}return i.flatten=function(b){for(var P=b[0][0].length,E={vertices:[],holes:[],dimensions:P},A=0,C=0;C<b.length;C++){for(var w=0;w<b[C].length;w++)for(var M=0;M<P;M++)E.vertices.push(b[C][w][M]);C>0&&(A+=b[C-1].length,E.holes.push(A))}return E},Si.exports}var ec=tc();const Rn=An(ec);var Xe={},Nr={exports:{}};var rc=Nr.exports,ih;function ic(){return ih||(ih=1,function(i,t){(function(e){var r=t&&!t.nodeType&&t,n=i&&!i.nodeType&&i,s=typeof In=="object"&&In;(s.global===s||s.window===s||s.self===s)&&(e=s);var a,o=2147483647,h=36,u=1,l=26,c=38,f=700,d=72,v=128,_="-",p=/^xn--/,g=/[^\x20-\x7E]/,y=/[\x2E\u3002\uFF0E\uFF61]/g,T={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},I=h-u,m=Math.floor,S=String.fromCharCode,x;function N(C){throw new RangeError(T[C])}function D(C,w){for(var M=C.length,R=[];M--;)R[M]=w(C[M]);return R}function F(C,w){var M=C.split("@"),R="";M.length>1&&(R=M[0]+"@",C=M[1]),C=C.replace(y,".");var U=C.split("."),X=D(U,w).join(".");return R+X}function k(C){for(var w=[],M=0,R=C.length,U,X;M<R;)U=C.charCodeAt(M++),U>=55296&&U<=56319&&M<R?(X=C.charCodeAt(M++),(X&64512)==56320?w.push(((U&1023)<<10)+(X&1023)+65536):(w.push(U),M--)):w.push(U);return w}function L(C){return D(C,function(w){var M="";return w>65535&&(w-=65536,M+=S(w>>>10&1023|55296),w=56320|w&1023),M+=S(w),M}).join("")}function q(C){return C-48<10?C-22:C-65<26?C-65:C-97<26?C-97:h}function Z(C,w){return C+22+75*(C<26)-((w!=0)<<5)}function G(C,w,M){var R=0;for(C=M?m(C/f):C>>1,C+=m(C/w);C>I*l>>1;R+=h)C=m(C/I);return m(R+(I+1)*C/(C+c))}function b(C){var w=[],M=C.length,R,U=0,X=v,W=d,V,Y,K,j,et,nt,ft,J,$;for(V=C.lastIndexOf(_),V<0&&(V=0),Y=0;Y<V;++Y)C.charCodeAt(Y)>=128&&N("not-basic"),w.push(C.charCodeAt(Y));for(K=V>0?V+1:0;K<M;){for(j=U,et=1,nt=h;K>=M&&N("invalid-input"),ft=q(C.charCodeAt(K++)),(ft>=h||ft>m((o-U)/et))&&N("overflow"),U+=ft*et,J=nt<=W?u:nt>=W+l?l:nt-W,!(ft<J);nt+=h)$=h-J,et>m(o/$)&&N("overflow"),et*=$;R=w.length+1,W=G(U-j,R,j==0),m(U/R)>o-X&&N("overflow"),X+=m(U/R),U%=R,w.splice(U++,0,X)}return L(w)}function P(C){var w,M,R,U,X,W,V,Y,K,j,et,nt=[],ft,J,$,rt;for(C=k(C),ft=C.length,w=v,M=0,X=d,W=0;W<ft;++W)et=C[W],et<128&&nt.push(S(et));for(R=U=nt.length,U&&nt.push(_);R<ft;){for(V=o,W=0;W<ft;++W)et=C[W],et>=w&&et<V&&(V=et);for(J=R+1,V-w>m((o-M)/J)&&N("overflow"),M+=(V-w)*J,w=V,W=0;W<ft;++W)if(et=C[W],et<w&&++M>o&&N("overflow"),et==w){for(Y=M,K=h;j=K<=X?u:K>=X+l?l:K-X,!(Y<j);K+=h)rt=Y-j,$=h-j,nt.push(S(Z(j+rt%$,0))),Y=m(rt/$);nt.push(S(Z(Y,0))),X=G(M,J,R==U),M=0,++R}++M,++w}return nt.join("")}function E(C){return F(C,function(w){return p.test(w)?b(w.slice(4).toLowerCase()):w})}function A(C){return F(C,function(w){return g.test(w)?"xn--"+P(w):w})}if(a={version:"1.4.1",ucs2:{decode:k,encode:L},decode:b,encode:P,toASCII:A,toUnicode:E},r&&n)if(i.exports==r)n.exports=a;else for(x in a)a.hasOwnProperty(x)&&(r[x]=a[x]);else e.punycode=a})(rc)}(Nr,Nr.exports)),Nr.exports}var On,nh;function nc(){return nh||(nh=1,On=Error),On}var Dn,sh;function sc(){return sh||(sh=1,Dn=EvalError),Dn}var Fn,ah;function ac(){return ah||(ah=1,Fn=RangeError),Fn}var Ln,oh;function oc(){return oh||(oh=1,Ln=ReferenceError),Ln}var Bn,hh;function uh(){return hh||(hh=1,Bn=SyntaxError),Bn}var Nn,lh;function Ur(){return lh||(lh=1,Nn=TypeError),Nn}var Un,fh;function hc(){return fh||(fh=1,Un=URIError),Un}var kn,ch;function uc(){return ch||(ch=1,kn=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),r=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var n=42;t[e]=n;for(e in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var s=Object.getOwnPropertySymbols(t);if(s.length!==1||s[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,e);if(a.value!==n||a.enumerable!==!0)return!1}return!0}),kn}var Gn,dh;function lc(){if(dh)return Gn;dh=1;var i=typeof Symbol<"u"&&Symbol,t=uc();return Gn=function(){return typeof i!="function"||typeof Symbol!="function"||typeof i("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},Gn}var Xn,ph;function fc(){if(ph)return Xn;ph=1;var i={__proto__:null,foo:{}},t=Object;return Xn=function(){return{__proto__:i}.foo===i.foo&&!(i instanceof t)},Xn}var Hn,vh;function cc(){if(vh)return Hn;vh=1;var i="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,e=Math.max,r="[object Function]",n=function(h,u){for(var l=[],c=0;c<h.length;c+=1)l[c]=h[c];for(var f=0;f<u.length;f+=1)l[f+h.length]=u[f];return l},s=function(h,u){for(var l=[],c=u,f=0;c<h.length;c+=1,f+=1)l[f]=h[c];return l},a=function(o,h){for(var u="",l=0;l<o.length;l+=1)u+=o[l],l+1<o.length&&(u+=h);return u};return Hn=function(h){var u=this;if(typeof u!="function"||t.apply(u)!==r)throw new TypeError(i+u);for(var l=s(arguments,1),c,f=function(){if(this instanceof c){var g=u.apply(this,n(l,arguments));return Object(g)===g?g:this}return u.apply(h,n(l,arguments))},d=e(0,u.length-l.length),v=[],_=0;_<d;_++)v[_]="$"+_;if(c=Function("binder","return function ("+a(v,",")+"){ return binder.apply(this,arguments); }")(f),u.prototype){var p=function(){};p.prototype=u.prototype,c.prototype=new p,p.prototype=null}return c},Hn}var Vn,_h;function jn(){if(_h)return Vn;_h=1;var i=cc();return Vn=Function.prototype.bind||i,Vn}var zn,gh;function dc(){if(gh)return zn;gh=1;var i=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=jn();return zn=e.call(i,t),zn}var Wn,mh;function pr(){if(mh)return Wn;mh=1;var i,t=nc(),e=sc(),r=ac(),n=oc(),s=uh(),a=Ur(),o=hc(),h=Function,u=function(P){try{return h('"use strict"; return ('+P+").constructor;")()}catch{}},l=Object.getOwnPropertyDescriptor;if(l)try{l({},"")}catch{l=null}var c=function(){throw new a},f=l?function(){try{return arguments.callee,c}catch{try{return l(arguments,"callee").get}catch{return c}}}():c,d=lc()(),v=fc()(),_=Object.getPrototypeOf||(v?function(P){return P.__proto__}:null),p={},g=typeof Uint8Array>"u"||!_?i:_(Uint8Array),y={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?i:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?i:ArrayBuffer,"%ArrayIteratorPrototype%":d&&_?_([][Symbol.iterator]()):i,"%AsyncFromSyncIteratorPrototype%":i,"%AsyncFunction%":p,"%AsyncGenerator%":p,"%AsyncGeneratorFunction%":p,"%AsyncIteratorPrototype%":p,"%Atomics%":typeof Atomics>"u"?i:Atomics,"%BigInt%":typeof BigInt>"u"?i:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?i:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?i:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?i:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":t,"%eval%":eval,"%EvalError%":e,"%Float32Array%":typeof Float32Array>"u"?i:Float32Array,"%Float64Array%":typeof Float64Array>"u"?i:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?i:FinalizationRegistry,"%Function%":h,"%GeneratorFunction%":p,"%Int8Array%":typeof Int8Array>"u"?i:Int8Array,"%Int16Array%":typeof Int16Array>"u"?i:Int16Array,"%Int32Array%":typeof Int32Array>"u"?i:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":d&&_?_(_([][Symbol.iterator]())):i,"%JSON%":typeof JSON=="object"?JSON:i,"%Map%":typeof Map>"u"?i:Map,"%MapIteratorPrototype%":typeof Map>"u"||!d||!_?i:_(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?i:Promise,"%Proxy%":typeof Proxy>"u"?i:Proxy,"%RangeError%":r,"%ReferenceError%":n,"%Reflect%":typeof Reflect>"u"?i:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?i:Set,"%SetIteratorPrototype%":typeof Set>"u"||!d||!_?i:_(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?i:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":d&&_?_(""[Symbol.iterator]()):i,"%Symbol%":d?Symbol:i,"%SyntaxError%":s,"%ThrowTypeError%":f,"%TypedArray%":g,"%TypeError%":a,"%Uint8Array%":typeof Uint8Array>"u"?i:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?i:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?i:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?i:Uint32Array,"%URIError%":o,"%WeakMap%":typeof WeakMap>"u"?i:WeakMap,"%WeakRef%":typeof WeakRef>"u"?i:WeakRef,"%WeakSet%":typeof WeakSet>"u"?i:WeakSet};if(_)try{null.error}catch(P){var T=_(_(P));y["%Error.prototype%"]=T}var I=function P(E){var A;if(E==="%AsyncFunction%")A=u("async function () {}");else if(E==="%GeneratorFunction%")A=u("function* () {}");else if(E==="%AsyncGeneratorFunction%")A=u("async function* () {}");else if(E==="%AsyncGenerator%"){var C=P("%AsyncGeneratorFunction%");C&&(A=C.prototype)}else if(E==="%AsyncIteratorPrototype%"){var w=P("%AsyncGenerator%");w&&_&&(A=_(w.prototype))}return y[E]=A,A},m={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},S=jn(),x=dc(),N=S.call(Function.call,Array.prototype.concat),D=S.call(Function.apply,Array.prototype.splice),F=S.call(Function.call,String.prototype.replace),k=S.call(Function.call,String.prototype.slice),L=S.call(Function.call,RegExp.prototype.exec),q=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Z=/\\(\\)?/g,G=function(E){var A=k(E,0,1),C=k(E,-1);if(A==="%"&&C!=="%")throw new s("invalid intrinsic syntax, expected closing `%`");if(C==="%"&&A!=="%")throw new s("invalid intrinsic syntax, expected opening `%`");var w=[];return F(E,q,function(M,R,U,X){w[w.length]=U?F(X,Z,"$1"):R||M}),w},b=function(E,A){var C=E,w;if(x(m,C)&&(w=m[C],C="%"+w[0]+"%"),x(y,C)){var M=y[C];if(M===p&&(M=I(C)),typeof M>"u"&&!A)throw new a("intrinsic "+E+" exists, but is not available. Please file an issue!");return{alias:w,name:C,value:M}}throw new s("intrinsic "+E+" does not exist!")};return Wn=function(E,A){if(typeof E!="string"||E.length===0)throw new a("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof A!="boolean")throw new a('"allowMissing" argument must be a boolean');if(L(/^%?[^%]*%?$/,E)===null)throw new s("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var C=G(E),w=C.length>0?C[0]:"",M=b("%"+w+"%",A),R=M.name,U=M.value,X=!1,W=M.alias;W&&(w=W[0],D(C,N([0,1],W)));for(var V=1,Y=!0;V<C.length;V+=1){var K=C[V],j=k(K,0,1),et=k(K,-1);if((j==='"'||j==="'"||j==="`"||et==='"'||et==="'"||et==="`")&&j!==et)throw new s("property names with quotes must have matching quotes");if((K==="constructor"||!Y)&&(X=!0),w+="."+K,R="%"+w+"%",x(y,R))U=y[R];else if(U!=null){if(!(K in U)){if(!A)throw new a("base intrinsic for "+E+" exists, but the property is not available.");return}if(l&&V+1>=C.length){var nt=l(U,K);Y=!!nt,Y&&"get"in nt&&!("originalValue"in nt.get)?U=nt.get:U=U[K]}else Y=x(U,K),U=U[K];Y&&!X&&(y[R]=U)}}return U},Wn}var Yn={exports:{}},qn,yh;function $n(){if(yh)return qn;yh=1;var i=pr(),t=i("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return qn=t,qn}var Kn,xh;function bh(){if(xh)return Kn;xh=1;var i=pr(),t=i("%Object.getOwnPropertyDescriptor%",!0);if(t)try{t([],"length")}catch{t=null}return Kn=t,Kn}var Zn,Th;function pc(){if(Th)return Zn;Th=1;var i=$n(),t=uh(),e=Ur(),r=bh();return Zn=function(s,a,o){if(!s||typeof s!="object"&&typeof s!="function")throw new e("`obj` must be an object or a function`");if(typeof a!="string"&&typeof a!="symbol")throw new e("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new e("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new e("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new e("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new e("`loose`, if provided, must be a boolean");var h=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,l=arguments.length>5?arguments[5]:null,c=arguments.length>6?arguments[6]:!1,f=!!r&&r(s,a);if(i)i(s,a,{configurable:l===null&&f?f.configurable:!l,enumerable:h===null&&f?f.enumerable:!h,value:o,writable:u===null&&f?f.writable:!u});else if(c||!h&&!u&&!l)s[a]=o;else throw new t("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Zn}var Jn,Eh;function vc(){if(Eh)return Jn;Eh=1;var i=$n(),t=function(){return!!i};return t.hasArrayLengthDefineBug=function(){if(!i)return null;try{return i([],"length",{value:1}).length!==1}catch{return!0}},Jn=t,Jn}var Qn,Sh;function _c(){if(Sh)return Qn;Sh=1;var i=pr(),t=pc(),e=vc()(),r=bh(),n=Ur(),s=i("%Math.floor%");return Qn=function(o,h){if(typeof o!="function")throw new n("`fn` is not a function");if(typeof h!="number"||h<0||h>4294967295||s(h)!==h)throw new n("`length` must be a positive 32-bit integer");var u=arguments.length>2&&!!arguments[2],l=!0,c=!0;if("length"in o&&r){var f=r(o,"length");f&&!f.configurable&&(l=!1),f&&!f.writable&&(c=!1)}return(l||c||!u)&&(e?t(o,"length",h,!0,!0):t(o,"length",h)),o},Qn}var Ph;function gc(){return Ph||(Ph=1,function(i){var t=jn(),e=pr(),r=_c(),n=Ur(),s=e("%Function.prototype.apply%"),a=e("%Function.prototype.call%"),o=e("%Reflect.apply%",!0)||t.call(a,s),h=$n(),u=e("%Math.max%");i.exports=function(f){if(typeof f!="function")throw new n("a function is required");var d=o(t,a,arguments);return r(d,1+u(0,f.length-(arguments.length-1)),!0)};var l=function(){return o(t,s,arguments)};h?h(i.exports,"apply",{value:l}):i.exports.apply=l}(Yn)),Yn.exports}var ts,wh;function mc(){if(wh)return ts;wh=1;var i=pr(),t=gc(),e=t(i("String.prototype.indexOf"));return ts=function(n,s){var a=i(n,!!s);return typeof a=="function"&&e(n,".prototype.")>-1?t(a):a},ts}const yc=Zf(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var es,Ch;function xc(){if(Ch)return es;Ch=1;var i=typeof Map=="function"&&Map.prototype,t=Object.getOwnPropertyDescriptor&&i?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,e=i&&t&&typeof t.get=="function"?t.get:null,r=i&&Map.prototype.forEach,n=typeof Set=="function"&&Set.prototype,s=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,a=n&&s&&typeof s.get=="function"?s.get:null,o=n&&Set.prototype.forEach,h=typeof WeakMap=="function"&&WeakMap.prototype,u=h?WeakMap.prototype.has:null,l=typeof WeakSet=="function"&&WeakSet.prototype,c=l?WeakSet.prototype.has:null,f=typeof WeakRef=="function"&&WeakRef.prototype,d=f?WeakRef.prototype.deref:null,v=Boolean.prototype.valueOf,_=Object.prototype.toString,p=Function.prototype.toString,g=String.prototype.match,y=String.prototype.slice,T=String.prototype.replace,I=String.prototype.toUpperCase,m=String.prototype.toLowerCase,S=RegExp.prototype.test,x=Array.prototype.concat,N=Array.prototype.join,D=Array.prototype.slice,F=Math.floor,k=typeof BigInt=="function"?BigInt.prototype.valueOf:null,L=Object.getOwnPropertySymbols,q=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Z=typeof Symbol=="function"&&typeof Symbol.iterator=="object",G=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Z||!0)?Symbol.toStringTag:null,b=Object.prototype.propertyIsEnumerable,P=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(O){return O.__proto__}:null);function E(O,B){if(O===1/0||O===-1/0||O!==O||O&&O>-1e3&&O<1e3||S.call(/e/,B))return B;var ct=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof O=="number"){var gt=O<0?-F(-O):F(O);if(gt!==O){var At=String(gt),ht=y.call(B,At.length+1);return T.call(At,ct,"$&_")+"."+T.call(T.call(ht,/([0-9]{3})/g,"$&_"),/_$/,"")}}return T.call(B,ct,"$&_")}var A=yc,C=A.custom,w=et(C)?C:null;es=function O(B,ct,gt,At){var ht=ct||{};if(J(ht,"quoteStyle")&&ht.quoteStyle!=="single"&&ht.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(J(ht,"maxStringLength")&&(typeof ht.maxStringLength=="number"?ht.maxStringLength<0&&ht.maxStringLength!==1/0:ht.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var ke=J(ht,"customInspect")?ht.customInspect:!0;if(typeof ke!="boolean"&&ke!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(J(ht,"indent")&&ht.indent!==null&&ht.indent!==" "&&!(parseInt(ht.indent,10)===ht.indent&&ht.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(J(ht,"numericSeparator")&&typeof ht.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var fr=ht.numericSeparator;if(typeof B>"u")return"undefined";if(B===null)return"null";if(typeof B=="boolean")return B?"true":"false";if(typeof B=="string")return xi(B,ht);if(typeof B=="number"){if(B===0)return 1/0/B>0?"0":"-0";var Vt=String(B);return fr?E(B,Vt):Vt}if(typeof B=="bigint"){var Ge=String(B)+"n";return fr?E(B,Ge):Ge}var Bo=typeof ht.depth>"u"?5:ht.depth;if(typeof gt>"u"&&(gt=0),gt>=Bo&&Bo>0&&typeof B=="object")return U(B)?"[Array]":"[Object]";var Or=T0(ht,gt);if(typeof At>"u")At=[];else if(ot(At,B)>=0)return"[Circular]";function fe(Dr,Sn,S0){if(Sn&&(At=D.call(At),At.push(Sn)),S0){var Wf={depth:ht.depth};return J(ht,"quoteStyle")&&(Wf.quoteStyle=ht.quoteStyle),O(Dr,Wf,gt+1,At)}return O(Dr,ht,gt+1,At)}if(typeof B=="function"&&!W(B)){var kf=rt(B),Gf=Tn(B,fe);return"[Function"+(kf?": "+kf:" (anonymous)")+"]"+(Gf.length>0?" { "+N.call(Gf,", ")+" }":"")}if(et(B)){var Xf=Z?T.call(String(B),/^(Symbol\(.*\))_[^)]*$/,"$1"):q.call(B);return typeof B=="object"&&!Z?bi(Xf):Xf}if(bn(B)){for(var Ti="<"+m.call(String(B.nodeName)),No=B.attributes||[],En=0;En<No.length;En++)Ti+=" "+No[En].name+"="+M(R(No[En].value),"double",ht);return Ti+=">",B.childNodes&&B.childNodes.length&&(Ti+="..."),Ti+="</"+m.call(String(B.nodeName))+">",Ti}if(U(B)){if(B.length===0)return"[]";var Uo=Tn(B,fe);return Or&&!b0(Uo)?"["+Lo(Uo,Or)+"]":"[ "+N.call(Uo,", ")+" ]"}if(V(B)){var ko=Tn(B,fe);return!("cause"in Error.prototype)&&"cause"in B&&!b.call(B,"cause")?"{ ["+String(B)+"] "+N.call(x.call("[cause]: "+fe(B.cause),ko),", ")+" }":ko.length===0?"["+String(B)+"]":"{ ["+String(B)+"] "+N.call(ko,", ")+" }"}if(typeof B=="object"&&ke){if(w&&typeof B[w]=="function"&&A)return A(B,{depth:Bo-gt});if(ke!=="symbol"&&typeof B.inspect=="function")return B.inspect()}if(Ht(B)){var Hf=[];return r&&r.call(B,function(Dr,Sn){Hf.push(fe(Sn,B,!0)+" => "+fe(Dr,B))}),Uf("Map",e.call(B),Hf,Or)}if(yn(B)){var Vf=[];return o&&o.call(B,function(Dr){Vf.push(fe(Dr,B))}),Uf("Set",a.call(B),Vf,Or)}if(Ue(B))return Fo("WeakMap");if(xn(B))return Fo("WeakSet");if(Rr(B))return Fo("WeakRef");if(K(B))return bi(fe(Number(B)));if(nt(B))return bi(fe(k.call(B)));if(j(B))return bi(v.call(B));if(Y(B))return bi(fe(String(B)));if(typeof window<"u"&&B===window)return"{ [object Window] }";if(B===In)return"{ [object globalThis] }";if(!X(B)&&!W(B)){var Go=Tn(B,fe),jf=P?P(B)===Object.prototype:B instanceof Object||B.constructor===Object,Xo=B instanceof Object?"":"null prototype",zf=!jf&&G&&Object(B)===B&&G in B?y.call($(B),8,-1):Xo?"Object":"",E0=jf||typeof B.constructor!="function"?"":B.constructor.name?B.constructor.name+" ":"",Ho=E0+(zf||Xo?"["+N.call(x.call([],zf||[],Xo||[]),": ")+"] ":"");return Go.length===0?Ho+"{}":Or?Ho+"{"+Lo(Go,Or)+"}":Ho+"{ "+N.call(Go,", ")+" }"}return String(B)};function M(O,B,ct){var gt=(ct.quoteStyle||B)==="double"?'"':"'";return gt+O+gt}function R(O){return T.call(String(O),/"/g,"&quot;")}function U(O){return $(O)==="[object Array]"&&(!G||!(typeof O=="object"&&G in O))}function X(O){return $(O)==="[object Date]"&&(!G||!(typeof O=="object"&&G in O))}function W(O){return $(O)==="[object RegExp]"&&(!G||!(typeof O=="object"&&G in O))}function V(O){return $(O)==="[object Error]"&&(!G||!(typeof O=="object"&&G in O))}function Y(O){return $(O)==="[object String]"&&(!G||!(typeof O=="object"&&G in O))}function K(O){return $(O)==="[object Number]"&&(!G||!(typeof O=="object"&&G in O))}function j(O){return $(O)==="[object Boolean]"&&(!G||!(typeof O=="object"&&G in O))}function et(O){if(Z)return O&&typeof O=="object"&&O instanceof Symbol;if(typeof O=="symbol")return!0;if(!O||typeof O!="object"||!q)return!1;try{return q.call(O),!0}catch{}return!1}function nt(O){if(!O||typeof O!="object"||!k)return!1;try{return k.call(O),!0}catch{}return!1}var ft=Object.prototype.hasOwnProperty||function(O){return O in this};function J(O,B){return ft.call(O,B)}function $(O){return _.call(O)}function rt(O){if(O.name)return O.name;var B=g.call(p.call(O),/^function\s*([\w$]+)/);return B?B[1]:null}function ot(O,B){if(O.indexOf)return O.indexOf(B);for(var ct=0,gt=O.length;ct<gt;ct++)if(O[ct]===B)return ct;return-1}function Ht(O){if(!e||!O||typeof O!="object")return!1;try{e.call(O);try{a.call(O)}catch{return!0}return O instanceof Map}catch{}return!1}function Ue(O){if(!u||!O||typeof O!="object")return!1;try{u.call(O,u);try{c.call(O,c)}catch{return!0}return O instanceof WeakMap}catch{}return!1}function Rr(O){if(!d||!O||typeof O!="object")return!1;try{return d.call(O),!0}catch{}return!1}function yn(O){if(!a||!O||typeof O!="object")return!1;try{a.call(O);try{e.call(O)}catch{return!0}return O instanceof Set}catch{}return!1}function xn(O){if(!c||!O||typeof O!="object")return!1;try{c.call(O,c);try{u.call(O,u)}catch{return!0}return O instanceof WeakSet}catch{}return!1}function bn(O){return!O||typeof O!="object"?!1:typeof HTMLElement<"u"&&O instanceof HTMLElement?!0:typeof O.nodeName=="string"&&typeof O.getAttribute=="function"}function xi(O,B){if(O.length>B.maxStringLength){var ct=O.length-B.maxStringLength,gt="... "+ct+" more character"+(ct>1?"s":"");return xi(y.call(O,0,B.maxStringLength),B)+gt}var At=T.call(T.call(O,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,x0);return M(At,"single",B)}function x0(O){var B=O.charCodeAt(0),ct={8:"b",9:"t",10:"n",12:"f",13:"r"}[B];return ct?"\\"+ct:"\\x"+(B<16?"0":"")+I.call(B.toString(16))}function bi(O){return"Object("+O+")"}function Fo(O){return O+" { ? }"}function Uf(O,B,ct,gt){var At=gt?Lo(ct,gt):N.call(ct,", ");return O+" ("+B+") {"+At+"}"}function b0(O){for(var B=0;B<O.length;B++)if(ot(O[B],`
2
- `)>=0)return!1;return!0}function T0(O,B){var ct;if(O.indent===" ")ct=" ";else if(typeof O.indent=="number"&&O.indent>0)ct=N.call(Array(O.indent+1)," ");else return null;return{base:ct,prev:N.call(Array(B+1),ct)}}function Lo(O,B){if(O.length===0)return"";var ct=`
3
- `+B.prev+B.base;return ct+N.call(O,","+ct)+`
4
- `+B.prev}function Tn(O,B){var ct=U(O),gt=[];if(ct){gt.length=O.length;for(var At=0;At<O.length;At++)gt[At]=J(O,At)?B(O[At],O):""}var ht=typeof L=="function"?L(O):[],ke;if(Z){ke={};for(var fr=0;fr<ht.length;fr++)ke["$"+ht[fr]]=ht[fr]}for(var Vt in O)J(O,Vt)&&(ct&&String(Number(Vt))===Vt&&Vt<O.length||Z&&ke["$"+Vt]instanceof Symbol||(S.call(/[^\w$]/,Vt)?gt.push(B(Vt,O)+": "+B(O[Vt],O)):gt.push(Vt+": "+B(O[Vt],O))));if(typeof L=="function")for(var Ge=0;Ge<ht.length;Ge++)b.call(O,ht[Ge])&&gt.push("["+B(ht[Ge])+"]: "+B(O[ht[Ge]],O));return gt}return es}var rs,Ih;function bc(){if(Ih)return rs;Ih=1;var i=pr(),t=mc(),e=xc(),r=Ur(),n=i("%WeakMap%",!0),s=i("%Map%",!0),a=t("WeakMap.prototype.get",!0),o=t("WeakMap.prototype.set",!0),h=t("WeakMap.prototype.has",!0),u=t("Map.prototype.get",!0),l=t("Map.prototype.set",!0),c=t("Map.prototype.has",!0),f=function(p,g){for(var y=p,T;(T=y.next)!==null;y=T)if(T.key===g)return y.next=T.next,T.next=p.next,p.next=T,T},d=function(p,g){var y=f(p,g);return y&&y.value},v=function(p,g,y){var T=f(p,g);T?T.value=y:p.next={key:g,next:p.next,value:y}},_=function(p,g){return!!f(p,g)};return rs=function(){var g,y,T,I={assert:function(m){if(!I.has(m))throw new r("Side channel does not contain "+e(m))},get:function(m){if(n&&m&&(typeof m=="object"||typeof m=="function")){if(g)return a(g,m)}else if(s){if(y)return u(y,m)}else if(T)return d(T,m)},has:function(m){if(n&&m&&(typeof m=="object"||typeof m=="function")){if(g)return h(g,m)}else if(s){if(y)return c(y,m)}else if(T)return _(T,m);return!1},set:function(m,S){n&&m&&(typeof m=="object"||typeof m=="function")?(g||(g=new n),o(g,m,S)):s?(y||(y=new s),l(y,m,S)):(T||(T={key:{},next:null}),v(T,m,S))}};return I},rs}var is,Ah;function ns(){if(Ah)return is;Ah=1;var i=String.prototype.replace,t=/%20/g,e={RFC1738:"RFC1738",RFC3986:"RFC3986"};return is={default:e.RFC3986,formatters:{RFC1738:function(r){return i.call(r,t,"+")},RFC3986:function(r){return String(r)}},RFC1738:e.RFC1738,RFC3986:e.RFC3986},is}var ss,Mh;function Rh(){if(Mh)return ss;Mh=1;var i=ns(),t=Object.prototype.hasOwnProperty,e=Array.isArray,r=function(){for(var p=[],g=0;g<256;++g)p.push("%"+((g<16?"0":"")+g.toString(16)).toUpperCase());return p}(),n=function(g){for(;g.length>1;){var y=g.pop(),T=y.obj[y.prop];if(e(T)){for(var I=[],m=0;m<T.length;++m)typeof T[m]<"u"&&I.push(T[m]);y.obj[y.prop]=I}}},s=function(g,y){for(var T=y&&y.plainObjects?Object.create(null):{},I=0;I<g.length;++I)typeof g[I]<"u"&&(T[I]=g[I]);return T},a=function p(g,y,T){if(!y)return g;if(typeof y!="object"){if(e(g))g.push(y);else if(g&&typeof g=="object")(T&&(T.plainObjects||T.allowPrototypes)||!t.call(Object.prototype,y))&&(g[y]=!0);else return[g,y];return g}if(!g||typeof g!="object")return[g].concat(y);var I=g;return e(g)&&!e(y)&&(I=s(g,T)),e(g)&&e(y)?(y.forEach(function(m,S){if(t.call(g,S)){var x=g[S];x&&typeof x=="object"&&m&&typeof m=="object"?g[S]=p(x,m,T):g.push(m)}else g[S]=m}),g):Object.keys(y).reduce(function(m,S){var x=y[S];return t.call(m,S)?m[S]=p(m[S],x,T):m[S]=x,m},I)},o=function(g,y){return Object.keys(y).reduce(function(T,I){return T[I]=y[I],T},g)},h=function(p,g,y){var T=p.replace(/\+/g," ");if(y==="iso-8859-1")return T.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(T)}catch{return T}},u=1024,l=function(g,y,T,I,m){if(g.length===0)return g;var S=g;if(typeof g=="symbol"?S=Symbol.prototype.toString.call(g):typeof g!="string"&&(S=String(g)),T==="iso-8859-1")return escape(S).replace(/%u[0-9a-f]{4}/gi,function(q){return"%26%23"+parseInt(q.slice(2),16)+"%3B"});for(var x="",N=0;N<S.length;N+=u){for(var D=S.length>=u?S.slice(N,N+u):S,F=[],k=0;k<D.length;++k){var L=D.charCodeAt(k);if(L===45||L===46||L===95||L===126||L>=48&&L<=57||L>=65&&L<=90||L>=97&&L<=122||m===i.RFC1738&&(L===40||L===41)){F[F.length]=D.charAt(k);continue}if(L<128){F[F.length]=r[L];continue}if(L<2048){F[F.length]=r[192|L>>6]+r[128|L&63];continue}if(L<55296||L>=57344){F[F.length]=r[224|L>>12]+r[128|L>>6&63]+r[128|L&63];continue}k+=1,L=65536+((L&1023)<<10|D.charCodeAt(k)&1023),F[F.length]=r[240|L>>18]+r[128|L>>12&63]+r[128|L>>6&63]+r[128|L&63]}x+=F.join("")}return x},c=function(g){for(var y=[{obj:{o:g},prop:"o"}],T=[],I=0;I<y.length;++I)for(var m=y[I],S=m.obj[m.prop],x=Object.keys(S),N=0;N<x.length;++N){var D=x[N],F=S[D];typeof F=="object"&&F!==null&&T.indexOf(F)===-1&&(y.push({obj:S,prop:D}),T.push(F))}return n(y),g},f=function(g){return Object.prototype.toString.call(g)==="[object RegExp]"},d=function(g){return!g||typeof g!="object"?!1:!!(g.constructor&&g.constructor.isBuffer&&g.constructor.isBuffer(g))},v=function(g,y){return[].concat(g,y)},_=function(g,y){if(e(g)){for(var T=[],I=0;I<g.length;I+=1)T.push(y(g[I]));return T}return y(g)};return ss={arrayToObject:s,assign:o,combine:v,compact:c,decode:h,encode:l,isBuffer:d,isRegExp:f,maybeMap:_,merge:a},ss}var as,Oh;function Tc(){if(Oh)return as;Oh=1;var i=bc(),t=Rh(),e=ns(),r=Object.prototype.hasOwnProperty,n={brackets:function(p){return p+"[]"},comma:"comma",indices:function(p,g){return p+"["+g+"]"},repeat:function(p){return p}},s=Array.isArray,a=Array.prototype.push,o=function(_,p){a.apply(_,s(p)?p:[p])},h=Date.prototype.toISOString,u=e.default,l={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:t.encode,encodeValuesOnly:!1,format:u,formatter:e.formatters[u],indices:!1,serializeDate:function(p){return h.call(p)},skipNulls:!1,strictNullHandling:!1},c=function(p){return typeof p=="string"||typeof p=="number"||typeof p=="boolean"||typeof p=="symbol"||typeof p=="bigint"},f={},d=function _(p,g,y,T,I,m,S,x,N,D,F,k,L,q,Z,G,b,P){for(var E=p,A=P,C=0,w=!1;(A=A.get(f))!==void 0&&!w;){var M=A.get(p);if(C+=1,typeof M<"u"){if(M===C)throw new RangeError("Cyclic object value");w=!0}typeof A.get(f)>"u"&&(C=0)}if(typeof D=="function"?E=D(g,E):E instanceof Date?E=L(E):y==="comma"&&s(E)&&(E=t.maybeMap(E,function($){return $ instanceof Date?L($):$})),E===null){if(m)return N&&!G?N(g,l.encoder,b,"key",q):g;E=""}if(c(E)||t.isBuffer(E)){if(N){var R=G?g:N(g,l.encoder,b,"key",q);return[Z(R)+"="+Z(N(E,l.encoder,b,"value",q))]}return[Z(g)+"="+Z(String(E))]}var U=[];if(typeof E>"u")return U;var X;if(y==="comma"&&s(E))G&&N&&(E=t.maybeMap(E,N)),X=[{value:E.length>0?E.join(",")||null:void 0}];else if(s(D))X=D;else{var W=Object.keys(E);X=F?W.sort(F):W}var V=x?g.replace(/\./g,"%2E"):g,Y=T&&s(E)&&E.length===1?V+"[]":V;if(I&&s(E)&&E.length===0)return Y+"[]";for(var K=0;K<X.length;++K){var j=X[K],et=typeof j=="object"&&typeof j.value<"u"?j.value:E[j];if(!(S&&et===null)){var nt=k&&x?j.replace(/\./g,"%2E"):j,ft=s(E)?typeof y=="function"?y(Y,nt):Y:Y+(k?"."+nt:"["+nt+"]");P.set(p,C);var J=i();J.set(f,P),o(U,_(et,ft,y,T,I,m,S,x,y==="comma"&&G&&s(E)?null:N,D,F,k,L,q,Z,G,b,J))}}return U},v=function(p){if(!p)return l;if(typeof p.allowEmptyArrays<"u"&&typeof p.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof p.encodeDotInKeys<"u"&&typeof p.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(p.encoder!==null&&typeof p.encoder<"u"&&typeof p.encoder!="function")throw new TypeError("Encoder has to be a function.");var g=p.charset||l.charset;if(typeof p.charset<"u"&&p.charset!=="utf-8"&&p.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var y=e.default;if(typeof p.format<"u"){if(!r.call(e.formatters,p.format))throw new TypeError("Unknown format option provided.");y=p.format}var T=e.formatters[y],I=l.filter;(typeof p.filter=="function"||s(p.filter))&&(I=p.filter);var m;if(p.arrayFormat in n?m=p.arrayFormat:"indices"in p?m=p.indices?"indices":"repeat":m=l.arrayFormat,"commaRoundTrip"in p&&typeof p.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var S=typeof p.allowDots>"u"?p.encodeDotInKeys===!0?!0:l.allowDots:!!p.allowDots;return{addQueryPrefix:typeof p.addQueryPrefix=="boolean"?p.addQueryPrefix:l.addQueryPrefix,allowDots:S,allowEmptyArrays:typeof p.allowEmptyArrays=="boolean"?!!p.allowEmptyArrays:l.allowEmptyArrays,arrayFormat:m,charset:g,charsetSentinel:typeof p.charsetSentinel=="boolean"?p.charsetSentinel:l.charsetSentinel,commaRoundTrip:p.commaRoundTrip,delimiter:typeof p.delimiter>"u"?l.delimiter:p.delimiter,encode:typeof p.encode=="boolean"?p.encode:l.encode,encodeDotInKeys:typeof p.encodeDotInKeys=="boolean"?p.encodeDotInKeys:l.encodeDotInKeys,encoder:typeof p.encoder=="function"?p.encoder:l.encoder,encodeValuesOnly:typeof p.encodeValuesOnly=="boolean"?p.encodeValuesOnly:l.encodeValuesOnly,filter:I,format:y,formatter:T,serializeDate:typeof p.serializeDate=="function"?p.serializeDate:l.serializeDate,skipNulls:typeof p.skipNulls=="boolean"?p.skipNulls:l.skipNulls,sort:typeof p.sort=="function"?p.sort:null,strictNullHandling:typeof p.strictNullHandling=="boolean"?p.strictNullHandling:l.strictNullHandling}};return as=function(_,p){var g=_,y=v(p),T,I;typeof y.filter=="function"?(I=y.filter,g=I("",g)):s(y.filter)&&(I=y.filter,T=I);var m=[];if(typeof g!="object"||g===null)return"";var S=n[y.arrayFormat],x=S==="comma"&&y.commaRoundTrip;T||(T=Object.keys(g)),y.sort&&T.sort(y.sort);for(var N=i(),D=0;D<T.length;++D){var F=T[D];y.skipNulls&&g[F]===null||o(m,d(g[F],F,S,x,y.allowEmptyArrays,y.strictNullHandling,y.skipNulls,y.encodeDotInKeys,y.encode?y.encoder:null,y.filter,y.sort,y.allowDots,y.serializeDate,y.format,y.formatter,y.encodeValuesOnly,y.charset,N))}var k=m.join(y.delimiter),L=y.addQueryPrefix===!0?"?":"";return y.charsetSentinel&&(y.charset==="iso-8859-1"?L+="utf8=%26%2310003%3B&":L+="utf8=%E2%9C%93&"),k.length>0?L+k:""},as}var os,Dh;function Ec(){if(Dh)return os;Dh=1;var i=Rh(),t=Object.prototype.hasOwnProperty,e=Array.isArray,r={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:i.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1},n=function(f){return f.replace(/&#(\d+);/g,function(d,v){return String.fromCharCode(parseInt(v,10))})},s=function(f,d){return f&&typeof f=="string"&&d.comma&&f.indexOf(",")>-1?f.split(","):f},a="utf8=%26%2310003%3B",o="utf8=%E2%9C%93",h=function(d,v){var _={__proto__:null},p=v.ignoreQueryPrefix?d.replace(/^\?/,""):d;p=p.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var g=v.parameterLimit===1/0?void 0:v.parameterLimit,y=p.split(v.delimiter,g),T=-1,I,m=v.charset;if(v.charsetSentinel)for(I=0;I<y.length;++I)y[I].indexOf("utf8=")===0&&(y[I]===o?m="utf-8":y[I]===a&&(m="iso-8859-1"),T=I,I=y.length);for(I=0;I<y.length;++I)if(I!==T){var S=y[I],x=S.indexOf("]="),N=x===-1?S.indexOf("="):x+1,D,F;N===-1?(D=v.decoder(S,r.decoder,m,"key"),F=v.strictNullHandling?null:""):(D=v.decoder(S.slice(0,N),r.decoder,m,"key"),F=i.maybeMap(s(S.slice(N+1),v),function(L){return v.decoder(L,r.decoder,m,"value")})),F&&v.interpretNumericEntities&&m==="iso-8859-1"&&(F=n(F)),S.indexOf("[]=")>-1&&(F=e(F)?[F]:F);var k=t.call(_,D);k&&v.duplicates==="combine"?_[D]=i.combine(_[D],F):(!k||v.duplicates==="last")&&(_[D]=F)}return _},u=function(f,d,v,_){for(var p=_?d:s(d,v),g=f.length-1;g>=0;--g){var y,T=f[g];if(T==="[]"&&v.parseArrays)y=v.allowEmptyArrays&&(p===""||v.strictNullHandling&&p===null)?[]:[].concat(p);else{y=v.plainObjects?Object.create(null):{};var I=T.charAt(0)==="["&&T.charAt(T.length-1)==="]"?T.slice(1,-1):T,m=v.decodeDotInKeys?I.replace(/%2E/g,"."):I,S=parseInt(m,10);!v.parseArrays&&m===""?y={0:p}:!isNaN(S)&&T!==m&&String(S)===m&&S>=0&&v.parseArrays&&S<=v.arrayLimit?(y=[],y[S]=p):m!=="__proto__"&&(y[m]=p)}p=y}return p},l=function(d,v,_,p){if(d){var g=_.allowDots?d.replace(/\.([^.[]+)/g,"[$1]"):d,y=/(\[[^[\]]*])/,T=/(\[[^[\]]*])/g,I=_.depth>0&&y.exec(g),m=I?g.slice(0,I.index):g,S=[];if(m){if(!_.plainObjects&&t.call(Object.prototype,m)&&!_.allowPrototypes)return;S.push(m)}for(var x=0;_.depth>0&&(I=T.exec(g))!==null&&x<_.depth;){if(x+=1,!_.plainObjects&&t.call(Object.prototype,I[1].slice(1,-1))&&!_.allowPrototypes)return;S.push(I[1])}if(I){if(_.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+_.depth+" and strictDepth is true");S.push("["+g.slice(I.index)+"]")}return u(S,v,_,p)}},c=function(d){if(!d)return r;if(typeof d.allowEmptyArrays<"u"&&typeof d.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof d.decodeDotInKeys<"u"&&typeof d.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(d.decoder!==null&&typeof d.decoder<"u"&&typeof d.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof d.charset<"u"&&d.charset!=="utf-8"&&d.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var v=typeof d.charset>"u"?r.charset:d.charset,_=typeof d.duplicates>"u"?r.duplicates:d.duplicates;if(_!=="combine"&&_!=="first"&&_!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var p=typeof d.allowDots>"u"?d.decodeDotInKeys===!0?!0:r.allowDots:!!d.allowDots;return{allowDots:p,allowEmptyArrays:typeof d.allowEmptyArrays=="boolean"?!!d.allowEmptyArrays:r.allowEmptyArrays,allowPrototypes:typeof d.allowPrototypes=="boolean"?d.allowPrototypes:r.allowPrototypes,allowSparse:typeof d.allowSparse=="boolean"?d.allowSparse:r.allowSparse,arrayLimit:typeof d.arrayLimit=="number"?d.arrayLimit:r.arrayLimit,charset:v,charsetSentinel:typeof d.charsetSentinel=="boolean"?d.charsetSentinel:r.charsetSentinel,comma:typeof d.comma=="boolean"?d.comma:r.comma,decodeDotInKeys:typeof d.decodeDotInKeys=="boolean"?d.decodeDotInKeys:r.decodeDotInKeys,decoder:typeof d.decoder=="function"?d.decoder:r.decoder,delimiter:typeof d.delimiter=="string"||i.isRegExp(d.delimiter)?d.delimiter:r.delimiter,depth:typeof d.depth=="number"||d.depth===!1?+d.depth:r.depth,duplicates:_,ignoreQueryPrefix:d.ignoreQueryPrefix===!0,interpretNumericEntities:typeof d.interpretNumericEntities=="boolean"?d.interpretNumericEntities:r.interpretNumericEntities,parameterLimit:typeof d.parameterLimit=="number"?d.parameterLimit:r.parameterLimit,parseArrays:d.parseArrays!==!1,plainObjects:typeof d.plainObjects=="boolean"?d.plainObjects:r.plainObjects,strictDepth:typeof d.strictDepth=="boolean"?!!d.strictDepth:r.strictDepth,strictNullHandling:typeof d.strictNullHandling=="boolean"?d.strictNullHandling:r.strictNullHandling}};return os=function(f,d){var v=c(d);if(f===""||f===null||typeof f>"u")return v.plainObjects?Object.create(null):{};for(var _=typeof f=="string"?h(f,v):f,p=v.plainObjects?Object.create(null):{},g=Object.keys(_),y=0;y<g.length;++y){var T=g[y],I=l(T,_[T],v,typeof f=="string");p=i.merge(p,I,v)}return v.allowSparse===!0?p:i.compact(p)},os}var hs,Fh;function Sc(){if(Fh)return hs;Fh=1;var i=Tc(),t=Ec(),e=ns();return hs={formats:e,parse:t,stringify:i},hs}var Lh;function Pc(){if(Lh)return Xe;Lh=1;var i=ic();function t(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var e=/^([a-z0-9.+-]+:)/i,r=/:[0-9]*$/,n=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,s=["<",">",'"',"`"," ","\r",`
5
- `," "],a=["{","}","|","\\","^","`"].concat(s),o=["'"].concat(a),h=["%","/","?",";","#"].concat(o),u=["/","?","#"],l=255,c=/^[+a-z0-9A-Z_-]{0,63}$/,f=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,d={javascript:!0,"javascript:":!0},v={javascript:!0,"javascript:":!0},_={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},p=Sc();function g(m,S,x){if(m&&typeof m=="object"&&m instanceof t)return m;var N=new t;return N.parse(m,S,x),N}t.prototype.parse=function(m,S,x){if(typeof m!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof m);var N=m.indexOf("?"),D=N!==-1&&N<m.indexOf("#")?"?":"#",F=m.split(D),k=/\\/g;F[0]=F[0].replace(k,"/"),m=F.join(D);var L=m;if(L=L.trim(),!x&&m.split("#").length===1){var q=n.exec(L);if(q)return this.path=L,this.href=L,this.pathname=q[1],q[2]?(this.search=q[2],S?this.query=p.parse(this.search.substr(1)):this.query=this.search.substr(1)):S&&(this.search="",this.query={}),this}var Z=e.exec(L);if(Z){Z=Z[0];var G=Z.toLowerCase();this.protocol=G,L=L.substr(Z.length)}if(x||Z||L.match(/^\/\/[^@/]+@[^@/]+/)){var b=L.substr(0,2)==="//";b&&!(Z&&v[Z])&&(L=L.substr(2),this.slashes=!0)}if(!v[Z]&&(b||Z&&!_[Z])){for(var P=-1,E=0;E<u.length;E++){var A=L.indexOf(u[E]);A!==-1&&(P===-1||A<P)&&(P=A)}var C,w;P===-1?w=L.lastIndexOf("@"):w=L.lastIndexOf("@",P),w!==-1&&(C=L.slice(0,w),L=L.slice(w+1),this.auth=decodeURIComponent(C)),P=-1;for(var E=0;E<h.length;E++){var A=L.indexOf(h[E]);A!==-1&&(P===-1||A<P)&&(P=A)}P===-1&&(P=L.length),this.host=L.slice(0,P),L=L.slice(P),this.parseHost(),this.hostname=this.hostname||"";var M=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!M)for(var R=this.hostname.split(/\./),E=0,U=R.length;E<U;E++){var X=R[E];if(X&&!X.match(c)){for(var W="",V=0,Y=X.length;V<Y;V++)X.charCodeAt(V)>127?W+="x":W+=X[V];if(!W.match(c)){var K=R.slice(0,E),j=R.slice(E+1),et=X.match(f);et&&(K.push(et[1]),j.unshift(et[2])),j.length&&(L="/"+j.join(".")+L),this.hostname=K.join(".");break}}}this.hostname.length>l?this.hostname="":this.hostname=this.hostname.toLowerCase(),M||(this.hostname=i.toASCII(this.hostname));var nt=this.port?":"+this.port:"",ft=this.hostname||"";this.host=ft+nt,this.href+=this.host,M&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),L[0]!=="/"&&(L="/"+L))}if(!d[G])for(var E=0,U=o.length;E<U;E++){var J=o[E];if(L.indexOf(J)!==-1){var $=encodeURIComponent(J);$===J&&($=escape(J)),L=L.split(J).join($)}}var rt=L.indexOf("#");rt!==-1&&(this.hash=L.substr(rt),L=L.slice(0,rt));var ot=L.indexOf("?");if(ot!==-1?(this.search=L.substr(ot),this.query=L.substr(ot+1),S&&(this.query=p.parse(this.query)),L=L.slice(0,ot)):S&&(this.search="",this.query={}),L&&(this.pathname=L),_[G]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var nt=this.pathname||"",Ht=this.search||"";this.path=nt+Ht}return this.href=this.format(),this};function y(m){return typeof m=="string"&&(m=g(m)),m instanceof t?m.format():t.prototype.format.call(m)}t.prototype.format=function(){var m=this.auth||"";m&&(m=encodeURIComponent(m),m=m.replace(/%3A/i,":"),m+="@");var S=this.protocol||"",x=this.pathname||"",N=this.hash||"",D=!1,F="";this.host?D=m+this.host:this.hostname&&(D=m+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(D+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(F=p.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var k=this.search||F&&"?"+F||"";return S&&S.substr(-1)!==":"&&(S+=":"),this.slashes||(!S||_[S])&&D!==!1?(D="//"+(D||""),x&&x.charAt(0)!=="/"&&(x="/"+x)):D||(D=""),N&&N.charAt(0)!=="#"&&(N="#"+N),k&&k.charAt(0)!=="?"&&(k="?"+k),x=x.replace(/[?#]/g,function(L){return encodeURIComponent(L)}),k=k.replace("#","%23"),S+D+x+k+N};function T(m,S){return g(m,!1,!0).resolve(S)}t.prototype.resolve=function(m){return this.resolveObject(g(m,!1,!0)).format()};function I(m,S){return m?g(m,!1,!0).resolveObject(S):S}return t.prototype.resolveObject=function(m){if(typeof m=="string"){var S=new t;S.parse(m,!1,!0),m=S}for(var x=new t,N=Object.keys(this),D=0;D<N.length;D++){var F=N[D];x[F]=this[F]}if(x.hash=m.hash,m.href==="")return x.href=x.format(),x;if(m.slashes&&!m.protocol){for(var k=Object.keys(m),L=0;L<k.length;L++){var q=k[L];q!=="protocol"&&(x[q]=m[q])}return _[x.protocol]&&x.hostname&&!x.pathname&&(x.pathname="/",x.path=x.pathname),x.href=x.format(),x}if(m.protocol&&m.protocol!==x.protocol){if(!_[m.protocol]){for(var Z=Object.keys(m),G=0;G<Z.length;G++){var b=Z[G];x[b]=m[b]}return x.href=x.format(),x}if(x.protocol=m.protocol,!m.host&&!v[m.protocol]){for(var U=(m.pathname||"").split("/");U.length&&!(m.host=U.shift()););m.host||(m.host=""),m.hostname||(m.hostname=""),U[0]!==""&&U.unshift(""),U.length<2&&U.unshift(""),x.pathname=U.join("/")}else x.pathname=m.pathname;if(x.search=m.search,x.query=m.query,x.host=m.host||"",x.auth=m.auth,x.hostname=m.hostname||m.host,x.port=m.port,x.pathname||x.search){var P=x.pathname||"",E=x.search||"";x.path=P+E}return x.slashes=x.slashes||m.slashes,x.href=x.format(),x}var A=x.pathname&&x.pathname.charAt(0)==="/",C=m.host||m.pathname&&m.pathname.charAt(0)==="/",w=C||A||x.host&&m.pathname,M=w,R=x.pathname&&x.pathname.split("/")||[],U=m.pathname&&m.pathname.split("/")||[],X=x.protocol&&!_[x.protocol];if(X&&(x.hostname="",x.port=null,x.host&&(R[0]===""?R[0]=x.host:R.unshift(x.host)),x.host="",m.protocol&&(m.hostname=null,m.port=null,m.host&&(U[0]===""?U[0]=m.host:U.unshift(m.host)),m.host=null),w=w&&(U[0]===""||R[0]==="")),C)x.host=m.host||m.host===""?m.host:x.host,x.hostname=m.hostname||m.hostname===""?m.hostname:x.hostname,x.search=m.search,x.query=m.query,R=U;else if(U.length)R||(R=[]),R.pop(),R=R.concat(U),x.search=m.search,x.query=m.query;else if(m.search!=null){if(X){x.host=R.shift(),x.hostname=x.host;var W=x.host&&x.host.indexOf("@")>0?x.host.split("@"):!1;W&&(x.auth=W.shift(),x.hostname=W.shift(),x.host=x.hostname)}return x.search=m.search,x.query=m.query,(x.pathname!==null||x.search!==null)&&(x.path=(x.pathname?x.pathname:"")+(x.search?x.search:"")),x.href=x.format(),x}if(!R.length)return x.pathname=null,x.search?x.path="/"+x.search:x.path=null,x.href=x.format(),x;for(var V=R.slice(-1)[0],Y=(x.host||m.host||R.length>1)&&(V==="."||V==="..")||V==="",K=0,j=R.length;j>=0;j--)V=R[j],V==="."?R.splice(j,1):V===".."?(R.splice(j,1),K++):K&&(R.splice(j,1),K--);if(!w&&!M)for(;K--;K)R.unshift("..");w&&R[0]!==""&&(!R[0]||R[0].charAt(0)!=="/")&&R.unshift(""),Y&&R.join("/").substr(-1)!=="/"&&R.push("");var et=R[0]===""||R[0]&&R[0].charAt(0)==="/";if(X){x.hostname=et?"":R.length?R.shift():"",x.host=x.hostname;var W=x.host&&x.host.indexOf("@")>0?x.host.split("@"):!1;W&&(x.auth=W.shift(),x.hostname=W.shift(),x.host=x.hostname)}return w=w||x.host&&R.length,w&&!et&&R.unshift(""),R.length>0?x.pathname=R.join("/"):(x.pathname=null,x.path=null),(x.pathname!==null||x.search!==null)&&(x.path=(x.pathname?x.pathname:"")+(x.search?x.search:"")),x.auth=m.auth||x.auth,x.slashes=x.slashes||m.slashes,x.href=x.format(),x},t.prototype.parseHost=function(){var m=this.host,S=r.exec(m);S&&(S=S[0],S!==":"&&(this.port=S.substr(1)),m=m.substr(0,m.length-S.length)),m&&(this.hostname=m)},Xe.parse=g,Xe.resolve=T,Xe.resolveObject=I,Xe.format=y,Xe.Url=t,Xe}var us=Pc();var ce={parse:us.parse,format:us.format,resolve:us.resolve};function ae(i){if(typeof i!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(i))}function Bh(i){var t=i.split("?")[0];return t.split("#")[0]}function wc(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cc(i,t,e){return i.replace(new RegExp(wc(t),"g"),e)}function Ic(i,t){for(var e="",r=0,n=-1,s=0,a,o=0;o<=i.length;++o){if(o<i.length)a=i.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(n===o-1||s===1))if(n!==o-1&&s===2){if(e.length<2||r!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){var h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",r=0):(e=e.slice(0,h),r=e.length-1-e.lastIndexOf("/")),n=o,s=0;continue}}else if(e.length===2||e.length===1){e="",r=0,n=o,s=0;continue}}}else e.length>0?e+="/"+i.slice(n+1,o):e=i.slice(n+1,o),r=o-n-1;n=o,s=0}else a===46&&s!==-1?++s:s=-1}return e}var Nh={toPosix:function(i){return Cc(i,"\\","/")},isUrl:function(i){return/^https?:/.test(this.toPosix(i))},isDataUrl:function(i){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i)},hasProtocol:function(i){return/^[^/:]+:\//.test(this.toPosix(i))},getProtocol:function(i){ae(i),i=this.toPosix(i);var t="",e=/^file:\/\/\//.exec(i),r=/^[^/:]+:\/\//.exec(i),n=/^[^/:]+:\//.exec(i);if(e||r||n){var s=(e==null?void 0:e[0])||(r==null?void 0:r[0])||(n==null?void 0:n[0]);t=s,i=i.slice(s.length)}return t},toAbsolute:function(i,t,e){if(this.isDataUrl(i))return i;var r=Bh(this.toPosix(t??z.ADAPTER.getBaseUrl())),n=Bh(this.toPosix(e??this.rootname(r)));if(ae(i),i=this.toPosix(i),i.startsWith("/"))return Nh.join(n,i.slice(1));var s=this.isAbsolute(i)?i:this.join(r,i);return s},normalize:function(i){if(i=this.toPosix(i),ae(i),i.length===0)return".";var t="",e=i.startsWith("/");this.hasProtocol(i)&&(t=this.rootname(i),i=i.slice(t.length));var r=i.endsWith("/");return i=Ic(i),i.length>0&&r&&(i+="/"),e?"/"+i:t+i},isAbsolute:function(i){return ae(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join:function(){for(var i=arguments,t,e=[],r=0;r<arguments.length;r++)e[r]=i[r];if(e.length===0)return".";for(var n,s=0;s<e.length;++s){var a=e[s];if(ae(a),a.length>0)if(n===void 0)n=a;else{var o=(t=e[s-1])!==null&&t!==void 0?t:"";this.extname(o)?n+="/../"+a:n+="/"+a}}return n===void 0?".":this.normalize(n)},dirname:function(i){if(ae(i),i.length===0)return".";i=this.toPosix(i);var t=i.charCodeAt(0),e=t===47,r=-1,n=!0,s=this.getProtocol(i),a=i;i=i.slice(s.length);for(var o=i.length-1;o>=1;--o)if(t=i.charCodeAt(o),t===47){if(!n){r=o;break}}else n=!1;return r===-1?e?"/":this.isUrl(a)?s+i:s:e&&r===1?"//":s+i.slice(0,r)},rootname:function(i){ae(i),i=this.toPosix(i);var t="";if(i.startsWith("/")?t="/":t=this.getProtocol(i),this.isUrl(i)){var e=i.indexOf("/",t.length);e!==-1?t=i.slice(0,e):t=i,t.endsWith("/")||(t+="/")}return t},basename:function(i,t){ae(i),t&&ae(t),i=this.toPosix(i);var e=0,r=-1,n=!0,s;if(t!==void 0&&t.length>0&&t.length<=i.length){if(t.length===i.length&&t===i)return"";var a=t.length-1,o=-1;for(s=i.length-1;s>=0;--s){var h=i.charCodeAt(s);if(h===47){if(!n){e=s+1;break}}else o===-1&&(n=!1,o=s+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(r=s):(a=-1,r=o))}return e===r?r=o:r===-1&&(r=i.length),i.slice(e,r)}for(s=i.length-1;s>=0;--s)if(i.charCodeAt(s)===47){if(!n){e=s+1;break}}else r===-1&&(n=!1,r=s+1);return r===-1?"":i.slice(e,r)},extname:function(i){ae(i),i=this.toPosix(i);for(var t=-1,e=0,r=-1,n=!0,s=0,a=i.length-1;a>=0;--a){var o=i.charCodeAt(a);if(o===47){if(!n){e=a+1;break}continue}r===-1&&(n=!1,r=a+1),o===46?t===-1?t=a:s!==1&&(s=1):t!==-1&&(s=-1)}return t===-1||r===-1||s===0||s===1&&t===r-1&&t===e+1?"":i.slice(t,r)},parse:function(i){ae(i);var t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=this.toPosix(i);var e=i.charCodeAt(0),r=this.isAbsolute(i),n;t.root=this.rootname(i),r||this.hasProtocol(i)?n=1:n=0;for(var s=-1,a=0,o=-1,h=!0,u=i.length-1,l=0;u>=n;--u){if(e=i.charCodeAt(u),e===47){if(!h){a=u+1;break}continue}o===-1&&(h=!1,o=u+1),e===46?s===-1?s=u:l!==1&&(l=1):s!==-1&&(l=-1)}return s===-1||o===-1||l===0||l===1&&s===o-1&&s===a+1?o!==-1&&(a===0&&r?t.base=t.name=i.slice(1,o):t.base=t.name=i.slice(a,o)):(a===0&&r?(t.name=i.slice(1,s),t.base=i.slice(1,o)):(t.name=i.slice(a,s),t.base=i.slice(a,o)),t.ext=i.slice(s,o)),t.dir=this.dirname(i),t},sep:"/",delimiter:":"};z.RETINA_PREFIX=/@([0-9\.]+)x/,z.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var ls=!1,Uh="6.5.10";function Ac(){ls=!0}function kh(i){var t;if(!ls){if(z.ADAPTER.getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){var e=[`
6
- %c %c %c PixiJS `+Uh+" - ✰ "+i+` ✰ %c %c http://www.pixijs.com/ %c %c ♥%c♥%c♥
7
-
8
- `,"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 "+Uh+" - "+i+" - http://www.pixijs.com/");ls=!0}}var fs;function Gh(){return typeof fs>"u"&&(fs=function(){var t={stencil:!0,failIfMajorPerformanceCaveat:z.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!z.ADAPTER.getWebGLRenderingContext())return!1;var e=z.ADAPTER.createCanvas(),r=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),n=!!(r&&r.getContextAttributes().stencil);if(r){var s=r.getExtension("WEBGL_lose_context");s&&s.loseContext()}return r=null,n}catch{return!1}}()),fs}var Mc="#f0f8ff",Rc="#faebd7",Oc="#00ffff",Dc="#7fffd4",Fc="#f0ffff",Lc="#f5f5dc",Bc="#ffe4c4",Nc="#000000",Uc="#ffebcd",kc="#0000ff",Gc="#8a2be2",Xc="#a52a2a",Hc="#deb887",Vc="#5f9ea0",jc="#7fff00",zc="#d2691e",Wc="#ff7f50",Yc="#6495ed",qc="#fff8dc",$c="#dc143c",Kc="#00ffff",Zc="#00008b",Jc="#008b8b",Qc="#b8860b",td="#a9a9a9",ed="#006400",rd="#a9a9a9",id="#bdb76b",nd="#8b008b",sd="#556b2f",ad="#ff8c00",od="#9932cc",hd="#8b0000",ud="#e9967a",ld="#8fbc8f",fd="#483d8b",cd="#2f4f4f",dd="#2f4f4f",pd="#00ced1",vd="#9400d3",_d="#ff1493",gd="#00bfff",md="#696969",yd="#696969",xd="#1e90ff",bd="#b22222",Td="#fffaf0",Ed="#228b22",Sd="#ff00ff",Pd="#dcdcdc",wd="#f8f8ff",Cd="#daa520",Id="#ffd700",Ad="#808080",Md="#008000",Rd="#adff2f",Od="#808080",Dd="#f0fff0",Fd="#ff69b4",Ld="#cd5c5c",Bd="#4b0082",Nd="#fffff0",Ud="#f0e68c",kd="#fff0f5",Gd="#e6e6fa",Xd="#7cfc00",Hd="#fffacd",Vd="#add8e6",jd="#f08080",zd="#e0ffff",Wd="#fafad2",Yd="#d3d3d3",qd="#90ee90",$d="#d3d3d3",Kd="#ffb6c1",Zd="#ffa07a",Jd="#20b2aa",Qd="#87cefa",tp="#778899",ep="#778899",rp="#b0c4de",ip="#ffffe0",np="#00ff00",sp="#32cd32",ap="#faf0e6",op="#ff00ff",hp="#800000",up="#66cdaa",lp="#0000cd",fp="#ba55d3",cp="#9370db",dp="#3cb371",pp="#7b68ee",vp="#00fa9a",_p="#48d1cc",gp="#c71585",mp="#191970",yp="#f5fffa",xp="#ffe4e1",bp="#ffe4b5",Tp="#ffdead",Ep="#000080",Sp="#fdf5e6",Pp="#808000",wp="#6b8e23",Cp="#ffa500",Ip="#ff4500",Ap="#da70d6",Mp="#eee8aa",Rp="#98fb98",Op="#afeeee",Dp="#db7093",Fp="#ffefd5",Lp="#ffdab9",Bp="#cd853f",Np="#ffc0cb",Up="#dda0dd",kp="#b0e0e6",Gp="#800080",Xp="#663399",Hp="#ff0000",Vp="#bc8f8f",jp="#4169e1",zp="#8b4513",Wp="#fa8072",Yp="#f4a460",qp="#2e8b57",$p="#fff5ee",Kp="#a0522d",Zp="#c0c0c0",Jp="#87ceeb",Qp="#6a5acd",tv="#708090",ev="#708090",rv="#fffafa",iv="#00ff7f",nv="#4682b4",sv="#d2b48c",av="#008080",ov="#d8bfd8",hv="#ff6347",uv="#40e0d0",lv="#ee82ee",fv="#f5deb3",cv="#ffffff",dv="#f5f5f5",pv="#ffff00",vv="#9acd32",_v={aliceblue:Mc,antiquewhite:Rc,aqua:Oc,aquamarine:Dc,azure:Fc,beige:Lc,bisque:Bc,black:Nc,blanchedalmond:Uc,blue:kc,blueviolet:Gc,brown:Xc,burlywood:Hc,cadetblue:Vc,chartreuse:jc,chocolate:zc,coral:Wc,cornflowerblue:Yc,cornsilk:qc,crimson:$c,cyan:Kc,darkblue:Zc,darkcyan:Jc,darkgoldenrod:Qc,darkgray:td,darkgreen:ed,darkgrey:rd,darkkhaki:id,darkmagenta:nd,darkolivegreen:sd,darkorange:ad,darkorchid:od,darkred:hd,darksalmon:ud,darkseagreen:ld,darkslateblue:fd,darkslategray:cd,darkslategrey:dd,darkturquoise:pd,darkviolet:vd,deeppink:_d,deepskyblue:gd,dimgray:md,dimgrey:yd,dodgerblue:xd,firebrick:bd,floralwhite:Td,forestgreen:Ed,fuchsia:Sd,gainsboro:Pd,ghostwhite:wd,goldenrod:Cd,gold:Id,gray:Ad,green:Md,greenyellow:Rd,grey:Od,honeydew:Dd,hotpink:Fd,indianred:Ld,indigo:Bd,ivory:Nd,khaki:Ud,lavenderblush:kd,lavender:Gd,lawngreen:Xd,lemonchiffon:Hd,lightblue:Vd,lightcoral:jd,lightcyan:zd,lightgoldenrodyellow:Wd,lightgray:Yd,lightgreen:qd,lightgrey:$d,lightpink:Kd,lightsalmon:Zd,lightseagreen:Jd,lightskyblue:Qd,lightslategray:tp,lightslategrey:ep,lightsteelblue:rp,lightyellow:ip,lime:np,limegreen:sp,linen:ap,magenta:op,maroon:hp,mediumaquamarine:up,mediumblue:lp,mediumorchid:fp,mediumpurple:cp,mediumseagreen:dp,mediumslateblue:pp,mediumspringgreen:vp,mediumturquoise:_p,mediumvioletred:gp,midnightblue:mp,mintcream:yp,mistyrose:xp,moccasin:bp,navajowhite:Tp,navy:Ep,oldlace:Sp,olive:Pp,olivedrab:wp,orange:Cp,orangered:Ip,orchid:Ap,palegoldenrod:Mp,palegreen:Rp,paleturquoise:Op,palevioletred:Dp,papayawhip:Fp,peachpuff:Lp,peru:Bp,pink:Np,plum:Up,powderblue:kp,purple:Gp,rebeccapurple:Xp,red:Hp,rosybrown:Vp,royalblue:jp,saddlebrown:zp,salmon:Wp,sandybrown:Yp,seagreen:qp,seashell:$p,sienna:Kp,silver:Zp,skyblue:Jp,slateblue:Qp,slategray:tv,slategrey:ev,snow:rv,springgreen:iv,steelblue:nv,tan:sv,teal:av,thistle:ov,tomato:hv,turquoise:uv,violet:lv,wheat:fv,white:cv,whitesmoke:dv,yellow:pv,yellowgreen:vv};function He(i,t){return t===void 0&&(t=[]),t[0]=(i>>16&255)/255,t[1]=(i>>8&255)/255,t[2]=(i&255)/255,t}function cs(i){var t=i.toString(16);return t="000000".substring(0,6-t.length)+t,"#"+t}function ds(i){return typeof i=="string"&&(i=_v[i.toLowerCase()]||i,i[0]==="#"&&(i=i.slice(1))),parseInt(i,16)}function gv(i){return(i[0]*255<<16)+(i[1]*255<<8)+(i[2]*255|0)}function mv(){for(var i=[],t=[],e=0;e<32;e++)i[e]=e,t[e]=e;i[tt.NORMAL_NPM]=tt.NORMAL,i[tt.ADD_NPM]=tt.ADD,i[tt.SCREEN_NPM]=tt.SCREEN,t[tt.NORMAL]=tt.NORMAL_NPM,t[tt.ADD]=tt.ADD_NPM,t[tt.SCREEN]=tt.SCREEN_NPM;var r=[];return r.push(t),r.push(i),r}var ps=mv();function vs(i,t){return ps[t?1:0][i]}function Xh(i,t,e,r){return e=e||new Float32Array(4),r||r===void 0?(e[0]=i[0]*t,e[1]=i[1]*t,e[2]=i[2]*t):(e[0]=i[0],e[1]=i[1],e[2]=i[2]),e[3]=t,e}function Pi(i,t){if(t===1)return(t*255<<24)+i;if(t===0)return 0;var e=i>>16&255,r=i>>8&255,n=i&255;return e=e*t+.5|0,r=r*t+.5|0,n=n*t+.5|0,(t*255<<24)+(e<<16)+(r<<8)+n}function _s(i,t,e,r){return e=e||new Float32Array(4),e[0]=(i>>16&255)/255,e[1]=(i>>8&255)/255,e[2]=(i&255)/255,(r||r===void 0)&&(e[0]*=t,e[1]*=t,e[2]*=t),e[3]=t,e}function Hh(i,t){t===void 0&&(t=null);var e=i*6;if(t=t||new Uint16Array(e),t.length!==e)throw new Error("Out buffer length is incorrect, got "+t.length+" and expected "+e);for(var r=0,n=0;r<e;r+=6,n+=4)t[r+0]=n+0,t[r+1]=n+1,t[r+2]=n+2,t[r+3]=n+0,t[r+4]=n+2,t[r+5]=n+3;return t}function wi(i){if(i.BYTES_PER_ELEMENT===4)return i instanceof Float32Array?"Float32Array":i instanceof Uint32Array?"Uint32Array":"Int32Array";if(i.BYTES_PER_ELEMENT===2){if(i instanceof Uint16Array)return"Uint16Array"}else if(i.BYTES_PER_ELEMENT===1&&i instanceof Uint8Array)return"Uint8Array";return null}var yv={Float32Array,Uint32Array,Int32Array,Uint8Array};function xv(i,t){for(var e=0,r=0,n={},s=0;s<i.length;s++)r+=t[s],e+=i[s].length;for(var a=new ArrayBuffer(e*4),o=null,h=0,s=0;s<i.length;s++){var u=t[s],l=i[s],c=wi(l);n[c]||(n[c]=new yv[c](a)),o=n[c];for(var f=0;f<l.length;f++){var d=(f/u|0)*r+h,v=f%u;o[d+v]=l[f]}h+=u}return new Float32Array(a)}function kr(i){return i+=i===0?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i+1}function gs(i){return!(i&i-1)&&!!i}function ms(i){var t=(i>65535?1:0)<<4;i>>>=t;var e=(i>255?1:0)<<3;return i>>>=e,t|=e,e=(i>15?1:0)<<2,i>>>=e,t|=e,e=(i>3?1:0)<<1,i>>>=e,t|=e,t|i>>1}function Ve(i,t,e){var r=i.length,n;if(!(t>=r||e===0)){e=t+e>r?r-t:e;var s=r-e;for(n=t;n<s;++n)i[n]=i[n+e];i.length=s}}function je(i){return i===0?0:i<0?-1:1}var bv=0;function Ie(){return++bv}var Vh={};function Bt(i,t,e){if(e===void 0&&(e=3),!Vh[t]){var r=new Error().stack;typeof r>"u"?console.warn("PixiJS Deprecation Warning: ",t+`
9
- Deprecated since v`+i):(r=r.split(`
1
+ (function(ae,Zt){typeof exports=="object"&&typeof module<"u"?Zt(exports,require("../lib/cubism2.min.js"),require("../lib/cubism5.min.js")):typeof define=="function"&&define.amd?define(["exports","../lib/cubism2.min","../lib/cubism5.min"],Zt):(ae=typeof globalThis<"u"?globalThis:ae||self,Zt(ae.l2d={}))})(this,function(ae){"use strict";var Zt=(s=>(s[s.WEBGL_LEGACY=0]="WEBGL_LEGACY",s[s.WEBGL=1]="WEBGL",s[s.WEBGL2=2]="WEBGL2",s))(Zt||{}),bn=(s=>(s[s.UNKNOWN=0]="UNKNOWN",s[s.WEBGL=1]="WEBGL",s[s.CANVAS=2]="CANVAS",s))(bn||{}),rs=(s=>(s[s.COLOR=16384]="COLOR",s[s.DEPTH=256]="DEPTH",s[s.STENCIL=1024]="STENCIL",s))(rs||{}),nt=(s=>(s[s.NORMAL=0]="NORMAL",s[s.ADD=1]="ADD",s[s.MULTIPLY=2]="MULTIPLY",s[s.SCREEN=3]="SCREEN",s[s.OVERLAY=4]="OVERLAY",s[s.DARKEN=5]="DARKEN",s[s.LIGHTEN=6]="LIGHTEN",s[s.COLOR_DODGE=7]="COLOR_DODGE",s[s.COLOR_BURN=8]="COLOR_BURN",s[s.HARD_LIGHT=9]="HARD_LIGHT",s[s.SOFT_LIGHT=10]="SOFT_LIGHT",s[s.DIFFERENCE=11]="DIFFERENCE",s[s.EXCLUSION=12]="EXCLUSION",s[s.HUE=13]="HUE",s[s.SATURATION=14]="SATURATION",s[s.COLOR=15]="COLOR",s[s.LUMINOSITY=16]="LUMINOSITY",s[s.NORMAL_NPM=17]="NORMAL_NPM",s[s.ADD_NPM=18]="ADD_NPM",s[s.SCREEN_NPM=19]="SCREEN_NPM",s[s.NONE=20]="NONE",s[s.SRC_OVER=0]="SRC_OVER",s[s.SRC_IN=21]="SRC_IN",s[s.SRC_OUT=22]="SRC_OUT",s[s.SRC_ATOP=23]="SRC_ATOP",s[s.DST_OVER=24]="DST_OVER",s[s.DST_IN=25]="DST_IN",s[s.DST_OUT=26]="DST_OUT",s[s.DST_ATOP=27]="DST_ATOP",s[s.ERASE=26]="ERASE",s[s.SUBTRACT=28]="SUBTRACT",s[s.XOR=29]="XOR",s))(nt||{}),oe=(s=>(s[s.POINTS=0]="POINTS",s[s.LINES=1]="LINES",s[s.LINE_LOOP=2]="LINE_LOOP",s[s.LINE_STRIP=3]="LINE_STRIP",s[s.TRIANGLES=4]="TRIANGLES",s[s.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",s[s.TRIANGLE_FAN=6]="TRIANGLE_FAN",s))(oe||{}),H=(s=>(s[s.RGBA=6408]="RGBA",s[s.RGB=6407]="RGB",s[s.RG=33319]="RG",s[s.RED=6403]="RED",s[s.RGBA_INTEGER=36249]="RGBA_INTEGER",s[s.RGB_INTEGER=36248]="RGB_INTEGER",s[s.RG_INTEGER=33320]="RG_INTEGER",s[s.RED_INTEGER=36244]="RED_INTEGER",s[s.ALPHA=6406]="ALPHA",s[s.LUMINANCE=6409]="LUMINANCE",s[s.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",s[s.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",s[s.DEPTH_STENCIL=34041]="DEPTH_STENCIL",s))(H||{}),ui=(s=>(s[s.TEXTURE_2D=3553]="TEXTURE_2D",s[s.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",s[s.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",s[s.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",s[s.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",s[s.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",s[s.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",s))(ui||{}),it=(s=>(s[s.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",s[s.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",s[s.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",s[s.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",s[s.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",s[s.UNSIGNED_INT=5125]="UNSIGNED_INT",s[s.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",s[s.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",s[s.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",s[s.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",s[s.BYTE=5120]="BYTE",s[s.SHORT=5122]="SHORT",s[s.INT=5124]="INT",s[s.FLOAT=5126]="FLOAT",s[s.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",s[s.HALF_FLOAT=36193]="HALF_FLOAT",s))(it||{}),Y=(s=>(s[s.FLOAT=0]="FLOAT",s[s.INT=1]="INT",s[s.UINT=2]="UINT",s))(Y||{}),be=(s=>(s[s.NEAREST=0]="NEAREST",s[s.LINEAR=1]="LINEAR",s))(be||{}),Te=(s=>(s[s.CLAMP=33071]="CLAMP",s[s.REPEAT=10497]="REPEAT",s[s.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",s))(Te||{}),he=(s=>(s[s.OFF=0]="OFF",s[s.POW2=1]="POW2",s[s.ON=2]="ON",s[s.ON_MANUAL=3]="ON_MANUAL",s))(he||{}),Nt=(s=>(s[s.NPM=0]="NPM",s[s.UNPACK=1]="UNPACK",s[s.PMA=2]="PMA",s[s.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",s[s.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",s[s.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",s))(Nt||{}),le=(s=>(s[s.NO=0]="NO",s[s.YES=1]="YES",s[s.AUTO=2]="AUTO",s[s.BLEND=0]="BLEND",s[s.CLEAR=1]="CLEAR",s[s.BLIT=2]="BLIT",s))(le||{}),ss=(s=>(s[s.AUTO=0]="AUTO",s[s.MANUAL=1]="MANUAL",s))(ss||{}),Xt=(s=>(s.LOW="lowp",s.MEDIUM="mediump",s.HIGH="highp",s))(Xt||{}),It=(s=>(s[s.NONE=0]="NONE",s[s.SCISSOR=1]="SCISSOR",s[s.STENCIL=2]="STENCIL",s[s.SPRITE=3]="SPRITE",s[s.COLOR=4]="COLOR",s))(It||{}),bh=(s=>(s[s.RED=1]="RED",s[s.GREEN=2]="GREEN",s[s.BLUE=4]="BLUE",s[s.ALPHA=8]="ALPHA",s))(bh||{}),St=(s=>(s[s.NONE=0]="NONE",s[s.LOW=2]="LOW",s[s.MEDIUM=4]="MEDIUM",s[s.HIGH=8]="HIGH",s))(St||{}),ue=(s=>(s[s.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",s[s.ARRAY_BUFFER=34962]="ARRAY_BUFFER",s[s.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",s))(ue||{});const Th={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")},q={ADAPTER:Th,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Tn=/iPhone/i,Eh=/iPod/i,wh=/iPad/i,Ch=/\biOS-universal(?:.+)Mac\b/i,En=/\bAndroid(?:.+)Mobile\b/i,Ah=/Android/i,Mi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,ns=/Silk/i,Oe=/Windows Phone/i,Sh=/\bWindows(?:.+)ARM\b/i,Ph=/BlackBerry/i,Mh=/BB10/i,Ih=/Opera Mini/i,Rh=/\b(CriOS|Chrome)(?:.+)Mobile/i,Dh=/Mobile(?:.+)Firefox\b/i,Fh=function(s){return typeof s<"u"&&s.platform==="MacIntel"&&typeof s.maxTouchPoints=="number"&&s.maxTouchPoints>1&&typeof MSStream>"u"};function ff(s){return function(t){return t.test(s)}}function Bh(s){var t={userAgent:"",platform:"",maxTouchPoints:0};!s&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof s=="string"?t.userAgent=s:s&&s.userAgent&&(t={userAgent:s.userAgent,platform:s.platform,maxTouchPoints:s.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var r=ff(e),n={apple:{phone:r(Tn)&&!r(Oe),ipod:r(Eh),tablet:!r(Tn)&&(r(wh)||Fh(t))&&!r(Oe),universal:r(Ch),device:(r(Tn)||r(Eh)||r(wh)||r(Ch)||Fh(t))&&!r(Oe)},amazon:{phone:r(Mi),tablet:!r(Mi)&&r(ns),device:r(Mi)||r(ns)},android:{phone:!r(Oe)&&r(Mi)||!r(Oe)&&r(En),tablet:!r(Oe)&&!r(Mi)&&!r(En)&&(r(ns)||r(Ah)),device:!r(Oe)&&(r(Mi)||r(ns)||r(En)||r(Ah))||r(/\bokhttp\b/i)},windows:{phone:r(Oe),tablet:r(Sh),device:r(Oe)||r(Sh)},other:{blackberry:r(Ph),blackberry10:r(Mh),opera:r(Ih),firefox:r(Dh),chrome:r(Rh),device:r(Ph)||r(Mh)||r(Ih)||r(Dh)||r(Rh)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const pf=Bh.default??Bh,ce=pf(globalThis.navigator);q.RETINA_PREFIX=/@([0-9\.]+)x/,q.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var wn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Lh(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function mf(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var t=s.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(s).forEach(function(i){var r=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return s[i]}})}),e}var Cn={exports:{}},Oh;function gf(){return Oh||(Oh=1,function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function r(h,l,u){this.fn=h,this.context=l,this.once=u||!1}function n(h,l,u,c,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new r(u,c||h,d),p=e?e+l:l;return h._events[p]?h._events[p].fn?h._events[p]=[h._events[p],f]:h._events[p].push(f):(h._events[p]=f,h._eventsCount++),h}function a(h,l){--h._eventsCount===0?h._events=new i:delete h._events[l]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],u,c;if(this._eventsCount===0)return l;for(c in u=this._events)t.call(u,c)&&l.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(u)):l},o.prototype.listeners=function(l){var u=e?e+l:l,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,f=c.length,p=new Array(f);d<f;d++)p[d]=c[d].fn;return p},o.prototype.listenerCount=function(l){var u=e?e+l:l,c=this._events[u];return c?c.fn?1:c.length:0},o.prototype.emit=function(l,u,c,d,f,p){var g=e?e+l:l;if(!this._events[g])return!1;var m=this._events[g],_=arguments.length,b,y;if(m.fn){switch(m.once&&this.removeListener(l,m.fn,void 0,!0),_){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,u),!0;case 3:return m.fn.call(m.context,u,c),!0;case 4:return m.fn.call(m.context,u,c,d),!0;case 5:return m.fn.call(m.context,u,c,d,f),!0;case 6:return m.fn.call(m.context,u,c,d,f,p),!0}for(y=1,b=new Array(_-1);y<_;y++)b[y-1]=arguments[y];m.fn.apply(m.context,b)}else{var E=m.length,v;for(y=0;y<E;y++)switch(m[y].once&&this.removeListener(l,m[y].fn,void 0,!0),_){case 1:m[y].fn.call(m[y].context);break;case 2:m[y].fn.call(m[y].context,u);break;case 3:m[y].fn.call(m[y].context,u,c);break;case 4:m[y].fn.call(m[y].context,u,c,d);break;default:if(!b)for(v=1,b=new Array(_-1);v<_;v++)b[v-1]=arguments[v];m[y].fn.apply(m[y].context,b)}}return!0},o.prototype.on=function(l,u,c){return n(this,l,u,c,!1)},o.prototype.once=function(l,u,c){return n(this,l,u,c,!0)},o.prototype.removeListener=function(l,u,c,d){var f=e?e+l:l;if(!this._events[f])return this;if(!u)return a(this,f),this;var p=this._events[f];if(p.fn)p.fn===u&&(!d||p.once)&&(!c||p.context===c)&&a(this,f);else{for(var g=0,m=[],_=p.length;g<_;g++)(p[g].fn!==u||d&&!p[g].once||c&&p[g].context!==c)&&m.push(p[g]);m.length?this._events[f]=m.length===1?m[0]:m:a(this,f)}return this},o.prototype.removeAllListeners=function(l){var u;return l?(u=e?e+l:l,this._events[u]&&a(this,u)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,s.exports=o}(Cn)),Cn.exports}var _f=gf();const Ee=Lh(_f);var as={exports:{}},kh;function yf(){if(kh)return as.exports;kh=1,as.exports=s,as.exports.default=s;function s(w,C,x){x=x||2;var R=C&&C.length,A=R?C[0]*x:w.length,S=t(w,0,A,x,!0),F=[];if(!S||S.next===S.prev)return F;var L,U,X,J,Z,tt,st;if(R&&(S=h(w,C,S,x)),w.length>80*x){L=X=w[0],U=J=w[1];for(var K=x;K<A;K+=x)Z=w[K],tt=w[K+1],Z<L&&(L=Z),tt<U&&(U=tt),Z>X&&(X=Z),tt>J&&(J=tt);st=Math.max(X-L,J-U),st=st!==0?32767/st:0}return i(S,F,x,L,U,st,0),F}function t(w,C,x,R,A){var S,F;if(A===W(w,C,x,R)>0)for(S=C;S<x;S+=R)F=D(S,w[S],w[S+1],F);else for(S=x-R;S>=C;S-=R)F=D(S,w[S],w[S+1],F);return F&&E(F,F.next)&&(O(F),F=F.next),F}function e(w,C){if(!w)return w;C||(C=w);var x=w,R;do if(R=!1,!x.steiner&&(E(x,x.next)||y(x.prev,x,x.next)===0)){if(O(x),x=C=x.prev,x===x.next)break;R=!0}else x=x.next;while(R||x!==C);return C}function i(w,C,x,R,A,S,F){if(w){!F&&S&&f(w,R,A,S);for(var L=w,U,X;w.prev!==w.next;){if(U=w.prev,X=w.next,S?n(w,R,A,S):r(w)){C.push(U.i/x|0),C.push(w.i/x|0),C.push(X.i/x|0),O(w),w=X.next,L=X.next;continue}if(w=X,w===L){F?F===1?(w=a(e(w),C,x),i(w,C,x,R,A,S,2)):F===2&&o(w,C,x,R,A,S):i(e(w),C,x,R,A,S,1);break}}}}function r(w){var C=w.prev,x=w,R=w.next;if(y(C,x,R)>=0)return!1;for(var A=C.x,S=x.x,F=R.x,L=C.y,U=x.y,X=R.y,J=A<S?A<F?A:F:S<F?S:F,Z=L<U?L<X?L:X:U<X?U:X,tt=A>S?A>F?A:F:S>F?S:F,st=L>U?L>X?L:X:U>X?U:X,K=R.next;K!==C;){if(K.x>=J&&K.x<=tt&&K.y>=Z&&K.y<=st&&_(A,L,S,U,F,X,K.x,K.y)&&y(K.prev,K,K.next)>=0)return!1;K=K.next}return!0}function n(w,C,x,R){var A=w.prev,S=w,F=w.next;if(y(A,S,F)>=0)return!1;for(var L=A.x,U=S.x,X=F.x,J=A.y,Z=S.y,tt=F.y,st=L<U?L<X?L:X:U<X?U:X,K=J<Z?J<tt?J:tt:Z<tt?Z:tt,ht=L>U?L>X?L:X:U>X?U:X,dt=J>Z?J>tt?J:tt:Z>tt?Z:tt,bt=g(st,K,C,x,R),_t=g(ht,dt,C,x,R),rt=w.prevZ,ct=w.nextZ;rt&&rt.z>=bt&&ct&&ct.z<=_t;){if(rt.x>=st&&rt.x<=ht&&rt.y>=K&&rt.y<=dt&&rt!==A&&rt!==F&&_(L,J,U,Z,X,tt,rt.x,rt.y)&&y(rt.prev,rt,rt.next)>=0||(rt=rt.prevZ,ct.x>=st&&ct.x<=ht&&ct.y>=K&&ct.y<=dt&&ct!==A&&ct!==F&&_(L,J,U,Z,X,tt,ct.x,ct.y)&&y(ct.prev,ct,ct.next)>=0))return!1;ct=ct.nextZ}for(;rt&&rt.z>=bt;){if(rt.x>=st&&rt.x<=ht&&rt.y>=K&&rt.y<=dt&&rt!==A&&rt!==F&&_(L,J,U,Z,X,tt,rt.x,rt.y)&&y(rt.prev,rt,rt.next)>=0)return!1;rt=rt.prevZ}for(;ct&&ct.z<=_t;){if(ct.x>=st&&ct.x<=ht&&ct.y>=K&&ct.y<=dt&&ct!==A&&ct!==F&&_(L,J,U,Z,X,tt,ct.x,ct.y)&&y(ct.prev,ct,ct.next)>=0)return!1;ct=ct.nextZ}return!0}function a(w,C,x){var R=w;do{var A=R.prev,S=R.next.next;!E(A,S)&&v(A,R,R.next,S)&&N(A,S)&&N(S,A)&&(C.push(A.i/x|0),C.push(R.i/x|0),C.push(S.i/x|0),O(R),O(R.next),R=w=S),R=R.next}while(R!==w);return e(R)}function o(w,C,x,R,A,S){var F=w;do{for(var L=F.next.next;L!==F.prev;){if(F.i!==L.i&&b(F,L)){var U=z(F,L);F=e(F,F.next),U=e(U,U.next),i(F,C,x,R,A,S,0),i(U,C,x,R,A,S,0);return}L=L.next}F=F.next}while(F!==w)}function h(w,C,x,R){var A=[],S,F,L,U,X;for(S=0,F=C.length;S<F;S++)L=C[S]*R,U=S<F-1?C[S+1]*R:w.length,X=t(w,L,U,R,!1),X===X.next&&(X.steiner=!0),A.push(m(X));for(A.sort(l),S=0;S<A.length;S++)x=u(A[S],x);return x}function l(w,C){return w.x-C.x}function u(w,C){var x=c(w,C);if(!x)return C;var R=z(x,w);return e(R,R.next),e(x,x.next)}function c(w,C){var x=C,R=w.x,A=w.y,S=-1/0,F;do{if(A<=x.y&&A>=x.next.y&&x.next.y!==x.y){var L=x.x+(A-x.y)*(x.next.x-x.x)/(x.next.y-x.y);if(L<=R&&L>S&&(S=L,F=x.x<x.next.x?x:x.next,L===R))return F}x=x.next}while(x!==C);if(!F)return null;var U=F,X=F.x,J=F.y,Z=1/0,tt;x=F;do R>=x.x&&x.x>=X&&R!==x.x&&_(A<J?R:S,A,X,J,A<J?S:R,A,x.x,x.y)&&(tt=Math.abs(A-x.y)/(R-x.x),N(x,w)&&(tt<Z||tt===Z&&(x.x>F.x||x.x===F.x&&d(F,x)))&&(F=x,Z=tt)),x=x.next;while(x!==U);return F}function d(w,C){return y(w.prev,w,C.prev)<0&&y(C.next,w,w.next)<0}function f(w,C,x,R){var A=w;do A.z===0&&(A.z=g(A.x,A.y,C,x,R)),A.prevZ=A.prev,A.nextZ=A.next,A=A.next;while(A!==w);A.prevZ.nextZ=null,A.prevZ=null,p(A)}function p(w){var C,x,R,A,S,F,L,U,X=1;do{for(x=w,w=null,S=null,F=0;x;){for(F++,R=x,L=0,C=0;C<X&&(L++,R=R.nextZ,!!R);C++);for(U=X;L>0||U>0&&R;)L!==0&&(U===0||!R||x.z<=R.z)?(A=x,x=x.nextZ,L--):(A=R,R=R.nextZ,U--),S?S.nextZ=A:w=A,A.prevZ=S,S=A;x=R}S.nextZ=null,X*=2}while(F>1);return w}function g(w,C,x,R,A){return w=(w-x)*A|0,C=(C-R)*A|0,w=(w|w<<8)&16711935,w=(w|w<<4)&252645135,w=(w|w<<2)&858993459,w=(w|w<<1)&1431655765,C=(C|C<<8)&16711935,C=(C|C<<4)&252645135,C=(C|C<<2)&858993459,C=(C|C<<1)&1431655765,w|C<<1}function m(w){var C=w,x=w;do(C.x<x.x||C.x===x.x&&C.y<x.y)&&(x=C),C=C.next;while(C!==w);return x}function _(w,C,x,R,A,S,F,L){return(A-F)*(C-L)>=(w-F)*(S-L)&&(w-F)*(R-L)>=(x-F)*(C-L)&&(x-F)*(S-L)>=(A-F)*(R-L)}function b(w,C){return w.next.i!==C.i&&w.prev.i!==C.i&&!P(w,C)&&(N(w,C)&&N(C,w)&&G(w,C)&&(y(w.prev,w,C.prev)||y(w,C.prev,C))||E(w,C)&&y(w.prev,w,w.next)>0&&y(C.prev,C,C.next)>0)}function y(w,C,x){return(C.y-w.y)*(x.x-C.x)-(C.x-w.x)*(x.y-C.y)}function E(w,C){return w.x===C.x&&w.y===C.y}function v(w,C,x,R){var A=T(y(w,C,x)),S=T(y(w,C,R)),F=T(y(x,R,w)),L=T(y(x,R,C));return!!(A!==S&&F!==L||A===0&&M(w,x,C)||S===0&&M(w,R,C)||F===0&&M(x,w,R)||L===0&&M(x,C,R))}function M(w,C,x){return C.x<=Math.max(w.x,x.x)&&C.x>=Math.min(w.x,x.x)&&C.y<=Math.max(w.y,x.y)&&C.y>=Math.min(w.y,x.y)}function T(w){return w>0?1:w<0?-1:0}function P(w,C){var x=w;do{if(x.i!==w.i&&x.next.i!==w.i&&x.i!==C.i&&x.next.i!==C.i&&v(x,x.next,w,C))return!0;x=x.next}while(x!==w);return!1}function N(w,C){return y(w.prev,w,w.next)<0?y(w,C,w.next)>=0&&y(w,w.prev,C)>=0:y(w,C,w.prev)<0||y(w,w.next,C)<0}function G(w,C){var x=w,R=!1,A=(w.x+C.x)/2,S=(w.y+C.y)/2;do x.y>S!=x.next.y>S&&x.next.y!==x.y&&A<(x.next.x-x.x)*(S-x.y)/(x.next.y-x.y)+x.x&&(R=!R),x=x.next;while(x!==w);return R}function z(w,C){var x=new V(w.i,w.x,w.y),R=new V(C.i,C.x,C.y),A=w.next,S=C.prev;return w.next=C,C.prev=w,x.next=A,A.prev=x,R.next=x,x.prev=R,S.next=R,R.prev=S,R}function D(w,C,x,R){var A=new V(w,C,x);return R?(A.next=R.next,A.prev=R,R.next.prev=A,R.next=A):(A.prev=A,A.next=A),A}function O(w){w.next.prev=w.prev,w.prev.next=w.next,w.prevZ&&(w.prevZ.nextZ=w.nextZ),w.nextZ&&(w.nextZ.prevZ=w.prevZ)}function V(w,C,x){this.i=w,this.x=C,this.y=x,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}s.deviation=function(w,C,x,R){var A=C&&C.length,S=A?C[0]*x:w.length,F=Math.abs(W(w,0,S,x));if(A)for(var L=0,U=C.length;L<U;L++){var X=C[L]*x,J=L<U-1?C[L+1]*x:w.length;F-=Math.abs(W(w,X,J,x))}var Z=0;for(L=0;L<R.length;L+=3){var tt=R[L]*x,st=R[L+1]*x,K=R[L+2]*x;Z+=Math.abs((w[tt]-w[K])*(w[st+1]-w[tt+1])-(w[tt]-w[st])*(w[K+1]-w[tt+1]))}return F===0&&Z===0?0:Math.abs((Z-F)/F)};function W(w,C,x,R){for(var A=0,S=C,F=x-R;S<x;S+=R)A+=(w[F]-w[S])*(w[S+1]+w[F+1]),F=S;return A}return s.flatten=function(w){for(var C=w[0][0].length,x={vertices:[],holes:[],dimensions:C},R=0,A=0;A<w.length;A++){for(var S=0;S<w[A].length;S++)for(var F=0;F<C;F++)x.vertices.push(w[A][S][F]);A>0&&(R+=w[A-1].length,x.holes.push(R))}return x},as.exports}var vf=yf();const Nh=Lh(vf);var ci={},nr={exports:{}};var xf=nr.exports,Uh;function bf(){return Uh||(Uh=1,function(s,t){(function(e){var i=t&&!t.nodeType&&t,r=s&&!s.nodeType&&s,n=typeof wn=="object"&&wn;(n.global===n||n.window===n||n.self===n)&&(e=n);var a,o=2147483647,h=36,l=1,u=26,c=38,d=700,f=72,p=128,g="-",m=/^xn--/,_=/[^\x20-\x7E]/,b=/[\x2E\u3002\uFF0E\uFF61]/g,y={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=h-l,v=Math.floor,M=String.fromCharCode,T;function P(A){throw new RangeError(y[A])}function N(A,S){for(var F=A.length,L=[];F--;)L[F]=S(A[F]);return L}function G(A,S){var F=A.split("@"),L="";F.length>1&&(L=F[0]+"@",A=F[1]),A=A.replace(b,".");var U=A.split("."),X=N(U,S).join(".");return L+X}function z(A){for(var S=[],F=0,L=A.length,U,X;F<L;)U=A.charCodeAt(F++),U>=55296&&U<=56319&&F<L?(X=A.charCodeAt(F++),(X&64512)==56320?S.push(((U&1023)<<10)+(X&1023)+65536):(S.push(U),F--)):S.push(U);return S}function D(A){return N(A,function(S){var F="";return S>65535&&(S-=65536,F+=M(S>>>10&1023|55296),S=56320|S&1023),F+=M(S),F}).join("")}function O(A){return A-48<10?A-22:A-65<26?A-65:A-97<26?A-97:h}function V(A,S){return A+22+75*(A<26)-((S!=0)<<5)}function W(A,S,F){var L=0;for(A=F?v(A/d):A>>1,A+=v(A/S);A>E*u>>1;L+=h)A=v(A/E);return v(L+(E+1)*A/(A+c))}function w(A){var S=[],F=A.length,L,U=0,X=p,J=f,Z,tt,st,K,ht,dt,bt,_t,rt;for(Z=A.lastIndexOf(g),Z<0&&(Z=0),tt=0;tt<Z;++tt)A.charCodeAt(tt)>=128&&P("not-basic"),S.push(A.charCodeAt(tt));for(st=Z>0?Z+1:0;st<F;){for(K=U,ht=1,dt=h;st>=F&&P("invalid-input"),bt=O(A.charCodeAt(st++)),(bt>=h||bt>v((o-U)/ht))&&P("overflow"),U+=bt*ht,_t=dt<=J?l:dt>=J+u?u:dt-J,!(bt<_t);dt+=h)rt=h-_t,ht>v(o/rt)&&P("overflow"),ht*=rt;L=S.length+1,J=W(U-K,L,K==0),v(U/L)>o-X&&P("overflow"),X+=v(U/L),U%=L,S.splice(U++,0,X)}return D(S)}function C(A){var S,F,L,U,X,J,Z,tt,st,K,ht,dt=[],bt,_t,rt,ct;for(A=z(A),bt=A.length,S=p,F=0,X=f,J=0;J<bt;++J)ht=A[J],ht<128&&dt.push(M(ht));for(L=U=dt.length,U&&dt.push(g);L<bt;){for(Z=o,J=0;J<bt;++J)ht=A[J],ht>=S&&ht<Z&&(Z=ht);for(_t=L+1,Z-S>v((o-F)/_t)&&P("overflow"),F+=(Z-S)*_t,S=Z,J=0;J<bt;++J)if(ht=A[J],ht<S&&++F>o&&P("overflow"),ht==S){for(tt=F,st=h;K=st<=X?l:st>=X+u?u:st-X,!(tt<K);st+=h)ct=tt-K,rt=h-K,dt.push(M(V(K+ct%rt,0))),tt=v(ct/rt);dt.push(M(V(tt,0))),X=W(F,_t,L==U),F=0,++L}++F,++S}return dt.join("")}function x(A){return G(A,function(S){return m.test(S)?w(S.slice(4).toLowerCase()):S})}function R(A){return G(A,function(S){return _.test(S)?"xn--"+C(S):S})}if(a={version:"1.4.1",ucs2:{decode:z,encode:D},decode:w,encode:C,toASCII:R,toUnicode:x},i&&r)if(s.exports==i)r.exports=a;else for(T in a)a.hasOwnProperty(T)&&(i[T]=a[T]);else e.punycode=a})(xf)}(nr,nr.exports)),nr.exports}var An,Gh;function Tf(){return Gh||(Gh=1,An=Error),An}var Sn,Vh;function Ef(){return Vh||(Vh=1,Sn=EvalError),Sn}var Pn,Hh;function wf(){return Hh||(Hh=1,Pn=RangeError),Pn}var Mn,Xh;function Cf(){return Xh||(Xh=1,Mn=ReferenceError),Mn}var In,zh;function Wh(){return zh||(zh=1,In=SyntaxError),In}var Rn,$h;function ar(){return $h||($h=1,Rn=TypeError),Rn}var Dn,jh;function Af(){return jh||(jh=1,Dn=URIError),Dn}var Fn,Yh;function Sf(){return Yh||(Yh=1,Fn=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),i=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var r=42;t[e]=r;for(e in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var n=Object.getOwnPropertySymbols(t);if(n.length!==1||n[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,e);if(a.value!==r||a.enumerable!==!0)return!1}return!0}),Fn}var Bn,qh;function Pf(){if(qh)return Bn;qh=1;var s=typeof Symbol<"u"&&Symbol,t=Sf();return Bn=function(){return typeof s!="function"||typeof Symbol!="function"||typeof s("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},Bn}var Ln,Kh;function Mf(){if(Kh)return Ln;Kh=1;var s={__proto__:null,foo:{}},t=Object;return Ln=function(){return{__proto__:s}.foo===s.foo&&!(s instanceof t)},Ln}var On,Zh;function If(){if(Zh)return On;Zh=1;var s="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,e=Math.max,i="[object Function]",r=function(h,l){for(var u=[],c=0;c<h.length;c+=1)u[c]=h[c];for(var d=0;d<l.length;d+=1)u[d+h.length]=l[d];return u},n=function(h,l){for(var u=[],c=l,d=0;c<h.length;c+=1,d+=1)u[d]=h[c];return u},a=function(o,h){for(var l="",u=0;u<o.length;u+=1)l+=o[u],u+1<o.length&&(l+=h);return l};return On=function(h){var l=this;if(typeof l!="function"||t.apply(l)!==i)throw new TypeError(s+l);for(var u=n(arguments,1),c,d=function(){if(this instanceof c){var _=l.apply(this,r(u,arguments));return Object(_)===_?_:this}return l.apply(h,r(u,arguments))},f=e(0,l.length-u.length),p=[],g=0;g<f;g++)p[g]="$"+g;if(c=Function("binder","return function ("+a(p,",")+"){ return binder.apply(this,arguments); }")(d),l.prototype){var m=function(){};m.prototype=l.prototype,c.prototype=new m,m.prototype=null}return c},On}var kn,Jh;function Nn(){if(Jh)return kn;Jh=1;var s=If();return kn=Function.prototype.bind||s,kn}var Un,Qh;function Rf(){if(Qh)return Un;Qh=1;var s=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=Nn();return Un=e.call(s,t),Un}var Gn,tl;function Ii(){if(tl)return Gn;tl=1;var s,t=Tf(),e=Ef(),i=wf(),r=Cf(),n=Wh(),a=ar(),o=Af(),h=Function,l=function(C){try{return h('"use strict"; return ('+C+").constructor;")()}catch{}},u=Object.getOwnPropertyDescriptor;if(u)try{u({},"")}catch{u=null}var c=function(){throw new a},d=u?function(){try{return arguments.callee,c}catch{try{return u(arguments,"callee").get}catch{return c}}}():c,f=Pf()(),p=Mf()(),g=Object.getPrototypeOf||(p?function(C){return C.__proto__}:null),m={},_=typeof Uint8Array>"u"||!g?s:g(Uint8Array),b={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?s:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?s:ArrayBuffer,"%ArrayIteratorPrototype%":f&&g?g([][Symbol.iterator]()):s,"%AsyncFromSyncIteratorPrototype%":s,"%AsyncFunction%":m,"%AsyncGenerator%":m,"%AsyncGeneratorFunction%":m,"%AsyncIteratorPrototype%":m,"%Atomics%":typeof Atomics>"u"?s:Atomics,"%BigInt%":typeof BigInt>"u"?s:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?s:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?s:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?s:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":t,"%eval%":eval,"%EvalError%":e,"%Float32Array%":typeof Float32Array>"u"?s:Float32Array,"%Float64Array%":typeof Float64Array>"u"?s:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?s:FinalizationRegistry,"%Function%":h,"%GeneratorFunction%":m,"%Int8Array%":typeof Int8Array>"u"?s:Int8Array,"%Int16Array%":typeof Int16Array>"u"?s:Int16Array,"%Int32Array%":typeof Int32Array>"u"?s:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":f&&g?g(g([][Symbol.iterator]())):s,"%JSON%":typeof JSON=="object"?JSON:s,"%Map%":typeof Map>"u"?s:Map,"%MapIteratorPrototype%":typeof Map>"u"||!f||!g?s:g(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?s:Promise,"%Proxy%":typeof Proxy>"u"?s:Proxy,"%RangeError%":i,"%ReferenceError%":r,"%Reflect%":typeof Reflect>"u"?s:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?s:Set,"%SetIteratorPrototype%":typeof Set>"u"||!f||!g?s:g(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?s:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":f&&g?g(""[Symbol.iterator]()):s,"%Symbol%":f?Symbol:s,"%SyntaxError%":n,"%ThrowTypeError%":d,"%TypedArray%":_,"%TypeError%":a,"%Uint8Array%":typeof Uint8Array>"u"?s:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?s:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?s:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?s:Uint32Array,"%URIError%":o,"%WeakMap%":typeof WeakMap>"u"?s:WeakMap,"%WeakRef%":typeof WeakRef>"u"?s:WeakRef,"%WeakSet%":typeof WeakSet>"u"?s:WeakSet};if(g)try{null.error}catch(C){var y=g(g(C));b["%Error.prototype%"]=y}var E=function C(x){var R;if(x==="%AsyncFunction%")R=l("async function () {}");else if(x==="%GeneratorFunction%")R=l("function* () {}");else if(x==="%AsyncGeneratorFunction%")R=l("async function* () {}");else if(x==="%AsyncGenerator%"){var A=C("%AsyncGeneratorFunction%");A&&(R=A.prototype)}else if(x==="%AsyncIteratorPrototype%"){var S=C("%AsyncGenerator%");S&&g&&(R=g(S.prototype))}return b[x]=R,R},v={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},M=Nn(),T=Rf(),P=M.call(Function.call,Array.prototype.concat),N=M.call(Function.apply,Array.prototype.splice),G=M.call(Function.call,String.prototype.replace),z=M.call(Function.call,String.prototype.slice),D=M.call(Function.call,RegExp.prototype.exec),O=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,V=/\\(\\)?/g,W=function(x){var R=z(x,0,1),A=z(x,-1);if(R==="%"&&A!=="%")throw new n("invalid intrinsic syntax, expected closing `%`");if(A==="%"&&R!=="%")throw new n("invalid intrinsic syntax, expected opening `%`");var S=[];return G(x,O,function(F,L,U,X){S[S.length]=U?G(X,V,"$1"):L||F}),S},w=function(x,R){var A=x,S;if(T(v,A)&&(S=v[A],A="%"+S[0]+"%"),T(b,A)){var F=b[A];if(F===m&&(F=E(A)),typeof F>"u"&&!R)throw new a("intrinsic "+x+" exists, but is not available. Please file an issue!");return{alias:S,name:A,value:F}}throw new n("intrinsic "+x+" does not exist!")};return Gn=function(x,R){if(typeof x!="string"||x.length===0)throw new a("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof R!="boolean")throw new a('"allowMissing" argument must be a boolean');if(D(/^%?[^%]*%?$/,x)===null)throw new n("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var A=W(x),S=A.length>0?A[0]:"",F=w("%"+S+"%",R),L=F.name,U=F.value,X=!1,J=F.alias;J&&(S=J[0],N(A,P([0,1],J)));for(var Z=1,tt=!0;Z<A.length;Z+=1){var st=A[Z],K=z(st,0,1),ht=z(st,-1);if((K==='"'||K==="'"||K==="`"||ht==='"'||ht==="'"||ht==="`")&&K!==ht)throw new n("property names with quotes must have matching quotes");if((st==="constructor"||!tt)&&(X=!0),S+="."+st,L="%"+S+"%",T(b,L))U=b[L];else if(U!=null){if(!(st in U)){if(!R)throw new a("base intrinsic for "+x+" exists, but the property is not available.");return}if(u&&Z+1>=A.length){var dt=u(U,st);tt=!!dt,tt&&"get"in dt&&!("originalValue"in dt.get)?U=dt.get:U=U[st]}else tt=T(U,st),U=U[st];tt&&!X&&(b[L]=U)}}return U},Gn}var Vn={exports:{}},Hn,el;function Xn(){if(el)return Hn;el=1;var s=Ii(),t=s("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return Hn=t,Hn}var zn,il;function rl(){if(il)return zn;il=1;var s=Ii(),t=s("%Object.getOwnPropertyDescriptor%",!0);if(t)try{t([],"length")}catch{t=null}return zn=t,zn}var Wn,sl;function Df(){if(sl)return Wn;sl=1;var s=Xn(),t=Wh(),e=ar(),i=rl();return Wn=function(n,a,o){if(!n||typeof n!="object"&&typeof n!="function")throw new e("`obj` must be an object or a function`");if(typeof a!="string"&&typeof a!="symbol")throw new e("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new e("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new e("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new e("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new e("`loose`, if provided, must be a boolean");var h=arguments.length>3?arguments[3]:null,l=arguments.length>4?arguments[4]:null,u=arguments.length>5?arguments[5]:null,c=arguments.length>6?arguments[6]:!1,d=!!i&&i(n,a);if(s)s(n,a,{configurable:u===null&&d?d.configurable:!u,enumerable:h===null&&d?d.enumerable:!h,value:o,writable:l===null&&d?d.writable:!l});else if(c||!h&&!l&&!u)n[a]=o;else throw new t("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Wn}var $n,nl;function Ff(){if(nl)return $n;nl=1;var s=Xn(),t=function(){return!!s};return t.hasArrayLengthDefineBug=function(){if(!s)return null;try{return s([],"length",{value:1}).length!==1}catch{return!0}},$n=t,$n}var jn,al;function Bf(){if(al)return jn;al=1;var s=Ii(),t=Df(),e=Ff()(),i=rl(),r=ar(),n=s("%Math.floor%");return jn=function(o,h){if(typeof o!="function")throw new r("`fn` is not a function");if(typeof h!="number"||h<0||h>4294967295||n(h)!==h)throw new r("`length` must be a positive 32-bit integer");var l=arguments.length>2&&!!arguments[2],u=!0,c=!0;if("length"in o&&i){var d=i(o,"length");d&&!d.configurable&&(u=!1),d&&!d.writable&&(c=!1)}return(u||c||!l)&&(e?t(o,"length",h,!0,!0):t(o,"length",h)),o},jn}var ol;function Lf(){return ol||(ol=1,function(s){var t=Nn(),e=Ii(),i=Bf(),r=ar(),n=e("%Function.prototype.apply%"),a=e("%Function.prototype.call%"),o=e("%Reflect.apply%",!0)||t.call(a,n),h=Xn(),l=e("%Math.max%");s.exports=function(d){if(typeof d!="function")throw new r("a function is required");var f=o(t,a,arguments);return i(f,1+l(0,d.length-(arguments.length-1)),!0)};var u=function(){return o(t,n,arguments)};h?h(s.exports,"apply",{value:u}):s.exports.apply=u}(Vn)),Vn.exports}var Yn,hl;function Of(){if(hl)return Yn;hl=1;var s=Ii(),t=Lf(),e=t(s("String.prototype.indexOf"));return Yn=function(r,n){var a=s(r,!!n);return typeof a=="function"&&e(r,".prototype.")>-1?t(a):a},Yn}const kf=mf(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var qn,ll;function Nf(){if(ll)return qn;ll=1;var s=typeof Map=="function"&&Map.prototype,t=Object.getOwnPropertyDescriptor&&s?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,e=s&&t&&typeof t.get=="function"?t.get:null,i=s&&Map.prototype.forEach,r=typeof Set=="function"&&Set.prototype,n=Object.getOwnPropertyDescriptor&&r?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,a=r&&n&&typeof n.get=="function"?n.get:null,o=r&&Set.prototype.forEach,h=typeof WeakMap=="function"&&WeakMap.prototype,l=h?WeakMap.prototype.has:null,u=typeof WeakSet=="function"&&WeakSet.prototype,c=u?WeakSet.prototype.has:null,d=typeof WeakRef=="function"&&WeakRef.prototype,f=d?WeakRef.prototype.deref:null,p=Boolean.prototype.valueOf,g=Object.prototype.toString,m=Function.prototype.toString,_=String.prototype.match,b=String.prototype.slice,y=String.prototype.replace,E=String.prototype.toUpperCase,v=String.prototype.toLowerCase,M=RegExp.prototype.test,T=Array.prototype.concat,P=Array.prototype.join,N=Array.prototype.slice,G=Math.floor,z=typeof BigInt=="function"?BigInt.prototype.valueOf:null,D=Object.getOwnPropertySymbols,O=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,V=typeof Symbol=="function"&&typeof Symbol.iterator=="object",W=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===V||!0)?Symbol.toStringTag:null,w=Object.prototype.propertyIsEnumerable,C=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(B){return B.__proto__}:null);function x(B,k){if(B===1/0||B===-1/0||B!==B||B&&B>-1e3&&B<1e3||M.call(/e/,k))return k;var yt=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof B=="number"){var Tt=B<0?-G(-B):G(B);if(Tt!==B){var Mt=String(Tt),pt=b.call(k,Mt.length+1);return y.call(Mt,yt,"$&_")+"."+y.call(y.call(pt,/([0-9]{3})/g,"$&_"),/_$/,"")}}return y.call(k,yt,"$&_")}var R=kf,A=R.custom,S=ht(A)?A:null;qn=function B(k,yt,Tt,Mt){var pt=yt||{};if(_t(pt,"quoteStyle")&&pt.quoteStyle!=="single"&&pt.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(_t(pt,"maxStringLength")&&(typeof pt.maxStringLength=="number"?pt.maxStringLength<0&&pt.maxStringLength!==1/0:pt.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var hi=_t(pt,"customInspect")?pt.customInspect:!0;if(typeof hi!="boolean"&&hi!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(_t(pt,"indent")&&pt.indent!==null&&pt.indent!==" "&&!(parseInt(pt.indent,10)===pt.indent&&pt.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(_t(pt,"numericSeparator")&&typeof pt.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var Pi=pt.numericSeparator;if(typeof k>"u")return"undefined";if(k===null)return"null";if(typeof k=="boolean")return k?"true":"false";if(typeof k=="string")return Jd(k,pt);if(typeof k=="number"){if(k===0)return 1/0/k>0?"0":"-0";var qt=String(k);return Pi?x(k,qt):qt}if(typeof k=="bigint"){var li=String(k)+"n";return Pi?x(k,li):li}var nh=typeof pt.depth>"u"?5:pt.depth;if(typeof Tt>"u"&&(Tt=0),Tt>=nh&&nh>0&&typeof k=="object")return U(k)?"[Array]":"[Object]";var Ji=bv(pt,Tt);if(typeof Mt>"u")Mt=[];else if(Ye(Mt,k)>=0)return"[Circular]";function ve(Qi,fn,Ev){if(fn&&(Mt=N.call(Mt),Mt.push(fn)),Ev){var hf={depth:pt.depth};return _t(pt,"quoteStyle")&&(hf.quoteStyle=pt.quoteStyle),B(Qi,hf,Tt+1,Mt)}return B(Qi,pt,Tt+1,Mt)}if(typeof k=="function"&&!J(k)){var tf=ct(k),ef=cn(k,ve);return"[Function"+(tf?": "+tf:" (anonymous)")+"]"+(ef.length>0?" { "+P.call(ef,", ")+" }":"")}if(ht(k)){var rf=V?y.call(String(k),/^(Symbol\(.*\))_[^)]*$/,"$1"):O.call(k);return typeof k=="object"&&!V?Kr(rf):rf}if(yv(k)){for(var Zr="<"+v.call(String(k.nodeName)),ah=k.attributes||[],dn=0;dn<ah.length;dn++)Zr+=" "+ah[dn].name+"="+F(L(ah[dn].value),"double",pt);return Zr+=">",k.childNodes&&k.childNodes.length&&(Zr+="..."),Zr+="</"+v.call(String(k.nodeName))+">",Zr}if(U(k)){if(k.length===0)return"[]";var oh=cn(k,ve);return Ji&&!xv(oh)?"["+sh(oh,Ji)+"]":"[ "+P.call(oh,", ")+" ]"}if(Z(k)){var hh=cn(k,ve);return!("cause"in Error.prototype)&&"cause"in k&&!w.call(k,"cause")?"{ ["+String(k)+"] "+P.call(T.call("[cause]: "+ve(k.cause),hh),", ")+" }":hh.length===0?"["+String(k)+"]":"{ ["+String(k)+"] "+P.call(hh,", ")+" }"}if(typeof k=="object"&&hi){if(S&&typeof k[S]=="function"&&R)return R(k,{depth:nh-Tt});if(hi!=="symbol"&&typeof k.inspect=="function")return k.inspect()}if(oi(k)){var sf=[];return i&&i.call(k,function(Qi,fn){sf.push(ve(fn,k,!0)+" => "+ve(Qi,k))}),Qd("Map",e.call(k),sf,Ji)}if(gv(k)){var nf=[];return o&&o.call(k,function(Qi){nf.push(ve(Qi,k))}),Qd("Set",a.call(k),nf,Ji)}if(pv(k))return rh("WeakMap");if(_v(k))return rh("WeakSet");if(mv(k))return rh("WeakRef");if(st(k))return Kr(ve(Number(k)));if(dt(k))return Kr(ve(z.call(k)));if(K(k))return Kr(p.call(k));if(tt(k))return Kr(ve(String(k)));if(typeof window<"u"&&k===window)return"{ [object Window] }";if(k===wn)return"{ [object globalThis] }";if(!X(k)&&!J(k)){var lh=cn(k,ve),af=C?C(k)===Object.prototype:k instanceof Object||k.constructor===Object,uh=k instanceof Object?"":"null prototype",of=!af&&W&&Object(k)===k&&W in k?b.call(rt(k),8,-1):uh?"Object":"",Tv=af||typeof k.constructor!="function"?"":k.constructor.name?k.constructor.name+" ":"",ch=Tv+(of||uh?"["+P.call(T.call([],of||[],uh||[]),": ")+"] ":"");return lh.length===0?ch+"{}":Ji?ch+"{"+sh(lh,Ji)+"}":ch+"{ "+P.call(lh,", ")+" }"}return String(k)};function F(B,k,yt){var Tt=(yt.quoteStyle||k)==="double"?'"':"'";return Tt+B+Tt}function L(B){return y.call(String(B),/"/g,"&quot;")}function U(B){return rt(B)==="[object Array]"&&(!W||!(typeof B=="object"&&W in B))}function X(B){return rt(B)==="[object Date]"&&(!W||!(typeof B=="object"&&W in B))}function J(B){return rt(B)==="[object RegExp]"&&(!W||!(typeof B=="object"&&W in B))}function Z(B){return rt(B)==="[object Error]"&&(!W||!(typeof B=="object"&&W in B))}function tt(B){return rt(B)==="[object String]"&&(!W||!(typeof B=="object"&&W in B))}function st(B){return rt(B)==="[object Number]"&&(!W||!(typeof B=="object"&&W in B))}function K(B){return rt(B)==="[object Boolean]"&&(!W||!(typeof B=="object"&&W in B))}function ht(B){if(V)return B&&typeof B=="object"&&B instanceof Symbol;if(typeof B=="symbol")return!0;if(!B||typeof B!="object"||!O)return!1;try{return O.call(B),!0}catch{}return!1}function dt(B){if(!B||typeof B!="object"||!z)return!1;try{return z.call(B),!0}catch{}return!1}var bt=Object.prototype.hasOwnProperty||function(B){return B in this};function _t(B,k){return bt.call(B,k)}function rt(B){return g.call(B)}function ct(B){if(B.name)return B.name;var k=_.call(m.call(B),/^function\s*([\w$]+)/);return k?k[1]:null}function Ye(B,k){if(B.indexOf)return B.indexOf(k);for(var yt=0,Tt=B.length;yt<Tt;yt++)if(B[yt]===k)return yt;return-1}function oi(B){if(!e||!B||typeof B!="object")return!1;try{e.call(B);try{a.call(B)}catch{return!0}return B instanceof Map}catch{}return!1}function pv(B){if(!l||!B||typeof B!="object")return!1;try{l.call(B,l);try{c.call(B,c)}catch{return!0}return B instanceof WeakMap}catch{}return!1}function mv(B){if(!f||!B||typeof B!="object")return!1;try{return f.call(B),!0}catch{}return!1}function gv(B){if(!a||!B||typeof B!="object")return!1;try{a.call(B);try{e.call(B)}catch{return!0}return B instanceof Set}catch{}return!1}function _v(B){if(!c||!B||typeof B!="object")return!1;try{c.call(B,c);try{l.call(B,l)}catch{return!0}return B instanceof WeakSet}catch{}return!1}function yv(B){return!B||typeof B!="object"?!1:typeof HTMLElement<"u"&&B instanceof HTMLElement?!0:typeof B.nodeName=="string"&&typeof B.getAttribute=="function"}function Jd(B,k){if(B.length>k.maxStringLength){var yt=B.length-k.maxStringLength,Tt="... "+yt+" more character"+(yt>1?"s":"");return Jd(b.call(B,0,k.maxStringLength),k)+Tt}var Mt=y.call(y.call(B,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,vv);return F(Mt,"single",k)}function vv(B){var k=B.charCodeAt(0),yt={8:"b",9:"t",10:"n",12:"f",13:"r"}[k];return yt?"\\"+yt:"\\x"+(k<16?"0":"")+E.call(k.toString(16))}function Kr(B){return"Object("+B+")"}function rh(B){return B+" { ? }"}function Qd(B,k,yt,Tt){var Mt=Tt?sh(yt,Tt):P.call(yt,", ");return B+" ("+k+") {"+Mt+"}"}function xv(B){for(var k=0;k<B.length;k++)if(Ye(B[k],`
2
+ `)>=0)return!1;return!0}function bv(B,k){var yt;if(B.indent===" ")yt=" ";else if(typeof B.indent=="number"&&B.indent>0)yt=P.call(Array(B.indent+1)," ");else return null;return{base:yt,prev:P.call(Array(k+1),yt)}}function sh(B,k){if(B.length===0)return"";var yt=`
3
+ `+k.prev+k.base;return yt+P.call(B,","+yt)+`
4
+ `+k.prev}function cn(B,k){var yt=U(B),Tt=[];if(yt){Tt.length=B.length;for(var Mt=0;Mt<B.length;Mt++)Tt[Mt]=_t(B,Mt)?k(B[Mt],B):""}var pt=typeof D=="function"?D(B):[],hi;if(V){hi={};for(var Pi=0;Pi<pt.length;Pi++)hi["$"+pt[Pi]]=pt[Pi]}for(var qt in B)_t(B,qt)&&(yt&&String(Number(qt))===qt&&qt<B.length||V&&hi["$"+qt]instanceof Symbol||(M.call(/[^\w$]/,qt)?Tt.push(k(qt,B)+": "+k(B[qt],B)):Tt.push(qt+": "+k(B[qt],B))));if(typeof D=="function")for(var li=0;li<pt.length;li++)w.call(B,pt[li])&&Tt.push("["+k(pt[li])+"]: "+k(B[pt[li]],B));return Tt}return qn}var Kn,ul;function Uf(){if(ul)return Kn;ul=1;var s=Ii(),t=Of(),e=Nf(),i=ar(),r=s("%WeakMap%",!0),n=s("%Map%",!0),a=t("WeakMap.prototype.get",!0),o=t("WeakMap.prototype.set",!0),h=t("WeakMap.prototype.has",!0),l=t("Map.prototype.get",!0),u=t("Map.prototype.set",!0),c=t("Map.prototype.has",!0),d=function(m,_){for(var b=m,y;(y=b.next)!==null;b=y)if(y.key===_)return b.next=y.next,y.next=m.next,m.next=y,y},f=function(m,_){var b=d(m,_);return b&&b.value},p=function(m,_,b){var y=d(m,_);y?y.value=b:m.next={key:_,next:m.next,value:b}},g=function(m,_){return!!d(m,_)};return Kn=function(){var _,b,y,E={assert:function(v){if(!E.has(v))throw new i("Side channel does not contain "+e(v))},get:function(v){if(r&&v&&(typeof v=="object"||typeof v=="function")){if(_)return a(_,v)}else if(n){if(b)return l(b,v)}else if(y)return f(y,v)},has:function(v){if(r&&v&&(typeof v=="object"||typeof v=="function")){if(_)return h(_,v)}else if(n){if(b)return c(b,v)}else if(y)return g(y,v);return!1},set:function(v,M){r&&v&&(typeof v=="object"||typeof v=="function")?(_||(_=new r),o(_,v,M)):n?(b||(b=new n),u(b,v,M)):(y||(y={key:{},next:null}),p(y,v,M))}};return E},Kn}var Zn,cl;function Jn(){if(cl)return Zn;cl=1;var s=String.prototype.replace,t=/%20/g,e={RFC1738:"RFC1738",RFC3986:"RFC3986"};return Zn={default:e.RFC3986,formatters:{RFC1738:function(i){return s.call(i,t,"+")},RFC3986:function(i){return String(i)}},RFC1738:e.RFC1738,RFC3986:e.RFC3986},Zn}var Qn,dl;function fl(){if(dl)return Qn;dl=1;var s=Jn(),t=Object.prototype.hasOwnProperty,e=Array.isArray,i=function(){for(var m=[],_=0;_<256;++_)m.push("%"+((_<16?"0":"")+_.toString(16)).toUpperCase());return m}(),r=function(_){for(;_.length>1;){var b=_.pop(),y=b.obj[b.prop];if(e(y)){for(var E=[],v=0;v<y.length;++v)typeof y[v]<"u"&&E.push(y[v]);b.obj[b.prop]=E}}},n=function(_,b){for(var y=b&&b.plainObjects?Object.create(null):{},E=0;E<_.length;++E)typeof _[E]<"u"&&(y[E]=_[E]);return y},a=function m(_,b,y){if(!b)return _;if(typeof b!="object"){if(e(_))_.push(b);else if(_&&typeof _=="object")(y&&(y.plainObjects||y.allowPrototypes)||!t.call(Object.prototype,b))&&(_[b]=!0);else return[_,b];return _}if(!_||typeof _!="object")return[_].concat(b);var E=_;return e(_)&&!e(b)&&(E=n(_,y)),e(_)&&e(b)?(b.forEach(function(v,M){if(t.call(_,M)){var T=_[M];T&&typeof T=="object"&&v&&typeof v=="object"?_[M]=m(T,v,y):_.push(v)}else _[M]=v}),_):Object.keys(b).reduce(function(v,M){var T=b[M];return t.call(v,M)?v[M]=m(v[M],T,y):v[M]=T,v},E)},o=function(_,b){return Object.keys(b).reduce(function(y,E){return y[E]=b[E],y},_)},h=function(m,_,b){var y=m.replace(/\+/g," ");if(b==="iso-8859-1")return y.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(y)}catch{return y}},l=1024,u=function(_,b,y,E,v){if(_.length===0)return _;var M=_;if(typeof _=="symbol"?M=Symbol.prototype.toString.call(_):typeof _!="string"&&(M=String(_)),y==="iso-8859-1")return escape(M).replace(/%u[0-9a-f]{4}/gi,function(O){return"%26%23"+parseInt(O.slice(2),16)+"%3B"});for(var T="",P=0;P<M.length;P+=l){for(var N=M.length>=l?M.slice(P,P+l):M,G=[],z=0;z<N.length;++z){var D=N.charCodeAt(z);if(D===45||D===46||D===95||D===126||D>=48&&D<=57||D>=65&&D<=90||D>=97&&D<=122||v===s.RFC1738&&(D===40||D===41)){G[G.length]=N.charAt(z);continue}if(D<128){G[G.length]=i[D];continue}if(D<2048){G[G.length]=i[192|D>>6]+i[128|D&63];continue}if(D<55296||D>=57344){G[G.length]=i[224|D>>12]+i[128|D>>6&63]+i[128|D&63];continue}z+=1,D=65536+((D&1023)<<10|N.charCodeAt(z)&1023),G[G.length]=i[240|D>>18]+i[128|D>>12&63]+i[128|D>>6&63]+i[128|D&63]}T+=G.join("")}return T},c=function(_){for(var b=[{obj:{o:_},prop:"o"}],y=[],E=0;E<b.length;++E)for(var v=b[E],M=v.obj[v.prop],T=Object.keys(M),P=0;P<T.length;++P){var N=T[P],G=M[N];typeof G=="object"&&G!==null&&y.indexOf(G)===-1&&(b.push({obj:M,prop:N}),y.push(G))}return r(b),_},d=function(_){return Object.prototype.toString.call(_)==="[object RegExp]"},f=function(_){return!_||typeof _!="object"?!1:!!(_.constructor&&_.constructor.isBuffer&&_.constructor.isBuffer(_))},p=function(_,b){return[].concat(_,b)},g=function(_,b){if(e(_)){for(var y=[],E=0;E<_.length;E+=1)y.push(b(_[E]));return y}return b(_)};return Qn={arrayToObject:n,assign:o,combine:p,compact:c,decode:h,encode:u,isBuffer:f,isRegExp:d,maybeMap:g,merge:a},Qn}var ta,pl;function Gf(){if(pl)return ta;pl=1;var s=Uf(),t=fl(),e=Jn(),i=Object.prototype.hasOwnProperty,r={brackets:function(m){return m+"[]"},comma:"comma",indices:function(m,_){return m+"["+_+"]"},repeat:function(m){return m}},n=Array.isArray,a=Array.prototype.push,o=function(g,m){a.apply(g,n(m)?m:[m])},h=Date.prototype.toISOString,l=e.default,u={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:t.encode,encodeValuesOnly:!1,format:l,formatter:e.formatters[l],indices:!1,serializeDate:function(m){return h.call(m)},skipNulls:!1,strictNullHandling:!1},c=function(m){return typeof m=="string"||typeof m=="number"||typeof m=="boolean"||typeof m=="symbol"||typeof m=="bigint"},d={},f=function g(m,_,b,y,E,v,M,T,P,N,G,z,D,O,V,W,w,C){for(var x=m,R=C,A=0,S=!1;(R=R.get(d))!==void 0&&!S;){var F=R.get(m);if(A+=1,typeof F<"u"){if(F===A)throw new RangeError("Cyclic object value");S=!0}typeof R.get(d)>"u"&&(A=0)}if(typeof N=="function"?x=N(_,x):x instanceof Date?x=D(x):b==="comma"&&n(x)&&(x=t.maybeMap(x,function(rt){return rt instanceof Date?D(rt):rt})),x===null){if(v)return P&&!W?P(_,u.encoder,w,"key",O):_;x=""}if(c(x)||t.isBuffer(x)){if(P){var L=W?_:P(_,u.encoder,w,"key",O);return[V(L)+"="+V(P(x,u.encoder,w,"value",O))]}return[V(_)+"="+V(String(x))]}var U=[];if(typeof x>"u")return U;var X;if(b==="comma"&&n(x))W&&P&&(x=t.maybeMap(x,P)),X=[{value:x.length>0?x.join(",")||null:void 0}];else if(n(N))X=N;else{var J=Object.keys(x);X=G?J.sort(G):J}var Z=T?_.replace(/\./g,"%2E"):_,tt=y&&n(x)&&x.length===1?Z+"[]":Z;if(E&&n(x)&&x.length===0)return tt+"[]";for(var st=0;st<X.length;++st){var K=X[st],ht=typeof K=="object"&&typeof K.value<"u"?K.value:x[K];if(!(M&&ht===null)){var dt=z&&T?K.replace(/\./g,"%2E"):K,bt=n(x)?typeof b=="function"?b(tt,dt):tt:tt+(z?"."+dt:"["+dt+"]");C.set(m,A);var _t=s();_t.set(d,C),o(U,g(ht,bt,b,y,E,v,M,T,b==="comma"&&W&&n(x)?null:P,N,G,z,D,O,V,W,w,_t))}}return U},p=function(m){if(!m)return u;if(typeof m.allowEmptyArrays<"u"&&typeof m.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof m.encodeDotInKeys<"u"&&typeof m.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(m.encoder!==null&&typeof m.encoder<"u"&&typeof m.encoder!="function")throw new TypeError("Encoder has to be a function.");var _=m.charset||u.charset;if(typeof m.charset<"u"&&m.charset!=="utf-8"&&m.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var b=e.default;if(typeof m.format<"u"){if(!i.call(e.formatters,m.format))throw new TypeError("Unknown format option provided.");b=m.format}var y=e.formatters[b],E=u.filter;(typeof m.filter=="function"||n(m.filter))&&(E=m.filter);var v;if(m.arrayFormat in r?v=m.arrayFormat:"indices"in m?v=m.indices?"indices":"repeat":v=u.arrayFormat,"commaRoundTrip"in m&&typeof m.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var M=typeof m.allowDots>"u"?m.encodeDotInKeys===!0?!0:u.allowDots:!!m.allowDots;return{addQueryPrefix:typeof m.addQueryPrefix=="boolean"?m.addQueryPrefix:u.addQueryPrefix,allowDots:M,allowEmptyArrays:typeof m.allowEmptyArrays=="boolean"?!!m.allowEmptyArrays:u.allowEmptyArrays,arrayFormat:v,charset:_,charsetSentinel:typeof m.charsetSentinel=="boolean"?m.charsetSentinel:u.charsetSentinel,commaRoundTrip:m.commaRoundTrip,delimiter:typeof m.delimiter>"u"?u.delimiter:m.delimiter,encode:typeof m.encode=="boolean"?m.encode:u.encode,encodeDotInKeys:typeof m.encodeDotInKeys=="boolean"?m.encodeDotInKeys:u.encodeDotInKeys,encoder:typeof m.encoder=="function"?m.encoder:u.encoder,encodeValuesOnly:typeof m.encodeValuesOnly=="boolean"?m.encodeValuesOnly:u.encodeValuesOnly,filter:E,format:b,formatter:y,serializeDate:typeof m.serializeDate=="function"?m.serializeDate:u.serializeDate,skipNulls:typeof m.skipNulls=="boolean"?m.skipNulls:u.skipNulls,sort:typeof m.sort=="function"?m.sort:null,strictNullHandling:typeof m.strictNullHandling=="boolean"?m.strictNullHandling:u.strictNullHandling}};return ta=function(g,m){var _=g,b=p(m),y,E;typeof b.filter=="function"?(E=b.filter,_=E("",_)):n(b.filter)&&(E=b.filter,y=E);var v=[];if(typeof _!="object"||_===null)return"";var M=r[b.arrayFormat],T=M==="comma"&&b.commaRoundTrip;y||(y=Object.keys(_)),b.sort&&y.sort(b.sort);for(var P=s(),N=0;N<y.length;++N){var G=y[N];b.skipNulls&&_[G]===null||o(v,f(_[G],G,M,T,b.allowEmptyArrays,b.strictNullHandling,b.skipNulls,b.encodeDotInKeys,b.encode?b.encoder:null,b.filter,b.sort,b.allowDots,b.serializeDate,b.format,b.formatter,b.encodeValuesOnly,b.charset,P))}var z=v.join(b.delimiter),D=b.addQueryPrefix===!0?"?":"";return b.charsetSentinel&&(b.charset==="iso-8859-1"?D+="utf8=%26%2310003%3B&":D+="utf8=%E2%9C%93&"),z.length>0?D+z:""},ta}var ea,ml;function Vf(){if(ml)return ea;ml=1;var s=fl(),t=Object.prototype.hasOwnProperty,e=Array.isArray,i={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:s.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1},r=function(d){return d.replace(/&#(\d+);/g,function(f,p){return String.fromCharCode(parseInt(p,10))})},n=function(d,f){return d&&typeof d=="string"&&f.comma&&d.indexOf(",")>-1?d.split(","):d},a="utf8=%26%2310003%3B",o="utf8=%E2%9C%93",h=function(f,p){var g={__proto__:null},m=p.ignoreQueryPrefix?f.replace(/^\?/,""):f;m=m.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var _=p.parameterLimit===1/0?void 0:p.parameterLimit,b=m.split(p.delimiter,_),y=-1,E,v=p.charset;if(p.charsetSentinel)for(E=0;E<b.length;++E)b[E].indexOf("utf8=")===0&&(b[E]===o?v="utf-8":b[E]===a&&(v="iso-8859-1"),y=E,E=b.length);for(E=0;E<b.length;++E)if(E!==y){var M=b[E],T=M.indexOf("]="),P=T===-1?M.indexOf("="):T+1,N,G;P===-1?(N=p.decoder(M,i.decoder,v,"key"),G=p.strictNullHandling?null:""):(N=p.decoder(M.slice(0,P),i.decoder,v,"key"),G=s.maybeMap(n(M.slice(P+1),p),function(D){return p.decoder(D,i.decoder,v,"value")})),G&&p.interpretNumericEntities&&v==="iso-8859-1"&&(G=r(G)),M.indexOf("[]=")>-1&&(G=e(G)?[G]:G);var z=t.call(g,N);z&&p.duplicates==="combine"?g[N]=s.combine(g[N],G):(!z||p.duplicates==="last")&&(g[N]=G)}return g},l=function(d,f,p,g){for(var m=g?f:n(f,p),_=d.length-1;_>=0;--_){var b,y=d[_];if(y==="[]"&&p.parseArrays)b=p.allowEmptyArrays&&(m===""||p.strictNullHandling&&m===null)?[]:[].concat(m);else{b=p.plainObjects?Object.create(null):{};var E=y.charAt(0)==="["&&y.charAt(y.length-1)==="]"?y.slice(1,-1):y,v=p.decodeDotInKeys?E.replace(/%2E/g,"."):E,M=parseInt(v,10);!p.parseArrays&&v===""?b={0:m}:!isNaN(M)&&y!==v&&String(M)===v&&M>=0&&p.parseArrays&&M<=p.arrayLimit?(b=[],b[M]=m):v!=="__proto__"&&(b[v]=m)}m=b}return m},u=function(f,p,g,m){if(f){var _=g.allowDots?f.replace(/\.([^.[]+)/g,"[$1]"):f,b=/(\[[^[\]]*])/,y=/(\[[^[\]]*])/g,E=g.depth>0&&b.exec(_),v=E?_.slice(0,E.index):_,M=[];if(v){if(!g.plainObjects&&t.call(Object.prototype,v)&&!g.allowPrototypes)return;M.push(v)}for(var T=0;g.depth>0&&(E=y.exec(_))!==null&&T<g.depth;){if(T+=1,!g.plainObjects&&t.call(Object.prototype,E[1].slice(1,-1))&&!g.allowPrototypes)return;M.push(E[1])}if(E){if(g.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+g.depth+" and strictDepth is true");M.push("["+_.slice(E.index)+"]")}return l(M,p,g,m)}},c=function(f){if(!f)return i;if(typeof f.allowEmptyArrays<"u"&&typeof f.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof f.decodeDotInKeys<"u"&&typeof f.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(f.decoder!==null&&typeof f.decoder<"u"&&typeof f.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof f.charset<"u"&&f.charset!=="utf-8"&&f.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var p=typeof f.charset>"u"?i.charset:f.charset,g=typeof f.duplicates>"u"?i.duplicates:f.duplicates;if(g!=="combine"&&g!=="first"&&g!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var m=typeof f.allowDots>"u"?f.decodeDotInKeys===!0?!0:i.allowDots:!!f.allowDots;return{allowDots:m,allowEmptyArrays:typeof f.allowEmptyArrays=="boolean"?!!f.allowEmptyArrays:i.allowEmptyArrays,allowPrototypes:typeof f.allowPrototypes=="boolean"?f.allowPrototypes:i.allowPrototypes,allowSparse:typeof f.allowSparse=="boolean"?f.allowSparse:i.allowSparse,arrayLimit:typeof f.arrayLimit=="number"?f.arrayLimit:i.arrayLimit,charset:p,charsetSentinel:typeof f.charsetSentinel=="boolean"?f.charsetSentinel:i.charsetSentinel,comma:typeof f.comma=="boolean"?f.comma:i.comma,decodeDotInKeys:typeof f.decodeDotInKeys=="boolean"?f.decodeDotInKeys:i.decodeDotInKeys,decoder:typeof f.decoder=="function"?f.decoder:i.decoder,delimiter:typeof f.delimiter=="string"||s.isRegExp(f.delimiter)?f.delimiter:i.delimiter,depth:typeof f.depth=="number"||f.depth===!1?+f.depth:i.depth,duplicates:g,ignoreQueryPrefix:f.ignoreQueryPrefix===!0,interpretNumericEntities:typeof f.interpretNumericEntities=="boolean"?f.interpretNumericEntities:i.interpretNumericEntities,parameterLimit:typeof f.parameterLimit=="number"?f.parameterLimit:i.parameterLimit,parseArrays:f.parseArrays!==!1,plainObjects:typeof f.plainObjects=="boolean"?f.plainObjects:i.plainObjects,strictDepth:typeof f.strictDepth=="boolean"?!!f.strictDepth:i.strictDepth,strictNullHandling:typeof f.strictNullHandling=="boolean"?f.strictNullHandling:i.strictNullHandling}};return ea=function(d,f){var p=c(f);if(d===""||d===null||typeof d>"u")return p.plainObjects?Object.create(null):{};for(var g=typeof d=="string"?h(d,p):d,m=p.plainObjects?Object.create(null):{},_=Object.keys(g),b=0;b<_.length;++b){var y=_[b],E=u(y,g[y],p,typeof d=="string");m=s.merge(m,E,p)}return p.allowSparse===!0?m:s.compact(m)},ea}var ia,gl;function Hf(){if(gl)return ia;gl=1;var s=Gf(),t=Vf(),e=Jn();return ia={formats:e,parse:t,stringify:s},ia}var _l;function Xf(){if(_l)return ci;_l=1;var s=bf();function t(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var e=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,r=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,n=["<",">",'"',"`"," ","\r",`
5
+ `," "],a=["{","}","|","\\","^","`"].concat(n),o=["'"].concat(a),h=["%","/","?",";","#"].concat(o),l=["/","?","#"],u=255,c=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,f={javascript:!0,"javascript:":!0},p={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},m=Hf();function _(v,M,T){if(v&&typeof v=="object"&&v instanceof t)return v;var P=new t;return P.parse(v,M,T),P}t.prototype.parse=function(v,M,T){if(typeof v!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof v);var P=v.indexOf("?"),N=P!==-1&&P<v.indexOf("#")?"?":"#",G=v.split(N),z=/\\/g;G[0]=G[0].replace(z,"/"),v=G.join(N);var D=v;if(D=D.trim(),!T&&v.split("#").length===1){var O=r.exec(D);if(O)return this.path=D,this.href=D,this.pathname=O[1],O[2]?(this.search=O[2],M?this.query=m.parse(this.search.substr(1)):this.query=this.search.substr(1)):M&&(this.search="",this.query={}),this}var V=e.exec(D);if(V){V=V[0];var W=V.toLowerCase();this.protocol=W,D=D.substr(V.length)}if(T||V||D.match(/^\/\/[^@/]+@[^@/]+/)){var w=D.substr(0,2)==="//";w&&!(V&&p[V])&&(D=D.substr(2),this.slashes=!0)}if(!p[V]&&(w||V&&!g[V])){for(var C=-1,x=0;x<l.length;x++){var R=D.indexOf(l[x]);R!==-1&&(C===-1||R<C)&&(C=R)}var A,S;C===-1?S=D.lastIndexOf("@"):S=D.lastIndexOf("@",C),S!==-1&&(A=D.slice(0,S),D=D.slice(S+1),this.auth=decodeURIComponent(A)),C=-1;for(var x=0;x<h.length;x++){var R=D.indexOf(h[x]);R!==-1&&(C===-1||R<C)&&(C=R)}C===-1&&(C=D.length),this.host=D.slice(0,C),D=D.slice(C),this.parseHost(),this.hostname=this.hostname||"";var F=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!F)for(var L=this.hostname.split(/\./),x=0,U=L.length;x<U;x++){var X=L[x];if(X&&!X.match(c)){for(var J="",Z=0,tt=X.length;Z<tt;Z++)X.charCodeAt(Z)>127?J+="x":J+=X[Z];if(!J.match(c)){var st=L.slice(0,x),K=L.slice(x+1),ht=X.match(d);ht&&(st.push(ht[1]),K.unshift(ht[2])),K.length&&(D="/"+K.join(".")+D),this.hostname=st.join(".");break}}}this.hostname.length>u?this.hostname="":this.hostname=this.hostname.toLowerCase(),F||(this.hostname=s.toASCII(this.hostname));var dt=this.port?":"+this.port:"",bt=this.hostname||"";this.host=bt+dt,this.href+=this.host,F&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),D[0]!=="/"&&(D="/"+D))}if(!f[W])for(var x=0,U=o.length;x<U;x++){var _t=o[x];if(D.indexOf(_t)!==-1){var rt=encodeURIComponent(_t);rt===_t&&(rt=escape(_t)),D=D.split(_t).join(rt)}}var ct=D.indexOf("#");ct!==-1&&(this.hash=D.substr(ct),D=D.slice(0,ct));var Ye=D.indexOf("?");if(Ye!==-1?(this.search=D.substr(Ye),this.query=D.substr(Ye+1),M&&(this.query=m.parse(this.query)),D=D.slice(0,Ye)):M&&(this.search="",this.query={}),D&&(this.pathname=D),g[W]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var dt=this.pathname||"",oi=this.search||"";this.path=dt+oi}return this.href=this.format(),this};function b(v){return typeof v=="string"&&(v=_(v)),v instanceof t?v.format():t.prototype.format.call(v)}t.prototype.format=function(){var v=this.auth||"";v&&(v=encodeURIComponent(v),v=v.replace(/%3A/i,":"),v+="@");var M=this.protocol||"",T=this.pathname||"",P=this.hash||"",N=!1,G="";this.host?N=v+this.host:this.hostname&&(N=v+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(N+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(G=m.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var z=this.search||G&&"?"+G||"";return M&&M.substr(-1)!==":"&&(M+=":"),this.slashes||(!M||g[M])&&N!==!1?(N="//"+(N||""),T&&T.charAt(0)!=="/"&&(T="/"+T)):N||(N=""),P&&P.charAt(0)!=="#"&&(P="#"+P),z&&z.charAt(0)!=="?"&&(z="?"+z),T=T.replace(/[?#]/g,function(D){return encodeURIComponent(D)}),z=z.replace("#","%23"),M+N+T+z+P};function y(v,M){return _(v,!1,!0).resolve(M)}t.prototype.resolve=function(v){return this.resolveObject(_(v,!1,!0)).format()};function E(v,M){return v?_(v,!1,!0).resolveObject(M):M}return t.prototype.resolveObject=function(v){if(typeof v=="string"){var M=new t;M.parse(v,!1,!0),v=M}for(var T=new t,P=Object.keys(this),N=0;N<P.length;N++){var G=P[N];T[G]=this[G]}if(T.hash=v.hash,v.href==="")return T.href=T.format(),T;if(v.slashes&&!v.protocol){for(var z=Object.keys(v),D=0;D<z.length;D++){var O=z[D];O!=="protocol"&&(T[O]=v[O])}return g[T.protocol]&&T.hostname&&!T.pathname&&(T.pathname="/",T.path=T.pathname),T.href=T.format(),T}if(v.protocol&&v.protocol!==T.protocol){if(!g[v.protocol]){for(var V=Object.keys(v),W=0;W<V.length;W++){var w=V[W];T[w]=v[w]}return T.href=T.format(),T}if(T.protocol=v.protocol,!v.host&&!p[v.protocol]){for(var U=(v.pathname||"").split("/");U.length&&!(v.host=U.shift()););v.host||(v.host=""),v.hostname||(v.hostname=""),U[0]!==""&&U.unshift(""),U.length<2&&U.unshift(""),T.pathname=U.join("/")}else T.pathname=v.pathname;if(T.search=v.search,T.query=v.query,T.host=v.host||"",T.auth=v.auth,T.hostname=v.hostname||v.host,T.port=v.port,T.pathname||T.search){var C=T.pathname||"",x=T.search||"";T.path=C+x}return T.slashes=T.slashes||v.slashes,T.href=T.format(),T}var R=T.pathname&&T.pathname.charAt(0)==="/",A=v.host||v.pathname&&v.pathname.charAt(0)==="/",S=A||R||T.host&&v.pathname,F=S,L=T.pathname&&T.pathname.split("/")||[],U=v.pathname&&v.pathname.split("/")||[],X=T.protocol&&!g[T.protocol];if(X&&(T.hostname="",T.port=null,T.host&&(L[0]===""?L[0]=T.host:L.unshift(T.host)),T.host="",v.protocol&&(v.hostname=null,v.port=null,v.host&&(U[0]===""?U[0]=v.host:U.unshift(v.host)),v.host=null),S=S&&(U[0]===""||L[0]==="")),A)T.host=v.host||v.host===""?v.host:T.host,T.hostname=v.hostname||v.hostname===""?v.hostname:T.hostname,T.search=v.search,T.query=v.query,L=U;else if(U.length)L||(L=[]),L.pop(),L=L.concat(U),T.search=v.search,T.query=v.query;else if(v.search!=null){if(X){T.host=L.shift(),T.hostname=T.host;var J=T.host&&T.host.indexOf("@")>0?T.host.split("@"):!1;J&&(T.auth=J.shift(),T.hostname=J.shift(),T.host=T.hostname)}return T.search=v.search,T.query=v.query,(T.pathname!==null||T.search!==null)&&(T.path=(T.pathname?T.pathname:"")+(T.search?T.search:"")),T.href=T.format(),T}if(!L.length)return T.pathname=null,T.search?T.path="/"+T.search:T.path=null,T.href=T.format(),T;for(var Z=L.slice(-1)[0],tt=(T.host||v.host||L.length>1)&&(Z==="."||Z==="..")||Z==="",st=0,K=L.length;K>=0;K--)Z=L[K],Z==="."?L.splice(K,1):Z===".."?(L.splice(K,1),st++):st&&(L.splice(K,1),st--);if(!S&&!F)for(;st--;st)L.unshift("..");S&&L[0]!==""&&(!L[0]||L[0].charAt(0)!=="/")&&L.unshift(""),tt&&L.join("/").substr(-1)!=="/"&&L.push("");var ht=L[0]===""||L[0]&&L[0].charAt(0)==="/";if(X){T.hostname=ht?"":L.length?L.shift():"",T.host=T.hostname;var J=T.host&&T.host.indexOf("@")>0?T.host.split("@"):!1;J&&(T.auth=J.shift(),T.hostname=J.shift(),T.host=T.hostname)}return S=S||T.host&&L.length,S&&!ht&&L.unshift(""),L.length>0?T.pathname=L.join("/"):(T.pathname=null,T.path=null),(T.pathname!==null||T.search!==null)&&(T.path=(T.pathname?T.pathname:"")+(T.search?T.search:"")),T.auth=v.auth||T.auth,T.slashes=T.slashes||v.slashes,T.href=T.format(),T},t.prototype.parseHost=function(){var v=this.host,M=i.exec(v);M&&(M=M[0],M!==":"&&(this.port=M.substr(1)),v=v.substr(0,v.length-M.length)),v&&(this.hostname=v)},ci.parse=_,ci.resolve=y,ci.resolveObject=E,ci.format=b,ci.Url=t,ci}var ra=Xf();const yl={};function ot(s,t,e=3){if(yl[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
6
+ Deprecated since v${s}`):(i=i.split(`
10
7
  `).splice(e).join(`
11
- `),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",t+`
12
- Deprecated since v`+i),console.warn(r),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",t+`
13
- Deprecated since v`+i),console.warn(r))),Vh[t]=!0}}var ys={},Gt=Object.create(null),$t=Object.create(null);function Tv(){var i;for(i in Gt)Gt[i].destroy();for(i in $t)$t[i].destroy()}function Ev(){var i;for(i in Gt)delete Gt[i];for(i in $t)delete $t[i]}var xs=function(){function i(t,e,r){this.canvas=z.ADAPTER.createCanvas(),this.context=this.canvas.getContext("2d"),this.resolution=r||z.RESOLUTION,this.resize(t,e)}return i.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height)},i.prototype.resize=function(t,e){this.canvas.width=Math.round(t*this.resolution),this.canvas.height=Math.round(e*this.resolution)},i.prototype.destroy=function(){this.context=null,this.canvas=null},Object.defineProperty(i.prototype,"width",{get:function(){return this.canvas.width},set:function(t){this.canvas.width=Math.round(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.canvas.height},set:function(t){this.canvas.height=Math.round(t)},enumerable:!1,configurable:!0}),i}();function jh(i){var t=i.width,e=i.height,r=i.getContext("2d",{willReadFrequently:!0}),n=r.getImageData(0,0,t,e),s=n.data,a=s.length,o={top:null,left:null,right:null,bottom:null},h=null,u,l,c;for(u=0;u<a;u+=4)s[u+3]!==0&&(l=u/4%t,c=~~(u/4/t),o.top===null&&(o.top=c),(o.left===null||l<o.left)&&(o.left=l),(o.right===null||o.right<l)&&(o.right=l+1),(o.bottom===null||o.bottom<c)&&(o.bottom=c));return o.top!==null&&(t=o.right-o.left,e=o.bottom-o.top+1,h=r.getImageData(o.left,o.top,t,e)),{height:e,width:t,data:h}}var zh=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function Sv(i){var t=zh.exec(i);if(t)return{mediaType:t[1]?t[1].toLowerCase():void 0,subType:t[2]?t[2].toLowerCase():void 0,charset:t[3]?t[3].toLowerCase():void 0,encoding:t[4]?t[4].toLowerCase():void 0,data:t[5]}}var Ci;function Wh(i,t){if(t===void 0&&(t=globalThis.location),i.indexOf("data:")===0)return"";t=t||globalThis.location,Ci||(Ci=document.createElement("a")),Ci.href=i;var e=ce.parse(Ci.href),r=!e.port&&t.port===""||e.port===t.port;return e.hostname!==t.hostname||!r||e.protocol!==t.protocol?"anonymous":""}function Gr(i,t){var e=z.RETINA_PREFIX.exec(i);return e?parseFloat(e[1]):t!==void 0?t:1}const Pv=Object.freeze(Object.defineProperty({__proto__:null,BaseTextureCache:$t,CanvasRenderTarget:xs,DATA_URI:zh,EventEmitter:xe,ProgramCache:ys,TextureCache:Gt,clearTextureCache:Ev,correctBlendMode:vs,createIndicesForQuads:Hh,decomposeDataUri:Sv,deprecation:Bt,destroyTextureCache:Tv,determineCrossOrigin:Wh,earcut:Rn,getBufferType:wi,getResolutionOfUrl:Gr,hex2rgb:He,hex2string:cs,interleaveTypedArrays:xv,isMobile:qt,isPow2:gs,isWebGLSupported:Gh,log2:ms,nextPow2:kr,path:Nh,premultiplyBlendMode:ps,premultiplyRgba:Xh,premultiplyTint:Pi,premultiplyTintToRgba:_s,removeItems:Ve,rgb2hex:gv,sayHello:kh,sign:je,skipHello:Ac,string2hex:ds,trimCanvas:jh,uid:Ie,url:ce},Symbol.toStringTag,{value:"Module"}));var Xr=Math.PI*2,Yh=180/Math.PI,qh=Math.PI/180,Rt;(function(i){i[i.POLY=0]="POLY",i[i.RECT=1]="RECT",i[i.CIRC=2]="CIRC",i[i.ELIP=3]="ELIP",i[i.RREC=4]="RREC"})(Rt||(Rt={}));var vt=function(){function i(t,e){t===void 0&&(t=0),e===void 0&&(e=0),this.x=0,this.y=0,this.x=t,this.y=e}return i.prototype.clone=function(){return new i(this.x,this.y)},i.prototype.copyFrom=function(t){return this.set(t.x,t.y),this},i.prototype.copyTo=function(t){return t.set(this.x,this.y),t},i.prototype.equals=function(t){return t.x===this.x&&t.y===this.y},i.prototype.set=function(t,e){return t===void 0&&(t=0),e===void 0&&(e=t),this.x=t,this.y=e,this},i.prototype.toString=function(){return"[@pixi/math:Point x="+this.x+" y="+this.y+"]"},i}(),Ii=[new vt,new vt,new vt,new vt],ut=function(){function i(t,e,r,n){t===void 0&&(t=0),e===void 0&&(e=0),r===void 0&&(r=0),n===void 0&&(n=0),this.x=Number(t),this.y=Number(e),this.width=Number(r),this.height=Number(n),this.type=Rt.RECT}return Object.defineProperty(i.prototype,"left",{get:function(){return this.x},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"right",{get:function(){return this.x+this.width},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"top",{get:function(){return this.y},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!1,configurable:!0}),Object.defineProperty(i,"EMPTY",{get:function(){return new i(0,0,0,0)},enumerable:!1,configurable:!0}),i.prototype.clone=function(){return new i(this.x,this.y,this.width,this.height)},i.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this},i.prototype.copyTo=function(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t},i.prototype.contains=function(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height},i.prototype.intersects=function(t,e){if(!e){var r=this.x<t.x?t.x:this.x,n=this.right>t.right?t.right:this.right;if(n<=r)return!1;var s=this.y<t.y?t.y:this.y,a=this.bottom>t.bottom?t.bottom:this.bottom;return a>s}var o=this.left,h=this.right,u=this.top,l=this.bottom;if(h<=o||l<=u)return!1;var c=Ii[0].set(t.left,t.top),f=Ii[1].set(t.left,t.bottom),d=Ii[2].set(t.right,t.top),v=Ii[3].set(t.right,t.bottom);if(d.x<=c.x||f.y<=c.y)return!1;var _=Math.sign(e.a*e.d-e.b*e.c);if(_===0||(e.apply(c,c),e.apply(f,f),e.apply(d,d),e.apply(v,v),Math.max(c.x,f.x,d.x,v.x)<=o||Math.min(c.x,f.x,d.x,v.x)>=h||Math.max(c.y,f.y,d.y,v.y)<=u||Math.min(c.y,f.y,d.y,v.y)>=l))return!1;var p=_*(f.y-c.y),g=_*(c.x-f.x),y=p*o+g*u,T=p*h+g*u,I=p*o+g*l,m=p*h+g*l;if(Math.max(y,T,I,m)<=p*c.x+g*c.y||Math.min(y,T,I,m)>=p*v.x+g*v.y)return!1;var S=_*(c.y-d.y),x=_*(d.x-c.x),N=S*o+x*u,D=S*h+x*u,F=S*o+x*l,k=S*h+x*l;return!(Math.max(N,D,F,k)<=S*c.x+x*c.y||Math.min(N,D,F,k)>=S*v.x+x*v.y)},i.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},i.prototype.fit=function(t){var e=Math.max(this.x,t.x),r=Math.min(this.x+this.width,t.x+t.width),n=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(r-e,0),this.y=n,this.height=Math.max(s-n,0),this},i.prototype.ceil=function(t,e){t===void 0&&(t=1),e===void 0&&(e=.001);var r=Math.ceil((this.x+this.width-e)*t)/t,n=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=r-this.x,this.height=n-this.y,this},i.prototype.enlarge=function(t){var e=Math.min(this.x,t.x),r=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),s=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=r-e,this.y=n,this.height=s-n,this},i.prototype.toString=function(){return"[@pixi/math:Rectangle x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+"]"},i}(),$h=function(){function i(t,e,r){t===void 0&&(t=0),e===void 0&&(e=0),r===void 0&&(r=0),this.x=t,this.y=e,this.radius=r,this.type=Rt.CIRC}return i.prototype.clone=function(){return new i(this.x,this.y,this.radius)},i.prototype.contains=function(t,e){if(this.radius<=0)return!1;var r=this.radius*this.radius,n=this.x-t,s=this.y-e;return n*=n,s*=s,n+s<=r},i.prototype.getBounds=function(){return new ut(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)},i.prototype.toString=function(){return"[@pixi/math:Circle x="+this.x+" y="+this.y+" radius="+this.radius+"]"},i}(),Kh=function(){function i(t,e,r,n){t===void 0&&(t=0),e===void 0&&(e=0),r===void 0&&(r=0),n===void 0&&(n=0),this.x=t,this.y=e,this.width=r,this.height=n,this.type=Rt.ELIP}return i.prototype.clone=function(){return new i(this.x,this.y,this.width,this.height)},i.prototype.contains=function(t,e){if(this.width<=0||this.height<=0)return!1;var r=(t-this.x)/this.width,n=(e-this.y)/this.height;return r*=r,n*=n,r+n<=1},i.prototype.getBounds=function(){return new ut(this.x-this.width,this.y-this.height,this.width,this.height)},i.prototype.toString=function(){return"[@pixi/math:Ellipse x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+"]"},i}(),Hr=function(){function i(){for(var t=arguments,e=[],r=0;r<arguments.length;r++)e[r]=t[r];var n=Array.isArray(e[0])?e[0]:e;if(typeof n[0]!="number"){for(var s=[],a=0,o=n.length;a<o;a++)s.push(n[a].x,n[a].y);n=s}this.points=n,this.type=Rt.POLY,this.closeStroke=!0}return i.prototype.clone=function(){var t=this.points.slice(),e=new i(t);return e.closeStroke=this.closeStroke,e},i.prototype.contains=function(t,e){for(var r=!1,n=this.points.length/2,s=0,a=n-1;s<n;a=s++){var o=this.points[s*2],h=this.points[s*2+1],u=this.points[a*2],l=this.points[a*2+1],c=h>e!=l>e&&t<(u-o)*((e-h)/(l-h))+o;c&&(r=!r)}return r},i.prototype.toString=function(){return"[@pixi/math:Polygon"+("closeStroke="+this.closeStroke)+("points="+this.points.reduce(function(t,e){return t+", "+e},"")+"]")},i}(),Zh=function(){function i(t,e,r,n,s){t===void 0&&(t=0),e===void 0&&(e=0),r===void 0&&(r=0),n===void 0&&(n=0),s===void 0&&(s=20),this.x=t,this.y=e,this.width=r,this.height=n,this.radius=s,this.type=Rt.RREC}return i.prototype.clone=function(){return new i(this.x,this.y,this.width,this.height,this.radius)},i.prototype.contains=function(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){var r=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+r&&e<=this.y+this.height-r||t>=this.x+r&&t<=this.x+this.width-r)return!0;var n=t-(this.x+r),s=e-(this.y+r),a=r*r;if(n*n+s*s<=a||(n=t-(this.x+this.width-r),n*n+s*s<=a)||(s=e-(this.y+this.height-r),n*n+s*s<=a)||(n=t-(this.x+r),n*n+s*s<=a))return!0}return!1},i.prototype.toString=function(){return"[@pixi/math:RoundedRectangle x="+this.x+" y="+this.y+("width="+this.width+" height="+this.height+" radius="+this.radius+"]")},i}(),Ae=function(){function i(t,e,r,n){r===void 0&&(r=0),n===void 0&&(n=0),this._x=r,this._y=n,this.cb=t,this.scope=e}return i.prototype.clone=function(t,e){return t===void 0&&(t=this.cb),e===void 0&&(e=this.scope),new i(t,e,this._x,this._y)},i.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},i.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},i.prototype.copyTo=function(t){return t.set(this._x,this._y),t},i.prototype.equals=function(t){return t.x===this._x&&t.y===this._y},i.prototype.toString=function(){return"[@pixi/math:ObservablePoint x=0 y=0 scope="+this.scope+"]"},Object.defineProperty(i.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(i.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}),i}(),bt=function(){function i(t,e,r,n,s,a){t===void 0&&(t=1),e===void 0&&(e=0),r===void 0&&(r=0),n===void 0&&(n=1),s===void 0&&(s=0),a===void 0&&(a=0),this.array=null,this.a=t,this.b=e,this.c=r,this.d=n,this.tx=s,this.ty=a}return i.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]},i.prototype.set=function(t,e,r,n,s,a){return this.a=t,this.b=e,this.c=r,this.d=n,this.tx=s,this.ty=a,this},i.prototype.toArray=function(t,e){this.array||(this.array=new Float32Array(9));var r=e||this.array;return t?(r[0]=this.a,r[1]=this.b,r[2]=0,r[3]=this.c,r[4]=this.d,r[5]=0,r[6]=this.tx,r[7]=this.ty,r[8]=1):(r[0]=this.a,r[1]=this.c,r[2]=this.tx,r[3]=this.b,r[4]=this.d,r[5]=this.ty,r[6]=0,r[7]=0,r[8]=1),r},i.prototype.apply=function(t,e){e=e||new vt;var r=t.x,n=t.y;return e.x=this.a*r+this.c*n+this.tx,e.y=this.b*r+this.d*n+this.ty,e},i.prototype.applyInverse=function(t,e){e=e||new vt;var r=1/(this.a*this.d+this.c*-this.b),n=t.x,s=t.y;return e.x=this.d*r*n+-this.c*r*s+(this.ty*this.c-this.tx*this.d)*r,e.y=this.a*r*s+-this.b*r*n+(-this.ty*this.a+this.tx*this.b)*r,e},i.prototype.translate=function(t,e){return this.tx+=t,this.ty+=e,this},i.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},i.prototype.rotate=function(t){var e=Math.cos(t),r=Math.sin(t),n=this.a,s=this.c,a=this.tx;return this.a=n*e-this.b*r,this.b=n*r+this.b*e,this.c=s*e-this.d*r,this.d=s*r+this.d*e,this.tx=a*e-this.ty*r,this.ty=a*r+this.ty*e,this},i.prototype.append=function(t){var e=this.a,r=this.b,n=this.c,s=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*r+t.b*s,this.c=t.c*e+t.d*n,this.d=t.c*r+t.d*s,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*r+t.ty*s+this.ty,this},i.prototype.setTransform=function(t,e,r,n,s,a,o,h,u){return this.a=Math.cos(o+u)*s,this.b=Math.sin(o+u)*s,this.c=-Math.sin(o-h)*a,this.d=Math.cos(o-h)*a,this.tx=t-(r*this.a+n*this.c),this.ty=e-(r*this.b+n*this.d),this},i.prototype.prepend=function(t){var e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){var r=this.a,n=this.c;this.a=r*t.a+this.b*t.c,this.b=r*t.b+this.b*t.d,this.c=n*t.a+this.d*t.c,this.d=n*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},i.prototype.decompose=function(t){var e=this.a,r=this.b,n=this.c,s=this.d,a=t.pivot,o=-Math.atan2(-n,s),h=Math.atan2(r,e),u=Math.abs(o+h);return u<1e-5||Math.abs(Xr-u)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=h),t.scale.x=Math.sqrt(e*e+r*r),t.scale.y=Math.sqrt(n*n+s*s),t.position.x=this.tx+(a.x*e+a.y*n),t.position.y=this.ty+(a.x*r+a.y*s),t},i.prototype.invert=function(){var t=this.a,e=this.b,r=this.c,n=this.d,s=this.tx,a=t*n-e*r;return this.a=n/a,this.b=-e/a,this.c=-r/a,this.d=t/a,this.tx=(r*this.ty-n*s)/a,this.ty=-(t*this.ty-e*s)/a,this},i.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this},i.prototype.clone=function(){var t=new i;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},i.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},i.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},i.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(i,"IDENTITY",{get:function(){return new i},enumerable:!1,configurable:!0}),Object.defineProperty(i,"TEMP_MATRIX",{get:function(){return new i},enumerable:!1,configurable:!0}),i}(),ze=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],We=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Ye=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],qe=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],bs=[],Jh=[],Ai=Math.sign;function wv(){for(var i=0;i<16;i++){var t=[];bs.push(t);for(var e=0;e<16;e++)for(var r=Ai(ze[i]*ze[e]+Ye[i]*We[e]),n=Ai(We[i]*ze[e]+qe[i]*We[e]),s=Ai(ze[i]*Ye[e]+Ye[i]*qe[e]),a=Ai(We[i]*Ye[e]+qe[i]*qe[e]),o=0;o<16;o++)if(ze[o]===r&&We[o]===n&&Ye[o]===s&&qe[o]===a){t.push(o);break}}for(var i=0;i<16;i++){var h=new bt;h.set(ze[i],We[i],Ye[i],qe[i],0,0),Jh.push(h)}}wv();var Tt={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(i){return ze[i]},uY:function(i){return We[i]},vX:function(i){return Ye[i]},vY:function(i){return qe[i]},inv:function(i){return i&8?i&15:-i&7},add:function(i,t){return bs[i][t]},sub:function(i,t){return bs[i][Tt.inv(t)]},rotate180:function(i){return i^4},isVertical:function(i){return(i&3)===2},byDirection:function(i,t){return Math.abs(i)*2<=Math.abs(t)?t>=0?Tt.S:Tt.N:Math.abs(t)*2<=Math.abs(i)?i>0?Tt.E:Tt.W:t>0?i>0?Tt.SE:Tt.SW:i>0?Tt.NE:Tt.NW},matrixAppendRotationInv:function(i,t,e,r){e===void 0&&(e=0),r===void 0&&(r=0);var n=Jh[Tt.inv(t)];n.tx=e,n.ty=r,i.append(n)}},Mi=function(){function i(){this.worldTransform=new bt,this.localTransform=new bt,this.position=new Ae(this.onChange,this,0,0),this.scale=new Ae(this.onChange,this,1,1),this.pivot=new Ae(this.onChange,this,0,0),this.skew=new Ae(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 i.prototype.onChange=function(){this._localID++},i.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++},i.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+") ")+"]"},i.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)},i.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 r=t.worldTransform,n=this.worldTransform;n.a=e.a*r.a+e.b*r.c,n.b=e.a*r.b+e.b*r.d,n.c=e.c*r.a+e.d*r.c,n.d=e.c*r.b+e.d*r.d,n.tx=e.tx*r.a+e.ty*r.c+r.tx,n.ty=e.tx*r.b+e.ty*r.d+r.ty,this._parentID=t._worldID,this._worldID++}},i.prototype.setFromMatrix=function(t){t.decompose(this),this._localID++},Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},set:function(t){this._rotation!==t&&(this._rotation=t,this.updateSkew())},enumerable:!1,configurable:!0}),i.IDENTITY=new i,i}();var Vr=function(){return Vr=Object.assign||function(t){for(var e=arguments,r,n=1,s=arguments.length;n<s;n++){r=e[n];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},Vr.apply(this,arguments)},dt;(function(i){i.Application="application",i.RendererPlugin="renderer-webgl-plugin",i.CanvasRendererPlugin="renderer-canvas-plugin",i.Loader="loader",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser"})(dt||(dt={}));var Qh=function(i){if(typeof i=="function"||typeof i=="object"&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");var t=typeof i.extension!="object"?{type:i.extension}:i.extension;i=Vr(Vr({},t),{ref:i})}if(typeof i=="object")i=Vr({},i);else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},Kt={_addHandlers:null,_removeHandlers:null,_queue:{},remove:function(){for(var i=arguments,t=this,e=[],r=0;r<arguments.length;r++)e[r]=i[r];return e.map(Qh).forEach(function(n){n.type.forEach(function(s){var a,o;return(o=(a=t._removeHandlers)[s])===null||o===void 0?void 0:o.call(a,n)})}),this},add:function(){for(var i=arguments,t=this,e=[],r=0;r<arguments.length;r++)e[r]=i[r];return e.map(Qh).forEach(function(n){n.type.forEach(function(s){var a=t._addHandlers,o=t._queue;a[s]?a[s](n):(o[s]=o[s]||[],o[s].push(n))})}),this},handle:function(i,t,e){var r=this._addHandlers=this._addHandlers||{},n=this._removeHandlers=this._removeHandlers||{};if(r[i]||n[i])throw new Error("Extension type "+i+" already has a handler");r[i]=t,n[i]=e;var s=this._queue;return s[i]&&(s[i].forEach(function(a){return t(a)}),delete s[i]),this},handleByMap:function(i,t){return this.handle(i,function(e){t[e.name]=e.ref},function(e){delete t[e.name]})},handleByList:function(i,t){return this.handle(i,function(e){var r,n;t.includes(e.ref)||(t.push(e.ref),i===dt.Loader&&((n=(r=e.ref).add)===null||n===void 0||n.call(r)))},function(e){var r=t.indexOf(e.ref);r!==-1&&t.splice(r,1)})}};var Dt=function(){function i(t){this.items=[],this._name=t,this._aliasCount=0}return i.prototype.emit=function(t,e,r,n,s,a,o,h){if(arguments.length>8)throw new Error("max arguments reached");var u=this,l=u.name,c=u.items;this._aliasCount++;for(var f=0,d=c.length;f<d;f++)c[f][l](t,e,r,n,s,a,o,h);return c===this.items&&this._aliasCount--,this},i.prototype.ensureNonAliasedItems=function(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))},i.prototype.add=function(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this},i.prototype.remove=function(t){var e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this},i.prototype.contains=function(t){return this.items.indexOf(t)!==-1},i.prototype.removeAll=function(){return this.ensureNonAliasedItems(),this.items.length=0,this},i.prototype.destroy=function(){this.removeAll(),this.items=null,this._name=null},Object.defineProperty(i.prototype,"empty",{get:function(){return this.items.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),i}();Object.defineProperties(Dt.prototype,{dispatch:{value:Dt.prototype.emit},run:{value:Dt.prototype.emit}});z.TARGET_FPMS=.06;var de;(function(i){i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY"})(de||(de={}));var Ts=function(){function i(t,e,r,n){e===void 0&&(e=null),r===void 0&&(r=0),n===void 0&&(n=!1),this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=r,this.once=n}return i.prototype.match=function(t,e){return e===void 0&&(e=null),this.fn===t&&this.context===e},i.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},i.prototype.connect=function(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this},i.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},i}(),Ot=function(){function i(){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 Ts(null,null,1/0),this.deltaMS=1/z.TARGET_FPMS,this.elapsedMS=1/z.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 i.prototype._requestIfNeeded=function(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))},i.prototype._cancelIfNeeded=function(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)},i.prototype._startIfPossible=function(){this.started?this._requestIfNeeded():this.autoStart&&this.start()},i.prototype.add=function(t,e,r){return r===void 0&&(r=de.NORMAL),this._addListener(new Ts(t,e,r))},i.prototype.addOnce=function(t,e,r){return r===void 0&&(r=de.NORMAL),this._addListener(new Ts(t,e,r,!0))},i.prototype._addListener=function(t){var e=this._head.next,r=this._head;if(!e)t.connect(r);else{for(;e;){if(t.priority>e.priority){t.connect(r);break}r=e,e=e.next}t.previous||t.connect(r)}return this._startIfPossible(),this},i.prototype.remove=function(t,e){for(var r=this._head.next;r;)r.match(t,e)?r=r.destroy():r=r.next;return this._head.next||this._cancelIfNeeded(),this},Object.defineProperty(i.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}),i.prototype.start=function(){this.started||(this.started=!0,this._requestIfNeeded())},i.prototype.stop=function(){this.started&&(this.started=!1,this._cancelIfNeeded())},i.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}},i.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 r=t-this._lastFrame|0;if(r<this._minElapsedMS)return;this._lastFrame=t-r%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*z.TARGET_FPMS;for(var n=this._head,s=n.next;s;)s=s.emit(this.deltaTime);n.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t},Object.defineProperty(i.prototype,"FPS",{get:function(){return 1e3/this.elapsedMS},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"minFPS",{get:function(){return 1e3/this._maxElapsedMS},set:function(t){var e=Math.min(this.maxFPS,t),r=Math.min(Math.max(0,e)/1e3,z.TARGET_FPMS);this._maxElapsedMS=1/r},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"maxFPS",{get:function(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0},set:function(t){if(t===0)this._minElapsedMS=0;else{var e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}},enumerable:!1,configurable:!0}),Object.defineProperty(i,"shared",{get:function(){if(!i._shared){var t=i._shared=new i;t.autoStart=!0,t._protected=!0}return i._shared},enumerable:!1,configurable:!0}),Object.defineProperty(i,"system",{get:function(){if(!i._system){var t=i._system=new i;t.autoStart=!0,t._protected=!0}return i._system},enumerable:!1,configurable:!0}),i}(),Es=function(){function i(){}return i.init=function(t){var e=this;t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set:function(r){this._ticker&&this._ticker.remove(this.render,this),this._ticker=r,r&&r.add(this.render,this,de.LOW)},get:function(){return this._ticker}}),this.stop=function(){e._ticker.stop()},this.start=function(){e._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Ot.shared:new Ot,t.autoStart&&this.start()},i.destroy=function(){if(this._ticker){var t=this._ticker;this.ticker=null,t.destroy()}},i.extension=dt.Application,i}();z.PREFER_ENV=qt.any?Ut.WEBGL:Ut.WEBGL2,z.STRICT_TEXTURE_CACHE=!1;var jr=[];function Ri(i,t){if(!i)return null;var e="";if(typeof i=="string"){var r=/\.(\w{3,4})(?:$|\?|#)/i.exec(i);r&&(e=r[1].toLowerCase())}for(var n=jr.length-1;n>=0;--n){var s=jr[n];if(s.test&&s.test(i,e))return new s(i,t)}throw new Error("Unrecognized source type to auto-detect Resource")}var Ss=function(i,t){return Ss=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},Ss(i,t)};function mt(i,t){Ss(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Ps=function(){return Ps=Object.assign||function(t){for(var e=arguments,r,n=1,s=arguments.length;n<s;n++){r=e[n];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},Ps.apply(this,arguments)};function Cv(i,t){var e={};for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&t.indexOf(r)<0&&(e[r]=i[r]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(i);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(i,r[n])&&(e[r[n]]=i[r[n]]);return e}var $e=function(){function i(t,e){t===void 0&&(t=0),e===void 0&&(e=0),this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new Dt("setRealSize"),this.onUpdate=new Dt("update"),this.onError=new Dt("onError")}return i.prototype.bind=function(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)},i.prototype.unbind=function(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)},i.prototype.resize=function(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))},Object.defineProperty(i.prototype,"valid",{get:function(){return!!this._width&&!!this._height},enumerable:!1,configurable:!0}),i.prototype.update=function(){this.destroyed||this.onUpdate.emit()},i.prototype.load=function(){return Promise.resolve(this)},Object.defineProperty(i.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),i.prototype.style=function(t,e,r){return!1},i.prototype.dispose=function(){},i.prototype.destroy=function(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)},i.test=function(t,e){return!1},i}(),Ke=function(i){mt(t,i);function t(e,r){var n=this,s=r||{},a=s.width,o=s.height;if(!a||!o)throw new Error("BufferResource width or height invalid");return n=i.call(this,a,o)||this,n.data=e,n}return t.prototype.upload=function(e,r,n){var s=e.gl;s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.alphaMode===Wt.UNPACK);var a=r.realWidth,o=r.realHeight;return n.width===a&&n.height===o?s.texSubImage2D(r.target,0,0,0,a,o,r.format,n.type,this.data):(n.width=a,n.height=o,s.texImage2D(r.target,0,n.internalFormat,a,o,0,r.format,n.type,this.data)),!0},t.prototype.dispose=function(){this.data=null},t.test=function(e){return e instanceof Float32Array||e instanceof Uint8Array||e instanceof Uint32Array},t}($e),Iv={scaleMode:ie.NEAREST,format:H.RGBA,alphaMode:Wt.NPM},lt=function(i){mt(t,i);function t(e,r){e===void 0&&(e=null),r===void 0&&(r=null);var n=i.call(this)||this;r=r||{};var s=r.alphaMode,a=r.mipmap,o=r.anisotropicLevel,h=r.scaleMode,u=r.width,l=r.height,c=r.wrapMode,f=r.format,d=r.type,v=r.target,_=r.resolution,p=r.resourceOptions;return e&&!(e instanceof $e)&&(e=Ri(e,p),e.internal=!0),n.resolution=_||z.RESOLUTION,n.width=Math.round((u||0)*n.resolution)/n.resolution,n.height=Math.round((l||0)*n.resolution)/n.resolution,n._mipmap=a!==void 0?a:z.MIPMAP_TEXTURES,n.anisotropicLevel=o!==void 0?o:z.ANISOTROPIC_LEVEL,n._wrapMode=c||z.WRAP_MODE,n._scaleMode=h!==void 0?h:z.SCALE_MODE,n.format=f||H.RGBA,n.type=d||Q.UNSIGNED_BYTE,n.target=v||Ce.TEXTURE_2D,n.alphaMode=s!==void 0?s:Wt.UNPACK,n.uid=Ie(),n.touched=0,n.isPowerOfTwo=!1,n._refreshPOT(),n._glTextures={},n.dirtyId=0,n.dirtyStyleId=0,n.cacheId=null,n.valid=u>0&&l>0,n.textureCacheIds=[],n.destroyed=!1,n.resource=null,n._batchEnabled=0,n._batchLocation=0,n.parentTextureArray=null,n.setResource(e),n}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,r){var n;return e!==void 0&&e!==this.scaleMode&&(this.scaleMode=e,n=!0),r!==void 0&&r!==this.mipmap&&(this.mipmap=r,n=!0),n&&this.dirtyStyleId++,this},t.prototype.setSize=function(e,r,n){return n=n||this.resolution,this.setRealSize(e*n,r*n,n)},t.prototype.setRealSize=function(e,r,n){return this.resolution=n||this.resolution,this.width=Math.round(e)/this.resolution,this.height=Math.round(r)/this.resolution,this._refreshPOT(),this.update(),this},t.prototype._refreshPOT=function(){this.isPowerOfTwo=gs(this.realWidth)&&gs(this.realHeight)},t.prototype.setResolution=function(e){var r=this.resolution;return r===e?this:(this.resolution=e,this.valid&&(this.width=Math.round(this.width*r)/e,this.height=Math.round(this.height*r)/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 $t[this.cacheId],delete Gt[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,r,n){n===void 0&&(n=z.STRICT_TEXTURE_CACHE);var s=typeof e=="string",a=null;if(s)a=e;else{if(!e._pixiId){var o=r&&r.pixiIdPrefix||"pixiid";e._pixiId=o+"_"+Ie()}a=e._pixiId}var h=$t[a];if(s&&n&&!h)throw new Error('The cacheId "'+a+'" does not exist in BaseTextureCache.');return h||(h=new t(e,r),h.cacheId=a,t.addToCache(h,a)),h},t.fromBuffer=function(e,r,n,s){e=e||new Float32Array(r*n*4);var a=new Ke(e,{width:r,height:n}),o=e instanceof Float32Array?Q.FLOAT:Q.UNSIGNED_BYTE;return new t(a,Object.assign({},Iv,s||{width:r,height:n,type:o}))},t.addToCache=function(e,r){r&&(e.textureCacheIds.indexOf(r)===-1&&e.textureCacheIds.push(r),$t[r]&&console.warn("BaseTexture added to the cache with an id ["+r+"] that already had an entry"),$t[r]=e)},t.removeFromCache=function(e){if(typeof e=="string"){var r=$t[e];if(r){var n=r.textureCacheIds.indexOf(e);return n>-1&&r.textureCacheIds.splice(n,1),delete $t[e],r}}else if(e&&e.textureCacheIds){for(var s=0;s<e.textureCacheIds.length;++s)delete $t[e.textureCacheIds[s]];return e.textureCacheIds.length=0,e}return null},t._globalBatch=0,t}(xe),Oi=function(i){mt(t,i);function t(e,r){var n=this,s=r||{},a=s.width,o=s.height;n=i.call(this,a,o)||this,n.items=[],n.itemDirtyIds=[];for(var h=0;h<e;h++){var u=new lt;n.items.push(u),n.itemDirtyIds.push(-2)}return n.length=e,n._load=null,n.baseTexture=null,n}return t.prototype.initFromArray=function(e,r){for(var n=0;n<this.length;n++)e[n]&&(e[n].castToBaseTexture?this.addBaseTextureAt(e[n].castToBaseTexture(),n):e[n]instanceof $e?this.addResourceAt(e[n],n):this.addResourceAt(Ri(e[n],r),n))},t.prototype.dispose=function(){for(var e=0,r=this.length;e<r;e++)this.items[e].destroy();this.items=null,this.itemDirtyIds=null,this._load=null},t.prototype.addResourceAt=function(e,r){if(!this.items[r])throw new Error("Index "+r+" is out of bounds");return e.valid&&!this.valid&&this.resize(e.width,e.height),this.items[r].setResource(e),this},t.prototype.bind=function(e){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");i.prototype.bind.call(this,e);for(var r=0;r<this.length;r++)this.items[r].parentTextureArray=e,this.items[r].on("update",e.update,e)},t.prototype.unbind=function(e){i.prototype.unbind.call(this,e);for(var r=0;r<this.length;r++)this.items[r].parentTextureArray=null,this.items[r].off("update",e.update,e)},t.prototype.load=function(){var e=this;if(this._load)return this._load;var r=this.items.map(function(s){return s.resource}).filter(function(s){return s}),n=r.map(function(s){return s.load()});return this._load=Promise.all(n).then(function(){var s=e.items[0],a=s.realWidth,o=s.realHeight;return e.resize(a,o),Promise.resolve(e)}),this._load},t}($e),ws=function(i){mt(t,i);function t(e,r){var n=this,s=r||{},a=s.width,o=s.height,h,u;return Array.isArray(e)?(h=e,u=e.length):u=e,n=i.call(this,u,{width:a,height:o})||this,h&&n.initFromArray(h,r),n}return t.prototype.addBaseTextureAt=function(e,r){if(e.resource)this.addResourceAt(e.resource,r);else throw new Error("ArrayResource does not support RenderTexture");return this},t.prototype.bind=function(e){i.prototype.bind.call(this,e),e.target=Ce.TEXTURE_2D_ARRAY},t.prototype.upload=function(e,r,n){var s=this,a=s.length,o=s.itemDirtyIds,h=s.items,u=e.gl;n.dirtyId<0&&u.texImage3D(u.TEXTURE_2D_ARRAY,0,n.internalFormat,this._width,this._height,a,0,r.format,n.type,null);for(var l=0;l<a;l++){var c=h[l];o[l]<c.dirtyId&&(o[l]=c.dirtyId,c.valid&&u.texSubImage3D(u.TEXTURE_2D_ARRAY,0,0,0,l,c.resource.width,c.resource.height,1,r.format,n.type,c.resource.source))}return!0},t}(Oi),pe=function(i){mt(t,i);function t(e){var r=this,n=e,s=n.naturalWidth||n.videoWidth||n.width,a=n.naturalHeight||n.videoHeight||n.height;return r=i.call(this,s,a)||this,r.source=e,r.noSubImage=!1,r}return t.crossOrigin=function(e,r,n){n===void 0&&r.indexOf("data:")!==0?e.crossOrigin=Wh(r):n!==!1&&(e.crossOrigin=typeof n=="string"?n:"anonymous")},t.prototype.upload=function(e,r,n,s){var a=e.gl,o=r.realWidth,h=r.realHeight;if(s=s||this.source,s instanceof HTMLImageElement){if(!s.complete||s.naturalWidth===0)return!1}else if(s instanceof HTMLVideoElement&&s.readyState<=1)return!1;return a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.alphaMode===Wt.UNPACK),!this.noSubImage&&r.target===a.TEXTURE_2D&&n.width===o&&n.height===h?a.texSubImage2D(a.TEXTURE_2D,0,0,0,r.format,n.type,s):(n.width=o,n.height=h,a.texImage2D(r.target,0,n.internalFormat,r.format,n.type,s)),!0},t.prototype.update=function(){if(!this.destroyed){var e=this.source,r=e.naturalWidth||e.videoWidth||e.width,n=e.naturalHeight||e.videoHeight||e.height;this.resize(r,n),i.prototype.update.call(this)}},t.prototype.dispose=function(){this.source=null},t}($e),Cs=function(i){mt(t,i);function t(e){return i.call(this,e)||this}return t.test=function(e){var r=globalThis.OffscreenCanvas;return r&&e instanceof r?!0:globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement},t}(pe),Is=function(i){mt(t,i);function t(e,r){var n=this,s=r||{},a=s.width,o=s.height,h=s.autoLoad,u=s.linkBaseTexture;if(e&&e.length!==t.SIDES)throw new Error("Invalid length. Got "+e.length+", expected 6");n=i.call(this,6,{width:a,height:o})||this;for(var l=0;l<t.SIDES;l++)n.items[l].target=Ce.TEXTURE_CUBE_MAP_POSITIVE_X+l;return n.linkBaseTexture=u!==!1,e&&n.initFromArray(e,r),h!==!1&&n.load(),n}return t.prototype.bind=function(e){i.prototype.bind.call(this,e),e.target=Ce.TEXTURE_CUBE_MAP},t.prototype.addBaseTextureAt=function(e,r,n){if(!this.items[r])throw new Error("Index "+r+" is out of bounds");if(!this.linkBaseTexture||e.parentTextureArray||Object.keys(e._glTextures).length>0)if(e.resource)this.addResourceAt(e.resource,r);else throw new Error("CubeResource does not support copying of renderTexture.");else e.target=Ce.TEXTURE_CUBE_MAP_POSITIVE_X+r,e.parentTextureArray=this.baseTexture,this.items[r]=e;return e.valid&&!this.valid&&this.resize(e.realWidth,e.realHeight),this.items[r]=e,this},t.prototype.upload=function(e,r,n){for(var s=this.itemDirtyIds,a=0;a<t.SIDES;a++){var o=this.items[a];(s[a]<o.dirtyId||n.dirtyId<r.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(e,o,n),s[a]=o.dirtyId):s[a]<-1&&(e.gl.texImage2D(o.target,0,n.internalFormat,r.realWidth,r.realHeight,0,r.format,n.type,null),s[a]=-1))}return!0},t.test=function(e){return Array.isArray(e)&&e.length===t.SIDES},t.SIDES=6,t}(Oi),Di=function(i){mt(t,i);function t(e,r){var n=this;if(r=r||{},!(e instanceof HTMLImageElement)){var s=new Image;pe.crossOrigin(s,e,r.crossorigin),s.src=e,e=s}return n=i.call(this,e)||this,!e.complete&&n._width&&n._height&&(n._width=0,n._height=0),n.url=e.src,n._process=null,n.preserveBitmap=!1,n.createBitmap=(r.createBitmap!==void 0?r.createBitmap:z.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,n.alphaMode=typeof r.alphaMode=="number"?r.alphaMode:null,n.bitmap=null,n._load=null,r.autoLoad!==!1&&n.load(),n}return t.prototype.load=function(e){var r=this;return this._load?this._load:(e!==void 0&&(this.createBitmap=e),this._load=new Promise(function(n,s){var a=r.source;r.url=a.src;var o=function(){r.destroyed||(a.onload=null,a.onerror=null,r.resize(a.width,a.height),r._load=null,r.createBitmap?n(r.process()):n(r))};a.complete&&a.src?o():(a.onload=o,a.onerror=function(h){s(h),r.onError.emit(h)})}),this._load)},t.prototype.process=function(){var e=this,r=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);var n=globalThis.createImageBitmap,s=!r.crossOrigin||r.crossOrigin==="anonymous";return this._process=fetch(r.src,{mode:s?"cors":"no-cors"}).then(function(a){return a.blob()}).then(function(a){return n(a,0,0,r.width,r.height,{premultiplyAlpha:e.alphaMode===null||e.alphaMode===Wt.UNPACK?"premultiply":"none"})}).then(function(a){return e.destroyed?Promise.reject():(e.bitmap=a,e.update(),e._process=null,Promise.resolve(e))}),this._process},t.prototype.upload=function(e,r,n){if(typeof this.alphaMode=="number"&&(r.alphaMode=this.alphaMode),!this.createBitmap)return i.prototype.upload.call(this,e,r,n);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(i.prototype.upload.call(this,e,r,n,this.bitmap),!this.preserveBitmap){var s=!0,a=r._glTextures;for(var o in a){var h=a[o];if(h!==n&&h.dirtyId!==r.dirtyId){s=!1;break}}s&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0},t.prototype.dispose=function(){this.source.onload=null,this.source.onerror=null,i.prototype.dispose.call(this),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null},t.test=function(e){return typeof e=="string"||e instanceof HTMLImageElement},t}(pe),As=function(i){mt(t,i);function t(e,r){var n=this;return r=r||{},n=i.call(this,z.ADAPTER.createCanvas())||this,n._width=0,n._height=0,n.svg=e,n.scale=r.scale||1,n._overrideWidth=r.width,n._overrideHeight=r.height,n._resolve=null,n._crossorigin=r.crossorigin,n._load=null,r.autoLoad!==!1&&n.load(),n}return t.prototype.load=function(){var e=this;return this._load?this._load:(this._load=new Promise(function(r){if(e._resolve=function(){e.resize(e.source.width,e.source.height),r(e)},t.SVG_XML.test(e.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");e.svg="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e.svg)))}e._loadSvg()}),this._load)},t.prototype._loadSvg=function(){var e=this,r=new Image;pe.crossOrigin(r,this.svg,this._crossorigin),r.src=this.svg,r.onerror=function(n){e._resolve&&(r.onerror=null,e.onError.emit(n))},r.onload=function(){if(e._resolve){var n=r.width,s=r.height;if(!n||!s)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");var a=n*e.scale,o=s*e.scale;(e._overrideWidth||e._overrideHeight)&&(a=e._overrideWidth||e._overrideHeight/s*n,o=e._overrideHeight||e._overrideWidth/n*s),a=Math.round(a),o=Math.round(o);var h=e.source;h.width=a,h.height=o,h._pixiId="canvas_"+Ie(),h.getContext("2d").drawImage(r,0,0,n,s,0,0,a,o),e._resolve(),e._resolve=null}}},t.getSize=function(e){var r=t.SVG_SIZE.exec(e),n={};return r&&(n[r[1]]=Math.round(parseFloat(r[3])),n[r[5]]=Math.round(parseFloat(r[7]))),n},t.prototype.dispose=function(){i.prototype.dispose.call(this),this._resolve=null,this._crossorigin=null},t.test=function(e,r){return r==="svg"||typeof e=="string"&&e.startsWith("data:image/svg+xml")||typeof e=="string"&&t.SVG_XML.test(e)},t.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,t.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i,t}(pe),Ms=function(i){mt(t,i);function t(e,r){var n=this;if(r=r||{},!(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 a=e[0].src||e[0];pe.crossOrigin(s,a,r.crossorigin);for(var o=0;o<e.length;++o){var h=document.createElement("source"),u=e[o],l=u.src,c=u.mime;l=l||e[o];var f=l.split("?").shift().toLowerCase(),d=f.slice(f.lastIndexOf(".")+1);c=c||t.MIME_TYPES[d]||"video/"+d,h.src=l,h.type=c,s.appendChild(h)}e=s}return n=i.call(this,e)||this,n.noSubImage=!0,n._autoUpdate=!0,n._isConnectedToTicker=!1,n._updateFPS=r.updateFPS||0,n._msToNextUpdate=0,n.autoPlay=r.autoPlay!==!1,n._load=null,n._resolve=null,n._onCanPlay=n._onCanPlay.bind(n),n._onError=n._onError.bind(n),r.autoLoad!==!1&&n.load(),n}return t.prototype.update=function(e){if(!this.destroyed){var r=Ot.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-r),(!this._updateFPS||this._msToNextUpdate<=0)&&(i.prototype.update.call(this),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}},t.prototype.load=function(){var e=this;if(this._load)return this._load;var r=this.source;return(r.readyState===r.HAVE_ENOUGH_DATA||r.readyState===r.HAVE_FUTURE_DATA)&&r.width&&r.height&&(r.complete=!0),r.addEventListener("play",this._onPlayStart.bind(this)),r.addEventListener("pause",this._onPlayStop.bind(this)),this._isSourceReady()?this._onCanPlay():(r.addEventListener("canplay",this._onCanPlay),r.addEventListener("canplaythrough",this._onCanPlay),r.addEventListener("error",this._onError,!0)),this._load=new Promise(function(n){e.valid?n(e):(e._resolve=n,r.load())}),this._load},t.prototype._onError=function(e){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(e)},t.prototype._isSourcePlaying=function(){var e=this.source;return!e.paused&&!e.ended&&this._isSourceReady()},t.prototype._isSourceReady=function(){var e=this.source;return e.readyState>2},t.prototype._onPlayStart=function(){this.valid||this._onCanPlay(),this.autoUpdate&&!this._isConnectedToTicker&&(Ot.shared.add(this.update,this),this._isConnectedToTicker=!0)},t.prototype._onPlayStop=function(){this._isConnectedToTicker&&(Ot.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 r=this.valid;this.resize(e.videoWidth,e.videoHeight),!r&&this._resolve&&(this._resolve(this),this._resolve=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&e.play()},t.prototype.dispose=function(){this._isConnectedToTicker&&(Ot.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()),i.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?(Ot.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._isSourcePlaying()&&(Ot.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,r){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement||t.TYPES.indexOf(r)>-1},t.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],t.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"},t}(pe),Rs=function(i){mt(t,i);function t(e){return i.call(this,e)||this}return t.test=function(e){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&e instanceof ImageBitmap},t}(pe);jr.push(Di,Rs,Cs,Ms,As,Ke,Is,ws);var tu={__proto__:null,Resource:$e,BaseImageResource:pe,INSTALLED:jr,autoDetectResource:Ri,AbstractMultiResource:Oi,ArrayResource:ws,BufferResource:Ke,CanvasResource:Cs,CubeResource:Is,ImageResource:Di,SVGResource:As,VideoResource:Ms,ImageBitmapResource:Rs},Av=function(i){mt(t,i);function t(){return i!==null&&i.apply(this,arguments)||this}return t.prototype.upload=function(e,r,n){var s=e.gl;s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.alphaMode===Wt.UNPACK);var a=r.realWidth,o=r.realHeight;return n.width===a&&n.height===o?s.texSubImage2D(r.target,0,0,0,a,o,r.format,n.type,this.data):(n.width=a,n.height=o,s.texImage2D(r.target,0,n.internalFormat,a,o,0,r.format,n.type,this.data)),!0},t}(Ke),Fi=function(){function i(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 Dt("disposeFramebuffer"),this.multisample=xt.NONE}return Object.defineProperty(i.prototype,"colorTexture",{get:function(){return this.colorTextures[0]},enumerable:!1,configurable:!0}),i.prototype.addColorTexture=function(t,e){return t===void 0&&(t=0),this.colorTextures[t]=e||new lt(null,{scaleMode:ie.NEAREST,resolution:1,mipmap:zt.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this},i.prototype.addDepthTexture=function(t){return this.depthTexture=t||new lt(new Av(null,{width:this.width,height:this.height}),{scaleMode:ie.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:zt.OFF,format:H.DEPTH_COMPONENT,type:Q.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this},i.prototype.enableDepth=function(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this},i.prototype.enableStencil=function(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this},i.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 r=0;r<this.colorTextures.length;r++){var n=this.colorTextures[r],s=n.resolution;n.setSize(t/s,e/s)}if(this.depthTexture){var s=this.depthTexture.resolution;this.depthTexture.setSize(t/s,e/s)}}},i.prototype.dispose=function(){this.disposeRunner.emit(this,!1)},i.prototype.destroyDepthTexture=function(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)},i}(),Os=function(i){mt(t,i);function t(e){e===void 0&&(e={});var r=this;if(typeof e=="number"){var n=arguments[0],s=arguments[1],a=arguments[2],o=arguments[3];e={width:n,height:s,scaleMode:a,resolution:o}}return e.width=e.width||100,e.height=e.height||100,e.multisample=e.multisample!==void 0?e.multisample:xt.NONE,r=i.call(this,null,e)||this,r.mipmap=zt.OFF,r.valid=!0,r.clearColor=[0,0,0,0],r.framebuffer=new Fi(r.realWidth,r.realHeight).addColorTexture(0,r),r.framebuffer.multisample=e.multisample,r.maskStack=[],r.filterStack=[{}],r}return t.prototype.resize=function(e,r){this.framebuffer.resize(e*this.resolution,r*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)},t.prototype.dispose=function(){this.framebuffer.dispose(),i.prototype.dispose.call(this)},t.prototype.destroy=function(){i.prototype.destroy.call(this),this.framebuffer.destroyDepthTexture(),this.framebuffer=null},t}(lt),Ds=function(){function i(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}return i.prototype.set=function(t,e,r){var n=e.width,s=e.height;if(r){var a=t.width/2/n,o=t.height/2/s,h=t.x/n+a,u=t.y/s+o;r=Tt.add(r,Tt.NW),this.x0=h+a*Tt.uX(r),this.y0=u+o*Tt.uY(r),r=Tt.add(r,2),this.x1=h+a*Tt.uX(r),this.y1=u+o*Tt.uY(r),r=Tt.add(r,2),this.x2=h+a*Tt.uX(r),this.y2=u+o*Tt.uY(r),r=Tt.add(r,2),this.x3=h+a*Tt.uX(r),this.y3=u+o*Tt.uY(r)}else this.x0=t.x/n,this.y0=t.y/s,this.x1=(t.x+t.width)/n,this.y1=t.y/s,this.x2=(t.x+t.width)/n,this.y2=(t.y+t.height)/s,this.x3=t.x/n,this.y3=(t.y+t.height)/s;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3},i.prototype.toString=function(){return"[@pixi/core:TextureUvs "+("x0="+this.x0+" y0="+this.y0+" ")+("x1="+this.x1+" y1="+this.y1+" x2="+this.x2+" ")+("y2="+this.y2+" x3="+this.x3+" y3="+this.y3)+"]"},i}(),eu=new Ds;function Li(i){i.destroy=function(){},i.on=function(){},i.once=function(){},i.emit=function(){}}var it=function(i){mt(t,i);function t(e,r,n,s,a,o){var h=i.call(this)||this;if(h.noFrame=!1,r||(h.noFrame=!0,r=new ut(0,0,1,1)),e instanceof t&&(e=e.baseTexture),h.baseTexture=e,h._frame=r,h.trim=s,h.valid=!1,h._uvs=eu,h.uvMatrix=null,h.orig=n||r,h._rotate=Number(a||0),a===!0)h._rotate=2;else if(h._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");return h.defaultAnchor=o?new vt(o.x,o.y):new vt(0,0),h._updateID=0,h.textureCacheIds=[],e.valid?h.noFrame?e.valid&&h.onBaseTextureUpdated(e):h.frame=r:e.once("loaded",h.onBaseTextureUpdated,h),h.noFrame&&e.on("update",h.onBaseTextureUpdated,h),h}return t.prototype.update=function(){this.baseTexture.resource&&this.baseTexture.resource.update()},t.prototype.onBaseTextureUpdated=function(e){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=e.width,this._frame.height=e.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)},t.prototype.destroy=function(e){if(this.baseTexture){if(e){var r=this.baseTexture.resource;r&&r.url&&Gt[r.url]&&t.removeFromCache(r.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,t.removeFromCache(this),this.textureCacheIds=null},t.prototype.clone=function(){var e=this._frame.clone(),r=this._frame===this.orig?e:this.orig.clone(),n=new t(this.baseTexture,!this.noFrame&&e,r,this.trim&&this.trim.clone(),this.rotate,this.defaultAnchor);return this.noFrame&&(n._frame=e),n},t.prototype.updateUvs=function(){this._uvs===eu&&(this._uvs=new Ds),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++},t.from=function(e,r,n){r===void 0&&(r={}),n===void 0&&(n=z.STRICT_TEXTURE_CACHE);var s=typeof e=="string",a=null;if(s)a=e;else if(e instanceof lt){if(!e.cacheId){var o=r&&r.pixiIdPrefix||"pixiid";e.cacheId=o+"-"+Ie(),lt.addToCache(e,e.cacheId)}a=e.cacheId}else{if(!e._pixiId){var o=r&&r.pixiIdPrefix||"pixiid";e._pixiId=o+"_"+Ie()}a=e._pixiId}var h=Gt[a];if(s&&n&&!h)throw new Error('The cacheId "'+a+'" does not exist in TextureCache.');return!h&&!(e instanceof lt)?(r.resolution||(r.resolution=Gr(e)),h=new t(new lt(e,r)),h.baseTexture.cacheId=a,lt.addToCache(h.baseTexture,a),t.addToCache(h,a)):!h&&e instanceof lt&&(h=new t(e),t.addToCache(h,a)),h},t.fromURL=function(e,r){var n=Object.assign({autoLoad:!1},r==null?void 0:r.resourceOptions),s=t.from(e,Object.assign({resourceOptions:n},r),!1),a=s.baseTexture.resource;return s.baseTexture.valid?Promise.resolve(s):a.load().then(function(){return Promise.resolve(s)})},t.fromBuffer=function(e,r,n,s){return new t(lt.fromBuffer(e,r,n,s))},t.fromLoader=function(e,r,n,s){var a=new lt(e,Object.assign({scaleMode:z.SCALE_MODE,resolution:Gr(r)},s)),o=a.resource;o instanceof Di&&(o.url=r);var h=new t(a);return n||(n=r),lt.addToCache(h.baseTexture,n),t.addToCache(h,n),n!==r&&(lt.addToCache(h.baseTexture,r),t.addToCache(h,r)),h.baseTexture.valid?Promise.resolve(h):new Promise(function(u){h.baseTexture.once("loaded",function(){return u(h)})})},t.addToCache=function(e,r){r&&(e.textureCacheIds.indexOf(r)===-1&&e.textureCacheIds.push(r),Gt[r]&&console.warn("Texture added to the cache with an id ["+r+"] that already had an entry"),Gt[r]=e)},t.removeFromCache=function(e){if(typeof e=="string"){var r=Gt[e];if(r){var n=r.textureCacheIds.indexOf(e);return n>-1&&r.textureCacheIds.splice(n,1),delete Gt[e],r}}else if(e&&e.textureCacheIds){for(var s=0;s<e.textureCacheIds.length;++s)Gt[e.textureCacheIds[s]]===e&&delete Gt[e.textureCacheIds[s]];return e.textureCacheIds.length=0,e}return null},Object.defineProperty(t.prototype,"resolution",{get:function(){return this.baseTexture.resolution},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frame",{get:function(){return this._frame},set:function(e){this._frame=e,this.noFrame=!1;var r=e.x,n=e.y,s=e.width,a=e.height,o=r+s>this.baseTexture.width,h=n+a>this.baseTexture.height;if(o||h){var u=o&&h?"and":"or",l="X: "+r+" + "+s+" = "+(r+s)+" > "+this.baseTexture.width,c="Y: "+n+" + "+a+" = "+(n+a)+" > "+this.baseTexture.height;throw new Error("Texture Error: frame does not fit inside the base Texture dimensions: "+(l+" "+u+" "+c))}this.valid=s&&a&&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 lt),Li(t._EMPTY),Li(t._EMPTY.baseTexture)),t._EMPTY},enumerable:!1,configurable:!0}),Object.defineProperty(t,"WHITE",{get:function(){if(!t._WHITE){var e=z.ADAPTER.createCanvas(16,16),r=e.getContext("2d");e.width=16,e.height=16,r.fillStyle="white",r.fillRect(0,0,16,16),t._WHITE=new t(lt.from(e)),Li(t._WHITE),Li(t._WHITE.baseTexture)}return t._WHITE},enumerable:!1,configurable:!0}),t}(xe),Me=function(i){mt(t,i);function t(e,r){var n=i.call(this,e,r)||this;return n.valid=!0,n.filterFrame=null,n.filterPoolKey=null,n.updateUvs(),n}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,r,n){n===void 0&&(n=!0);var s=this.baseTexture.resolution,a=Math.round(e*s)/s,o=Math.round(r*s)/s;this.valid=a>0&&o>0,this._frame.width=this.orig.width=a,this._frame.height=this.orig.height=o,n&&this.baseTexture.resize(a,o),this.updateUvs()},t.prototype.setResolution=function(e){var r=this.baseTexture;r.resolution!==e&&(r.setResolution(e),this.resize(r.width,r.height,!1))},t.create=function(e){for(var r=arguments,n=[],s=1;s<arguments.length;s++)n[s-1]=r[s];return typeof e=="number"&&(Bt("6.0.0","Arguments (width, height, scaleMode, resolution) have been deprecated."),e={width:e,height:n[0],scaleMode:n[1],resolution:n[2]}),new t(new Os(e))},t}(it),ru=function(){function i(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}return i.prototype.createTexture=function(t,e,r){r===void 0&&(r=xt.NONE);var n=new Os(Object.assign({width:t,height:e,resolution:1,multisample:r},this.textureOptions));return new Me(n)},i.prototype.getOptimalTexture=function(t,e,r,n){r===void 0&&(r=1),n===void 0&&(n=xt.NONE);var s;t=Math.ceil(t*r-1e-6),e=Math.ceil(e*r-1e-6),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=kr(t),e=kr(e),s=((t&65535)<<16|e&65535)>>>0,n>1&&(s+=n*4294967296)):s=n>1?-n:-1,this.texturePool[s]||(this.texturePool[s]=[]);var a=this.texturePool[s].pop();return a||(a=this.createTexture(t,e,n)),a.filterPoolKey=s,a.setResolution(r),a},i.prototype.getFilterTexture=function(t,e,r){var n=this.getOptimalTexture(t.width,t.height,e||t.resolution,r||xt.NONE);return n.filterFrame=t.filterFrame,n},i.prototype.returnTexture=function(t){var e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)},i.prototype.returnFilterTexture=function(t){this.returnTexture(t)},i.prototype.clear=function(t){if(t=t!==!1,t)for(var e in this.texturePool){var r=this.texturePool[e];if(r)for(var n=0;n<r.length;n++)r[n].destroy(!0)}this.texturePool={}},i.prototype.setScreenSize=function(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(var e in this.texturePool)if(Number(e)<0){var r=this.texturePool[e];if(r)for(var n=0;n<r.length;n++)r[n].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}},i.SCREEN_KEY=-1,i}(),Fs=function(){function i(t,e,r,n,s,a,o){e===void 0&&(e=0),r===void 0&&(r=!1),n===void 0&&(n=Q.FLOAT),this.buffer=t,this.size=e,this.normalized=r,this.type=n,this.stride=s,this.start=a,this.instance=o}return i.prototype.destroy=function(){this.buffer=null},i.from=function(t,e,r,n,s){return new i(t,e,r,n,s)},i}(),Mv=0,Mt=function(){function i(t,e,r){e===void 0&&(e=!0),r===void 0&&(r=!1),this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=r,this.static=e,this.id=Mv++,this.disposeRunner=new Dt("disposeBuffer")}return i.prototype.update=function(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++},i.prototype.dispose=function(){this.disposeRunner.emit(this,!1)},i.prototype.destroy=function(){this.dispose(),this.data=null},Object.defineProperty(i.prototype,"index",{get:function(){return this.type===se.ELEMENT_ARRAY_BUFFER},set:function(t){this.type=t?se.ELEMENT_ARRAY_BUFFER:se.ARRAY_BUFFER},enumerable:!1,configurable:!0}),i.from=function(t){return t instanceof Array&&(t=new Float32Array(t)),new i(t)},i}(),Rv={Float32Array,Uint32Array,Int32Array,Uint8Array};function Ov(i,t){for(var e=0,r=0,n={},s=0;s<i.length;s++)r+=t[s],e+=i[s].length;for(var a=new ArrayBuffer(e*4),o=null,h=0,s=0;s<i.length;s++){var u=t[s],l=i[s],c=wi(l);n[c]||(n[c]=new Rv[c](a)),o=n[c];for(var f=0;f<l.length;f++){var d=(f/u|0)*r+h,v=f%u;o[d+v]=l[f]}h+=u}return new Float32Array(a)}var iu={5126:4,5123:2,5121:1},Dv=0,Fv={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array},vr=function(){function i(t,e){t===void 0&&(t=[]),e===void 0&&(e={}),this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=Dv++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new Dt("disposeGeometry"),this.refCount=0}return i.prototype.addAttribute=function(t,e,r,n,s,a,o,h){if(r===void 0&&(r=0),n===void 0&&(n=!1),h===void 0&&(h=!1),!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof Mt||(e instanceof Array&&(e=new Float32Array(e)),e=new Mt(e));var u=t.split("|");if(u.length>1){for(var l=0;l<u.length;l++)this.addAttribute(u[l],e,r,n,s);return this}var c=this.buffers.indexOf(e);return c===-1&&(this.buffers.push(e),c=this.buffers.length-1),this.attributes[t]=new Fs(c,r,n,s,a,o,h),this.instanced=this.instanced||h,this},i.prototype.getAttribute=function(t){return this.attributes[t]},i.prototype.getBuffer=function(t){return this.buffers[this.getAttribute(t).buffer]},i.prototype.addIndex=function(t){return t instanceof Mt||(t instanceof Array&&(t=new Uint16Array(t)),t=new Mt(t)),t.type=se.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.indexOf(t)===-1&&this.buffers.push(t),this},i.prototype.getIndex=function(){return this.indexBuffer},i.prototype.interleave=function(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;var t=[],e=[],r=new Mt,n;for(n in this.attributes){var s=this.attributes[n],a=this.buffers[s.buffer];t.push(a.data),e.push(s.size*iu[s.type]/4),s.buffer=0}for(r.data=Ov(t,e),n=0;n<this.buffers.length;n++)this.buffers[n]!==this.indexBuffer&&this.buffers[n].destroy();return this.buffers=[r],this.indexBuffer&&this.buffers.push(this.indexBuffer),this},i.prototype.getSize=function(){for(var t in this.attributes){var e=this.attributes[t],r=this.buffers[e.buffer];return r.data.length/(e.stride/4||e.size)}return 0},i.prototype.dispose=function(){this.disposeRunner.emit(this,!1)},i.prototype.destroy=function(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null},i.prototype.clone=function(){for(var t=new i,e=0;e<this.buffers.length;e++)t.buffers[e]=new Mt(this.buffers[e].data.slice(0));for(var e in this.attributes){var r=this.attributes[e];t.attributes[e]=new Fs(r.buffer,r.size,r.normalized,r.type,r.stride,r.start,r.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=se.ELEMENT_ARRAY_BUFFER),t},i.merge=function(t){for(var e=new i,r=[],n=[],s=[],a,o=0;o<t.length;o++){a=t[o];for(var h=0;h<a.buffers.length;h++)n[h]=n[h]||0,n[h]+=a.buffers[h].data.length,s[h]=0}for(var o=0;o<a.buffers.length;o++)r[o]=new Fv[wi(a.buffers[o].data)](n[o]),e.buffers[o]=new Mt(r[o]);for(var o=0;o<t.length;o++){a=t[o];for(var h=0;h<a.buffers.length;h++)r[h].set(a.buffers[h].data,s[h]),s[h]+=a.buffers[h].data.length}if(e.attributes=a.attributes,a.indexBuffer){e.indexBuffer=e.buffers[a.buffers.indexOf(a.indexBuffer)],e.indexBuffer.type=se.ELEMENT_ARRAY_BUFFER;for(var u=0,l=0,c=0,f=0,o=0;o<a.buffers.length;o++)if(a.buffers[o]!==a.indexBuffer){f=o;break}for(var o in a.attributes){var d=a.attributes[o];(d.buffer|0)===f&&(l+=d.size*iu[d.type]/4)}for(var o=0;o<t.length;o++){for(var v=t[o].indexBuffer.data,h=0;h<v.length;h++)e.indexBuffer.data[h+c]+=u;u+=t[o].buffers[f].data.length/l,c+=v.length}}return e},i}(),nu=function(i){mt(t,i);function t(){var e=i.call(this)||this;return e.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2]),e}return t}(vr),Ls=function(i){mt(t,i);function t(){var e=i.call(this)||this;return e.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),e.uvs=new Float32Array([0,0,1,0,1,1,0,1]),e.vertexBuffer=new Mt(e.vertices),e.uvBuffer=new Mt(e.uvs),e.addAttribute("aVertexPosition",e.vertexBuffer).addAttribute("aTextureCoord",e.uvBuffer).addIndex([0,1,2,0,2,3]),e}return t.prototype.map=function(e,r){var n=0,s=0;return this.uvs[0]=n,this.uvs[1]=s,this.uvs[2]=n+r.width/e.width,this.uvs[3]=s,this.uvs[4]=n+r.width/e.width,this.uvs[5]=s+r.height/e.height,this.uvs[6]=n,this.uvs[7]=s+r.height/e.height,n=r.x,s=r.y,this.vertices[0]=n,this.vertices[1]=s,this.vertices[2]=n+r.width,this.vertices[3]=s,this.vertices[4]=n+r.width,this.vertices[5]=s+r.height,this.vertices[6]=n,this.vertices[7]=s+r.height,this.invalidate(),this},t.prototype.invalidate=function(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this},t}(vr),Lv=0,Re=function(){function i(t,e,r){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=Lv++,this.static=!!e,this.ubo=!!r,t instanceof Mt?(this.buffer=t,this.buffer.type=se.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new Mt(new Float32Array(1)),this.buffer.type=se.UNIFORM_BUFFER,this.autoManage=!0))}return i.prototype.update=function(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()},i.prototype.add=function(t,e,r){if(!this.ubo)this.uniforms[t]=new i(e,r);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")},i.from=function(t,e,r){return new i(t,e,r)},i.uboFrom=function(t,e){return new i(t,e??!0,!0)},i}(),su=function(){function i(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=xt.NONE,this.sourceFrame=new ut,this.destinationFrame=new ut,this.bindingSourceFrame=new ut,this.bindingDestinationFrame=new ut,this.filters=[],this.transform=null}return i.prototype.clear=function(){this.target=null,this.filters=null,this.renderTexture=null},i}(),Bi=[new vt,new vt,new vt,new vt],Bs=new bt,Ns=function(){function i(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new ru,this.texturePool.setScreenSize(t.view),this.statePool=[],this.quad=new nu,this.quadUv=new Ls,this.tempRect=new ut,this.activeState={},this.globalUniforms=new Re({outputFrame:new ut,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}return i.prototype.push=function(t,e){for(var r,n,s=this.renderer,a=this.defaultFilterStack,o=this.statePool.pop()||new su,h=this.renderer.renderTexture,u=e[0].resolution,l=e[0].multisample,c=e[0].padding,f=e[0].autoFit,d=(r=e[0].legacy)!==null&&r!==void 0?r:!0,v=1;v<e.length;v++){var _=e[v];u=Math.min(u,_.resolution),l=Math.min(l,_.multisample),c=this.useMaxPadding?Math.max(c,_.padding):c+_.padding,f=f&&_.autoFit,d=d||((n=_.legacy)!==null&&n!==void 0?n:!0)}a.length===1&&(this.defaultFilterStack[0].renderTexture=h.current),a.push(o),o.resolution=u,o.multisample=l,o.legacy=d,o.target=t,o.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),o.sourceFrame.pad(c);var p=this.tempRect.copyFrom(h.sourceFrame);s.projection.transform&&this.transformAABB(Bs.copyFrom(s.projection.transform).invert(),p),f?(o.sourceFrame.fit(p),(o.sourceFrame.width<=0||o.sourceFrame.height<=0)&&(o.sourceFrame.width=0,o.sourceFrame.height=0)):o.sourceFrame.intersects(p)||(o.sourceFrame.width=0,o.sourceFrame.height=0),this.roundFrame(o.sourceFrame,h.current?h.current.resolution:s.resolution,h.sourceFrame,h.destinationFrame,s.projection.transform),o.renderTexture=this.getOptimalFilterTexture(o.sourceFrame.width,o.sourceFrame.height,u,l),o.filters=e,o.destinationFrame.width=o.renderTexture.width,o.destinationFrame.height=o.renderTexture.height;var g=this.tempRect;g.x=0,g.y=0,g.width=o.sourceFrame.width,g.height=o.sourceFrame.height,o.renderTexture.filterFrame=o.sourceFrame,o.bindingSourceFrame.copyFrom(h.sourceFrame),o.bindingDestinationFrame.copyFrom(h.destinationFrame),o.transform=s.projection.transform,s.projection.transform=null,h.bind(o.renderTexture,o.sourceFrame,g),s.framebuffer.clear(0,0,0,0)},i.prototype.pop=function(){var t=this.defaultFilterStack,e=t.pop(),r=e.filters;this.activeState=e;var n=this.globalUniforms.uniforms;n.outputFrame=e.sourceFrame,n.resolution=e.resolution;var s=n.inputSize,a=n.inputPixel,o=n.inputClamp;if(s[0]=e.destinationFrame.width,s[1]=e.destinationFrame.height,s[2]=1/s[0],s[3]=1/s[1],a[0]=Math.round(s[0]*e.resolution),a[1]=Math.round(s[1]*e.resolution),a[2]=1/a[0],a[3]=1/a[1],o[0]=.5*a[2],o[1]=.5*a[3],o[2]=e.sourceFrame.width*s[2]-.5*a[2],o[3]=e.sourceFrame.height*s[3]-.5*a[3],e.legacy){var h=n.filterArea;h[0]=e.destinationFrame.width,h[1]=e.destinationFrame.height,h[2]=e.sourceFrame.x,h[3]=e.sourceFrame.y,n.filterClamp=n.inputClamp}this.globalUniforms.update();var u=t[t.length-1];if(this.renderer.framebuffer.blit(),r.length===1)r[0].apply(this,e.renderTexture,u.renderTexture,Yt.BLEND,e),this.returnFilterTexture(e.renderTexture);else{var l=e.renderTexture,c=this.getOptimalFilterTexture(l.width,l.height,e.resolution);c.filterFrame=l.filterFrame;var f=0;for(f=0;f<r.length-1;++f){f===1&&e.multisample>1&&(c=this.getOptimalFilterTexture(l.width,l.height,e.resolution),c.filterFrame=l.filterFrame),r[f].apply(this,l,c,Yt.CLEAR,e);var d=l;l=c,c=d}r[f].apply(this,l,u.renderTexture,Yt.BLEND,e),f>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(l),this.returnFilterTexture(c)}e.clear(),this.statePool.push(e)},i.prototype.bindAndClear=function(t,e){e===void 0&&(e=Yt.CLEAR);var r=this.renderer,n=r.renderTexture,s=r.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 a=this.tempRect;a.x=0,a.y=0,a.width=t.filterFrame.width,a.height=t.filterFrame.height,n.bind(t,t.filterFrame,a)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?n.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);var o=s.stateId&1||this.forceClear;(e===Yt.CLEAR||e===Yt.BLIT&&o)&&this.renderer.framebuffer.clear(0,0,0,0)},i.prototype.applyFilter=function(t,e,r,n){var s=this.renderer;s.state.set(t.state),this.bindAndClear(r,n),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(jt.TRIANGLES)):(s.geometry.bind(this.quad),s.geometry.draw(jt.TRIANGLE_STRIP))},i.prototype.calculateSpriteMatrix=function(t,e){var r=this.activeState,n=r.sourceFrame,s=r.destinationFrame,a=e._texture.orig,o=t.set(s.width,0,0,s.height,n.x,n.y),h=e.worldTransform.copyTo(bt.TEMP_MATRIX);return h.invert(),o.prepend(h),o.scale(1/a.width,1/a.height),o.translate(e.anchor.x,e.anchor.y),o},i.prototype.destroy=function(){this.renderer=null,this.texturePool.clear(!1)},i.prototype.getOptimalFilterTexture=function(t,e,r,n){return r===void 0&&(r=1),n===void 0&&(n=xt.NONE),this.texturePool.getOptimalTexture(t,e,r,n)},i.prototype.getFilterTexture=function(t,e,r){if(typeof t=="number"){var n=t;t=e,e=n}t=t||this.activeState.renderTexture;var s=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,r||xt.NONE);return s.filterFrame=t.filterFrame,s},i.prototype.returnFilterTexture=function(t){this.texturePool.returnTexture(t)},i.prototype.emptyPool=function(){this.texturePool.clear(!0)},i.prototype.resize=function(){this.texturePool.setScreenSize(this.renderer.view)},i.prototype.transformAABB=function(t,e){var r=Bi[0],n=Bi[1],s=Bi[2],a=Bi[3];r.set(e.left,e.top),n.set(e.left,e.bottom),s.set(e.right,e.top),a.set(e.right,e.bottom),t.apply(r,r),t.apply(n,n),t.apply(s,s),t.apply(a,a);var o=Math.min(r.x,n.x,s.x,a.x),h=Math.min(r.y,n.y,s.y,a.y),u=Math.max(r.x,n.x,s.x,a.x),l=Math.max(r.y,n.y,s.y,a.y);e.x=o,e.y=h,e.width=u-o,e.height=l-h},i.prototype.roundFrame=function(t,e,r,n,s){if(!(t.width<=0||t.height<=0||r.width<=0||r.height<=0)){if(s){var a=s.a,o=s.b,h=s.c,u=s.d;if((Math.abs(o)>1e-4||Math.abs(h)>1e-4)&&(Math.abs(a)>1e-4||Math.abs(u)>1e-4))return}s=s?Bs.copyFrom(s):Bs.identity(),s.translate(-r.x,-r.y).scale(n.width/r.width,n.height/r.height).translate(n.x,n.y),this.transformAABB(s,t),t.ceil(e),this.transformAABB(s.invert(),t)}},i}(),zr=function(){function i(t){this.renderer=t}return i.prototype.flush=function(){},i.prototype.destroy=function(){this.renderer=null},i.prototype.start=function(){},i.prototype.stop=function(){this.flush()},i.prototype.render=function(t){},i}(),Us=function(){function i(t){this.renderer=t,this.emptyRenderer=new zr(t),this.currentRenderer=this.emptyRenderer}return i.prototype.setObjectRenderer=function(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())},i.prototype.flush=function(){this.setObjectRenderer(this.emptyRenderer)},i.prototype.reset=function(){this.setObjectRenderer(this.emptyRenderer)},i.prototype.copyBoundTextures=function(t,e){for(var r=this.renderer.texture.boundTextures,n=e-1;n>=0;--n)t[n]=r[n]||null,t[n]&&(t[n]._batchLocation=n)},i.prototype.boundArray=function(t,e,r,n){for(var s=t.elements,a=t.ids,o=t.count,h=0,u=0;u<o;u++){var l=s[u],c=l._batchLocation;if(c>=0&&c<n&&e[c]===l){a[u]=c;continue}for(;h<n;){var f=e[h];if(f&&f._batchEnabled===r&&f._batchLocation===h){h++;continue}a[u]=h,l._batchLocation=h,e[h]=l;break}}},i.prototype.destroy=function(){this.renderer=null},i}(),au=0,ks=function(){function i(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this),t.view.addEventListener("webglcontextlost",this.handleContextLost,!1),t.view.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}return Object.defineProperty(i.prototype,"isLost",{get:function(){return!this.gl||this.gl.isContextLost()},enumerable:!1,configurable:!0}),i.prototype.contextChange=function(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=au++},i.prototype.initFromContext=function(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=au++,this.renderer.runners.contextChange.emit(t)},i.prototype.initFromOptions=function(t){var e=this.createContext(this.renderer.view,t);this.initFromContext(e)},i.prototype.createContext=function(t,e){var r;if(z.PREFER_ENV>=Ut.WEBGL2&&(r=t.getContext("webgl2",e)),r)this.webGLVersion=2;else if(this.webGLVersion=1,r=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!r)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=r,this.getExtensions(),this.gl},i.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")})},i.prototype.handleContextLost=function(t){var e=this;t.preventDefault(),setTimeout(function(){e.gl.isContextLost()&&e.extensions.loseContext&&e.extensions.loseContext.restoreContext()},0)},i.prototype.handleContextRestored=function(){this.renderer.runners.contextChange.emit(this.gl)},i.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()},i.prototype.postrender=function(){this.renderer.renderingToScreen&&this.gl.flush()},i.prototype.validateContext=function(t){var e=t.getContextAttributes(),r="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;r&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");var n=r||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=n,n||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")},i}(),ou=function(){function i(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=xt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}return i}(),Bv=new ut,Gs=function(){function i(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Fi(10,10),this.msaaSamples=null}return i.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 ut,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){var e=this.renderer.context.extensions.drawBuffers,r=this.renderer.context.extensions.depthTexture;z.PREFER_ENV===Ut.WEBGL_LEGACY&&(e=null,r=null),e?t.drawBuffers=function(n){return e.drawBuffersWEBGL(n)}:(this.hasMRT=!1,t.drawBuffers=function(){}),r||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)},i.prototype.bind=function(t,e,r){r===void 0&&(r=0);var n=this.gl;if(t){var s=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,n.bindFramebuffer(n.FRAMEBUFFER,s.framebuffer)),s.mipLevel!==r&&(t.dirtyId++,t.dirtyFormat++,s.mipLevel=r),s.dirtyId!==t.dirtyId&&(s.dirtyId=t.dirtyId,s.dirtyFormat!==t.dirtyFormat?(s.dirtyFormat=t.dirtyFormat,s.dirtySize=t.dirtySize,this.updateFramebuffer(t,r)):s.dirtySize!==t.dirtySize&&(s.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(var a=0;a<t.colorTextures.length;a++){var o=t.colorTextures[a];this.renderer.texture.unbind(o.parentTextureArray||o)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){var h=e.width>>r,u=e.height>>r,l=h/e.width;this.setViewport(e.x*l,e.y*l,h,u)}else{var h=t.width>>r,u=t.height>>r;this.setViewport(0,0,h,u)}}else this.current&&(this.current=null,n.bindFramebuffer(n.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)},i.prototype.setViewport=function(t,e,r,n){var s=this.viewport;t=Math.round(t),e=Math.round(e),r=Math.round(r),n=Math.round(n),(s.width!==r||s.height!==n||s.x!==t||s.y!==e)&&(s.x=t,s.y=e,s.width=r,s.height=n,this.gl.viewport(t,e,r,n))},Object.defineProperty(i.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}),i.prototype.clear=function(t,e,r,n,s){s===void 0&&(s=Fr.COLOR|Fr.DEPTH);var a=this.gl;a.clearColor(t,e,r,n),a.clear(s)},i.prototype.initFramebuffer=function(t){var e=this.gl,r=new ou(e.createFramebuffer());return r.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=r,this.managedFramebuffers.push(t),t.disposeRunner.add(this),r},i.prototype.resizeFramebuffer=function(t){var e=this.gl,r=t.glFramebuffers[this.CONTEXT_UID];r.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,r.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,r.multisample,e.RGBA8,t.width,t.height)),r.stencil&&(e.bindRenderbuffer(e.RENDERBUFFER,r.stencil),r.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,r.multisample,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,t.width,t.height));var n=t.colorTextures,s=n.length;e.drawBuffers||(s=Math.min(s,1));for(var a=0;a<s;a++){var o=n[a],h=o.parentTextureArray||o;this.renderer.texture.bind(h,0)}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)},i.prototype.updateFramebuffer=function(t,e){var r=this.gl,n=t.glFramebuffers[this.CONTEXT_UID],s=t.colorTextures,a=s.length;r.drawBuffers||(a=Math.min(a,1)),n.multisample>1&&this.canMultisampleFramebuffer(t)?(n.msaaBuffer=n.msaaBuffer||r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,n.msaaBuffer),r.renderbufferStorageMultisample(r.RENDERBUFFER,n.multisample,r.RGBA8,t.width,t.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,n.msaaBuffer)):n.msaaBuffer&&(r.deleteRenderbuffer(n.msaaBuffer),n.msaaBuffer=null,n.blitFramebuffer&&(n.blitFramebuffer.dispose(),n.blitFramebuffer=null));for(var o=[],h=0;h<a;h++){var u=s[h],l=u.parentTextureArray||u;this.renderer.texture.bind(l,0),!(h===0&&n.msaaBuffer)&&(r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+h,u.target,l._glTextures[this.CONTEXT_UID].texture,e),o.push(r.COLOR_ATTACHMENT0+h))}if(o.length>1&&r.drawBuffers(o),t.depthTexture){var c=this.writeDepthTexture;if(c){var f=t.depthTexture;this.renderer.texture.bind(f,0),r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,f._glTextures[this.CONTEXT_UID].texture,e)}}(t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)?(n.stencil=n.stencil||r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,n.stencil),n.msaaBuffer?r.renderbufferStorageMultisample(r.RENDERBUFFER,n.multisample,r.DEPTH24_STENCIL8,t.width,t.height):r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t.width,t.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,n.stencil)):n.stencil&&(r.deleteRenderbuffer(n.stencil),n.stencil=null)},i.prototype.canMultisampleFramebuffer=function(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture},i.prototype.detectSamples=function(t){var e=this.msaaSamples,r=xt.NONE;if(t<=1||e===null)return r;for(var n=0;n<e.length;n++)if(e[n]<=t){r=e[n];break}return r===1&&(r=xt.NONE),r},i.prototype.blit=function(t,e,r){var n=this,s=n.current,a=n.renderer,o=n.gl,h=n.CONTEXT_UID;if(a.context.webGLVersion===2&&s){var u=s.glFramebuffers[h];if(u){if(!t){if(!u.msaaBuffer)return;var l=s.colorTextures[0];if(!l)return;u.blitFramebuffer||(u.blitFramebuffer=new Fi(s.width,s.height),u.blitFramebuffer.addColorTexture(0,l)),t=u.blitFramebuffer,t.colorTextures[0]!==l&&(t.colorTextures[0]=l,t.dirtyId++,t.dirtyFormat++),(t.width!==s.width||t.height!==s.height)&&(t.width=s.width,t.height=s.height,t.dirtyId++,t.dirtySize++)}e||(e=Bv,e.width=s.width,e.height=s.height),r||(r=e);var c=e.width===r.width&&e.height===r.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,u.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,r.left,r.top,r.right,r.bottom,o.COLOR_BUFFER_BIT,c?o.NEAREST:o.LINEAR)}}},i.prototype.disposeFramebuffer=function(t,e){var r=t.glFramebuffers[this.CONTEXT_UID],n=this.gl;if(r){delete t.glFramebuffers[this.CONTEXT_UID];var s=this.managedFramebuffers.indexOf(t);s>=0&&this.managedFramebuffers.splice(s,1),t.disposeRunner.remove(this),e||(n.deleteFramebuffer(r.framebuffer),r.msaaBuffer&&n.deleteRenderbuffer(r.msaaBuffer),r.stencil&&n.deleteRenderbuffer(r.stencil)),r.blitFramebuffer&&r.blitFramebuffer.dispose()}},i.prototype.disposeAll=function(t){var e=this.managedFramebuffers;this.managedFramebuffers=[];for(var r=0;r<e.length;r++)this.disposeFramebuffer(e[r],t)},i.prototype.forceStencil=function(){var t=this.current;if(t){var e=t.glFramebuffers[this.CONTEXT_UID];if(!(!e||e.stencil)){t.stencil=!0;var r=t.width,n=t.height,s=this.gl,a=s.createRenderbuffer();s.bindRenderbuffer(s.RENDERBUFFER,a),e.msaaBuffer?s.renderbufferStorageMultisample(s.RENDERBUFFER,e.multisample,s.DEPTH24_STENCIL8,r,n):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,r,n),e.stencil=a,s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,a)}}},i.prototype.reset=function(){this.current=this.unknownFramebuffer,this.viewport=new ut},i.prototype.destroy=function(){this.renderer=null},i}(),Xs={5126:4,5123:2,5121:1},Hs=function(){function i(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}return i.prototype.contextChange=function(){this.disposeAll(!0);var t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,e.webGLVersion!==2){var r=this.renderer.context.extensions.vertexArrayObject;z.PREFER_ENV===Ut.WEBGL_LEGACY&&(r=null),r?(t.createVertexArray=function(){return r.createVertexArrayOES()},t.bindVertexArray=function(s){return r.bindVertexArrayOES(s)},t.deleteVertexArray=function(s){return r.deleteVertexArrayOES(s)}):(this.hasVao=!1,t.createVertexArray=function(){return null},t.bindVertexArray=function(){return null},t.deleteVertexArray=function(){return null})}if(e.webGLVersion!==2){var n=t.getExtension("ANGLE_instanced_arrays");n?(t.vertexAttribDivisor=function(s,a){return n.vertexAttribDivisorANGLE(s,a)},t.drawElementsInstanced=function(s,a,o,h,u){return n.drawElementsInstancedANGLE(s,a,o,h,u)},t.drawArraysInstanced=function(s,a,o,h){return n.drawArraysInstancedANGLE(s,a,o,h)}):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex},i.prototype.bind=function(t,e){e=e||this.renderer.shader.shader;var r=this.gl,n=t.glVertexArrayObjects[this.CONTEXT_UID],s=!1;n||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=n={},s=!0);var a=n[e.program.id]||this.initGeometryVao(t,e,s);this._activeGeometry=t,this._activeVao!==a&&(this._activeVao=a,this.hasVao?r.bindVertexArray(a):this.activateVao(t,e.program)),this.updateBuffers()},i.prototype.reset=function(){this.unbind()},i.prototype.updateBuffers=function(){for(var t=this._activeGeometry,e=this.renderer.buffer,r=0;r<t.buffers.length;r++){var n=t.buffers[r];e.update(n)}},i.prototype.checkCompatibility=function(t,e){var r=t.attributes,n=e.attributeData;for(var s in n)if(!r[s])throw new Error('shader and geometry incompatible, geometry missing the "'+s+'" attribute')},i.prototype.getSignature=function(t,e){var r=t.attributes,n=e.attributeData,s=["g",t.id];for(var a in r)n[a]&&s.push(a,n[a].location);return s.join("-")},i.prototype.initGeometryVao=function(t,e,r){r===void 0&&(r=!0);var n=this.gl,s=this.CONTEXT_UID,a=this.renderer.buffer,o=e.program;o.glPrograms[s]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,o);var h=this.getSignature(t,o),u=t.glVertexArrayObjects[this.CONTEXT_UID],l=u[h];if(l)return u[o.id]=l,l;var c=t.buffers,f=t.attributes,d={},v={};for(var _ in c)d[_]=0,v[_]=0;for(var _ in f)!f[_].size&&o.attributeData[_]?f[_].size=o.attributeData[_].size:f[_].size||console.warn("PIXI Geometry attribute '"+_+"' size cannot be determined (likely the bound shader does not have the attribute)"),d[f[_].buffer]+=f[_].size*Xs[f[_].type];for(var _ in f){var p=f[_],g=p.size;p.stride===void 0&&(d[p.buffer]===g*Xs[p.type]?p.stride=0:p.stride=d[p.buffer]),p.start===void 0&&(p.start=v[p.buffer],v[p.buffer]+=g*Xs[p.type])}l=n.createVertexArray(),n.bindVertexArray(l);for(var y=0;y<c.length;y++){var T=c[y];a.bind(T),r&&T._glBuffers[s].refCount++}return this.activateVao(t,o),this._activeVao=l,u[o.id]=l,u[h]=l,l},i.prototype.disposeGeometry=function(t,e){var r;if(this.managedGeometries[t.id]){delete this.managedGeometries[t.id];var n=t.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,a=t.buffers,o=(r=this.renderer)===null||r===void 0?void 0:r.buffer;if(t.disposeRunner.remove(this),!!n){if(o)for(var h=0;h<a.length;h++){var u=a[h]._glBuffers[this.CONTEXT_UID];u&&(u.refCount--,u.refCount===0&&!e&&o.dispose(a[h],e))}if(!e){for(var l in n)if(l[0]==="g"){var c=n[l];this._activeVao===c&&this.unbind(),s.deleteVertexArray(c)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}},i.prototype.disposeAll=function(t){for(var e=Object.keys(this.managedGeometries),r=0;r<e.length;r++)this.disposeGeometry(this.managedGeometries[e[r]],t)},i.prototype.activateVao=function(t,e){var r=this.gl,n=this.CONTEXT_UID,s=this.renderer.buffer,a=t.buffers,o=t.attributes;t.indexBuffer&&s.bind(t.indexBuffer);var h=null;for(var u in o){var l=o[u],c=a[l.buffer],f=c._glBuffers[n];if(e.attributeData[u]){h!==f&&(s.bind(c),h=f);var d=e.attributeData[u].location;if(r.enableVertexAttribArray(d),r.vertexAttribPointer(d,l.size,l.type||r.FLOAT,l.normalized,l.stride,l.start),l.instance)if(this.hasInstance)r.vertexAttribDivisor(d,1);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}},i.prototype.draw=function(t,e,r,n){var s=this.gl,a=this._activeGeometry;if(a.indexBuffer){var o=a.indexBuffer.data.BYTES_PER_ELEMENT,h=o===2?s.UNSIGNED_SHORT:s.UNSIGNED_INT;o===2||o===4&&this.canUseUInt32ElementIndex?a.instanced?s.drawElementsInstanced(t,e||a.indexBuffer.data.length,h,(r||0)*o,n||1):s.drawElements(t,e||a.indexBuffer.data.length,h,(r||0)*o):console.warn("unsupported index buffer type: uint32")}else a.instanced?s.drawArraysInstanced(t,r,e||a.getSize(),n||1):s.drawArrays(t,r,e||a.getSize());return this},i.prototype.unbind=function(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null},i.prototype.destroy=function(){this.renderer=null},i}(),hu=function(){function i(t){t===void 0&&(t=null),this.type=It.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=z.FILTER_MULTISAMPLE,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}return Object.defineProperty(i.prototype,"filter",{get:function(){return this._filters?this._filters[0]:null},set:function(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null},enumerable:!1,configurable:!0}),i.prototype.reset=function(){this.pooled&&(this.maskObject=null,this.type=It.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null},i.prototype.copyCountersOrReset=function(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)},i}();function uu(i,t,e){var r=i.createShader(t);return i.shaderSource(r,e),i.compileShader(r),r}function lu(i,t){var e=i.getShaderSource(t).split(`
14
- `).map(function(u,l){return l+": "+u}),r=i.getShaderInfoLog(t),n=r.split(`
15
- `),s={},a=n.map(function(u){return parseFloat(u.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))}).filter(function(u){return u&&!s[u]?(s[u]=!0,!0):!1}),o=[""];a.forEach(function(u){e[u-1]="%c"+e[u-1]+"%c",o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});var h=e.join(`
16
- `);o[0]=h,console.error(r),console.groupCollapsed("click to view full shader code"),console.warn.apply(console,o),console.groupEnd()}function Nv(i,t,e,r){i.getProgramParameter(t,i.LINK_STATUS)||(i.getShaderParameter(e,i.COMPILE_STATUS)||lu(i,e),i.getShaderParameter(r,i.COMPILE_STATUS)||lu(i,r),console.error("PixiJS Error: Could not initialize shader."),i.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",i.getProgramInfoLog(t)))}function Vs(i){for(var t=new Array(i),e=0;e<t.length;e++)t[e]=!1;return t}function fu(i,t){switch(i){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return Vs(2*t);case"bvec3":return Vs(3*t);case"bvec4":return Vs(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var cu={},Wr=cu;function du(){if(Wr===cu||Wr&&Wr.isContextLost()){var i=z.ADAPTER.createCanvas(),t=void 0;z.PREFER_ENV>=Ut.WEBGL2&&(t=i.getContext("webgl2",{})),t||(t=i.getContext("webgl",{})||i.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),Wr=t}return Wr}var Ni;function Uv(){if(!Ni){Ni=kt.MEDIUM;var i=du();if(i&&i.getShaderPrecisionFormat){var t=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT);Ni=t.precision?kt.HIGH:kt.MEDIUM}}return Ni}function pu(i,t,e){if(i.substring(0,9)!=="precision"){var r=t;return t===kt.HIGH&&e!==kt.HIGH&&(r=kt.MEDIUM),"precision "+r+` float;
17
- `+i}else if(e!==kt.HIGH&&i.substring(0,15)==="precision highp")return i.replace("precision highp","precision mediump");return i}var kv={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 vu(i){return kv[i]}var Ui=null,_u={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 gu(i,t){if(!Ui){var e=Object.keys(_u);Ui={};for(var r=0;r<e.length;++r){var n=e[r];Ui[i[n]]=_u[n]}}return Ui[t]}var Ze=[{test:function(i){return i.type==="float"&&i.size===1&&!i.isArray},code:function(i){return`
18
- if(uv["`+i+'"] !== ud["'+i+`"].value)
8
+ `),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
9
+ Deprecated since v${s}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
10
+ Deprecated since v${s}`),console.warn(i))),yl[t]=!0}const os={get parse(){return ot("7.3.0","utils.url.parse is deprecated, use native URL API instead."),ra.parse},get format(){return ot("7.3.0","utils.url.format is deprecated, use native URL API instead."),ra.format},get resolve(){return ot("7.3.0","utils.url.resolve is deprecated, use native URL API instead."),ra.resolve}};function de(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function or(s){return s.split("?")[0].split("#")[0]}function zf(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wf(s,t,e){return s.replace(new RegExp(zf(t),"g"),e)}function $f(s,t){let e="",i=0,r=-1,n=0,a=-1;for(let o=0;o<=s.length;++o){if(o<s.length)a=s.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(r===o-1||n===1))if(r!==o-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),r=o,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,r=o,n=0;continue}}}else e.length>0?e+=`/${s.slice(r+1,o)}`:e=s.slice(r+1,o),i=o-r-1;r=o,n=0}else a===46&&n!==-1?++n:n=-1}return e}const Rt={toPosix(s){return Wf(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){de(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(de(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=or(this.toPosix(t??q.ADAPTER.getBaseUrl())),r=or(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?Rt.join(r,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(de(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=$f(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return de(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e<s.length;++e){const i=s[e];if(de(i),i.length>0)if(t===void 0)t=i;else{const r=s[e-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(de(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,r=!0;const n=this.getProtocol(s),a=s;s=s.slice(n.length);for(let o=s.length-1;o>=1;--o)if(t=s.charCodeAt(o),t===47){if(!r){i=o;break}}else r=!1;return i===-1?e?"/":this.isUrl(a)?n+s:n:e&&i===1?"//":n+s.slice(0,i)},rootname(s){de(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){de(s),t&&de(t),s=or(this.toPosix(s));let e=0,i=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let a=t.length-1,o=-1;for(n=s.length-1;n>=0;--n){const h=s.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else o===-1&&(r=!1,o=n+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(i=n):(a=-1,i=o))}return e===i?i=o:i===-1&&(i=s.length),s.slice(e,i)}for(n=s.length-1;n>=0;--n)if(s.charCodeAt(n)===47){if(!r){e=n+1;break}}else i===-1&&(r=!1,i=n+1);return i===-1?"":s.slice(e,i)},extname(s){de(s),s=or(this.toPosix(s));let t=-1,e=0,i=-1,r=!0,n=0;for(let a=s.length-1;a>=0;--a){const o=s.charCodeAt(a);if(o===47){if(!r){e=a+1;break}continue}i===-1&&(r=!1,i=a+1),o===46?t===-1?t=a:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":s.slice(t,i)},parse(s){de(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=or(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let r;t.root=this.rootname(s),i||this.hasProtocol(s)?r=1:r=0;let n=-1,a=0,o=-1,h=!0,l=s.length-1,u=0;for(;l>=r;--l){if(e=s.charCodeAt(l),e===47){if(!h){a=l+1;break}continue}o===-1&&(h=!1,o=l+1),e===46?n===-1?n=l:u!==1&&(u=1):n!==-1&&(u=-1)}return n===-1||o===-1||u===0||u===1&&n===o-1&&n===a+1?o!==-1&&(a===0&&i?t.base=t.name=s.slice(1,o):t.base=t.name=s.slice(a,o)):(a===0&&i?(t.name=s.slice(1,n),t.base=s.slice(1,o)):(t.name=s.slice(a,n),t.base=s.slice(a,o)),t.ext=s.slice(n,o)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let sa;async function vl(){return sa??(sa=(async()=>{var n;const s=document.createElement("canvas").getContext("webgl");if(!s)return Nt.UNPACK;const t=await new Promise(a=>{const o=document.createElement("video");o.onloadeddata=()=>a(o),o.onerror=()=>a(null),o.autoplay=!1,o.crossOrigin="anonymous",o.preload="auto",o.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",o.load()});if(!t)return Nt.UNPACK;const e=s.createTexture();s.bindTexture(s.TEXTURE_2D,e);const i=s.createFramebuffer();s.bindFramebuffer(s.FRAMEBUFFER,i),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,e,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.NONE),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,t);const r=new Uint8Array(4);return s.readPixels(0,0,1,1,s.RGBA,s.UNSIGNED_BYTE,r),s.deleteFramebuffer(i),s.deleteTexture(e),(n=s.getExtension("WEBGL_lose_context"))==null||n.loseContext(),r[0]<=r[3]?Nt.PMA:Nt.UNPACK})()),sa}function jf(){ot("7.0.0","skipHello is deprecated, please use settings.RENDER_OPTIONS.hello")}function Yf(){ot("7.0.0",`sayHello is deprecated, please use Renderer's "hello" option`)}let na;function xl(){return typeof na>"u"&&(na=function(){var t;const s={stencil:!0,failIfMajorPerformanceCaveat:q.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!q.ADAPTER.getWebGLRenderingContext())return!1;const e=q.ADAPTER.createCanvas();let i=e.getContext("webgl",s)||e.getContext("experimental-webgl",s);const r=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext()}return i=null,r}catch{return!1}}()),na}var qf={grad:.9,turn:360,rad:360/(2*Math.PI)},ke=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},Ft=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},Jt=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},bl=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},Tl=function(s){return{r:Jt(s.r,0,255),g:Jt(s.g,0,255),b:Jt(s.b,0,255),a:Jt(s.a)}},aa=function(s){return{r:Ft(s.r),g:Ft(s.g),b:Ft(s.b),a:Ft(s.a,3)}},Kf=/^#([0-9a-f]{3,8})$/i,hs=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},El=function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=Math.max(t,e,i),a=n-Math.min(t,e,i),o=a?n===t?(e-i)/a:n===e?2+(i-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:n?a/n*100:0,v:n/255*100,a:r}},wl=function(s){var t=s.h,e=s.s,i=s.v,r=s.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),a=i*(1-e),o=i*(1-(t-n)*e),h=i*(1-(1-t+n)*e),l=n%6;return{r:255*[i,o,a,a,h,i][l],g:255*[h,i,i,o,a,a][l],b:255*[a,a,h,i,i,o][l],a:r}},Cl=function(s){return{h:bl(s.h),s:Jt(s.s,0,100),l:Jt(s.l,0,100),a:Jt(s.a)}},Al=function(s){return{h:Ft(s.h),s:Ft(s.s),l:Ft(s.l),a:Ft(s.a,3)}},Sl=function(s){return wl((e=(t=s).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},hr=function(s){return{h:(t=El(s)).h,s:(r=(200-(e=t.s))*(i=t.v)/100)>0&&r<200?e*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,i,r},Zf=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Jf=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qf=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,tp=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,oa={string:[[function(s){var t=Kf.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?Ft(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?Ft(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=Qf.exec(s)||tp.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:Tl({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(s){var t=Zf.exec(s)||Jf.exec(s);if(!t)return null;var e,i,r=Cl({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(qf[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Sl(r)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=r===void 0?1:r;return ke(t)&&ke(e)&&ke(i)?Tl({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,r=s.a,n=r===void 0?1:r;if(!ke(t)||!ke(e)||!ke(i))return null;var a=Cl({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return Sl(a)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,r=s.a,n=r===void 0?1:r;if(!ke(t)||!ke(e)||!ke(i))return null;var a=function(o){return{h:bl(o.h),s:Jt(o.s,0,100),v:Jt(o.v,0,100),a:Jt(o.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return wl(a)},"hsv"]]},Pl=function(s,t){for(var e=0;e<t.length;e++){var i=t[e][0](s);if(i)return[i,t[e][1]]}return[null,void 0]},ep=function(s){return typeof s=="string"?Pl(s.trim(),oa.string):typeof s=="object"&&s!==null?Pl(s,oa.object):[null,void 0]},ha=function(s,t){var e=hr(s);return{h:e.h,s:Jt(e.s+100*t,0,100),l:e.l,a:e.a}},la=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},Ml=function(s,t){var e=hr(s);return{h:e.h,s:e.s,l:Jt(e.l+100*t,0,100),a:e.a}},ua=function(){function s(t){this.parsed=ep(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return Ft(la(this.rgba),2)},s.prototype.isDark=function(){return la(this.rgba)<.5},s.prototype.isLight=function(){return la(this.rgba)>=.5},s.prototype.toHex=function(){return t=aa(this.rgba),e=t.r,i=t.g,r=t.b,a=(n=t.a)<1?hs(Ft(255*n)):"","#"+hs(e)+hs(i)+hs(r)+a;var t,e,i,r,n,a},s.prototype.toRgb=function(){return aa(this.rgba)},s.prototype.toRgbString=function(){return t=aa(this.rgba),e=t.r,i=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+r+", "+n+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,n},s.prototype.toHsl=function(){return Al(hr(this.rgba))},s.prototype.toHslString=function(){return t=Al(hr(this.rgba)),e=t.h,i=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+n+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,n},s.prototype.toHsv=function(){return t=El(this.rgba),{h:Ft(t.h),s:Ft(t.s),v:Ft(t.v),a:Ft(t.a,3)};var t},s.prototype.invert=function(){return we({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),we(ha(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),we(ha(this.rgba,-t))},s.prototype.grayscale=function(){return we(ha(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),we(Ml(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),we(Ml(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?we({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Ft(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=hr(this.rgba);return typeof t=="number"?we({h:t,s:e.s,l:e.l,a:e.a}):Ft(e.h)},s.prototype.isEqual=function(t){return this.toHex()===we(t).toHex()},s}(),we=function(s){return s instanceof ua?s:new ua(s)},Il=[],ip=function(s){s.forEach(function(t){Il.indexOf(t)<0&&(t(ua,oa),Il.push(t))})};function rp(s,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var r in e)i[e[r]]=r;var n={};s.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,l=i[this.toHex()];if(l)return l;if(a!=null&&a.closest){var u=this.toRgb(),c=1/0,d="black";if(!n.length)for(var f in e)n[f]=new s(e[f]).toRgb();for(var p in e){var g=(o=u,h=n[p],Math.pow(o.r-h.r,2)+Math.pow(o.g-h.g,2)+Math.pow(o.b-h.b,2));g<c&&(c=g,d=p)}return d}},t.string.push([function(a){var o=a.toLowerCase(),h=o==="transparent"?"#0000":e[o];return h?new s(h).toRgb():null},"name"])}ip([rp]);const Ri=class pn{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof pn)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((r,n)=>r===e[n]);if(t!==null&&e!==null){const r=Object.keys(t),n=Object.keys(e);return r.length!==n.length?!1:r.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(r*255),t}toRgbArray(t){t=t??[];const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,r,n]=pn.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=r,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(r<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,i,r]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(r*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,r,n]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=n,t}normalize(t){let e,i,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,i=(a>>8&255)/255,r=(a&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,r,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,r,n=255]=t,e/=255,i/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=pn.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=we(t);a.isValid()&&({r:e,g:i,b:r,a:n}=a.rgba,e/=255,i/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=r,this._components[3]=n,this.refreshInt();else throw new Error(`Unable to convert color ${t}`)}refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),i)}),t)}};Ri.shared=new Ri,Ri.temp=new Ri,Ri.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let gt=Ri;function sp(s,t=[]){return ot("7.2.0","utils.hex2rgb is deprecated, use Color#toRgbArray instead"),gt.shared.setValue(s).toRgbArray(t)}function Rl(s){return ot("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),gt.shared.setValue(s).toHex()}function np(s){return ot("7.2.0","utils.string2hex is deprecated, use Color#toNumber instead"),gt.shared.setValue(s).toNumber()}function Dl(s){return ot("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),gt.shared.setValue(s).toNumber()}function ap(){const s=[],t=[];for(let i=0;i<32;i++)s[i]=i,t[i]=i;s[nt.NORMAL_NPM]=nt.NORMAL,s[nt.ADD_NPM]=nt.ADD,s[nt.SCREEN_NPM]=nt.SCREEN,t[nt.NORMAL]=nt.NORMAL_NPM,t[nt.ADD]=nt.ADD_NPM,t[nt.SCREEN]=nt.SCREEN_NPM;const e=[];return e.push(t),e.push(s),e}const ca=ap();function da(s,t){return ca[t?1:0][s]}function op(s,t,e,i=!0){return ot("7.2.0","utils.premultiplyRgba has moved to Color.premultiply"),gt.shared.setValue(s).premultiply(t,i).toArray(e??new Float32Array(4))}function hp(s,t){return ot("7.2.0","utils.premultiplyTint has moved to Color.toPremultiplied"),gt.shared.setValue(s).toPremultiplied(t)}function lp(s,t,e,i=!0){return ot("7.2.0","utils.premultiplyTintToRgba has moved to Color.premultiply"),gt.shared.setValue(s).premultiply(t,i).toArray(e??new Float32Array(4))}const Fl=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function Bl(s,t=null){const e=s*6;if(t=t||new Uint16Array(e),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,r=0;i<e;i+=6,r+=4)t[i+0]=r+0,t[i+1]=r+1,t[i+2]=r+2,t[i+3]=r+0,t[i+4]=r+2,t[i+5]=r+3;return t}function ls(s){if(s.BYTES_PER_ELEMENT===4)return s instanceof Float32Array?"Float32Array":s instanceof Uint32Array?"Uint32Array":"Int32Array";if(s.BYTES_PER_ELEMENT===2){if(s instanceof Uint16Array)return"Uint16Array"}else if(s.BYTES_PER_ELEMENT===1&&s instanceof Uint8Array)return"Uint8Array";return null}const up={Float32Array,Uint32Array,Int32Array,Uint8Array};function cp(s,t){let e=0,i=0;const r={};for(let h=0;h<s.length;h++)i+=t[h],e+=s[h].length;const n=new ArrayBuffer(e*4);let a=null,o=0;for(let h=0;h<s.length;h++){const l=t[h],u=s[h],c=ls(u);r[c]||(r[c]=new up[c](n)),a=r[c];for(let d=0;d<u.length;d++){const f=(d/l|0)*i+o,p=d%l;a[f+p]=u[d]}o+=l}return new Float32Array(n)}function lr(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function fa(s){return!(s&s-1)&&!!s}function pa(s){let t=(s>65535?1:0)<<4;s>>>=t;let e=(s>255?1:0)<<3;return s>>>=e,t|=e,e=(s>15?1:0)<<2,s>>>=e,t|=e,e=(s>3?1:0)<<1,s>>>=e,t|=e,t|s>>1}function di(s,t,e){const i=s.length;let r;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(r=t;r<n;++r)s[r]=s[r+e];s.length=n}function Ne(s){return s===0?0:s<0?-1:1}let dp=0;function qe(){return++dp}const ma=class{constructor(s,t,e,i){this.left=s,this.top=t,this.right=e,this.bottom=i}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};ma.EMPTY=new ma(0,0,0,0);let ga=ma;const _a={},Ut=Object.create(null),zt=Object.create(null);function fp(){let s;for(s in Ut)Ut[s].destroy();for(s in zt)zt[s].destroy()}function pp(){let s;for(s in Ut)delete Ut[s];for(s in zt)delete zt[s]}class Ll{constructor(t,e,i){this._canvas=q.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||q.RESOLUTION,this.resize(t,e)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(e*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function Ol(s,t,e){for(let i=0,r=4*e*t;i<t;++i,r+=4)if(s[r+3]!==0)return!1;return!0}function kl(s,t,e,i,r){const n=4*t;for(let a=i,o=i*n+4*e;a<=r;++a,o+=n)if(s[o+3]!==0)return!1;return!0}function Nl(s){const{width:t,height:e}=s,i=s.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const r=i.getImageData(0,0,t,e).data;let n=0,a=0,o=t-1,h=e-1;for(;a<e&&Ol(r,t,a);)++a;if(a===e)return ga.EMPTY;for(;Ol(r,t,h);)--h;for(;kl(r,t,n,a,h);)++n;for(;kl(r,t,o,a,h);)--o;return++o,++h,new ga(n,a,o,h)}function Ul(s){const t=Nl(s),{width:e,height:i}=t;let r=null;if(!t.isEmpty()){const n=s.getContext("2d");if(n===null)throw new TypeError("Failed to get canvas 2D context");r=n.getImageData(t.left,t.top,e,i)}return{width:e,height:i,data:r}}function mp(s){const t=Fl.exec(s);if(t)return{mediaType:t[1]?t[1].toLowerCase():void 0,subType:t[2]?t[2].toLowerCase():void 0,charset:t[3]?t[3].toLowerCase():void 0,encoding:t[4]?t[4].toLowerCase():void 0,data:t[5]}}function Gl(s,t=globalThis.location){if(s.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(s,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function Ce(s,t=1){var i;const e=(i=q.RETINA_PREFIX)==null?void 0:i.exec(s);return e?parseFloat(e[1]):t}const gp=Object.freeze(Object.defineProperty({__proto__:null,BaseTextureCache:zt,BoundingBox:ga,CanvasRenderTarget:Ll,DATA_URI:Fl,EventEmitter:Ee,ProgramCache:_a,TextureCache:Ut,clearTextureCache:pp,correctBlendMode:da,createIndicesForQuads:Bl,decomposeDataUri:mp,deprecation:ot,destroyTextureCache:fp,detectVideoAlphaMode:vl,determineCrossOrigin:Gl,earcut:Nh,getBufferType:ls,getCanvasBoundingBox:Nl,getResolutionOfUrl:Ce,hex2rgb:sp,hex2string:Rl,interleaveTypedArrays:cp,isMobile:ce,isPow2:fa,isWebGLSupported:xl,log2:pa,nextPow2:lr,path:Rt,premultiplyBlendMode:ca,premultiplyRgba:op,premultiplyTint:hp,premultiplyTintToRgba:lp,removeItems:di,rgb2hex:Dl,sayHello:Yf,sign:Ne,skipHello:jf,string2hex:np,trimCanvas:Ul,uid:qe,url:os},Symbol.toStringTag,{value:"Module"}));var $=(s=>(s.Renderer="renderer",s.Application="application",s.RendererSystem="renderer-webgl-system",s.RendererPlugin="renderer-webgl-plugin",s.CanvasRendererSystem="renderer-canvas-system",s.CanvasRendererPlugin="renderer-canvas-plugin",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s))($||{});const ya=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},Vl=(s,t)=>ya(s).priority??t,Q={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(ya).forEach(t=>{t.type.forEach(e=>{var i,r;return(r=(i=this._removeHandlers)[e])==null?void 0:r.call(i,t)})}),this},add(...s){return s.map(ya).forEach(t=>{t.type.forEach(e=>{var n,a;const i=this._addHandlers,r=this._queue;i[e]?(n=i[e])==null||n.call(i,t):(r[e]=r[e]||[],(a=r[e])==null||a.push(t))})}),this},handle(s,t,e){var a;const i=this._addHandlers,r=this._removeHandlers;if(i[s]||r[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,r[s]=e;const n=this._queue;return n[s]&&((a=n[s])==null||a.forEach(o=>t(o)),delete n[s]),this},handleByMap(s,t){return this.handle(s,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((r,n)=>Vl(n,e)-Vl(r,e)))},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1)})}};class us{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const _p=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
11
+ `);function yp(s){let t="";for(let e=0;e<s;++e)e>0&&(t+=`
12
+ else `),e<s-1&&(t+=`if(test == ${e}.0){}`);return t}function Hl(s,t){if(s===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);for(;;){const i=_p.replace(/%forloop%/gi,yp(s));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))s=s/2|0;else break}return s}const va=0,xa=1,ba=2,Ta=3,Ea=4,wa=5;class fe{constructor(){this.data=0,this.blendMode=nt.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<va)}set blend(t){!!(this.data&1<<va)!==t&&(this.data^=1<<va)}get offsets(){return!!(this.data&1<<xa)}set offsets(t){!!(this.data&1<<xa)!==t&&(this.data^=1<<xa)}get culling(){return!!(this.data&1<<ba)}set culling(t){!!(this.data&1<<ba)!==t&&(this.data^=1<<ba)}get depthTest(){return!!(this.data&1<<Ta)}set depthTest(t){!!(this.data&1<<Ta)!==t&&(this.data^=1<<Ta)}get depthMask(){return!!(this.data&1<<wa)}set depthMask(t){!!(this.data&1<<wa)!==t&&(this.data^=1<<wa)}get clockwiseFrontFace(){return!!(this.data&1<<Ea)}set clockwiseFrontFace(t){!!(this.data&1<<Ea)!==t&&(this.data^=1<<Ea)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==nt.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new fe;return t.depthTest=!1,t.blend=!0,t}}fe.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const cs=[];function Ca(s,t){if(!s)return null;let e="";if(typeof s=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(s);i&&(e=i[1].toLowerCase())}for(let i=cs.length-1;i>=0;--i){const r=cs[i];if(r.test&&r.test(s,e))return new r(s,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class Wt{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,r,n,a,o,h){if(arguments.length>8)throw new Error("max arguments reached");const{name:l,items:u}=this;this._aliasCount++;for(let c=0,d=u.length;c<d;c++)u[c][l](t,e,i,r,n,a,o,h);return u===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(Wt.prototype,{dispatch:{value:Wt.prototype.emit},run:{value:Wt.prototype.emit}});class Di{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new Wt("setRealSize"),this.onUpdate=new Wt("update"),this.onError=new Wt("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,e,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,e){return!1}}class ur extends Di{constructor(t,e){const{width:i,height:r}=e||{};if(!i||!r)throw new Error("BufferResource width or height invalid");super(i,r),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const r=t.gl;r.pixelStorei(r.UNPACK_ALIGNMENT,this.unpackAlignment),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Nt.UNPACK);const n=e.realWidth,a=e.realHeight;return i.width===n&&i.height===a?r.texSubImage2D(e.target,0,0,0,n,a,e.format,i.type,this.data):(i.width=n,i.height=a,r.texImage2D(e.target,0,i.internalFormat,n,a,0,e.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const vp={scaleMode:be.NEAREST,alphaMode:Nt.NPM},Aa=class tr extends Ee{constructor(t=null,e=null){super(),e=Object.assign({},tr.defaultOptions,e);const{alphaMode:i,mipmap:r,anisotropicLevel:n,scaleMode:a,width:o,height:h,wrapMode:l,format:u,type:c,target:d,resolution:f,resourceOptions:p}=e;t&&!(t instanceof Di)&&(t=Ca(t,p),t.internal=!0),this.resolution=f||q.RESOLUTION,this.width=Math.round((o||0)*this.resolution)/this.resolution,this.height=Math.round((h||0)*this.resolution)/this.resolution,this._mipmap=r,this.anisotropicLevel=n,this._wrapMode=l,this._scaleMode=a,this.format=u,this.type=c,this.target=d,this.alphaMode=i,this.uid=qe(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=o>0&&h>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(t)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,e){let i;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,i=!0),e!==void 0&&e!==this.mipmap&&(this.mipmap=e,i=!0),i&&this.dirtyStyleId++,this}setSize(t,e,i){return i=i||this.resolution,this.setRealSize(t*i,e*i,i)}setRealSize(t,e,i){return this.resolution=i||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=fa(this.realWidth)&&fa(this.realHeight)}setResolution(t){const e=this.resolution;return e===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this}update(){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))}onError(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete zt[this.cacheId],delete Ut[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),tr.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,e,i=q.STRICT_TEXTURE_CACHE){const r=typeof t=="string";let n=null;if(r)n=t;else{if(!t._pixiId){const o=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${o}_${qe()}`}n=t._pixiId}let a=zt[n];if(r&&i&&!a)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return a||(a=new tr(t,e),a.cacheId=n,tr.addToCache(a,n)),a}static fromBuffer(t,e,i,r){t=t||new Float32Array(e*i*4);const n=new ur(t,{width:e,height:i,...r==null?void 0:r.resourceOptions});let a,o;return t instanceof Float32Array?(a=H.RGBA,o=it.FLOAT):t instanceof Int32Array?(a=H.RGBA_INTEGER,o=it.INT):t instanceof Uint32Array?(a=H.RGBA_INTEGER,o=it.UNSIGNED_INT):t instanceof Int16Array?(a=H.RGBA_INTEGER,o=it.SHORT):t instanceof Uint16Array?(a=H.RGBA_INTEGER,o=it.UNSIGNED_SHORT):t instanceof Int8Array?(a=H.RGBA,o=it.BYTE):(a=H.RGBA,o=it.UNSIGNED_BYTE),n.internal=!0,new tr(n,Object.assign({},vp,{type:o,format:a},r))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),zt[e]&&zt[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),zt[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=zt[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete zt[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete zt[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};Aa.defaultOptions={mipmap:he.POW2,anisotropicLevel:0,scaleMode:be.LINEAR,wrapMode:Te.CLAMP,alphaMode:Nt.UNPACK,target:ui.TEXTURE_2D,format:H.RGBA,type:it.UNSIGNED_BYTE},Aa._globalBatch=0;let lt=Aa;class ds{constructor(){this.texArray=null,this.blend=0,this.type=oe.TRIANGLES,this.start=0,this.size=0,this.data=null}}let xp=0;class At{constructor(t,e=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=e,this.id=xp++,this.disposeRunner=new Wt("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?ue.ELEMENT_ARRAY_BUFFER:ue.ARRAY_BUFFER}get index(){return this.type===ue.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new At(t)}}class cr{constructor(t,e=0,i=!1,r=it.FLOAT,n,a,o,h=1){this.buffer=t,this.size=e,this.normalized=i,this.type=r,this.stride=n,this.start=a,this.instance=o,this.divisor=h}destroy(){this.buffer=null}static from(t,e,i,r,n){return new cr(t,e,i,r,n)}}const bp={Float32Array,Uint32Array,Int32Array,Uint8Array};function Tp(s,t){let e=0,i=0;const r={};for(let h=0;h<s.length;h++)i+=t[h],e+=s[h].length;const n=new ArrayBuffer(e*4);let a=null,o=0;for(let h=0;h<s.length;h++){const l=t[h],u=s[h],c=ls(u);r[c]||(r[c]=new bp[c](n)),a=r[c];for(let d=0;d<u.length;d++){const f=(d/l|0)*i+o,p=d%l;a[f+p]=u[d]}o+=l}return new Float32Array(n)}const Xl={5126:4,5123:2,5121:1};let Ep=0;const wp={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class Ue{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=Ep++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new Wt("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,r=!1,n,a,o,h=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof At||(e instanceof Array&&(e=new Float32Array(e)),e=new At(e));const l=t.split("|");if(l.length>1){for(let c=0;c<l.length;c++)this.addAttribute(l[c],e,i,r,n);return this}let u=this.buffers.indexOf(e);return u===-1&&(this.buffers.push(e),u=this.buffers.length-1),this.attributes[t]=new cr(u,i,r,n,a,o,h),this.instanced=this.instanced||h,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof At||(t instanceof Array&&(t=new Uint16Array(t)),t=new At(t)),t.type=ue.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],i=new At;let r;for(r in this.attributes){const n=this.attributes[r],a=this.buffers[n.buffer];t.push(a.data),e.push(n.size*Xl[n.type]/4),n.buffer=0}for(i.data=Tp(t,e),r=0;r<this.buffers.length;r++)this.buffers[r]!==this.indexBuffer&&this.buffers[r].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new Ue;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new At(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new cr(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=ue.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new Ue,i=[],r=[],n=[];let a;for(let o=0;o<t.length;o++){a=t[o];for(let h=0;h<a.buffers.length;h++)r[h]=r[h]||0,r[h]+=a.buffers[h].data.length,n[h]=0}for(let o=0;o<a.buffers.length;o++)i[o]=new wp[ls(a.buffers[o].data)](r[o]),e.buffers[o]=new At(i[o]);for(let o=0;o<t.length;o++){a=t[o];for(let h=0;h<a.buffers.length;h++)i[h].set(a.buffers[h].data,n[h]),n[h]+=a.buffers[h].data.length}if(e.attributes=a.attributes,a.indexBuffer){e.indexBuffer=e.buffers[a.buffers.indexOf(a.indexBuffer)],e.indexBuffer.type=ue.ELEMENT_ARRAY_BUFFER;let o=0,h=0,l=0,u=0;for(let c=0;c<a.buffers.length;c++)if(a.buffers[c]!==a.indexBuffer){u=c;break}for(const c in a.attributes){const d=a.attributes[c];(d.buffer|0)===u&&(h+=d.size*Xl[d.type]/4)}for(let c=0;c<t.length;c++){const d=t[c].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+l]+=o;o+=t[c].buffers[u].data.length/h,l+=d.length}}return e}}class Sa extends Ue{constructor(t=!1){super(),this._buffer=new At(null,t,!1),this._indexBuffer=new At(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,it.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,it.FLOAT).addAttribute("aColor",this._buffer,4,!0,it.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,it.FLOAT).addIndex(this._indexBuffer)}}const dr=Math.PI*2,zl=180/Math.PI,Wl=Math.PI/180;var Bt=(s=>(s[s.POLY=0]="POLY",s[s.RECT=1]="RECT",s[s.CIRC=2]="CIRC",s[s.ELIP=3]="ELIP",s[s.RREC=4]="RREC",s))(Bt||{});class ft{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new ft(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}}ft.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const fs=[new ft,new ft,new ft,new ft];class ut{constructor(t=0,e=0,i=0,r=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(r),this.type=Bt.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new ut(0,0,0,0)}clone(){return new ut(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const P=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=P)return!1;const N=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>N}const i=this.left,r=this.right,n=this.top,a=this.bottom;if(r<=i||a<=n)return!1;const o=fs[0].set(t.left,t.top),h=fs[1].set(t.left,t.bottom),l=fs[2].set(t.right,t.top),u=fs[3].set(t.right,t.bottom);if(l.x<=o.x||h.y<=o.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(o,o),e.apply(h,h),e.apply(l,l),e.apply(u,u),Math.max(o.x,h.x,l.x,u.x)<=i||Math.min(o.x,h.x,l.x,u.x)>=r||Math.max(o.y,h.y,l.y,u.y)<=n||Math.min(o.y,h.y,l.y,u.y)>=a))return!1;const d=c*(h.y-o.y),f=c*(o.x-h.x),p=d*i+f*n,g=d*r+f*n,m=d*i+f*a,_=d*r+f*a;if(Math.max(p,g,m,_)<=d*o.x+f*o.y||Math.min(p,g,m,_)>=d*u.x+f*u.y)return!1;const b=c*(o.y-l.y),y=c*(l.x-o.x),E=b*i+y*n,v=b*r+y*n,M=b*i+y*a,T=b*r+y*a;return!(Math.max(E,v,M,T)<=b*o.x+y*o.y||Math.min(E,v,M,T)>=b*u.x+y*u.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,r=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=i-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=r,this.height=n-r,this}}ut.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class fr{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Bt.CIRC}clone(){return new fr(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=i}getBounds(){return new ut(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}fr.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class pr{constructor(t=0,e=0,i=0,r=0){this.x=t,this.y=e,this.width=i,this.height=r,this.type=Bt.ELIP}clone(){return new pr(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,r=(e-this.y)/this.height;return i*=i,r*=r,i+r<=1}getBounds(){return new ut(this.x-this.width,this.y-this.height,this.width,this.height)}}pr.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Ke{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let r=0,n=e.length;r<n;r++)i.push(e[r].x,e[r].y);e=i}this.points=e,this.type=Bt.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Ke(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const r=this.points.length/2;for(let n=0,a=r-1;n<r;a=n++){const o=this.points[n*2],h=this.points[n*2+1],l=this.points[a*2],u=this.points[a*2+1];h>e!=u>e&&t<(l-o)*((e-h)/(u-h))+o&&(i=!i)}return i}}Ke.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((s,t)=>`${s}, ${t}`,"")}]`};class mr{constructor(t=0,e=0,i=0,r=0,n=20){this.x=t,this.y=e,this.width=i,this.height=r,this.radius=n,this.type=Bt.RREC}clone(){return new mr(this.x,this.y,this.width,this.height,this.radius)}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),n=e-(this.y+i);const a=i*i;if(r*r+n*n<=a||(r=t-(this.x+this.width-i),r*r+n*n<=a)||(n=e-(this.y+this.height-i),r*r+n*n<=a)||(r=t-(this.x+i),r*r+n*n<=a))return!0}return!1}}mr.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class vt{constructor(t=1,e=0,i=0,r=1,n=0,a=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=a}fromArray(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]}set(t,e,i,r,n,a){return this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=a,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new ft;const i=t.x,r=t.y;return e.x=this.a*i+this.c*r+this.tx,e.y=this.b*i+this.d*r+this.ty,e}applyInverse(t,e){e=e||new ft;const i=1/(this.a*this.d+this.c*-this.b),r=t.x,n=t.y;return e.x=this.d*i*r+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*n+-this.b*i*r+(-this.ty*this.a+this.tx*this.b)*i,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),r=this.a,n=this.c,a=this.tx;return this.a=r*e-this.b*i,this.b=r*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=a*e-this.ty*i,this.ty=a*i+this.ty*e,this}append(t){const e=this.a,i=this.b,r=this.c,n=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*r,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}setTransform(t,e,i,r,n,a,o,h,l){return this.a=Math.cos(o+l)*n,this.b=Math.sin(o+l)*n,this.c=-Math.sin(o-h)*a,this.d=Math.cos(o-h)*a,this.tx=t-(i*this.a+r*this.c),this.ty=e-(i*this.b+r*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,r=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=r*t.a+this.d*t.c,this.d=r*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}decompose(t){const e=this.a,i=this.b,r=this.c,n=this.d,a=t.pivot,o=-Math.atan2(-r,n),h=Math.atan2(i,e),l=Math.abs(o+h);return l<1e-5||Math.abs(dr-l)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=h),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(r*r+n*n),t.position.x=this.tx+(a.x*e+a.y*r),t.position.y=this.ty+(a.x*i+a.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,a=t*r-e*i;return this.a=r/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-r*n)/a,this.ty=-(t*this.ty-e*n)/a,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new vt;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}copyTo(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}copyFrom(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}static get IDENTITY(){return new vt}static get TEMP_MATRIX(){return new vt}}vt.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}]`};const fi=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],pi=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],mi=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],gi=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Pa=[],$l=[],ps=Math.sign;function Cp(){for(let s=0;s<16;s++){const t=[];Pa.push(t);for(let e=0;e<16;e++){const i=ps(fi[s]*fi[e]+mi[s]*pi[e]),r=ps(pi[s]*fi[e]+gi[s]*pi[e]),n=ps(fi[s]*mi[e]+mi[s]*gi[e]),a=ps(pi[s]*mi[e]+gi[s]*gi[e]);for(let o=0;o<16;o++)if(fi[o]===i&&pi[o]===r&&mi[o]===n&&gi[o]===a){t.push(o);break}}}for(let s=0;s<16;s++){const t=new vt;t.set(fi[s],pi[s],mi[s],gi[s],0,0),$l.push(t)}}Cp();const wt={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:s=>fi[s],uY:s=>pi[s],vX:s=>mi[s],vY:s=>gi[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>Pa[s][t],sub:(s,t)=>Pa[s][wt.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?wt.S:wt.N:Math.abs(t)*2<=Math.abs(s)?s>0?wt.E:wt.W:t>0?s>0?wt.SE:wt.SW:s>0?wt.NE:wt.NW,matrixAppendRotationInv:(s,t,e=0,i=0)=>{const r=$l[wt.inv(t)];r.tx=e,r.ty=i,s.append(r)}};class pe{constructor(t,e,i=0,r=0){this._x=i,this._y=r,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new pe(t,e,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}pe.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Ma=class{constructor(){this.worldTransform=new vt,this.localTransform=new vt,this.position=new pe(this.onChange,this,0,0),this.scale=new pe(this.onChange,this,1,1),this.pivot=new pe(this.onChange,this,0,0),this.skew=new pe(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}onChange(){this._localID++}updateSkew(){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++}updateLocalTransform(){const s=this.localTransform;this._localID!==this._currentLocalID&&(s.a=this._cx*this.scale.x,s.b=this._sx*this.scale.x,s.c=this._cy*this.scale.y,s.d=this._sy*this.scale.y,s.tx=this.position.x-(this.pivot.x*s.a+this.pivot.y*s.c),s.ty=this.position.y-(this.pivot.x*s.b+this.pivot.y*s.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(s){const t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==s._worldID){const e=s.worldTransform,i=this.worldTransform;i.a=t.a*e.a+t.b*e.c,i.b=t.a*e.b+t.b*e.d,i.c=t.c*e.a+t.d*e.c,i.d=t.c*e.b+t.d*e.d,i.tx=t.tx*e.a+t.ty*e.c+e.tx,i.ty=t.tx*e.b+t.ty*e.d+e.ty,this._parentID=s._worldID,this._worldID++}}setFromMatrix(s){s.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(s){this._rotation!==s&&(this._rotation=s,this.updateSkew())}};Ma.IDENTITY=new Ma;let Fi=Ma;Fi.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}) ]`};var Ap=`varying vec2 vTextureCoord;
13
+
14
+ uniform sampler2D uSampler;
15
+
16
+ void main(void){
17
+ gl_FragColor *= texture2D(uSampler, vTextureCoord);
18
+ }`,Sp=`attribute vec2 aVertexPosition;
19
+ attribute vec2 aTextureCoord;
20
+
21
+ uniform mat3 projectionMatrix;
22
+
23
+ varying vec2 vTextureCoord;
24
+
25
+ void main(void){
26
+ gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
27
+ vTextureCoord = aTextureCoord;
28
+ }
29
+ `;function jl(s,t,e){const i=s.createShader(t);return s.shaderSource(i,e),s.compileShader(i),i}function Ia(s){const t=new Array(s);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Yl(s,t){switch(s){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return Ia(2*t);case"bvec3":return Ia(3*t);case"bvec4":return Ia(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const _i=[{test:s=>s.type==="float"&&s.size===1&&!s.isArray,code:s=>`
30
+ if(uv["${s}"] !== ud["${s}"].value)
19
31
  {
20
- ud["`+i+'"].value = uv["'+i+`"]
21
- gl.uniform1f(ud["`+i+'"].location, uv["'+i+`"])
32
+ ud["${s}"].value = uv["${s}"]
33
+ gl.uniform1f(ud["${s}"].location, uv["${s}"])
22
34
  }
23
- `}},{test:function(i,t){return(i.type==="sampler2D"||i.type==="samplerCube"||i.type==="sampler2DArray")&&i.size===1&&!i.isArray&&(t==null||t.castToBaseTexture!==void 0)},code:function(i){return`t = syncData.textureCount++;
35
+ `},{test:(s,t)=>(s.type==="sampler2D"||s.type==="samplerCube"||s.type==="sampler2DArray")&&s.size===1&&!s.isArray&&(t==null||t.castToBaseTexture!==void 0),code:s=>`t = syncData.textureCount++;
24
36
 
25
- renderer.texture.bind(uv["`+i+`"], t);
37
+ renderer.texture.bind(uv["${s}"], t);
26
38
 
27
- if(ud["`+i+`"].value !== t)
39
+ if(ud["${s}"].value !== t)
28
40
  {
29
- ud["`+i+`"].value = t;
30
- gl.uniform1i(ud["`+i+`"].location, t);
41
+ ud["${s}"].value = t;
42
+ gl.uniform1i(ud["${s}"].location, t);
31
43
  ; // eslint-disable-line max-len
32
- }`}},{test:function(i,t){return i.type==="mat3"&&i.size===1&&!i.isArray&&t.a!==void 0},code:function(i){return`
33
- gl.uniformMatrix3fv(ud["`+i+'"].location, false, uv["'+i+`"].toArray(true));
34
- `},codeUbo:function(i){return`
35
- var `+i+"_matrix = uv."+i+`.toArray(true);
36
-
37
- data[offset] = `+i+`_matrix[0];
38
- data[offset+1] = `+i+`_matrix[1];
39
- data[offset+2] = `+i+`_matrix[2];
44
+ }`},{test:(s,t)=>s.type==="mat3"&&s.size===1&&!s.isArray&&t.a!==void 0,code:s=>`
45
+ gl.uniformMatrix3fv(ud["${s}"].location, false, uv["${s}"].toArray(true));
46
+ `,codeUbo:s=>`
47
+ var ${s}_matrix = uv.${s}.toArray(true);
48
+
49
+ data[offset] = ${s}_matrix[0];
50
+ data[offset+1] = ${s}_matrix[1];
51
+ data[offset+2] = ${s}_matrix[2];
40
52
 
41
- data[offset + 4] = `+i+`_matrix[3];
42
- data[offset + 5] = `+i+`_matrix[4];
43
- data[offset + 6] = `+i+`_matrix[5];
53
+ data[offset + 4] = ${s}_matrix[3];
54
+ data[offset + 5] = ${s}_matrix[4];
55
+ data[offset + 6] = ${s}_matrix[5];
44
56
 
45
- data[offset + 8] = `+i+`_matrix[6];
46
- data[offset + 9] = `+i+`_matrix[7];
47
- data[offset + 10] = `+i+`_matrix[8];
48
- `}},{test:function(i,t){return i.type==="vec2"&&i.size===1&&!i.isArray&&t.x!==void 0},code:function(i){return`
49
- cv = ud["`+i+`"].value;
50
- v = uv["`+i+`"];
57
+ data[offset + 8] = ${s}_matrix[6];
58
+ data[offset + 9] = ${s}_matrix[7];
59
+ data[offset + 10] = ${s}_matrix[8];
60
+ `},{test:(s,t)=>s.type==="vec2"&&s.size===1&&!s.isArray&&t.x!==void 0,code:s=>`
61
+ cv = ud["${s}"].value;
62
+ v = uv["${s}"];
51
63
 
52
64
  if(cv[0] !== v.x || cv[1] !== v.y)
53
65
  {
54
66
  cv[0] = v.x;
55
67
  cv[1] = v.y;
56
- gl.uniform2f(ud["`+i+`"].location, v.x, v.y);
57
- }`},codeUbo:function(i){return`
58
- v = uv.`+i+`;
68
+ gl.uniform2f(ud["${s}"].location, v.x, v.y);
69
+ }`,codeUbo:s=>`
70
+ v = uv.${s};
59
71
 
60
72
  data[offset] = v.x;
61
73
  data[offset+1] = v.y;
62
- `}},{test:function(i){return i.type==="vec2"&&i.size===1&&!i.isArray},code:function(i){return`
63
- cv = ud["`+i+`"].value;
64
- v = uv["`+i+`"];
74
+ `},{test:s=>s.type==="vec2"&&s.size===1&&!s.isArray,code:s=>`
75
+ cv = ud["${s}"].value;
76
+ v = uv["${s}"];
65
77
 
66
78
  if(cv[0] !== v[0] || cv[1] !== v[1])
67
79
  {
68
80
  cv[0] = v[0];
69
81
  cv[1] = v[1];
70
- gl.uniform2f(ud["`+i+`"].location, v[0], v[1]);
82
+ gl.uniform2f(ud["${s}"].location, v[0], v[1]);
71
83
  }
72
- `}},{test:function(i,t){return i.type==="vec4"&&i.size===1&&!i.isArray&&t.width!==void 0},code:function(i){return`
73
- cv = ud["`+i+`"].value;
74
- v = uv["`+i+`"];
84
+ `},{test:(s,t)=>s.type==="vec4"&&s.size===1&&!s.isArray&&t.width!==void 0,code:s=>`
85
+ cv = ud["${s}"].value;
86
+ v = uv["${s}"];
75
87
 
76
88
  if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height)
77
89
  {
@@ -79,17 +91,52 @@ Deprecated since v`+i),console.warn(r))),Vh[t]=!0}}var ys={},Gt=Object.create(nu
79
91
  cv[1] = v.y;
80
92
  cv[2] = v.width;
81
93
  cv[3] = v.height;
82
- gl.uniform4f(ud["`+i+`"].location, v.x, v.y, v.width, v.height)
83
- }`},codeUbo:function(i){return`
84
- v = uv.`+i+`;
94
+ gl.uniform4f(ud["${s}"].location, v.x, v.y, v.width, v.height)
95
+ }`,codeUbo:s=>`
96
+ v = uv.${s};
85
97
 
86
98
  data[offset] = v.x;
87
99
  data[offset+1] = v.y;
88
100
  data[offset+2] = v.width;
89
101
  data[offset+3] = v.height;
90
- `}},{test:function(i){return i.type==="vec4"&&i.size===1&&!i.isArray},code:function(i){return`
91
- cv = ud["`+i+`"].value;
92
- v = uv["`+i+`"];
102
+ `},{test:(s,t)=>s.type==="vec4"&&s.size===1&&!s.isArray&&t.red!==void 0,code:s=>`
103
+ cv = ud["${s}"].value;
104
+ v = uv["${s}"];
105
+
106
+ if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha)
107
+ {
108
+ cv[0] = v.red;
109
+ cv[1] = v.green;
110
+ cv[2] = v.blue;
111
+ cv[3] = v.alpha;
112
+ gl.uniform4f(ud["${s}"].location, v.red, v.green, v.blue, v.alpha)
113
+ }`,codeUbo:s=>`
114
+ v = uv.${s};
115
+
116
+ data[offset] = v.red;
117
+ data[offset+1] = v.green;
118
+ data[offset+2] = v.blue;
119
+ data[offset+3] = v.alpha;
120
+ `},{test:(s,t)=>s.type==="vec3"&&s.size===1&&!s.isArray&&t.red!==void 0,code:s=>`
121
+ cv = ud["${s}"].value;
122
+ v = uv["${s}"];
123
+
124
+ if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a)
125
+ {
126
+ cv[0] = v.red;
127
+ cv[1] = v.green;
128
+ cv[2] = v.blue;
129
+
130
+ gl.uniform3f(ud["${s}"].location, v.red, v.green, v.blue)
131
+ }`,codeUbo:s=>`
132
+ v = uv.${s};
133
+
134
+ data[offset] = v.red;
135
+ data[offset+1] = v.green;
136
+ data[offset+2] = v.blue;
137
+ `},{test:s=>s.type==="vec4"&&s.size===1&&!s.isArray,code:s=>`
138
+ cv = ud["${s}"].value;
139
+ v = uv["${s}"];
93
140
 
94
141
  if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
95
142
  {
@@ -98,8 +145,8 @@ Deprecated since v`+i),console.warn(r))),Vh[t]=!0}}var ys={},Gt=Object.create(nu
98
145
  cv[2] = v[2];
99
146
  cv[3] = v[3];
100
147
 
101
- gl.uniform4f(ud["`+i+`"].location, v[0], v[1], v[2], v[3])
102
- }`}}],Gv={float:`
148
+ gl.uniform4f(ud["${s}"].location, v[0], v[1], v[2], v[3])
149
+ }`}],Pp={float:`
103
150
  if (cv !== v)
104
151
  {
105
152
  cu.value = v;
@@ -235,50 +282,74 @@ Deprecated since v`+i),console.warn(r))),Vh[t]=!0}}var ys={},Gt=Object.create(nu
235
282
  cu.value = v;
236
283
 
237
284
  gl.uniform1i(location, v);
238
- }`},Xv={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};function Hv(i,t){var e,r=[`
285
+ }`},Mp={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};function Ip(s,t){var i;const e=[`
239
286
  var v = null;
240
287
  var cv = null;
241
288
  var cu = null;
242
289
  var t = 0;
243
290
  var gl = renderer.gl;
244
- `];for(var n in i.uniforms){var s=t[n];if(!s){!((e=i.uniforms[n])===null||e===void 0)&&e.group&&(i.uniforms[n].ubo?r.push(`
245
- renderer.shader.syncUniformBufferGroup(uv.`+n+", '"+n+`');
246
- `):r.push(`
247
- renderer.shader.syncUniformGroup(uv.`+n+`, syncData);
248
- `));continue}for(var a=i.uniforms[n],o=!1,h=0;h<Ze.length;h++)if(Ze[h].test(s,a)){r.push(Ze[h].code(n,a)),o=!0;break}if(!o){var u=s.size===1&&!s.isArray?Gv:Xv,l=u[s.type].replace("location",'ud["'+n+'"].location');r.push(`
249
- cu = ud["`+n+`"];
291
+ `];for(const r in s.uniforms){const n=t[r];if(!n){((i=s.uniforms[r])==null?void 0:i.group)===!0&&(s.uniforms[r].ubo?e.push(`
292
+ renderer.shader.syncUniformBufferGroup(uv.${r}, '${r}');
293
+ `):e.push(`
294
+ renderer.shader.syncUniformGroup(uv.${r}, syncData);
295
+ `));continue}const a=s.uniforms[r];let o=!1;for(let h=0;h<_i.length;h++)if(_i[h].test(n,a)){e.push(_i[h].code(r,a)),o=!0;break}if(!o){const h=(n.size===1&&!n.isArray?Pp:Mp)[n.type].replace("location",`ud["${r}"].location`);e.push(`
296
+ cu = ud["${r}"];
250
297
  cv = cu.value;
251
- v = uv["`+n+`"];
252
- `+l+";")}}return new Function("ud","uv","renderer","syncData",r.join(`
253
- `))}var Vv=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
254
- `);function jv(i){for(var t="",e=0;e<i;++e)e>0&&(t+=`
255
- else `),e<i-1&&(t+="if(test == "+e+".0){}");return t}function mu(i,t){if(i===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");for(var e=t.createShader(t.FRAGMENT_SHADER);;){var r=Vv.replace(/%forloop%/gi,jv(i));if(t.shaderSource(e,r),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))i=i/2|0;else break}return i}var Yr;function zv(){if(typeof Yr=="boolean")return Yr;try{var i=new Function("param1","param2","param3","return param1[param2] === param3;");Yr=i({a:"b"},"a","b")===!0}catch{Yr=!1}return Yr}var Wv=`varying vec2 vTextureCoord;
256
-
257
- uniform sampler2D uSampler;
298
+ v = uv["${r}"];
299
+ ${h};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
300
+ `))}const ql={};let Bi=ql;function Kl(){if(Bi===ql||Bi!=null&&Bi.isContextLost()){const s=q.ADAPTER.createCanvas();let t;q.PREFER_ENV>=Zt.WEBGL2&&(t=s.getContext("webgl2",{})),t||(t=s.getContext("webgl",{})||s.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),Bi=t}return Bi}let ms;function Rp(){if(!ms){ms=Xt.MEDIUM;const s=Kl();if(s&&s.getShaderPrecisionFormat){const t=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT);t&&(ms=t.precision?Xt.HIGH:Xt.MEDIUM)}}return ms}function Zl(s,t){const e=s.getShaderSource(t).split(`
301
+ `).map((l,u)=>`${u}: ${l}`),i=s.getShaderInfoLog(t),r=i.split(`
302
+ `),n={},a=r.map(l=>parseFloat(l.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(l=>l&&!n[l]?(n[l]=!0,!0):!1),o=[""];a.forEach(l=>{e[l-1]=`%c${e[l-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const h=e.join(`
303
+ `);o[0]=h,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...o),console.groupEnd()}function Dp(s,t,e,i){s.getProgramParameter(t,s.LINK_STATUS)||(s.getShaderParameter(e,s.COMPILE_STATUS)||Zl(s,e),s.getShaderParameter(i,s.COMPILE_STATUS)||Zl(s,i),console.error("PixiJS Error: Could not initialize shader."),s.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",s.getProgramInfoLog(t)))}const Fp={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 Jl(s){return Fp[s]}let gs=null;const Ql={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 tu(s,t){if(!gs){const e=Object.keys(Ql);gs={};for(let i=0;i<e.length;++i){const r=e[i];gs[s[r]]=Ql[r]}}return gs[t]}function eu(s,t,e){if(s.substring(0,9)!=="precision"){let i=t;return t===Xt.HIGH&&e!==Xt.HIGH&&(i=Xt.MEDIUM),`precision ${i} float;
304
+ ${s}`}else if(e!==Xt.HIGH&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}let gr;function iu(){if(typeof gr=="boolean")return gr;try{gr=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{gr=!1}return gr}let Bp=0;const _s={},Ra=class er{constructor(t,e,i="pixi-shader",r={}){this.extra={},this.id=Bp++,this.vertexSrc=t||er.defaultVertexSrc,this.fragmentSrc=e||er.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=r,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),_s[i]?(_s[i]++,i+=`-${_s[i]}`):_s[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
305
+ ${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i}
306
+ ${this.fragmentSrc}`,this.vertexSrc=eu(this.vertexSrc,er.defaultVertexPrecision,Xt.HIGH),this.fragmentSrc=eu(this.fragmentSrc,er.defaultFragmentPrecision,Rp())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return Sp}static get defaultFragmentSrc(){return Ap}static from(t,e,i){const r=t+e;let n=_a[r];return n||(_a[r]=n=new er(t,e,i)),n}};Ra.defaultVertexPrecision=Xt.HIGH,Ra.defaultFragmentPrecision=ce.apple.device?Xt.HIGH:Xt.MEDIUM;let Ae=Ra,Lp=0;class Qt{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=Lp++,this.static=!!e,this.ubo=!!i,t instanceof At?(this.buffer=t,this.buffer.type=ue.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new At(new Float32Array(1)),this.buffer.type=ue.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,i){if(!this.ubo)this.uniforms[t]=new Qt(e,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,e,i){return new Qt(t,e,i)}static uboFrom(t,e){return new Qt(t,e??!0,!0)}}class me{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof Qt?this.uniformGroup=e:this.uniformGroup=new Qt(e):this.uniformGroup=new Qt({}),this.disposeRunner=new Wt("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const r=e.uniforms[i];if(r.group===!0&&this.checkUniformExists(t,r))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,e,i){const r=Ae.from(t,e);return new me(r,i)}}class ru{constructor(t,e){if(this.vertexSrc=t,this.fragTemplate=e,this.programCache={},this.defaultGroupCache={},!e.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!e.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=n;this.defaultGroupCache[t]=Qt.from({uSamplers:i},!0);let r=this.fragTemplate;r=r.replace(/%count%/gi,`${t}`),r=r.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new Ae(this.vertexSrc,r)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new vt,default:this.defaultGroupCache[t]};return new me(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=`
307
+ `,e+=`
308
+ `;for(let i=0;i<t;i++)i>0&&(e+=`
309
+ else `),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+=`
310
+ {`,e+=`
311
+ color = texture2D(uSamplers[${i}], vTextureCoord);`,e+=`
312
+ }`;return e+=`
313
+ `,e+=`
314
+ `,e}}class ys{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}function Op(){return!ce.apple.device}function kp(s){let t=!0;const e=q.ADAPTER.getNavigator();if(ce.tablet||ce.phone){if(ce.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(ce.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?s:4}class _r{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var Np=`varying vec2 vTextureCoord;
315
+ varying vec4 vColor;
316
+ varying float vTextureId;
317
+ uniform sampler2D uSamplers[%count%];
258
318
 
259
319
  void main(void){
260
- gl_FragColor *= texture2D(uSampler, vTextureCoord);
261
- }`,Yv=`attribute vec2 aVertexPosition;
320
+ vec4 color;
321
+ %forloop%
322
+ gl_FragColor = color * vColor;
323
+ }
324
+ `,Up=`precision highp float;
325
+ attribute vec2 aVertexPosition;
262
326
  attribute vec2 aTextureCoord;
327
+ attribute vec4 aColor;
328
+ attribute float aTextureId;
263
329
 
264
330
  uniform mat3 projectionMatrix;
331
+ uniform mat3 translationMatrix;
332
+ uniform vec4 tint;
265
333
 
266
334
  varying vec2 vTextureCoord;
335
+ varying vec4 vColor;
336
+ varying float vTextureId;
267
337
 
268
338
  void main(void){
269
- gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
270
- vTextureCoord = aTextureCoord;
339
+ gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
340
+
341
+ vTextureCoord = aTextureCoord;
342
+ vTextureId = aTextureId;
343
+ vColor = aColor * tint;
271
344
  }
272
- `,qv=0,ki={},_r=function(){function i(t,e,r){r===void 0&&(r="pixi-shader"),this.id=qv++,this.vertexSrc=t||i.defaultVertexSrc,this.fragmentSrc=e||i.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.vertexSrc.substring(0,8)!=="#version"&&(r=r.replace(/\s+/g,"-"),ki[r]?(ki[r]++,r+="-"+ki[r]):ki[r]=1,this.vertexSrc="#define SHADER_NAME "+r+`
273
- `+this.vertexSrc,this.fragmentSrc="#define SHADER_NAME "+r+`
274
- `+this.fragmentSrc,this.vertexSrc=pu(this.vertexSrc,z.PRECISION_VERTEX,kt.HIGH),this.fragmentSrc=pu(this.fragmentSrc,z.PRECISION_FRAGMENT,Uv())),this.glPrograms={},this.syncUniforms=null}return Object.defineProperty(i,"defaultVertexSrc",{get:function(){return Yv},enumerable:!1,configurable:!0}),Object.defineProperty(i,"defaultFragmentSrc",{get:function(){return Wv},enumerable:!1,configurable:!0}),i.from=function(t,e,r){var n=t+e,s=ys[n];return s||(ys[n]=s=new i(t,e,r)),s},i}(),be=function(){function i(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof Re?this.uniformGroup=e:this.uniformGroup=new Re(e):this.uniformGroup=new Re({}),this.disposeRunner=new Dt("disposeShader")}return i.prototype.checkUniformExists=function(t,e){if(e.uniforms[t])return!0;for(var r in e.uniforms){var n=e.uniforms[r];if(n.group&&this.checkUniformExists(t,n))return!0}return!1},i.prototype.destroy=function(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()},Object.defineProperty(i.prototype,"uniforms",{get:function(){return this.uniformGroup.uniforms},enumerable:!1,configurable:!0}),i.from=function(t,e,r){var n=_r.from(t,e);return new i(n,r)},i}(),js=0,zs=1,Ws=2,Ys=3,qs=4,$s=5,Oe=function(){function i(){this.data=0,this.blendMode=tt.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}return Object.defineProperty(i.prototype,"blend",{get:function(){return!!(this.data&1<<js)},set:function(t){!!(this.data&1<<js)!==t&&(this.data^=1<<js)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"offsets",{get:function(){return!!(this.data&1<<zs)},set:function(t){!!(this.data&1<<zs)!==t&&(this.data^=1<<zs)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"culling",{get:function(){return!!(this.data&1<<Ws)},set:function(t){!!(this.data&1<<Ws)!==t&&(this.data^=1<<Ws)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depthTest",{get:function(){return!!(this.data&1<<Ys)},set:function(t){!!(this.data&1<<Ys)!==t&&(this.data^=1<<Ys)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depthMask",{get:function(){return!!(this.data&1<<$s)},set:function(t){!!(this.data&1<<$s)!==t&&(this.data^=1<<$s)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"clockwiseFrontFace",{get:function(){return!!(this.data&1<<qs)},set:function(t){!!(this.data&1<<qs)!==t&&(this.data^=1<<qs)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"blendMode",{get:function(){return this._blendMode},set:function(t){this.blend=t!==tt.NONE,this._blendMode=t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"polygonOffset",{get:function(){return this._polygonOffset},set:function(t){this.offsets=!!t,this._polygonOffset=t},enumerable:!1,configurable:!0}),i.prototype.toString=function(){return"[@pixi/core:State "+("blendMode="+this.blendMode+" ")+("clockwiseFrontFace="+this.clockwiseFrontFace+" ")+("culling="+this.culling+" ")+("depthMask="+this.depthMask+" ")+("polygonOffset="+this.polygonOffset)+"]"},i.for2d=function(){var t=new i;return t.depthTest=!1,t.blend=!0,t},i}(),$v=`varying vec2 vTextureCoord;
345
+ `;const yr=class xe extends _r{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Sa,this.vertexSize=6,this.state=fe.for2d(),this.size=xe.defaultBatchSize*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),t.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??kp(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??Op(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return ot("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return Up}static get defaultFragmentTemplate(){return Np}setShaderGenerator({vertex:t=xe.defaultVertexSrc,fragment:e=xe.defaultFragmentTemplate}={}){this.shaderGenerator=new ru(t,e)}contextChange(){const t=this.renderer.gl;q.PREFER_ENV===Zt.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),xe.defaultMaxTextures),this.maxTextures=Hl(this.maxTextures,t)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let e=0;e<this._packedGeometryPoolSize;e++)this._packedGeometries[e]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:t,_textureArrayPool:e}=xe,i=this.size/4,r=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new ds);for(;e.length<r;)e.push(new ys);for(let n=0;n<this.maxTextures;n++)this._tempBoundTextures[n]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:e}=this,i=xe._textureArrayPool,r=this.renderer.batch,n=this._tempBoundTextures,a=this.renderer.textureGC.count;let o=++lt._globalBatch,h=0,l=i[0],u=0;r.copyBoundTextures(n,e);for(let c=0;c<this._bufferSize;++c){const d=t[c];t[c]=null,d._batchEnabled!==o&&(l.count>=e&&(r.boundArray(l,n,o,e),this.buildDrawCalls(l,u,c),u=c,l=i[++h],++o),d._batchEnabled=o,d.touched=a,l.elements[l.count++]=d)}l.count>0&&(r.boundArray(l,n,o,e),this.buildDrawCalls(l,u,this._bufferSize),++h,++o);for(let c=0;c<n.length;c++)n[c]=null;lt._globalBatch=o}buildDrawCalls(t,e,i){const{_bufferedElements:r,_attributeBuffer:n,_indexBuffer:a,vertexSize:o}=this,h=xe._drawCallPool;let l=this._dcIndex,u=this._aIndex,c=this._iIndex,d=h[l];d.start=this._iIndex,d.texArray=t;for(let f=e;f<i;++f){const p=r[f],g=p._texture.baseTexture,m=ca[g.alphaMode?1:0][p.blendMode];r[f]=null,e<f&&d.blend!==m&&(d.size=c-d.start,e=f,d=h[++l],d.texArray=t,d.start=c),this.packInterleavedGeometry(p,n,a,u,c),u+=p.vertexData.length/2*o,c+=p.indices.length,d.blend=m}e<i&&(d.size=c-d.start,++l),this._dcIndex=l,this._aIndex=u,this._iIndex=c}bindAndClearTexArray(t){const e=this.renderer.texture;for(let i=0;i<t.count;i++)e.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:e,_indexBuffer:i}=this;xe.canUploadSameBuffer?(t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,t[this._flushId]=new this.geometryClass),t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:e,state:i}=this.renderer,r=xe._drawCallPool;let n=null;for(let a=0;a<t;a++){const{texArray:o,type:h,size:l,start:u,blend:c}=r[a];n!==o&&(n=o,this.bindAndClearTexArray(o)),this.state.blendMode=c,i.set(this.state),e.drawElements(h,l,e.UNSIGNED_SHORT,u*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),xe.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]&&this._packedGeometries[t].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(t){const e=lr(Math.ceil(t/8)),i=pa(e),r=e*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._aBuffers[r];return n||(this._aBuffers[r]=n=new us(r*this.vertexSize*4)),n}getIndexBuffer(t){const e=lr(Math.ceil(t/12)),i=pa(e),r=e*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._iBuffers[i];return n||(this._iBuffers[i]=n=new Uint16Array(r)),n}packInterleavedGeometry(t,e,i,r,n){const{uint32View:a,float32View:o}=e,h=r/this.vertexSize,l=t.uvs,u=t.indices,c=t.vertexData,d=t._texture.baseTexture._batchLocation,f=Math.min(t.worldAlpha,1),p=gt.shared.setValue(t._tintRGB).toPremultiplied(f,t._texture.baseTexture.alphaMode>0);for(let g=0;g<c.length;g+=2)o[r++]=c[g],o[r++]=c[g+1],o[r++]=l[g],o[r++]=l[g+1],a[r++]=p,o[r++]=d;for(let g=0;g<u.length;g++)i[n++]=h+u[g]}};yr.defaultBatchSize=4096,yr.extension={name:"batch",type:$.RendererPlugin},yr._drawCallPool=[],yr._textureArrayPool=[];let Ze=yr;Q.add(Ze);var Gp=`varying vec2 vTextureCoord;
275
346
 
276
347
  uniform sampler2D uSampler;
277
348
 
278
349
  void main(void){
279
350
  gl_FragColor = texture2D(uSampler, vTextureCoord);
280
351
  }
281
- `,Kv=`attribute vec2 aVertexPosition;
352
+ `,Vp=`attribute vec2 aVertexPosition;
282
353
 
283
354
  uniform mat3 projectionMatrix;
284
355
 
@@ -304,23 +375,7 @@ void main(void)
304
375
  gl_Position = filterVertexPosition();
305
376
  vTextureCoord = filterTextureCoord();
306
377
  }
307
- `,Te=function(i){mt(t,i);function t(e,r,n){var s=this,a=_r.from(e||t.defaultVertexSrc,r||t.defaultFragmentSrc);return s=i.call(this,a,n)||this,s.padding=0,s.resolution=z.FILTER_RESOLUTION,s.multisample=z.FILTER_MULTISAMPLE,s.enabled=!0,s.autoFit=!0,s.state=new Oe,s}return t.prototype.apply=function(e,r,n,s,a){e.applyFilter(this,r,n,s)},Object.defineProperty(t.prototype,"blendMode",{get:function(){return this.state.blendMode},set:function(e){this.state.blendMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resolution",{get:function(){return this._resolution},set:function(e){this._resolution=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"defaultVertexSrc",{get:function(){return Kv},enumerable:!1,configurable:!0}),Object.defineProperty(t,"defaultFragmentSrc",{get:function(){return $v},enumerable:!1,configurable:!0}),t}(be),Zv=`attribute vec2 aVertexPosition;
308
- attribute vec2 aTextureCoord;
309
-
310
- uniform mat3 projectionMatrix;
311
- uniform mat3 otherMatrix;
312
-
313
- varying vec2 vMaskCoord;
314
- varying vec2 vTextureCoord;
315
-
316
- void main(void)
317
- {
318
- gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
319
-
320
- vTextureCoord = aTextureCoord;
321
- vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;
322
- }
323
- `,Jv=`varying vec2 vMaskCoord;
378
+ `;const Da=class Jr extends me{constructor(t,e,i){const r=Ae.from(t||Jr.defaultVertexSrc,e||Jr.defaultFragmentSrc);super(r,i),this.padding=0,this.resolution=Jr.defaultResolution,this.multisample=Jr.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new fe}apply(t,e,i,r,n){t.applyFilter(this,e,i,r)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return Vp}static get defaultFragmentSrc(){return Gp}};Da.defaultResolution=1,Da.defaultMultisample=St.NONE;let kt=Da;class vr{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new gt(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:r}=t,n=i??e;n!==void 0&&(this.color=n),this.alpha=r}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}vr.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},vr.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"background"},Q.add(vr);class Fa{constructor(t){this.renderer=t,this.emptyRenderer=new _r(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:i}=this.renderer.texture;for(let r=e-1;r>=0;--r)t[r]=i[r]||null,t[r]&&(t[r]._batchLocation=r)}boundArray(t,e,i,r){const{elements:n,ids:a,count:o}=t;let h=0;for(let l=0;l<o;l++){const u=n[l],c=u._batchLocation;if(c>=0&&c<r&&e[c]===u){a[l]=c;continue}for(;h<r;){const d=e[h];if(d&&d._batchEnabled===i&&d._batchLocation===h){h++;continue}a[l]=h,u._batchLocation=h,e[h]=u;break}}}destroy(){this.renderer=null}}Fa.extension={type:$.RendererSystem,name:"batch"},Q.add(Fa);let su=0;class xr{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=su++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:i,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=su++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;e.addEventListener!==void 0&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let i;if(q.PREFER_ENV>=Zt.WEBGL2&&(i=t.getContext("webgl2",e)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,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"),bptc:t.getExtension("EXT_texture_compression_bptc")};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")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const r=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=r,r||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}xr.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},xr.extension={type:$.RendererSystem,name:"context"},Q.add(xr);class vs{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");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 Wt("disposeFramebuffer"),this.multisample=St.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new lt(null,{scaleMode:be.NEAREST,resolution:1,mipmap:he.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new lt(null,{scaleMode:be.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:he.OFF,format:H.DEPTH_COMPONENT,type:it.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,e){if(t=Math.round(t),e=Math.round(e),!t||!e)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const r=this.colorTextures[i],n=r.resolution;r.setSize(t/n,e/n)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,e/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Ba extends lt{constructor(t={}){if(typeof t=="number"){const e=arguments[0],i=arguments[1],r=arguments[2],n=arguments[3];t={width:e,height:i,scaleMode:r,resolution:n}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=St.NONE),super(null,t),this.mipmap=he.OFF,this.valid=!0,this._clear=new gt([0,0,0,0]),this.framebuffer=new vs(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e){this.framebuffer.resize(t*this.resolution,e*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class Se extends Di{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.displayWidth||e.width,r=e.naturalHeight||e.videoHeight||e.displayHeight||e.height;super(i,r),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=Gl(e):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,e,i,r){const n=t.gl,a=e.realWidth,o=e.realHeight;if(r=r||this.source,typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement){if(!r.complete||r.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement&&r.readyState<=1)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Nt.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&i.width===a&&i.height===o?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,i.type,r):(i.width=a,i.height=o,n.texImage2D(e.target,0,i.internalFormat,e.format,i.type,r)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(e,i),super.update()}dispose(){this.source=null}}class La extends Se{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;Se.crossOrigin(i,t,e.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(e.createBitmap??q.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.bitmap=null,this._load=null,e.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((e,i)=>{const r=this.source;this.url=r.src;const n=()=>{this.destroyed||(r.onload=null,r.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};r.complete&&r.src?n():(r.onload=n,r.onerror=a=>{i(a),this.onError.emit(a)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(r=>r.blob()).then(r=>e(r,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Nt.UNPACK?"premultiply":"none"})).then(r=>this.destroyed?Promise.reject():(this.bitmap=r,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,i){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let r=!0;const n=e._glTextures;for(const a in n){const o=n[a];if(o!==i&&o.dirtyId!==e.dirtyId){r=!1;break}}r&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class xs{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const r=e.width,n=e.height;if(i){const a=t.width/2/r,o=t.height/2/n,h=t.x/r+a,l=t.y/n+o;i=wt.add(i,wt.NW),this.x0=h+a*wt.uX(i),this.y0=l+o*wt.uY(i),i=wt.add(i,2),this.x1=h+a*wt.uX(i),this.y1=l+o*wt.uY(i),i=wt.add(i,2),this.x2=h+a*wt.uX(i),this.y2=l+o*wt.uY(i),i=wt.add(i,2),this.x3=h+a*wt.uX(i),this.y3=l+o*wt.uY(i)}else this.x0=t.x/r,this.y0=t.y/n,this.x1=(t.x+t.width)/r,this.y1=t.y/n,this.x2=(t.x+t.width)/r,this.y2=(t.y+t.height)/n,this.x3=t.x/r,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}xs.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const nu=new xs;function bs(s){s.destroy=function(){},s.on=function(){},s.once=function(){},s.emit=function(){}}class j extends Ee{constructor(t,e,i,r,n,a,o){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new ut(0,0,1,1)),t instanceof j&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=r,this.valid=!1,this.destroyed=!1,this._uvs=nu,this.uvMatrix=null,this.orig=i||e,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=a?new ft(a.x,a.y):new ft(0,0),this.defaultBorders=o,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:e}=this.baseTexture;e!=null&&e.url&&Ut[e.url]&&j.removeFromCache(e.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,j.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var r;const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),i=new j(this.baseTexture,!this.noFrame&&t,e,(r=this.trim)==null?void 0:r.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===nu&&(this._uvs=new xs),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=q.STRICT_TEXTURE_CACHE){const r=typeof t=="string";let n=null;if(r)n=t;else if(t instanceof lt){if(!t.cacheId){const o=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${o}-${qe()}`,lt.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const o=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${o}_${qe()}`}n=t._pixiId}let a=Ut[n];if(r&&i&&!a)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!a&&!(t instanceof lt)?(e.resolution||(e.resolution=Ce(t)),a=new j(new lt(t,e)),a.baseTexture.cacheId=n,lt.addToCache(a.baseTexture,n),j.addToCache(a,n)):!a&&t instanceof lt&&(a=new j(t),j.addToCache(a,n)),a}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),r=j.from(t,Object.assign({resourceOptions:i},e),!1),n=r.baseTexture.resource;return r.baseTexture.valid?Promise.resolve(r):n.load().then(()=>Promise.resolve(r))}static fromBuffer(t,e,i,r){return new j(lt.fromBuffer(t,e,i,r))}static fromLoader(t,e,i,r){const n=new lt(t,Object.assign({scaleMode:lt.defaultOptions.scaleMode,resolution:Ce(e)},r)),{resource:a}=n;a instanceof La&&(a.url=e);const o=new j(n);return i||(i=e),lt.addToCache(o.baseTexture,i),j.addToCache(o,i),i!==e&&(lt.addToCache(o.baseTexture,e),j.addToCache(o,e)),o.baseTexture.valid?Promise.resolve(o):new Promise(h=>{o.baseTexture.once("loaded",()=>h(o))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),Ut[e]&&Ut[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),Ut[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=Ut[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete Ut[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)Ut[t.textureCacheIds[e]]===t&&delete Ut[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:i,width:r,height:n}=t,a=e+r>this.baseTexture.width,o=i+n>this.baseTexture.height;if(a||o){const h=a&&o?"and":"or",l=`X: ${e} + ${r} = ${e+r} > ${this.baseTexture.width}`,u=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${l} ${h} ${u}`)}this.valid=r&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return j._EMPTY||(j._EMPTY=new j(new lt),bs(j._EMPTY),bs(j._EMPTY.baseTexture)),j._EMPTY}static get WHITE(){if(!j._WHITE){const t=q.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),j._WHITE=new j(lt.from(t)),bs(j._WHITE),bs(j._WHITE.baseTexture)}return j._WHITE}}class Je extends j{constructor(t,e){super(t,e),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e,i=!0){const r=this.baseTexture.resolution,n=Math.round(t*r)/r,a=Math.round(e*r)/r;this.valid=n>0&&a>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=a,i&&this.baseTexture.resize(n,a),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new Je(new Ba(t))}}class Oa{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=St.NONE){const r=new Ba(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new Je(r)}getOptimalTexture(t,e,i=1,r=St.NONE){let n;t=Math.max(Math.ceil(t*i-1e-6),1),e=Math.max(Math.ceil(e*i-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=lr(t),e=lr(e),n=((t&65535)<<16|e&65535)>>>0,r>1&&(n+=r*4294967296)):n=r>1?-r:-1,this.texturePool[n]||(this.texturePool[n]=[]);let a=this.texturePool[n].pop();return a||(a=this.createTexture(t,e,r)),a.filterPoolKey=n,a.setResolution(i),a}getFilterTexture(t,e,i){const r=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||St.NONE);return r.filterFrame=t.filterFrame,r}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const e in this.texturePool){const i=this.texturePool[e];if(i)for(let r=0;r<i.length;r++)i[r].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const i=this.texturePool[e];if(i)for(let r=0;r<i.length;r++)i[r].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}Oa.SCREEN_KEY=-1;class au extends Ue{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class ka extends Ue{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new At(this.vertices),this.uvBuffer=new At(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,r=0;return this.uvs[0]=i,this.uvs[1]=r,this.uvs[2]=i+e.width/t.width,this.uvs[3]=r,this.uvs[4]=i+e.width/t.width,this.uvs[5]=r+e.height/t.height,this.uvs[6]=i,this.uvs[7]=r+e.height/t.height,i=e.x,r=e.y,this.vertices[0]=i,this.vertices[1]=r,this.vertices[2]=i+e.width,this.vertices[3]=r,this.vertices[4]=i+e.width,this.vertices[5]=r+e.height,this.vertices[6]=i,this.vertices[7]=r+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class ou{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=St.NONE,this.sourceFrame=new ut,this.destinationFrame=new ut,this.bindingSourceFrame=new ut,this.bindingDestinationFrame=new ut,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const Ts=[new ft,new ft,new ft,new ft],Na=new vt;class Ua{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Oa,this.statePool=[],this.quad=new au,this.quadUv=new ka,this.tempRect=new ut,this.activeState={},this.globalUniforms=new Qt({outputFrame:new ut,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const i=this.renderer,r=this.defaultFilterStack,n=this.statePool.pop()||new ou,a=i.renderTexture;let o,h;if(a.current){const m=a.current;o=m.resolution,h=m.multisample}else o=i.resolution,h=i.multisample;let l=e[0].resolution||o,u=e[0].multisample??h,c=e[0].padding,d=e[0].autoFit,f=e[0].legacy??!0;for(let m=1;m<e.length;m++){const _=e[m];l=Math.min(l,_.resolution||o),u=Math.min(u,_.multisample??h),c=this.useMaxPadding?Math.max(c,_.padding):c+_.padding,d=d&&_.autoFit,f=f||(_.legacy??!0)}r.length===1&&(this.defaultFilterStack[0].renderTexture=a.current),r.push(n),n.resolution=l,n.multisample=u,n.legacy=f,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(c);const p=this.tempRect.copyFrom(a.sourceFrame);i.projection.transform&&this.transformAABB(Na.copyFrom(i.projection.transform).invert(),p),d?(n.sourceFrame.fit(p),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(p)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,a.current?a.current.resolution:i.resolution,a.sourceFrame,a.destinationFrame,i.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,l,u),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const g=this.tempRect;g.x=0,g.y=0,g.width=n.sourceFrame.width,g.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(a.sourceFrame),n.bindingDestinationFrame.copyFrom(a.destinationFrame),n.transform=i.projection.transform,i.projection.transform=null,a.bind(n.renderTexture,n.sourceFrame,g),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const r=this.globalUniforms.uniforms;r.outputFrame=e.sourceFrame,r.resolution=e.resolution;const n=r.inputSize,a=r.inputPixel,o=r.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],a[0]=Math.round(n[0]*e.resolution),a[1]=Math.round(n[1]*e.resolution),a[2]=1/a[0],a[3]=1/a[1],o[0]=.5*a[2],o[1]=.5*a[3],o[2]=e.sourceFrame.width*n[2]-.5*a[2],o[3]=e.sourceFrame.height*n[3]-.5*a[3],e.legacy){const l=r.filterArea;l[0]=e.destinationFrame.width,l[1]=e.destinationFrame.height,l[2]=e.sourceFrame.x,l[3]=e.sourceFrame.y,r.filterClamp=r.inputClamp}this.globalUniforms.update();const h=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,e.renderTexture,h.renderTexture,le.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let l=e.renderTexture,u=this.getOptimalFilterTexture(l.width,l.height,e.resolution);u.filterFrame=l.filterFrame;let c=0;for(c=0;c<i.length-1;++c){c===1&&e.multisample>1&&(u=this.getOptimalFilterTexture(l.width,l.height,e.resolution),u.filterFrame=l.filterFrame),i[c].apply(this,l,u,le.CLEAR,e);const d=l;l=u,u=d}i[c].apply(this,l,h.renderTexture,le.BLEND,e),c>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(l),this.returnFilterTexture(u)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=le.CLEAR){const{renderTexture:i,state:r}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t==null?void 0:t.filterFrame){const a=this.tempRect;a.x=0,a.y=0,a.width=t.filterFrame.width,a.height=t.filterFrame.height,i.bind(t,t.filterFrame,a)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=r.stateId&1||this.forceClear;(e===le.CLEAR||e===le.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,r){const n=this.renderer;n.state.set(t.state),this.bindAndClear(i,r),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(oe.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(oe.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:r}=this.activeState,{orig:n}=e._texture,a=t.set(r.width,0,0,r.height,i.x,i.y),o=e.worldTransform.copyTo(vt.TEMP_MATRIX);return o.invert(),a.prepend(o),a.scale(1/n.width,1/n.height),a.translate(e.anchor.x,e.anchor.y),a}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,i=1,r=St.NONE){return this.texturePool.getOptimalTexture(t,e,i,r)}getFilterTexture(t,e,i){if(typeof t=="number"){const n=t;t=e,e=n}t=t||this.activeState.renderTexture;const r=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,i||St.NONE);return r.filterFrame=t.filterFrame,r}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=Ts[0],r=Ts[1],n=Ts[2],a=Ts[3];i.set(e.left,e.top),r.set(e.left,e.bottom),n.set(e.right,e.top),a.set(e.right,e.bottom),t.apply(i,i),t.apply(r,r),t.apply(n,n),t.apply(a,a);const o=Math.min(i.x,r.x,n.x,a.x),h=Math.min(i.y,r.y,n.y,a.y),l=Math.max(i.x,r.x,n.x,a.x),u=Math.max(i.y,r.y,n.y,a.y);e.x=o,e.y=h,e.width=l-o,e.height=u-h}roundFrame(t,e,i,r,n){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(n){const{a,b:o,c:h,d:l}=n;if((Math.abs(o)>1e-4||Math.abs(h)>1e-4)&&(Math.abs(a)>1e-4||Math.abs(l)>1e-4))return}n=n?Na.copyFrom(n):Na.identity(),n.translate(-i.x,-i.y).scale(r.width/i.width,r.height/i.height).translate(r.x,r.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}Ua.extension={type:$.RendererSystem,name:"filter"},Q.add(Ua);class hu{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=St.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const Hp=new ut;class Ga{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new vs(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new ut,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;q.PREFER_ENV===Zt.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=r=>e.drawBuffersWEBGL(r):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,i=0){const{gl:r}=this;if(t){const n=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,r.bindFramebuffer(r.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=i),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let a=0;a<t.colorTextures.length;a++){const o=t.colorTextures[a];this.renderer.texture.unbind(o.parentTextureArray||o)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const a=e.width>>i,o=e.height>>i,h=a/e.width;this.setViewport(e.x*h,e.y*h,a,o)}else{const a=t.width>>i,o=t.height>>i;this.setViewport(0,0,a,o)}}else this.current&&(this.current=null,r.bindFramebuffer(r.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,i,r){const n=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),r=Math.round(r),(n.width!==i||n.height!==r||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=i,n.height=r,this.gl.viewport(t,e,i,r))}get size(){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}}clear(t,e,i,r,n=rs.COLOR|rs.DEPTH){const{gl:a}=this;a.clearColor(t,e,i,r),a.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new hu(e.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:e}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){e.bindRenderbuffer(e.RENDERBUFFER,i.stencil);let a;this.renderer.context.webGLVersion===1?a=e.DEPTH_STENCIL:t.depth&&t.stencil?a=e.DEPTH24_STENCIL8:t.depth?a=e.DEPTH_COMPONENT24:a=e.STENCIL_INDEX8,i.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,a,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,a,t.width,t.height)}const r=t.colorTextures;let n=r.length;e.drawBuffers||(n=Math.min(n,1));for(let a=0;a<n;a++){const o=r[a],h=o.parentTextureArray||o;this.renderer.texture.bind(h,0),a===0&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,h._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:i}=this,r=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let a=n.length;i.drawBuffers||(a=Math.min(a,1)),r.multisample>1&&this.canMultisampleFramebuffer(t)?r.msaaBuffer=r.msaaBuffer||i.createRenderbuffer():r.msaaBuffer&&(i.deleteRenderbuffer(r.msaaBuffer),r.msaaBuffer=null,r.blitFramebuffer&&(r.blitFramebuffer.dispose(),r.blitFramebuffer=null));const o=[];for(let h=0;h<a;h++){const l=n[h],u=l.parentTextureArray||l;this.renderer.texture.bind(u,0),h===0&&r.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,r.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,u._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,r.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+h,l.target,u._glTextures[this.CONTEXT_UID].texture,e),o.push(i.COLOR_ATTACHMENT0+h))}if(o.length>1&&i.drawBuffers(o),t.depthTexture&&this.writeDepthTexture){const h=t.depthTexture;this.renderer.texture.bind(h,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,h._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){r.stencil=r.stencil||i.createRenderbuffer();let h,l;this.renderer.context.webGLVersion===1?(h=i.DEPTH_STENCIL_ATTACHMENT,l=i.DEPTH_STENCIL):t.depth&&t.stencil?(h=i.DEPTH_STENCIL_ATTACHMENT,l=i.DEPTH24_STENCIL8):t.depth?(h=i.DEPTH_ATTACHMENT,l=i.DEPTH_COMPONENT24):(h=i.STENCIL_ATTACHMENT,l=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,r.stencil),r.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,l,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,l,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,h,i.RENDERBUFFER,r.stencil)}else r.stencil&&(i.deleteRenderbuffer(r.stencil),r.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=St.NONE;if(t<=1||e===null)return i;for(let r=0;r<e.length;r++)if(e[r]<=t){i=e[r];break}return i===1&&(i=St.NONE),i}blit(t,e,i){const{current:r,renderer:n,gl:a,CONTEXT_UID:o}=this;if(n.context.webGLVersion!==2||!r)return;const h=r.glFramebuffers[o];if(!h)return;if(!t){if(!h.msaaBuffer)return;const u=r.colorTextures[0];if(!u)return;h.blitFramebuffer||(h.blitFramebuffer=new vs(r.width,r.height),h.blitFramebuffer.addColorTexture(0,u)),t=h.blitFramebuffer,t.colorTextures[0]!==u&&(t.colorTextures[0]=u,t.dirtyId++,t.dirtyFormat++),(t.width!==r.width||t.height!==r.height)&&(t.width=r.width,t.height=r.height,t.dirtyId++,t.dirtySize++)}e||(e=Hp,e.width=r.width,e.height=r.height),i||(i=e);const l=e.width===i.width&&e.height===i.height;this.bind(t),a.bindFramebuffer(a.READ_FRAMEBUFFER,h.framebuffer),a.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,a.COLOR_BUFFER_BIT,l?a.NEAREST:a.LINEAR),a.bindFramebuffer(a.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const i=t.glFramebuffers[this.CONTEXT_UID],r=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(r.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&r.deleteRenderbuffer(i.msaaBuffer),i.stencil&&r.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<e.length;i++)this.disposeFramebuffer(e[i],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,r=t.height,n=this.gl,a=e.stencil=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,a);let o,h;this.renderer.context.webGLVersion===1?(o=n.DEPTH_STENCIL_ATTACHMENT,h=n.DEPTH_STENCIL):t.depth?(o=n.DEPTH_STENCIL_ATTACHMENT,h=n.DEPTH24_STENCIL8):(o=n.STENCIL_ATTACHMENT,h=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,h,i,r):n.renderbufferStorage(n.RENDERBUFFER,h,i,r),n.framebufferRenderbuffer(n.FRAMEBUFFER,o,n.RENDERBUFFER,a)}reset(){this.current=this.unknownFramebuffer,this.viewport=new ut}destroy(){this.renderer=null}}Ga.extension={type:$.RendererSystem,name:"framebuffer"},Q.add(Ga);const Va={5126:4,5123:2,5121:1};class Ha{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,e.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;q.PREFER_ENV===Zt.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=r=>i.bindVertexArrayOES(r),t.deleteVertexArray=r=>i.deleteVertexArrayOES(r)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(r,n)=>i.vertexAttribDivisorANGLE(r,n),t.drawElementsInstanced=(r,n,a,o,h)=>i.drawElementsInstancedANGLE(r,n,a,o,h),t.drawArraysInstanced=(r,n,a,o)=>i.drawArraysInstancedANGLE(r,n,a,o)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:i}=this;let r=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;r||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=r={},n=!0);const a=r[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==a&&(this._activeVao=a,this.hasVao?i.bindVertexArray(a):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const r=t.buffers[i];e.update(r)}}checkCompatibility(t,e){const i=t.attributes,r=e.attributeData;for(const n in r)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,r=e.attributeData,n=["g",t.id];for(const a in i)r[a]&&n.push(a,r[a].location);return n.join("-")}initGeometryVao(t,e,i=!0){const r=this.gl,n=this.CONTEXT_UID,a=this.renderer.buffer,o=e.program;o.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,o);const h=this.getSignature(t,o),l=t.glVertexArrayObjects[this.CONTEXT_UID];let u=l[h];if(u)return l[o.id]=u,u;const c=t.buffers,d=t.attributes,f={},p={};for(const g in c)f[g]=0,p[g]=0;for(const g in d)!d[g].size&&o.attributeData[g]?d[g].size=o.attributeData[g].size:d[g].size||console.warn(`PIXI Geometry attribute '${g}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[g].buffer]+=d[g].size*Va[d[g].type];for(const g in d){const m=d[g],_=m.size;m.stride===void 0&&(f[m.buffer]===_*Va[m.type]?m.stride=0:m.stride=f[m.buffer]),m.start===void 0&&(m.start=p[m.buffer],p[m.buffer]+=_*Va[m.type])}u=r.createVertexArray(),r.bindVertexArray(u);for(let g=0;g<c.length;g++){const m=c[g];a.bind(m),i&&m._glBuffers[n].refCount++}return this.activateVao(t,o),l[o.id]=u,l[h]=u,r.bindVertexArray(null),a.unbind(ue.ARRAY_BUFFER),u}disposeGeometry(t,e){var o;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],r=this.gl,n=t.buffers,a=(o=this.renderer)==null?void 0:o.buffer;if(t.disposeRunner.remove(this),!!i){if(a)for(let h=0;h<n.length;h++){const l=n[h]._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&a.dispose(n[h],e))}if(!e){for(const h in i)if(h[0]==="g"){const l=i[h];this._activeVao===l&&this.unbind(),r.deleteVertexArray(l)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let i=0;i<e.length;i++)this.disposeGeometry(this.managedGeometries[e[i]],t)}activateVao(t,e){const i=this.gl,r=this.CONTEXT_UID,n=this.renderer.buffer,a=t.buffers,o=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let h=null;for(const l in o){const u=o[l],c=a[u.buffer],d=c._glBuffers[r];if(e.attributeData[l]){h!==d&&(n.bind(c),h=d);const f=e.attributeData[l].location;if(i.enableVertexAttribArray(f),i.vertexAttribPointer(f,u.size,u.type||i.FLOAT,u.normalized,u.stride,u.start),u.instance)if(this.hasInstance)i.vertexAttribDivisor(f,u.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,r){const{gl:n}=this,a=this._activeGeometry;if(a.indexBuffer){const o=a.indexBuffer.data.BYTES_PER_ELEMENT,h=o===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;o===2||o===4&&this.canUseUInt32ElementIndex?a.instanced?n.drawElementsInstanced(t,e||a.indexBuffer.data.length,h,(i||0)*o,r||1):n.drawElements(t,e||a.indexBuffer.data.length,h,(i||0)*o):console.warn("unsupported index buffer type: uint32")}else a.instanced?n.drawArraysInstanced(t,i,e||a.getSize(),r||1):n.drawArrays(t,i,e||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}Ha.extension={type:$.RendererSystem,name:"geometry"},Q.add(Ha);const lu=new vt;class Es{constructor(t,e){this._texture=t,this.mapCoord=new vt,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let r=0;r<t.length;r+=2){const n=t[r],a=t[r+1];e[r]=n*i.a+a*i.c+i.tx,e[r+1]=n*i.b+a*i.d+i.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const i=e._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const r=e.orig,n=e.trim;n&&(lu.set(r.width/n.width,0,0,r.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(lu));const a=e.baseTexture,o=this.uClampFrame,h=this.clampMargin/a.resolution,l=this.clampOffset;return o[0]=(e._frame.x+h+l)/a.width,o[1]=(e._frame.y+h+l)/a.height,o[2]=(e._frame.x+e._frame.width-h+l)/a.width,o[3]=(e._frame.y+e._frame.height-h+l)/a.height,this.uClampOffset[0]=l/a.realWidth,this.uClampOffset[1]=l/a.realHeight,this.isSimple=e._frame.width===a.width&&e._frame.height===a.height&&e.rotate===0,!0}}var Xp=`varying vec2 vMaskCoord;
324
379
  varying vec2 vTextureCoord;
325
380
 
326
381
  uniform sampler2D uSampler;
@@ -345,7 +400,23 @@ void main(void)
345
400
 
346
401
  gl_FragColor = original;
347
402
  }
348
- `,yu=new bt,Gi=function(){function i(t,e){this._texture=t,this.mapCoord=new bt,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}return Object.defineProperty(i.prototype,"texture",{get:function(){return this._texture},set:function(t){this._texture=t,this._textureID=-1},enumerable:!1,configurable:!0}),i.prototype.multiplyUvs=function(t,e){e===void 0&&(e=t);for(var r=this.mapCoord,n=0;n<t.length;n+=2){var s=t[n],a=t[n+1];e[n]=s*r.a+a*r.c+r.tx,e[n+1]=s*r.b+a*r.d+r.ty}return e},i.prototype.update=function(t){var e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;var r=e._uvs;this.mapCoord.set(r.x1-r.x0,r.y1-r.y0,r.x3-r.x0,r.y3-r.y0,r.x0,r.y0);var n=e.orig,s=e.trim;s&&(yu.set(n.width/s.width,0,0,n.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(yu));var a=e.baseTexture,o=this.uClampFrame,h=this.clampMargin/a.resolution,u=this.clampOffset;return o[0]=(e._frame.x+h+u)/a.width,o[1]=(e._frame.y+h+u)/a.height,o[2]=(e._frame.x+e._frame.width-h+u)/a.width,o[3]=(e._frame.y+e._frame.height-h+u)/a.height,this.uClampOffset[0]=u/a.realWidth,this.uClampOffset[1]=u/a.realHeight,this.isSimple=e._frame.width===a.width&&e._frame.height===a.height&&e.rotate===0,!0},i}(),xu=function(i){mt(t,i);function t(e,r,n){var s=this,a=null;return typeof e!="string"&&r===void 0&&n===void 0&&(a=e,e=void 0,r=void 0,n=void 0),s=i.call(this,e||Zv,r||Jv,n)||this,s.maskSprite=a,s.maskMatrix=new bt,s}return Object.defineProperty(t.prototype,"maskSprite",{get:function(){return this._maskSprite},set:function(e){this._maskSprite=e,this._maskSprite&&(this._maskSprite.renderable=!1)},enumerable:!1,configurable:!0}),t.prototype.apply=function(e,r,n,s){var a=this._maskSprite,o=a._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new Gi(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=e.calculateSpriteMatrix(this.maskMatrix,a).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=a.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,e.applyFilter(this,r,n,s))},t}(Te),Ks=function(){function i(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}return i.prototype.setMaskStack=function(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)},i.prototype.push=function(t,e){var r=e;if(!r.isMaskData){var n=this.maskDataPool.pop()||new hu;n.pooled=!0,n.maskObject=e,r=n}var s=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(r.copyCountersOrReset(s),r._colorMask=s?s._colorMask:15,r.autoDetect&&this.detect(r),r._target=t,r.type!==It.SPRITE&&this.maskStack.push(r),r.enabled)switch(r.type){case It.SCISSOR:this.renderer.scissor.push(r);break;case It.STENCIL:this.renderer.stencil.push(r);break;case It.SPRITE:r.copyCountersOrReset(null),this.pushSpriteMask(r);break;case It.COLOR:this.pushColorMask(r);break}r.type===It.SPRITE&&this.maskStack.push(r)},i.prototype.pop=function(t){var e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case It.SCISSOR:this.renderer.scissor.pop(e);break;case It.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case It.SPRITE:this.popSpriteMask(e);break;case It.COLOR:this.popColorMask(e);break}if(e.reset(),e.pooled&&this.maskDataPool.push(e),this.maskStack.length!==0){var r=this.maskStack[this.maskStack.length-1];r.type===It.SPRITE&&r._filters&&(r._filters[0].maskSprite=r.maskObject)}}},i.prototype.detect=function(t){var e=t.maskObject;e?e.isSprite?t.type=It.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=It.SCISSOR:t.type=It.STENCIL:t.type=It.COLOR},i.prototype.pushSpriteMask=function(t){var e,r,n=t.maskObject,s=t._target,a=t._filters;a||(a=this.alphaMaskPool[this.alphaMaskIndex],a||(a=this.alphaMaskPool[this.alphaMaskIndex]=[new xu]));var o=this.renderer,h=o.renderTexture,u,l;if(h.current){var c=h.current;u=t.resolution||c.resolution,l=(e=t.multisample)!==null&&e!==void 0?e:c.multisample}else u=t.resolution||o.resolution,l=(r=t.multisample)!==null&&r!==void 0?r:o.multisample;a[0].resolution=u,a[0].multisample=l,a[0].maskSprite=n;var f=s.filterArea;s.filterArea=n.getBounds(!0),o.filter.push(s,a),s.filterArea=f,t._filters||this.alphaMaskIndex++},i.prototype.popSpriteMask=function(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)},i.prototype.pushColorMask=function(t){var e=t._colorMask,r=t._colorMask=e&t.colorMask;r!==e&&this.renderer.gl.colorMask((r&1)!==0,(r&2)!==0,(r&4)!==0,(r&8)!==0)},i.prototype.popColorMask=function(t){var e=t._colorMask,r=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;r!==e&&this.renderer.gl.colorMask((r&1)!==0,(r&2)!==0,(r&4)!==0,(r&8)!==0)},i.prototype.destroy=function(){this.renderer=null},i}(),bu=function(){function i(t){this.renderer=t,this.maskStack=[],this.glConst=0}return i.prototype.getStackLength=function(){return this.maskStack.length},i.prototype.setMaskStack=function(t){var e=this.renderer.gl,r=this.getStackLength();this.maskStack=t;var n=this.getStackLength();n!==r&&(n===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))},i.prototype._useCurrent=function(){},i.prototype.destroy=function(){this.renderer=null,this.maskStack=null},i}(),Tu=new bt,Eu=[],Zs=function(i){mt(t,i);function t(e){var r=i.call(this,e)||this;return r.glConst=z.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST,r}return t.prototype.getStackLength=function(){var e=this.maskStack[this.maskStack.length-1];return e?e._scissorCounter:0},t.prototype.calcScissorRect=function(e){var r;if(!e._scissorRectLocal){var n=e._scissorRect,s=e.maskObject,a=this.renderer,o=a.renderTexture,h=s.getBounds(!0,(r=Eu.pop())!==null&&r!==void 0?r:new ut);this.roundFrameToPixels(h,o.current?o.current.resolution:a.resolution,o.sourceFrame,o.destinationFrame,a.projection.transform),n&&h.fit(n),e._scissorRectLocal=h}},t.isMatrixRotated=function(e){if(!e)return!1;var r=e.a,n=e.b,s=e.c,a=e.d;return(Math.abs(n)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(r)>1e-4||Math.abs(a)>1e-4)},t.prototype.testScissor=function(e){var r=e.maskObject;if(!r.isFastRect||!r.isFastRect()||t.isMatrixRotated(r.worldTransform)||t.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(e);var n=e._scissorRectLocal;return n.width>0&&n.height>0},t.prototype.roundFrameToPixels=function(e,r,n,s,a){t.isMatrixRotated(a)||(a=a?Tu.copyFrom(a):Tu.identity(),a.translate(-n.x,-n.y).scale(s.width/n.width,s.height/n.height).translate(s.x,s.y),this.renderer.filter.transformAABB(a,e),e.fit(s),e.x=Math.round(e.x*r),e.y=Math.round(e.y*r),e.width=Math.round(e.width*r),e.height=Math.round(e.height*r))},t.prototype.push=function(e){e._scissorRectLocal||this.calcScissorRect(e);var r=this.renderer.gl;e._scissorRect||r.enable(r.SCISSOR_TEST),e._scissorCounter++,e._scissorRect=e._scissorRectLocal,this._useCurrent()},t.prototype.pop=function(e){var r=this.renderer.gl;e&&Eu.push(e._scissorRectLocal),this.getStackLength()>0?this._useCurrent():r.disable(r.SCISSOR_TEST)},t.prototype._useCurrent=function(){var e=this.maskStack[this.maskStack.length-1]._scissorRect,r;this.renderer.renderTexture.current?r=e.y:r=this.renderer.height-e.height-e.y,this.renderer.gl.scissor(e.x,r,e.width,e.height)},t}(bu),Js=function(i){mt(t,i);function t(e){var r=i.call(this,e)||this;return r.glConst=z.ADAPTER.getWebGLRenderingContext().STENCIL_TEST,r}return t.prototype.getStackLength=function(){var e=this.maskStack[this.maskStack.length-1];return e?e._stencilCounter:0},t.prototype.push=function(e){var r=e.maskObject,n=this.renderer.gl,s=e._stencilCounter;s===0&&(this.renderer.framebuffer.forceStencil(),n.clearStencil(0),n.clear(n.STENCIL_BUFFER_BIT),n.enable(n.STENCIL_TEST)),e._stencilCounter++;var a=e._colorMask;a!==0&&(e._colorMask=0,n.colorMask(!1,!1,!1,!1)),n.stencilFunc(n.EQUAL,s,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.INCR),r.renderable=!0,r.render(this.renderer),this.renderer.batch.flush(),r.renderable=!1,a!==0&&(e._colorMask=a,n.colorMask((a&1)!==0,(a&2)!==0,(a&4)!==0,(a&8)!==0)),this._useCurrent()},t.prototype.pop=function(e){var r=this.renderer.gl;if(this.getStackLength()===0)r.disable(r.STENCIL_TEST);else{var n=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,s=n?n._colorMask:15;s!==0&&(n._colorMask=0,r.colorMask(!1,!1,!1,!1)),r.stencilOp(r.KEEP,r.KEEP,r.DECR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,s!==0&&(n._colorMask=s,r.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}(bu),Qs=function(){function i(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new bt,this.transform=null}return i.prototype.update=function(t,e,r,n){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,r,n),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)},i.prototype.calculateProjection=function(t,e,r,n){var s=this.projectionMatrix,a=n?-1:1;s.identity(),s.a=1/e.width*2,s.d=a*(1/e.height*2),s.tx=-1-e.x*s.a,s.ty=-a-e.y*s.d},i.prototype.setTransform=function(t){},i.prototype.destroy=function(){this.renderer=null},i}(),Je=new ut,qr=new ut,ta=function(){function i(t){this.renderer=t,this.clearColor=t._backgroundColorRgba,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new ut,this.destinationFrame=new ut,this.viewportFrame=new ut}return i.prototype.bind=function(t,e,r){t===void 0&&(t=null);var n=this.renderer;this.current=t;var s,a,o;t?(s=t.baseTexture,o=s.resolution,e||(Je.width=t.frame.width,Je.height=t.frame.height,e=Je),r||(qr.x=t.frame.x,qr.y=t.frame.y,qr.width=e.width,qr.height=e.height,r=qr),a=s.framebuffer):(o=n.resolution,e||(Je.width=n.screen.width,Je.height=n.screen.height,e=Je),r||(r=Je,r.width=e.width,r.height=e.height));var h=this.viewportFrame;h.x=r.x*o,h.y=r.y*o,h.width=r.width*o,h.height=r.height*o,t||(h.y=n.view.height-(h.y+h.height)),h.ceil(),this.renderer.framebuffer.bind(a,h),this.renderer.projection.update(r,e,o,!a),t?this.renderer.mask.setMaskStack(s.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(r)},i.prototype.clear=function(t,e){this.current?t=t||this.current.baseTexture.clearColor:t=t||this.clearColor;var r=this.destinationFrame,n=this.current?this.current.baseTexture:this.renderer.screen,s=r.width!==n.width||r.height!==n.height;if(s){var a=this.viewportFrame,o=a.x,h=a.y,u=a.width,l=a.height;o=Math.round(o),h=Math.round(h),u=Math.round(u),l=Math.round(l),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(o,h,u,l)}this.renderer.framebuffer.clear(t[0],t[1],t[2],t[3],e),s&&this.renderer.scissor.pop()},i.prototype.resize=function(){this.bind(null)},i.prototype.reset=function(){this.bind(null)},i.prototype.destroy=function(){this.renderer=null},i}();function Qv(i,t,e,r,n){e.buffer.update(n)}var t_={float:`
403
+ `,zp=`attribute vec2 aVertexPosition;
404
+ attribute vec2 aTextureCoord;
405
+
406
+ uniform mat3 projectionMatrix;
407
+ uniform mat3 otherMatrix;
408
+
409
+ varying vec2 vMaskCoord;
410
+ varying vec2 vTextureCoord;
411
+
412
+ void main(void)
413
+ {
414
+ gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
415
+
416
+ vTextureCoord = aTextureCoord;
417
+ vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;
418
+ }
419
+ `;class uu extends kt{constructor(t,e,i){let r=null;typeof t!="string"&&e===void 0&&i===void 0&&(r=t,t=void 0,e=void 0,i=void 0),super(t||zp,e||Xp,i),this.maskSprite=r,this.maskMatrix=new vt}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,r){const n=this._maskSprite,a=n._texture;a.valid&&(a.uvMatrix||(a.uvMatrix=new Es(a,0)),a.uvMatrix.update(),this.uniforms.npmAlpha=a.baseTexture.alphaMode?0:1,this.uniforms.mask=a,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,n).prepend(a.uvMatrix.mapCoord),this.uniforms.alpha=n.worldAlpha,this.uniforms.maskClamp=a.uvMatrix.uClampFrame,t.applyFilter(this,e,i,r))}}class cu{constructor(t=null){this.type=It.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=kt.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=It.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class Xa{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let i=e;if(!i.isMaskData){const n=this.maskDataPool.pop()||new cu;n.pooled=!0,n.maskObject=e,i=n}const r=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(r),i._colorMask=r?r._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==It.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case It.SCISSOR:this.renderer.scissor.push(i);break;case It.STENCIL:this.renderer.stencil.push(i);break;case It.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case It.COLOR:this.pushColorMask(i);break}i.type===It.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case It.SCISSOR:this.renderer.scissor.pop(e);break;case It.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case It.SPRITE:this.popSpriteMask(e);break;case It.COLOR:this.popColorMask(e);break}if(e.reset(),e.pooled&&this.maskDataPool.push(e),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===It.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=It.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=It.SCISSOR:t.type=It.STENCIL:t.type=It.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let r=t._filters;r||(r=this.alphaMaskPool[this.alphaMaskIndex],r||(r=this.alphaMaskPool[this.alphaMaskIndex]=[new uu])),r[0].resolution=t.resolution,r[0].multisample=t.multisample,r[0].maskSprite=e;const n=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,r),i.filterArea=n,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,i=t._colorMask=e&t.colorMask;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const e=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}Xa.extension={type:$.RendererSystem,name:"mask"},Q.add(Xa);class du{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,i=this.getStackLength();this.maskStack=t;const r=this.getStackLength();r!==i&&(r===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const fu=new vt,pu=[],mu=class mn extends du{constructor(t){super(t),this.glConst=q.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:i}=t,{renderer:r}=this,n=r.renderTexture,a=i.getBounds(!0,pu.pop()??new ut);this.roundFrameToPixels(a,n.current?n.current.resolution:r.resolution,n.sourceFrame,n.destinationFrame,r.projection.transform),e&&a.fit(e),t._scissorRectLocal=a}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:i,c:r,d:n}=t;return(Math.abs(i)>1e-4||Math.abs(r)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(n)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||mn.isMatrixRotated(e.worldTransform)||mn.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,e,i,r,n){mn.isMatrixRotated(n)||(n=n?fu.copyFrom(n):fu.identity(),n.translate(-i.x,-i.y).scale(r.width/i.width,r.height/i.height).translate(r.x,r.y),this.renderer.filter.transformAABB(n,t),t.fit(r),t.x=Math.round(t.x*e),t.y=Math.round(t.y*e),t.width=Math.round(t.width*e),t.height=Math.round(t.height*e))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:e}=this.renderer;t._scissorRect||e.enable(e.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:e}=this.renderer;t&&pu.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():e.disable(e.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let e;this.renderer.renderTexture.current?e=t.y:e=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};mu.extension={type:$.RendererSystem,name:"scissor"};let gu=mu;Q.add(gu);class za extends du{constructor(t){super(t),this.glConst=q.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const e=t.maskObject,{gl:i}=this.renderer,r=t._stencilCounter;r===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,r,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,i.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}pop(t){const e=this.renderer.gl;if(this.getStackLength()===0)e.disable(e.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,r=i?i._colorMask:15;r!==0&&(i._colorMask=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,r!==0&&(i._colorMask=r,e.colorMask((r&1)!==0,(r&2)!==0,(r&4)!==0,(r&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}za.extension={type:$.RendererSystem,name:"stencil"},Q.add(za);class Wa{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return ot("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return ot("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return ot("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),t.events}}})}init(){const t=this.rendererPlugins;for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}Wa.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"_plugin"},Q.add(Wa);class $a{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new vt,this.transform=null}update(t,e,i,r){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,r),this.transform&&this.projectionMatrix.append(this.transform);const n=this.renderer;n.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,n.globalUniforms.update(),n.shader.shader&&n.shader.syncUniformGroup(n.shader.shader.uniforms.globals)}calculateProjection(t,e,i,r){const n=this.projectionMatrix,a=r?-1:1;n.identity(),n.a=1/e.width*2,n.d=a*(1/e.height*2),n.tx=-1-e.x*n.a,n.ty=-a-e.y*n.d}setTransform(t){}destroy(){this.renderer=null}}$a.extension={type:$.RendererSystem,name:"projection"},Q.add($a);const Wp=new Fi,_u=new ut;class ja{constructor(t){this.renderer=t,this._tempMatrix=new vt}generateTexture(t,e){const{region:i,...r}=e||{},n=(i==null?void 0:i.copyTo(_u))||t.getLocalBounds(_u,!0),a=r.resolution||this.renderer.resolution;n.width=Math.max(n.width,1/a),n.height=Math.max(n.height,1/a),r.width=n.width,r.height=n.height,r.resolution=a,r.multisample??(r.multisample=this.renderer.multisample);const o=Je.create(r);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const h=t.transform;return t.transform=Wp,this.renderer.render(t,{renderTexture:o,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=h,o}destroy(){}}ja.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"textureGenerator"},Q.add(ja);const yi=new ut,br=new ut;class Ya{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new ut,this.destinationFrame=new ut,this.viewportFrame=new ut}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,i){const r=this.renderer;this.current=t;let n,a,o;t?(n=t.baseTexture,o=n.resolution,e||(yi.width=t.frame.width,yi.height=t.frame.height,e=yi),i||(br.x=t.frame.x,br.y=t.frame.y,br.width=e.width,br.height=e.height,i=br),a=n.framebuffer):(o=r.resolution,e||(yi.width=r._view.screen.width,yi.height=r._view.screen.height,e=yi),i||(i=yi,i.width=e.width,i.height=e.height));const h=this.viewportFrame;h.x=i.x*o,h.y=i.y*o,h.width=i.width*o,h.height=i.height*o,t||(h.y=r.view.height-(h.y+h.height)),h.ceil(),this.renderer.framebuffer.bind(a,h),this.renderer.projection.update(i,e,o,!a),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(i)}clear(t,e){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,r=gt.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&r.premultiply(r.alpha);const n=this.destinationFrame,a=this.current?this.current.baseTexture:this.renderer._view.screen,o=n.width!==a.width||n.height!==a.height;if(o){let{x:h,y:l,width:u,height:c}=this.viewportFrame;h=Math.round(h),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(h,l,u,c)}this.renderer.framebuffer.clear(r.red,r.green,r.blue,r.alpha,e),o&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}Ya.extension={type:$.RendererSystem,name:"renderTexture"},Q.add(Ya);class $p{}class yu{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function jp(s,t){const e={},i=t.getProgramParameter(s,t.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const n=t.getActiveAttrib(s,r);if(n.name.startsWith("gl_"))continue;const a=tu(t,n.type),o={type:a,name:n.name,size:Jl(a),location:t.getAttribLocation(s,n.name)};e[n.name]=o}return e}function Yp(s,t){const e={},i=t.getProgramParameter(s,t.ACTIVE_UNIFORMS);for(let r=0;r<i;r++){const n=t.getActiveUniform(s,r),a=n.name.replace(/\[.*?\]$/,""),o=!!n.name.match(/\[.*?\]$/),h=tu(t,n.type);e[a]={name:a,index:r,type:h,size:n.size,isArray:o,value:Yl(h,n.size)}}return e}function vu(s,t){var o;const e=jl(s,s.VERTEX_SHADER,t.vertexSrc),i=jl(s,s.FRAGMENT_SHADER,t.fragmentSrc),r=s.createProgram();s.attachShader(r,e),s.attachShader(r,i);const n=(o=t.extra)==null?void 0:o.transformFeedbackVaryings;if(n&&(typeof s.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):s.transformFeedbackVaryings(r,n.names,n.bufferMode==="separate"?s.SEPARATE_ATTRIBS:s.INTERLEAVED_ATTRIBS)),s.linkProgram(r),s.getProgramParameter(r,s.LINK_STATUS)||Dp(s,r,e,i),t.attributeData=jp(r,s),t.uniformData=Yp(r,s),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const h=Object.keys(t.attributeData);h.sort((l,u)=>l>u?1:-1);for(let l=0;l<h.length;l++)t.attributeData[h[l]].location=l,s.bindAttribLocation(r,l,h[l]);s.linkProgram(r)}s.deleteShader(e),s.deleteShader(i);const a={};for(const h in t.uniformData){const l=t.uniformData[h];a[h]={location:s.getUniformLocation(r,h),value:Yl(l.type,l.size)}}return new yu(r,a)}function qp(s,t,e,i,r){e.buffer.update(r)}const Kp={float:`
349
420
  data[offset] = v;
350
421
  `,vec2:`
351
422
  data[offset] = v[0];
@@ -383,7 +454,7 @@ void main(void)
383
454
  {
384
455
  data[offset + i] = v[i];
385
456
  }
386
- `},Su={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 Pu(i){for(var t=i.map(function(h){return{data:h,offset:0,dataLen:0,dirty:0}}),e=0,r=0,n=0,s=0;s<t.length;s++){var a=t[s];if(e=Su[a.data.type],a.data.size>1&&(e=Math.max(e,16)*a.data.size),a.dataLen=e,r%e!==0&&r<16){var o=r%e%16;r+=o,n+=o}r+e>16?(n=Math.ceil(n/16)*16,a.offset=n,n+=e,r=e):(a.offset=n,r+=e,n+=e)}return n=Math.ceil(n/16)*16,{uboElements:t,size:n}}function wu(i,t){var e=[];for(var r in i)t[r]&&e.push(t[r]);return e.sort(function(n,s){return n.index-s.index}),e}function Cu(i,t){if(!i.autoManage)return{size:0,syncFunc:Qv};for(var e=wu(i.uniforms,t),r=Pu(e),n=r.uboElements,s=r.size,a=[`
457
+ `},xu={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 bu(s){const t=s.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,i=0,r=0;for(let n=0;n<t.length;n++){const a=t[n];if(e=xu[a.data.type],a.data.size>1&&(e=Math.max(e,16)*a.data.size),a.dataLen=e,i%e!==0&&i<16){const o=i%e%16;i+=o,r+=o}i+e>16?(r=Math.ceil(r/16)*16,a.offset=r,r+=e,i=e):(a.offset=r,i+=e,r+=e)}return r=Math.ceil(r/16)*16,{uboElements:t,size:r}}function Tu(s,t){const e=[];for(const i in s)t[i]&&e.push(t[i]);return e.sort((i,r)=>i.index-r.index),e}function Eu(s,t){if(!s.autoManage)return{size:0,syncFunc:qp};const e=Tu(s.uniforms,t),{uboElements:i,size:r}=bu(e),n=[`
387
458
  var v = null;
388
459
  var v2 = null;
389
460
  var cv = null;
@@ -391,31 +462,31 @@ void main(void)
391
462
  var gl = renderer.gl
392
463
  var index = 0;
393
464
  var data = buffer.data;
394
- `],o=0;o<n.length;o++){for(var h=n[o],u=i.uniforms[h.data.name],l=h.data.name,c=!1,f=0;f<Ze.length;f++){var d=Ze[f];if(d.codeUbo&&d.test(h.data,u)){a.push("offset = "+h.offset/4+";",Ze[f].codeUbo(h.data.name,u)),c=!0;break}}if(!c)if(h.data.size>1){var v=vu(h.data.type),_=Math.max(Su[h.data.type]/16,1),p=v/_,g=(4-p%4)%4;a.push(`
395
- cv = ud.`+l+`.value;
396
- v = uv.`+l+`;
397
- offset = `+h.offset/4+`;
465
+ `];for(let a=0;a<i.length;a++){const o=i[a],h=s.uniforms[o.data.name],l=o.data.name;let u=!1;for(let c=0;c<_i.length;c++){const d=_i[c];if(d.codeUbo&&d.test(o.data,h)){n.push(`offset = ${o.offset/4};`,_i[c].codeUbo(o.data.name,h)),u=!0;break}}if(!u)if(o.data.size>1){const c=Jl(o.data.type),d=Math.max(xu[o.data.type]/16,1),f=c/d,p=(4-f%4)%4;n.push(`
466
+ cv = ud.${l}.value;
467
+ v = uv.${l};
468
+ offset = ${o.offset/4};
398
469
 
399
470
  t = 0;
400
471
 
401
- for(var i=0; i < `+h.data.size*_+`; i++)
472
+ for(var i=0; i < ${o.data.size*d}; i++)
402
473
  {
403
- for(var j = 0; j < `+p+`; j++)
474
+ for(var j = 0; j < ${f}; j++)
404
475
  {
405
476
  data[offset++] = v[t++];
406
477
  }
407
- offset += `+g+`;
478
+ offset += ${p};
408
479
  }
409
480
 
410
- `)}else{var y=t_[h.data.type];a.push(`
411
- cv = ud.`+l+`.value;
412
- v = uv.`+l+`;
413
- offset = `+h.offset/4+`;
414
- `+y+`;
415
- `)}}return a.push(`
481
+ `)}else{const c=Kp[o.data.type];n.push(`
482
+ cv = ud.${l}.value;
483
+ v = uv.${l};
484
+ offset = ${o.offset/4};
485
+ ${c};
486
+ `)}}return n.push(`
416
487
  renderer.buffer.update(buffer);
417
- `),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",a.join(`
418
- `))}}var e_=function(){function i(){}return i}(),Iu=function(){function i(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}return i.prototype.destroy=function(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null},i}();function r_(i,t){for(var e={},r=t.getProgramParameter(i,t.ACTIVE_ATTRIBUTES),n=0;n<r;n++){var s=t.getActiveAttrib(i,n);if(s.name.indexOf("gl_")!==0){var a=gu(t,s.type),o={type:a,name:s.name,size:vu(a),location:t.getAttribLocation(i,s.name)};e[s.name]=o}}return e}function i_(i,t){for(var e={},r=t.getProgramParameter(i,t.ACTIVE_UNIFORMS),n=0;n<r;n++){var s=t.getActiveUniform(i,n),a=s.name.replace(/\[.*?\]$/,""),o=!!s.name.match(/\[.*?\]$/),h=gu(t,s.type);e[a]={name:a,index:n,type:h,size:s.size,isArray:o,value:fu(h,s.size)}}return e}function Au(i,t){var e=uu(i,i.VERTEX_SHADER,t.vertexSrc),r=uu(i,i.FRAGMENT_SHADER,t.fragmentSrc),n=i.createProgram();if(i.attachShader(n,e),i.attachShader(n,r),i.linkProgram(n),i.getProgramParameter(n,i.LINK_STATUS)||Nv(i,n,e,r),t.attributeData=r_(n,i),t.uniformData=i_(n,i),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){var s=Object.keys(t.attributeData);s.sort(function(l,c){return l>c?1:-1});for(var a=0;a<s.length;a++)t.attributeData[s[a]].location=a,i.bindAttribLocation(n,a,s[a]);i.linkProgram(n)}i.deleteShader(e),i.deleteShader(r);var o={};for(var a in t.uniformData){var h=t.uniformData[a];o[a]={location:i.getUniformLocation(n,a),value:fu(h.type,h.size)}}var u=new Iu(n,o);return u}var n_=0,Xi={textureCount:0,uboCount:0},ea=function(){function i(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=n_++}return i.prototype.systemCheck=function(){if(!zv())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")},i.prototype.contextChange=function(t){this.gl=t,this.reset()},i.prototype.bind=function(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;var r=t.program,n=r.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==r&&(this.program=r,this.gl.useProgram(n.program)),e||(Xi.textureCount=0,Xi.uboCount=0,this.syncUniformGroup(t.uniformGroup,Xi)),n},i.prototype.setUniforms=function(t){var e=this.shader.program,r=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(r.uniformData,t,this.renderer)},i.prototype.syncUniformGroup=function(t,e){var r=this.getGlProgram();(!t.static||t.dirtyId!==r.uniformDirtyGroups[t.id])&&(r.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,r,e))},i.prototype.syncUniforms=function(t,e,r){var n=t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t);n(e.uniformData,t.uniforms,this.renderer,r)},i.prototype.createSyncGroups=function(t){var e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=Hv(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]},i.prototype.syncUniformBufferGroup=function(t,e){var r=this.getGlProgram();if(!t.static||t.dirtyId!==0||!r.uniformGroups[t.id]){t.dirtyId=0;var n=r.uniformGroups[t.id]||this.createSyncBufferGroup(t,r,e);t.buffer.update(),n(r.uniformData,t.uniforms,this.renderer,Xi,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,r.uniformBufferBindings[e])},i.prototype.createSyncBufferGroup=function(t,e,r){var n=this.renderer.gl;this.renderer.buffer.bind(t.buffer);var s=this.gl.getUniformBlockIndex(e.program,r);e.uniformBufferBindings[r]=this.shader.uniformBindCount,n.uniformBlockBinding(e.program,s,this.shader.uniformBindCount),this.shader.uniformBindCount++;var a=this.getSignature(t,this.shader.program.uniformData,"ubo"),o=this._uboCache[a];if(o||(o=this._uboCache[a]=Cu(t,this.shader.program.uniformData)),t.autoManage){var h=new Float32Array(o.size/4);t.buffer.update(h)}return e.uniformGroups[t.id]=o.syncFunc,e.uniformGroups[t.id]},i.prototype.getSignature=function(t,e,r){var n=t.uniforms,s=[r+"-"];for(var a in n)s.push(a),e[a]&&s.push(e[a].type);return s.join("-")},i.prototype.getGlProgram=function(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null},i.prototype.generateProgram=function(t){var e=this.gl,r=t.program,n=Au(e,r);return r.glPrograms[this.renderer.CONTEXT_UID]=n,n},i.prototype.reset=function(){this.program=null,this.shader=null},i.prototype.disposeShader=function(t){this.shader===t&&(this.shader=null)},i.prototype.destroy=function(){this.renderer=null,this.destroyed=!0},i}();function s_(i,t){return t===void 0&&(t=[]),t[tt.NORMAL]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.ADD]=[i.ONE,i.ONE],t[tt.MULTIPLY]=[i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.SCREEN]=[i.ONE,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.OVERLAY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.DARKEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.LIGHTEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.COLOR_DODGE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.COLOR_BURN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.HARD_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.SOFT_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.DIFFERENCE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.EXCLUSION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.HUE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.SATURATION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.COLOR]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.LUMINOSITY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.NONE]=[0,0],t[tt.NORMAL_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.ADD_NPM]=[i.SRC_ALPHA,i.ONE,i.ONE,i.ONE],t[tt.SCREEN_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[tt.SRC_IN]=[i.DST_ALPHA,i.ZERO],t[tt.SRC_OUT]=[i.ONE_MINUS_DST_ALPHA,i.ZERO],t[tt.SRC_ATOP]=[i.DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[tt.DST_OVER]=[i.ONE_MINUS_DST_ALPHA,i.ONE],t[tt.DST_IN]=[i.ZERO,i.SRC_ALPHA],t[tt.DST_OUT]=[i.ZERO,i.ONE_MINUS_SRC_ALPHA],t[tt.DST_ATOP]=[i.ONE_MINUS_DST_ALPHA,i.SRC_ALPHA],t[tt.XOR]=[i.ONE_MINUS_DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[tt.SUBTRACT]=[i.ONE,i.ONE,i.ONE,i.ONE,i.FUNC_REVERSE_SUBTRACT,i.FUNC_ADD],t}var a_=0,o_=1,h_=2,u_=3,l_=4,f_=5,ra=function(){function i(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=tt.NONE,this._blendEq=!1,this.map=[],this.map[a_]=this.setBlend,this.map[o_]=this.setOffset,this.map[h_]=this.setCullFace,this.map[u_]=this.setDepthTest,this.map[l_]=this.setFrontFace,this.map[f_]=this.setDepthMask,this.checks=[],this.defaultState=new Oe,this.defaultState.blend=!0}return i.prototype.contextChange=function(t){this.gl=t,this.blendModes=s_(t),this.set(this.defaultState),this.reset()},i.prototype.set=function(t){if(t=t||this.defaultState,this.stateId!==t.data){for(var e=this.stateId^t.data,r=0;e;)e&1&&this.map[r].call(this,!!(t.data&1<<r)),e=e>>1,r++;this.stateId=t.data}for(var r=0;r<this.checks.length;r++)this.checks[r](this,t)},i.prototype.forceState=function(t){t=t||this.defaultState;for(var e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(var e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data},i.prototype.setBlend=function(t){this.updateCheck(i.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)},i.prototype.setOffset=function(t){this.updateCheck(i.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)},i.prototype.setDepthTest=function(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)},i.prototype.setDepthMask=function(t){this.gl.depthMask(t)},i.prototype.setCullFace=function(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)},i.prototype.setFrontFace=function(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])},i.prototype.setBlendMode=function(t){if(t!==this.blendMode){this.blendMode=t;var e=this.blendModes[t],r=this.gl;e.length===2?r.blendFunc(e[0],e[1]):r.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,r.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,r.blendEquationSeparate(r.FUNC_ADD,r.FUNC_ADD))}},i.prototype.setPolygonOffset=function(t,e){this.gl.polygonOffset(t,e)},i.prototype.reset=function(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)},i.prototype.updateCheck=function(t,e){var r=this.checks.indexOf(t);e&&r===-1?this.checks.push(t):!e&&r!==-1&&this.checks.splice(r,1)},i.checkBlendMode=function(t,e){t.setBlendMode(e.blendMode)},i.checkPolygonOffset=function(t,e){t.setPolygonOffset(1,e.polygonOffset)},i.prototype.destroy=function(){this.gl=null},i}(),ia=function(){function i(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=z.GC_MAX_IDLE,this.checkCountMax=z.GC_MAX_CHECK_COUNT,this.mode=z.GC_MODE}return i.prototype.postrender=function(){this.renderer.renderingToScreen&&(this.count++,this.mode!==Br.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))},i.prototype.run=function(){for(var t=this.renderer.texture,e=t.managedTextures,r=!1,n=0;n<e.length;n++){var s=e[n];!s.framebuffer&&this.count-s.touched>this.maxIdle&&(t.destroyTexture(s,!0),e[n]=null,r=!0)}if(r){for(var a=0,n=0;n<e.length;n++)e[n]!==null&&(e[a++]=e[n]);e.length=a}},i.prototype.unload=function(t){var e=this.renderer.texture,r=t._texture;r&&!r.framebuffer&&e.destroyTexture(r);for(var n=t.children.length-1;n>=0;n--)this.unload(t.children[n])},i.prototype.destroy=function(){this.renderer=null},i}();function c_(i){var t,e,r,n,s,a,o,h,u,l,c,f,d,v,_,p,g,y,T,I,m,S,x;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?x=(t={},t[Q.UNSIGNED_BYTE]=(e={},e[H.RGBA]=i.RGBA8,e[H.RGB]=i.RGB8,e[H.RG]=i.RG8,e[H.RED]=i.R8,e[H.RGBA_INTEGER]=i.RGBA8UI,e[H.RGB_INTEGER]=i.RGB8UI,e[H.RG_INTEGER]=i.RG8UI,e[H.RED_INTEGER]=i.R8UI,e[H.ALPHA]=i.ALPHA,e[H.LUMINANCE]=i.LUMINANCE,e[H.LUMINANCE_ALPHA]=i.LUMINANCE_ALPHA,e),t[Q.BYTE]=(r={},r[H.RGBA]=i.RGBA8_SNORM,r[H.RGB]=i.RGB8_SNORM,r[H.RG]=i.RG8_SNORM,r[H.RED]=i.R8_SNORM,r[H.RGBA_INTEGER]=i.RGBA8I,r[H.RGB_INTEGER]=i.RGB8I,r[H.RG_INTEGER]=i.RG8I,r[H.RED_INTEGER]=i.R8I,r),t[Q.UNSIGNED_SHORT]=(n={},n[H.RGBA_INTEGER]=i.RGBA16UI,n[H.RGB_INTEGER]=i.RGB16UI,n[H.RG_INTEGER]=i.RG16UI,n[H.RED_INTEGER]=i.R16UI,n[H.DEPTH_COMPONENT]=i.DEPTH_COMPONENT16,n),t[Q.SHORT]=(s={},s[H.RGBA_INTEGER]=i.RGBA16I,s[H.RGB_INTEGER]=i.RGB16I,s[H.RG_INTEGER]=i.RG16I,s[H.RED_INTEGER]=i.R16I,s),t[Q.UNSIGNED_INT]=(a={},a[H.RGBA_INTEGER]=i.RGBA32UI,a[H.RGB_INTEGER]=i.RGB32UI,a[H.RG_INTEGER]=i.RG32UI,a[H.RED_INTEGER]=i.R32UI,a[H.DEPTH_COMPONENT]=i.DEPTH_COMPONENT24,a),t[Q.INT]=(o={},o[H.RGBA_INTEGER]=i.RGBA32I,o[H.RGB_INTEGER]=i.RGB32I,o[H.RG_INTEGER]=i.RG32I,o[H.RED_INTEGER]=i.R32I,o),t[Q.FLOAT]=(h={},h[H.RGBA]=i.RGBA32F,h[H.RGB]=i.RGB32F,h[H.RG]=i.RG32F,h[H.RED]=i.R32F,h[H.DEPTH_COMPONENT]=i.DEPTH_COMPONENT32F,h),t[Q.HALF_FLOAT]=(u={},u[H.RGBA]=i.RGBA16F,u[H.RGB]=i.RGB16F,u[H.RG]=i.RG16F,u[H.RED]=i.R16F,u),t[Q.UNSIGNED_SHORT_5_6_5]=(l={},l[H.RGB]=i.RGB565,l),t[Q.UNSIGNED_SHORT_4_4_4_4]=(c={},c[H.RGBA]=i.RGBA4,c),t[Q.UNSIGNED_SHORT_5_5_5_1]=(f={},f[H.RGBA]=i.RGB5_A1,f),t[Q.UNSIGNED_INT_2_10_10_10_REV]=(d={},d[H.RGBA]=i.RGB10_A2,d[H.RGBA_INTEGER]=i.RGB10_A2UI,d),t[Q.UNSIGNED_INT_10F_11F_11F_REV]=(v={},v[H.RGB]=i.R11F_G11F_B10F,v),t[Q.UNSIGNED_INT_5_9_9_9_REV]=(_={},_[H.RGB]=i.RGB9_E5,_),t[Q.UNSIGNED_INT_24_8]=(p={},p[H.DEPTH_STENCIL]=i.DEPTH24_STENCIL8,p),t[Q.FLOAT_32_UNSIGNED_INT_24_8_REV]=(g={},g[H.DEPTH_STENCIL]=i.DEPTH32F_STENCIL8,g),t):x=(y={},y[Q.UNSIGNED_BYTE]=(T={},T[H.RGBA]=i.RGBA,T[H.RGB]=i.RGB,T[H.ALPHA]=i.ALPHA,T[H.LUMINANCE]=i.LUMINANCE,T[H.LUMINANCE_ALPHA]=i.LUMINANCE_ALPHA,T),y[Q.UNSIGNED_SHORT_5_6_5]=(I={},I[H.RGB]=i.RGB,I),y[Q.UNSIGNED_SHORT_4_4_4_4]=(m={},m[H.RGBA]=i.RGBA,m),y[Q.UNSIGNED_SHORT_5_5_5_1]=(S={},S[H.RGBA]=i.RGBA,S),y),x}var Hi=function(){function i(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=Q.UNSIGNED_BYTE,this.internalFormat=H.RGBA,this.samplerType=0}return i}(),na=function(){function i(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new lt,this.hasIntegerTextures=!1}return i.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=c_(t);var e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(var r=0;r<e;r++)this.boundTextures[r]=null;this.emptyTextures={};var n=new Hi(t.createTexture());t.bindTexture(t.TEXTURE_2D,n.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=n,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new Hi(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(var r=0;r<6;r++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(var r=0;r<this.boundTextures.length;r++)this.bind(null,r)},i.prototype.bind=function(t,e){e===void 0&&(e=0);var r=this.gl;if(t=t==null?void 0:t.castToBaseTexture(),t&&t.valid&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;var n=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(t.target,n.texture)),n.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,r.activeTexture(r.TEXTURE0+e)),this.updateTexture(t)):n.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(r.TEXTURE_2D,this.emptyTextures[r.TEXTURE_2D].texture),this.boundTextures[e]=null},i.prototype.reset=function(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(var t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture},i.prototype.unbind=function(t){var e=this,r=e.gl,n=e.boundTextures;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(var s=0;s<n.length;s++)n[s]===this.unknownTexture&&this.bind(null,s)}for(var s=0;s<n.length;s++)n[s]===t&&(this.currentLocation!==s&&(r.activeTexture(r.TEXTURE0+s),this.currentLocation=s),r.bindTexture(t.target,this.emptyTextures[t.target].texture),n[s]=null)},i.prototype.ensureSamplerType=function(t){var e=this,r=e.boundTextures,n=e.hasIntegerTextures,s=e.CONTEXT_UID;if(n)for(var a=t-1;a>=0;--a){var o=r[a];if(o){var h=o._glTextures[s];h.samplerType!==Lr.FLOAT&&this.renderer.texture.unbind(o)}}},i.prototype.initTexture=function(t){var e=new Hi(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e},i.prototype.initTextureType=function(t,e){var r,n;e.internalFormat=(n=(r=this.internalFormats[t.type])===null||r===void 0?void 0:r[t.format])!==null&&n!==void 0?n:t.format,this.webGLVersion===2&&t.type===Q.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type},i.prototype.updateTexture=function(t){var e=t._glTextures[this.CONTEXT_UID];if(e){var r=this.renderer;if(this.initTextureType(t,e),t.resource&&t.resource.upload(r,t,e))e.samplerType!==Lr.FLOAT&&(this.hasIntegerTextures=!0);else{var n=t.realWidth,s=t.realHeight,a=r.gl;(e.width!==n||e.height!==s||e.dirtyId<0)&&(e.width=n,e.height=s,a.texImage2D(t.target,0,e.internalFormat,n,s,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}},i.prototype.destroyTexture=function(t,e){var r=this.gl;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),r.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){var n=this.managedTextures.indexOf(t);n!==-1&&Ve(this.managedTextures,n,1)}},i.prototype.updateTextureStyle=function(t){var e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===zt.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=ne.CLAMP:e.wrapMode=t.wrapMode,t.resource&&t.resource.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)},i.prototype.setStyle=function(t,e){var r=this.gl;if(e.mipmap&&t.mipmap!==zt.ON_MANUAL&&r.generateMipmap(t.target),r.texParameteri(t.target,r.TEXTURE_WRAP_S,e.wrapMode),r.texParameteri(t.target,r.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){r.texParameteri(t.target,r.TEXTURE_MIN_FILTER,t.scaleMode===ie.LINEAR?r.LINEAR_MIPMAP_LINEAR:r.NEAREST_MIPMAP_NEAREST);var n=this.renderer.context.extensions.anisotropicFiltering;if(n&&t.anisotropicLevel>0&&t.scaleMode===ie.LINEAR){var s=Math.min(t.anisotropicLevel,r.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT));r.texParameterf(t.target,n.TEXTURE_MAX_ANISOTROPY_EXT,s)}}else r.texParameteri(t.target,r.TEXTURE_MIN_FILTER,t.scaleMode===ie.LINEAR?r.LINEAR:r.NEAREST);r.texParameteri(t.target,r.TEXTURE_MAG_FILTER,t.scaleMode===ie.LINEAR?r.LINEAR:r.NEAREST)},i.prototype.destroy=function(){this.renderer=null},i}(),Mu={__proto__:null,FilterSystem:Ns,BatchSystem:Us,ContextSystem:ks,FramebufferSystem:Gs,GeometrySystem:Hs,MaskSystem:Ks,ScissorSystem:Zs,StencilSystem:Js,ProjectionSystem:Qs,RenderTextureSystem:ta,ShaderSystem:ea,StateSystem:ra,TextureGCSystem:ia,TextureSystem:na},sa=new bt,Ru=function(i){mt(t,i);function t(e,r){e===void 0&&(e=cr.UNKNOWN);var n=i.call(this)||this;return r=Object.assign({},z.RENDER_OPTIONS,r),n.options=r,n.type=e,n.screen=new ut(0,0,r.width,r.height),n.view=r.view||z.ADAPTER.createCanvas(),n.resolution=r.resolution||z.RESOLUTION,n.useContextAlpha=r.useContextAlpha,n.autoDensity=!!r.autoDensity,n.preserveDrawingBuffer=r.preserveDrawingBuffer,n.clearBeforeRender=r.clearBeforeRender,n._backgroundColor=0,n._backgroundColorRgba=[0,0,0,1],n._backgroundColorString="#000000",n.backgroundColor=r.backgroundColor||n._backgroundColor,n.backgroundAlpha=r.backgroundAlpha,r.transparent!==void 0&&(Bt("6.0.0","Option transparent is deprecated, please use backgroundAlpha instead."),n.useContextAlpha=r.transparent,n.backgroundAlpha=r.transparent?0:1),n._lastObjectRendered=null,n.plugins={},n}return t.prototype.initPlugins=function(e){for(var r in e)this.plugins[r]=new e[r](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,r){this.view.width=Math.round(e*this.resolution),this.view.height=Math.round(r*this.resolution);var n=this.view.width/this.resolution,s=this.view.height/this.resolution;this.screen.width=n,this.screen.height=s,this.autoDensity&&(this.view.style.width=n+"px",this.view.style.height=s+"px"),this.emit("resize",n,s)},t.prototype.generateTexture=function(e,r,n,s){r===void 0&&(r={}),typeof r=="number"&&(Bt("6.1.0","generateTexture options (scaleMode, resolution, region) are now object options."),r={scaleMode:r,resolution:n,region:s});var a=r.region,o=Cv(r,["region"]);s=a||e.getLocalBounds(null,!0),s.width===0&&(s.width=1),s.height===0&&(s.height=1);var h=Me.create(Ps({width:s.width,height:s.height},o));return sa.tx=-s.x,sa.ty=-s.y,this.render(e,{renderTexture:h,clear:!1,transform:sa,skipUpdateTransform:!!e.parent}),h},t.prototype.destroy=function(e){for(var r in this.plugins)this.plugins[r].destroy(),this.plugins[r]=null;e&&this.view.parentNode&&this.view.parentNode.removeChild(this.view);var n=this;n.plugins=null,n.type=cr.UNKNOWN,n.view=null,n.screen=null,n._tempDisplayObjectParent=null,n.options=null,this._backgroundColorRgba=null,this._backgroundColorString=null,this._lastObjectRendered=null},Object.defineProperty(t.prototype,"backgroundColor",{get:function(){return this._backgroundColor},set:function(e){this._backgroundColor=e,this._backgroundColorString=cs(e),He(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}(xe),d_=function(){function i(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}return i}(),p_=function(){function i(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}return i.prototype.destroy=function(){this.renderer=null},i.prototype.contextChange=function(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID},i.prototype.bind=function(t){var e=this,r=e.gl,n=e.CONTEXT_UID,s=t._glBuffers[n]||this.createGLBuffer(t);r.bindBuffer(t.type,s.buffer)},i.prototype.bindBufferBase=function(t,e){var r=this,n=r.gl,s=r.CONTEXT_UID;if(this.boundBufferBases[e]!==t){var a=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,n.bindBufferBase(n.UNIFORM_BUFFER,e,a.buffer)}},i.prototype.bindBufferRange=function(t,e,r){var n=this,s=n.gl,a=n.CONTEXT_UID;r=r||0;var o=t._glBuffers[a]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,o.buffer,r*256,256)},i.prototype.update=function(t){var e=this,r=e.gl,n=e.CONTEXT_UID,s=t._glBuffers[n];if(t._updateID!==s.updateID)if(s.updateID=t._updateID,r.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)r.bufferSubData(t.type,0,t.data);else{var a=t.static?r.STATIC_DRAW:r.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,r.bufferData(t.type,t.data,a)}},i.prototype.dispose=function(t,e){if(this.managedBuffers[t.id]){delete this.managedBuffers[t.id];var r=t._glBuffers[this.CONTEXT_UID],n=this.gl;t.disposeRunner.remove(this),r&&(e||n.deleteBuffer(r.buffer),delete t._glBuffers[this.CONTEXT_UID])}},i.prototype.disposeAll=function(t){for(var e=Object.keys(this.managedBuffers),r=0;r<e.length;r++)this.dispose(this.managedBuffers[e[r]],t)},i.prototype.createGLBuffer=function(t){var e=this,r=e.CONTEXT_UID,n=e.gl;return t._glBuffers[r]=new d_(n.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[r]},i}(),aa=function(i){mt(t,i);function t(e){var r=i.call(this,cr.WEBGL,e)||this;return e=r.options,r.gl=null,r.CONTEXT_UID=0,r.runners={destroy:new Dt("destroy"),contextChange:new Dt("contextChange"),reset:new Dt("reset"),update:new Dt("update"),postrender:new Dt("postrender"),prerender:new Dt("prerender"),resize:new Dt("resize")},r.runners.contextChange.add(r),r.globalUniforms=new Re({projectionMatrix:new bt},!0),r.addSystem(Ks,"mask").addSystem(ks,"context").addSystem(ra,"state").addSystem(ea,"shader").addSystem(na,"texture").addSystem(p_,"buffer").addSystem(Hs,"geometry").addSystem(Gs,"framebuffer").addSystem(Zs,"scissor").addSystem(Js,"stencil").addSystem(Qs,"projection").addSystem(ia,"textureGC").addSystem(Ns,"filter").addSystem(ta,"renderTexture").addSystem(Us,"batch"),r.initPlugins(t.__plugins),r.multisample=void 0,e.context?r.context.initFromContext(e.context):r.context.initFromOptions({alpha:!!r.useContextAlpha,antialias:e.antialias,premultipliedAlpha:r.useContextAlpha&&r.useContextAlpha!=="notMultiplied",stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:r.options.powerPreference}),r.renderingToScreen=!0,kh(r.context.webGLVersion===2?"WebGL 2":"WebGL 1"),r.resize(r.options.width,r.options.height),r}return t.create=function(e){if(Gh())return new t(e);throw new Error('WebGL unsupported in this browser, use "pixi.js-legacy" for fallback canvas2d support.')},t.prototype.contextChange=function(){var e=this.gl,r;if(this.context.webGLVersion===1){var n=e.getParameter(e.FRAMEBUFFER_BINDING);e.bindFramebuffer(e.FRAMEBUFFER,null),r=e.getParameter(e.SAMPLES),e.bindFramebuffer(e.FRAMEBUFFER,n)}else{var n=e.getParameter(e.DRAW_FRAMEBUFFER_BINDING);e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),r=e.getParameter(e.SAMPLES),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,n)}r>=xt.HIGH?this.multisample=xt.HIGH:r>=xt.MEDIUM?this.multisample=xt.MEDIUM:r>=xt.LOW?this.multisample=xt.LOW:this.multisample=xt.NONE},t.prototype.addSystem=function(e,r){var n=new e(this);if(this[r])throw new Error('Whoops! The name "'+r+'" is already in use');this[r]=n;for(var s in this.runners)this.runners[s].add(n);return this},t.prototype.render=function(e,r){var n,s,a,o;if(r&&(r instanceof Me?(Bt("6.0.0","Renderer#render arguments changed, use options instead."),n=r,s=arguments[2],a=arguments[3],o=arguments[4]):(n=r.renderTexture,s=r.clear,a=r.transform,o=r.skipUpdateTransform)),this.renderingToScreen=!n,this.runners.prerender.emit(),this.emit("prerender"),this.projection.transform=a,!this.context.isLost){if(n||(this._lastObjectRendered=e),!o){var h=e.enableTempParent();e.updateTransform(),e.disableTempParent(h)}this.renderTexture.bind(n),this.batch.currentRenderer.start(),(s!==void 0?s:this.clearBeforeRender)&&this.renderTexture.clear(),e.render(this),this.batch.currentRenderer.flush(),n&&n.baseTexture.update(),this.runners.postrender.emit(),this.projection.transform=null,this.emit("postrender")}},t.prototype.generateTexture=function(e,r,n,s){r===void 0&&(r={});var a=i.prototype.generateTexture.call(this,e,r,n,s);return this.framebuffer.blit(),a},t.prototype.resize=function(e,r){i.prototype.resize.call(this,e,r),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 r in this.runners)this.runners[r].destroy();i.prototype.destroy.call(this,e),this.gl=null},Object.defineProperty(t.prototype,"extract",{get:function(){return Bt("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,r){Bt("6.5.0","Renderer.registerPlugin() has been deprecated, please use extensions.add() instead."),Kt.add({name:e,type:dt.RendererPlugin,ref:r})},t.__plugins={},t}(Ru);Kt.handleByMap(dt.RendererPlugin,aa.__plugins);function Ou(i){return aa.create(i)}var v_=`attribute vec2 aVertexPosition;
488
+ `),{size:r,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(`
489
+ `))}}let Zp=0;const ws={textureCount:0,uboCount:0};class qa{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=Zp++}systemCheck(){if(!iu())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,r=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(r.program)),e||(ws.textureCount=0,ws.uboCount=0,this.syncUniformGroup(t.uniformGroup,ws)),r}setUniforms(t){const e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=Ip(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;const r=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),r(i.uniformData,t.uniforms,this.renderer,ws,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:r}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,r.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const a=this.getSignature(t,this.shader.program.uniformData,"ubo");let o=this._uboCache[a];if(o||(o=this._uboCache[a]=Eu(t,this.shader.program.uniformData)),t.autoManage){const h=new Float32Array(o.size/4);t.buffer.update(h)}return e.uniformGroups[t.id]=o.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){const r=t.uniforms,n=[`${i}-`];for(const a in r)n.push(a),e[a]&&n.push(e[a].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,i=t.program,r=vu(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=r,r}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}qa.extension={type:$.RendererSystem,name:"shader"},Q.add(qa);class Tr{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.3 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}Tr.defaultOptions={hello:!1},Tr.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"startup"},Q.add(Tr);function Jp(s,t=[]){return t[nt.NORMAL]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.ADD]=[s.ONE,s.ONE],t[nt.MULTIPLY]=[s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.SCREEN]=[s.ONE,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.OVERLAY]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.DARKEN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.LIGHTEN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.COLOR_DODGE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.COLOR_BURN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.HARD_LIGHT]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.SOFT_LIGHT]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.DIFFERENCE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.EXCLUSION]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.HUE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.SATURATION]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.COLOR]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.LUMINOSITY]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.NONE]=[0,0],t[nt.NORMAL_NPM]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.ADD_NPM]=[s.SRC_ALPHA,s.ONE,s.ONE,s.ONE],t[nt.SCREEN_NPM]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[nt.SRC_IN]=[s.DST_ALPHA,s.ZERO],t[nt.SRC_OUT]=[s.ONE_MINUS_DST_ALPHA,s.ZERO],t[nt.SRC_ATOP]=[s.DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],t[nt.DST_OVER]=[s.ONE_MINUS_DST_ALPHA,s.ONE],t[nt.DST_IN]=[s.ZERO,s.SRC_ALPHA],t[nt.DST_OUT]=[s.ZERO,s.ONE_MINUS_SRC_ALPHA],t[nt.DST_ATOP]=[s.ONE_MINUS_DST_ALPHA,s.SRC_ALPHA],t[nt.XOR]=[s.ONE_MINUS_DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],t[nt.SUBTRACT]=[s.ONE,s.ONE,s.ONE,s.ONE,s.FUNC_REVERSE_SUBTRACT,s.FUNC_ADD],t}const Qp=0,tm=1,em=2,im=3,rm=4,sm=5,wu=class dh{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=nt.NONE,this._blendEq=!1,this.map=[],this.map[Qp]=this.setBlend,this.map[tm]=this.setOffset,this.map[em]=this.setCullFace,this.map[im]=this.setDepthTest,this.map[rm]=this.setFrontFace,this.map[sm]=this.setDepthMask,this.checks=[],this.defaultState=new fe,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=Jp(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(dh.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(dh.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const e=this.blendModes[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,e){const i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};wu.extension={type:$.RendererSystem,name:"state"};let Cu=wu;Q.add(Cu);class Au extends Ee{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(r=>t.systems[r]),i=[...e,...Object.keys(t.systems).filter(r=>!e.includes(r))];for(const r of i)this.addSystem(t.systems[r],r)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Wt(e)})}addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const r in this.runners)this.runners[r].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach(r=>{const n=i.find(a=>this._systemsHash[a]===r);r[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const Er=class gn{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=gn.defaultMaxIdle,this.checkCountMax=gn.defaultCheckCountMax,this.mode=gn.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==ss.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let i=!1;for(let r=0;r<e.length;r++){const n=e[r];n.resource&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[r]=null,i=!0)}if(i){let r=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[r++]=e[n]);e.length=r}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let r=t.children.length-1;r>=0;r--)this.unload(t.children[r])}destroy(){this.renderer=null}};Er.defaultMode=ss.AUTO,Er.defaultMaxIdle=60*60,Er.defaultCheckCountMax=60*10,Er.extension={type:$.RendererSystem,name:"textureGC"};let Qe=Er;Q.add(Qe);class Cs{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=it.UNSIGNED_BYTE,this.internalFormat=H.RGBA,this.samplerType=0}}function nm(s){let t;return"WebGL2RenderingContext"in globalThis&&s instanceof globalThis.WebGL2RenderingContext?t={[s.RGB]:Y.FLOAT,[s.RGBA]:Y.FLOAT,[s.ALPHA]:Y.FLOAT,[s.LUMINANCE]:Y.FLOAT,[s.LUMINANCE_ALPHA]:Y.FLOAT,[s.R8]:Y.FLOAT,[s.R8_SNORM]:Y.FLOAT,[s.RG8]:Y.FLOAT,[s.RG8_SNORM]:Y.FLOAT,[s.RGB8]:Y.FLOAT,[s.RGB8_SNORM]:Y.FLOAT,[s.RGB565]:Y.FLOAT,[s.RGBA4]:Y.FLOAT,[s.RGB5_A1]:Y.FLOAT,[s.RGBA8]:Y.FLOAT,[s.RGBA8_SNORM]:Y.FLOAT,[s.RGB10_A2]:Y.FLOAT,[s.RGB10_A2UI]:Y.FLOAT,[s.SRGB8]:Y.FLOAT,[s.SRGB8_ALPHA8]:Y.FLOAT,[s.R16F]:Y.FLOAT,[s.RG16F]:Y.FLOAT,[s.RGB16F]:Y.FLOAT,[s.RGBA16F]:Y.FLOAT,[s.R32F]:Y.FLOAT,[s.RG32F]:Y.FLOAT,[s.RGB32F]:Y.FLOAT,[s.RGBA32F]:Y.FLOAT,[s.R11F_G11F_B10F]:Y.FLOAT,[s.RGB9_E5]:Y.FLOAT,[s.R8I]:Y.INT,[s.R8UI]:Y.UINT,[s.R16I]:Y.INT,[s.R16UI]:Y.UINT,[s.R32I]:Y.INT,[s.R32UI]:Y.UINT,[s.RG8I]:Y.INT,[s.RG8UI]:Y.UINT,[s.RG16I]:Y.INT,[s.RG16UI]:Y.UINT,[s.RG32I]:Y.INT,[s.RG32UI]:Y.UINT,[s.RGB8I]:Y.INT,[s.RGB8UI]:Y.UINT,[s.RGB16I]:Y.INT,[s.RGB16UI]:Y.UINT,[s.RGB32I]:Y.INT,[s.RGB32UI]:Y.UINT,[s.RGBA8I]:Y.INT,[s.RGBA8UI]:Y.UINT,[s.RGBA16I]:Y.INT,[s.RGBA16UI]:Y.UINT,[s.RGBA32I]:Y.INT,[s.RGBA32UI]:Y.UINT,[s.DEPTH_COMPONENT16]:Y.FLOAT,[s.DEPTH_COMPONENT24]:Y.FLOAT,[s.DEPTH_COMPONENT32F]:Y.FLOAT,[s.DEPTH_STENCIL]:Y.FLOAT,[s.DEPTH24_STENCIL8]:Y.FLOAT,[s.DEPTH32F_STENCIL8]:Y.FLOAT}:t={[s.RGB]:Y.FLOAT,[s.RGBA]:Y.FLOAT,[s.ALPHA]:Y.FLOAT,[s.LUMINANCE]:Y.FLOAT,[s.LUMINANCE_ALPHA]:Y.FLOAT,[s.DEPTH_STENCIL]:Y.FLOAT},t}function am(s){let t;return"WebGL2RenderingContext"in globalThis&&s instanceof globalThis.WebGL2RenderingContext?t={[it.UNSIGNED_BYTE]:{[H.RGBA]:s.RGBA8,[H.RGB]:s.RGB8,[H.RG]:s.RG8,[H.RED]:s.R8,[H.RGBA_INTEGER]:s.RGBA8UI,[H.RGB_INTEGER]:s.RGB8UI,[H.RG_INTEGER]:s.RG8UI,[H.RED_INTEGER]:s.R8UI,[H.ALPHA]:s.ALPHA,[H.LUMINANCE]:s.LUMINANCE,[H.LUMINANCE_ALPHA]:s.LUMINANCE_ALPHA},[it.BYTE]:{[H.RGBA]:s.RGBA8_SNORM,[H.RGB]:s.RGB8_SNORM,[H.RG]:s.RG8_SNORM,[H.RED]:s.R8_SNORM,[H.RGBA_INTEGER]:s.RGBA8I,[H.RGB_INTEGER]:s.RGB8I,[H.RG_INTEGER]:s.RG8I,[H.RED_INTEGER]:s.R8I},[it.UNSIGNED_SHORT]:{[H.RGBA_INTEGER]:s.RGBA16UI,[H.RGB_INTEGER]:s.RGB16UI,[H.RG_INTEGER]:s.RG16UI,[H.RED_INTEGER]:s.R16UI,[H.DEPTH_COMPONENT]:s.DEPTH_COMPONENT16},[it.SHORT]:{[H.RGBA_INTEGER]:s.RGBA16I,[H.RGB_INTEGER]:s.RGB16I,[H.RG_INTEGER]:s.RG16I,[H.RED_INTEGER]:s.R16I},[it.UNSIGNED_INT]:{[H.RGBA_INTEGER]:s.RGBA32UI,[H.RGB_INTEGER]:s.RGB32UI,[H.RG_INTEGER]:s.RG32UI,[H.RED_INTEGER]:s.R32UI,[H.DEPTH_COMPONENT]:s.DEPTH_COMPONENT24},[it.INT]:{[H.RGBA_INTEGER]:s.RGBA32I,[H.RGB_INTEGER]:s.RGB32I,[H.RG_INTEGER]:s.RG32I,[H.RED_INTEGER]:s.R32I},[it.FLOAT]:{[H.RGBA]:s.RGBA32F,[H.RGB]:s.RGB32F,[H.RG]:s.RG32F,[H.RED]:s.R32F,[H.DEPTH_COMPONENT]:s.DEPTH_COMPONENT32F},[it.HALF_FLOAT]:{[H.RGBA]:s.RGBA16F,[H.RGB]:s.RGB16F,[H.RG]:s.RG16F,[H.RED]:s.R16F},[it.UNSIGNED_SHORT_5_6_5]:{[H.RGB]:s.RGB565},[it.UNSIGNED_SHORT_4_4_4_4]:{[H.RGBA]:s.RGBA4},[it.UNSIGNED_SHORT_5_5_5_1]:{[H.RGBA]:s.RGB5_A1},[it.UNSIGNED_INT_2_10_10_10_REV]:{[H.RGBA]:s.RGB10_A2,[H.RGBA_INTEGER]:s.RGB10_A2UI},[it.UNSIGNED_INT_10F_11F_11F_REV]:{[H.RGB]:s.R11F_G11F_B10F},[it.UNSIGNED_INT_5_9_9_9_REV]:{[H.RGB]:s.RGB9_E5},[it.UNSIGNED_INT_24_8]:{[H.DEPTH_STENCIL]:s.DEPTH24_STENCIL8},[it.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[H.DEPTH_STENCIL]:s.DEPTH32F_STENCIL8}}:t={[it.UNSIGNED_BYTE]:{[H.RGBA]:s.RGBA,[H.RGB]:s.RGB,[H.ALPHA]:s.ALPHA,[H.LUMINANCE]:s.LUMINANCE,[H.LUMINANCE_ALPHA]:s.LUMINANCE_ALPHA},[it.UNSIGNED_SHORT_5_6_5]:{[H.RGB]:s.RGB},[it.UNSIGNED_SHORT_4_4_4_4]:{[H.RGBA]:s.RGBA},[it.UNSIGNED_SHORT_5_5_5_1]:{[H.RGBA]:s.RGBA}},t}class Ka{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new lt,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=am(t),this.samplerTypes=nm(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let r=0;r<e;r++)this.boundTextures[r]=null;this.emptyTextures={};const i=new Cs(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new Cs(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let r=0;r<6;r++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let r=0;r<this.boundTextures.length;r++)this.bind(null,r)}bind(t,e=0){const{gl:i}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const r=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,r.texture)),r.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):r.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let r=0;r<i.length;r++)i[r]===this.unknownTexture&&this.bind(null,r)}for(let r=0;r<i.length;r++)i[r]===t&&(this.currentLocation!==r&&(e.activeTexture(e.TEXTURE0+r),this.currentLocation=r),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[r]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:r}=this;if(i)for(let n=t-1;n>=0;--n){const a=e[n];a&&a._glTextures[r].samplerType!==Y.FLOAT&&this.renderer.texture.unbind(a)}}initTexture(t){const e=new Cs(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){var i;e.internalFormat=((i=this.internalFormats[t.type])==null?void 0:i[t.format])??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??Y.FLOAT,this.webGLVersion===2&&t.type===it.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var r;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const i=this.renderer;if(this.initTextureType(t,e),(r=t.resource)==null?void 0:r.upload(i,t,e))e.samplerType!==Y.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,a=t.realHeight,o=i.gl;(e.width!==n||e.height!==a||e.dirtyId<0)&&(e.width=n,e.height=a,o.texImage2D(t.target,0,e.internalFormat,n,a,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const r=this.managedTextures.indexOf(t);r!==-1&&di(this.managedTextures,r,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===he.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Te.CLAMP:e.wrapMode=t.wrapMode,(i=t.resource)!=null&&i.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const i=this.gl;if(e.mipmap&&t.mipmap!==he.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===be.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const r=this.renderer.context.extensions.anisotropicFiltering;if(r&&t.anisotropicLevel>0&&t.scaleMode===be.LINEAR){const n=Math.min(t.anisotropicLevel,i.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,r.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===be.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===be.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}Ka.extension={type:$.RendererSystem,name:"texture"},Q.add(Ka);class Za{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,r=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,r)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:i,renderer:r}=this;e&&r.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:r}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[r]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let a=0;a<t.buffers.length;a++){const o=t.buffers[a];o&&(i.buffer.update(o),o._glBuffers[r].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,a,o._glBuffers[r].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let a=0;a<t.buffers.length;a++){const o=t.buffers[a];if(!o)continue;const h=o._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&n.dispose(o,e))}i&&(e||r.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Za.extension={type:$.RendererSystem,name:"transformFeedback"},Q.add(Za);class wr{constructor(t){this.renderer=t}init(t){this.screen=new ut(0,0,t.width,t.height),this.element=t.view||q.ADAPTER.createCanvas(),this.resolution=t.resolution||q.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const i=this.element.width/this.resolution,r=this.element.height/this.resolution;this.screen.width=i,this.screen.height=r,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${r}px`),this.renderer.emit("resize",i,r),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&((e=this.element.parentNode)==null||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}wr.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},wr.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"_view"},Q.add(wr),q.PREFER_ENV=Zt.WEBGL2,q.STRICT_TEXTURE_CACHE=!1,q.RENDER_OPTIONS={...xr.defaultOptions,...vr.defaultOptions,...wr.defaultOptions,...Tr.defaultOptions},Object.defineProperties(q,{WRAP_MODE:{get(){return lt.defaultOptions.wrapMode},set(s){ot("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),lt.defaultOptions.wrapMode=s}},SCALE_MODE:{get(){return lt.defaultOptions.scaleMode},set(s){ot("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),lt.defaultOptions.scaleMode=s}},MIPMAP_TEXTURES:{get(){return lt.defaultOptions.mipmap},set(s){ot("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),lt.defaultOptions.mipmap=s}},ANISOTROPIC_LEVEL:{get(){return lt.defaultOptions.anisotropicLevel},set(s){ot("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),lt.defaultOptions.anisotropicLevel=s}},FILTER_RESOLUTION:{get(){return ot("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),kt.defaultResolution},set(s){kt.defaultResolution=s}},FILTER_MULTISAMPLE:{get(){return ot("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),kt.defaultMultisample},set(s){kt.defaultMultisample=s}},SPRITE_MAX_TEXTURES:{get(){return Ze.defaultMaxTextures},set(s){ot("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Ze.defaultMaxTextures=s}},SPRITE_BATCH_SIZE:{get(){return Ze.defaultBatchSize},set(s){ot("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Ze.defaultBatchSize=s}},CAN_UPLOAD_SAME_BUFFER:{get(){return Ze.canUploadSameBuffer},set(s){ot("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Ze.canUploadSameBuffer=s}},GC_MODE:{get(){return Qe.defaultMode},set(s){ot("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Qe.defaultMode=s}},GC_MAX_IDLE:{get(){return Qe.defaultMaxIdle},set(s){ot("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Qe.defaultMaxIdle=s}},GC_MAX_CHECK_COUNT:{get(){return Qe.defaultCheckCountMax},set(s){ot("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Qe.defaultCheckCountMax=s}},PRECISION_VERTEX:{get(){return Ae.defaultVertexPrecision},set(s){ot("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Ae.defaultVertexPrecision=s}},PRECISION_FRAGMENT:{get(){return Ae.defaultFragmentPrecision},set(s){ot("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Ae.defaultFragmentPrecision=s}}});var Pe=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(Pe||{});class Ja{constructor(t,e=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=r}match(t,e=null){return this.fn===t&&this.context===e}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(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);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Su=class Kt{constructor(){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 Ja(null,null,1/0),this.deltaMS=1/Kt.targetFPMS,this.elapsedMS=1/Kt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=Pe.NORMAL){return this._addListener(new Ja(t,e,i))}addOnce(t,e,i=Pe.NORMAL){return this._addListener(new Ja(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Kt.targetFPMS;const i=this._head;let r=i.next;for(;r;)r=r.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,Kt.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!Kt._shared){const t=Kt._shared=new Kt;t.autoStart=!0,t._protected=!0}return Kt._shared}static get system(){if(!Kt._system){const t=Kt._system=new Kt;t.autoStart=!0,t._protected=!0}return Kt._system}};Su.targetFPMS=.06;let Pt=Su;Object.defineProperties(q,{TARGET_FPMS:{get(){return Pt.targetFPMS},set(s){ot("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),Pt.targetFPMS=s}}});class As{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Pe.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Pt.shared:new Pt,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}As.extension=$.Application,Q.add(As);const Pu=[];Q.handleByList($.Renderer,Pu);function Mu(s){for(const t of Pu)if(t.test(s))return new t(s);throw new Error("Unable to auto-detect a suitable renderer.")}var om=`attribute vec2 aVertexPosition;
419
490
  attribute vec2 aTextureCoord;
420
491
 
421
492
  uniform mat3 projectionMatrix;
@@ -426,7 +497,7 @@ void main(void)
426
497
  {
427
498
  gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
428
499
  vTextureCoord = aTextureCoord;
429
- }`,__=`attribute vec2 aVertexPosition;
500
+ }`,hm=`attribute vec2 aVertexPosition;
430
501
 
431
502
  uniform mat3 projectionMatrix;
432
503
 
@@ -452,469 +523,150 @@ void main(void)
452
523
  gl_Position = filterVertexPosition();
453
524
  vTextureCoord = filterTextureCoord();
454
525
  }
455
- `,Du=v_,oa=__,g_=function(){function i(t){Bt("6.1.0","System class is deprecated, implemement ISystem interface instead."),this.renderer=t}return i.prototype.destroy=function(){this.renderer=null},i}(),Vi=function(){function i(){this.texArray=null,this.blend=0,this.type=jt.TRIANGLES,this.start=0,this.size=0,this.data=null}return i}(),ji=function(){function i(){this.elements=[],this.ids=[],this.count=0}return i.prototype.clear=function(){for(var t=0;t<this.count;t++)this.elements[t]=null;this.count=0},i}(),zi=function(){function i(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}return Object.defineProperty(i.prototype,"int8View",{get:function(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"uint8View",{get:function(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"int16View",{get:function(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"uint16View",{get:function(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"int32View",{get:function(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View},enumerable:!1,configurable:!0}),i.prototype.view=function(t){return this[t+"View"]},i.prototype.destroy=function(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null},i.sizeOf=function(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(t+" isn't a valid view type")}},i}(),Fu=function(i){mt(t,i);function t(e){var r=i.call(this,e)||this;return r.shaderGenerator=null,r.geometryClass=null,r.vertexSize=null,r.state=Oe.for2d(),r.size=z.SPRITE_BATCH_SIZE*4,r._vertexCount=0,r._indexCount=0,r._bufferedElements=[],r._bufferedTextures=[],r._bufferSize=0,r._shader=null,r._packedGeometries=[],r._packedGeometryPoolSize=2,r._flushId=0,r._aBuffers={},r._iBuffers={},r.MAX_TEXTURES=1,r.renderer.on("prerender",r.onPrerender,r),e.runners.contextChange.add(r),r._dcIndex=0,r._aIndex=0,r._iIndex=0,r._attributeBuffer=null,r._indexBuffer=null,r._tempBoundTextures=[],r}return t.prototype.contextChange=function(){var e=this.renderer.gl;z.PREFER_ENV===Ut.WEBGL_LEGACY?this.MAX_TEXTURES=1:(this.MAX_TEXTURES=Math.min(e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),z.SPRITE_MAX_TEXTURES),this.MAX_TEXTURES=mu(this.MAX_TEXTURES,e)),this._shader=this.shaderGenerator.generateShader(this.MAX_TEXTURES);for(var r=0;r<this._packedGeometryPoolSize;r++)this._packedGeometries[r]=new this.geometryClass;this.initFlushBuffers()},t.prototype.initFlushBuffers=function(){for(var e=t._drawCallPool,r=t._textureArrayPool,n=this.size/4,s=Math.floor(n/this.MAX_TEXTURES)+1;e.length<n;)e.push(new Vi);for(;r.length<s;)r.push(new ji);for(var a=0;a<this.MAX_TEXTURES;a++)this._tempBoundTextures[a]=null},t.prototype.onPrerender=function(){this._flushId=0},t.prototype.render=function(e){e._texture.valid&&(this._vertexCount+e.vertexData.length/2>this.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,r=e._bufferedTextures,n=e.MAX_TEXTURES,s=t._textureArrayPool,a=this.renderer.batch,o=this._tempBoundTextures,h=this.renderer.textureGC.count,u=++lt._globalBatch,l=0,c=s[0],f=0;a.copyBoundTextures(o,n);for(var d=0;d<this._bufferSize;++d){var v=r[d];r[d]=null,v._batchEnabled!==u&&(c.count>=n&&(a.boundArray(c,o,u,n),this.buildDrawCalls(c,f,d),f=d,c=s[++l],++u),v._batchEnabled=u,v.touched=h,c.elements[c.count++]=v)}c.count>0&&(a.boundArray(c,o,u,n),this.buildDrawCalls(c,f,this._bufferSize),++l,++u);for(var d=0;d<o.length;d++)o[d]=null;lt._globalBatch=u},t.prototype.buildDrawCalls=function(e,r,n){var s=this,a=s._bufferedElements,o=s._attributeBuffer,h=s._indexBuffer,u=s.vertexSize,l=t._drawCallPool,c=this._dcIndex,f=this._aIndex,d=this._iIndex,v=l[c];v.start=this._iIndex,v.texArray=e;for(var _=r;_<n;++_){var p=a[_],g=p._texture.baseTexture,y=ps[g.alphaMode?1:0][p.blendMode];a[_]=null,r<_&&v.blend!==y&&(v.size=d-v.start,r=_,v=l[++c],v.texArray=e,v.start=d),this.packInterleavedGeometry(p,o,h,f,d),f+=p.vertexData.length/2*u,d+=p.indices.length,v.blend=y}r<n&&(v.size=d-v.start,++c),this._dcIndex=c,this._aIndex=f,this._iIndex=d},t.prototype.bindAndClearTexArray=function(e){for(var r=this.renderer.texture,n=0;n<e.count;n++)r.bind(e.elements[n],e.ids[n]),e.elements[n]=null;e.count=0},t.prototype.updateGeometry=function(){var e=this,r=e._packedGeometries,n=e._attributeBuffer,s=e._indexBuffer;z.CAN_UPLOAD_SAME_BUFFER?(r[this._flushId]._buffer.update(n.rawBinaryData),r[this._flushId]._indexBuffer.update(s),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,r[this._flushId]=new this.geometryClass),r[this._flushId]._buffer.update(n.rawBinaryData),r[this._flushId]._indexBuffer.update(s),this.renderer.geometry.bind(r[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)},t.prototype.drawBatches=function(){for(var e=this._dcIndex,r=this.renderer,n=r.gl,s=r.state,a=t._drawCallPool,o=null,h=0;h<e;h++){var u=a[h],l=u.texArray,c=u.type,f=u.size,d=u.start,v=u.blend;o!==l&&(o=l,this.bindAndClearTexArray(l)),this.state.blendMode=v,s.set(this.state),n.drawElements(c,f,n.UNSIGNED_SHORT,d*2)}},t.prototype.flush=function(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)},t.prototype.start=function(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.MAX_TEXTURES),this.renderer.shader.bind(this._shader),z.CAN_UPLOAD_SAME_BUFFER&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])},t.prototype.stop=function(){this.flush()},t.prototype.destroy=function(){for(var e=0;e<this._packedGeometryPoolSize;e++)this._packedGeometries[e]&&this._packedGeometries[e].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),i.prototype.destroy.call(this)},t.prototype.getAttributeBuffer=function(e){var r=kr(Math.ceil(e/8)),n=ms(r),s=r*8;this._aBuffers.length<=n&&(this._iBuffers.length=n+1);var a=this._aBuffers[s];return a||(this._aBuffers[s]=a=new zi(s*this.vertexSize*4)),a},t.prototype.getIndexBuffer=function(e){var r=kr(Math.ceil(e/12)),n=ms(r),s=r*12;this._iBuffers.length<=n&&(this._iBuffers.length=n+1);var a=this._iBuffers[n];return a||(this._iBuffers[n]=a=new Uint16Array(s)),a},t.prototype.packInterleavedGeometry=function(e,r,n,s,a){for(var o=r.uint32View,h=r.float32View,u=s/this.vertexSize,l=e.uvs,c=e.indices,f=e.vertexData,d=e._texture.baseTexture._batchLocation,v=Math.min(e.worldAlpha,1),_=v<1&&e._texture.baseTexture.alphaMode?Pi(e._tintRGB,v):e._tintRGB+(v*255<<24),p=0;p<f.length;p+=2)h[s++]=f[p],h[s++]=f[p+1],h[s++]=l[p],h[s++]=l[p+1],o[s++]=_,h[s++]=d;for(var p=0;p<c.length;p++)n[a++]=u+c[p]},t._drawCallPool=[],t._textureArrayPool=[],t}(zr),Lu=function(){function i(t,e){if(this.vertexSrc=t,this.fragTemplate=e,this.programCache={},this.defaultGroupCache={},e.indexOf("%count%")<0)throw new Error('Fragment template must contain "%count%".');if(e.indexOf("%forloop%")<0)throw new Error('Fragment template must contain "%forloop%".')}return i.prototype.generateShader=function(t){if(!this.programCache[t]){for(var e=new Int32Array(t),r=0;r<t;r++)e[r]=r;this.defaultGroupCache[t]=Re.from({uSamplers:e},!0);var n=this.fragTemplate;n=n.replace(/%count%/gi,""+t),n=n.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new _r(this.vertexSrc,n)}var s={tint:new Float32Array([1,1,1,1]),translationMatrix:new bt,default:this.defaultGroupCache[t]};return new be(this.programCache[t],s)},i.prototype.generateSampleSrc=function(t){var e="";e+=`
456
- `,e+=`
457
- `;for(var r=0;r<t;r++)r>0&&(e+=`
458
- else `),r<t-1&&(e+="if(vTextureId < "+r+".5)"),e+=`
459
- {`,e+=`
460
- color = texture2D(uSamplers[`+r+"], vTextureCoord);",e+=`
461
- }`;return e+=`
462
- `,e+=`
463
- `,e},i}(),ha=function(i){mt(t,i);function t(e){e===void 0&&(e=!1);var r=i.call(this)||this;return r._buffer=new Mt(null,e,!1),r._indexBuffer=new Mt(null,e,!0),r.addAttribute("aVertexPosition",r._buffer,2,!1,Q.FLOAT).addAttribute("aTextureCoord",r._buffer,2,!1,Q.FLOAT).addAttribute("aColor",r._buffer,4,!0,Q.UNSIGNED_BYTE).addAttribute("aTextureId",r._buffer,1,!0,Q.FLOAT).addIndex(r._indexBuffer),r}return t}(vr),Bu=`precision highp float;
464
- attribute vec2 aVertexPosition;
465
- attribute vec2 aTextureCoord;
466
- attribute vec4 aColor;
467
- attribute float aTextureId;
526
+ `;const Iu=om,Qa=hm;class to{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{const i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=St.HIGH?this.multisample=St.HIGH:e>=St.MEDIUM?this.multisample=St.MEDIUM:e>=St.LOW?this.multisample=St.LOW:this.multisample=St.NONE}destroy(){}}to.extension={type:$.RendererSystem,name:"_multisample"},Q.add(to);class lm{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class eo{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,r=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,r.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:r}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[r]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,i){const{gl:r,CONTEXT_UID:n}=this;i=i||0;const a=t._glBuffers[n]||this.createGLBuffer(t);r.bindBufferRange(r.UNIFORM_BUFFER,e||0,a.buffer,i*256,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,r=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==r.updateID)if(r.updateID=t._updateID,e.bindBuffer(t.type,r.buffer),r.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;r.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this),i&&(e||r.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new lm(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}eo.extension={type:$.RendererSystem,name:"buffer"},Q.add(eo);class io{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let r,n,a,o;if(e&&(r=e.renderTexture,n=e.clear,a=e.transform,o=e.skipUpdateTransform),this.renderingToScreen=!r,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=a,!i.context.isLost){if(r||(this.lastObjectRendered=t),!o){const h=t.enableTempParent();t.updateTransform(),t.disableTempParent(h)}i.renderTexture.bind(r),i.batch.currentRenderer.start(),(n??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),r&&(e.blit&&i.framebuffer.blit(),r.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}io.extension={type:$.RendererSystem,name:"objectRenderer"},Q.add(io);const Ss=class fh extends Au{constructor(t){super(),this.type=bn.WEBGL,t=Object.assign({},q.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new Qt({projectionMatrix:new vt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:fh.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(e),"useContextAlpha"in t&&(ot("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=fh.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:xl()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return ot("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return ot("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return ot("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return ot("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){ot("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return ot("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){ot("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return ot("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};Ss.extension={type:$.Renderer,priority:1},Ss.__plugins={},Ss.__systems={};let Ps=Ss;Q.handleByMap($.RendererPlugin,Ps.__plugins),Q.handleByMap($.RendererSystem,Ps.__systems),Q.add(Ps);class ro extends Di{constructor(t,e){const{width:i,height:r}=e||{};super(i,r),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const a=new lt;this.items.push(a),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof Di?this.addResourceAt(t[i],i):this.addResourceAt(Ca(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{const{realWidth:e,realHeight:i}=this.items[0];return this.resize(e,i),this.update(),Promise.resolve(this)}),this._load}}class Ru extends ro{constructor(t,e){const{width:i,height:r}=e||{};let n,a;Array.isArray(t)?(n=t,a=t.length):a=t,super(a,{width:i,height:r}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=ui.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:r,itemDirtyIds:n,items:a}=this,{gl:o}=t;i.dirtyId<0&&o.texImage3D(o.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,r,0,e.format,i.type,null);for(let h=0;h<r;h++){const l=a[h];n[h]<l.dirtyId&&(n[h]=l.dirtyId,l.valid&&o.texSubImage3D(o.TEXTURE_2D_ARRAY,0,0,0,h,l.resource.width,l.resource.height,1,e.format,i.type,l.resource.source))}return!0}}class Du extends Se{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Fu=class Qr extends ro{constructor(t,e){const{width:i,height:r,autoLoad:n,linkBaseTexture:a}=e||{};if(t&&t.length!==Qr.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:r});for(let o=0;o<Qr.SIDES;o++)this.items[o].target=ui.TEXTURE_CUBE_MAP_POSITIVE_X+o;this.linkBaseTexture=a!==!1,t&&this.initFromArray(t,e),n!==!1&&this.load()}bind(t){super.bind(t),t.target=ui.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=ui.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,i){const r=this.itemDirtyIds;for(let n=0;n<Qr.SIDES;n++){const a=this.items[n];(r[n]<a.dirtyId||i.dirtyId<e.dirtyId)&&(a.valid&&a.resource?(a.resource.upload(t,a,i),r[n]=a.dirtyId):r[n]<-1&&(t.gl.texImage2D(a.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),r[n]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===Qr.SIDES}};Fu.SIDES=6;let Bu=Fu;class vi extends Se{constructor(t,e){e=e||{};let i,r,n;typeof t=="string"?(i=vi.EMPTY,r=t,n=!0):(i=t,r=null,n=!1),super(i),this.url=r,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??n,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{const i=await q.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const r=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(r,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Nt.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return vi._EMPTY=vi._EMPTY??q.ADAPTER.createCanvas(0,0),vi._EMPTY}}const so=class _n extends Se{constructor(t,e){e=e||{},super(q.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},_n.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const t=new Image;Se.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let r=e*this.scale,n=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(r=this._overrideWidth||this._overrideHeight/i*e,n=this._overrideHeight||this._overrideWidth/e*i),r=Math.round(r),n=Math.round(n);const a=this.source;a.width=r,a.height=n,a._pixiId=`canvas_${qe()}`,a.getContext("2d").drawImage(t,0,0,e,i,0,0,r,n),this._resolve(),this._resolve=null}}static getSize(t){const e=_n.SVG_SIZE.exec(t),i={};return e&&(i[e[1]]=Math.round(parseFloat(e[3])),i[e[5]]=Math.round(parseFloat(e[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&_n.SVG_XML.test(t)}};so.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,so.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Ms=so;class um extends Se{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const no=class ph extends Se{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const r=t[0].src||t[0];Se.crossOrigin(i,r,e.crossorigin);for(let n=0;n<t.length;++n){const a=document.createElement("source");let{src:o,mime:h}=t[n];if(o=o||t[n],o.startsWith("data:"))h=o.slice(5,o.indexOf(";"));else if(!o.startsWith("blob:")){const l=o.split("?").shift().toLowerCase(),u=l.slice(l.lastIndexOf(".")+1);h=h||ph.MIME_TYPES[u]||`video/${u}`}a.src=o,h&&(a.type=h),i.appendChild(a)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const e=Pt.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const t=this.source;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(Pt.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(Pt.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Pt.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||ph.TYPES.includes(e)}};no.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],no.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let ao=no;cs.push(vi,La,Du,ao,um,Ms,ur,Bu,Ru);class cm{constructor(){this._glTransformFeedbacks={},this.buffers=[],this.disposeRunner=new Wt("disposeTransformFeedback")}bindBuffer(t,e){this.buffers[t]=e}destroy(){this.disposeRunner.emit(this,!1)}}const dm="7.4.3";class Cr{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?ut.EMPTY:(t=t||new ut(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)}addPoint(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)}addPointMatrix(t,e){const{a:i,b:r,c:n,d:a,tx:o,ty:h}=t,l=i*e.x+n*e.y+o,u=r*e.x+a*e.y+h;this.minX=Math.min(this.minX,l),this.maxX=Math.max(this.maxX,l),this.minY=Math.min(this.minY,u),this.maxY=Math.max(this.maxY,u)}addQuad(t){let e=this.minX,i=this.minY,r=this.maxX,n=this.maxY,a=t[0],o=t[1];e=a<e?a:e,i=o<i?o:i,r=a>r?a:r,n=o>n?o:n,a=t[2],o=t[3],e=a<e?a:e,i=o<i?o:i,r=a>r?a:r,n=o>n?o:n,a=t[4],o=t[5],e=a<e?a:e,i=o<i?o:i,r=a>r?a:r,n=o>n?o:n,a=t[6],o=t[7],e=a<e?a:e,i=o<i?o:i,r=a>r?a:r,n=o>n?o:n,this.minX=e,this.minY=i,this.maxX=r,this.maxY=n}addFrame(t,e,i,r,n){this.addFrameMatrix(t.worldTransform,e,i,r,n)}addFrameMatrix(t,e,i,r,n){const a=t.a,o=t.b,h=t.c,l=t.d,u=t.tx,c=t.ty;let d=this.minX,f=this.minY,p=this.maxX,g=this.maxY,m=a*e+h*i+u,_=o*e+l*i+c;d=m<d?m:d,f=_<f?_:f,p=m>p?m:p,g=_>g?_:g,m=a*r+h*i+u,_=o*r+l*i+c,d=m<d?m:d,f=_<f?_:f,p=m>p?m:p,g=_>g?_:g,m=a*e+h*n+u,_=o*e+l*n+c,d=m<d?m:d,f=_<f?_:f,p=m>p?m:p,g=_>g?_:g,m=a*r+h*n+u,_=o*r+l*n+c,d=m<d?m:d,f=_<f?_:f,p=m>p?m:p,g=_>g?_:g,this.minX=d,this.minY=f,this.maxX=p,this.maxY=g}addVertexData(t,e,i){let r=this.minX,n=this.minY,a=this.maxX,o=this.maxY;for(let h=e;h<i;h+=2){const l=t[h],u=t[h+1];r=l<r?l:r,n=u<n?u:n,a=l>a?l:a,o=u>o?u:o}this.minX=r,this.minY=n,this.maxX=a,this.maxY=o}addVertices(t,e,i,r){this.addVerticesMatrix(t.worldTransform,e,i,r)}addVerticesMatrix(t,e,i,r,n=0,a=n){const o=t.a,h=t.b,l=t.c,u=t.d,c=t.tx,d=t.ty;let f=this.minX,p=this.minY,g=this.maxX,m=this.maxY;for(let _=i;_<r;_+=2){const b=e[_],y=e[_+1],E=o*b+l*y+c,v=u*y+h*b+d;f=Math.min(f,E-n),g=Math.max(g,E+n),p=Math.min(p,v-a),m=Math.max(m,v+a)}this.minX=f,this.minY=p,this.maxX=g,this.maxY=m}addBounds(t){const e=this.minX,i=this.minY,r=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>r?t.maxX:r,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,r=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,a=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=n&&r<=a){const o=this.minX,h=this.minY,l=this.maxX,u=this.maxY;this.minX=i<o?i:o,this.minY=r<h?r:h,this.maxX=n>l?n:l,this.maxY=a>u?a:u}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const i=t.minX>e.x?t.minX:e.x,r=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,a=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(i<=n&&r<=a){const o=this.minX,h=this.minY,l=this.maxX,u=this.maxY;this.minX=i<o?i:o,this.minY=r<h?r:h,this.maxX=n>l?n:l,this.maxY=a>u?a:u}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,r,n,a){t-=n,e-=a,i+=n,r+=a,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>r?this.maxY:r}}class Et extends Ee{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Fi,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new Cr,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const e=Object.keys(t);for(let i=0;i<e.length;++i){const r=e[i];Object.defineProperty(Et.prototype,r,Object.getOwnPropertyDescriptor(t,r))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new ut),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new ut),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Cr);const e=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(i==null?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const r=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const a=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=r,this._bounds.updateID+=this._boundsID-n,a}toGlobal(t,e,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,i,r){return e&&(t=e.toGlobal(t,i,r)),r||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,e=0,i=1,r=1,n=0,a=0,o=0,h=0,l=0){return this.position.x=t,this.position.y=e,this.scale.x=i||1,this.scale.y=r||1,this.rotation=n,this.skew.x=a,this.skew.y=o,this.pivot.x=h,this.pivot.y=l,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new oo),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*zl}set angle(t){this.transform.rotation=t*Wl}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount--,e._maskRefCount===0&&(e.renderable=!0,e.isMask=!1))}if(this._mask=t,this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount===0&&(e.renderable=!1,e.isMask=!0),e._maskRefCount++)}}}}class oo extends Et{constructor(){super(...arguments),this.sortDirty=null}}Et.prototype.displayObjectUpdateTransform=Et.prototype.updateTransform;const fm=new vt;function pm(s,t){return s.zIndex===t.zIndex?s._lastSortedIndex-t._lastSortedIndex:s.zIndex-t.zIndex}const Lu=class mh extends Et{constructor(){super(),this.children=[],this.sortableChildren=mh.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),r=this.getChildIndex(e);this.children[i]=e,this.children[r]=t,this.onChildrenChange(i<r?i:r)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);di(this.children,i,1),this.children.splice(e,0,t),this.onChildrenChange(e)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.removeChild(t[e]);else{const e=t[0],i=this.children.indexOf(e);if(i===-1)return null;e.parent=null,e.transform._parentID=-1,di(this.children,i,1),this._boundsID++,this.onChildrenChange(i),e.emit("removed",this),this.emit("childRemoved",e,this,i)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,di(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const i=t,r=e,n=r-i;let a;if(n>0&&n<=r){a=this.children.splice(i,n);for(let o=0;o<a.length;++o)a[o].parent=null,a[o].transform&&(a[o].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let o=0;o<a.length;++o)a[o].emit("removed",this),this.emit("childRemoved",a[o],this,o);return a}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,i=this.children.length;e<i;++e){const r=this.children[e];r._lastSortedIndex=e,!t&&r.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(pm),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t<e;++t){const i=this.children[t];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(!(!e.visible||!e.renderable))if(e.calculateBounds(),e._mask){const i=e._mask.isMaskData?e._mask.maskObject:e._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(e._bounds,i._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const i=super.getLocalBounds(t);if(!e)for(let r=0,n=this.children.length;r<n;++r){const a=this.children[r];a.visible&&a.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let i,r;this.cullArea?(i=this.cullArea,r=this.worldTransform):this._render!==mh.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(r?(r=fm.copyFrom(r),r.prepend(n)):r=n),i&&e.intersects(i,r))this._render(t);else if(this.cullArea)return;for(let a=0,o=this.children.length;a<o;++a){const h=this.children[a],l=h.cullable;h.cullable=l||!this.cullArea,h.render(t),h.cullable=l}}render(t){var e;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(e=this.filters)!=null&&e.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let i=0,r=this.children.length;i<r;++i)this.children[i].render(t)}}renderAdvanced(t){var n,a,o;const e=this.filters,i=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let h=0;h<e.length;h++)e[h].enabled&&this._enabledFilters.push(e[h])}const r=e&&((n=this._enabledFilters)==null?void 0:n.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==It.NONE));if(r&&t.batch.flush(),e&&((a=this._enabledFilters)!=null&&a.length)&&t.filter.push(this,this._enabledFilters),i&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let h=0,l=this.children.length;h<l;++h)this.children[h].render(t)}r&&t.batch.flush(),i&&t.mask.pop(this),e&&((o=this._enabledFilters)!=null&&o.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t==null?void 0:t.children,i=this.removeChildren(0,this.children.length);if(e)for(let r=0;r<i.length;++r)i[r].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}};Lu.defaultSortableChildren=!1;let Vt=Lu;Vt.prototype.containerUpdateTransform=Vt.prototype.updateTransform,Object.defineProperties(q,{SORTABLE_CHILDREN:{get(){return Vt.defaultSortableChildren},set(s){ot("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),Vt.defaultSortableChildren=s}}});const Ar=new ft,mm=new Uint16Array([0,1,2,0,2,3]);class Ge extends Vt{constructor(t){super(),this._anchor=new pe(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new gt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=nt.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||j.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=mm,this.pluginName="batch",this.isSprite=!0,this._roundPixels=q.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=Ne(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=Ne(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,i=e.a,r=e.b,n=e.c,a=e.d,o=e.tx,h=e.ty,l=this.vertexData,u=t.trim,c=t.orig,d=this._anchor;let f=0,p=0,g=0,m=0;if(u?(p=u.x-d._x*c.width,f=p+u.width,m=u.y-d._y*c.height,g=m+u.height):(p=-d._x*c.width,f=p+c.width,m=-d._y*c.height,g=m+c.height),l[0]=i*p+n*m+o,l[1]=a*m+r*p+h,l[2]=i*f+n*m+o,l[3]=a*m+r*f+h,l[4]=i*f+n*g+o,l[5]=a*g+r*f+h,l[6]=i*p+n*g+o,l[7]=a*g+r*p+h,this._roundPixels){const _=q.RESOLUTION;for(let b=0;b<l.length;++b)l[b]=Math.round(l[b]*_)/_}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,i=t.orig,r=this._anchor,n=this.transform.worldTransform,a=n.a,o=n.b,h=n.c,l=n.d,u=n.tx,c=n.ty,d=-r._x*i.width,f=d+i.width,p=-r._y*i.height,g=p+i.height;if(e[0]=a*d+h*p+u,e[1]=l*p+o*d+c,e[2]=a*f+h*p+u,e[3]=l*p+o*f+c,e[4]=a*f+h*g+u,e[5]=l*g+o*f+c,e[6]=a*d+h*g+u,e[7]=l*g+o*d+c,this._roundPixels){const m=q.RESOLUTION;for(let _=0;_<e.length;++_)e[_]=Math.round(e[_]*m)/m}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new Cr),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new ut),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,Ar);const e=this._texture.orig.width,i=this._texture.orig.height,r=-e*this.anchor.x;let n=0;return Ar.x>=r&&Ar.x<r+e&&(n=-i*this.anchor.y,Ar.y>=n&&Ar.y<n+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const i=t instanceof j?t:j.from(t,e);return new Ge(i)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=Ne(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const e=Ne(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||j.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Ou=new vt;Et.prototype._cacheAsBitmap=!1,Et.prototype._cacheData=null,Et.prototype._cacheAsBitmapResolution=null,Et.prototype._cacheAsBitmapMultisample=null;class gm{constructor(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}Object.defineProperties(Et.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(s){s!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=s,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(s){s!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=s,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(s){if(this._cacheAsBitmap===s)return;this._cacheAsBitmap=s;let t;s?(this._cacheData||(this._cacheData=new gm),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}}),Et.prototype._renderCached=function(s){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(s),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(s))},Et.prototype._initCachedDisplayObject=function(s){var d,f;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,s.batch.flush();const e=this.getLocalBounds(new ut,!0);if((f=this.filters)!=null&&f.length){const p=this.filters[0].padding;e.pad(p)}const i=this.cacheAsBitmapResolution||s.resolution;e.ceil(i),e.width=Math.max(e.width,1/i),e.height=Math.max(e.height,1/i);const r=s.renderTexture.current,n=s.renderTexture.sourceFrame.clone(),a=s.renderTexture.destinationFrame.clone(),o=s.projection.transform,h=Je.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??s.multisample}),l=`cacheAsBitmap_${qe()}`;this._cacheData.textureCacheId=l,lt.addToCache(h.baseTexture,l),j.addToCache(h,l);const u=this.transform.localTransform.copyTo(Ou).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,s.render(this,{renderTexture:h,clear:!0,transform:u,skipUpdateTransform:!1}),s.framebuffer.blit(),s.projection.transform=o,s.renderTexture.bind(r,n,a),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const c=new Ge(h);c.transform.worldTransform=this.transform.worldTransform,c.anchor.x=-(e.x/e.width),c.anchor.y=-(e.y/e.height),c.alpha=t,c._bounds=this._bounds,this._cacheData.sprite=c,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=c.containsPoint.bind(c)},Et.prototype._renderCachedCanvas=function(s){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(s),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(s))},Et.prototype._initCachedDisplayObjectCanvas=function(s){var u;if((u=this._cacheData)!=null&&u.sprite)return;const t=this.getLocalBounds(new ut,!0),e=this.alpha;this.alpha=1;const i=s.canvasContext.activeContext,r=s._projTransform,n=this.cacheAsBitmapResolution||s.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const a=Je.create({width:t.width,height:t.height,resolution:n}),o=`cacheAsBitmap_${qe()}`;this._cacheData.textureCacheId=o,lt.addToCache(a.baseTexture,o),j.addToCache(a,o);const h=Ou;this.transform.localTransform.copyTo(h),h.invert(),h.tx-=t.x,h.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,s.render(this,{renderTexture:a,clear:!0,transform:h,skipUpdateTransform:!1}),s.canvasContext.activeContext=i,s._projTransform=r,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=e;const l=new Ge(a);l.transform.worldTransform=this.transform.worldTransform,l.anchor.x=-(t.x/t.width),l.anchor.y=-(t.y/t.height),l.alpha=e,l._bounds=this._bounds,this._cacheData.sprite=l,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=s._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=l.containsPoint.bind(l)},Et.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Et.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Et.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,lt.removeFromCache(this._cacheData.textureCacheId),j.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Et.prototype._cacheAsBitmapDestroy=function(s){this.cacheAsBitmap=!1,this.destroy(s)},Et.prototype.name=null,Vt.prototype.getChildByName=function(s,t){for(let e=0,i=this.children.length;e<i;e++)if(this.children[e].name===s)return this.children[e];if(t)for(let e=0,i=this.children.length;e<i;e++){const r=this.children[e];if(!r.getChildByName)continue;const n=r.getChildByName(s,!0);if(n)return n}return null},Et.prototype.getGlobalPosition=function(s=new ft,t=!1){return this.parent?this.parent.toGlobal(this.position,s,t):(s.x=this.position.x,s.y=this.position.y),s};var _m=`varying vec2 vTextureCoord;
468
527
 
469
- uniform mat3 projectionMatrix;
470
- uniform mat3 translationMatrix;
471
- uniform vec4 tint;
528
+ uniform sampler2D uSampler;
529
+ uniform float uAlpha;
472
530
 
473
- varying vec2 vTextureCoord;
474
- varying vec4 vColor;
475
- varying float vTextureId;
531
+ void main(void)
532
+ {
533
+ gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
534
+ }
535
+ `;class ku extends kt{constructor(t=1){super(Iu,_m,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const ym={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},vm=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
536
+ `);function xm(s){const t=ym[s],e=t.length;let i=vm,r="";const n="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let a;for(let o=0;o<s;o++){let h=n.replace("%index%",o.toString());a=o,o>=e&&(a=s-o-1),h=h.replace("%value%",t[a].toString()),r+=h,r+=`
537
+ `}return i=i.replace("%blur%",r),i=i.replace("%size%",s.toString()),i}const bm=`
538
+ attribute vec2 aVertexPosition;
476
539
 
477
- void main(void){
478
- gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
540
+ uniform mat3 projectionMatrix;
479
541
 
480
- vTextureCoord = aTextureCoord;
481
- vTextureId = aTextureId;
482
- vColor = aColor * tint;
483
- }
484
- `,Nu=`varying vec2 vTextureCoord;
485
- varying vec4 vColor;
486
- varying float vTextureId;
487
- uniform sampler2D uSamplers[%count%];
542
+ uniform float strength;
488
543
 
489
- void main(void){
490
- vec4 color;
491
- %forloop%
492
- gl_FragColor = color * vColor;
493
- }
494
- `,Uu=function(){function i(){}return i.create=function(t){var e=Object.assign({vertex:Bu,fragment:Nu,geometryClass:ha,vertexSize:6},t),r=e.vertex,n=e.fragment,s=e.vertexSize,a=e.geometryClass;return function(o){mt(h,o);function h(u){var l=o.call(this,u)||this;return l.shaderGenerator=new Lu(r,n),l.geometryClass=a,l.vertexSize=s,l}return h}(Fu)},Object.defineProperty(i,"defaultVertexSrc",{get:function(){return Bu},enumerable:!1,configurable:!0}),Object.defineProperty(i,"defaultFragmentTemplate",{get:function(){return Nu},enumerable:!1,configurable:!0}),i}(),ua=Uu.create();Object.assign(ua,{extension:{name:"batch",type:dt.RendererPlugin}});var ku={},m_=function(i){Object.defineProperty(ku,i,{get:function(){return Bt("6.0.0","PIXI.systems."+i+" has moved to PIXI."+i),tu[i]}})};for(var la in tu)m_(la);var Gu={},y_=function(i){Object.defineProperty(Gu,i,{get:function(){return Bt("6.0.0","PIXI.resources."+i+" has moved to PIXI."+i),Mu[i]}})};for(var la in Mu)y_(la);var x_="6.5.10";z.SORTABLE_CHILDREN=!1;var $r=function(){function i(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}return i.prototype.isEmpty=function(){return this.minX>this.maxX||this.minY>this.maxY},i.prototype.clear=function(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0},i.prototype.getRectangle=function(t){return this.minX>this.maxX||this.minY>this.maxY?ut.EMPTY:(t=t||new ut(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)},i.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)},i.prototype.addPointMatrix=function(t,e){var r=t.a,n=t.b,s=t.c,a=t.d,o=t.tx,h=t.ty,u=r*e.x+s*e.y+o,l=n*e.x+a*e.y+h;this.minX=Math.min(this.minX,u),this.maxX=Math.max(this.maxX,u),this.minY=Math.min(this.minY,l),this.maxY=Math.max(this.maxY,l)},i.prototype.addQuad=function(t){var e=this.minX,r=this.minY,n=this.maxX,s=this.maxY,a=t[0],o=t[1];e=a<e?a:e,r=o<r?o:r,n=a>n?a:n,s=o>s?o:s,a=t[2],o=t[3],e=a<e?a:e,r=o<r?o:r,n=a>n?a:n,s=o>s?o:s,a=t[4],o=t[5],e=a<e?a:e,r=o<r?o:r,n=a>n?a:n,s=o>s?o:s,a=t[6],o=t[7],e=a<e?a:e,r=o<r?o:r,n=a>n?a:n,s=o>s?o:s,this.minX=e,this.minY=r,this.maxX=n,this.maxY=s},i.prototype.addFrame=function(t,e,r,n,s){this.addFrameMatrix(t.worldTransform,e,r,n,s)},i.prototype.addFrameMatrix=function(t,e,r,n,s){var a=t.a,o=t.b,h=t.c,u=t.d,l=t.tx,c=t.ty,f=this.minX,d=this.minY,v=this.maxX,_=this.maxY,p=a*e+h*r+l,g=o*e+u*r+c;f=p<f?p:f,d=g<d?g:d,v=p>v?p:v,_=g>_?g:_,p=a*n+h*r+l,g=o*n+u*r+c,f=p<f?p:f,d=g<d?g:d,v=p>v?p:v,_=g>_?g:_,p=a*e+h*s+l,g=o*e+u*s+c,f=p<f?p:f,d=g<d?g:d,v=p>v?p:v,_=g>_?g:_,p=a*n+h*s+l,g=o*n+u*s+c,f=p<f?p:f,d=g<d?g:d,v=p>v?p:v,_=g>_?g:_,this.minX=f,this.minY=d,this.maxX=v,this.maxY=_},i.prototype.addVertexData=function(t,e,r){for(var n=this.minX,s=this.minY,a=this.maxX,o=this.maxY,h=e;h<r;h+=2){var u=t[h],l=t[h+1];n=u<n?u:n,s=l<s?l:s,a=u>a?u:a,o=l>o?l:o}this.minX=n,this.minY=s,this.maxX=a,this.maxY=o},i.prototype.addVertices=function(t,e,r,n){this.addVerticesMatrix(t.worldTransform,e,r,n)},i.prototype.addVerticesMatrix=function(t,e,r,n,s,a){s===void 0&&(s=0),a===void 0&&(a=s);for(var o=t.a,h=t.b,u=t.c,l=t.d,c=t.tx,f=t.ty,d=this.minX,v=this.minY,_=this.maxX,p=this.maxY,g=r;g<n;g+=2){var y=e[g],T=e[g+1],I=o*y+u*T+c,m=l*T+h*y+f;d=Math.min(d,I-s),_=Math.max(_,I+s),v=Math.min(v,m-a),p=Math.max(p,m+a)}this.minX=d,this.minY=v,this.maxX=_,this.maxY=p},i.prototype.addBounds=function(t){var e=this.minX,r=this.minY,n=this.maxX,s=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<r?t.minY:r,this.maxX=t.maxX>n?t.maxX:n,this.maxY=t.maxY>s?t.maxY:s},i.prototype.addBoundsMask=function(t,e){var r=t.minX>e.minX?t.minX:e.minX,n=t.minY>e.minY?t.minY:e.minY,s=t.maxX<e.maxX?t.maxX:e.maxX,a=t.maxY<e.maxY?t.maxY:e.maxY;if(r<=s&&n<=a){var o=this.minX,h=this.minY,u=this.maxX,l=this.maxY;this.minX=r<o?r:o,this.minY=n<h?n:h,this.maxX=s>u?s:u,this.maxY=a>l?a:l}},i.prototype.addBoundsMatrix=function(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)},i.prototype.addBoundsArea=function(t,e){var r=t.minX>e.x?t.minX:e.x,n=t.minY>e.y?t.minY:e.y,s=t.maxX<e.x+e.width?t.maxX:e.x+e.width,a=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(r<=s&&n<=a){var o=this.minX,h=this.minY,u=this.maxX,l=this.maxY;this.minX=r<o?r:o,this.minY=n<h?n:h,this.maxX=s>u?s:u,this.maxY=a>l?a:l}},i.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)},i.prototype.addFramePad=function(t,e,r,n,s,a){t-=s,e-=a,r+=s,n+=a,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>r?this.maxX:r,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>n?this.maxY:n},i}();var fa=function(i,t){return fa=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},fa(i,t)};function ca(i,t){fa(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Ct=function(i){ca(t,i);function t(){var e=i.call(this)||this;return e.tempDisplayObjectParent=null,e.transform=new Mi,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 $r,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 r=Object.keys(e),n=0;n<r.length;++n){var s=r[n];Object.defineProperty(t.prototype,s,Object.getOwnPropertyDescriptor(e,s))}},Object.defineProperty(t.prototype,"destroyed",{get:function(){return this._destroyed},enumerable:!1,configurable:!0}),t.prototype._recursivePostUpdateTransform=function(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)},t.prototype.updateTransform=function(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha},t.prototype.getBounds=function(e,r){return e||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),r||(this._boundsRect||(this._boundsRect=new ut),r=this._boundsRect),this._bounds.getRectangle(r)},t.prototype.getLocalBounds=function(e){e||(this._localBoundsRect||(this._localBoundsRect=new ut),e=this._localBoundsRect),this._localBounds||(this._localBounds=new $r);var r=this.transform,n=this.parent;this.parent=null,this.transform=this._tempDisplayObjectParent.transform;var s=this._bounds,a=this._boundsID;this._bounds=this._localBounds;var o=this.getBounds(!1,e);return this.parent=n,this.transform=r,this._bounds=s,this._bounds.updateID+=this._boundsID-a,o},t.prototype.toGlobal=function(e,r,n){return n===void 0&&(n=!1),n||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(e,r)},t.prototype.toLocal=function(e,r,n,s){return r&&(e=r.toGlobal(e,n,s)),s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(e,n)},t.prototype.setParent=function(e){if(!e||!e.addChild)throw new Error("setParent: Argument must be a Container");return e.addChild(this),e},t.prototype.setTransform=function(e,r,n,s,a,o,h,u,l){return e===void 0&&(e=0),r===void 0&&(r=0),n===void 0&&(n=1),s===void 0&&(s=1),a===void 0&&(a=0),o===void 0&&(o=0),h===void 0&&(h=0),u===void 0&&(u=0),l===void 0&&(l=0),this.position.x=e,this.position.y=r,this.scale.x=n||1,this.scale.y=s||1,this.rotation=a,this.skew.x=o,this.skew.y=h,this.pivot.x=u,this.pivot.y=l,this},t.prototype.destroy=function(e){this.parent&&this.parent.removeChild(this),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.interactive=!1,this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()},Object.defineProperty(t.prototype,"_tempDisplayObjectParent",{get:function(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new da),this.tempDisplayObjectParent},enumerable:!1,configurable:!0}),t.prototype.enableTempParent=function(){var e=this.parent;return this.parent=this._tempDisplayObjectParent,e},t.prototype.disableTempParent=function(e){this.parent=e},Object.defineProperty(t.prototype,"x",{get:function(){return this.position.x},set:function(e){this.transform.position.x=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this.position.y},set:function(e){this.transform.position.y=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldTransform",{get:function(){return this.transform.worldTransform},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localTransform",{get:function(){return this.transform.localTransform},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this.transform.position},set:function(e){this.transform.position.copyFrom(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scale",{get:function(){return this.transform.scale},set:function(e){this.transform.scale.copyFrom(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pivot",{get:function(){return this.transform.pivot},set:function(e){this.transform.pivot.copyFrom(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"skew",{get:function(){return this.transform.skew},set:function(e){this.transform.skew.copyFrom(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this.transform.rotation},set:function(e){this.transform.rotation=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"angle",{get:function(){return this.transform.rotation*Yh},set:function(e){this.transform.rotation=e*qh},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zIndex",{get:function(){return this._zIndex},set:function(e){this._zIndex=e,this.parent&&(this.parent.sortDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldVisible",{get:function(){var e=this;do{if(!e.visible)return!1;e=e.parent}while(e);return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mask",{get:function(){return this._mask},set:function(e){if(this._mask!==e){if(this._mask){var r=this._mask.isMaskData?this._mask.maskObject:this._mask;r&&(r._maskRefCount--,r._maskRefCount===0&&(r.renderable=!0,r.isMask=!1))}if(this._mask=e,this._mask){var r=this._mask.isMaskData?this._mask.maskObject:this._mask;r&&(r._maskRefCount===0&&(r.renderable=!1,r.isMask=!0),r._maskRefCount++)}}},enumerable:!1,configurable:!0}),t}(xe),da=function(i){ca(t,i);function t(){var e=i!==null&&i.apply(this,arguments)||this;return e.sortDirty=null,e}return t}(Ct);Ct.prototype.displayObjectUpdateTransform=Ct.prototype.updateTransform;function b_(i,t){return i.zIndex===t.zIndex?i._lastSortedIndex-t._lastSortedIndex:i.zIndex-t.zIndex}var Zt=function(i){ca(t,i);function t(){var e=i.call(this)||this;return e.children=[],e.sortableChildren=z.SORTABLE_CHILDREN,e.sortDirty=!1,e}return t.prototype.onChildrenChange=function(e){},t.prototype.addChild=function(){for(var e=arguments,r=[],n=0;n<arguments.length;n++)r[n]=e[n];if(r.length>1)for(var s=0;s<r.length;s++)this.addChild(r[s]);else{var a=r[0];a.parent&&a.parent.removeChild(a),a.parent=this,this.sortDirty=!0,a.transform._parentID=-1,this.children.push(a),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",a,this,this.children.length-1),a.emit("added",this)}return r[0]},t.prototype.addChildAt=function(e,r){if(r<0||r>this.children.length)throw new Error(e+"addChildAt: The index "+r+" 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(r,0,e),this._boundsID++,this.onChildrenChange(r),e.emit("added",this),this.emit("childAdded",e,this,r),e},t.prototype.swapChildren=function(e,r){if(e!==r){var n=this.getChildIndex(e),s=this.getChildIndex(r);this.children[n]=r,this.children[s]=e,this.onChildrenChange(n<s?n:s)}},t.prototype.getChildIndex=function(e){var r=this.children.indexOf(e);if(r===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return r},t.prototype.setChildIndex=function(e,r){if(r<0||r>=this.children.length)throw new Error("The index "+r+" supplied is out of bounds "+this.children.length);var n=this.getChildIndex(e);Ve(this.children,n,1),this.children.splice(r,0,e),this.onChildrenChange(r)},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,r=[],n=0;n<arguments.length;n++)r[n]=e[n];if(r.length>1)for(var s=0;s<r.length;s++)this.removeChild(r[s]);else{var a=r[0],o=this.children.indexOf(a);if(o===-1)return null;a.parent=null,a.transform._parentID=-1,Ve(this.children,o,1),this._boundsID++,this.onChildrenChange(o),a.emit("removed",this),this.emit("childRemoved",a,this,o)}return r[0]},t.prototype.removeChildAt=function(e){var r=this.getChildAt(e);return r.parent=null,r.transform._parentID=-1,Ve(this.children,e,1),this._boundsID++,this.onChildrenChange(e),r.emit("removed",this),this.emit("childRemoved",r,this,e),r},t.prototype.removeChildren=function(e,r){e===void 0&&(e=0),r===void 0&&(r=this.children.length);var n=e,s=r,a=s-n,o;if(a>0&&a<=s){o=this.children.splice(n,a);for(var h=0;h<o.length;++h)o[h].parent=null,o[h].transform&&(o[h].transform._parentID=-1);this._boundsID++,this.onChildrenChange(e);for(var h=0;h<o.length;++h)o[h].emit("removed",this),this.emit("childRemoved",o[h],this,h);return o}else if(a===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},t.prototype.sortChildren=function(){for(var e=!1,r=0,n=this.children.length;r<n;++r){var s=this.children[r];s._lastSortedIndex=r,!e&&s.zIndex!==0&&(e=!0)}e&&this.children.length>1&&this.children.sort(b_),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,r=this.children.length;e<r;++e){var n=this.children[e];n.visible&&n.updateTransform()}},t.prototype.calculateBounds=function(){this._bounds.clear(),this._calculateBounds();for(var e=0;e<this.children.length;e++){var r=this.children[e];if(!(!r.visible||!r.renderable))if(r.calculateBounds(),r._mask){var n=r._mask.isMaskData?r._mask.maskObject:r._mask;n?(n.calculateBounds(),this._bounds.addBoundsMask(r._bounds,n._bounds)):this._bounds.addBounds(r._bounds)}else r.filterArea?this._bounds.addBoundsArea(r._bounds,r.filterArea):this._bounds.addBounds(r._bounds)}this._bounds.updateID=this._boundsID},t.prototype.getLocalBounds=function(e,r){r===void 0&&(r=!1);var n=i.prototype.getLocalBounds.call(this,e);if(!r)for(var s=0,a=this.children.length;s<a;++s){var o=this.children[s];o.visible&&o.updateTransform()}return n},t.prototype._calculateBounds=function(){},t.prototype._renderWithCulling=function(e){var r=e.renderTexture.sourceFrame;if(r.width>0&&r.height>0){var n,s;if(this.cullArea?(n=this.cullArea,s=this.worldTransform):this._render!==t.prototype._render&&(n=this.getBounds(!0)),n&&r.intersects(n,s))this._render(e);else if(this.cullArea)return;for(var a=0,o=this.children.length;a<o;++a){var h=this.children[a],u=h.cullable;h.cullable=u||!this.cullArea,h.render(e),h.cullable=u}}},t.prototype.render=function(e){if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||this.filters&&this.filters.length)this.renderAdvanced(e);else if(this.cullable)this._renderWithCulling(e);else{this._render(e);for(var r=0,n=this.children.length;r<n;++r)this.children[r].render(e)}},t.prototype.renderAdvanced=function(e){var r=this.filters,n=this._mask;if(r){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(var s=0;s<r.length;s++)r[s].enabled&&this._enabledFilters.push(r[s])}var a=r&&this._enabledFilters&&this._enabledFilters.length||n&&(!n.isMaskData||n.enabled&&(n.autoDetect||n.type!==It.NONE));if(a&&e.batch.flush(),r&&this._enabledFilters&&this._enabledFilters.length&&e.filter.push(this,this._enabledFilters),n&&e.mask.push(this,this._mask),this.cullable)this._renderWithCulling(e);else{this._render(e);for(var s=0,o=this.children.length;s<o;++s)this.children[s].render(e)}a&&e.batch.flush(),n&&e.mask.pop(this),r&&this._enabledFilters&&this._enabledFilters.length&&e.filter.pop()},t.prototype._render=function(e){},t.prototype.destroy=function(e){i.prototype.destroy.call(this),this.sortDirty=!1;var r=typeof e=="boolean"?e:e&&e.children,n=this.removeChildren(0,this.children.length);if(r)for(var s=0;s<n.length;++s)n[s].destroy(e)},Object.defineProperty(t.prototype,"width",{get:function(){return this.scale.x*this.getLocalBounds().width},set:function(e){var r=this.getLocalBounds().width;r!==0?this.scale.x=e/r:this.scale.x=1,this._width=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this.scale.y*this.getLocalBounds().height},set:function(e){var r=this.getLocalBounds().height;r!==0?this.scale.y=e/r:this.scale.y=1,this._height=e},enumerable:!1,configurable:!0}),t}(Ct);Zt.prototype.containerUpdateTransform=Zt.prototype.updateTransform;var Qe=Math.pow,St=(i,t,e)=>new Promise((r,n)=>{var s=h=>{try{o(e.next(h))}catch(u){n(u)}},a=h=>{try{o(e.throw(h))}catch(u){n(u)}},o=h=>h.done?r(h.value):Promise.resolve(h.value).then(s,a);o((e=e.apply(i,t)).next())});const Xu=2,Hu=2;var Kr;(i=>{i.supportMoreMaskDivisions=!0,i.setOpacityFromMotion=!1})(Kr||(Kr={}));var Ft;(i=>{i.LOG_LEVEL_VERBOSE=0,i.LOG_LEVEL_WARNING=1,i.LOG_LEVEL_ERROR=2,i.LOG_LEVEL_NONE=999,i.logLevel=i.LOG_LEVEL_WARNING,i.sound=!0,i.motionSync=!0,i.motionFadingDuration=500,i.idleMotionFadingDuration=2e3,i.expressionFadingDuration=500,i.preserveExpressionOnMotion=!0,i.cubism4=Kr})(Ft||(Ft={}));const _t={log(i,...t){Ft.logLevel<=Ft.LOG_LEVEL_VERBOSE&&console.log(`[${i}]`,...t)},warn(i,...t){Ft.logLevel<=Ft.LOG_LEVEL_WARNING&&console.warn(`[${i}]`,...t)},error(i,...t){Ft.logLevel<=Ft.LOG_LEVEL_ERROR&&console.error(`[${i}]`,...t)}};function Wi(i,t,e){return i<t?t:i>e?e:i}function T_(i,t){return Math.random()*(t-i)+i}function Zr(i,t,e,r,n){const s=t[r];s!==null&&typeof s===i&&(e[n]=s)}function Jr(i,t,e,r,n){const s=t[r];Array.isArray(s)&&(e[n]=s.filter(a=>a!==null&&typeof a===i))}function Vu(i,t){t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(r=>{r!=="constructor"&&Object.defineProperty(i.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r))})})}function E_(i){let t=i.lastIndexOf("/");return t!=-1&&(i=i.slice(0,t)),t=i.lastIndexOf("/"),t!==-1&&(i=i.slice(t+1)),i}function S_(i,t){const e=i.indexOf(t);e!==-1&&i.splice(e,1)}class pa extends xe{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 St(this,null,function*(){if(!this.definitions[t]){_t.warn(this.tag,`Undefined expression at [${t}]`);return}if(this.expressions[t]===null){_t.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 St(this,null,function*(){if(this.definitions.length){const t=[];for(let e=0;e<this.definitions.length;e++)this.expressions[e]!==null&&this.expressions[e]!==this.currentExpression&&e!==this.reserveExpressionIndex&&t.push(e);if(t.length){const e=Math.floor(Math.random()*t.length);return this.setExpression(e)}}return!1})}resetExpression(){this._setExpression(this.defaultExpression)}restoreExpression(){this._setExpression(this.currentExpression)}setExpression(t){return St(this,null,function*(){if(typeof t!="number"&&(t=this.getExpressionIndex(t)),!(t>-1&&t<this.definitions.length)||t===this.expressions.indexOf(this.currentExpression))return!1;this.reserveExpressionIndex=t;const e=yield this.loadExpression(t);return!e||this.reserveExpressionIndex!==t?!1:(this.reserveExpressionIndex=-1,this.currentExpression=e,this._setExpression(e),!0)})}update(t,e){return this.isFinished()?!1:this.updateParameters(t,e)}destroy(){this.destroyed=!0,this.emit("destroy");const t=this;t.definitions=void 0,t.expressions=void 0}}const ju=.01,P_=40/7.5,w_=1/(.15*1e3);class C_{constructor(){this.targetX=0,this.targetY=0,this.x=0,this.y=0,this.vx=0,this.vy=0}focus(t,e,r=!1){this.targetX=Wi(t,-1,1),this.targetY=Wi(e,-1,1),r&&(this.x=this.targetX,this.y=this.targetY)}update(t){const e=this.targetX-this.x,r=this.targetY-this.y;if(Math.abs(e)<ju&&Math.abs(r)<ju)return;const n=Math.sqrt(Qe(e,2)+Qe(r,2)),s=P_/(1e3/t);let a=s*(e/n)-this.vx,o=s*(r/n)-this.vy;const h=Math.sqrt(Qe(a,2)+Qe(o,2)),u=s*w_*t;h>u&&(a*=u/h,o*=u/h),this.vx+=a,this.vy+=o;const l=Math.sqrt(Qe(this.vx,2)+Qe(this.vy,2)),c=.5*(Math.sqrt(Qe(u,2)+8*u*n)-u);l>c&&(this.vx*=c/l,this.vy*=c/l),this.x+=this.vx,this.y+=this.vy}}class Yi{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=E_(this.url)}resolveURL(t){return ce.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<this.textures.length;e++)this.textures[e]=t(this.textures[e],`textures[${e}]`)}getDefinedFiles(){const t=[];return this.replaceFiles(e=>(t.push(e),e)),t}validateFiles(t){const e=(s,a)=>{const o=this.resolveURL(s);if(!t.includes(o)){if(a)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 va=(i=>(i[i.NONE=0]="NONE",i[i.IDLE=1]="IDLE",i[i.NORMAL=2]="NORMAL",i[i.FORCE=3]="FORCE",i))(va||{});class I_{constructor(){this.debug=!1,this.currentPriority=0,this.reservePriority=0}reserve(t,e,r){if(r<=0)return _t.log(this.tag,"Cannot start a motion with MotionPriority.NONE."),!1;if(t===this.currentGroup&&e===this.currentIndex)return _t.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 _t.log(this.tag,"Motion is already reserved.",this.dump(t,e)),!1;if(r===1){if(this.currentPriority!==0)return _t.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(t,e)),!1;if(this.reservedIdleGroup!==void 0)return _t.log(this.tag,"Cannot start idle motion because another idle motion has reserved.",this.dump(t,e)),!1;this.setReservedIdle(t,e)}else{if(r<3){if(r<=this.currentPriority)return _t.log(this.tag,"Cannot start motion because another motion is playing as an equivalent or higher priority.",this.dump(t,e)),!1;if(r<=this.reservePriority)return _t.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,r)}return!0}start(t,e,r,n){if(n===1){if(this.setReservedIdle(void 0,void 0),this.currentPriority!==0)return _t.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(e,r)),!1}else{if(e!==this.reservedGroup||r!==this.reservedIndex)return _t.log(this.tag,"Cannot start motion because another motion has taken the place.",this.dump(e,r)),!1;this.setReserved(void 0,void 0,0)}return t?(this.setCurrent(e,r,n),!0):!1}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(t,e,r){this.currentPriority=r,this.currentGroup=t,this.currentIndex=e}setReserved(t,e,r){this.reservePriority=r,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!Ft.preserveExpressionOnMotion&&this.currentPriority>1}dump(t,e){if(this.debug){const r=["currentPriority","reservePriority","currentGroup","currentIndex","reservedGroup","reservedIndex","reservedIdleGroup","reservedIdleIndex"];return`
495
- <Requested> group = "${t}", index = ${e}
496
- `+r.map(n=>"["+n+"] "+this[n]).join(`
497
- `)}return""}}const A_="SoundManager",M_=.5;class tr{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,r){const n=new Audio(t);return n.volume=this._volume,n.preload="auto",n.addEventListener("ended",()=>{this.dispose(n),e==null||e()}),n.addEventListener("error",s=>{this.dispose(n),_t.warn(A_,`Error occurred on "${t}"`,s.error),r==null||r(s.error)}),this.audios.push(n),n}static play(t){return new Promise((e,r)=>{var n;(n=t.play())==null||n.catch(s=>{t.dispatchEvent(new ErrorEvent("error",{error:s})),r(s)}),t.readyState===t.HAVE_ENOUGH_DATA?e():t.addEventListener("canplaythrough",e)})}static dispose(t){t.pause(),t.removeAttribute("src"),S_(this.audios,t)}static destroy(){for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}}tr.audios=[],tr._volume=M_;class gr extends xe{constructor(t,e){super(),this.motionGroups={},this.state=new I_,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 r of Object.keys(this.definitions))this.motionGroups[r]=[];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 r of e)if(this.definitions[r])for(let n=0;n<this.definitions[r].length;n++)this.loadMotion(r,n).then()}loadMotion(t,e){return St(this,null,function*(){var r;if(!((r=this.definitions[t])!=null&&r[e])){_t.warn(this.tag,`Undefined motion at "${t}"[${e}]`);return}if(this.motionGroups[t][e]===null){_t.warn(this.tag,`Cannot start motion at "${t}"[${e}] because it's already failed in loading.`);return}if(this.motionGroups[t][e])return this.motionGroups[t][e];const n=yield this._loadMotion(t,e);if(!this.destroyed)return this.motionGroups[t][e]=n??null,n})}_loadMotion(t,e){throw new Error("Not implemented.")}startMotion(t,e){return St(this,arguments,function*(r,n,s=va.NORMAL){var a;if(!this.state.reserve(r,n,s))return!1;const o=(a=this.definitions[r])==null?void 0:a[n];if(!o)return!1;this.currentAudio&&tr.dispose(this.currentAudio);let h;if(Ft.sound){const l=this.getSoundFile(o);if(l)try{h=tr.add(this.settings.resolveURL(l),()=>this.currentAudio=void 0,()=>this.currentAudio=void 0),this.currentAudio=h}catch(c){_t.warn(this.tag,"Failed to create audio",l,c)}}const u=yield this.loadMotion(r,n);if(h){const l=tr.play(h).catch(c=>_t.warn(this.tag,"Failed to play audio",h.src,c));Ft.motionSync&&(yield l)}return this.state.start(u,r,n,s)?(_t.log(this.tag,"Start motion:",this.getMotionName(o)),this.emit("motionStart",r,n,h),this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),this.playing=!0,this._startMotion(u),!0):(h&&(tr.dispose(h),this.currentAudio=void 0),!1)})}startRandomMotion(t,e){return St(this,null,function*(){const r=this.definitions[t];if(r!=null&&r.length){const n=[];for(let s=0;s<r.length;s++)this.motionGroups[t][s]!==null&&!this.state.isActive(t,s)&&n.push(s);if(n.length){const s=Math.floor(Math.random()*n.length);return this.startMotion(t,n[s],e)}}return!1})}stopAllMotions(){this._stopAllMotions(),this.state.reset(),this.currentAudio&&(tr.dispose(this.currentAudio),this.currentAudio=void 0)}update(t,e){var r;return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.shouldOverrideExpression()&&((r=this.expressionManager)==null||r.restoreExpression()),this.state.complete(),this.state.shouldRequestIdleMotion()&&this.startRandomMotion(this.groups.idle,va.IDLE)),this.updateParameters(t,e)}destroy(){var t;this.destroyed=!0,this.emit("destroy"),this.stopAllMotions(),(t=this.expressionManager)==null||t.destroy();const e=this;e.definitions=void 0,e.motionGroups=void 0}}const R_={x:0,y:0,width:0,height:0};class zu extends xe{constructor(){super(...arguments),this.focusController=new C_,this.originalWidth=0,this.originalHeight=0,this.width=0,this.height=0,this.localTransform=new bt,this.drawingMatrix=new bt,this.hitAreas={},this.textureFlipY=!1,this.viewport=[0,0,0,0],this.destroyed=!1}init(){this.setupLayout(),this.setupHitAreas()}setupLayout(){const t=this,e=this.getSize();t.originalWidth=e[0],t.originalHeight=e[1];const r=Object.assign({width:Xu,height:Hu},this.getLayout());this.localTransform.scale(r.width/Xu,r.height/Hu),t.width=this.originalWidth*this.localTransform.a,t.height=this.originalHeight*this.localTransform.d;const n=r.x!==void 0&&r.x-r.width/2||r.centerX!==void 0&&r.centerX||r.left!==void 0&&r.left-r.width/2||r.right!==void 0&&r.right+r.width/2||0,s=r.y!==void 0&&r.y-r.height/2||r.centerY!==void 0&&r.centerY||r.top!==void 0&&r.top-r.height/2||r.bottom!==void 0&&r.bottom+r.height/2||0;this.localTransform.translate(this.width*n,-this.height*s)}setupHitAreas(){const t=this.getHitAreaDefs().filter(e=>e.index>=0);for(const e of t)this.hitAreas[e.name]=e}hitTest(t,e){return Object.keys(this.hitAreas).filter(r=>this.isHit(r,t,e))}isHit(t,e,r){if(!this.hitAreas[t])return!1;const n=this.hitAreas[t].index,s=this.getDrawableBounds(n,R_);return s.x<=e&&e<=s.x+s.width&&s.y<=r&&r<=s.y+s.height}getDrawableBounds(t,e){const r=this.getDrawableVertices(t);let n=r[0],s=r[0],a=r[1],o=r[1];for(let h=0;h<r.length;h+=2){const u=r[h],l=r[h+1];n=Math.min(u,n),s=Math.max(u,s),a=Math.min(l,a),o=Math.max(l,o)}return e??(e={}),e.x=n,e.y=a,e.width=s-n,e.height=o-a,e}updateTransform(t){this.drawingMatrix.copyFrom(t).append(this.localTransform)}update(t,e){this.focusController.update(t)}destroy(){this.destroyed=!0,this.emit("destroy"),this.motionManager.destroy(),this.motionManager=void 0}}const O_="XHRLoader";class Wu extends Error{constructor(t,e,r,n=!1){super(t),this.url=e,this.status=r,this.aborted=n}}const Nt=class{static createXHR(i,t,e,r,n){const s=new XMLHttpRequest;if(Nt.allXhrSet.add(s),i){let a=Nt.xhrMap.get(i);a?a.add(s):(a=new Set([s]),Nt.xhrMap.set(i,a)),i.listeners("destroy").includes(Nt.cancelXHRs)||i.once("destroy",Nt.cancelXHRs)}return s.open("GET",t),s.responseType=e,s.onload=()=>{(s.status===200||s.status===0)&&s.response?r(s.response):s.onerror()},s.onerror=()=>{_t.warn(O_,`Failed to load resource as ${s.responseType} (Status ${s.status}): ${t}`),n(new Wu("Network error.",t,s.status))},s.onabort=()=>n(new Wu("Aborted.",t,s.status,!0)),s.onloadend=()=>{var a;Nt.allXhrSet.delete(s),i&&((a=Nt.xhrMap.get(i))==null||a.delete(s))},s}static cancelXHRs(){var i;(i=Nt.xhrMap.get(this))==null||i.forEach(t=>{t.abort(),Nt.allXhrSet.delete(t)}),Nt.xhrMap.delete(this)}static release(){Nt.allXhrSet.forEach(i=>i.abort()),Nt.allXhrSet.clear(),Nt.xhrMap=new WeakMap}};let qi=Nt;qi.xhrMap=new WeakMap,qi.allXhrSet=new Set,qi.loader=(i,t)=>new Promise((e,r)=>{Nt.createXHR(i.target,i.settings?i.settings.resolveURL(i.url):i.url,i.type,s=>{i.result=s,e()},r).send()});function Yu(i,t){let e=-1;return r(0);function r(n,s){if(s)return Promise.reject(s);if(n<=e)return Promise.reject(new Error("next() called multiple times"));e=n;const a=i[n];if(!a)return Promise.resolve();try{return Promise.resolve(a(t,r.bind(null,n+1)))}catch(o){return Promise.reject(o)}}}class De{static load(t){return Yu(this.middlewares,t).then(()=>t.result)}}De.middlewares=[qi.loader];function D_(i,t={}){var e;const r={resourceOptions:{crossorigin:t.crossOrigin}};if(it.fromURL)return it.fromURL(i,r).catch(a=>{if(a instanceof Error)throw a;const o=new Error("Texture loading error");throw o.event=a,o});r.resourceOptions.autoLoad=!1;const n=it.from(i,r);if(n.baseTexture.valid)return Promise.resolve(n);const s=n.baseTexture.resource;return(e=s._live2d_load)!=null||(s._live2d_load=new Promise((a,o)=>{const h=u=>{s.source.removeEventListener("error",h);const l=new Error("Texture loading error");l.event=u,o(l)};s.source.addEventListener("error",h),s.load().then(()=>a(n)).catch(h)})),s._live2d_load}const qu="Live2DFactory",$u=(i,t)=>St(void 0,null,function*(){if(typeof i.source=="string"){const e=yield De.load({url:i.source,type:"json",target:i.live2dModel});e.url=i.source,i.source=e,i.live2dModel.emit("settingsJSONLoaded",e)}return t()}),Ku=(i,t)=>St(void 0,null,function*(){if(i.source instanceof Yi)return i.settings=i.source,t();if(typeof i.source=="object"){const e=Et.findRuntime(i.source);if(e){const r=e.createModelSettings(i.source);return i.settings=r,i.live2dModel.emit("settingsLoaded",r),t()}}throw new TypeError("Unknown settings format.")}),Zu=(i,t)=>{if(i.settings){const e=Et.findRuntime(i.settings);if(e)return e.ready().then(t)}return t()},Ju=(i,t)=>St(void 0,null,function*(){yield t();const e=i.internalModel;if(e){const r=i.settings,n=Et.findRuntime(r);if(n){const s=[];r.pose&&s.push(De.load({settings:r,url:r.pose,type:"json",target:e}).then(a=>{e.pose=n.createPose(e.coreModel,a),i.live2dModel.emit("poseLoaded",e.pose)}).catch(a=>{i.live2dModel.emit("poseLoadError",a),_t.warn(qu,"Failed to load pose.",a)})),r.physics&&s.push(De.load({settings:r,url:r.physics,type:"json",target:e}).then(a=>{e.physics=n.createPhysics(e.coreModel,a),i.live2dModel.emit("physicsLoaded",e.physics)}).catch(a=>{i.live2dModel.emit("physicsLoadError",a),_t.warn(qu,"Failed to load physics.",a)})),s.length&&(yield Promise.all(s))}}}),Qu=(i,t)=>St(void 0,null,function*(){if(i.settings){const e=i.live2dModel,r=i.settings.textures.map(n=>{const s=i.settings.resolveURL(n);return D_(s,{crossOrigin:i.options.crossOrigin})});if(yield t(),i.internalModel)e.internalModel=i.internalModel,e.emit("modelLoaded",i.internalModel);else throw new TypeError("Missing internal model.");e.textures=yield Promise.all(r),e.emit("textureLoaded",e.textures)}else throw new TypeError("Missing settings.")}),tl=(i,t)=>St(void 0,null,function*(){const e=i.settings;if(e instanceof Yi){const r=Et.findRuntime(e);if(!r)throw new TypeError("Unknown model settings.");const n=yield De.load({settings:e,url:e.moc,type:"arraybuffer",target:i.live2dModel});if(!r.isValidMoc(n))throw new Error("Invalid moc data");const s=r.createCoreModel(n);return i.internalModel=r.createInternalModel(s,e,i.options),t()}throw new TypeError("Missing settings.")}),Lt=class{static registerRuntime(i){Lt.runtimes.push(i),Lt.runtimes.sort((t,e)=>e.version-t.version)}static findRuntime(i){for(const t of Lt.runtimes)if(t.test(i))return t}static setupLive2DModel(i,t,e){return St(this,null,function*(){const r=new Promise(a=>i.once("textureLoaded",a)),n=new Promise(a=>i.once("modelLoaded",a)),s=Promise.all([r,n]).then(()=>i.emit("ready"));yield Yu(Lt.live2DModelMiddlewares,{live2dModel:i,source:t,options:e||{}}),yield s,i.emit("load")})}static loadMotion(i,t,e){var r,n;const s=a=>i.emit("motionLoadError",t,e,a);try{const a=(r=i.definitions[t])==null?void 0:r[e];if(!a)return Promise.resolve(void 0);i.listeners("destroy").includes(Lt.releaseTasks)||i.once("destroy",Lt.releaseTasks);let o=Lt.motionTasksMap.get(i);o||(o={},Lt.motionTasksMap.set(i,o));let h=o[t];h||(h=[],o[t]=h);const u=i.getMotionFile(a);return(n=h[e])!=null||(h[e]=De.load({url:u,settings:i.settings,type:i.motionDataType,target:i}).then(l=>{var c;const f=(c=Lt.motionTasksMap.get(i))==null?void 0:c[t];f&&delete f[e];const d=i.createMotion(l,t,a);return i.emit("motionLoaded",t,e,d),d}).catch(l=>{_t.warn(i.tag,`Failed to load motion: ${u}
498
- `,l),s(l)})),h[e]}catch(a){_t.warn(i.tag,`Failed to load motion at "${t}"[${e}]
499
- `,a),s(a)}return Promise.resolve(void 0)}static loadExpression(i,t){var e;const r=n=>i.emit("expressionLoadError",t,n);try{const n=i.definitions[t];if(!n)return Promise.resolve(void 0);i.listeners("destroy").includes(Lt.releaseTasks)||i.once("destroy",Lt.releaseTasks);let s=Lt.expressionTasksMap.get(i);s||(s=[],Lt.expressionTasksMap.set(i,s));const a=i.getExpressionFile(n);return(e=s[t])!=null||(s[t]=De.load({url:a,settings:i.settings,type:"json",target:i}).then(o=>{const h=Lt.expressionTasksMap.get(i);h&&delete h[t];const u=i.createExpression(o,n);return i.emit("expressionLoaded",t,u),u}).catch(o=>{_t.warn(i.tag,`Failed to load expression: ${a}
500
- `,o),r(o)})),s[t]}catch(n){_t.warn(i.tag,`Failed to load expression at [${t}]
501
- `,n),r(n)}return Promise.resolve(void 0)}static releaseTasks(){this instanceof gr?Lt.motionTasksMap.delete(this):Lt.expressionTasksMap.delete(this)}};let Et=Lt;Et.runtimes=[],Et.urlToJSON=$u,Et.jsonToSettings=Ku,Et.waitUntilReady=Zu,Et.setupOptionals=Ju,Et.setupEssentials=Qu,Et.createInternalModel=tl,Et.live2DModelMiddlewares=[$u,Ku,Zu,Ju,Qu,tl],Et.motionTasksMap=new WeakMap,Et.expressionTasksMap=new WeakMap,gr.prototype._loadMotion=function(i,t){return Et.loadMotion(this,i,t)},pa.prototype._loadExpression=function(i){return Et.loadExpression(this,i)};class F_{constructor(){this._autoInteract=!1}get autoInteract(){return this._autoInteract}set autoInteract(t){t!==this._autoInteract&&(t?this.on("pointertap",el,this):this.off("pointertap",el,this),this._autoInteract=t)}registerInteraction(t){t!==this.interactionManager&&(this.unregisterInteraction(),this._autoInteract&&t&&(this.interactionManager=t,t.on("pointermove",rl,this)))}unregisterInteraction(){var t;this.interactionManager&&((t=this.interactionManager)==null||t.off("pointermove",rl,this),this.interactionManager=void 0)}}function el(i){this.tap(i.data.global.x,i.data.global.y)}function rl(i){this.focus(i.data.global.x,i.data.global.y)}class L_ extends Mi{}const Jt=new vt,B_=new bt;let Fe;class Qr extends Zt{constructor(t){super(),this.tag="Live2DModel(uninitialized)",this.textures=[],this.transform=new L_,this.anchor=new Ae(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 r=new this(e);return Et.setupLive2DModel(r,t,e).then(()=>r)}static fromSync(t,e){const r=new this(e);return Et.setupLive2DModel(r,t,e).then(e==null?void 0:e.onLoad).catch(e==null?void 0:e.onError),r}static registerTicker(t){Fe=t}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){var e;Fe||(Fe=(e=window.PIXI)==null?void 0:e.Ticker),t?this._destroyed||(Fe?(Fe.shared.add(this.onTickerUpdate,this),this._autoUpdate=!0):_t.warn(this.tag,"No Ticker registered, please call Live2DModel.registerTicker(Ticker).")):(Fe==null||Fe.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,r){return e===void 0?this.internalModel.motionManager.startRandomMotion(t,r):this.internalModel.motionManager.startMotion(t,e,r)}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,r=!1){Jt.x=t,Jt.y=e,this.toModelPosition(Jt,Jt,!0);let n=Jt.x/this.internalModel.originalWidth*2-1,s=Jt.y/this.internalModel.originalHeight*2-1,a=Math.atan2(s,n);this.internalModel.focusController.focus(Math.cos(a),-Math.sin(a),r)}tap(t,e){const r=this.hitTest(t,e);r.length&&(_t.log(this.tag,"Hit",r),this.emit("hit",r))}hitTest(t,e){return Jt.x=t,Jt.y=e,this.toModelPosition(Jt,Jt),this.internalModel.hitTest(Jt.x,Jt.y)}toModelPosition(t,e=t.clone(),r){return r||(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(Fe.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;s<this.textures.length;s++){const a=this.textures[s];a.valid&&((e||!a.baseTexture._glTextures[this.glContextID])&&(t.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL,this.internalModel.textureFlipY),t.texture.bind(a.baseTexture,0)),this.internalModel.bindTexture(s,a.baseTexture._glTextures[this.glContextID].texture),a.baseTexture.touched=t.textureGC.count)}const r=t.framebuffer.viewport;this.internalModel.viewport=[r.x,r.y,r.width,r.height],this.deltaTime&&(this.internalModel.update(this.deltaTime,this.elapsedTime),this.deltaTime=0);const n=B_.copyFrom(t.globalUniforms.uniforms.projectionMatrix).append(this.worldTransform);this.internalModel.updateTransform(n),this.internalModel.draw(t.gl),t.state.reset(),t.texture.reset()}destroy(t){this.emit("destroy"),this.autoUpdate=!1,this.unregisterInteraction(),t!=null&&t.texture&&this.textures.forEach(e=>e.destroy(t.baseTexture)),this.internalModel.destroy(),super.destroy(t)}}Vu(Qr,[F_]);const ve=class{static resolveURL(i,t){var e;const r=(e=ve.filesMap[i])==null?void 0:e[t];if(r===void 0)throw new Error("Cannot find this file from uploaded files: "+t);return r}static upload(i,t){return St(this,null,function*(){const e={};for(const r of t.getDefinedFiles()){const n=decodeURI(ce.resolve(t.url,r)),s=i.find(a=>a.webkitRelativePath===n);s&&(e[r]=URL.createObjectURL(s))}ve.filesMap[t._objectURL]=e})}static createSettings(i){return St(this,null,function*(){const t=i.find(a=>a.name.endsWith("model.json")||a.name.endsWith("model3.json"));if(!t)throw new TypeError("Settings file not found");const e=yield ve.readText(t),r=JSON.parse(e);r.url=t.webkitRelativePath;const n=Et.findRuntime(r);if(!n)throw new Error("Unknown settings JSON");const s=n.createModelSettings(r);return s._objectURL=URL.createObjectURL(t),s})}static readText(i){return St(this,null,function*(){return new Promise((t,e)=>{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=e,r.readAsText(i,"utf8")})})}};let _a=ve;_a.filesMap={},_a.factory=(i,t)=>St(void 0,null,function*(){if(Array.isArray(i.source)&&i.source[0]instanceof File){const e=i.source;let r=e.settings;if(!r)r=yield ve.createSettings(e);else if(!r._objectURL)throw new Error('"_objectURL" must be specified in ModelSettings');r.validateFiles(e.map(n=>encodeURI(n.webkitRelativePath))),yield ve.upload(e,r),r.resolveURL=function(n){return ve.resolveURL(this._objectURL,n)},i.source=r,i.live2dModel.once("modelLoaded",n=>{n.once("destroy",function(){const s=this.settings._objectURL;if(URL.revokeObjectURL(s),ve.filesMap[s])for(const a of Object.values(ve.filesMap[s]))URL.revokeObjectURL(a);delete ve.filesMap[s]})})}return t()}),Et.live2DModelMiddlewares.unshift(_a.factory);const Xt=class{static unzip(i,t){return St(this,null,function*(){const e=yield Xt.getFilePaths(i),r=[];for(const s of t.getDefinedFiles()){const a=decodeURI(ce.resolve(t.url,s));e.includes(a)&&r.push(a)}const n=yield Xt.getFiles(i,r);for(let s=0;s<n.length;s++){const a=r[s],o=n[s];Object.defineProperty(o,"webkitRelativePath",{value:a})}return n})}static createSettings(i){return St(this,null,function*(){const e=(yield Xt.getFilePaths(i)).find(a=>a.endsWith("model.json")||a.endsWith("model3.json"));if(!e)throw new Error("Settings file not found");const r=yield Xt.readText(i,e);if(!r)throw new Error("Empty settings file: "+e);const n=JSON.parse(r);n.url=e;const s=Et.findRuntime(n);if(!s)throw new Error("Unknown settings JSON");return s.createModelSettings(n)})}static zipReader(i,t){return St(this,null,function*(){throw new Error("Not implemented")})}static getFilePaths(i){return St(this,null,function*(){throw new Error("Not implemented")})}static getFiles(i,t){return St(this,null,function*(){throw new Error("Not implemented")})}static readText(i,t){return St(this,null,function*(){throw new Error("Not implemented")})}static releaseReader(i){}};let $i=Xt;if($i.ZIP_PROTOCOL="zip://",$i.uid=0,$i.factory=(i,t)=>St(void 0,null,function*(){const e=i.source;let r,n,s;if(typeof e=="string"&&(e.endsWith(".zip")||e.startsWith(Xt.ZIP_PROTOCOL))?(e.startsWith(Xt.ZIP_PROTOCOL)?r=e.slice(Xt.ZIP_PROTOCOL.length):r=e,n=yield De.load({url:r,type:"blob",target:i.live2dModel})):Array.isArray(e)&&e.length===1&&e[0]instanceof File&&e[0].name.endsWith(".zip")&&(n=e[0],r=URL.createObjectURL(n),s=e.settings),n){if(!n.size)throw new Error("Empty zip file");const a=yield Xt.zipReader(n,r);s||(s=yield Xt.createSettings(a)),s._objectURL=Xt.ZIP_PROTOCOL+Xt.uid+"/"+s.url;const o=yield Xt.unzip(a,s);o.settings=s,i.source=o,r.startsWith("blob:")&&i.live2dModel.once("modelLoaded",h=>{h.once("destroy",function(){URL.revokeObjectURL(r)})}),Xt.releaseReader(a)}return t()}),Et.live2DModelMiddlewares.unshift($i.factory),!window.Live2D)throw new Error("Could not find Cubism 2 runtime. This plugin requires live2d.min.js to be loaded.");const N_=Live2DMotion.prototype.updateParam;Live2DMotion.prototype.updateParam=function(i,t){N_.call(this,i,t),t.isFinished()&&this.onFinishHandler&&(this.onFinishHandler(this),delete this.onFinishHandler)};class U_ extends AMotion{constructor(t){super(),this.params=[],this.setFadeIn(t.fade_in>0?t.fade_in:Ft.expressionFadingDuration),this.setFadeOut(t.fade_out>0?t.fade_out:Ft.expressionFadingDuration),Array.isArray(t.params)&&t.params.forEach(e=>{const r=e.calc||"add";if(r==="add"){const n=e.def||0;e.val-=n}else if(r==="mult"){const n=e.def||1;e.val/=n}this.params.push({calc:r,val:e.val,id:e.id})})}updateParamExe(t,e,r,n){this.params.forEach(s=>{t.setParamFloat(s.id,s.val*r)})}}class k_ extends pa{constructor(t,e){var r;super(t,e),this.queueManager=new MotionQueueManager,this.definitions=(r=this.settings.expressions)!=null?r:[],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 new U_(t)}_setExpression(t){return this.queueManager.startMotion(t)}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}}class G_ extends gr{constructor(t,e){super(t,e),this.groups={idle:"idle"},this.motionDataType="arraybuffer",this.queueManager=new MotionQueueManager,this.definitions=this.settings.motions,this.init(e)}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new k_(this.settings,t))}isFinished(){return this.queueManager.isFinished()}createMotion(t,e,r){const n=Live2DMotion.loadMotion(t),s=e===this.groups.idle?Ft.idleMotionFadingDuration:Ft.motionFadingDuration;return n.setFadeIn(r.fade_in>0?r.fade_in:s),n.setFadeOut(r.fade_out>0?r.fade_out:s),n}getMotionFile(t){return t.file}getMotionName(t){return t.file}getSoundFile(t){return t.sound}_startMotion(t,e){return t.onFinishHandler=e,this.queueManager.stopAllMotions(),this.queueManager.startMotion(t)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}destroy(){super.destroy(),this.queueManager=void 0}}class X_{constructor(t){this.coreModel=t,this.blinkInterval=4e3,this.closingDuration=100,this.closedDuration=50,this.openingDuration=150,this.eyeState=0,this.eyeParamValue=1,this.closedTimer=0,this.nextBlinkTimeLeft=this.blinkInterval,this.leftParam=t.getParamIndex("PARAM_EYE_L_OPEN"),this.rightParam=t.getParamIndex("PARAM_EYE_R_OPEN")}setEyeParams(t){this.eyeParamValue=Wi(t,0,1),this.coreModel.setParamFloat(this.leftParam,this.eyeParamValue),this.coreModel.setParamFloat(this.rightParam,this.eyeParamValue)}update(t){switch(this.eyeState){case 0:this.nextBlinkTimeLeft-=t,this.nextBlinkTimeLeft<0&&(this.eyeState=1,this.nextBlinkTimeLeft=this.blinkInterval+this.closingDuration+this.closedDuration+this.openingDuration+T_(0,2e3));break;case 1:this.setEyeParams(this.eyeParamValue+t/this.closingDuration),this.eyeParamValue<=0&&(this.eyeState=2,this.closedTimer=0);break;case 2:this.closedTimer+=t,this.closedTimer>=this.closedDuration&&(this.eyeState=3);break;case 3:this.setEyeParams(this.eyeParamValue+t/this.openingDuration),this.eyeParamValue>=1&&(this.eyeState=0)}}}const er=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class H_ extends zu{constructor(t,e,r){super(),this.textureFlipY=!0,this.drawDataCount=0,this.disableCulling=!1,this.coreModel=t,this.settings=e,this.motionManager=new G_(e,r),this.eyeBlink=new X_(t),this.eyeballXParamIndex=t.getParamIndex("PARAM_EYE_BALL_X"),this.eyeballYParamIndex=t.getParamIndex("PARAM_EYE_BALL_Y"),this.angleXParamIndex=t.getParamIndex("PARAM_ANGLE_X"),this.angleYParamIndex=t.getParamIndex("PARAM_ANGLE_Y"),this.angleZParamIndex=t.getParamIndex("PARAM_ANGLE_Z"),this.bodyAngleXParamIndex=t.getParamIndex("PARAM_BODY_ANGLE_X"),this.breathParamIndex=t.getParamIndex("PARAM_BREATH"),this.init()}init(){super.init(),this.settings.initParams&&this.settings.initParams.forEach(({id:s,value:a})=>this.coreModel.setParamFloat(s,a)),this.settings.initOpacities&&this.settings.initOpacities.forEach(({id:s,value:a})=>this.coreModel.setPartsOpacity(s,a)),this.coreModel.saveParam();const t=this.coreModel.getModelContext()._$aS;t!=null&&t.length&&(this.drawDataCount=t.length);let e=this.coreModel.drawParamWebGL.culling;Object.defineProperty(this.coreModel.drawParamWebGL,"culling",{set:s=>e=s,get:()=>this.disableCulling?!1:e});const r=this.coreModel.getModelContext().clipManager,n=r.setupClip;r.setupClip=(s,a)=>{n.call(r,s,a),a.gl.viewport(...this.viewport)}}getSize(){return[this.coreModel.getCanvasWidth(),this.coreModel.getCanvasHeight()]}getLayout(){const t={};if(this.settings.layout)for(const e of Object.keys(this.settings.layout)){let r=e;e==="center_x"?r="centerX":e==="center_y"&&(r="centerY"),t[r]=this.settings.layout[e]}return t}updateWebGLContext(t,e){const r=this.coreModel.drawParamWebGL;r.firstDraw=!0,r.setGL(t),r.glno=e;for(const a in r)r.hasOwnProperty(a)&&r[a]instanceof WebGLBuffer&&(r[a]=null);const n=this.coreModel.getModelContext().clipManager;n.curFrameNo=e;const s=t.getParameter(t.FRAMEBUFFER_BINDING);n.getMaskRenderTexture(),t.bindFramebuffer(t.FRAMEBUFFER,s)}bindTexture(t,e){this.coreModel.setTexture(t,e)}getHitAreaDefs(){var t;return((t=this.settings.hitAreas)==null?void 0:t.map(e=>({id:e.id,name:e.name,index:this.coreModel.getDrawDataIndex(e.id)})))||[]}getDrawableIDs(){const t=this.coreModel.getModelContext(),e=[];for(let r=0;r<this.drawDataCount;r++){const n=t.getDrawData(r);n&&e.push(n.getDrawDataID().id)}return e}getDrawableIndex(t){return this.coreModel.getDrawDataIndex(t)}getDrawableVertices(t){if(typeof t=="string"&&(t=this.coreModel.getDrawDataIndex(t),t===-1))throw new TypeError("Unable to find drawable ID: "+t);return this.coreModel.getTransformedPoints(t).slice()}update(t,e){var r,n,s,a;super.update(t,e);const o=this.coreModel;this.emit("beforeMotionUpdate");const h=this.motionManager.update(this.coreModel,e);this.emit("afterMotionUpdate"),o.saveParam(),(r=this.motionManager.expressionManager)==null||r.update(o,e),h||(n=this.eyeBlink)==null||n.update(t),this.updateFocus(),this.updateNaturalMovements(t,e),(s=this.physics)==null||s.update(e),(a=this.pose)==null||a.update(t),this.emit("beforeModelUpdate"),o.update(),o.loadParam()}updateFocus(){this.coreModel.addToParamFloat(this.eyeballXParamIndex,this.focusController.x),this.coreModel.addToParamFloat(this.eyeballYParamIndex,this.focusController.y),this.coreModel.addToParamFloat(this.angleXParamIndex,this.focusController.x*30),this.coreModel.addToParamFloat(this.angleYParamIndex,this.focusController.y*30),this.coreModel.addToParamFloat(this.angleZParamIndex,this.focusController.x*this.focusController.y*-30),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,this.focusController.x*10)}updateNaturalMovements(t,e){const r=e/1e3*2*Math.PI;this.coreModel.addToParamFloat(this.angleXParamIndex,15*Math.sin(r/6.5345)*.5),this.coreModel.addToParamFloat(this.angleYParamIndex,8*Math.sin(r/3.5345)*.5),this.coreModel.addToParamFloat(this.angleZParamIndex,10*Math.sin(r/5.5345)*.5),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,4*Math.sin(r/15.5345)*.5),this.coreModel.setParamFloat(this.breathParamIndex,.5+.5*Math.sin(r/3.2345))}draw(t){const e=this.disableCulling;t.getParameter(t.FRAMEBUFFER_BINDING)&&(this.disableCulling=!0);const r=this.drawingMatrix;er[0]=r.a,er[1]=r.b,er[4]=r.c,er[5]=r.d,er[12]=r.tx,er[13]=r.ty,this.coreModel.setMatrix(er),this.coreModel.draw(),this.disableCulling=e}destroy(){super.destroy(),this.coreModel=void 0}}class ti extends Yi{constructor(t){if(super(t),this.motions={},!ti.isValidJSON(t))throw new TypeError("Invalid JSON.");this.moc=t.model,Jr("string",t,this,"textures","textures"),this.copy(t)}static isValidJSON(t){var e;return!!t&&typeof t.model=="string"&&((e=t.textures)==null?void 0:e.length)>0&&t.textures.every(r=>typeof r=="string")}copy(t){Zr("string",t,this,"name","name"),Zr("string",t,this,"pose","pose"),Zr("string",t,this,"physics","physics"),Zr("object",t,this,"layout","layout"),Zr("object",t,this,"motions","motions"),Jr("object",t,this,"hit_areas","hitAreas"),Jr("object",t,this,"expressions","expressions"),Jr("object",t,this,"init_params","initParams"),Jr("object",t,this,"init_opacities","initOpacities")}replaceFiles(t){super.replaceFiles(t);for(const[e,r]of Object.entries(this.motions))for(let n=0;n<r.length;n++)r[n].file=t(r[n].file,`motions.${e}[${n}].file`),r[n].sound!==void 0&&(r[n].sound=t(r[n].sound,`motions.${e}[${n}].sound`));if(this.expressions)for(let e=0;e<this.expressions.length;e++)this.expressions[e].file=t(this.expressions[e].file,`expressions[${e}].file`)}}const V_={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE},j_={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE};class z_{constructor(t,e){this.coreModel=t,this.physicsHairs=[],e.physics_hair&&(this.physicsHairs=e.physics_hair.map(r=>{const n=new PhysicsHair;return n.setup(r.setup.length,r.setup.regist,r.setup.mass),r.src.forEach(({id:s,ptype:a,scale:o,weight:h})=>{const u=V_[a];u&&n.addSrcParam(u,s,o,h)}),r.targets.forEach(({id:s,ptype:a,scale:o,weight:h})=>{const u=j_[a];u&&n.addTargetParam(u,s,o,h)}),n}))}update(t){this.physicsHairs.forEach(e=>e.update(this.coreModel,t))}}class il{constructor(t){this.id=t,this.paramIndex=-1,this.partsIndex=-1,this.link=[]}initIndex(t){this.paramIndex=t.getParamIndex("VISIBLE:"+this.id),this.partsIndex=t.getPartsDataIndex(PartsDataID.getID(this.id)),t.setParamFloat(this.paramIndex,1)}}class W_{constructor(t,e){this.coreModel=t,this.opacityAnimDuration=500,this.partsGroups=[],e.parts_visible&&(this.partsGroups=e.parts_visible.map(({group:r})=>r.map(({id:n,link:s})=>{const a=new il(n);return s&&(a.link=s.map(o=>new il(o))),a})),this.init())}init(){this.partsGroups.forEach(t=>{t.forEach(e=>{if(e.initIndex(this.coreModel),e.paramIndex>=0){const r=this.coreModel.getParamFloat(e.paramIndex)!==0;this.coreModel.setPartsOpacity(e.partsIndex,r?1:0),this.coreModel.setParamFloat(e.paramIndex,r?1:0),e.link.length>0&&e.link.forEach(n=>n.initIndex(this.coreModel))}})})}normalizePartsOpacityGroup(t,e){const r=this.coreModel,n=.5,s=.15;let a=1,o=t.findIndex(({paramIndex:h,partsIndex:u})=>u>=0&&r.getParamFloat(h)!==0);if(o>=0){const h=r.getPartsOpacity(t[o].partsIndex);a=Wi(h+e/this.opacityAnimDuration,0,1)}else o=0,a=1;t.forEach(({partsIndex:h},u)=>{if(h>=0)if(o==u)r.setPartsOpacity(h,a);else{let l=r.getPartsOpacity(h),c;a<n?c=a*(n-1)/n+1:c=(1-a)*n/(1-n),(1-c)*(1-a)>s&&(c=1-s/(1-a)),l>c&&(l=c),r.setPartsOpacity(h,l)}})}copyOpacity(t){const e=this.coreModel;t.forEach(({partsIndex:r,link:n})=>{if(r>=0&&n){const s=e.getPartsOpacity(r);n.forEach(({partsIndex:a})=>{a>=0&&e.setPartsOpacity(a,s)})}})}update(t){this.partsGroups.forEach(e=>{this.normalizePartsOpacityGroup(e,t),this.copyOpacity(e)})}}if(Et.registerRuntime({version:2,test(i){return i instanceof ti||ti.isValidJSON(i)},ready(){return Promise.resolve()},isValidMoc(i){if(i.byteLength<3)return!1;const t=new Int8Array(i,0,3);return String.fromCharCode(...t)==="moc"},createModelSettings(i){return new ti(i)},createCoreModel(i){const t=Live2DModelWebGL.loadModel(i),e=Live2D.getError();if(e)throw e;return t},createInternalModel(i,t,e){return new H_(i,t,e)},createPose(i,t){return new W_(i,t)},createPhysics(i,t){return new z_(i,t)}}),!window.Live2DCubismCore)throw new Error("Could not find Cubism 4 runtime. This plugin requires live2dcubismcore.js to be loaded.");class st{constructor(t,e){this.x=t||0,this.y=e||0}add(t){const e=new st(0,0);return e.x=this.x+t.x,e.y=this.y+t.y,e}substract(t){const e=new st(0,0);return e.x=this.x-t.x,e.y=this.y-t.y,e}multiply(t){const e=new st(0,0);return e.x=this.x*t.x,e.y=this.y*t.y,e}multiplyByScaler(t){return this.multiply(new st(t,t))}division(t){const e=new st(0,0);return e.x=this.x/t.x,e.y=this.y/t.y,e}divisionByScalar(t){return this.division(new st(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 Ki=class{static range(i,t,e){return i<t?i=t:i>e&&(i=e),i}static sin(i){return Math.sin(i)}static cos(i){return Math.cos(i)}static abs(i){return Math.abs(i)}static sqrt(i){return Math.sqrt(i)}static cbrt(i){if(i===0)return i;let t=i;const e=t<0;e&&(t=-t);let r;return t===1/0?r=1/0:(r=Math.exp(Math.log(t)/3),r=(t/(r*r)+2*r)/3),e?-r:r}static getEasingSine(i){return i<0?0:i>1?1:.5-.5*this.cos(i*Math.PI)}static max(i,t){return i>t?i:t}static min(i,t){return i>t?t:i}static degreesToRadian(i){return i/180*Math.PI}static radianToDegrees(i){return i*180/Math.PI}static directionToRadian(i,t){const e=Math.atan2(t.y,t.x),r=Math.atan2(i.y,i.x);let n=e-r;for(;n<-Math.PI;)n+=Math.PI*2;for(;n>Math.PI;)n-=Math.PI*2;return n}static directionToDegrees(i,t){const e=this.directionToRadian(i,t);let r=this.radianToDegrees(e);return t.x-i.x>0&&(r=-r),r}static radianToDirection(i){const t=new st;return t.x=this.sin(i),t.y=this.cos(i),t}static quadraticEquation(i,t,e){return this.abs(i)<Ki.Epsilon?this.abs(t)<Ki.Epsilon?-e:-e/t:-(t+this.sqrt(t*t-4*i*e))/(2*i)}static cardanoAlgorithmForBezier(i,t,e,r){if(this.sqrt(i)<Ki.Epsilon)return this.range(this.quadraticEquation(t,e,r),0,1);const n=t/i,s=e/i,a=r/i,o=(3*s-n*n)/3,h=o/3,u=(2*n*n*n-9*n*s+27*a)/27,l=u/2,c=l*l+h*h*h,f=.5,d=f+.01;if(c<0){const y=-o/3,T=y*y*y,I=this.sqrt(T),m=-u/(2*I),S=this.range(m,-1,1),x=Math.acos(S),D=2*this.cbrt(I),F=D*this.cos(x/3)-n/3;if(this.abs(F-f)<d)return this.range(F,0,1);const k=D*this.cos((x+2*Math.PI)/3)-n/3;if(this.abs(k-f)<d)return this.range(k,0,1);const L=D*this.cos((x+4*Math.PI)/3)-n/3;return this.range(L,0,1)}if(c==0){let y;l<0?y=this.cbrt(-l):y=-this.cbrt(l);const T=2*y-n/3;if(this.abs(T-f)<d)return this.range(T,0,1);const I=-y-n/3;return this.range(I,0,1)}const v=this.sqrt(c),_=this.cbrt(v-l),p=this.cbrt(v+l),g=_-p-n/3;return this.range(g,0,1)}constructor(){}};let yt=Ki;yt.Epsilon=1e-5;class Qt{constructor(){this._tr=new Float32Array(16),this.loadIdentity()}static multiply(t,e,r){const n=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),s=4;for(let a=0;a<s;++a)for(let o=0;o<s;++o)for(let h=0;h<s;++h)n[o+a*4]+=t[h+a*4]*e[o+h*4];for(let a=0;a<16;++a)r[a]=n[a]}loadIdentity(){const t=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);this.setMatrix(t)}setMatrix(t){for(let e=0;e<16;++e)this._tr[e]=t[e]}getArray(){return this._tr}getScaleX(){return this._tr[0]}getScaleY(){return this._tr[5]}getTranslateX(){return this._tr[12]}getTranslateY(){return this._tr[13]}transformX(t){return this._tr[0]*t+this._tr[12]}transformY(t){return this._tr[5]*t+this._tr[13]}invertTransformX(t){return(t-this._tr[12])/this._tr[0]}invertTransformY(t){return(t-this._tr[13])/this._tr[5]}translateRelative(t,e){const r=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,t,e,0,1]);Qt.multiply(r,this._tr,this._tr)}translate(t,e){this._tr[12]=t,this._tr[13]=e}translateX(t){this._tr[12]=t}translateY(t){this._tr[13]=t}scaleRelative(t,e){const r=new Float32Array([t,0,0,0,0,e,0,0,0,0,1,0,0,0,0,1]);Qt.multiply(r,this._tr,this._tr)}scale(t,e){this._tr[0]=t,this._tr[5]=e}multiplyByMatrix(t){Qt.multiply(t.getArray(),this._tr,this._tr)}clone(){const t=new Qt;for(let e=0;e<this._tr.length;e++)t._tr[e]=this._tr[e];return t}}class ga{initialize(t){this._model=t}drawModel(){this.getModel()!=null&&this.doDrawModel()}setMvpMatrix(t){this._mvpMatrix4x4.setMatrix(t.getArray())}getMvpMatrix(){return this._mvpMatrix4x4}setModelColor(t,e,r,n){t<0?t=0:t>1&&(t=1),e<0?e=0:e>1&&(e=1),r<0?r=0:r>1&&(r=1),n<0?n=0:n>1&&(n=1),this._modelColor.R=t,this._modelColor.G=e,this._modelColor.B=r,this._modelColor.A=n}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 ei,this._mvpMatrix4x4=new Qt,this._mvpMatrix4x4.loadIdentity()}}var Le=(i=>(i[i.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",i[i.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",i[i.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",i))(Le||{});class ei{constructor(){this.R=1,this.G=1,this.B=1,this.A=1}}let _e=!1,mr=!1,yr;const ma={vertexOffset:0,vertexStep:2};class ri{static startUp(t){if(_e)return ii("CubismFramework.startUp() is already done."),_e;if(Live2DCubismCore._isStarted)return _e=!0,!0;if(Live2DCubismCore._isStarted=!0,yr=t,yr&&Live2DCubismCore.Logging.csmSetLogFunction(yr.logFunction),_e=!0,_e){const e=Live2DCubismCore.Version.csmGetVersion(),r=(e&4278190080)>>24,n=(e&16711680)>>16,s=e&65535,a=e;ii("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+r).slice(-2),("00"+n).slice(-2),("0000"+s).slice(-4),a)}return ii("CubismFramework.startUp() is complete."),_e}static cleanUp(){_e=!1,mr=!1,yr=void 0}static initialize(){if(!_e){ni("CubismFramework is not started.");return}if(mr){ni("CubismFramework.initialize() skipped, already initialized.");return}mr=!0,ii("CubismFramework.initialize() is complete.")}static dispose(){if(!_e){ni("CubismFramework is not started.");return}if(!mr){ni("CubismFramework.dispose() skipped, not initialized.");return}ga.staticRelease(),mr=!1,ii("CubismFramework.dispose() is complete.")}static isStarted(){return _e}static isInitialized(){return mr}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return yr!=null?yr.loggingLevel:rr.LogLevel_Off}constructor(){}}var rr=(i=>(i[i.LogLevel_Verbose=0]="LogLevel_Verbose",i[i.LogLevel_Debug=1]="LogLevel_Debug",i[i.LogLevel_Info=2]="LogLevel_Info",i[i.LogLevel_Warning=3]="LogLevel_Warning",i[i.LogLevel_Error=4]="LogLevel_Error",i[i.LogLevel_Off=5]="LogLevel_Off",i))(rr||{});const Zi=()=>{};function nl(i,...t){Ji.print(rr.LogLevel_Debug,"[CSM][D]"+i+`
502
- `,t)}function ii(i,...t){Ji.print(rr.LogLevel_Info,"[CSM][I]"+i+`
503
- `,t)}function ni(i,...t){Ji.print(rr.LogLevel_Warning,"[CSM][W]"+i+`
504
- `,t)}function xr(i,...t){Ji.print(rr.LogLevel_Error,"[CSM][E]"+i+`
505
- `,t)}class Ji{static print(t,e,r){if(t<ri.getLoggingLevel())return;const n=ri.coreLogFunction;if(!n)return;const s=e.replace(/{(\d+)}/g,(a,o)=>r[o]);n(s)}static dumpBytes(t,e,r){for(let n=0;n<r;n++)n%16==0&&n>0?this.print(t,`
506
- `):n%8==0&&n>0&&this.print(t," "),this.print(t,"{0} ",[e[n]&255]);this.print(t,`
507
- `)}constructor(){}}class sl{constructor(){this._fadeInSeconds=-1,this._fadeOutSeconds=-1,this._weight=1,this._offsetSeconds=0,this._firedEventValues=[]}release(){this._weight=0}updateParameters(t,e,r){if(!e.isAvailable()||e.isFinished())return;if(!e.isStarted()){e.setIsStarted(!0),e.setStartTime(r-this._offsetSeconds),e.setFadeInStartTime(r);const o=this.getDuration();e.getEndTime()<0&&e.setEndTime(o<=0?-1:e.getStartTime()+o)}let n=this._weight;const s=this._fadeInSeconds==0?1:yt.getEasingSine((r-e.getFadeInStartTime())/this._fadeInSeconds),a=this._fadeOutSeconds==0||e.getEndTime()<0?1:yt.getEasingSine((e.getEndTime()-r)/this._fadeOutSeconds);n=n*s*a,e.setState(r,n),this.doUpdateParameters(t,r,n,e),e.getEndTime()>0&&e.getEndTime()<r&&e.setIsFinished(!0)}setFadeInTime(t){this._fadeInSeconds=t}setFadeOutTime(t){this._fadeOutSeconds=t}getFadeOutTime(){return this._fadeOutSeconds}getFadeInTime(){return this._fadeInSeconds}setWeight(t){this._weight=t}getWeight(){return this._weight}getDuration(){return-1}getLoopDuration(){return-1}setOffsetTime(t){this._offsetSeconds=t}getFiredEvent(t,e){return this._firedEventValues}setFinishedMotionHandler(t){this._onFinishedMotion=t}getFinishedMotionHandler(){return this._onFinishedMotion}}const al=1;class ya extends sl{constructor(){super(),this._parameters=[]}static create(t){const e=new ya,r=t.FadeInTime,n=t.FadeOutTime;e.setFadeInTime(r!==void 0?r:al),e.setFadeOutTime(n!==void 0?n:al);const s=t.Parameters||[];for(let a=0;a<s.length;++a){const o=s[a],h=o.Id,u=o.Value;let l;switch(o.Blend){case"Multiply":l=ir.ExpressionBlendType_Multiply;break;case"Overwrite":l=ir.ExpressionBlendType_Overwrite;break;case"Add":default:l=ir.ExpressionBlendType_Add;break}const c={parameterId:h,blendType:l,value:u};e._parameters.push(c)}return e}doUpdateParameters(t,e,r,n){for(let s=0;s<this._parameters.length;++s){const a=this._parameters[s];switch(a.blendType){case ir.ExpressionBlendType_Add:{t.addParameterValueById(a.parameterId,a.value,r);break}case ir.ExpressionBlendType_Multiply:{t.multiplyParameterValueById(a.parameterId,a.value,r);break}case ir.ExpressionBlendType_Overwrite:{t.setParameterValueById(a.parameterId,a.value,r);break}}}}}var ir=(i=>(i[i.ExpressionBlendType_Add=0]="ExpressionBlendType_Add",i[i.ExpressionBlendType_Multiply=1]="ExpressionBlendType_Multiply",i[i.ExpressionBlendType_Overwrite=2]="ExpressionBlendType_Overwrite",i))(ir||{});class Y_{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 r=e+t;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||r<this._endTimeSeconds)&&(this._endTimeSeconds=r)}isFinished(){return this._finished}isStarted(){return this._started}getStartTime(){return this._startTimeSeconds}getFadeInStartTime(){return this._fadeInStartTimeSeconds}getEndTime(){return this._endTimeSeconds}setStartTime(t){this._startTimeSeconds=t}setFadeInStartTime(t){this._fadeInStartTimeSeconds=t}setEndTime(t){this._endTimeSeconds=t}setIsFinished(t){this._finished=t}setIsStarted(t){this._started=t}isAvailable(){return this._available}setIsAvailable(t){this._available=t}setState(t,e){this._stateTimeSeconds=t,this._stateWeight=e}getStateTime(){return this._stateTimeSeconds}getStateWeight(){return this._stateWeight}getLastCheckEventSeconds(){return this._lastEventCheckSeconds}setLastCheckEventSeconds(t){this._lastEventCheckSeconds=t}isTriggeredFadeOut(){return this._isTriggeredFadeOut}getFadeOutSeconds(){return this._fadeOutSeconds}}class ol{constructor(){this._userTimeSeconds=0,this._eventCustomData=null,this._motions=[]}release(){for(let t=0;t<this._motions.length;++t)this._motions[t]&&this._motions[t].release();this._motions=void 0}startMotion(t,e,r){if(t==null)return q_;let n;for(let s=0;s<this._motions.length;++s)n=this._motions[s],n!=null&&n.setFadeOut(n._motion.getFadeOutTime());return n=new Y_,n._autoDelete=e,n._motion=t,this._motions.push(n),n._motionQueueEntryHandle}isFinished(){let t=0;for(;t<this._motions.length;){const e=this._motions[t];if(e==null){this._motions.splice(t,1);continue}if(e._motion==null){e.release(),this._motions.splice(t,1);continue}if(!e.isFinished())return!1;t++}return!0}isFinishedByHandle(t){for(let e=0;e<this._motions.length;e++){const r=this._motions[e];if(r!=null&&r._motionQueueEntryHandle==t&&!r.isFinished())return!1}return!0}stopAllMotions(){for(let t=0;t<this._motions.length;t++){const e=this._motions[t];e!=null&&e.release()}this._motions=[]}getCubismMotionQueueEntry(t){return this._motions.find(e=>e!=null&&e._motionQueueEntryHandle==t)}setEventCallback(t,e=null){this._eventCallBack=t,this._eventCustomData=e}doUpdateMotion(t,e){let r=!1,n=0;for(;n<this._motions.length;){const s=this._motions[n];if(s==null){this._motions.splice(n,1);continue}const a=s._motion;if(a==null){s.release(),this._motions.splice(n,1);continue}a.updateParameters(t,s,e),r=!0;const o=a.getFiredEvent(s.getLastCheckEventSeconds()-s.getStartTime(),e-s.getStartTime());for(let h=0;h<o.length;++h)this._eventCallBack(this,o[h],this._eventCustomData);s.setLastCheckEventSeconds(e),s.isFinished()?(s.release(),this._motions.splice(n,1)):(s.isTriggeredFadeOut()&&s.startFadeOut(s.getFadeOutSeconds(),e),n++)}return r}}const q_=-1;class $_ extends pa{constructor(t,e){var r;super(t,e),this.queueManager=new ol,this.definitions=(r=t.expressions)!=null?r:[],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 ya.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 hl{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(r=>r.Name==="EyeBlink"))==null?void 0:e.Ids}getLipSyncParameters(){var t,e;return(e=(t=this.groups)==null?void 0:t.find(r=>r.Name==="LipSync"))==null?void 0:e.Ids}}class br extends Yi{constructor(t){if(super(t),!br.isValidJSON(t))throw new TypeError("Invalid JSON.");Object.assign(this,new hl(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(r=>typeof r=="string")}replaceFiles(t){if(super.replaceFiles(t),this.motions)for(const[e,r]of Object.entries(this.motions))for(let n=0;n<r.length;n++)r[n].File=t(r[n].File,`motions.${e}[${n}].File`),r[n].Sound!==void 0&&(r[n].Sound=t(r[n].Sound,`motions.${e}[${n}].Sound`));if(this.expressions)for(let e=0;e<this.expressions.length;e++)this.expressions[e].File=t(this.expressions[e].File,`expressions[${e}].File`)}}Vu(br,[hl]);var nr=(i=>(i[i.CubismMotionCurveTarget_Model=0]="CubismMotionCurveTarget_Model",i[i.CubismMotionCurveTarget_Parameter=1]="CubismMotionCurveTarget_Parameter",i[i.CubismMotionCurveTarget_PartOpacity=2]="CubismMotionCurveTarget_PartOpacity",i))(nr||{}),ge=(i=>(i[i.CubismMotionSegmentType_Linear=0]="CubismMotionSegmentType_Linear",i[i.CubismMotionSegmentType_Bezier=1]="CubismMotionSegmentType_Bezier",i[i.CubismMotionSegmentType_Stepped=2]="CubismMotionSegmentType_Stepped",i[i.CubismMotionSegmentType_InverseStepped=3]="CubismMotionSegmentType_InverseStepped",i))(ge||{});class Be{constructor(t=0,e=0){this.time=t,this.value=e}}class K_{constructor(){this.basePointIndex=0,this.segmentType=0}}class Z_{constructor(){this.id="",this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}}class J_{constructor(){this.fireTime=0,this.value=""}}class Q_{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 ul{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 xa.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 xa=(i=>(i[i.EvaluationOptionFlag_AreBeziersRistricted=0]="EvaluationOptionFlag_AreBeziersRistricted",i))(xa||{});const tg="EyeBlink",eg="LipSync",rg="Model",ig="Parameter",ng="PartOpacity",sg=!1;function te(i,t,e){const r=new Be;return r.time=i.time+(t.time-i.time)*e,r.value=i.value+(t.value-i.value)*e,r}function ag(i,t){let e=(t-i[0].time)/(i[1].time-i[0].time);return e<0&&(e=0),i[0].value+(i[1].value-i[0].value)*e}function og(i,t){let e=(t-i[0].time)/(i[3].time-i[0].time);e<0&&(e=0);const r=te(i[0],i[1],e),n=te(i[1],i[2],e),s=te(i[2],i[3],e),a=te(r,n,e),o=te(n,s,e);return te(a,o,e).value}function hg(i,t){const e=t,r=i[0].time,n=i[3].time,s=i[1].time,a=i[2].time,o=n-3*a+3*s-r,h=3*a-6*s+3*r,u=3*s-3*r,l=r-e,c=yt.cardanoAlgorithmForBezier(o,h,u,l),f=te(i[0],i[1],c),d=te(i[1],i[2],c),v=te(i[2],i[3],c),_=te(f,d,c),p=te(d,v,c);return te(_,p,c).value}function ug(i,t){return i[0].value}function lg(i,t){return i[1].value}function ba(i,t,e){const r=i.curves[t];let n=-1;const s=r.baseSegmentIndex+r.segmentCount;let a=0;for(let h=r.baseSegmentIndex;h<s;++h)if(a=i.segments[h].basePointIndex+(i.segments[h].segmentType==ge.CubismMotionSegmentType_Bezier?3:1),i.points[a].time>e){n=h;break}if(n==-1)return i.points[a].value;const o=i.segments[n];return o.evaluate(i.points.slice(o.basePointIndex),e)}class Ta extends sl{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 r=new Ta;return r.parse(t),r._sourceFrameRate=r._motionData.fps,r._loopDurationSeconds=r._motionData.duration,r._onFinishedMotion=e,r}doUpdateParameters(t,e,r,n){this._modelCurveIdEyeBlink==null&&(this._modelCurveIdEyeBlink=tg),this._modelCurveIdLipSync==null&&(this._modelCurveIdLipSync=eg);let s=e-n.getStartTime();s<0&&(s=0);let a=Number.MAX_VALUE,o=Number.MAX_VALUE;const h=64;let u=0,l=0;this._eyeBlinkParameterIds.length>h&&nl("too many eye blink targets : {0}",this._eyeBlinkParameterIds.length),this._lipSyncParameterIds.length>h&&nl("too many lip sync targets : {0}",this._lipSyncParameterIds.length);const c=this._fadeInSeconds<=0?1:yt.getEasingSine((e-n.getFadeInStartTime())/this._fadeInSeconds),f=this._fadeOutSeconds<=0||n.getEndTime()<0?1:yt.getEasingSine((n.getEndTime()-e)/this._fadeOutSeconds);let d,v,_,p=s;if(this._isLoop)for(;p>this._motionData.duration;)p-=this._motionData.duration;const g=this._motionData.curves;for(v=0;v<this._motionData.curveCount&&g[v].type==nr.CubismMotionCurveTarget_Model;++v)d=ba(this._motionData,v,p),g[v].id==this._modelCurveIdEyeBlink?o=d:g[v].id==this._modelCurveIdLipSync&&(a=d);for(;v<this._motionData.curveCount&&g[v].type==nr.CubismMotionCurveTarget_Parameter;++v){if(_=t.getParameterIndex(g[v].id),_==-1)continue;const y=t.getParameterValueByIndex(_);if(d=ba(this._motionData,v,p),o!=Number.MAX_VALUE){for(let I=0;I<this._eyeBlinkParameterIds.length&&I<h;++I)if(this._eyeBlinkParameterIds[I]==g[v].id){d*=o,l|=1<<I;break}}if(a!=Number.MAX_VALUE){for(let I=0;I<this._lipSyncParameterIds.length&&I<h;++I)if(this._lipSyncParameterIds[I]==g[v].id){d+=a,u|=1<<I;break}}let T;if(g[v].fadeInTime<0&&g[v].fadeOutTime<0)T=y+(d-y)*r;else{let I,m;g[v].fadeInTime<0?I=c:I=g[v].fadeInTime==0?1:yt.getEasingSine((e-n.getFadeInStartTime())/g[v].fadeInTime),g[v].fadeOutTime<0?m=f:m=g[v].fadeOutTime==0||n.getEndTime()<0?1:yt.getEasingSine((n.getEndTime()-e)/g[v].fadeOutTime);const S=this._weight*I*m;T=y+(d-y)*S}t.setParameterValueByIndex(_,T,1)}{if(o!=Number.MAX_VALUE)for(let y=0;y<this._eyeBlinkParameterIds.length&&y<h;++y){const T=t.getParameterValueById(this._eyeBlinkParameterIds[y]);if(l>>y&1)continue;const I=T+(o-T)*r;t.setParameterValueById(this._eyeBlinkParameterIds[y],I)}if(a!=Number.MAX_VALUE)for(let y=0;y<this._lipSyncParameterIds.length&&y<h;++y){const T=t.getParameterValueById(this._lipSyncParameterIds[y]);if(u>>y&1)continue;const I=T+(a-T)*r;t.setParameterValueById(this._lipSyncParameterIds[y],I)}}for(;v<this._motionData.curveCount&&g[v].type==nr.CubismMotionCurveTarget_PartOpacity;++v)if(d=ba(this._motionData,v,p),Kr.setOpacityFromMotion)t.setPartOpacityById(g[v].id,d);else{if(_=t.getParameterIndex(g[v].id),_==-1)continue;t.setParameterValueByIndex(_,d)}s>=this._motionData.duration&&(this._isLoop?(n.setStartTime(e),this._isLoopFadeIn&&n.setFadeInStartTime(e)):(this._onFinishedMotion&&this._onFinishedMotion(this),n.setIsFinished(!0))),this._lastWeight=r}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 r=this._motionData.curves;for(let n=0;n<this._motionData.curveCount;++n)if(t==r[n].id){r[n].fadeInTime=e;return}}setParameterFadeOutTime(t,e){const r=this._motionData.curves;for(let n=0;n<this._motionData.curveCount;++n)if(t==r[n].id){r[n].fadeOutTime=e;return}}getParameterFadeInTime(t){const e=this._motionData.curves;for(let r=0;r<this._motionData.curveCount;++r)if(t==e[r].id)return e[r].fadeInTime;return-1}getParameterFadeOutTime(t){const e=this._motionData.curves;for(let r=0;r<this._motionData.curveCount;++r)if(t==e[r].id)return e[r].fadeOutTime;return-1}setEffectIds(t,e){this._eyeBlinkParameterIds=t,this._lipSyncParameterIds=e}release(){this._motionData=void 0}parse(t){this._motionData=new Q_;let e=new ul(t);this._motionData.duration=e.getMotionDuration(),this._motionData.loop=e.isMotionLoop(),this._motionData.curveCount=e.getMotionCurveCount(),this._motionData.fps=e.getMotionFps(),this._motionData.eventCount=e.getEventCount();const r=e.getEvaluationOptionFlag(xa.EvaluationOptionFlag_AreBeziersRistricted),n=e.getMotionFadeInTime(),s=e.getMotionFadeOutTime();n!==void 0?this._fadeInSeconds=n<0?1:n:this._fadeInSeconds=1,s!==void 0?this._fadeOutSeconds=s<0?1:s:this._fadeOutSeconds=1,this._motionData.curves=Array.from({length:this._motionData.curveCount}).map(()=>new Z_),this._motionData.segments=Array.from({length:e.getMotionTotalSegmentCount()}).map(()=>new K_),this._motionData.events=Array.from({length:this._motionData.eventCount}).map(()=>new J_),this._motionData.points=[];let a=0,o=0;for(let h=0;h<this._motionData.curveCount;++h){const u=this._motionData.curves[h];switch(e.getMotionCurveTarget(h)){case rg:u.type=nr.CubismMotionCurveTarget_Model;break;case ig:u.type=nr.CubismMotionCurveTarget_Parameter;break;case ng:u.type=nr.CubismMotionCurveTarget_PartOpacity;break;default:ni('Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!')}u.id=e.getMotionCurveId(h),u.baseSegmentIndex=o;const l=e.getMotionCurveFadeInTime(h),c=e.getMotionCurveFadeOutTime(h);u.fadeInTime=l!==void 0?l:-1,u.fadeOutTime=c!==void 0?c:-1;for(let f=0;f<e.getMotionCurveSegmentCount(h);){switch(f==0?(this._motionData.segments[o].basePointIndex=a,this._motionData.points[a]=new Be(e.getMotionCurveSegment(h,f),e.getMotionCurveSegment(h,f+1)),a+=1,f+=2):this._motionData.segments[o].basePointIndex=a-1,e.getMotionCurveSegment(h,f)){case ge.CubismMotionSegmentType_Linear:{this._motionData.segments[o].segmentType=ge.CubismMotionSegmentType_Linear,this._motionData.segments[o].evaluate=ag,this._motionData.points[a]=new Be(e.getMotionCurveSegment(h,f+1),e.getMotionCurveSegment(h,f+2)),a+=1,f+=3;break}case ge.CubismMotionSegmentType_Bezier:{this._motionData.segments[o].segmentType=ge.CubismMotionSegmentType_Bezier,r||sg?this._motionData.segments[o].evaluate=og:this._motionData.segments[o].evaluate=hg,this._motionData.points[a]=new Be(e.getMotionCurveSegment(h,f+1),e.getMotionCurveSegment(h,f+2)),this._motionData.points[a+1]=new Be(e.getMotionCurveSegment(h,f+3),e.getMotionCurveSegment(h,f+4)),this._motionData.points[a+2]=new Be(e.getMotionCurveSegment(h,f+5),e.getMotionCurveSegment(h,f+6)),a+=3,f+=7;break}case ge.CubismMotionSegmentType_Stepped:{this._motionData.segments[o].segmentType=ge.CubismMotionSegmentType_Stepped,this._motionData.segments[o].evaluate=ug,this._motionData.points[a]=new Be(e.getMotionCurveSegment(h,f+1),e.getMotionCurveSegment(h,f+2)),a+=1,f+=3;break}case ge.CubismMotionSegmentType_InverseStepped:{this._motionData.segments[o].segmentType=ge.CubismMotionSegmentType_InverseStepped,this._motionData.segments[o].evaluate=lg,this._motionData.points[a]=new Be(e.getMotionCurveSegment(h,f+1),e.getMotionCurveSegment(h,f+2)),a+=1,f+=3;break}}++u.segmentCount,++o}this._motionData.curves.push(u)}for(let h=0;h<e.getEventCount();++h)this._motionData.events[h].fireTime=e.getEventTime(h),this._motionData.events[h].value=e.getEventValue(h);e.release()}getFiredEvent(t,e){this._firedEventValues.length=0;for(let r=0;r<this._motionData.eventCount;++r)this._motionData.events[r].fireTime>t&&this._motionData.events[r].fireTime<=e&&this._firedEventValues.push(this._motionData.events[r].value);return this._firedEventValues}}class fg extends gr{constructor(t,e){var r;super(t,e),this.groups={idle:"Idle"},this.motionDataType="json",this.queueManager=new ol,this.definitions=(r=t.motions)!=null?r:{},this.eyeBlinkIds=t.getEyeBlinkParameters()||[],this.lipSyncIds=t.getLipSyncParameters()||[],this.init(e)}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new $_(this.settings,t)),this.queueManager.setEventCallback((e,r,n)=>{this.emit("motion:"+r)})}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,r){const n=Ta.create(t),s=new ul(t),a=(e===this.groups.idle?Ft.idleMotionFadingDuration:Ft.motionFadingDuration)/1e3;return s.getMotionFadeInTime()===void 0&&n.setFadeInTime(r.FadeInTime>0?r.FadeInTime:a),s.getMotionFadeOutTime()===void 0&&n.setFadeOutTime(r.FadeOutTime>0?r.FadeOutTime:a),n.setEffectIds(this.eyeBlinkIds,this.lipSyncIds),n}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 cg="ParamAngleX",dg="ParamAngleY",pg="ParamAngleZ",vg="ParamEyeBallX",_g="ParamEyeBallY",gg="ParamBodyAngleX",mg="ParamBreath";class Ea{constructor(){this._breathParameters=[],this._currentTime=0}static create(){return new Ea}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,e){this._currentTime+=e;const r=this._currentTime*2*3.14159;for(let n=0;n<this._breathParameters.length;++n){const s=this._breathParameters[n];t.addParameterValueById(s.parameterId,s.offset+s.peak*Math.sin(r/s.cycle),s.weight)}}}class si{constructor(t,e,r,n,s){this.parameterId=t??void 0,this.offset=e??0,this.peak=r??0,this.cycle=n??0,this.weight=s??0}}const Sa=class{static create(i){return new Sa(i)}setBlinkingInterval(i){this._blinkingIntervalSeconds=i}setBlinkingSetting(i,t,e){this._closingSeconds=i,this._closedSeconds=t,this._openingSeconds=e}setParameterIds(i){this._parameterIds=i}getParameterIds(){return this._parameterIds}updateParameters(i,t){this._userTimeSeconds+=t;let e,r=0;switch(this._blinkingState){case ee.EyeState_Closing:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closingSeconds,r>=1&&(r=1,this._blinkingState=ee.EyeState_Closed,this._stateStartTimeSeconds=this._userTimeSeconds),e=1-r;break;case ee.EyeState_Closed:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,r>=1&&(this._blinkingState=ee.EyeState_Opening,this._stateStartTimeSeconds=this._userTimeSeconds),e=0;break;case ee.EyeState_Opening:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,r>=1&&(r=1,this._blinkingState=ee.EyeState_Interval,this._nextBlinkingTime=this.determinNextBlinkingTiming()),e=r;break;case ee.EyeState_Interval:this._nextBlinkingTime<this._userTimeSeconds&&(this._blinkingState=ee.EyeState_Closing,this._stateStartTimeSeconds=this._userTimeSeconds),e=1;break;case ee.EyeState_First:default:this._blinkingState=ee.EyeState_Interval,this._nextBlinkingTime=this.determinNextBlinkingTiming(),e=1;break}Sa.CloseIfZero||(e=-e);for(let n=0;n<this._parameterIds.length;++n)i.setParameterValueById(this._parameterIds[n],e)}constructor(i){var t,e;this._blinkingState=ee.EyeState_First,this._nextBlinkingTime=0,this._stateStartTimeSeconds=0,this._blinkingIntervalSeconds=4,this._closingSeconds=.1,this._closedSeconds=.05,this._openingSeconds=.15,this._userTimeSeconds=0,this._parameterIds=[],i!=null&&(this._parameterIds=(e=(t=i.getEyeBlinkParameters())==null?void 0:t.slice())!=null?e:this._parameterIds)}determinNextBlinkingTiming(){const i=Math.random();return this._userTimeSeconds+i*(2*this._blinkingIntervalSeconds-1)}};let ll=Sa;ll.CloseIfZero=!0;var ee=(i=>(i[i.EyeState_First=0]="EyeState_First",i[i.EyeState_Interval=1]="EyeState_Interval",i[i.EyeState_Closing=2]="EyeState_Closing",i[i.EyeState_Closed=3]="EyeState_Closed",i[i.EyeState_Opening=4]="EyeState_Opening",i))(ee||{});class Pa{constructor(t=0,e=0,r=0,n=0){this.x=t,this.y=e,this.width=r,this.height=n}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 wa=4,yg=10;let sr,ai,Ca;class Ia{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,Ca),this._maskTexture=new xg(this._currentFrameNo,t)}return t}setGL(t){this.gl=t}calcClippedDrawTotalBounds(t,e){let r=Number.MAX_VALUE,n=Number.MAX_VALUE,s=Number.MIN_VALUE,a=Number.MIN_VALUE;const o=e._clippedDrawableIndexList.length;for(let h=0;h<o;h++){const u=e._clippedDrawableIndexList[h],l=t.getDrawableVertexCount(u),c=t.getDrawableVertices(u);let f=Number.MAX_VALUE,d=Number.MAX_VALUE,v=Number.MIN_VALUE,_=Number.MIN_VALUE;const p=l*ma.vertexStep;for(let g=ma.vertexOffset;g<p;g+=ma.vertexStep){const y=c[g],T=c[g+1];y<f&&(f=y),y>v&&(v=y),T<d&&(d=T),T>_&&(_=T)}if(f!=Number.MAX_VALUE)if(f<r&&(r=f),d<n&&(n=d),v>s&&(s=v),_>a&&(a=_),r==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 g=s-r,y=a-n;e._allClippedDrawRect.x=r,e._allClippedDrawRect.y=n,e._allClippedDrawRect.width=g,e._allClippedDrawRect.height=y}}}constructor(){this._maskRenderTexture=null,this._colorBuffer=null,this._currentFrameNo=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=[],this._clippingContextListForDraw=[],this._channelColors=[],this._tmpBoundsOnModel=new Pa,this._tmpMatrix=new Qt,this._tmpMatrixForMask=new Qt,this._tmpMatrixForDraw=new Qt;let t=new ei;t.R=1,t.G=0,t.B=0,t.A=0,this._channelColors.push(t),t=new ei,t.R=0,t.G=1,t.B=0,t.A=0,this._channelColors.push(t),t=new ei,t.R=0,t.G=0,t.B=1,t.A=0,this._channelColors.push(t),t=new ei,t.R=0,t.G=0,t.B=0,t.A=1,this._channelColors.push(t)}release(){var t,e,r;const n=this;for(let s=0;s<this._clippingContextListForMask.length;s++)this._clippingContextListForMask[s]&&((t=this._clippingContextListForMask[s])==null||t.release());n._clippingContextListForMask=void 0,n._clippingContextListForDraw=void 0,this._maskTexture&&((e=this.gl)==null||e.deleteFramebuffer(this._maskTexture.texture),n._maskTexture=void 0),n._channelColors=void 0,(r=this.gl)==null||r.deleteTexture(this._colorBuffer),this._colorBuffer=null}initialize(t,e,r,n){for(let s=0;s<e;s++){if(n[s]<=0){this._clippingContextListForDraw.push(null);continue}let a=this.findSameClip(r[s],n[s]);a==null&&(a=new bg(this,r[s],n[s]),this._clippingContextListForMask.push(a)),a.addClippedDrawable(s),this._clippingContextListForDraw.push(a)}}setupClippingContext(t,e){this._currentFrameNo++;let r=0;for(let n=0;n<this._clippingContextListForMask.length;n++){const s=this._clippingContextListForMask[n];this.calcClippedDrawTotalBounds(t,s),s._isUsing&&r++}if(r>0){this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),this._maskRenderTexture=this.getMaskRenderTexture(),e.getMvpMatrix(),e.preDraw(),this.setupLayoutBounds(r),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._maskRenderTexture),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT);for(let n=0;n<this._clippingContextListForMask.length;n++){const s=this._clippingContextListForMask[n],a=s._allClippedDrawRect,o=s._layoutBounds,h=.05;this._tmpBoundsOnModel.setRect(a),this._tmpBoundsOnModel.expand(a.width*h,a.height*h);const u=o.width/this._tmpBoundsOnModel.width,l=o.height/this._tmpBoundsOnModel.height;this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(o.x,o.y),this._tmpMatrix.scaleRelative(u,l),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(o.x,o.y),this._tmpMatrix.scaleRelative(u,l),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray()),s._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),s._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray());const c=s._clippingIdCount;for(let f=0;f<c;f++){const d=s._clippingIdList[f];t.getDrawableDynamicFlagVertexPositionsDidChange(d)&&(e.setIsCulling(t.getDrawableCulling(d)!=!1),e.setClippingContextBufferForMask(s),e.drawMesh(t.getDrawableTextureIndices(d),t.getDrawableVertexIndexCount(d),t.getDrawableVertexCount(d),t.getDrawableVertexIndices(d),t.getDrawableVertices(d),t.getDrawableVertexUvs(d),t.getDrawableOpacity(d),Le.CubismBlendMode_Normal,!1))}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,Ca),e.setClippingContextBufferForMask(null),this.gl.viewport(ai[0],ai[1],ai[2],ai[3])}}findSameClip(t,e){for(let r=0;r<this._clippingContextListForMask.length;r++){const n=this._clippingContextListForMask[r],s=n._clippingIdCount;if(s!=e)continue;let a=0;for(let o=0;o<s;o++){const h=n._clippingIdList[o];for(let u=0;u<s;u++)if(t[u]==h){a++;break}}if(a==s)return n}return null}setupLayoutBounds(t){let e=t/wa,r=t%wa;e=~~e,r=~~r;let n=0;for(let s=0;s<wa;s++){const a=e+(s<r?1:0);if(a!=0)if(a==1){const o=this._clippingContextListForMask[n++];o._layoutChannelNo=s,o._layoutBounds.x=0,o._layoutBounds.y=0,o._layoutBounds.width=1,o._layoutBounds.height=1}else if(a==2)for(let o=0;o<a;o++){let h=o%2;h=~~h;const u=this._clippingContextListForMask[n++];u._layoutChannelNo=s,u._layoutBounds.x=h*.5,u._layoutBounds.y=0,u._layoutBounds.width=.5,u._layoutBounds.height=1}else if(a<=4)for(let o=0;o<a;o++){let h=o%2,u=o/2;h=~~h,u=~~u;const l=this._clippingContextListForMask[n++];l._layoutChannelNo=s,l._layoutBounds.x=h*.5,l._layoutBounds.y=u*.5,l._layoutBounds.width=.5,l._layoutBounds.height=.5}else if(a<=9)for(let o=0;o<a;o++){let h=o%3,u=o/3;h=~~h,u=~~u;const l=this._clippingContextListForMask[n++];l._layoutChannelNo=s,l._layoutBounds.x=h/3,l._layoutBounds.y=u/3,l._layoutBounds.width=1/3,l._layoutBounds.height=1/3}else if(Kr.supportMoreMaskDivisions&&a<=16)for(let o=0;o<a;o++){let h=o%4,u=o/4;h=~~h,u=~~u;const l=this._clippingContextListForMask[n++];l._layoutChannelNo=s,l._layoutBounds.x=h/4,l._layoutBounds.y=u/4,l._layoutBounds.width=1/4,l._layoutBounds.height=1/4}else xr("not supported mask count : {0}",a)}}getColorBuffer(){return this._colorBuffer}getClippingContextListForDraw(){return this._clippingContextListForDraw}setClippingMaskBufferSize(t){this._clippingMaskBufferSize=t}getClippingMaskBufferSize(){return this._clippingMaskBufferSize}}class xg{constructor(t,e){this.frameNo=t,this.texture=e}}class bg{constructor(t,e,r){this._isUsing=!1,this._owner=t,this._clippingIdList=e,this._clippingIdCount=r,this._allClippedDrawRect=new Pa,this._layoutBounds=new Pa,this._clippedDrawableIndexList=[],this._matrixForMask=new Qt,this._matrixForDraw=new Qt}release(){const t=this;t._layoutBounds=void 0,t._allClippedDrawRect=void 0,t._clippedDrawableIndexList=void 0}addClippedDrawable(t){this._clippedDrawableIndexList.push(t)}getClippingManager(){return this._owner}setGl(t){this._owner.setGL(t)}}class Tr{static getInstance(){return sr==null&&(sr=new Tr),sr}static deleteInstance(){sr&&(sr.release(),sr=void 0)}constructor(){this._shaderSets=[]}release(){this.releaseShaderProgram()}setupShaderProgram(t,e,r,n,s,a,o,h,u,l,c,f,d){c||xr("NoPremultipliedAlpha is not allowed"),this._shaderSets.length==0&&this.generateShaders();let v,_,p,g;const y=t.getClippingContextBufferForMask();if(y!=null){const T=this._shaderSets[oi.ShaderNames_SetupMask];this.gl.useProgram(T.shaderProgram),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(T.samplerTexture0Location,0),o.vertex==null&&(o.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,o.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,n,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(T.attributePositionLocation),this.gl.vertexAttribPointer(T.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),o.uv==null&&(o.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,o.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,a,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(T.attributeTexCoordLocation),this.gl.vertexAttribPointer(T.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0);const I=y._layoutChannelNo,m=y.getClippingManager().getChannelFlagAsColor(I);this.gl.uniform4f(T.uniformChannelFlagLocation,m.R,m.G,m.B,m.A),this.gl.uniformMatrix4fv(T.uniformClipMatrixLocation,!1,y._matrixForMask.getArray());const S=y._layoutBounds;this.gl.uniform4f(T.uniformBaseColorLocation,S.x*2-1,S.y*2-1,S.getRight()*2-1,S.getBottom()*2-1),v=this.gl.ZERO,_=this.gl.ONE_MINUS_SRC_COLOR,p=this.gl.ZERO,g=this.gl.ONE_MINUS_SRC_ALPHA}else{const T=t.getClippingContextBufferForDraw(),m=T!=null?d?2:1:0;let S;switch(u){case Le.CubismBlendMode_Normal:default:S=this._shaderSets[oi.ShaderNames_NormalPremultipliedAlpha+m],v=this.gl.ONE,_=this.gl.ONE_MINUS_SRC_ALPHA,p=this.gl.ONE,g=this.gl.ONE_MINUS_SRC_ALPHA;break;case Le.CubismBlendMode_Additive:S=this._shaderSets[oi.ShaderNames_AddPremultipliedAlpha+m],v=this.gl.ONE,_=this.gl.ONE,p=this.gl.ZERO,g=this.gl.ONE;break;case Le.CubismBlendMode_Multiplicative:S=this._shaderSets[oi.ShaderNames_MultPremultipliedAlpha+m],v=this.gl.DST_COLOR,_=this.gl.ONE_MINUS_SRC_ALPHA,p=this.gl.ZERO,g=this.gl.ONE;break}if(this.gl.useProgram(S.shaderProgram),o.vertex==null&&(o.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,o.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,n,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(S.attributePositionLocation),this.gl.vertexAttribPointer(S.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),o.uv==null&&(o.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,o.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,a,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(S.attributeTexCoordLocation),this.gl.vertexAttribPointer(S.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),T!=null){this.gl.activeTexture(this.gl.TEXTURE1);const x=T.getClippingManager().getColorBuffer();this.gl.bindTexture(this.gl.TEXTURE_2D,x),this.gl.uniform1i(S.samplerTexture1Location,1),this.gl.uniformMatrix4fv(S.uniformClipMatrixLocation,!1,T._matrixForDraw.getArray());const N=T._layoutChannelNo,D=T.getClippingManager().getChannelFlagAsColor(N);this.gl.uniform4f(S.uniformChannelFlagLocation,D.R,D.G,D.B,D.A)}this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(S.samplerTexture0Location,0),this.gl.uniformMatrix4fv(S.uniformMatrixLocation,!1,f.getArray()),this.gl.uniform4f(S.uniformBaseColorLocation,l.R,l.G,l.B,l.A)}o.index==null&&(o.index=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,o.index),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,s,this.gl.DYNAMIC_DRAW),this.gl.blendFuncSeparate(v,_,p,g)}releaseShaderProgram(){for(let t=0;t<this._shaderSets.length;t++)this.gl.deleteProgram(this._shaderSets[t].shaderProgram),this._shaderSets[t].shaderProgram=0;this._shaderSets=[]}generateShaders(){for(let t=0;t<yg;t++)this._shaderSets.push({});this._shaderSets[0].shaderProgram=this.loadShaderProgram(Tg,Eg),this._shaderSets[1].shaderProgram=this.loadShaderProgram(Sg,Pg),this._shaderSets[2].shaderProgram=this.loadShaderProgram(fl,wg),this._shaderSets[3].shaderProgram=this.loadShaderProgram(fl,Cg),this._shaderSets[4].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[5].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[6].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[7].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[8].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[9].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[0].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_position"),this._shaderSets[0].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_texCoord"),this._shaderSets[0].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"s_texture0"),this._shaderSets[0].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_clipMatrix"),this._shaderSets[0].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_channelFlag"),this._shaderSets[0].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_baseColor"),this._shaderSets[1].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_position"),this._shaderSets[1].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_texCoord"),this._shaderSets[1].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"s_texture0"),this._shaderSets[1].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_matrix"),this._shaderSets[1].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_baseColor"),this._shaderSets[2].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_position"),this._shaderSets[2].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_texCoord"),this._shaderSets[2].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture0"),this._shaderSets[2].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture1"),this._shaderSets[2].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_matrix"),this._shaderSets[2].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_clipMatrix"),this._shaderSets[2].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_channelFlag"),this._shaderSets[2].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_baseColor"),this._shaderSets[3].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_position"),this._shaderSets[3].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_texCoord"),this._shaderSets[3].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture0"),this._shaderSets[3].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture1"),this._shaderSets[3].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_matrix"),this._shaderSets[3].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_clipMatrix"),this._shaderSets[3].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_channelFlag"),this._shaderSets[3].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_baseColor"),this._shaderSets[4].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_position"),this._shaderSets[4].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_texCoord"),this._shaderSets[4].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"s_texture0"),this._shaderSets[4].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_matrix"),this._shaderSets[4].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_baseColor"),this._shaderSets[5].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_position"),this._shaderSets[5].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_texCoord"),this._shaderSets[5].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture0"),this._shaderSets[5].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture1"),this._shaderSets[5].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_matrix"),this._shaderSets[5].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_clipMatrix"),this._shaderSets[5].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_channelFlag"),this._shaderSets[5].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_baseColor"),this._shaderSets[6].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_position"),this._shaderSets[6].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_texCoord"),this._shaderSets[6].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture0"),this._shaderSets[6].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture1"),this._shaderSets[6].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_matrix"),this._shaderSets[6].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_clipMatrix"),this._shaderSets[6].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_channelFlag"),this._shaderSets[6].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_baseColor"),this._shaderSets[7].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_position"),this._shaderSets[7].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_texCoord"),this._shaderSets[7].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"s_texture0"),this._shaderSets[7].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_matrix"),this._shaderSets[7].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_baseColor"),this._shaderSets[8].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_position"),this._shaderSets[8].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_texCoord"),this._shaderSets[8].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture0"),this._shaderSets[8].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture1"),this._shaderSets[8].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_matrix"),this._shaderSets[8].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_clipMatrix"),this._shaderSets[8].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_channelFlag"),this._shaderSets[8].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_baseColor"),this._shaderSets[9].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_position"),this._shaderSets[9].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_texCoord"),this._shaderSets[9].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture0"),this._shaderSets[9].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture1"),this._shaderSets[9].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_matrix"),this._shaderSets[9].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_clipMatrix"),this._shaderSets[9].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_channelFlag"),this._shaderSets[9].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_baseColor")}loadShaderProgram(t,e){let r=this.gl.createProgram(),n=this.compileShaderSource(this.gl.VERTEX_SHADER,t);if(!n)return xr("Vertex shader compile error!"),0;let s=this.compileShaderSource(this.gl.FRAGMENT_SHADER,e);return s?(this.gl.attachShader(r,n),this.gl.attachShader(r,s),this.gl.linkProgram(r),this.gl.getProgramParameter(r,this.gl.LINK_STATUS)?(this.gl.deleteShader(n),this.gl.deleteShader(s),r):(xr("Failed to link program: {0}",r),this.gl.deleteShader(n),this.gl.deleteShader(s),r&&this.gl.deleteProgram(r),0)):(xr("Vertex shader compile error!"),0)}compileShaderSource(t,e){const r=e,n=this.gl.createShader(t);if(this.gl.shaderSource(n,r),this.gl.compileShader(n),!n){const a=this.gl.getShaderInfoLog(n);xr("Shader compile log: {0} ",a)}return this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(this.gl.deleteShader(n),null)}setGl(t){this.gl=t}}var oi=(i=>(i[i.ShaderNames_SetupMask=0]="ShaderNames_SetupMask",i[i.ShaderNames_NormalPremultipliedAlpha=1]="ShaderNames_NormalPremultipliedAlpha",i[i.ShaderNames_NormalMaskedPremultipliedAlpha=2]="ShaderNames_NormalMaskedPremultipliedAlpha",i[i.ShaderNames_NomralMaskedInvertedPremultipliedAlpha=3]="ShaderNames_NomralMaskedInvertedPremultipliedAlpha",i[i.ShaderNames_AddPremultipliedAlpha=4]="ShaderNames_AddPremultipliedAlpha",i[i.ShaderNames_AddMaskedPremultipliedAlpha=5]="ShaderNames_AddMaskedPremultipliedAlpha",i[i.ShaderNames_AddMaskedPremultipliedAlphaInverted=6]="ShaderNames_AddMaskedPremultipliedAlphaInverted",i[i.ShaderNames_MultPremultipliedAlpha=7]="ShaderNames_MultPremultipliedAlpha",i[i.ShaderNames_MultMaskedPremultipliedAlpha=8]="ShaderNames_MultMaskedPremultipliedAlpha",i[i.ShaderNames_MultMaskedPremultipliedAlphaInverted=9]="ShaderNames_MultMaskedPremultipliedAlphaInverted",i))(oi||{});const Tg="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;}",Eg="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;}",Sg="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;}",fl="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;}",Pg="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;}",wg="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;}",Cg="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 cl extends ga{constructor(){super(),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._clippingManager=new Ia,this.firstDraw=!0,this._textures={},this._sortedDrawableIndexList=[],this._bufferData={vertex:null,uv:null,index:null}}initialize(t){t.isUsingMasking()&&(this._clippingManager=new Ia,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 Ia,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,r;const n=this;this._clippingManager.release(),n._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,(r=this.gl)==null||r.deleteBuffer(this._bufferData.index),this._bufferData.index=null,n._bufferData=void 0,n._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 r=0;r<t;++r){const n=e[r];this._sortedDrawableIndexList[n]=r}for(let r=0;r<t;++r){const n=this._sortedDrawableIndexList[r];this.getModel().getDrawableDynamicFlagIsVisible(n)&&(this.setClippingContextBufferForDraw(this._clippingManager!=null?this._clippingManager.getClippingContextListForDraw()[n]:null),this.setIsCulling(this.getModel().getDrawableCulling(n)),this.drawMesh(this.getModel().getDrawableTextureIndices(n),this.getModel().getDrawableVertexIndexCount(n),this.getModel().getDrawableVertexCount(n),this.getModel().getDrawableVertexIndices(n),this.getModel().getDrawableVertices(n),this.getModel().getDrawableVertexUvs(n),this.getModel().getDrawableOpacity(n),this.getModel().getDrawableBlendMode(n),this.getModel().getDrawableInvertedMaskBit(n)))}}drawMesh(t,e,r,n,s,a,o,h,u){this.isCulling()?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this.gl.frontFace(this.gl.CCW);const l=this.getModelColor();this.getClippingContextBufferForMask()==null&&(l.A*=o,this.isPremultipliedAlpha()&&(l.R*=l.A,l.G*=l.A,l.B*=l.A));let c=null;this._textures[t]!=null&&(c=this._textures[t]),Tr.getInstance().setupShaderProgram(this,c,r,s,n,a,this._bufferData,o,h,l,this.isPremultipliedAlpha(),this.getMvpMatrix(),u),this.gl.drawElements(this.gl.TRIANGLES,e,this.gl.UNSIGNED_SHORT,0),this.gl.useProgram(null),this.setClippingContextBufferForDraw(null),this.setClippingContextBufferForMask(null)}static doStaticRelease(){Tr.deleteInstance()}setRenderState(t,e){Ca=t,ai=e}preDraw(){this.firstDraw&&(this.firstDraw=!1,this._anisortopy=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")),this.gl.disable(this.gl.SCISSOR_TEST),this.gl.disable(this.gl.STENCIL_TEST),this.gl.disable(this.gl.DEPTH_TEST),this.gl.frontFace(this.gl.CW),this.gl.enable(this.gl.BLEND),this.gl.colorMask(!0,!0,!0,!0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null)}setClippingContextBufferForMask(t){this._clippingContextBufferForMask=t}getClippingContextBufferForMask(){return this._clippingContextBufferForMask}setClippingContextBufferForDraw(t){this._clippingContextBufferForDraw=t}getClippingContextBufferForDraw(){return this._clippingContextBufferForDraw}startUp(t){this.gl=t,this._clippingManager.setGL(t),Tr.getInstance().setGl(t)}}ga.staticRelease=()=>{cl.doStaticRelease()};const dl=new Qt;class Ig extends zu{constructor(t,e,r){super(),this.lipSync=!0,this.breath=Ea.create(),this.renderer=new cl,this.idParamAngleX=cg,this.idParamAngleY=dg,this.idParamAngleZ=pg,this.idParamEyeBallX=vg,this.idParamEyeBallY=_g,this.idParamBodyAngleX=gg,this.idParamBreath=mg,this.pixelsPerUnit=1,this.centeringTransform=new bt,this.coreModel=t,this.settings=e,this.motionManager=new fg(e,r),this.init()}init(){var t;super.init(),((t=this.settings.getEyeBlinkParameters())==null?void 0:t.length)>0&&(this.eyeBlink=ll.create(this.settings)),this.breath.setParameters([new si(this.idParamAngleX,0,15,6.5345,.5),new si(this.idParamAngleY,0,8,3.5345,.5),new si(this.idParamAngleZ,0,10,5.5345,.5),new si(this.idParamBodyAngleX,0,4,15.5345,.5),new si(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 r=e.charAt(0).toLowerCase()+e.slice(1);t[r]=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,Tr.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(r=>({id:r.Id,name:r.Name,index:this.coreModel.getDrawableIndex(r.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 r=0;r<e.length;r+=2)e[r]=e[r]*this.pixelsPerUnit+this.originalWidth/2,e[r+1]=-e[r+1]*this.pixelsPerUnit+this.originalHeight/2;return e}updateTransform(t){this.drawingMatrix.copyFrom(this.centeringTransform).prepend(this.localTransform).prepend(t)}update(t,e){var r,n,s,a;super.update(t,e),t/=1e3,e/=1e3;const o=this.coreModel;this.emit("beforeMotionUpdate");const h=this.motionManager.update(this.coreModel,e);this.emit("afterMotionUpdate"),o.saveParameters(),(r=this.motionManager.expressionManager)==null||r.update(o,e),h||(n=this.eyeBlink)==null||n.updateParameters(o,t),this.updateFocus(),this.updateNaturalMovements(t*1e3,e*1e3),(s=this.physics)==null||s.evaluate(o,t),(a=this.pose)==null||a.updateParameters(o,t),this.emit("beforeModelUpdate"),o.update(),o.loadParameters()}updateFocus(){this.coreModel.addParameterValueById(this.idParamEyeBallX,this.focusController.x),this.coreModel.addParameterValueById(this.idParamEyeBallY,this.focusController.y),this.coreModel.addParameterValueById(this.idParamAngleX,this.focusController.x*30),this.coreModel.addParameterValueById(this.idParamAngleY,this.focusController.y*30),this.coreModel.addParameterValueById(this.idParamAngleZ,this.focusController.x*this.focusController.y*-30),this.coreModel.addParameterValueById(this.idParamBodyAngleX,this.focusController.x*10)}updateNaturalMovements(t,e){var r;(r=this.breath)==null||r.updateParameters(this.coreModel,t/1e3)}draw(t){const e=this.drawingMatrix,r=dl.getArray();r[0]=e.a,r[1]=e.b,r[4]=-e.c,r[5]=-e.d,r[12]=e.tx,r[13]=e.ty,this.renderer.setMvpMatrix(dl),this.renderer.setRenderState(t.getParameter(t.FRAMEBUFFER_BINDING),this.viewport),this.renderer.drawModel()}destroy(){super.destroy(),this.renderer.release(),this.coreModel.release(),this.renderer=void 0,this.coreModel=void 0}}let Qi,pl=20;function Ag(){return ri.isStarted()?Promise.resolve():(Qi??(Qi=new Promise((i,t)=>{function e(){try{Mg(),i()}catch(r){if(pl--,pl<0){const n=new Error("Failed to start up Cubism 4 framework.");n.cause=r,t(n);return}_t.log("Cubism4","Startup failed, retrying 10ms later..."),setTimeout(e,10)}}e()})),Qi)}function Mg(i){i=Object.assign({logFunction:console.log,loggingLevel:rr.LogLevel_Verbose},i),ri.startUp(i),ri.initialize()}const Rg=.001,vl=.5;class Aa{static create(t){const e=new Aa;typeof t.FadeInTime=="number"&&(e._fadeTimeSeconds=t.FadeInTime,e._fadeTimeSeconds<=0&&(e._fadeTimeSeconds=vl));const r=t.Groups,n=r.length;for(let s=0;s<n;++s){const a=r[s],o=a.length;let h=0;for(let u=0;u<o;++u){const l=a[u],c=new tn;c.partId=l.Id;const f=l.Link;if(f){const d=f.length;for(let v=0;v<d;++v){const _=new tn;_.partId=f[v],c.link.push(_)}}e._partGroups.push(c),++h}e._partGroupCounts.push(h)}return e}updateParameters(t,e){t!=this._lastModel&&this.reset(t),this._lastModel=t,e<0&&(e=0);let r=0;for(let n=0;n<this._partGroupCounts.length;n++){const s=this._partGroupCounts[n];this.doFade(t,e,r,s),r+=s}this.copyPartOpacities(t)}reset(t){let e=0;for(let r=0;r<this._partGroupCounts.length;++r){const n=this._partGroupCounts[r];for(let s=e;s<e+n;++s){this._partGroups[s].initialize(t);const a=this._partGroups[s].partIndex,o=this._partGroups[s].parameterIndex;if(!(a<0)){t.setPartOpacityByIndex(a,s==e?1:0),t.setParameterValueByIndex(o,s==e?1:0);for(let h=0;h<this._partGroups[s].link.length;++h)this._partGroups[s].link[h].initialize(t)}}e+=n}}copyPartOpacities(t){for(let e=0;e<this._partGroups.length;++e){const r=this._partGroups[e];if(r.link.length==0)continue;const n=this._partGroups[e].partIndex,s=t.getPartOpacityByIndex(n);for(let a=0;a<r.link.length;++a){const h=r.link[a].partIndex;h<0||t.setPartOpacityByIndex(h,s)}}}doFade(t,e,r,n){let s=-1,a=1;const o=.5,h=.15;for(let u=r;u<r+n;++u){const l=this._partGroups[u].partIndex,c=this._partGroups[u].parameterIndex;if(t.getParameterValueByIndex(c)>Rg){if(s>=0)break;s=u,a=t.getPartOpacityByIndex(l),a+=e/this._fadeTimeSeconds,a>1&&(a=1)}}s<0&&(s=0,a=1);for(let u=r;u<r+n;++u){const l=this._partGroups[u].partIndex;if(s==u)t.setPartOpacityByIndex(l,a);else{let c=t.getPartOpacityByIndex(l),f;a<o?f=a*(o-1)/o+1:f=(1-a)*o/(1-o),(1-f)*(1-a)>h&&(f=1-h/(1-a)),c>f&&(c=f),t.setPartOpacityByIndex(l,c)}}}constructor(){this._fadeTimeSeconds=vl,this._lastModel=void 0,this._partGroups=[],this._partGroupCounts=[]}}class tn{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 tn;return t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=this.link.map(e=>e.clone()),t}}class Og{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 r=0;r<t;++r)r<e?this._savedParameters[r]=this._parameterValues[r]:this._savedParameters.push(this._parameterValues[r])}getModel(){return this._model}getPartIndex(t){let e;const r=this._model.parts.count;for(e=0;e<r;++e)if(t==this._partIds[e])return e;return t in this._notExistPartId?this._notExistPartId[t]:(e=r+this._notExistPartId.length,this._notExistPartId[t]=e,this._notExistPartOpacities[e]=0,e)}getPartCount(){return this._model.parts.count}setPartOpacityByIndex(t,e){if(t in this._notExistPartOpacities){this._notExistPartOpacities[t]=e;return}Zi(0<=t&&t<this.getPartCount()),this._partOpacities[t]=e}setPartOpacityById(t,e){const r=this.getPartIndex(t);r<0||this.setPartOpacityByIndex(r,e)}getPartOpacityByIndex(t){return t in this._notExistPartOpacities?this._notExistPartOpacities[t]:(Zi(0<=t&&t<this.getPartCount()),this._partOpacities[t])}getPartOpacityById(t){const e=this.getPartIndex(t);return e<0?0:this.getPartOpacityByIndex(e)}getParameterIndex(t){let e;const r=this._model.parameters.count;for(e=0;e<r;++e)if(t==this._parameterIds[e])return e;return t in this._notExistParameterId?this._notExistParameterId[t]:(e=this._model.parameters.count+Object.keys(this._notExistParameterId).length,this._notExistParameterId[t]=e,this._notExistParameterValues[e]=0,e)}getParameterCount(){return this._model.parameters.count}getParameterMaximumValue(t){return this._model.parameters.maximumValues[t]}getParameterMinimumValue(t){return this._model.parameters.minimumValues[t]}getParameterDefaultValue(t){return this._model.parameters.defaultValues[t]}getParameterValueByIndex(t){return t in this._notExistParameterValues?this._notExistParameterValues[t]:(Zi(0<=t&&t<this.getParameterCount()),this._parameterValues[t])}getParameterValueById(t){const e=this.getParameterIndex(t);return this.getParameterValueByIndex(e)}setParameterValueByIndex(t,e,r=1){if(t in this._notExistParameterValues){this._notExistParameterValues[t]=r==1?e:this._notExistParameterValues[t]*(1-r)+e*r;return}Zi(0<=t&&t<this.getParameterCount()),this._model.parameters.maximumValues[t]<e&&(e=this._model.parameters.maximumValues[t]),this._model.parameters.minimumValues[t]>e&&(e=this._model.parameters.minimumValues[t]),this._parameterValues[t]=r==1?e:this._parameterValues[t]=this._parameterValues[t]*(1-r)+e*r}setParameterValueById(t,e,r=1){const n=this.getParameterIndex(t);this.setParameterValueByIndex(n,e,r)}addParameterValueByIndex(t,e,r=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)+e*r)}addParameterValueById(t,e,r=1){const n=this.getParameterIndex(t);this.addParameterValueByIndex(n,e,r)}multiplyParameterValueById(t,e,r=1){const n=this.getParameterIndex(t);this.multiplyParameterValueByIndex(n,e,r)}multiplyParameterValueByIndex(t,e,r=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)*(1+(e-1)*r))}getDrawableIds(){return this._drawableIds.slice()}getDrawableIndex(t){const e=this._model.drawables.count;for(let r=0;r<e;++r)if(this._drawableIds[r]==t)return r;return-1}getDrawableCount(){return this._model.drawables.count}getDrawableId(t){return this._model.drawables.ids[t]}getDrawableRenderOrders(){return this._model.drawables.renderOrders}getDrawableTextureIndices(t){return this._model.drawables.textureIndices[t]}getDrawableDynamicFlagVertexPositionsDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVertexPositionsDidChangeBit(e[t])}getDrawableVertexIndexCount(t){return this._model.drawables.indexCounts[t]}getDrawableVertexCount(t){return this._model.drawables.vertexCounts[t]}getDrawableVertices(t){return this.getDrawableVertexPositions(t)}getDrawableVertexIndices(t){return this._model.drawables.indices[t]}getDrawableVertexPositions(t){return this._model.drawables.vertexPositions[t]}getDrawableVertexUvs(t){return this._model.drawables.vertexUvs[t]}getDrawableOpacity(t){return this._model.drawables.opacities[t]}getDrawableCulling(t){const e=this._model.drawables.constantFlags;return!Live2DCubismCore.Utils.hasIsDoubleSidedBit(e[t])}getDrawableBlendMode(t){const e=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasBlendAdditiveBit(e[t])?Le.CubismBlendMode_Additive:Live2DCubismCore.Utils.hasBlendMultiplicativeBit(e[t])?Le.CubismBlendMode_Multiplicative:Le.CubismBlendMode_Normal}getDrawableInvertedMaskBit(t){const e=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasIsInvertedMaskBit(e[t])}getDrawableMasks(){return this._model.drawables.masks}getDrawableMaskCounts(){return this._model.drawables.maskCounts}isUsingMasking(){for(let t=0;t<this._model.drawables.count;++t)if(!(this._model.drawables.maskCounts[t]<=0))return!0;return!1}getDrawableDynamicFlagIsVisible(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasIsVisibleBit(e[t])}getDrawableDynamicFlagVisibilityDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVisibilityDidChangeBit(e[t])}getDrawableDynamicFlagOpacityDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasOpacityDidChangeBit(e[t])}getDrawableDynamicFlagRenderOrderDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasRenderOrderDidChangeBit(e[t])}loadParameters(){let t=this._model.parameters.count;const e=this._savedParameters.length;t>e&&(t=e);for(let r=0;r<t;++r)this._parameterValues[r]=this._savedParameters[r]}initialize(){this._parameterValues=this._model.parameters.values,this._partOpacities=this._model.parts.opacities,this._parameterMaximumValues=this._model.parameters.maximumValues,this._parameterMinimumValues=this._model.parameters.minimumValues;{const t=this._model.parameters.ids,e=this._model.parameters.count;for(let r=0;r<e;++r)this._parameterIds.push(t[r])}{const t=this._model.parts.ids,e=this._model.parts.count;for(let r=0;r<e;++r)this._partIds.push(t[r])}{const t=this._model.drawables.ids,e=this._model.drawables.count;for(let r=0;r<e;++r)this._drawableIds.push(t[r])}}constructor(t){this._model=t,this._savedParameters=[],this._parameterIds=[],this._drawableIds=[],this._partIds=[],this._notExistPartId={},this._notExistParameterId={},this._notExistParameterValues={},this._notExistPartOpacities={},this.initialize()}release(){this._model.release(),this._model=void 0}}class Ma{static create(t){const e=Live2DCubismCore.Moc.fromArrayBuffer(t);if(e)return new Ma(e);throw new Error("Unknown error")}createModel(){let t;const e=Live2DCubismCore.Model.fromMoc(this._moc);if(e)return t=new Og(e),++this._modelCount,t;throw new Error("Unknown error")}deleteModel(t){t!=null&&--this._modelCount}constructor(t){this._moc=t,this._modelCount=0}release(){this._moc._release(),this._moc=void 0}}var Ra=(i=>(i[i.CubismPhysicsTargetType_Parameter=0]="CubismPhysicsTargetType_Parameter",i))(Ra||{}),ar=(i=>(i[i.CubismPhysicsSource_X=0]="CubismPhysicsSource_X",i[i.CubismPhysicsSource_Y=1]="CubismPhysicsSource_Y",i[i.CubismPhysicsSource_Angle=2]="CubismPhysicsSource_Angle",i))(ar||{});class Dg{constructor(){this.initialPosition=new st(0,0),this.position=new st(0,0),this.lastPosition=new st(0,0),this.lastGravity=new st(0,0),this.force=new st(0,0),this.velocity=new st(0,0)}}class Fg{constructor(){this.normalizationPosition={},this.normalizationAngle={}}}class Lg{constructor(){this.source={}}}class Bg{constructor(){this.destination={},this.translationScale=new st(0,0)}}class Ng{constructor(){this.settings=[],this.inputs=[],this.outputs=[],this.particles=[],this.gravity=new st(0,0),this.wind=new st(0,0)}}class Ug{constructor(t){this._json=t}release(){this._json=void 0}getGravity(){const t=new st(0,0);return t.x=this._json.Meta.EffectiveForces.Gravity.X,t.y=this._json.Meta.EffectiveForces.Gravity.Y,t}getWind(){const t=new st(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 r=new st(0,0);return r.x=this._json.PhysicsSettings[t].Vertices[e].Position.X,r.y=this._json.PhysicsSettings[t].Vertices[e].Position.Y,r}}const _l="X",gl="Y",ml="Angle",kg=5,yl=100,Gg=.001;class Oa{static create(t){const e=new Oa;return e.parse(t),e._physicsRig.gravity.y=0,e}evaluate(t,e){let r,n,s,a;const o=new st;let h,u,l,c,f,d,v,_;f=t.getModel().parameters.values,d=t.getModel().parameters.maximumValues,v=t.getModel().parameters.minimumValues,_=t.getModel().parameters.defaultValues;for(let p=0;p<this._physicsRig.subRigCount;++p){r={angle:0},o.x=0,o.y=0,h=this._physicsRig.settings[p],u=this._physicsRig.inputs.slice(h.baseInputIndex),l=this._physicsRig.outputs.slice(h.baseOutputIndex),c=this._physicsRig.particles.slice(h.baseParticleIndex);for(let g=0;g<h.inputCount;++g)n=u[g].weight/yl,u[g].sourceParameterIndex==-1&&(u[g].sourceParameterIndex=t.getParameterIndex(u[g].source.id)),u[g].getNormalizedParameterValue(o,r,f[u[g].sourceParameterIndex],v[u[g].sourceParameterIndex],d[u[g].sourceParameterIndex],_[u[g].sourceParameterIndex],h.normalizationPosition,h.normalizationAngle,u[g].reflect,n);s=yt.degreesToRadian(-r.angle),o.x=o.x*yt.cos(s)-o.y*yt.sin(s),o.y=o.x*yt.sin(s)+o.y*yt.cos(s),Qg(c,h.particleCount,o,r.angle,this._options.wind,Gg*h.normalizationPosition.maximum,e,kg);for(let g=0;g<h.outputCount;++g){const y=l[g].vertexIndex;if(y<1||y>=h.particleCount)break;l[g].destinationParameterIndex==-1&&(l[g].destinationParameterIndex=t.getParameterIndex(l[g].destination.id));const T=new st;T.x=c[y].position.x-c[y-1].position.x,T.y=c[y].position.y-c[y-1].position.y,a=l[g].getValue(T,c,y,l[g].reflect,this._options.gravity);const I=l[g].destinationParameterIndex,m=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(f.subarray(I))):f.slice(I);tm(m,v[I],d[I],a,l[g]);for(let S=I,x=0;S<f.length;S++,x++)f[S]=m[x]}}}setOptions(t){this._options=t}getOption(){return this._options}constructor(){this._options=new Xg,this._options.gravity.y=-1,this._options.gravity.x=0,this._options.wind.x=0,this._options.wind.y=0}release(){this._physicsRig=void 0}parse(t){this._physicsRig=new Ng;let e=new Ug(t);this._physicsRig.gravity=e.getGravity(),this._physicsRig.wind=e.getWind(),this._physicsRig.subRigCount=e.getSubRigCount();let r=0,n=0,s=0;for(let a=0;a<this._physicsRig.subRigCount;++a){const o=new Fg;o.normalizationPosition.minimum=e.getNormalizationPositionMinimumValue(a),o.normalizationPosition.maximum=e.getNormalizationPositionMaximumValue(a),o.normalizationPosition.defalut=e.getNormalizationPositionDefaultValue(a),o.normalizationAngle.minimum=e.getNormalizationAngleMinimumValue(a),o.normalizationAngle.maximum=e.getNormalizationAngleMaximumValue(a),o.normalizationAngle.defalut=e.getNormalizationAngleDefaultValue(a),o.inputCount=e.getInputCount(a),o.baseInputIndex=r,r+=o.inputCount;for(let h=0;h<o.inputCount;++h){const u=new Lg;switch(u.sourceParameterIndex=-1,u.weight=e.getInputWeight(a,h),u.reflect=e.getInputReflect(a,h),e.getInputType(a,h)){case _l:u.type=ar.CubismPhysicsSource_X,u.getNormalizedParameterValue=Hg;break;case gl:u.type=ar.CubismPhysicsSource_Y,u.getNormalizedParameterValue=Vg;break;case ml:u.type=ar.CubismPhysicsSource_Angle,u.getNormalizedParameterValue=jg;break}u.source.targetType=Ra.CubismPhysicsTargetType_Parameter,u.source.id=e.getInputSourceId(a,h),this._physicsRig.inputs.push(u)}o.outputCount=e.getOutputCount(a),o.baseOutputIndex=n,n+=o.outputCount;for(let h=0;h<o.outputCount;++h){const u=new Bg;switch(u.destinationParameterIndex=-1,u.vertexIndex=e.getOutputVertexIndex(a,h),u.angleScale=e.getOutputAngleScale(a,h),u.weight=e.getOutputWeight(a,h),u.destination.targetType=Ra.CubismPhysicsTargetType_Parameter,u.destination.id=e.getOutputDestinationId(a,h),e.getOutputType(a,h)){case _l:u.type=ar.CubismPhysicsSource_X,u.getValue=zg,u.getScale=Kg;break;case gl:u.type=ar.CubismPhysicsSource_Y,u.getValue=Wg,u.getScale=Zg;break;case ml:u.type=ar.CubismPhysicsSource_Angle,u.getValue=Yg,u.getScale=Jg;break}u.reflect=e.getOutputReflect(a,h),this._physicsRig.outputs.push(u)}o.particleCount=e.getParticleCount(a),o.baseParticleIndex=s,s+=o.particleCount;for(let h=0;h<o.particleCount;++h){const u=new Dg;u.mobility=e.getParticleMobility(a,h),u.delay=e.getParticleDelay(a,h),u.acceleration=e.getParticleAcceleration(a,h),u.radius=e.getParticleRadius(a,h),u.position=e.getParticlePosition(a,h),this._physicsRig.particles.push(u)}this._physicsRig.settings.push(o)}this.initialize(),e.release()}initialize(){let t,e,r;for(let n=0;n<this._physicsRig.subRigCount;++n){e=this._physicsRig.settings[n],t=this._physicsRig.particles.slice(e.baseParticleIndex),t[0].initialPosition=new st(0,0),t[0].lastPosition=new st(t[0].initialPosition.x,t[0].initialPosition.y),t[0].lastGravity=new st(0,-1),t[0].lastGravity.y*=-1,t[0].velocity=new st(0,0),t[0].force=new st(0,0);for(let s=1;s<e.particleCount;++s)r=new st(0,0),r.y=t[s].radius,t[s].initialPosition=new st(t[s-1].initialPosition.x+r.x,t[s-1].initialPosition.y+r.y),t[s].position=new st(t[s].initialPosition.x,t[s].initialPosition.y),t[s].lastPosition=new st(t[s].initialPosition.x,t[s].initialPosition.y),t[s].lastGravity=new st(0,-1),t[s].lastGravity.y*=-1,t[s].velocity=new st(0,0),t[s].force=new st(0,0)}}}class Xg{constructor(){this.gravity=new st(0,0),this.wind=new st(0,0)}}function Hg(i,t,e,r,n,s,a,o,h,u){i.x+=Da(e,r,n,s,a.minimum,a.maximum,a.defalut,h)*u}function Vg(i,t,e,r,n,s,a,o,h,u){i.y+=Da(e,r,n,s,a.minimum,a.maximum,a.defalut,h)*u}function jg(i,t,e,r,n,s,a,o,h,u){t.angle+=Da(e,r,n,s,o.minimum,o.maximum,o.defalut,h)*u}function zg(i,t,e,r,n){let s=i.x;return r&&(s*=-1),s}function Wg(i,t,e,r,n){let s=i.y;return r&&(s*=-1),s}function Yg(i,t,e,r,n){let s;return e>=2?n=t[e-1].position.substract(t[e-2].position):n=n.multiplyByScaler(-1),s=yt.directionToRadian(n,i),r&&(s*=-1),s}function qg(i,t){return Math.abs(Math.max(i,t)-Math.min(i,t))}function $g(i,t){return Math.min(i,t)+qg(i,t)/2}function Kg(i,t){return i.x}function Zg(i,t){return i.y}function Jg(i,t){return t}function Qg(i,t,e,r,n,s,a,o){let h,u,l,c,f=new st(0,0),d=new st(0,0),v=new st(0,0),_=new st(0,0);i[0].position=new st(e.x,e.y),h=yt.degreesToRadian(r),c=yt.radianToDirection(h),c.normalize();for(let p=1;p<t;++p)i[p].force=c.multiplyByScaler(i[p].acceleration).add(n),i[p].lastPosition=new st(i[p].position.x,i[p].position.y),u=i[p].delay*a*30,f=i[p].position.substract(i[p-1].position),l=yt.directionToRadian(i[p].lastGravity,c)/o,f.x=yt.cos(l)*f.x-f.y*yt.sin(l),f.y=yt.sin(l)*f.x+f.y*yt.cos(l),i[p].position=i[p-1].position.add(f),d=i[p].velocity.multiplyByScaler(u),v=i[p].force.multiplyByScaler(u).multiplyByScaler(u),i[p].position=i[p].position.add(d).add(v),_=i[p].position.substract(i[p-1].position),_.normalize(),i[p].position=i[p-1].position.add(_.multiplyByScaler(i[p].radius)),yt.abs(i[p].position.x)<s&&(i[p].position.x=0),u!=0&&(i[p].velocity=i[p].position.substract(i[p].lastPosition),i[p].velocity=i[p].velocity.divisionByScalar(u),i[p].velocity=i[p].velocity.multiplyByScaler(i[p].mobility)),i[p].force=new st(0,0),i[p].lastGravity=new st(c.x,c.y)}function tm(i,t,e,r,n){let s,a,o;s=n.getScale(n.translationScale,n.angleScale),a=r*s,a<t?(a<n.valueBelowMinimum&&(n.valueBelowMinimum=a),a=t):a>e&&(a>n.valueExceededMaximum&&(n.valueExceededMaximum=a),a=e),o=n.weight/yl,o>=1||(a=i[0]*(1-o)+a*o),i[0]=a}function Da(i,t,e,r,n,s,a,o){let h=0;const u=yt.max(e,t);u<i&&(i=u);const l=yt.min(e,t);l>i&&(i=l);const c=yt.min(n,s),f=yt.max(n,s),d=a,v=$g(l,u),_=i-v;switch(Math.sign(_)){case 1:{const p=f-d,g=u-v;g!=0&&(h=_*(p/g),h+=d);break}case-1:{const p=c-d,g=l-v;g!=0&&(h=_*(p/g),h+=d);break}case 0:{h=d;break}}return o?h:h*-1}Et.registerRuntime({version:4,ready:Ag,test(i){return i instanceof br||br.isValidJSON(i)},isValidMoc(i){if(i.byteLength<4)return!1;const t=new Int8Array(i,0,4);return String.fromCharCode(...t)==="MOC3"},createModelSettings(i){return new br(i)},createCoreModel(i){const t=Ma.create(i);try{const e=t.createModel();return e.__moc=t,e}catch(e){try{t.release()}catch{}throw e}},createInternalModel(i,t,e){const r=new Ig(i,t,e),n=i;return n.__moc&&(r.__moc=n.__moc,delete n.__moc,r.once("destroy",em)),r},createPhysics(i,t){return Oa.create(t)},createPose(i,t){return Aa.create(t)}});function em(){var i;(i=this.__moc)==null||i.release()}function rm(i){var t=this.constructor;return this.then(function(e){return t.resolve(i()).then(function(){return e})},function(e){return t.resolve(i()).then(function(){return t.reject(e)})})}function im(i){var t=this;return new t(function(e,r){if(!(i&&typeof i.length<"u"))return r(new TypeError(typeof i+" "+i+" is not iterable(cannot read property Symbol(Symbol.iterator))"));var n=Array.prototype.slice.call(i);if(n.length===0)return e([]);var s=n.length;function a(h,u){if(u&&(typeof u=="object"||typeof u=="function")){var l=u.then;if(typeof l=="function"){l.call(u,function(c){a(h,c)},function(c){n[h]={status:"rejected",reason:c},--s===0&&e(n)});return}}n[h]={status:"fulfilled",value:u},--s===0&&e(n)}for(var o=0;o<n.length;o++)a(o,n[o])})}function xl(i,t){this.name="AggregateError",this.errors=i,this.message=t||""}xl.prototype=Error.prototype;function nm(i){var t=this;return new t(function(e,r){if(!(i&&typeof i.length<"u"))return r(new TypeError("Promise.any accepts an array"));var n=Array.prototype.slice.call(i);if(n.length===0)return r();for(var s=[],a=0;a<n.length;a++)try{t.resolve(n[a]).then(e).catch(function(o){s.push(o),s.length===n.length&&r(new xl(s,"All promises were rejected"))})}catch(o){r(o)}})}var sm=setTimeout;function bl(i){return!!(i&&typeof i.length<"u")}function am(){}function om(i,t){return function(){i.apply(t,arguments)}}function Pt(i){if(!(this instanceof Pt))throw new TypeError("Promises must be constructed via new");if(typeof i!="function")throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],El(i,this)}function Tl(i,t){for(;i._state===3;)i=i._value;if(i._state===0){i._deferreds.push(t);return}i._handled=!0,Pt._immediateFn(function(){var e=i._state===1?t.onFulfilled:t.onRejected;if(e===null){(i._state===1?Fa:hi)(t.promise,i._value);return}var r;try{r=e(i._value)}catch(n){hi(t.promise,n);return}Fa(t.promise,r)})}function Fa(i,t){try{if(t===i)throw new TypeError("A promise cannot be resolved with itself.");if(t&&(typeof t=="object"||typeof t=="function")){var e=t.then;if(t instanceof Pt){i._state=3,i._value=t,La(i);return}else if(typeof e=="function"){El(om(e,t),i);return}}i._state=1,i._value=t,La(i)}catch(r){hi(i,r)}}function hi(i,t){i._state=2,i._value=t,La(i)}function La(i){i._state===2&&i._deferreds.length===0&&Pt._immediateFn(function(){i._handled||Pt._unhandledRejectionFn(i._value)});for(var t=0,e=i._deferreds.length;t<e;t++)Tl(i,i._deferreds[t]);i._deferreds=null}function hm(i,t,e){this.onFulfilled=typeof i=="function"?i:null,this.onRejected=typeof t=="function"?t:null,this.promise=e}function El(i,t){var e=!1;try{i(function(r){e||(e=!0,Fa(t,r))},function(r){e||(e=!0,hi(t,r))})}catch(r){if(e)return;e=!0,hi(t,r)}}Pt.prototype.catch=function(i){return this.then(null,i)},Pt.prototype.then=function(i,t){var e=new this.constructor(am);return Tl(this,new hm(i,t,e)),e},Pt.prototype.finally=rm,Pt.all=function(i){return new Pt(function(t,e){if(!bl(i))return e(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(i);if(r.length===0)return t([]);var n=r.length;function s(o,h){try{if(h&&(typeof h=="object"||typeof h=="function")){var u=h.then;if(typeof u=="function"){u.call(h,function(l){s(o,l)},e);return}}r[o]=h,--n===0&&t(r)}catch(l){e(l)}}for(var a=0;a<r.length;a++)s(a,r[a])})},Pt.any=nm,Pt.allSettled=im,Pt.resolve=function(i){return i&&typeof i=="object"&&i.constructor===Pt?i:new Pt(function(t){t(i)})},Pt.reject=function(i){return new Pt(function(t,e){e(i)})},Pt.race=function(i){return new Pt(function(t,e){if(!bl(i))return e(new TypeError("Promise.race accepts an array"));for(var r=0,n=i.length;r<n;r++)Pt.resolve(i[r]).then(t,e)})},Pt._immediateFn=typeof setImmediate=="function"&&function(i){setImmediate(i)}||function(i){sm(i,0)},Pt._unhandledRejectionFn=function(t){typeof console<"u"&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};var Ba,Sl;function um(){if(Sl)return Ba;Sl=1;var i=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,e=Object.prototype.propertyIsEnumerable;function r(s){if(s==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(s)}function n(){try{if(!Object.assign)return!1;var s=new String("abc");if(s[5]="de",Object.getOwnPropertyNames(s)[0]==="5")return!1;for(var a={},o=0;o<10;o++)a["_"+String.fromCharCode(o)]=o;var h=Object.getOwnPropertyNames(a).map(function(l){return a[l]});if(h.join("")!=="0123456789")return!1;var u={};return"abcdefghijklmnopqrst".split("").forEach(function(l){u[l]=l}),Object.keys(Object.assign({},u)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Ba=n()?Object.assign:function(s,a){for(var o,h=r(s),u,l=1;l<arguments.length;l++){o=Object(arguments[l]);for(var c in o)t.call(o,c)&&(h[c]=o[c]);if(i){u=i(o);for(var f=0;f<u.length;f++)e.call(o,u[f])&&(h[u[f]]=o[u[f]])}}return h},Ba}var lm=um();const fm=An(lm);typeof globalThis>"u"&&(typeof self<"u"?self.globalThis=self:typeof global<"u"&&(global.globalThis=global)),globalThis.Promise||(globalThis.Promise=Pt),Object.assign||(Object.assign=fm);var cm=16;if(Date.now&&Date.prototype.getTime||(Date.now=function(){return new Date().getTime()}),!(globalThis.performance&&globalThis.performance.now)){var dm=Date.now();globalThis.performance||(globalThis.performance={}),globalThis.performance.now=function(){return Date.now()-dm}}for(var Na=Date.now(),Pl=["ms","moz","webkit","o"],Ua=0;Ua<Pl.length&&!globalThis.requestAnimationFrame;++Ua){var ka=Pl[Ua];globalThis.requestAnimationFrame=globalThis[ka+"RequestAnimationFrame"],globalThis.cancelAnimationFrame=globalThis[ka+"CancelAnimationFrame"]||globalThis[ka+"CancelRequestAnimationFrame"]}globalThis.requestAnimationFrame||(globalThis.requestAnimationFrame=function(i){if(typeof i!="function")throw new TypeError(i+"is not a function");var t=Date.now(),e=cm+Na-t;return e<0&&(e=0),Na=t,globalThis.self.setTimeout(function(){Na=Date.now(),i(performance.now())},e)}),globalThis.cancelAnimationFrame||(globalThis.cancelAnimationFrame=function(i){return clearTimeout(i)}),Math.sign||(Math.sign=function(t){return t=Number(t),t===0||isNaN(t)?t:t>0?1:-1}),Number.isInteger||(Number.isInteger=function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t}),globalThis.ArrayBuffer||(globalThis.ArrayBuffer=Array),globalThis.Float32Array||(globalThis.Float32Array=Array),globalThis.Uint32Array||(globalThis.Uint32Array=Array),globalThis.Uint16Array||(globalThis.Uint16Array=Array),globalThis.Uint8Array||(globalThis.Uint8Array=Array),globalThis.Int32Array||(globalThis.Int32Array=Array);var wl={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Ct.mixin(wl);var pm=9,en=100,vm=0,_m=0,Cl=2,Il=1,gm=-1e3,mm=-1e3,ym=2,Al=function(){function i(t){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(qt.tablet||qt.phone)&&this.createTouchHook();var e=document.createElement("div");e.style.width=en+"px",e.style.height=en+"px",e.style.position="absolute",e.style.top=vm+"px",e.style.left=_m+"px",e.style.zIndex=Cl.toString(),this.div=e,this.renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}return Object.defineProperty(i.prototype,"isActive",{get:function(){return this._isActive},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isMobileAccessibility",{get:function(){return this._isMobileAccessibility},enumerable:!1,configurable:!0}),i.prototype.createTouchHook=function(){var t=this,e=document.createElement("button");e.style.width=Il+"px",e.style.height=Il+"px",e.style.position="absolute",e.style.top=gm+"px",e.style.left=mm+"px",e.style.zIndex=ym.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",function(){t._isMobileAccessibility=!0,t.activate(),t.destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e},i.prototype.destroyTouchHook=function(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)},i.prototype.activate=function(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),(t=this.renderer.view.parentNode)===null||t===void 0||t.appendChild(this.div))},i.prototype.deactivate=function(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),(t=this.div.parentNode)===null||t===void 0||t.removeChild(this.div))},i.prototype.updateAccessibleObjects=function(t){if(!(!t.visible||!t.accessibleChildren)){t.accessible&&t.interactive&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);var e=t.children;if(e)for(var r=0;r<e.length;r++)this.updateAccessibleObjects(e[r])}},i.prototype.update=function(){var t=performance.now();if(!(qt.android.device&&t<this.androidUpdateCount)&&(this.androidUpdateCount=t+this.androidUpdateFrequency,!!this.renderer.renderingToScreen)){this.renderer._lastObjectRendered&&this.updateAccessibleObjects(this.renderer._lastObjectRendered);var e=this.renderer.view.getBoundingClientRect(),r=e.left,n=e.top,s=e.width,a=e.height,o=this.renderer,h=o.width,u=o.height,l=o.resolution,c=s/h*l,f=a/u*l,d=this.div;d.style.left=r+"px",d.style.top=n+"px",d.style.width=h+"px",d.style.height=u+"px";for(var v=0;v<this.children.length;v++){var _=this.children[v];if(_.renderId!==this.renderId)_._accessibleActive=!1,Ve(this.children,v,1),this.div.removeChild(_._accessibleDiv),this.pool.push(_._accessibleDiv),_._accessibleDiv=null,v--;else{d=_._accessibleDiv;var p=_.hitArea,g=_.worldTransform;_.hitArea?(d.style.left=(g.tx+p.x*g.a)*c+"px",d.style.top=(g.ty+p.y*g.d)*f+"px",d.style.width=p.width*g.a*c+"px",d.style.height=p.height*g.d*f+"px"):(p=_.getBounds(),this.capHitArea(p),d.style.left=p.x*c+"px",d.style.top=p.y*f+"px",d.style.width=p.width*c+"px",d.style.height=p.height*f+"px",d.title!==_.accessibleTitle&&_.accessibleTitle!==null&&(d.title=_.accessibleTitle),d.getAttribute("aria-label")!==_.accessibleHint&&_.accessibleHint!==null&&d.setAttribute("aria-label",_.accessibleHint)),(_.accessibleTitle!==d.title||_.tabIndex!==d.tabIndex)&&(d.title=_.accessibleTitle,d.tabIndex=_.tabIndex,this.debug&&this.updateDebugHTML(d))}}this.renderId++}},i.prototype.updateDebugHTML=function(t){t.innerHTML="type: "+t.type+"</br> title : "+t.title+"</br> tabIndex: "+t.tabIndex},i.prototype.capHitArea=function(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);var e=this.renderer,r=e.width,n=e.height;t.x+t.width>r&&(t.width=r-t.x),t.y+t.height>n&&(t.height=n-t.y)},i.prototype.addChild=function(t){var e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=en+"px",e.style.height=en+"px",e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Cl.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().indexOf("chrome")>-1?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title="displayObject "+t.tabIndex),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex},i.prototype._onClick=function(t){var e=this.renderer.plugins.interaction,r=t.target.displayObject,n=e.eventData;e.dispatchEvent(r,"click",n),e.dispatchEvent(r,"pointertap",n),e.dispatchEvent(r,"tap",n)},i.prototype._onFocus=function(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive");var e=this.renderer.plugins.interaction,r=t.target.displayObject,n=e.eventData;e.dispatchEvent(r,"mouseover",n)},i.prototype._onFocusOut=function(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite");var e=this.renderer.plugins.interaction,r=t.target.displayObject,n=e.eventData;e.dispatchEvent(r,"mouseout",n)},i.prototype._onKeyDown=function(t){t.keyCode===pm&&this.activate()},i.prototype._onMouseMove=function(t){t.movementX===0&&t.movementY===0||this.deactivate()},i.prototype.destroy=function(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null},i.extension={name:"accessibility",type:[dt.RendererPlugin,dt.CanvasRendererPlugin]},i}();var Ga=function(){function i(){this.pressure=0,this.rotationAngle=0,this.twist=0,this.tangentialPressure=0,this.global=new vt,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(i.prototype,"pointerId",{get:function(){return this.identifier},enumerable:!1,configurable:!0}),i.prototype.getLocalPosition=function(t,e,r){return t.worldTransform.applyInverse(r||this.global,e)},i.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},i.prototype.reset=function(){this.isPrimary=!1},i}();var Xa=function(i,t){return Xa=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},Xa(i,t)};function xm(i,t){Xa(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Ml=function(){function i(){this.stopped=!1,this.stopsPropagatingAt=null,this.stopPropagationHint=!1,this.target=null,this.currentTarget=null,this.type=null,this.data=null}return i.prototype.stopPropagation=function(){this.stopped=!0,this.stopPropagationHint=!0,this.stopsPropagatingAt=this.currentTarget},i.prototype.reset=function(){this.stopped=!1,this.stopsPropagatingAt=null,this.stopPropagationHint=!1,this.currentTarget=null,this.target=null},i}(),rn=function(){function i(t){this._pointerId=t,this._flags=i.FLAGS.NONE}return i.prototype._doSet=function(t,e){e?this._flags=this._flags|t:this._flags=this._flags&~t},Object.defineProperty(i.prototype,"pointerId",{get:function(){return this._pointerId},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"flags",{get:function(){return this._flags},set:function(t){this._flags=t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"none",{get:function(){return this._flags===i.FLAGS.NONE},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"over",{get:function(){return(this._flags&i.FLAGS.OVER)!==0},set:function(t){this._doSet(i.FLAGS.OVER,t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rightDown",{get:function(){return(this._flags&i.FLAGS.RIGHT_DOWN)!==0},set:function(t){this._doSet(i.FLAGS.RIGHT_DOWN,t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"leftDown",{get:function(){return(this._flags&i.FLAGS.LEFT_DOWN)!==0},set:function(t){this._doSet(i.FLAGS.LEFT_DOWN,t)},enumerable:!1,configurable:!0}),i.FLAGS=Object.freeze({NONE:0,OVER:1,LEFT_DOWN:2,RIGHT_DOWN:4}),i}(),bm=function(){function i(){this._tempPoint=new vt}return i.prototype.recursiveFindHit=function(t,e,r,n,s){var a;if(!e||!e.visible)return!1;var o=t.data.global;s=e.interactive||s;var h=!1,u=s,l=!0;if(e.hitArea)n&&(e.worldTransform.applyInverse(o,this._tempPoint),e.hitArea.contains(this._tempPoint.x,this._tempPoint.y)?h=!0:(n=!1,l=!1)),u=!1;else if(e._mask&&n){var c=e._mask.isMaskData?e._mask.maskObject:e._mask;c&&!(!((a=c.containsPoint)===null||a===void 0)&&a.call(c,o))&&(n=!1)}if(l&&e.interactiveChildren&&e.children)for(var f=e.children,d=f.length-1;d>=0;d--){var v=f[d],_=this.recursiveFindHit(t,v,r,n,u);if(_){if(!v.parent)continue;u=!1,_&&(t.target&&(n=!1),h=!0)}}return s&&(n&&!t.target&&!e.hitArea&&e.containsPoint&&e.containsPoint(o)&&(h=!0),e.interactive&&(h&&!t.target&&(t.target=e),r&&r(t,e,!!h))),h},i.prototype.findHit=function(t,e,r,n){this.recursiveFindHit(t,e,r,n,!1)},i}(),Rl={interactive:!1,interactiveChildren:!0,hitArea:null,get buttonMode(){return this.cursor==="pointer"},set buttonMode(i){i?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};Ct.mixin(Rl);var nn=1,sn={target:null,data:{global:null}},Ha=function(i){xm(t,i);function t(e,r){var n=i.call(this)||this;return r=r||{},n.renderer=e,n.autoPreventDefault=r.autoPreventDefault!==void 0?r.autoPreventDefault:!0,n.interactionFrequency=r.interactionFrequency||10,n.mouse=new Ga,n.mouse.identifier=nn,n.mouse.global.set(-999999),n.activeInteractionData={},n.activeInteractionData[nn]=n.mouse,n.interactionDataPool=[],n.eventData=new Ml,n.interactionDOMElement=null,n.moveWhenInside=!1,n.eventsAdded=!1,n.tickerAdded=!1,n.mouseOverRenderer=!("PointerEvent"in globalThis),n.supportsTouchEvents="ontouchstart"in globalThis,n.supportsPointerEvents=!!globalThis.PointerEvent,n.onPointerUp=n.onPointerUp.bind(n),n.processPointerUp=n.processPointerUp.bind(n),n.onPointerCancel=n.onPointerCancel.bind(n),n.processPointerCancel=n.processPointerCancel.bind(n),n.onPointerDown=n.onPointerDown.bind(n),n.processPointerDown=n.processPointerDown.bind(n),n.onPointerMove=n.onPointerMove.bind(n),n.processPointerMove=n.processPointerMove.bind(n),n.onPointerOut=n.onPointerOut.bind(n),n.processPointerOverOut=n.processPointerOverOut.bind(n),n.onPointerOver=n.onPointerOver.bind(n),n.cursorStyles={default:"inherit",pointer:"pointer"},n.currentCursorMode=null,n.cursor=null,n.resolution=1,n.delayedEvents=[],n.search=new bm,n._tempDisplayObject=new da,n._eventListenerOptions={capture:!0,passive:!1},n._useSystemTicker=r.useSystemTicker!==void 0?r.useSystemTicker:!0,n.setTargetElement(n.renderer.view,n.renderer.resolution),n}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,r){return sn.target=null,sn.data.global=e,r||(r=this.lastObjectRendered),this.processInteractive(sn,r,null,!0),sn.target},t.prototype.setTargetElement=function(e,r){r===void 0&&(r=1),this.removeTickerListener(),this.removeEvents(),this.interactionDOMElement=e,this.resolution=r,this.addEvents(),this.addTickerListener()},t.prototype.addTickerListener=function(){this.tickerAdded||!this.interactionDOMElement||!this._useSystemTicker||(Ot.system.add(this.tickerUpdate,this,de.INTERACTION),this.tickerAdded=!0)},t.prototype.removeTickerListener=function(){this.tickerAdded&&(Ot.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._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())},t.prototype.update=function(){if(this.interactionDOMElement){if(this._didMove){this._didMove=!1;return}this.cursor=null;for(var e in this.activeInteractionData)if(this.activeInteractionData.hasOwnProperty(e)){var r=this.activeInteractionData[e];if(r.originalEvent&&r.pointerType!=="touch"){var n=this.configureInteractionEventForDOMEvent(this.eventData,r.originalEvent,r);this.processInteractive(n,this.lastObjectRendered,this.processPointerOverOut,!0)}}this.setCursorMode(this.cursor)}},t.prototype.setCursorMode=function(e){e=e||"default";var r=!0;if(globalThis.OffscreenCanvas&&this.interactionDOMElement instanceof OffscreenCanvas&&(r=!1),this.currentCursorMode!==e){this.currentCursorMode=e;var n=this.cursorStyles[e];if(n)switch(typeof n){case"string":r&&(this.interactionDOMElement.style.cursor=n);break;case"function":n(e);break;case"object":r&&Object.assign(this.interactionDOMElement.style,n);break}else r&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.interactionDOMElement.style.cursor=e)}},t.prototype.dispatchEvent=function(e,r,n){(!n.stopPropagationHint||e===n.stopsPropagatingAt)&&(n.currentTarget=e,n.type=r,e.emit(r,n),e[r]&&e[r](n))},t.prototype.delayDispatchEvent=function(e,r,n){this.delayedEvents.push({displayObject:e,eventString:r,eventData:n})},t.prototype.mapPositionToPoint=function(e,r,n){var s;this.interactionDOMElement.parentElement?s=this.interactionDOMElement.getBoundingClientRect():s={x:0,y:0,width:this.interactionDOMElement.width,height:this.interactionDOMElement.height,left:0,top:0};var a=1/this.resolution;e.x=(r-s.left)*(this.interactionDOMElement.width/s.width)*a,e.y=(n-s.top)*(this.interactionDOMElement.height/s.height)*a},t.prototype.processInteractive=function(e,r,n,s){var a=this.search.findHit(e,r,n,s),o=this.delayedEvents;if(!o.length)return a;e.stopPropagationHint=!1;var h=o.length;this.delayedEvents=[];for(var u=0;u<h;u++){var l=o[u],c=l.displayObject,f=l.eventString,d=l.eventData;d.stopsPropagatingAt===c&&(d.stopPropagationHint=!0),this.dispatchEvent(c,f,d)}return a},t.prototype.onPointerDown=function(e){if(!(this.supportsTouchEvents&&e.pointerType==="touch")){var r=this.normalizeToPointerData(e);if(this.autoPreventDefault&&r[0].isNormalized){var n=e.cancelable||!("cancelable"in e);n&&e.preventDefault()}for(var s=r.length,a=0;a<s;a++){var o=r[a],h=this.getInteractionDataForPointerId(o),u=this.configureInteractionEventForDOMEvent(this.eventData,o,h);if(u.data.originalEvent=e,this.processInteractive(u,this.lastObjectRendered,this.processPointerDown,!0),this.emit("pointerdown",u),o.pointerType==="touch")this.emit("touchstart",u);else if(o.pointerType==="mouse"||o.pointerType==="pen"){var l=o.button===2;this.emit(l?"rightdown":"mousedown",this.eventData)}}}},t.prototype.processPointerDown=function(e,r,n){var s=e.data,a=e.data.identifier;if(n){if(r.trackedPointers[a]||(r.trackedPointers[a]=new rn(a)),this.dispatchEvent(r,"pointerdown",e),s.pointerType==="touch")this.dispatchEvent(r,"touchstart",e);else if(s.pointerType==="mouse"||s.pointerType==="pen"){var o=s.button===2;o?r.trackedPointers[a].rightDown=!0:r.trackedPointers[a].leftDown=!0,this.dispatchEvent(r,o?"rightdown":"mousedown",e)}}},t.prototype.onPointerComplete=function(e,r,n){var s=this.normalizeToPointerData(e),a=s.length,o=e.target;e.composedPath&&e.composedPath().length>0&&(o=e.composedPath()[0]);for(var h=o!==this.interactionDOMElement?"outside":"",u=0;u<a;u++){var l=s[u],c=this.getInteractionDataForPointerId(l),f=this.configureInteractionEventForDOMEvent(this.eventData,l,c);if(f.data.originalEvent=e,this.processInteractive(f,this.lastObjectRendered,n,r||!h),this.emit(r?"pointercancel":"pointerup"+h,f),l.pointerType==="mouse"||l.pointerType==="pen"){var d=l.button===2;this.emit(d?"rightup"+h:"mouseup"+h,f)}else l.pointerType==="touch"&&(this.emit(r?"touchcancel":"touchend"+h,f),this.releaseInteractionDataForPointerId(l.pointerId))}},t.prototype.onPointerCancel=function(e){this.supportsTouchEvents&&e.pointerType==="touch"||this.onPointerComplete(e,!0,this.processPointerCancel)},t.prototype.processPointerCancel=function(e,r){var n=e.data,s=e.data.identifier;r.trackedPointers[s]!==void 0&&(delete r.trackedPointers[s],this.dispatchEvent(r,"pointercancel",e),n.pointerType==="touch"&&this.dispatchEvent(r,"touchcancel",e))},t.prototype.onPointerUp=function(e){this.supportsTouchEvents&&e.pointerType==="touch"||this.onPointerComplete(e,!1,this.processPointerUp)},t.prototype.processPointerUp=function(e,r,n){var s=e.data,a=e.data.identifier,o=r.trackedPointers[a],h=s.pointerType==="touch",u=s.pointerType==="mouse"||s.pointerType==="pen",l=!1;if(u){var c=s.button===2,f=rn.FLAGS,d=c?f.RIGHT_DOWN:f.LEFT_DOWN,v=o!==void 0&&o.flags&d;n?(this.dispatchEvent(r,c?"rightup":"mouseup",e),v&&(this.dispatchEvent(r,c?"rightclick":"click",e),l=!0)):v&&this.dispatchEvent(r,c?"rightupoutside":"mouseupoutside",e),o&&(c?o.rightDown=!1:o.leftDown=!1)}n?(this.dispatchEvent(r,"pointerup",e),h&&this.dispatchEvent(r,"touchend",e),o&&((!u||l)&&this.dispatchEvent(r,"pointertap",e),h&&(this.dispatchEvent(r,"tap",e),o.over=!1))):o&&(this.dispatchEvent(r,"pointerupoutside",e),h&&this.dispatchEvent(r,"touchendoutside",e)),o&&o.none&&delete r.trackedPointers[a]},t.prototype.onPointerMove=function(e){if(!(this.supportsTouchEvents&&e.pointerType==="touch")){var r=this.normalizeToPointerData(e);(r[0].pointerType==="mouse"||r[0].pointerType==="pen")&&(this._didMove=!0,this.cursor=null);for(var n=r.length,s=0;s<n;s++){var a=r[s],o=this.getInteractionDataForPointerId(a),h=this.configureInteractionEventForDOMEvent(this.eventData,a,o);h.data.originalEvent=e,this.processInteractive(h,this.lastObjectRendered,this.processPointerMove,!0),this.emit("pointermove",h),a.pointerType==="touch"&&this.emit("touchmove",h),(a.pointerType==="mouse"||a.pointerType==="pen")&&this.emit("mousemove",h)}r[0].pointerType==="mouse"&&this.setCursorMode(this.cursor)}},t.prototype.processPointerMove=function(e,r,n){var s=e.data,a=s.pointerType==="touch",o=s.pointerType==="mouse"||s.pointerType==="pen";o&&this.processPointerOverOut(e,r,n),(!this.moveWhenInside||n)&&(this.dispatchEvent(r,"pointermove",e),a&&this.dispatchEvent(r,"touchmove",e),o&&this.dispatchEvent(r,"mousemove",e))},t.prototype.onPointerOut=function(e){if(!(this.supportsTouchEvents&&e.pointerType==="touch")){var r=this.normalizeToPointerData(e),n=r[0];n.pointerType==="mouse"&&(this.mouseOverRenderer=!1,this.setCursorMode(null));var s=this.getInteractionDataForPointerId(n),a=this.configureInteractionEventForDOMEvent(this.eventData,n,s);a.data.originalEvent=n,this.processInteractive(a,this.lastObjectRendered,this.processPointerOverOut,!1),this.emit("pointerout",a),n.pointerType==="mouse"||n.pointerType==="pen"?this.emit("mouseout",a):this.releaseInteractionDataForPointerId(s.identifier)}},t.prototype.processPointerOverOut=function(e,r,n){var s=e.data,a=e.data.identifier,o=s.pointerType==="mouse"||s.pointerType==="pen",h=r.trackedPointers[a];n&&!h&&(h=r.trackedPointers[a]=new rn(a)),h!==void 0&&(n&&this.mouseOverRenderer?(h.over||(h.over=!0,this.delayDispatchEvent(r,"pointerover",e),o&&this.delayDispatchEvent(r,"mouseover",e)),o&&this.cursor===null&&(this.cursor=r.cursor)):h.over&&(h.over=!1,this.dispatchEvent(r,"pointerout",this.eventData),o&&this.dispatchEvent(r,"mouseout",e),h.none&&delete r.trackedPointers[a]))},t.prototype.onPointerOver=function(e){if(!(this.supportsTouchEvents&&e.pointerType==="touch")){var r=this.normalizeToPointerData(e),n=r[0],s=this.getInteractionDataForPointerId(n),a=this.configureInteractionEventForDOMEvent(this.eventData,n,s);a.data.originalEvent=n,n.pointerType==="mouse"&&(this.mouseOverRenderer=!0),this.emit("pointerover",a),(n.pointerType==="mouse"||n.pointerType==="pen")&&this.emit("mouseover",a)}},t.prototype.getInteractionDataForPointerId=function(e){var r=e.pointerId,n;return r===nn||e.pointerType==="mouse"?n=this.mouse:this.activeInteractionData[r]?n=this.activeInteractionData[r]:(n=this.interactionDataPool.pop()||new Ga,n.identifier=r,this.activeInteractionData[r]=n),n.copyEvent(e),n},t.prototype.releaseInteractionDataForPointerId=function(e){var r=this.activeInteractionData[e];r&&(delete this.activeInteractionData[e],r.reset(),this.interactionDataPool.push(r))},t.prototype.configureInteractionEventForDOMEvent=function(e,r,n){return e.data=n,this.mapPositionToPoint(n.global,r.clientX,r.clientY),r.pointerType==="touch"&&(r.globalX=n.global.x,r.globalY=n.global.y),n.originalEvent=r,e.reset(),e},t.prototype.normalizeToPointerData=function(e){var r=[];if(this.supportsTouchEvents&&e instanceof TouchEvent)for(var n=0,s=e.changedTouches.length;n<s;n++){var a=e.changedTouches[n];typeof a.button>"u"&&(a.button=e.touches.length?1:0),typeof a.buttons>"u"&&(a.buttons=e.touches.length?1:0),typeof a.isPrimary>"u"&&(a.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof a.width>"u"&&(a.width=a.radiusX||1),typeof a.height>"u"&&(a.height=a.radiusY||1),typeof a.tiltX>"u"&&(a.tiltX=0),typeof a.tiltY>"u"&&(a.tiltY=0),typeof a.pointerType>"u"&&(a.pointerType="touch"),typeof a.pointerId>"u"&&(a.pointerId=a.identifier||0),typeof a.pressure>"u"&&(a.pressure=a.force||.5),typeof a.twist>"u"&&(a.twist=0),typeof a.tangentialPressure>"u"&&(a.tangentialPressure=0),typeof a.layerX>"u"&&(a.layerX=a.offsetX=a.clientX),typeof a.layerY>"u"&&(a.layerY=a.offsetY=a.clientY),a.isNormalized=!0,r.push(a)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){var o=e;typeof o.isPrimary>"u"&&(o.isPrimary=!0),typeof o.width>"u"&&(o.width=1),typeof o.height>"u"&&(o.height=1),typeof o.tiltX>"u"&&(o.tiltX=0),typeof o.tiltY>"u"&&(o.tiltY=0),typeof o.pointerType>"u"&&(o.pointerType="mouse"),typeof o.pointerId>"u"&&(o.pointerId=nn),typeof o.pressure>"u"&&(o.pressure=.5),typeof o.twist>"u"&&(o.twist=0),typeof o.tangentialPressure>"u"&&(o.tangentialPressure=0),o.isNormalized=!0,r.push(o)}else r.push(e);return r},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:[dt.RendererPlugin,dt.CanvasRendererPlugin]},t}(xe);var Tm=new ut,Em=4,Ol=function(){function i(t){this.renderer=t}return i.prototype.image=function(t,e,r){var n=new Image;return n.src=this.base64(t,e,r),n},i.prototype.base64=function(t,e,r){return this.canvas(t).toDataURL(e,r)},i.prototype.canvas=function(t,e){var r=this._rawPixels(t,e),n=r.pixels,s=r.width,a=r.height,o=r.flipY,h=new xs(s,a,1),u=h.context.getImageData(0,0,s,a);if(i.arrayPostDivide(n,u.data),h.context.putImageData(u,0,0),o){var l=new xs(h.width,h.height,1);l.context.scale(1,-1),l.context.drawImage(h.canvas,0,-a),h.destroy(),h=l}return h.canvas},i.prototype.pixels=function(t,e){var r=this._rawPixels(t,e).pixels;return i.arrayPostDivide(r,r),r},i.prototype._rawPixels=function(t,e){var r=this.renderer,n,s=!1,a,o=!1;if(t)if(t instanceof Me)a=t;else{var h=r.context.webGLVersion>=2?r.multisample:xt.NONE;if(a=this.renderer.generateTexture(t,{multisample:h}),h!==xt.NONE){var u=Me.create({width:a.width,height:a.height});r.framebuffer.bind(a.framebuffer),r.framebuffer.blit(u.framebuffer),r.framebuffer.bind(null),a.destroy(!0),a=u}o=!0}a?(n=a.baseTexture.resolution,e=e??a.frame,s=!1,r.renderTexture.bind(a)):(n=r.resolution,e||(e=Tm,e.width=r.width,e.height=r.height),s=!0,r.renderTexture.bind(null));var l=Math.round(e.width*n),c=Math.round(e.height*n),f=new Uint8Array(Em*l*c),d=r.gl;return d.readPixels(Math.round(e.x*n),Math.round(e.y*n),l,c,d.RGBA,d.UNSIGNED_BYTE,f),o&&a.destroy(!0),{pixels:f,width:l,height:c,flipY:s}},i.prototype.destroy=function(){this.renderer=null},i.arrayPostDivide=function(t,e){for(var r=0;r<t.length;r+=4){var n=e[r+3]=t[r+3];n!==0?(e[r]=Math.round(Math.min(t[r]*255/n,255)),e[r+1]=Math.round(Math.min(t[r+1]*255/n,255)),e[r+2]=Math.round(Math.min(t[r+2]*255/n,255))):(e[r]=t[r],e[r+1]=t[r+1],e[r+2]=t[r+2])}},i.extension={name:"extract",type:dt.RendererPlugin},i}();var an=function(){function i(t,e,r){e===void 0&&(e=!1),this._fn=t,this._once=e,this._thisArg=r,this._next=this._prev=this._owner=null}return i.prototype.detach=function(){return this._owner===null?!1:(this._owner.detach(this),!0)},i}();function Dl(i,t){return i._head?(i._tail._next=t,t._prev=i._tail,i._tail=t):(i._head=t,i._tail=t),t._owner=i,t}var Ee=function(){function i(){this._head=this._tail=void 0}return i.prototype.handlers=function(t){t===void 0&&(t=!1);var e=this._head;if(t)return!!e;for(var r=[];e;)r.push(e),e=e._next;return r},i.prototype.has=function(t){if(!(t instanceof an))throw new Error("MiniSignal#has(): First arg must be a SignalBinding object.");return t._owner===this},i.prototype.dispatch=function(){for(var t=arguments,e=[],r=0;r<arguments.length;r++)e[r]=t[r];var n=this._head;if(!n)return!1;for(;n;)n._once&&this.detach(n),n._fn.apply(n._thisArg,e),n=n._next;return!0},i.prototype.add=function(t,e){if(e===void 0&&(e=null),typeof t!="function")throw new Error("MiniSignal#add(): First arg must be a Function.");return Dl(this,new an(t,!1,e))},i.prototype.once=function(t,e){if(e===void 0&&(e=null),typeof t!="function")throw new Error("MiniSignal#once(): First arg must be a Function.");return Dl(this,new an(t,!0,e))},i.prototype.detach=function(t){if(!(t instanceof an))throw new Error("MiniSignal#detach(): First arg must be a SignalBinding object.");return t._owner!==this?this:(t._prev&&(t._prev._next=t._next),t._next&&(t._next._prev=t._prev),t===this._head?(this._head=t._next,t._next===null&&(this._tail=null)):t===this._tail&&(this._tail=t._prev,this._tail._next=null),t._owner=null,this)},i.prototype.detachAll=function(){var t=this._head;if(!t)return this;for(this._head=this._tail=null;t;)t._owner=null,t=t._next;return this},i}();function Fl(i,t){t=t||{};for(var e={key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},r=e.parser[t.strictMode?"strict":"loose"].exec(i),n={},s=14;s--;)n[e.key[s]]=r[s]||"";return n[e.q.name]={},n[e.key[12]].replace(e.q.parser,function(a,o,h){o&&(n[e.q.name][o]=h)}),n}var Va,on=null,Sm=0,Ll=200,Pm=204,wm=1223,Cm=2;function Bl(){}function Nl(i,t,e){t&&t.indexOf(".")===0&&(t=t.substring(1)),t&&(i[t]=e)}function ja(i){return i.toString().replace("object ","")}var wt=function(){function i(t,e,r){if(this._dequeue=Bl,this._onLoadBinding=null,this._elementTimer=0,this._boundComplete=null,this._boundOnError=null,this._boundOnProgress=null,this._boundOnTimeout=null,this._boundXhrOnError=null,this._boundXhrOnTimeout=null,this._boundXhrOnAbort=null,this._boundXhrOnLoad=null,typeof t!="string"||typeof e!="string")throw new Error("Both name and url are required for constructing a resource.");r=r||{},this._flags=0,this._setFlag(i.STATUS_FLAGS.DATA_URL,e.indexOf("data:")===0),this.name=t,this.url=e,this.extension=this._getExtension(),this.data=null,this.crossOrigin=r.crossOrigin===!0?"anonymous":r.crossOrigin,this.timeout=r.timeout||0,this.loadType=r.loadType||this._determineLoadType(),this.xhrType=r.xhrType,this.metadata=r.metadata||{},this.error=null,this.xhr=null,this.children=[],this.type=i.TYPE.UNKNOWN,this.progressChunk=0,this._dequeue=Bl,this._onLoadBinding=null,this._elementTimer=0,this._boundComplete=this.complete.bind(this),this._boundOnError=this._onError.bind(this),this._boundOnProgress=this._onProgress.bind(this),this._boundOnTimeout=this._onTimeout.bind(this),this._boundXhrOnError=this._xhrOnError.bind(this),this._boundXhrOnTimeout=this._xhrOnTimeout.bind(this),this._boundXhrOnAbort=this._xhrOnAbort.bind(this),this._boundXhrOnLoad=this._xhrOnLoad.bind(this),this.onStart=new Ee,this.onProgress=new Ee,this.onComplete=new Ee,this.onAfterMiddleware=new Ee}return i.setExtensionLoadType=function(t,e){Nl(i._loadTypeMap,t,e)},i.setExtensionXhrType=function(t,e){Nl(i._xhrTypeMap,t,e)},Object.defineProperty(i.prototype,"isDataUrl",{get:function(){return this._hasFlag(i.STATUS_FLAGS.DATA_URL)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isComplete",{get:function(){return this._hasFlag(i.STATUS_FLAGS.COMPLETE)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isLoading",{get:function(){return this._hasFlag(i.STATUS_FLAGS.LOADING)},enumerable:!1,configurable:!0}),i.prototype.complete=function(){this._clearEvents(),this._finish()},i.prototype.abort=function(t){if(!this.error){if(this.error=new Error(t),this._clearEvents(),this.xhr)this.xhr.abort();else if(this.xdr)this.xdr.abort();else if(this.data)if(this.data.src)this.data.src=i.EMPTY_GIF;else for(;this.data.firstChild;)this.data.removeChild(this.data.firstChild);this._finish()}},i.prototype.load=function(t){var e=this;if(!this.isLoading){if(this.isComplete){t&&setTimeout(function(){return t(e)},1);return}else t&&this.onComplete.once(t);switch(this._setFlag(i.STATUS_FLAGS.LOADING,!0),this.onStart.dispatch(this),(this.crossOrigin===!1||typeof this.crossOrigin!="string")&&(this.crossOrigin=this._determineCrossOrigin(this.url)),this.loadType){case i.LOAD_TYPE.IMAGE:this.type=i.TYPE.IMAGE,this._loadElement("image");break;case i.LOAD_TYPE.AUDIO:this.type=i.TYPE.AUDIO,this._loadSourceElement("audio");break;case i.LOAD_TYPE.VIDEO:this.type=i.TYPE.VIDEO,this._loadSourceElement("video");break;case i.LOAD_TYPE.XHR:default:typeof Va>"u"&&(Va=!!(globalThis.XDomainRequest&&!("withCredentials"in new XMLHttpRequest))),Va&&this.crossOrigin?this._loadXdr():this._loadXhr();break}}},i.prototype._hasFlag=function(t){return(this._flags&t)!==0},i.prototype._setFlag=function(t,e){this._flags=e?this._flags|t:this._flags&~t},i.prototype._clearEvents=function(){clearTimeout(this._elementTimer),this.data&&this.data.removeEventListener&&(this.data.removeEventListener("error",this._boundOnError,!1),this.data.removeEventListener("load",this._boundComplete,!1),this.data.removeEventListener("progress",this._boundOnProgress,!1),this.data.removeEventListener("canplaythrough",this._boundComplete,!1)),this.xhr&&(this.xhr.removeEventListener?(this.xhr.removeEventListener("error",this._boundXhrOnError,!1),this.xhr.removeEventListener("timeout",this._boundXhrOnTimeout,!1),this.xhr.removeEventListener("abort",this._boundXhrOnAbort,!1),this.xhr.removeEventListener("progress",this._boundOnProgress,!1),this.xhr.removeEventListener("load",this._boundXhrOnLoad,!1)):(this.xhr.onerror=null,this.xhr.ontimeout=null,this.xhr.onprogress=null,this.xhr.onload=null))},i.prototype._finish=function(){if(this.isComplete)throw new Error("Complete called again for an already completed resource.");this._setFlag(i.STATUS_FLAGS.COMPLETE,!0),this._setFlag(i.STATUS_FLAGS.LOADING,!1),this.onComplete.dispatch(this)},i.prototype._loadElement=function(t){this.metadata.loadElement?this.data=this.metadata.loadElement:t==="image"&&typeof globalThis.Image<"u"?this.data=new Image:this.data=document.createElement(t),this.crossOrigin&&(this.data.crossOrigin=this.crossOrigin),this.metadata.skipSource||(this.data.src=this.url),this.data.addEventListener("error",this._boundOnError,!1),this.data.addEventListener("load",this._boundComplete,!1),this.data.addEventListener("progress",this._boundOnProgress,!1),this.timeout&&(this._elementTimer=setTimeout(this._boundOnTimeout,this.timeout))},i.prototype._loadSourceElement=function(t){if(this.metadata.loadElement?this.data=this.metadata.loadElement:t==="audio"&&typeof globalThis.Audio<"u"?this.data=new Audio:this.data=document.createElement(t),this.data===null){this.abort("Unsupported element: "+t);return}if(this.crossOrigin&&(this.data.crossOrigin=this.crossOrigin),!this.metadata.skipSource)if(navigator.isCocoonJS)this.data.src=Array.isArray(this.url)?this.url[0]:this.url;else if(Array.isArray(this.url))for(var e=this.metadata.mimeType,r=0;r<this.url.length;++r)this.data.appendChild(this._createSource(t,this.url[r],Array.isArray(e)?e[r]:e));else{var e=this.metadata.mimeType;this.data.appendChild(this._createSource(t,this.url,Array.isArray(e)?e[0]:e))}this.data.addEventListener("error",this._boundOnError,!1),this.data.addEventListener("load",this._boundComplete,!1),this.data.addEventListener("progress",this._boundOnProgress,!1),this.data.addEventListener("canplaythrough",this._boundComplete,!1),this.data.load(),this.timeout&&(this._elementTimer=setTimeout(this._boundOnTimeout,this.timeout))},i.prototype._loadXhr=function(){typeof this.xhrType!="string"&&(this.xhrType=this._determineXhrType());var t=this.xhr=new XMLHttpRequest;this.crossOrigin==="use-credentials"&&(t.withCredentials=!0),t.open("GET",this.url,!0),t.timeout=this.timeout,this.xhrType===i.XHR_RESPONSE_TYPE.JSON||this.xhrType===i.XHR_RESPONSE_TYPE.DOCUMENT?t.responseType=i.XHR_RESPONSE_TYPE.TEXT:t.responseType=this.xhrType,t.addEventListener("error",this._boundXhrOnError,!1),t.addEventListener("timeout",this._boundXhrOnTimeout,!1),t.addEventListener("abort",this._boundXhrOnAbort,!1),t.addEventListener("progress",this._boundOnProgress,!1),t.addEventListener("load",this._boundXhrOnLoad,!1),t.send()},i.prototype._loadXdr=function(){typeof this.xhrType!="string"&&(this.xhrType=this._determineXhrType());var t=this.xhr=new globalThis.XDomainRequest;t.timeout=this.timeout||5e3,t.onerror=this._boundXhrOnError,t.ontimeout=this._boundXhrOnTimeout,t.onprogress=this._boundOnProgress,t.onload=this._boundXhrOnLoad,t.open("GET",this.url,!0),setTimeout(function(){return t.send()},1)},i.prototype._createSource=function(t,e,r){r||(r=t+"/"+this._getExtension(e));var n=document.createElement("source");return n.src=e,n.type=r,n},i.prototype._onError=function(t){this.abort("Failed to load element using: "+t.target.nodeName)},i.prototype._onProgress=function(t){t&&t.lengthComputable&&this.onProgress.dispatch(this,t.loaded/t.total)},i.prototype._onTimeout=function(){this.abort("Load timed out.")},i.prototype._xhrOnError=function(){var t=this.xhr;this.abort(ja(t)+" Request failed. Status: "+t.status+', text: "'+t.statusText+'"')},i.prototype._xhrOnTimeout=function(){var t=this.xhr;this.abort(ja(t)+" Request timed out.")},i.prototype._xhrOnAbort=function(){var t=this.xhr;this.abort(ja(t)+" Request was aborted by the user.")},i.prototype._xhrOnLoad=function(){var t=this.xhr,e="",r=typeof t.status>"u"?Ll:t.status;(t.responseType===""||t.responseType==="text"||typeof t.responseType>"u")&&(e=t.responseText),r===Sm&&(e.length>0||t.responseType===i.XHR_RESPONSE_TYPE.BUFFER)?r=Ll:r===wm&&(r=Pm);var n=r/100|0;if(n===Cm)if(this.xhrType===i.XHR_RESPONSE_TYPE.TEXT)this.data=e,this.type=i.TYPE.TEXT;else if(this.xhrType===i.XHR_RESPONSE_TYPE.JSON)try{this.data=JSON.parse(e),this.type=i.TYPE.JSON}catch(o){this.abort("Error trying to parse loaded json: "+o);return}else if(this.xhrType===i.XHR_RESPONSE_TYPE.DOCUMENT)try{if(globalThis.DOMParser){var s=new DOMParser;this.data=s.parseFromString(e,"text/xml")}else{var a=document.createElement("div");a.innerHTML=e,this.data=a}this.type=i.TYPE.XML}catch(o){this.abort("Error trying to parse loaded xml: "+o);return}else this.data=t.response||e;else{this.abort("["+t.status+"] "+t.statusText+": "+t.responseURL);return}this.complete()},i.prototype._determineCrossOrigin=function(t,e){if(t.indexOf("data:")===0)return"";if(globalThis.origin!==globalThis.location.origin)return"anonymous";e=e||globalThis.location,on||(on=document.createElement("a")),on.href=t;var r=Fl(on.href,{strictMode:!0}),n=!r.port&&e.port===""||r.port===e.port,s=r.protocol?r.protocol+":":"";return r.host!==e.hostname||!n||s!==e.protocol?"anonymous":""},i.prototype._determineXhrType=function(){return i._xhrTypeMap[this.extension]||i.XHR_RESPONSE_TYPE.TEXT},i.prototype._determineLoadType=function(){return i._loadTypeMap[this.extension]||i.LOAD_TYPE.XHR},i.prototype._getExtension=function(t){t===void 0&&(t=this.url);var e="";if(this.isDataUrl){var r=t.indexOf("/");e=t.substring(r+1,t.indexOf(";",r))}else{var n=t.indexOf("?"),s=t.indexOf("#"),a=Math.min(n>-1?n:t.length,s>-1?s:t.length);t=t.substring(0,a),e=t.substring(t.lastIndexOf(".")+1)}return e.toLowerCase()},i.prototype._getMimeFromXhrType=function(t){switch(t){case i.XHR_RESPONSE_TYPE.BUFFER:return"application/octet-binary";case i.XHR_RESPONSE_TYPE.BLOB:return"application/blob";case i.XHR_RESPONSE_TYPE.DOCUMENT:return"application/xml";case i.XHR_RESPONSE_TYPE.JSON:return"application/json";case i.XHR_RESPONSE_TYPE.DEFAULT:case i.XHR_RESPONSE_TYPE.TEXT:default:return"text/plain"}},i}();(function(i){(function(t){t[t.NONE=0]="NONE",t[t.DATA_URL=1]="DATA_URL",t[t.COMPLETE=2]="COMPLETE",t[t.LOADING=4]="LOADING"})(i.STATUS_FLAGS||(i.STATUS_FLAGS={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.JSON=1]="JSON",t[t.XML=2]="XML",t[t.IMAGE=3]="IMAGE",t[t.AUDIO=4]="AUDIO",t[t.VIDEO=5]="VIDEO",t[t.TEXT=6]="TEXT"}(i.TYPE||(i.TYPE={})),function(t){t[t.XHR=1]="XHR",t[t.IMAGE=2]="IMAGE",t[t.AUDIO=3]="AUDIO",t[t.VIDEO=4]="VIDEO"}(i.LOAD_TYPE||(i.LOAD_TYPE={})),function(t){t.DEFAULT="text",t.BUFFER="arraybuffer",t.BLOB="blob",t.DOCUMENT="document",t.JSON="json",t.TEXT="text"}(i.XHR_RESPONSE_TYPE||(i.XHR_RESPONSE_TYPE={})),i._loadTypeMap={gif:i.LOAD_TYPE.IMAGE,png:i.LOAD_TYPE.IMAGE,bmp:i.LOAD_TYPE.IMAGE,jpg:i.LOAD_TYPE.IMAGE,jpeg:i.LOAD_TYPE.IMAGE,tif:i.LOAD_TYPE.IMAGE,tiff:i.LOAD_TYPE.IMAGE,webp:i.LOAD_TYPE.IMAGE,tga:i.LOAD_TYPE.IMAGE,avif:i.LOAD_TYPE.IMAGE,svg:i.LOAD_TYPE.IMAGE,"svg+xml":i.LOAD_TYPE.IMAGE,mp3:i.LOAD_TYPE.AUDIO,ogg:i.LOAD_TYPE.AUDIO,wav:i.LOAD_TYPE.AUDIO,mp4:i.LOAD_TYPE.VIDEO,webm:i.LOAD_TYPE.VIDEO},i._xhrTypeMap={xhtml:i.XHR_RESPONSE_TYPE.DOCUMENT,html:i.XHR_RESPONSE_TYPE.DOCUMENT,htm:i.XHR_RESPONSE_TYPE.DOCUMENT,xml:i.XHR_RESPONSE_TYPE.DOCUMENT,tmx:i.XHR_RESPONSE_TYPE.DOCUMENT,svg:i.XHR_RESPONSE_TYPE.DOCUMENT,tsx:i.XHR_RESPONSE_TYPE.DOCUMENT,gif:i.XHR_RESPONSE_TYPE.BLOB,png:i.XHR_RESPONSE_TYPE.BLOB,bmp:i.XHR_RESPONSE_TYPE.BLOB,jpg:i.XHR_RESPONSE_TYPE.BLOB,jpeg:i.XHR_RESPONSE_TYPE.BLOB,tif:i.XHR_RESPONSE_TYPE.BLOB,tiff:i.XHR_RESPONSE_TYPE.BLOB,webp:i.XHR_RESPONSE_TYPE.BLOB,tga:i.XHR_RESPONSE_TYPE.BLOB,avif:i.XHR_RESPONSE_TYPE.BLOB,json:i.XHR_RESPONSE_TYPE.JSON,text:i.XHR_RESPONSE_TYPE.TEXT,txt:i.XHR_RESPONSE_TYPE.TEXT,ttf:i.XHR_RESPONSE_TYPE.BUFFER,otf:i.XHR_RESPONSE_TYPE.BUFFER},i.EMPTY_GIF="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="})(wt||(wt={}));function or(){}function Im(i){return function(){for(var e=arguments,r=[],n=0;n<arguments.length;n++)r[n]=e[n];if(i===null)throw new Error("Callback was already called.");var s=i;i=null,s.apply(this,r)}}var Am=function(){function i(t,e){this.data=t,this.callback=e}return i}(),za=function(){function i(t,e){var r=this;if(e===void 0&&(e=1),this.workers=0,this.saturated=or,this.unsaturated=or,this.empty=or,this.drain=or,this.error=or,this.started=!1,this.paused=!1,this._tasks=[],this._insert=function(n,s,a){if(a&&typeof a!="function")throw new Error("task callback must be a function");if(r.started=!0,n==null&&r.idle()){setTimeout(function(){return r.drain()},1);return}var o=new Am(n,typeof a=="function"?a:or);s?r._tasks.unshift(o):r._tasks.push(o),setTimeout(r.process,1)},this.process=function(){for(;!r.paused&&r.workers<r.concurrency&&r._tasks.length;){var n=r._tasks.shift();r._tasks.length===0&&r.empty(),r.workers+=1,r.workers===r.concurrency&&r.saturated(),r._worker(n.data,Im(r._next(n)))}},this._worker=t,e===0)throw new Error("Concurrency must not be zero");this.concurrency=e,this.buffer=e/4}return i.prototype._next=function(t){var e=this;return function(){for(var r=arguments,n=[],s=0;s<arguments.length;s++)n[s]=r[s];e.workers-=1,t.callback.apply(t,n),n[0]!=null&&e.error(n[0],t.data),e.workers<=e.concurrency-e.buffer&&e.unsaturated(),e.idle()&&e.drain(),e.process()}},i.prototype.push=function(t,e){this._insert(t,!1,e)},i.prototype.kill=function(){this.workers=0,this.drain=or,this.started=!1,this._tasks=[]},i.prototype.unshift=function(t,e){this._insert(t,!0,e)},i.prototype.length=function(){return this._tasks.length},i.prototype.running=function(){return this.workers},i.prototype.idle=function(){return this._tasks.length+this.workers===0},i.prototype.pause=function(){this.paused!==!0&&(this.paused=!0)},i.prototype.resume=function(){if(this.paused!==!1){this.paused=!1;for(var t=1;t<=this.concurrency;t++)this.process()}},i.eachSeries=function(t,e,r,n){var s=0,a=t.length;function o(h){if(h||s===a){r&&r(h);return}n?setTimeout(function(){e(t[s++],o)},1):e(t[s++],o)}o()},i.queue=function(t,e){return new i(t,e)},i}(),Wa=100,Mm=/(#[\w-]+)?$/,ui=function(){function i(t,e){var r=this;t===void 0&&(t=""),e===void 0&&(e=10),this.progress=0,this.loading=!1,this.defaultQueryString="",this._beforeMiddleware=[],this._afterMiddleware=[],this._resourcesParsing=[],this._boundLoadResource=function(h,u){return r._loadResource(h,u)},this.resources={},this.baseUrl=t,this._beforeMiddleware=[],this._afterMiddleware=[],this._resourcesParsing=[],this._boundLoadResource=function(h,u){return r._loadResource(h,u)},this._queue=za.queue(this._boundLoadResource,e),this._queue.pause(),this.resources={},this.onProgress=new Ee,this.onError=new Ee,this.onLoad=new Ee,this.onStart=new Ee,this.onComplete=new Ee;for(var n=0;n<i._plugins.length;++n){var s=i._plugins[n],a=s.pre,o=s.use;a&&this.pre(a),o&&this.use(o)}this._protected=!1}return i.prototype._add=function(t,e,r,n){if(this.loading&&(!r||!r.parentResource))throw new Error("Cannot add resources while the loader is running.");if(this.resources[t])throw new Error('Resource named "'+t+'" already exists.');if(e=this._prepareUrl(e),this.resources[t]=new wt(t,e,r),typeof n=="function"&&this.resources[t].onAfterMiddleware.once(n),this.loading){for(var s=r.parentResource,a=[],o=0;o<s.children.length;++o)s.children[o].isComplete||a.push(s.children[o]);var h=s.progressChunk*(a.length+1),u=h/(a.length+2);s.children.push(this.resources[t]),s.progressChunk=u;for(var o=0;o<a.length;++o)a[o].progressChunk=u;this.resources[t].progressChunk=u}return this._queue.push(this.resources[t]),this},i.prototype.pre=function(t){return this._beforeMiddleware.push(t),this},i.prototype.use=function(t){return this._afterMiddleware.push(t),this},i.prototype.reset=function(){this.progress=0,this.loading=!1,this._queue.kill(),this._queue.pause();for(var t in this.resources){var e=this.resources[t];e._onLoadBinding&&e._onLoadBinding.detach(),e.isLoading&&e.abort("loader reset")}return this.resources={},this},i.prototype.load=function(t){if(Bt("6.5.0","@pixi/loaders is being replaced with @pixi/assets in the next major release."),typeof t=="function"&&this.onComplete.once(t),this.loading)return this;if(this._queue.idle())this._onStart(),this._onComplete();else{for(var e=this._queue._tasks.length,r=Wa/e,n=0;n<this._queue._tasks.length;++n)this._queue._tasks[n].data.progressChunk=r;this._onStart(),this._queue.resume()}return this},Object.defineProperty(i.prototype,"concurrency",{get:function(){return this._queue.concurrency},set:function(t){this._queue.concurrency=t},enumerable:!1,configurable:!0}),i.prototype._prepareUrl=function(t){var e=Fl(t,{strictMode:!0}),r;if(e.protocol||!e.path||t.indexOf("//")===0?r=t:this.baseUrl.length&&this.baseUrl.lastIndexOf("/")!==this.baseUrl.length-1&&t.charAt(0)!=="/"?r=this.baseUrl+"/"+t:r=this.baseUrl+t,this.defaultQueryString){var n=Mm.exec(r)[0];r=r.slice(0,r.length-n.length),r.indexOf("?")!==-1?r+="&"+this.defaultQueryString:r+="?"+this.defaultQueryString,r+=n}return r},i.prototype._loadResource=function(t,e){var r=this;t._dequeue=e,za.eachSeries(this._beforeMiddleware,function(n,s){n.call(r,t,function(){s(t.isComplete?{}:null)})},function(){t.isComplete?r._onLoad(t):(t._onLoadBinding=t.onComplete.once(r._onLoad,r),t.load())},!0)},i.prototype._onStart=function(){this.progress=0,this.loading=!0,this.onStart.dispatch(this)},i.prototype._onComplete=function(){this.progress=Wa,this.loading=!1,this.onComplete.dispatch(this,this.resources)},i.prototype._onLoad=function(t){var e=this;t._onLoadBinding=null,this._resourcesParsing.push(t),t._dequeue(),za.eachSeries(this._afterMiddleware,function(r,n){r.call(e,t,n)},function(){t.onAfterMiddleware.dispatch(t),e.progress=Math.min(Wa,e.progress+t.progressChunk),e.onProgress.dispatch(e,t),t.error?e.onError.dispatch(t.error,e,t):e.onLoad.dispatch(e,t),e._resourcesParsing.splice(e._resourcesParsing.indexOf(t),1),e._queue.idle()&&e._resourcesParsing.length===0&&e._onComplete()},!0)},i.prototype.destroy=function(){this._protected||this.reset()},Object.defineProperty(i,"shared",{get:function(){var t=i._shared;return t||(t=new i,t._protected=!0,i._shared=t),t},enumerable:!1,configurable:!0}),i.registerPlugin=function(t){return Bt("6.5.0","Loader.registerPlugin() is deprecated, use extensions.add() instead."),Kt.add({type:dt.Loader,ref:t}),i},i._plugins=[],i}();Kt.handleByList(dt.Loader,ui._plugins),ui.prototype.add=function(t,e,r,n){if(Array.isArray(t)){for(var s=0;s<t.length;++s)this.add(t[s]);return this}if(typeof t=="object"&&(r=t,n=e||r.callback||r.onComplete,e=r.url,t=r.name||r.key||r.url),typeof e!="string"&&(n=r,r=e,e=t),typeof e!="string")throw new Error("No url passed to add resource to loader.");return typeof r=="function"&&(n=r,r=null),this._add(t,e,r,n)};var Ul=function(){function i(){}return i.init=function(t){t=Object.assign({sharedLoader:!1},t),this.loader=t.sharedLoader?ui.shared:new ui},i.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},i.extension=dt.Application,i}(),kl=function(){function i(){}return i.add=function(){wt.setExtensionLoadType("svg",wt.LOAD_TYPE.XHR),wt.setExtensionXhrType("svg",wt.XHR_RESPONSE_TYPE.TEXT)},i.use=function(t,e){if(t.data&&(t.type===wt.TYPE.IMAGE||t.extension==="svg")){var r=t.data,n=t.url,s=t.name,a=t.metadata;it.fromLoader(r,n,s,a).then(function(o){t.texture=o,e()}).catch(e)}else e()},i.extension=dt.Loader,i}(),Rm="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Om(i){for(var t="",e=0;e<i.length;){for(var r=[0,0,0],n=[0,0,0,0],s=0;s<r.length;++s)e<i.length?r[s]=i.charCodeAt(e++)&255:r[s]=0;n[0]=r[0]>>2,n[1]=(r[0]&3)<<4|r[1]>>4,n[2]=(r[1]&15)<<2|r[2]>>6,n[3]=r[2]&63;var a=e-(i.length-1);switch(a){case 2:n[3]=64,n[2]=64;break;case 1:n[3]=64;break}for(var s=0;s<n.length;++s)t+=Rm.charAt(n[s])}return t}function Dm(i,t){if(!i.data){t();return}if(i.xhr&&i.xhrType===wt.XHR_RESPONSE_TYPE.BLOB){if(!self.Blob||typeof i.data=="string"){var e=i.xhr.getResponseHeader("content-type");if(e&&e.indexOf("image")===0){i.data=new Image,i.data.src="data:"+e+";base64,"+Om(i.xhr.responseText),i.type=wt.TYPE.IMAGE,i.data.onload=function(){i.data.onload=null,t()};return}}else if(i.data.type.indexOf("image")===0){var r=globalThis.URL||globalThis.webkitURL,n=r.createObjectURL(i.data);i.blob=i.data,i.data=new Image,i.data.src=n,i.type=wt.TYPE.IMAGE,i.data.onload=function(){r.revokeObjectURL(n),i.data.onload=null,t()};return}}t()}var Fm=function(){function i(){}return i.extension=dt.Loader,i.use=Dm,i}();Kt.add(kl,Fm);var pt,at;(function(i){i[i.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",i[i.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",i[i.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",i[i.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",i[i.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",i[i.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",i[i.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",i[i.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",i[i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",i[i.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",i[i.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",i[i.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR"})(at||(at={}));var li=(pt={},pt[at.COMPRESSED_RGB_S3TC_DXT1_EXT]=.5,pt[at.COMPRESSED_RGBA_S3TC_DXT1_EXT]=.5,pt[at.COMPRESSED_RGBA_S3TC_DXT3_EXT]=1,pt[at.COMPRESSED_RGBA_S3TC_DXT5_EXT]=1,pt[at.COMPRESSED_SRGB_S3TC_DXT1_EXT]=.5,pt[at.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT]=.5,pt[at.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT]=1,pt[at.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT]=1,pt[at.COMPRESSED_R11_EAC]=.5,pt[at.COMPRESSED_SIGNED_R11_EAC]=.5,pt[at.COMPRESSED_RG11_EAC]=1,pt[at.COMPRESSED_SIGNED_RG11_EAC]=1,pt[at.COMPRESSED_RGB8_ETC2]=.5,pt[at.COMPRESSED_RGBA8_ETC2_EAC]=1,pt[at.COMPRESSED_SRGB8_ETC2]=.5,pt[at.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC]=1,pt[at.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2]=.5,pt[at.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2]=.5,pt[at.COMPRESSED_RGB_PVRTC_4BPPV1_IMG]=.5,pt[at.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG]=.5,pt[at.COMPRESSED_RGB_PVRTC_2BPPV1_IMG]=.25,pt[at.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG]=.25,pt[at.COMPRESSED_RGB_ETC1_WEBGL]=.5,pt[at.COMPRESSED_RGB_ATC_WEBGL]=.5,pt[at.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL]=1,pt[at.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL]=1,pt[at.COMPRESSED_RGBA_ASTC_4x4_KHR]=1,pt);var Ya=function(i,t){return Ya=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},Ya(i,t)};function Gl(i,t){Ya(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function Lm(i,t,e,r){function n(s){return s instanceof e?s:new e(function(a){a(s)})}return new(e||(e=Promise))(function(s,a){function o(l){try{u(r.next(l))}catch(c){a(c)}}function h(l){try{u(r.throw(l))}catch(c){a(c)}}function u(l){l.done?s(l.value):n(l.value).then(o,h)}u((r=r.apply(i,[])).next())})}function Bm(i,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,n,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(u){return function(l){return h([u,l])}}function h(u){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,n&&(s=u[0]&2?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return e.label++,{value:u[1],done:!1};case 5:e.label++,n=u[1],u=[0];continue;case 7:u=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){e.label=u[1];break}if(u[0]===6&&e.label<s[1]){e.label=s[1],s=u;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(u);break}s[2]&&e.ops.pop(),e.trys.pop();continue}u=t.call(i,e)}catch(l){u=[6,l],n=0}finally{r=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}var Xl=function(i){Gl(t,i);function t(e,r){r===void 0&&(r={width:1,height:1,autoLoad:!0});var n=this,s,a;return typeof e=="string"?(s=e,a=new Uint8Array):(s=null,a=e),n=i.call(this,a,r)||this,n.origin=s,n.buffer=a?new zi(a):null,n.origin&&r.autoLoad!==!1&&n.load(),a&&a.length&&(n.loaded=!0,n.onBlobLoaded(n.buffer.rawBinaryData)),n}return t.prototype.onBlobLoaded=function(e){},t.prototype.load=function(){return Lm(this,void 0,Promise,function(){var e,r,n;return Bm(this,function(s){switch(s.label){case 0:return[4,fetch(this.origin)];case 1:return e=s.sent(),[4,e.blob()];case 2:return r=s.sent(),[4,r.arrayBuffer()];case 3:return n=s.sent(),this.data=new Uint32Array(n),this.buffer=new zi(n),this.loaded=!0,this.onBlobLoaded(n),this.update(),[2,this]}})})},t}(Ke),hn=function(i){Gl(t,i);function t(e,r){var n=i.call(this,e,r)||this;return n.format=r.format,n.levels=r.levels||1,n._width=r.width,n._height=r.height,n._extension=t._formatToExtension(n.format),(r.levelBuffers||n.buffer)&&(n._levelBuffers=r.levelBuffers||t._createLevelBuffers(e instanceof Uint8Array?e:n.buffer.uint8View,n.format,n.levels,4,4,n.width,n.height)),n}return t.prototype.upload=function(e,r,n){var s=e.gl,a=e.context.extensions[this._extension];if(!a)throw new Error(this._extension+" textures are not supported on the current machine");if(!this._levelBuffers)return!1;for(var o=0,h=this.levels;o<h;o++){var u=this._levelBuffers[o],l=u.levelID,c=u.levelWidth,f=u.levelHeight,d=u.levelBuffer;s.compressedTexImage2D(s.TEXTURE_2D,l,this.format,c,f,0,d)}return!0},t.prototype.onBlobLoaded=function(){this._levelBuffers=t._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)},t._formatToExtension=function(e){if(e>=33776&&e<=33779)return"s3tc";if(e>=37488&&e<=37497)return"etc";if(e>=35840&&e<=35843)return"pvrtc";if(e>=36196)return"etc1";if(e>=35986&&e<=34798)return"atc";throw new Error("Invalid (compressed) texture format given!")},t._createLevelBuffers=function(e,r,n,s,a,o,h){for(var u=new Array(n),l=e.byteOffset,c=o,f=h,d=c+s-1&~(s-1),v=f+a-1&~(a-1),_=d*v*li[r],p=0;p<n;p++)u[p]={levelID:p,levelWidth:n>1?c:d,levelHeight:n>1?f:v,levelBuffer:new Uint8Array(e.buffer,l,_)},l+=_,c=c>>1||1,f=f>>1||1,d=c+s-1&~(s-1),v=f+a-1&~(a-1),_=d*v*li[r];return u},t}(Xl),Hl=function(){function i(){}return i.use=function(t,e){var r=t.data,n=this;if(t.type===wt.TYPE.JSON&&r&&r.cacheID&&r.textures){for(var s=r.textures,a=void 0,o=void 0,h=0,u=s.length;h<u;h++){var l=s[h],c=l.src,f=l.format;if(f||(o=c),i.textureFormats[f]){a=c;break}}if(a=a||o,!a){e(new Error("Cannot load compressed-textures in "+t.url+", make sure you provide a fallback"));return}if(a===t.url){e(new Error("URL of compressed texture cannot be the same as the manifest's URL"));return}var d={crossOrigin:t.crossOrigin,metadata:t.metadata.imageMetadata,parentResource:t},v=ce.resolve(t.url.replace(n.baseUrl,""),a),_=r.cacheID;n.add(_,v,d,function(p){if(p.error){e(p.error);return}var g=p.texture,y=g===void 0?null:g,T=p.textures,I=T===void 0?{}:T;Object.assign(t,{texture:y,textures:I}),e()})}else e()},Object.defineProperty(i,"textureExtensions",{get:function(){if(!i._textureExtensions){var t=z.ADAPTER.createCanvas(),e=t.getContext("webgl");if(!e)return console.warn("WebGL not available for compressed textures. Silently failing."),{};var r={s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc")};i._textureExtensions=r}return i._textureExtensions},enumerable:!1,configurable:!0}),Object.defineProperty(i,"textureFormats",{get:function(){if(!i._textureFormats){var t=i.textureExtensions;i._textureFormats={};for(var e in t){var r=t[e];r&&Object.assign(i._textureFormats,Object.getPrototypeOf(r))}}return i._textureFormats},enumerable:!1,configurable:!0}),i.extension=dt.Loader,i}();function Vl(i,t,e){var r={textures:{},texture:null};if(!t)return r;var n=t.map(function(s){return new it(new lt(s,Object.assign({mipmap:zt.OFF,alphaMode:Wt.NO_PREMULTIPLIED_ALPHA},e)))});return n.forEach(function(s,a){var o=s.baseTexture,h=i+"-"+(a+1);lt.addToCache(o,h),it.addToCache(s,h),a===0&&(lt.addToCache(o,i),it.addToCache(s,i),r.texture=s),r.textures[h]=s}),r}var fi,oe,qa=4,un=124,Nm=32,jl=20,Um=542327876,ln={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},km={FOURCC:2},fn={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},he;(function(i){i[i.DXGI_FORMAT_UNKNOWN=0]="DXGI_FORMAT_UNKNOWN",i[i.DXGI_FORMAT_R32G32B32A32_TYPELESS=1]="DXGI_FORMAT_R32G32B32A32_TYPELESS",i[i.DXGI_FORMAT_R32G32B32A32_FLOAT=2]="DXGI_FORMAT_R32G32B32A32_FLOAT",i[i.DXGI_FORMAT_R32G32B32A32_UINT=3]="DXGI_FORMAT_R32G32B32A32_UINT",i[i.DXGI_FORMAT_R32G32B32A32_SINT=4]="DXGI_FORMAT_R32G32B32A32_SINT",i[i.DXGI_FORMAT_R32G32B32_TYPELESS=5]="DXGI_FORMAT_R32G32B32_TYPELESS",i[i.DXGI_FORMAT_R32G32B32_FLOAT=6]="DXGI_FORMAT_R32G32B32_FLOAT",i[i.DXGI_FORMAT_R32G32B32_UINT=7]="DXGI_FORMAT_R32G32B32_UINT",i[i.DXGI_FORMAT_R32G32B32_SINT=8]="DXGI_FORMAT_R32G32B32_SINT",i[i.DXGI_FORMAT_R16G16B16A16_TYPELESS=9]="DXGI_FORMAT_R16G16B16A16_TYPELESS",i[i.DXGI_FORMAT_R16G16B16A16_FLOAT=10]="DXGI_FORMAT_R16G16B16A16_FLOAT",i[i.DXGI_FORMAT_R16G16B16A16_UNORM=11]="DXGI_FORMAT_R16G16B16A16_UNORM",i[i.DXGI_FORMAT_R16G16B16A16_UINT=12]="DXGI_FORMAT_R16G16B16A16_UINT",i[i.DXGI_FORMAT_R16G16B16A16_SNORM=13]="DXGI_FORMAT_R16G16B16A16_SNORM",i[i.DXGI_FORMAT_R16G16B16A16_SINT=14]="DXGI_FORMAT_R16G16B16A16_SINT",i[i.DXGI_FORMAT_R32G32_TYPELESS=15]="DXGI_FORMAT_R32G32_TYPELESS",i[i.DXGI_FORMAT_R32G32_FLOAT=16]="DXGI_FORMAT_R32G32_FLOAT",i[i.DXGI_FORMAT_R32G32_UINT=17]="DXGI_FORMAT_R32G32_UINT",i[i.DXGI_FORMAT_R32G32_SINT=18]="DXGI_FORMAT_R32G32_SINT",i[i.DXGI_FORMAT_R32G8X24_TYPELESS=19]="DXGI_FORMAT_R32G8X24_TYPELESS",i[i.DXGI_FORMAT_D32_FLOAT_S8X24_UINT=20]="DXGI_FORMAT_D32_FLOAT_S8X24_UINT",i[i.DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS=21]="DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS",i[i.DXGI_FORMAT_X32_TYPELESS_G8X24_UINT=22]="DXGI_FORMAT_X32_TYPELESS_G8X24_UINT",i[i.DXGI_FORMAT_R10G10B10A2_TYPELESS=23]="DXGI_FORMAT_R10G10B10A2_TYPELESS",i[i.DXGI_FORMAT_R10G10B10A2_UNORM=24]="DXGI_FORMAT_R10G10B10A2_UNORM",i[i.DXGI_FORMAT_R10G10B10A2_UINT=25]="DXGI_FORMAT_R10G10B10A2_UINT",i[i.DXGI_FORMAT_R11G11B10_FLOAT=26]="DXGI_FORMAT_R11G11B10_FLOAT",i[i.DXGI_FORMAT_R8G8B8A8_TYPELESS=27]="DXGI_FORMAT_R8G8B8A8_TYPELESS",i[i.DXGI_FORMAT_R8G8B8A8_UNORM=28]="DXGI_FORMAT_R8G8B8A8_UNORM",i[i.DXGI_FORMAT_R8G8B8A8_UNORM_SRGB=29]="DXGI_FORMAT_R8G8B8A8_UNORM_SRGB",i[i.DXGI_FORMAT_R8G8B8A8_UINT=30]="DXGI_FORMAT_R8G8B8A8_UINT",i[i.DXGI_FORMAT_R8G8B8A8_SNORM=31]="DXGI_FORMAT_R8G8B8A8_SNORM",i[i.DXGI_FORMAT_R8G8B8A8_SINT=32]="DXGI_FORMAT_R8G8B8A8_SINT",i[i.DXGI_FORMAT_R16G16_TYPELESS=33]="DXGI_FORMAT_R16G16_TYPELESS",i[i.DXGI_FORMAT_R16G16_FLOAT=34]="DXGI_FORMAT_R16G16_FLOAT",i[i.DXGI_FORMAT_R16G16_UNORM=35]="DXGI_FORMAT_R16G16_UNORM",i[i.DXGI_FORMAT_R16G16_UINT=36]="DXGI_FORMAT_R16G16_UINT",i[i.DXGI_FORMAT_R16G16_SNORM=37]="DXGI_FORMAT_R16G16_SNORM",i[i.DXGI_FORMAT_R16G16_SINT=38]="DXGI_FORMAT_R16G16_SINT",i[i.DXGI_FORMAT_R32_TYPELESS=39]="DXGI_FORMAT_R32_TYPELESS",i[i.DXGI_FORMAT_D32_FLOAT=40]="DXGI_FORMAT_D32_FLOAT",i[i.DXGI_FORMAT_R32_FLOAT=41]="DXGI_FORMAT_R32_FLOAT",i[i.DXGI_FORMAT_R32_UINT=42]="DXGI_FORMAT_R32_UINT",i[i.DXGI_FORMAT_R32_SINT=43]="DXGI_FORMAT_R32_SINT",i[i.DXGI_FORMAT_R24G8_TYPELESS=44]="DXGI_FORMAT_R24G8_TYPELESS",i[i.DXGI_FORMAT_D24_UNORM_S8_UINT=45]="DXGI_FORMAT_D24_UNORM_S8_UINT",i[i.DXGI_FORMAT_R24_UNORM_X8_TYPELESS=46]="DXGI_FORMAT_R24_UNORM_X8_TYPELESS",i[i.DXGI_FORMAT_X24_TYPELESS_G8_UINT=47]="DXGI_FORMAT_X24_TYPELESS_G8_UINT",i[i.DXGI_FORMAT_R8G8_TYPELESS=48]="DXGI_FORMAT_R8G8_TYPELESS",i[i.DXGI_FORMAT_R8G8_UNORM=49]="DXGI_FORMAT_R8G8_UNORM",i[i.DXGI_FORMAT_R8G8_UINT=50]="DXGI_FORMAT_R8G8_UINT",i[i.DXGI_FORMAT_R8G8_SNORM=51]="DXGI_FORMAT_R8G8_SNORM",i[i.DXGI_FORMAT_R8G8_SINT=52]="DXGI_FORMAT_R8G8_SINT",i[i.DXGI_FORMAT_R16_TYPELESS=53]="DXGI_FORMAT_R16_TYPELESS",i[i.DXGI_FORMAT_R16_FLOAT=54]="DXGI_FORMAT_R16_FLOAT",i[i.DXGI_FORMAT_D16_UNORM=55]="DXGI_FORMAT_D16_UNORM",i[i.DXGI_FORMAT_R16_UNORM=56]="DXGI_FORMAT_R16_UNORM",i[i.DXGI_FORMAT_R16_UINT=57]="DXGI_FORMAT_R16_UINT",i[i.DXGI_FORMAT_R16_SNORM=58]="DXGI_FORMAT_R16_SNORM",i[i.DXGI_FORMAT_R16_SINT=59]="DXGI_FORMAT_R16_SINT",i[i.DXGI_FORMAT_R8_TYPELESS=60]="DXGI_FORMAT_R8_TYPELESS",i[i.DXGI_FORMAT_R8_UNORM=61]="DXGI_FORMAT_R8_UNORM",i[i.DXGI_FORMAT_R8_UINT=62]="DXGI_FORMAT_R8_UINT",i[i.DXGI_FORMAT_R8_SNORM=63]="DXGI_FORMAT_R8_SNORM",i[i.DXGI_FORMAT_R8_SINT=64]="DXGI_FORMAT_R8_SINT",i[i.DXGI_FORMAT_A8_UNORM=65]="DXGI_FORMAT_A8_UNORM",i[i.DXGI_FORMAT_R1_UNORM=66]="DXGI_FORMAT_R1_UNORM",i[i.DXGI_FORMAT_R9G9B9E5_SHAREDEXP=67]="DXGI_FORMAT_R9G9B9E5_SHAREDEXP",i[i.DXGI_FORMAT_R8G8_B8G8_UNORM=68]="DXGI_FORMAT_R8G8_B8G8_UNORM",i[i.DXGI_FORMAT_G8R8_G8B8_UNORM=69]="DXGI_FORMAT_G8R8_G8B8_UNORM",i[i.DXGI_FORMAT_BC1_TYPELESS=70]="DXGI_FORMAT_BC1_TYPELESS",i[i.DXGI_FORMAT_BC1_UNORM=71]="DXGI_FORMAT_BC1_UNORM",i[i.DXGI_FORMAT_BC1_UNORM_SRGB=72]="DXGI_FORMAT_BC1_UNORM_SRGB",i[i.DXGI_FORMAT_BC2_TYPELESS=73]="DXGI_FORMAT_BC2_TYPELESS",i[i.DXGI_FORMAT_BC2_UNORM=74]="DXGI_FORMAT_BC2_UNORM",i[i.DXGI_FORMAT_BC2_UNORM_SRGB=75]="DXGI_FORMAT_BC2_UNORM_SRGB",i[i.DXGI_FORMAT_BC3_TYPELESS=76]="DXGI_FORMAT_BC3_TYPELESS",i[i.DXGI_FORMAT_BC3_UNORM=77]="DXGI_FORMAT_BC3_UNORM",i[i.DXGI_FORMAT_BC3_UNORM_SRGB=78]="DXGI_FORMAT_BC3_UNORM_SRGB",i[i.DXGI_FORMAT_BC4_TYPELESS=79]="DXGI_FORMAT_BC4_TYPELESS",i[i.DXGI_FORMAT_BC4_UNORM=80]="DXGI_FORMAT_BC4_UNORM",i[i.DXGI_FORMAT_BC4_SNORM=81]="DXGI_FORMAT_BC4_SNORM",i[i.DXGI_FORMAT_BC5_TYPELESS=82]="DXGI_FORMAT_BC5_TYPELESS",i[i.DXGI_FORMAT_BC5_UNORM=83]="DXGI_FORMAT_BC5_UNORM",i[i.DXGI_FORMAT_BC5_SNORM=84]="DXGI_FORMAT_BC5_SNORM",i[i.DXGI_FORMAT_B5G6R5_UNORM=85]="DXGI_FORMAT_B5G6R5_UNORM",i[i.DXGI_FORMAT_B5G5R5A1_UNORM=86]="DXGI_FORMAT_B5G5R5A1_UNORM",i[i.DXGI_FORMAT_B8G8R8A8_UNORM=87]="DXGI_FORMAT_B8G8R8A8_UNORM",i[i.DXGI_FORMAT_B8G8R8X8_UNORM=88]="DXGI_FORMAT_B8G8R8X8_UNORM",i[i.DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM=89]="DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM",i[i.DXGI_FORMAT_B8G8R8A8_TYPELESS=90]="DXGI_FORMAT_B8G8R8A8_TYPELESS",i[i.DXGI_FORMAT_B8G8R8A8_UNORM_SRGB=91]="DXGI_FORMAT_B8G8R8A8_UNORM_SRGB",i[i.DXGI_FORMAT_B8G8R8X8_TYPELESS=92]="DXGI_FORMAT_B8G8R8X8_TYPELESS",i[i.DXGI_FORMAT_B8G8R8X8_UNORM_SRGB=93]="DXGI_FORMAT_B8G8R8X8_UNORM_SRGB",i[i.DXGI_FORMAT_BC6H_TYPELESS=94]="DXGI_FORMAT_BC6H_TYPELESS",i[i.DXGI_FORMAT_BC6H_UF16=95]="DXGI_FORMAT_BC6H_UF16",i[i.DXGI_FORMAT_BC6H_SF16=96]="DXGI_FORMAT_BC6H_SF16",i[i.DXGI_FORMAT_BC7_TYPELESS=97]="DXGI_FORMAT_BC7_TYPELESS",i[i.DXGI_FORMAT_BC7_UNORM=98]="DXGI_FORMAT_BC7_UNORM",i[i.DXGI_FORMAT_BC7_UNORM_SRGB=99]="DXGI_FORMAT_BC7_UNORM_SRGB",i[i.DXGI_FORMAT_AYUV=100]="DXGI_FORMAT_AYUV",i[i.DXGI_FORMAT_Y410=101]="DXGI_FORMAT_Y410",i[i.DXGI_FORMAT_Y416=102]="DXGI_FORMAT_Y416",i[i.DXGI_FORMAT_NV12=103]="DXGI_FORMAT_NV12",i[i.DXGI_FORMAT_P010=104]="DXGI_FORMAT_P010",i[i.DXGI_FORMAT_P016=105]="DXGI_FORMAT_P016",i[i.DXGI_FORMAT_420_OPAQUE=106]="DXGI_FORMAT_420_OPAQUE",i[i.DXGI_FORMAT_YUY2=107]="DXGI_FORMAT_YUY2",i[i.DXGI_FORMAT_Y210=108]="DXGI_FORMAT_Y210",i[i.DXGI_FORMAT_Y216=109]="DXGI_FORMAT_Y216",i[i.DXGI_FORMAT_NV11=110]="DXGI_FORMAT_NV11",i[i.DXGI_FORMAT_AI44=111]="DXGI_FORMAT_AI44",i[i.DXGI_FORMAT_IA44=112]="DXGI_FORMAT_IA44",i[i.DXGI_FORMAT_P8=113]="DXGI_FORMAT_P8",i[i.DXGI_FORMAT_A8P8=114]="DXGI_FORMAT_A8P8",i[i.DXGI_FORMAT_B4G4R4A4_UNORM=115]="DXGI_FORMAT_B4G4R4A4_UNORM",i[i.DXGI_FORMAT_P208=116]="DXGI_FORMAT_P208",i[i.DXGI_FORMAT_V208=117]="DXGI_FORMAT_V208",i[i.DXGI_FORMAT_V408=118]="DXGI_FORMAT_V408",i[i.DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE=119]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE",i[i.DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE=120]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE",i[i.DXGI_FORMAT_FORCE_UINT=121]="DXGI_FORMAT_FORCE_UINT"})(he||(he={}));var $a;(function(i){i[i.DDS_DIMENSION_TEXTURE1D=2]="DDS_DIMENSION_TEXTURE1D",i[i.DDS_DIMENSION_TEXTURE2D=3]="DDS_DIMENSION_TEXTURE2D",i[i.DDS_DIMENSION_TEXTURE3D=6]="DDS_DIMENSION_TEXTURE3D"})($a||($a={}));var Gm=1,Xm=2,Hm=4,Vm=64,jm=512,zm=131072,Wm=827611204,Ym=861165636,qm=894720068,$m=808540228,Km=4,Zm=(fi={},fi[Wm]=at.COMPRESSED_RGBA_S3TC_DXT1_EXT,fi[Ym]=at.COMPRESSED_RGBA_S3TC_DXT3_EXT,fi[qm]=at.COMPRESSED_RGBA_S3TC_DXT5_EXT,fi),Jm=(oe={},oe[he.DXGI_FORMAT_BC1_TYPELESS]=at.COMPRESSED_RGBA_S3TC_DXT1_EXT,oe[he.DXGI_FORMAT_BC1_UNORM]=at.COMPRESSED_RGBA_S3TC_DXT1_EXT,oe[he.DXGI_FORMAT_BC2_TYPELESS]=at.COMPRESSED_RGBA_S3TC_DXT3_EXT,oe[he.DXGI_FORMAT_BC2_UNORM]=at.COMPRESSED_RGBA_S3TC_DXT3_EXT,oe[he.DXGI_FORMAT_BC3_TYPELESS]=at.COMPRESSED_RGBA_S3TC_DXT5_EXT,oe[he.DXGI_FORMAT_BC3_UNORM]=at.COMPRESSED_RGBA_S3TC_DXT5_EXT,oe[he.DXGI_FORMAT_BC1_UNORM_SRGB]=at.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,oe[he.DXGI_FORMAT_BC2_UNORM_SRGB]=at.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,oe[he.DXGI_FORMAT_BC3_UNORM_SRGB]=at.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,oe);function zl(i){var t=new Uint32Array(i),e=t[0];if(e!==Um)throw new Error("Invalid DDS file magic word");var r=new Uint32Array(i,0,un/Uint32Array.BYTES_PER_ELEMENT),n=r[ln.HEIGHT],s=r[ln.WIDTH],a=r[ln.MIPMAP_COUNT],o=new Uint32Array(i,ln.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,Nm/Uint32Array.BYTES_PER_ELEMENT),h=o[Gm];if(h&Hm){var u=o[km.FOURCC];if(u!==$m){var l=Zm[u],c=qa+un,f=new Uint8Array(i,c),d=new hn(f,{format:l,width:s,height:n,levels:a});return[d]}var v=qa+un,_=new Uint32Array(t.buffer,v,jl/Uint32Array.BYTES_PER_ELEMENT),p=_[fn.DXGI_FORMAT],g=_[fn.RESOURCE_DIMENSION],y=_[fn.MISC_FLAG],T=_[fn.ARRAY_SIZE],I=Jm[p];if(I===void 0)throw new Error("DDSParser cannot parse texture data with DXGI format "+p);if(y===Km)throw new Error("DDSParser does not support cubemap textures");if(g===$a.DDS_DIMENSION_TEXTURE3D)throw new Error("DDSParser does not supported 3D texture data");var m=new Array,S=qa+un+jl;if(T===1)m.push(new Uint8Array(i,S));else{for(var x=li[I],N=0,D=s,F=n,k=0;k<a;k++){var L=Math.max(1,D+3&-4),q=Math.max(1,F+3&-4),Z=L*q*x;N+=Z,D=D>>>1,F=F>>>1}for(var G=S,k=0;k<T;k++)m.push(new Uint8Array(i,G,N)),G+=N}return m.map(function(b){return new hn(b,{format:I,width:s,height:n,levels:a})})}throw h&Vm?new Error("DDSParser does not support uncompressed texture data."):h&jm?new Error("DDSParser does not supported YUV uncompressed texture data."):h&zm?new Error("DDSParser does not support single-channel (lumninance) texture data!"):h&Xm?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}var Ne,Se,ci,Wl=[171,75,84,88,32,49,49,187,13,10,26,10],Qm=67305985,ue={ENDIANNESS:12,GL_TYPE:16,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},Ka=64,Za=(Ne={},Ne[Q.UNSIGNED_BYTE]=1,Ne[Q.UNSIGNED_SHORT]=2,Ne[Q.INT]=4,Ne[Q.UNSIGNED_INT]=4,Ne[Q.FLOAT]=4,Ne[Q.HALF_FLOAT]=8,Ne),Yl=(Se={},Se[H.RGBA]=4,Se[H.RGB]=3,Se[H.RG]=2,Se[H.RED]=1,Se[H.LUMINANCE]=1,Se[H.LUMINANCE_ALPHA]=2,Se[H.ALPHA]=1,Se),ql=(ci={},ci[Q.UNSIGNED_SHORT_4_4_4_4]=2,ci[Q.UNSIGNED_SHORT_5_5_5_1]=2,ci[Q.UNSIGNED_SHORT_5_6_5]=2,ci);function $l(i,t,e){e===void 0&&(e=!1);var r=new DataView(t);if(!ty(i,r))return null;var n=r.getUint32(ue.ENDIANNESS,!0)===Qm,s=r.getUint32(ue.GL_TYPE,n),a=r.getUint32(ue.GL_FORMAT,n),o=r.getUint32(ue.GL_INTERNAL_FORMAT,n),h=r.getUint32(ue.PIXEL_WIDTH,n),u=r.getUint32(ue.PIXEL_HEIGHT,n)||1,l=r.getUint32(ue.PIXEL_DEPTH,n)||1,c=r.getUint32(ue.NUMBER_OF_ARRAY_ELEMENTS,n)||1,f=r.getUint32(ue.NUMBER_OF_FACES,n),d=r.getUint32(ue.NUMBER_OF_MIPMAP_LEVELS,n),v=r.getUint32(ue.BYTES_OF_KEY_VALUE_DATA,n);if(u===0||l!==1)throw new Error("Only 2D textures are supported");if(f!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(c!==1)throw new Error("WebGL does not support array textures");var _=4,p=4,g=h+3&-4,y=u+3&-4,T=new Array(c),I=h*u;s===0&&(I=g*y);var m;if(s!==0?Za[s]?m=Za[s]*Yl[a]:m=ql[s]:m=li[o],m===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");for(var S=e?ry(r,v,n):null,x=I*m,N=x,D=h,F=u,k=g,L=y,q=Ka+v,Z=0;Z<d;Z++){for(var G=r.getUint32(q,n),b=q+4,P=0;P<c;P++){var E=T[P];E||(E=T[P]=new Array(d)),E[Z]={levelID:Z,levelWidth:d>1||s!==0?D:k,levelHeight:d>1||s!==0?F:L,levelBuffer:new Uint8Array(t,b,N)},b+=N}q+=G+4,q=q%4!==0?q+4-q%4:q,D=D>>1||1,F=F>>1||1,k=D+_-1&-4,L=F+p-1&-4,N=k*L*m}return s!==0?{uncompressed:T.map(function(A){var C=A[0].levelBuffer,w=!1;return s===Q.FLOAT?C=new Float32Array(A[0].levelBuffer.buffer,A[0].levelBuffer.byteOffset,A[0].levelBuffer.byteLength/4):s===Q.UNSIGNED_INT?(w=!0,C=new Uint32Array(A[0].levelBuffer.buffer,A[0].levelBuffer.byteOffset,A[0].levelBuffer.byteLength/4)):s===Q.INT&&(w=!0,C=new Int32Array(A[0].levelBuffer.buffer,A[0].levelBuffer.byteOffset,A[0].levelBuffer.byteLength/4)),{resource:new Ke(C,{width:A[0].levelWidth,height:A[0].levelHeight}),type:s,format:w?ey(a):a}}),kvData:S}:{compressed:T.map(function(A){return new hn(null,{format:o,width:h,height:u,levels:d,levelBuffers:A})}),kvData:S}}function ty(i,t){for(var e=0;e<Wl.length;e++)if(t.getUint8(e)!==Wl[e])return console.error(i+" is not a valid *.ktx file!"),!1;return!0}function ey(i){switch(i){case H.RGBA:return H.RGBA_INTEGER;case H.RGB:return H.RGB_INTEGER;case H.RG:return H.RG_INTEGER;case H.RED:return H.RED_INTEGER;default:return i}}function ry(i,t,e){for(var r=new Map,n=0;n<t;){var s=i.getUint32(Ka+n,e),a=Ka+n+4,o=3-(s+3)%4;if(s===0||s>t-n){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}for(var h=0;h<s&&i.getUint8(a+h)!==0;h++);if(h===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}var u=new TextDecoder().decode(new Uint8Array(i.buffer,a,h)),l=new DataView(i.buffer,a+h+1,s-h-1);r.set(u,l),n+=4+s+o}return r}wt.setExtensionXhrType("dds",wt.XHR_RESPONSE_TYPE.BUFFER);var Kl=function(){function i(){}return i.use=function(t,e){if(t.extension==="dds"&&t.data)try{Object.assign(t,Vl(t.name||t.url,zl(t.data),t.metadata))}catch(r){e(r);return}e()},i.extension=dt.Loader,i}();wt.setExtensionXhrType("ktx",wt.XHR_RESPONSE_TYPE.BUFFER);var Zl=function(){function i(){}return i.use=function(t,e){if(t.extension==="ktx"&&t.data)try{var r=t.name||t.url,n=$l(r,t.data,this.loadKeyValueData),s=n.compressed,a=n.uncompressed,o=n.kvData;if(s){var h=Vl(r,s,t.metadata);if(o&&h.textures)for(var u in h.textures)h.textures[u].baseTexture.ktxKeyValueData=o;Object.assign(t,h)}else if(a){var l={};a.forEach(function(c,f){var d=new it(new lt(c.resource,{mipmap:zt.OFF,alphaMode:Wt.NO_PREMULTIPLIED_ALPHA,type:c.type,format:c.format})),v=r+"-"+(f+1);o&&(d.baseTexture.ktxKeyValueData=o),lt.addToCache(d.baseTexture,v),it.addToCache(d,v),f===0&&(l[r]=d,lt.addToCache(d.baseTexture,r),it.addToCache(d,r)),l[v]=d}),Object.assign(t,{textures:l})}}catch(c){e(c);return}e()},i.extension=dt.Loader,i.loadKeyValueData=!1,i}();var Ja=function(i,t){return Ja=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},Ja(i,t)};function Jl(i,t){Ja(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var iy=function(i){Jl(t,i);function t(e,r,n,s){e===void 0&&(e=1500),n===void 0&&(n=16384),s===void 0&&(s=!1);var a=i.call(this)||this,o=16384;return n>o&&(n=o),a._properties=[!1,!0,!1,!1,!1],a._maxSize=e,a._batchSize=n,a._buffers=null,a._bufferUpdateIDs=[],a._updateID=0,a.interactiveChildren=!1,a.blendMode=tt.NORMAL,a.autoResize=s,a.roundPixels=!0,a.baseTexture=null,a.setProperties(r),a._tint=0,a.tintRgb=new Float32Array(4),a.tint=16777215,a}return t.prototype.setProperties=function(e){e&&(this._properties[0]="vertices"in e||"scale"in e?!!e.vertices||!!e.scale:this._properties[0],this._properties[1]="position"in e?!!e.position:this._properties[1],this._properties[2]="rotation"in e?!!e.rotation:this._properties[2],this._properties[3]="uvs"in e?!!e.uvs:this._properties[3],this._properties[4]="tint"in e||"alpha"in e?!!e.tint||!!e.alpha:this._properties[4])},t.prototype.updateTransform=function(){this.displayObjectUpdateTransform()},Object.defineProperty(t.prototype,"tint",{get:function(){return this._tint},set:function(e){this._tint=e,He(e,this.tintRgb)},enumerable:!1,configurable:!0}),t.prototype.render=function(e){var r=this;!this.visible||this.worldAlpha<=0||!this.children.length||!this.renderable||(this.baseTexture||(this.baseTexture=this.children[0]._texture.baseTexture,this.baseTexture.valid||this.baseTexture.once("update",function(){return r.onChildrenChange(0)})),e.batch.setObjectRenderer(e.plugins.particle),e.plugins.particle.render(this))},t.prototype.onChildrenChange=function(e){for(var r=Math.floor(e/this._batchSize);this._bufferUpdateIDs.length<r;)this._bufferUpdateIDs.push(0);this._bufferUpdateIDs[r]=++this._updateID},t.prototype.dispose=function(){if(this._buffers){for(var e=0;e<this._buffers.length;++e)this._buffers[e].destroy();this._buffers=null}},t.prototype.destroy=function(e){i.prototype.destroy.call(this,e),this.dispose(),this._properties=null,this._buffers=null,this._bufferUpdateIDs=null},t}(Zt),Ql=function(){function i(t,e,r){this.geometry=new vr,this.indexBuffer=null,this.size=r,this.dynamicProperties=[],this.staticProperties=[];for(var n=0;n<t.length;++n){var s=t[n];s={attributeName:s.attributeName,size:s.size,uploadFunction:s.uploadFunction,type:s.type||Q.FLOAT,offset:s.offset},e[n]?this.dynamicProperties.push(s):this.staticProperties.push(s)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}return i.prototype.initBuffers=function(){var t=this.geometry,e=0;this.indexBuffer=new Mt(Hh(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(var r=0;r<this.dynamicProperties.length;++r){var n=this.dynamicProperties[r];n.offset=e,e+=n.size,this.dynamicStride+=n.size}var s=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(s),this.dynamicDataUint32=new Uint32Array(s),this.dynamicBuffer=new Mt(this.dynamicData,!1,!1);var a=0;this.staticStride=0;for(var r=0;r<this.staticProperties.length;++r){var n=this.staticProperties[r];n.offset=a,a+=n.size,this.staticStride+=n.size}var o=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(o),this.staticDataUint32=new Uint32Array(o),this.staticBuffer=new Mt(this.staticData,!0,!1);for(var r=0;r<this.dynamicProperties.length;++r){var n=this.dynamicProperties[r];t.addAttribute(n.attributeName,this.dynamicBuffer,0,n.type===Q.UNSIGNED_BYTE,n.type,this.dynamicStride*4,n.offset*4)}for(var r=0;r<this.staticProperties.length;++r){var n=this.staticProperties[r];t.addAttribute(n.attributeName,this.staticBuffer,0,n.type===Q.UNSIGNED_BYTE,n.type,this.staticStride*4,n.offset*4)}},i.prototype.uploadDynamic=function(t,e,r){for(var n=0;n<this.dynamicProperties.length;n++){var s=this.dynamicProperties[n];s.uploadFunction(t,e,r,s.type===Q.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,s.offset)}this.dynamicBuffer._updateID++},i.prototype.uploadStatic=function(t,e,r){for(var n=0;n<this.staticProperties.length;n++){var s=this.staticProperties[n];s.uploadFunction(t,e,r,s.type===Q.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,s.offset)}this.staticBuffer._updateID++},i.prototype.destroy=function(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()},i}(),ny=`varying vec2 vTextureCoord;
508
- varying vec4 vColor;
544
+ varying vec2 vBlurTexCoords[%size%];
545
+
546
+ uniform vec4 inputSize;
547
+ uniform vec4 outputFrame;
548
+
549
+ vec4 filterVertexPosition( void )
550
+ {
551
+ vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
552
+
553
+ return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
554
+ }
555
+
556
+ vec2 filterTextureCoord( void )
557
+ {
558
+ return aVertexPosition * (outputFrame.zw * inputSize.zw);
559
+ }
560
+
561
+ void main(void)
562
+ {
563
+ gl_Position = filterVertexPosition();
509
564
 
565
+ vec2 textureCoord = filterTextureCoord();
566
+ %blur%
567
+ }`;function Tm(s,t){const e=Math.ceil(s/2);let i=bm,r="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let a=0;a<s;a++){let o=n.replace("%index%",a.toString());o=o.replace("%sampleIndex%",`${a-(e-1)}.0`),r+=o,r+=`
568
+ `}return i=i.replace("%blur%",r),i=i.replace("%size%",s.toString()),i}class Is extends kt{constructor(t,e=8,i=4,r=kt.defaultResolution,n=5){const a=Tm(n,t),o=xm(n);super(a,o),this.horizontal=t,this.resolution=r,this._quality=0,this.quality=i,this.blur=e}apply(t,e,i,r){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/e.width):this.uniforms.strength=1/i.height*(i.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,e,i,r);else{const n=t.getFilterTexture(),a=t.renderer;let o=e,h=n;this.state.blend=!1,t.applyFilter(this,o,h,le.CLEAR);for(let l=1;l<this.passes-1;l++){t.bindAndClear(o,le.BLIT),this.uniforms.uSampler=h;const u=h;h=o,o=u,a.shader.bind(this),a.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,h,i,r),t.returnFilterTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class Nu extends kt{constructor(t=8,e=4,i=kt.defaultResolution,r=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new Is(!0,t,e,i,r),this.blurYFilter=new Is(!1,t,e,i,r),this.resolution=i,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,i,r){const n=Math.abs(this.blurXFilter.strength),a=Math.abs(this.blurYFilter.strength);if(n&&a){const o=t.getFilterTexture();this.blurXFilter.apply(t,e,o,le.CLEAR),this.blurYFilter.apply(t,o,i,r),t.returnFilterTexture(o)}else a?this.blurYFilter.apply(t,e,i,r):this.blurXFilter.apply(t,e,i,r)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var Em=`varying vec2 vTextureCoord;
510
569
  uniform sampler2D uSampler;
570
+ uniform float m[20];
571
+ uniform float uAlpha;
511
572
 
512
- void main(void){
513
- vec4 color = texture2D(uSampler, vTextureCoord) * vColor;
514
- gl_FragColor = color;
515
- }`,sy=`attribute vec2 aVertexPosition;
516
- attribute vec2 aTextureCoord;
517
- attribute vec4 aColor;
573
+ void main(void)
574
+ {
575
+ vec4 c = texture2D(uSampler, vTextureCoord);
518
576
 
519
- attribute vec2 aPositionCoord;
520
- attribute float aRotation;
577
+ if (uAlpha == 0.0) {
578
+ gl_FragColor = c;
579
+ return;
580
+ }
521
581
 
522
- uniform mat3 translationMatrix;
523
- uniform vec4 uColor;
582
+ // Un-premultiply alpha before applying the color matrix. See issue #3539.
583
+ if (c.a > 0.0) {
584
+ c.rgb /= c.a;
585
+ }
524
586
 
525
- varying vec2 vTextureCoord;
526
- varying vec4 vColor;
587
+ vec4 result;
527
588
 
528
- void main(void){
529
- float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);
530
- float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);
589
+ result.r = (m[0] * c.r);
590
+ result.r += (m[1] * c.g);
591
+ result.r += (m[2] * c.b);
592
+ result.r += (m[3] * c.a);
593
+ result.r += m[4];
531
594
 
532
- vec2 v = vec2(x, y);
533
- v = v + aPositionCoord;
595
+ result.g = (m[5] * c.r);
596
+ result.g += (m[6] * c.g);
597
+ result.g += (m[7] * c.b);
598
+ result.g += (m[8] * c.a);
599
+ result.g += m[9];
534
600
 
535
- gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
601
+ result.b = (m[10] * c.r);
602
+ result.b += (m[11] * c.g);
603
+ result.b += (m[12] * c.b);
604
+ result.b += (m[13] * c.a);
605
+ result.b += m[14];
536
606
 
537
- vTextureCoord = aTextureCoord;
538
- vColor = aColor * uColor;
539
- }
540
- `,tf=function(i){Jl(t,i);function t(e){var r=i.call(this,e)||this;return r.shader=null,r.properties=null,r.tempMatrix=new bt,r.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:r.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:r.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:r.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:r.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:Q.UNSIGNED_BYTE,uploadFunction:r.uploadTint,offset:0}],r.shader=be.from(sy,ny,{}),r.state=Oe.for2d(),r}return t.prototype.render=function(e){var r=e.children,n=e._maxSize,s=e._batchSize,a=this.renderer,o=r.length;if(o!==0){o>n&&!e.autoResize&&(o=n);var h=e._buffers;h||(h=e._buffers=this.generateBuffers(e));var u=r[0]._texture.baseTexture,l=u.alphaMode>0;this.state.blendMode=vs(e.blendMode,l),a.state.set(this.state);var c=a.gl,f=e.worldTransform.copyTo(this.tempMatrix);f.prepend(a.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=f.toArray(!0),this.shader.uniforms.uColor=Xh(e.tintRgb,e.worldAlpha,this.shader.uniforms.uColor,l),this.shader.uniforms.uSampler=u,this.renderer.shader.bind(this.shader);for(var d=!1,v=0,_=0;v<o;v+=s,_+=1){var p=o-v;p>s&&(p=s),_>=h.length&&h.push(this._generateOneMoreBuffer(e));var g=h[_];g.uploadDynamic(r,v,p);var y=e._bufferUpdateIDs[_]||0;d=d||g._updateID<y,d&&(g._updateID=e._updateID,g.uploadStatic(r,v,p)),a.geometry.bind(g.geometry),c.drawElements(c.TRIANGLES,p*6,c.UNSIGNED_SHORT,0)}}},t.prototype.generateBuffers=function(e){for(var r=[],n=e._maxSize,s=e._batchSize,a=e._properties,o=0;o<n;o+=s)r.push(new Ql(this.properties,a,s));return r},t.prototype._generateOneMoreBuffer=function(e){var r=e._batchSize,n=e._properties;return new Ql(this.properties,n,r)},t.prototype.uploadVertices=function(e,r,n,s,a,o){for(var h=0,u=0,l=0,c=0,f=0;f<n;++f){var d=e[r+f],v=d._texture,_=d.scale.x,p=d.scale.y,g=v.trim,y=v.orig;g?(u=g.x-d.anchor.x*y.width,h=u+g.width,c=g.y-d.anchor.y*y.height,l=c+g.height):(h=y.width*(1-d.anchor.x),u=y.width*-d.anchor.x,l=y.height*(1-d.anchor.y),c=y.height*-d.anchor.y),s[o]=u*_,s[o+1]=c*p,s[o+a]=h*_,s[o+a+1]=c*p,s[o+a*2]=h*_,s[o+a*2+1]=l*p,s[o+a*3]=u*_,s[o+a*3+1]=l*p,o+=a*4}},t.prototype.uploadPosition=function(e,r,n,s,a,o){for(var h=0;h<n;h++){var u=e[r+h].position;s[o]=u.x,s[o+1]=u.y,s[o+a]=u.x,s[o+a+1]=u.y,s[o+a*2]=u.x,s[o+a*2+1]=u.y,s[o+a*3]=u.x,s[o+a*3+1]=u.y,o+=a*4}},t.prototype.uploadRotation=function(e,r,n,s,a,o){for(var h=0;h<n;h++){var u=e[r+h].rotation;s[o]=u,s[o+a]=u,s[o+a*2]=u,s[o+a*3]=u,o+=a*4}},t.prototype.uploadUvs=function(e,r,n,s,a,o){for(var h=0;h<n;++h){var u=e[r+h]._texture._uvs;u?(s[o]=u.x0,s[o+1]=u.y0,s[o+a]=u.x1,s[o+a+1]=u.y1,s[o+a*2]=u.x2,s[o+a*2+1]=u.y2,s[o+a*3]=u.x3,s[o+a*3+1]=u.y3,o+=a*4):(s[o]=0,s[o+1]=0,s[o+a]=0,s[o+a+1]=0,s[o+a*2]=0,s[o+a*2+1]=0,s[o+a*3]=0,s[o+a*3+1]=0,o+=a*4)}},t.prototype.uploadTint=function(e,r,n,s,a,o){for(var h=0;h<n;++h){var u=e[r+h],l=u._texture.baseTexture.alphaMode>0,c=u.alpha,f=c<1&&l?Pi(u._tintRGB,c):u._tintRGB+(c*255<<24);s[o]=f,s[o+a]=f,s[o+a*2]=f,s[o+a*3]=f,o+=a*4}},t.prototype.destroy=function(){i.prototype.destroy.call(this),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null},t.extension={name:"particle",type:dt.RendererPlugin},t}(zr);var me;(function(i){i.MITER="miter",i.BEVEL="bevel",i.ROUND="round"})(me||(me={}));var Pe;(function(i){i.BUTT="butt",i.ROUND="round",i.SQUARE="square"})(Pe||(Pe={}));var Er={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount:function(i,t){if(t===void 0&&(t=20),!this.adaptive||!i||isNaN(i))return t;var e=Math.ceil(i/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}},Qa=function(){function i(){this.color=16777215,this.alpha=1,this.texture=it.WHITE,this.matrix=null,this.visible=!1,this.reset()}return i.prototype.clone=function(){var t=new i;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t},i.prototype.reset=function(){this.color=16777215,this.alpha=1,this.texture=it.WHITE,this.matrix=null,this.visible=!1},i.prototype.destroy=function(){this.texture=null,this.matrix=null},i}();var to=function(i,t){return to=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},to(i,t)};function eo(i,t){to(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function ef(i,t){var e,r;t===void 0&&(t=!1);var n=i.length;if(!(n<6)){for(var s=0,a=0,o=i[n-2],h=i[n-1];a<n;a+=2){var u=i[a],l=i[a+1];s+=(u-o)*(l+h),o=u,h=l}if(!t&&s>0||t&&s<=0)for(var c=n/2,a=c+c%2;a<n;a+=2){var f=n-a-2,d=n-a-1,v=a,_=a+1;e=[i[v],i[f]],i[f]=e[0],i[v]=e[1],r=[i[_],i[d]],i[d]=r[0],i[_]=r[1]}}}var ro={build:function(i){i.points=i.shape.points.slice()},triangulate:function(i,t){var e=i.points,r=i.holes,n=t.points,s=t.indices;if(e.length>=6){ef(e,!1);for(var a=[],o=0;o<r.length;o++){var h=r[o];ef(h.points,!0),a.push(e.length/2),e=e.concat(h.points)}var u=Rn(e,a,2);if(!u)return;for(var l=n.length/2,o=0;o<u.length;o+=3)s.push(u[o]+l),s.push(u[o+1]+l),s.push(u[o+2]+l);for(var o=0;o<e.length;o++)n.push(e[o])}}},di={build:function(i){var t=i.points,e,r,n,s,a,o;if(i.type===Rt.CIRC){var h=i.shape;e=h.x,r=h.y,a=o=h.radius,n=s=0}else if(i.type===Rt.ELIP){var u=i.shape;e=u.x,r=u.y,a=u.width,o=u.height,n=s=0}else{var l=i.shape,c=l.width/2,f=l.height/2;e=l.x+c,r=l.y+f,a=o=Math.max(0,Math.min(l.radius,Math.min(c,f))),n=c-a,s=f-o}if(!(a>=0&&o>=0&&n>=0&&s>=0)){t.length=0;return}var d=Math.ceil(2.3*Math.sqrt(a+o)),v=d*8+(n?4:0)+(s?4:0);if(t.length=v,v!==0){if(d===0){t.length=8,t[0]=t[6]=e+n,t[1]=t[3]=r+s,t[2]=t[4]=e-n,t[5]=t[7]=r-s;return}var _=0,p=d*4+(n?2:0)+2,g=p,y=v;{var T=n+a,I=s,m=e+T,S=e-T,x=r+I;if(t[_++]=m,t[_++]=x,t[--p]=x,t[--p]=S,s){var N=r-I;t[g++]=S,t[g++]=N,t[--y]=N,t[--y]=m}}for(var D=1;D<d;D++){var F=Math.PI/2*(D/d),T=n+Math.cos(F)*a,I=s+Math.sin(F)*o,m=e+T,S=e-T,x=r+I,N=r-I;t[_++]=m,t[_++]=x,t[--p]=x,t[--p]=S,t[g++]=S,t[g++]=N,t[--y]=N,t[--y]=m}{var T=n,I=s+o,m=e+T,S=e-T,x=r+I,N=r-I;t[_++]=m,t[_++]=x,t[--y]=N,t[--y]=m,n&&(t[_++]=S,t[_++]=x,t[--y]=N,t[--y]=S)}}},triangulate:function(i,t){var e=i.points,r=t.points,n=t.indices;if(e.length!==0){var s=r.length/2,a=s,o,h;if(i.type!==Rt.RREC){var u=i.shape;o=u.x,h=u.y}else{var l=i.shape;o=l.x+l.width/2,h=l.y+l.height/2}var c=i.matrix;r.push(i.matrix?c.a*o+c.c*h+c.tx:o,i.matrix?c.b*o+c.d*h+c.ty:h),s++,r.push(e[0],e[1]);for(var f=2;f<e.length;f+=2)r.push(e[f],e[f+1]),n.push(s++,a,s);n.push(a+1,a,s)}}},rf={build:function(i){var t=i.shape,e=t.x,r=t.y,n=t.width,s=t.height,a=i.points;a.length=0,a.push(e,r,e+n,r,e+n,r+s,e,r+s)},triangulate:function(i,t){var e=i.points,r=t.points,n=r.length/2;r.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(n,n+1,n+2,n+1,n+2,n+3)}};function Sr(i,t,e){var r=t-i;return i+r*e}function cn(i,t,e,r,n,s,a){a===void 0&&(a=[]);for(var o=20,h=a,u=0,l=0,c=0,f=0,d=0,v=0,_=0,p=0;_<=o;++_)p=_/o,u=Sr(i,e,p),l=Sr(t,r,p),c=Sr(e,n,p),f=Sr(r,s,p),d=Sr(u,c,p),v=Sr(l,f,p),!(_===0&&h[h.length-2]===d&&h[h.length-1]===v)&&h.push(d,v);return h}var nf={build:function(i){if(vi.nextRoundedRectBehavior){di.build(i);return}var t=i.shape,e=i.points,r=t.x,n=t.y,s=t.width,a=t.height,o=Math.max(0,Math.min(t.radius,Math.min(s,a)/2));e.length=0,o?(cn(r,n+o,r,n,r+o,n,e),cn(r+s-o,n,r+s,n,r+s,n+o,e),cn(r+s,n+a-o,r+s,n+a,r+s-o,n+a,e),cn(r+o,n+a,r,n+a,r,n+a-o,e)):e.push(r,n,r+s,n,r+s,n+a,r,n+a)},triangulate:function(i,t){if(vi.nextRoundedRectBehavior){di.triangulate(i,t);return}for(var e=i.points,r=t.points,n=t.indices,s=r.length/2,a=Rn(e,null,2),o=0,h=a.length;o<h;o+=3)n.push(a[o]+s),n.push(a[o+1]+s),n.push(a[o+2]+s);for(var o=0,h=e.length;o<h;o++)r.push(e[o],e[++o])}};function sf(i,t,e,r,n,s,a,o){var h=i-e*n,u=t-r*n,l=i+e*s,c=t+r*s,f,d;a?(f=r,d=-e):(f=-r,d=e);var v=h+f,_=u+d,p=l+f,g=c+d;return o.push(v,_),o.push(p,g),2}function hr(i,t,e,r,n,s,a,o){var h=e-i,u=r-t,l=Math.atan2(h,u),c=Math.atan2(n-i,s-t);o&&l<c?l+=Math.PI*2:!o&&l>c&&(c+=Math.PI*2);var f=l,d=c-l,v=Math.abs(d),_=Math.sqrt(h*h+u*u),p=(15*v*Math.sqrt(_)/Math.PI>>0)+1,g=d/p;if(f+=g,o){a.push(i,t),a.push(e,r);for(var y=1,T=f;y<p;y++,T+=g)a.push(i,t),a.push(i+Math.sin(T)*_,t+Math.cos(T)*_);a.push(i,t),a.push(n,s)}else{a.push(e,r),a.push(i,t);for(var y=1,T=f;y<p;y++,T+=g)a.push(i+Math.sin(T)*_,t+Math.cos(T)*_),a.push(i,t);a.push(n,s),a.push(i,t)}return p*2}function ay(i,t){var e=i.shape,r=i.points||e.points.slice(),n=t.closePointEps;if(r.length!==0){var s=i.lineStyle,a=new vt(r[0],r[1]),o=new vt(r[r.length-2],r[r.length-1]),h=e.type!==Rt.POLY||e.closeStroke,u=Math.abs(a.x-o.x)<n&&Math.abs(a.y-o.y)<n;if(h){r=r.slice(),u&&(r.pop(),r.pop(),o.set(r[r.length-2],r[r.length-1]));var l=(a.x+o.x)*.5,c=(o.y+a.y)*.5;r.unshift(l,c),r.push(l,c)}var f=t.points,d=r.length/2,v=r.length,_=f.length/2,p=s.width/2,g=p*p,y=s.miterLimit*s.miterLimit,T=r[0],I=r[1],m=r[2],S=r[3],x=0,N=0,D=-(I-S),F=T-m,k=0,L=0,q=Math.sqrt(D*D+F*F);D/=q,F/=q,D*=p,F*=p;var Z=s.alignment,G=(1-Z)*2,b=Z*2;h||(s.cap===Pe.ROUND?v+=hr(T-D*(G-b)*.5,I-F*(G-b)*.5,T-D*G,I-F*G,T+D*b,I+F*b,f,!0)+2:s.cap===Pe.SQUARE&&(v+=sf(T,I,D,F,G,b,!0,f))),f.push(T-D*G,I-F*G),f.push(T+D*b,I+F*b);for(var P=1;P<d-1;++P){T=r[(P-1)*2],I=r[(P-1)*2+1],m=r[P*2],S=r[P*2+1],x=r[(P+1)*2],N=r[(P+1)*2+1],D=-(I-S),F=T-m,q=Math.sqrt(D*D+F*F),D/=q,F/=q,D*=p,F*=p,k=-(S-N),L=m-x,q=Math.sqrt(k*k+L*L),k/=q,L/=q,k*=p,L*=p;var E=m-T,A=I-S,C=m-x,w=N-S,M=E*C+A*w,R=A*C-w*E,U=R<0;if(Math.abs(R)<.001*Math.abs(M)){f.push(m-D*G,S-F*G),f.push(m+D*b,S+F*b),M>=0&&(s.join===me.ROUND?v+=hr(m,S,m-D*G,S-F*G,m-k*G,S-L*G,f,!1)+4:v+=2,f.push(m-k*b,S-L*b),f.push(m+k*G,S+L*G));continue}var X=(-D+T)*(-F+S)-(-D+m)*(-F+I),W=(-k+x)*(-L+S)-(-k+m)*(-L+N),V=(E*W-C*X)/R,Y=(w*X-A*W)/R,K=(V-m)*(V-m)+(Y-S)*(Y-S),j=m+(V-m)*G,et=S+(Y-S)*G,nt=m-(V-m)*b,ft=S-(Y-S)*b,J=Math.min(E*E+A*A,C*C+w*w),$=U?G:b,rt=J+$*$*g,ot=K<=rt;ot?s.join===me.BEVEL||K/g>y?(U?(f.push(j,et),f.push(m+D*b,S+F*b),f.push(j,et),f.push(m+k*b,S+L*b)):(f.push(m-D*G,S-F*G),f.push(nt,ft),f.push(m-k*G,S-L*G),f.push(nt,ft)),v+=2):s.join===me.ROUND?U?(f.push(j,et),f.push(m+D*b,S+F*b),v+=hr(m,S,m+D*b,S+F*b,m+k*b,S+L*b,f,!0)+4,f.push(j,et),f.push(m+k*b,S+L*b)):(f.push(m-D*G,S-F*G),f.push(nt,ft),v+=hr(m,S,m-D*G,S-F*G,m-k*G,S-L*G,f,!1)+4,f.push(m-k*G,S-L*G),f.push(nt,ft)):(f.push(j,et),f.push(nt,ft)):(f.push(m-D*G,S-F*G),f.push(m+D*b,S+F*b),s.join===me.ROUND?U?v+=hr(m,S,m+D*b,S+F*b,m+k*b,S+L*b,f,!0)+2:v+=hr(m,S,m-D*G,S-F*G,m-k*G,S-L*G,f,!1)+2:s.join===me.MITER&&K/g<=y&&(U?(f.push(nt,ft),f.push(nt,ft)):(f.push(j,et),f.push(j,et)),v+=2),f.push(m-k*G,S-L*G),f.push(m+k*b,S+L*b),v+=2)}T=r[(d-2)*2],I=r[(d-2)*2+1],m=r[(d-1)*2],S=r[(d-1)*2+1],D=-(I-S),F=T-m,q=Math.sqrt(D*D+F*F),D/=q,F/=q,D*=p,F*=p,f.push(m-D*G,S-F*G),f.push(m+D*b,S+F*b),h||(s.cap===Pe.ROUND?v+=hr(m-D*(G-b)*.5,S-F*(G-b)*.5,m-D*G,S-F*G,m+D*b,S+F*b,f,!1)+2:s.cap===Pe.SQUARE&&(v+=sf(m,S,D,F,G,b,!1,f)));for(var Ht=t.indices,Ue=Er.epsilon*Er.epsilon,P=_;P<v+_-2;++P)T=f[P*2],I=f[P*2+1],m=f[(P+1)*2],S=f[(P+1)*2+1],x=f[(P+2)*2],N=f[(P+2)*2+1],!(Math.abs(T*(S-N)+m*(N-I)+x*(I-S))<Ue)&&Ht.push(P,P+1,P+2)}}function oy(i,t){var e=0,r=i.shape,n=i.points||r.points,s=r.type!==Rt.POLY||r.closeStroke;if(n.length!==0){var a=t.points,o=t.indices,h=n.length/2,u=a.length/2,l=u;for(a.push(n[0],n[1]),e=1;e<h;e++)a.push(n[e*2],n[e*2+1]),o.push(l,l+1),l++;s&&o.push(l,u)}}function io(i,t){i.lineStyle.native?oy(i,t):ay(i,t)}var no=function(){function i(){}return i.curveTo=function(t,e,r,n,s,a){var o=a[a.length-2],h=a[a.length-1],u=h-e,l=o-t,c=n-e,f=r-t,d=Math.abs(u*f-l*c);if(d<1e-8||s===0)return(a[a.length-2]!==t||a[a.length-1]!==e)&&a.push(t,e),null;var v=u*u+l*l,_=c*c+f*f,p=u*c+l*f,g=s*Math.sqrt(v)/d,y=s*Math.sqrt(_)/d,T=g*p/v,I=y*p/_,m=g*f+y*l,S=g*c+y*u,x=l*(y+T),N=u*(y+T),D=f*(g+I),F=c*(g+I),k=Math.atan2(N-S,x-m),L=Math.atan2(F-S,D-m);return{cx:m+t,cy:S+e,radius:s,startAngle:k,endAngle:L,anticlockwise:l*c>f*u}},i.arc=function(t,e,r,n,s,a,o,h,u){for(var l=o-a,c=Er._segmentsCount(Math.abs(l)*s,Math.ceil(Math.abs(l)/Xr)*40),f=l/(c*2),d=f*2,v=Math.cos(f),_=Math.sin(f),p=c-1,g=p%1/p,y=0;y<=p;++y){var T=y+g*y,I=f+a+d*T,m=Math.cos(I),S=-Math.sin(I);u.push((v*m+_*S)*s+r,(v*-S+_*m)*s+n)}},i}(),af=function(){function i(){}return i.curveLength=function(t,e,r,n,s,a,o,h){for(var u=10,l=0,c=0,f=0,d=0,v=0,_=0,p=0,g=0,y=0,T=0,I=0,m=t,S=e,x=1;x<=u;++x)c=x/u,f=c*c,d=f*c,v=1-c,_=v*v,p=_*v,g=p*t+3*_*c*r+3*v*f*s+d*o,y=p*e+3*_*c*n+3*v*f*a+d*h,T=m-g,I=S-y,m=g,S=y,l+=Math.sqrt(T*T+I*I);return l},i.curveTo=function(t,e,r,n,s,a,o){var h=o[o.length-2],u=o[o.length-1];o.length-=2;var l=Er._segmentsCount(i.curveLength(h,u,t,e,r,n,s,a)),c=0,f=0,d=0,v=0,_=0;o.push(h,u);for(var p=1,g=0;p<=l;++p)g=p/l,c=1-g,f=c*c,d=f*c,v=g*g,_=v*g,o.push(d*h+3*f*g*t+3*c*v*r+_*s,d*u+3*f*g*e+3*c*v*n+_*a)},i}(),of=function(){function i(){}return i.curveLength=function(t,e,r,n,s,a){var o=t-2*r+s,h=e-2*n+a,u=2*r-2*t,l=2*n-2*e,c=4*(o*o+h*h),f=4*(o*u+h*l),d=u*u+l*l,v=2*Math.sqrt(c+f+d),_=Math.sqrt(c),p=2*c*_,g=2*Math.sqrt(d),y=f/_;return(p*v+_*f*(v-g)+(4*d*c-f*f)*Math.log((2*_+y+v)/(y+g)))/(4*p)},i.curveTo=function(t,e,r,n,s){for(var a=s[s.length-2],o=s[s.length-1],h=Er._segmentsCount(i.curveLength(a,o,t,e,r,n)),u=0,l=0,c=1;c<=h;++c){var f=c/h;u=a+(t-a)*f,l=o+(e-o)*f,s.push(u+(t+(r-t)*f-u)*f,l+(e+(n-e)*f-l)*f)}},i}(),hf=function(){function i(){this.reset()}return i.prototype.begin=function(t,e,r){this.reset(),this.style=t,this.start=e,this.attribStart=r},i.prototype.end=function(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start},i.prototype.reset=function(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0},i}(),ur,dn=(ur={},ur[Rt.POLY]=ro,ur[Rt.CIRC]=di,ur[Rt.ELIP]=di,ur[Rt.RECT]=rf,ur[Rt.RREC]=nf,ur),so=[],pi=[],ao=function(){function i(t,e,r,n){e===void 0&&(e=null),r===void 0&&(r=null),n===void 0&&(n=null),this.points=[],this.holes=[],this.shape=t,this.lineStyle=r,this.fillStyle=e,this.matrix=n,this.type=t.type}return i.prototype.clone=function(){return new i(this.shape,this.fillStyle,this.lineStyle,this.matrix)},i.prototype.destroy=function(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null},i}(),Pr=new vt,uf=function(i){eo(t,i);function t(){var e=i.call(this)||this;return e.closePointEps=1e-4,e.boundsPadding=0,e.uvsFloat32=null,e.indicesUint16=null,e.batchable=!1,e.points=[],e.colors=[],e.uvs=[],e.indices=[],e.textureIds=[],e.graphicsData=[],e.drawCalls=[],e.batchDirty=-1,e.batches=[],e.dirty=0,e.cacheDirty=-1,e.clearDirty=0,e.shapeIndex=0,e._bounds=new $r,e.boundsDirty=-1,e}return Object.defineProperty(t.prototype,"bounds",{get:function(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds},enumerable:!1,configurable:!0}),t.prototype.invalidate=function(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(var e=0;e<this.drawCalls.length;e++)this.drawCalls[e].texArray.clear(),pi.push(this.drawCalls[e]);this.drawCalls.length=0;for(var e=0;e<this.batches.length;e++){var r=this.batches[e];r.reset(),so.push(r)}this.batches.length=0},t.prototype.clear=function(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this},t.prototype.drawShape=function(e,r,n,s){r===void 0&&(r=null),n===void 0&&(n=null),s===void 0&&(s=null);var a=new ao(e,r,n,s);return this.graphicsData.push(a),this.dirty++,this},t.prototype.drawHole=function(e,r){if(r===void 0&&(r=null),!this.graphicsData.length)return null;var n=new ao(e,null,null,r),s=this.graphicsData[this.graphicsData.length-1];return n.lineStyle=s.lineStyle,s.holes.push(n),this.dirty++,this},t.prototype.destroy=function(){i.prototype.destroy.call(this);for(var e=0;e<this.graphicsData.length;++e)this.graphicsData[e].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null},t.prototype.containsPoint=function(e){for(var r=this.graphicsData,n=0;n<r.length;++n){var s=r[n];if(s.fillStyle.visible&&s.shape&&(s.matrix?s.matrix.applyInverse(e,Pr):Pr.copyFrom(e),s.shape.contains(Pr.x,Pr.y))){var a=!1;if(s.holes)for(var o=0;o<s.holes.length;o++){var h=s.holes[o];if(h.shape.contains(Pr.x,Pr.y)){a=!0;break}}if(!a)return!0}}return!1},t.prototype.updateBatches=function(){if(!this.graphicsData.length){this.batchable=!0;return}if(this.validateBatching()){this.cacheDirty=this.dirty;var e=this.uvs,r=this.graphicsData,n=null,s=null;this.batches.length>0&&(n=this.batches[this.batches.length-1],s=n.style);for(var a=this.shapeIndex;a<r.length;a++){this.shapeIndex++;var o=r[a],h=o.fillStyle,u=o.lineStyle,l=dn[o.type];l.build(o),o.matrix&&this.transformPoints(o.points,o.matrix),(h.visible||u.visible)&&this.processHoles(o.holes);for(var c=0;c<2;c++){var f=c===0?h:u;if(f.visible){var d=f.texture.baseTexture,v=this.indices.length,_=this.points.length/2;d.wrapMode=ne.REPEAT,c===0?this.processFill(o):this.processLine(o);var p=this.points.length/2-_;p!==0&&(n&&!this._compareStyles(s,f)&&(n.end(v,_),n=null),n||(n=so.pop()||new hf,n.begin(f,v,_),this.batches.push(n),s=f),this.addUvs(this.points,e,f.texture,_,p,f.matrix))}}}var g=this.indices.length,y=this.points.length/2;if(n&&n.end(g,y),this.batches.length===0){this.batchable=!0;return}var T=y>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&T===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=T?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}},t.prototype._compareStyles=function(e,r){return!(!e||!r||e.texture.baseTexture!==r.texture.baseTexture||e.color+e.alpha!==r.color+r.alpha||!!e.native!=!!r.native)},t.prototype.validateBatching=function(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(var e=0,r=this.graphicsData.length;e<r;e++){var n=this.graphicsData[e],s=n.fillStyle,a=n.lineStyle;if(s&&!s.texture.baseTexture.valid||a&&!a.texture.baseTexture.valid)return!1}return!0},t.prototype.packBatches=function(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);for(var e=this.batches,r=0,n=e.length;r<n;r++)for(var s=e[r],a=0;a<s.size;a++){var o=s.start+a;this.indicesUint16[o]=this.indicesUint16[o]-s.attribStart}},t.prototype.isBatchable=function(){if(this.points.length>65535*2)return!1;for(var e=this.batches,r=0;r<e.length;r++)if(e[r].style.native)return!1;return this.points.length<t.BATCHABLE_SIZE*2},t.prototype.buildDrawCalls=function(){for(var e=++lt._globalBatch,r=0;r<this.drawCalls.length;r++)this.drawCalls[r].texArray.clear(),pi.push(this.drawCalls[r]);this.drawCalls.length=0;var n=this.colors,s=this.textureIds,a=pi.pop();a||(a=new Vi,a.texArray=new ji),a.texArray.count=0,a.start=0,a.size=0,a.type=jt.TRIANGLES;var o=0,h=null,u=0,l=!1,c=jt.TRIANGLES,f=0;this.drawCalls.push(a);for(var r=0;r<this.batches.length;r++){var d=this.batches[r],v=8,_=d.style,p=_.texture.baseTexture;l!==!!_.native&&(l=!!_.native,c=l?jt.LINES:jt.TRIANGLES,h=null,o=v,e++),h!==p&&(h=p,p._batchEnabled!==e&&(o===v&&(e++,o=0,a.size>0&&(a=pi.pop(),a||(a=new Vi,a.texArray=new ji),this.drawCalls.push(a)),a.start=f,a.size=0,a.texArray.count=0,a.type=c),p.touched=1,p._batchEnabled=e,p._batchLocation=o,p.wrapMode=ne.REPEAT,a.texArray.elements[a.texArray.count++]=p,o++)),a.size+=d.size,f+=d.size,u=p._batchLocation,this.addColors(n,_.color,_.alpha,d.attribSize,d.attribStart),this.addTextureIds(s,u,d.attribSize,d.attribStart)}lt._globalBatch=e,this.packAttributes()},t.prototype.packAttributes=function(){for(var e=this.points,r=this.uvs,n=this.colors,s=this.textureIds,a=new ArrayBuffer(e.length*3*4),o=new Float32Array(a),h=new Uint32Array(a),u=0,l=0;l<e.length/2;l++)o[u++]=e[l*2],o[u++]=e[l*2+1],o[u++]=r[l*2],o[u++]=r[l*2+1],h[u++]=n[l],o[u++]=s[l];this._buffer.update(a),this._indexBuffer.update(this.indicesUint16)},t.prototype.processFill=function(e){if(e.holes.length)ro.triangulate(e,this);else{var r=dn[e.type];r.triangulate(e,this)}},t.prototype.processLine=function(e){io(e,this);for(var r=0;r<e.holes.length;r++)io(e.holes[r],this)},t.prototype.processHoles=function(e){for(var r=0;r<e.length;r++){var n=e[r],s=dn[n.type];s.build(n),n.matrix&&this.transformPoints(n.points,n.matrix)}},t.prototype.calculateBounds=function(){var e=this._bounds;e.clear(),e.addVertexData(this.points,0,this.points.length),e.pad(this.boundsPadding,this.boundsPadding)},t.prototype.transformPoints=function(e,r){for(var n=0;n<e.length/2;n++){var s=e[n*2],a=e[n*2+1];e[n*2]=r.a*s+r.c*a+r.tx,e[n*2+1]=r.b*s+r.d*a+r.ty}},t.prototype.addColors=function(e,r,n,s,a){a===void 0&&(a=0);var o=(r>>16)+(r&65280)+((r&255)<<16),h=Pi(o,n);e.length=Math.max(e.length,a+s);for(var u=0;u<s;u++)e[a+u]=h},t.prototype.addTextureIds=function(e,r,n,s){s===void 0&&(s=0),e.length=Math.max(e.length,s+n);for(var a=0;a<n;a++)e[s+a]=r},t.prototype.addUvs=function(e,r,n,s,a,o){o===void 0&&(o=null);for(var h=0,u=r.length,l=n.frame;h<a;){var c=e[(s+h)*2],f=e[(s+h)*2+1];if(o){var d=o.a*c+o.c*f+o.tx;f=o.b*c+o.d*f+o.ty,c=d}h++,r.push(c/l.width,f/l.height)}var v=n.baseTexture;(l.width<v.width||l.height<v.height)&&this.adjustUvs(r,n,u,a)},t.prototype.adjustUvs=function(e,r,n,s){for(var a=r.baseTexture,o=1e-6,h=n+s*2,u=r.frame,l=u.width/a.width,c=u.height/a.height,f=u.x/u.width,d=u.y/u.height,v=Math.floor(e[n]+o),_=Math.floor(e[n+1]+o),p=n+2;p<h;p+=2)v=Math.min(v,Math.floor(e[p]+o)),_=Math.min(_,Math.floor(e[p+1]+o));f-=v,d-=_;for(var p=n;p<h;p+=2)e[p]=(e[p]+f)*l,e[p+1]=(e[p+1]+d)*c},t.BATCHABLE_SIZE=100,t}(ha),lf=function(i){eo(t,i);function t(){var e=i!==null&&i.apply(this,arguments)||this;return e.width=0,e.alignment=.5,e.native=!1,e.cap=Pe.BUTT,e.join=me.MITER,e.miterLimit=10,e}return t.prototype.clone=function(){var e=new t;return e.color=this.color,e.alpha=this.alpha,e.texture=this.texture,e.matrix=this.matrix,e.visible=this.visible,e.width=this.width,e.alignment=this.alignment,e.native=this.native,e.cap=this.cap,e.join=this.join,e.miterLimit=this.miterLimit,e},t.prototype.reset=function(){i.prototype.reset.call(this),this.color=0,this.alignment=.5,this.width=0,this.native=!1},t}(Qa),hy=new Float32Array(3),oo={},vi=function(i){eo(t,i);function t(e){e===void 0&&(e=null);var r=i.call(this)||this;return r.shader=null,r.pluginName="batch",r.currentPath=null,r.batches=[],r.batchTint=-1,r.batchDirty=-1,r.vertexData=null,r._fillStyle=new Qa,r._lineStyle=new lf,r._matrix=null,r._holeMode=!1,r.state=Oe.for2d(),r._geometry=e||new uf,r._geometry.refCount++,r._transformID=-1,r.tint=16777215,r.blendMode=tt.NORMAL,r}return Object.defineProperty(t.prototype,"geometry",{get:function(){return this._geometry},enumerable:!1,configurable:!0}),t.prototype.clone=function(){return this.finishPoly(),new t(this._geometry)},Object.defineProperty(t.prototype,"blendMode",{get:function(){return this.state.blendMode},set:function(e){this.state.blendMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tint",{get:function(){return this._tint},set:function(e){this._tint=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fill",{get:function(){return this._fillStyle},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"line",{get:function(){return this._lineStyle},enumerable:!1,configurable:!0}),t.prototype.lineStyle=function(e,r,n,s,a){return e===void 0&&(e=null),r===void 0&&(r=0),n===void 0&&(n=1),s===void 0&&(s=.5),a===void 0&&(a=!1),typeof e=="number"&&(e={width:e,color:r,alpha:n,alignment:s,native:a}),this.lineTextureStyle(e)},t.prototype.lineTextureStyle=function(e){e=Object.assign({width:0,texture:it.WHITE,color:e&&e.texture?16777215:0,alpha:1,matrix:null,alignment:.5,native:!1,cap:Pe.BUTT,join:me.MITER,miterLimit:10},e),this.currentPath&&this.startPoly();var r=e.width>0&&e.alpha>0;return r?(e.matrix&&(e.matrix=e.matrix.clone(),e.matrix.invert()),Object.assign(this._lineStyle,{visible:r},e)):this._lineStyle.reset(),this},t.prototype.startPoly=function(){if(this.currentPath){var e=this.currentPath.points,r=this.currentPath.points.length;r>2&&(this.drawShape(this.currentPath),this.currentPath=new Hr,this.currentPath.closeStroke=!1,this.currentPath.points.push(e[r-2],e[r-1]))}else this.currentPath=new Hr,this.currentPath.closeStroke=!1},t.prototype.finishPoly=function(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)},t.prototype.moveTo=function(e,r){return this.startPoly(),this.currentPath.points[0]=e,this.currentPath.points[1]=r,this},t.prototype.lineTo=function(e,r){this.currentPath||this.moveTo(0,0);var n=this.currentPath.points,s=n[n.length-2],a=n[n.length-1];return(s!==e||a!==r)&&n.push(e,r),this},t.prototype._initCurve=function(e,r){e===void 0&&(e=0),r===void 0&&(r=0),this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[e,r]):this.moveTo(e,r)},t.prototype.quadraticCurveTo=function(e,r,n,s){this._initCurve();var a=this.currentPath.points;return a.length===0&&this.moveTo(0,0),of.curveTo(e,r,n,s,a),this},t.prototype.bezierCurveTo=function(e,r,n,s,a,o){return this._initCurve(),af.curveTo(e,r,n,s,a,o,this.currentPath.points),this},t.prototype.arcTo=function(e,r,n,s,a){this._initCurve(e,r);var o=this.currentPath.points,h=no.curveTo(e,r,n,s,a,o);if(h){var u=h.cx,l=h.cy,c=h.radius,f=h.startAngle,d=h.endAngle,v=h.anticlockwise;this.arc(u,l,c,f,d,v)}return this},t.prototype.arc=function(e,r,n,s,a,o){if(o===void 0&&(o=!1),s===a)return this;!o&&a<=s?a+=Xr:o&&s<=a&&(s+=Xr);var h=a-s;if(h===0)return this;var u=e+Math.cos(s)*n,l=r+Math.sin(s)*n,c=this._geometry.closePointEps,f=this.currentPath?this.currentPath.points:null;if(f){var d=Math.abs(f[f.length-2]-u),v=Math.abs(f[f.length-1]-l);d<c&&v<c||f.push(u,l)}else this.moveTo(u,l),f=this.currentPath.points;return no.arc(u,l,e,r,n,s,a,o,f),this},t.prototype.beginFill=function(e,r){return e===void 0&&(e=0),r===void 0&&(r=1),this.beginTextureFill({texture:it.WHITE,color:e,alpha:r})},t.prototype.beginTextureFill=function(e){e=Object.assign({texture:it.WHITE,color:16777215,alpha:1,matrix:null},e),this.currentPath&&this.startPoly();var r=e.alpha>0;return r?(e.matrix&&(e.matrix=e.matrix.clone(),e.matrix.invert()),Object.assign(this._fillStyle,{visible:r},e)):this._fillStyle.reset(),this},t.prototype.endFill=function(){return this.finishPoly(),this._fillStyle.reset(),this},t.prototype.drawRect=function(e,r,n,s){return this.drawShape(new ut(e,r,n,s))},t.prototype.drawRoundedRect=function(e,r,n,s,a){return this.drawShape(new Zh(e,r,n,s,a))},t.prototype.drawCircle=function(e,r,n){return this.drawShape(new $h(e,r,n))},t.prototype.drawEllipse=function(e,r,n,s){return this.drawShape(new Kh(e,r,n,s))},t.prototype.drawPolygon=function(){for(var e=arguments,r=[],n=0;n<arguments.length;n++)r[n]=e[n];var s,a=!0,o=r[0];o.points?(a=o.closeStroke,s=o.points):Array.isArray(r[0])?s=r[0]:s=r;var h=new Hr(s);return h.closeStroke=a,this.drawShape(h),this},t.prototype.drawShape=function(e){return this._holeMode?this._geometry.drawHole(e,this._matrix):this._geometry.drawShape(e,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this},t.prototype.clear=function(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this},t.prototype.isFastRect=function(){var e=this._geometry.graphicsData;return e.length===1&&e[0].shape.type===Rt.RECT&&!e[0].matrix&&!e[0].holes.length&&!(e[0].lineStyle.visible&&e[0].lineStyle.width)},t.prototype._render=function(e){this.finishPoly();var r=this._geometry;r.updateBatches(),r.batchable?(this.batchDirty!==r.batchDirty&&this._populateBatches(),this._renderBatched(e)):(e.batch.flush(),this._renderDirect(e))},t.prototype._populateBatches=function(){var e=this._geometry,r=this.blendMode,n=e.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=e.batchDirty,this.batches.length=n,this.vertexData=new Float32Array(e.points);for(var s=0;s<n;s++){var a=e.batches[s],o=a.style.color,h=new Float32Array(this.vertexData.buffer,a.attribStart*4*2,a.attribSize*2),u=new Float32Array(e.uvsFloat32.buffer,a.attribStart*4*2,a.attribSize*2),l=new Uint16Array(e.indicesUint16.buffer,a.start*2,a.size),c={vertexData:h,blendMode:r,indices:l,uvs:u,_batchRGB:He(o),_tintRGB:o,_texture:a.style.texture,alpha:a.style.alpha,worldAlpha:1};this.batches[s]=c}},t.prototype._renderBatched=function(e){if(this.batches.length){e.batch.setObjectRenderer(e.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(var r=0,n=this.batches.length;r<n;r++){var s=this.batches[r];s.worldAlpha=this.worldAlpha*s.alpha,e.plugins[this.pluginName].render(s)}}},t.prototype._renderDirect=function(e){var r=this._resolveDirectShader(e),n=this._geometry,s=this.tint,a=this.worldAlpha,o=r.uniforms,h=n.drawCalls;o.translationMatrix=this.transform.worldTransform,o.tint[0]=(s>>16&255)/255*a,o.tint[1]=(s>>8&255)/255*a,o.tint[2]=(s&255)/255*a,o.tint[3]=a,e.shader.bind(r),e.geometry.bind(n,r),e.state.set(this.state);for(var u=0,l=h.length;u<l;u++)this._renderDrawCallDirect(e,n.drawCalls[u])},t.prototype._renderDrawCallDirect=function(e,r){for(var n=r.texArray,s=r.type,a=r.size,o=r.start,h=n.count,u=0;u<h;u++)e.texture.bind(n.elements[u],u);e.geometry.draw(s,a,o)},t.prototype._resolveDirectShader=function(e){var r=this.shader,n=this.pluginName;if(!r){if(!oo[n]){for(var s=e.plugins[n].MAX_TEXTURES,a=new Int32Array(s),o=0;o<s;o++)a[o]=o;var h={tint:new Float32Array([1,1,1,1]),translationMatrix:new bt,default:Re.from({uSamplers:a},!0)},u=e.plugins[n]._shader.program;oo[n]=new be(u,h)}r=oo[n]}return r},t.prototype._calculateBounds=function(){this.finishPoly();var e=this._geometry;if(e.graphicsData.length){var r=e.bounds,n=r.minX,s=r.minY,a=r.maxX,o=r.maxY;this._bounds.addFrame(this.transform,n,s,a,o)}},t.prototype.containsPoint=function(e){return this.worldTransform.applyInverse(e,t._TEMP_POINT),this._geometry.containsPoint(t._TEMP_POINT)},t.prototype.calculateTints=function(){if(this.batchTint!==this.tint){this.batchTint=this.tint;for(var e=He(this.tint,hy),r=0;r<this.batches.length;r++){var n=this.batches[r],s=n._batchRGB,a=e[0]*s[0]*255,o=e[1]*s[1]*255,h=e[2]*s[2]*255,u=(a<<16)+(o<<8)+(h|0);n._tintRGB=(u>>16)+(u&65280)+((u&255)<<16)}}},t.prototype.calculateVertices=function(){var e=this.transform._worldID;if(this._transformID!==e){this._transformID=e;for(var r=this.transform.worldTransform,n=r.a,s=r.b,a=r.c,o=r.d,h=r.tx,u=r.ty,l=this._geometry.points,c=this.vertexData,f=0,d=0;d<l.length;d+=2){var v=l[d],_=l[d+1];c[f++]=n*v+a*_+h,c[f++]=o*_+s*v+u}}},t.prototype.closePath=function(){var e=this.currentPath;return e&&(e.closeStroke=!0,this.finishPoly()),this},t.prototype.setMatrix=function(e){return this._matrix=e,this},t.prototype.beginHole=function(){return this.finishPoly(),this._holeMode=!0,this},t.prototype.endHole=function(){return this.finishPoly(),this._holeMode=!1,this},t.prototype.destroy=function(e){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,i.prototype.destroy.call(this,e)},t.nextRoundedRectBehavior=!1,t._TEMP_POINT=new vt,t}(Zt),uy={buildPoly:ro,buildCircle:di,buildRectangle:rf,buildRoundedRectangle:nf,buildLine:io,ArcUtils:no,BezierUtils:af,QuadraticUtils:of,BatchPart:hf,FILL_COMMANDS:dn,BATCH_POOL:so,DRAW_CALL_POOL:pi};var ho=function(i,t){return ho=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},ho(i,t)};function ly(i,t){ho(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var _i=new vt,fy=new Uint16Array([0,1,2,0,2,3]),wr=function(i){ly(t,i);function t(e){var r=i.call(this)||this;return r._anchor=new Ae(r._onAnchorUpdate,r,e?e.defaultAnchor.x:0,e?e.defaultAnchor.y:0),r._texture=null,r._width=0,r._height=0,r._tint=null,r._tintRGB=null,r.tint=16777215,r.blendMode=tt.NORMAL,r._cachedTint=16777215,r.uvs=null,r.texture=e||it.EMPTY,r.vertexData=new Float32Array(8),r.vertexTrimmedData=null,r._transformID=-1,r._textureID=-1,r._transformTrimmedID=-1,r._textureTrimmedID=-1,r.indices=fy,r.pluginName="batch",r.isSprite=!0,r._roundPixels=z.ROUND_PIXELS,r}return t.prototype._onTextureUpdate=function(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=je(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=je(this.scale.y)*this._height/this._texture.orig.height)},t.prototype._onAnchorUpdate=function(){this._transformID=-1,this._transformTrimmedID=-1},t.prototype.calculateVertices=function(){var e=this._texture;if(!(this._transformID===this.transform._worldID&&this._textureID===e._updateID)){this._textureID!==e._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=e._updateID;var r=this.transform.worldTransform,n=r.a,s=r.b,a=r.c,o=r.d,h=r.tx,u=r.ty,l=this.vertexData,c=e.trim,f=e.orig,d=this._anchor,v=0,_=0,p=0,g=0;if(c?(_=c.x-d._x*f.width,v=_+c.width,g=c.y-d._y*f.height,p=g+c.height):(_=-d._x*f.width,v=_+f.width,g=-d._y*f.height,p=g+f.height),l[0]=n*_+a*g+h,l[1]=o*g+s*_+u,l[2]=n*v+a*g+h,l[3]=o*g+s*v+u,l[4]=n*v+a*p+h,l[5]=o*p+s*v+u,l[6]=n*_+a*p+h,l[7]=o*p+s*_+u,this._roundPixels)for(var y=z.RESOLUTION,T=0;T<l.length;++T)l[T]=Math.round((l[T]*y|0)/y)}},t.prototype.calculateTrimmedVertices=function(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;var e=this._texture,r=this.vertexTrimmedData,n=e.orig,s=this._anchor,a=this.transform.worldTransform,o=a.a,h=a.b,u=a.c,l=a.d,c=a.tx,f=a.ty,d=-s._x*n.width,v=d+n.width,_=-s._y*n.height,p=_+n.height;r[0]=o*d+u*_+c,r[1]=l*_+h*d+f,r[2]=o*v+u*_+c,r[3]=l*_+h*v+f,r[4]=o*v+u*p+c,r[5]=l*p+h*v+f,r[6]=o*d+u*p+c,r[7]=l*p+h*d+f},t.prototype._render=function(e){this.calculateVertices(),e.batch.setObjectRenderer(e.plugins[this.pluginName]),e.plugins[this.pluginName].render(this)},t.prototype._calculateBounds=function(){var e=this._texture.trim,r=this._texture.orig;!e||e.width===r.width&&e.height===r.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))},t.prototype.getLocalBounds=function(e){return this.children.length===0?(this._localBounds||(this._localBounds=new $r),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),e||(this._localBoundsRect||(this._localBoundsRect=new ut),e=this._localBoundsRect),this._localBounds.getRectangle(e)):i.prototype.getLocalBounds.call(this,e)},t.prototype.containsPoint=function(e){this.worldTransform.applyInverse(e,_i);var r=this._texture.orig.width,n=this._texture.orig.height,s=-r*this.anchor.x,a=0;return _i.x>=s&&_i.x<s+r&&(a=-n*this.anchor.y,_i.y>=a&&_i.y<a+n)},t.prototype.destroy=function(e){i.prototype.destroy.call(this,e),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null;var r=typeof e=="boolean"?e:e&&e.texture;if(r){var n=typeof e=="boolean"?e:e&&e.baseTexture;this._texture.destroy(!!n)}this._texture=null},t.from=function(e,r){var n=e instanceof it?e:it.from(e,r);return new t(n)},Object.defineProperty(t.prototype,"roundPixels",{get:function(){return this._roundPixels},set:function(e){this._roundPixels!==e&&(this._transformID=-1),this._roundPixels=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return Math.abs(this.scale.x)*this._texture.orig.width},set:function(e){var r=je(this.scale.x)||1;this.scale.x=r*e/this._texture.orig.width,this._width=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return Math.abs(this.scale.y)*this._texture.orig.height},set:function(e){var r=je(this.scale.y)||1;this.scale.y=r*e/this._texture.orig.height,this._height=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"anchor",{get:function(){return this._anchor},set:function(e){this._anchor.copyFrom(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tint",{get:function(){return this._tint},set:function(e){this._tint=e,this._tintRGB=(e>>16)+(e&65280)+((e&255)<<16)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"texture",{get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=e||it.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,e&&(e.baseTexture.valid?this._onTextureUpdate():e.once("update",this._onTextureUpdate,this)))},enumerable:!1,configurable:!0}),t}(Zt);var uo=function(i,t){return uo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},uo(i,t)};function cy(i,t){uo(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Cr;(function(i){i[i.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",i[i.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL"})(Cr||(Cr={}));var lo={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:Cr.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100,leading:0},dy=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],lr=function(){function i(t){this.styleID=0,this.reset(),co(this,t,t)}return i.prototype.clone=function(){var t={};return co(t,this,lo),new i(t)},i.prototype.reset=function(){co(this,lo,lo)},Object.defineProperty(i.prototype,"align",{get:function(){return this._align},set:function(t){this._align!==t&&(this._align=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"breakWords",{get:function(){return this._breakWords},set:function(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"dropShadow",{get:function(){return this._dropShadow},set:function(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"dropShadowAlpha",{get:function(){return this._dropShadowAlpha},set:function(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"dropShadowAngle",{get:function(){return this._dropShadowAngle},set:function(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"dropShadowBlur",{get:function(){return this._dropShadowBlur},set:function(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"dropShadowColor",{get:function(){return this._dropShadowColor},set:function(t){var e=fo(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"dropShadowDistance",{get:function(){return this._dropShadowDistance},set:function(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"fill",{get:function(){return this._fill},set:function(t){var e=fo(t);this._fill!==e&&(this._fill=e,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"fillGradientType",{get:function(){return this._fillGradientType},set:function(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"fillGradientStops",{get:function(){return this._fillGradientStops},set:function(t){py(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"fontSize",{get:function(){return this._fontSize},set:function(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"fontStyle",{get:function(){return this._fontStyle},set:function(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"fontVariant",{get:function(){return this._fontVariant},set:function(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"letterSpacing",{get:function(){return this._letterSpacing},set:function(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"lineHeight",{get:function(){return this._lineHeight},set:function(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"leading",{get:function(){return this._leading},set:function(t){this._leading!==t&&(this._leading=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"lineJoin",{get:function(){return this._lineJoin},set:function(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"miterLimit",{get:function(){return this._miterLimit},set:function(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"padding",{get:function(){return this._padding},set:function(t){this._padding!==t&&(this._padding=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stroke",{get:function(){return this._stroke},set:function(t){var e=fo(t);this._stroke!==e&&(this._stroke=e,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"strokeThickness",{get:function(){return this._strokeThickness},set:function(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"textBaseline",{get:function(){return this._textBaseline},set:function(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"trim",{get:function(){return this._trim},set:function(t){this._trim!==t&&(this._trim=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"whiteSpace",{get:function(){return this._whiteSpace},set:function(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"wordWrap",{get:function(){return this._wordWrap},set:function(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"wordWrapWidth",{get:function(){return this._wordWrapWidth},set:function(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)},enumerable:!1,configurable:!0}),i.prototype.toFontString=function(){var t=typeof this.fontSize=="number"?this.fontSize+"px":this.fontSize,e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(var r=e.length-1;r>=0;r--){var n=e[r].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&dy.indexOf(n)<0&&(n='"'+n+'"'),e[r]=n}return this.fontStyle+" "+this.fontVariant+" "+this.fontWeight+" "+t+" "+e.join(",")},i}();function ff(i){return typeof i=="number"?cs(i):(typeof i=="string"&&i.indexOf("0x")===0&&(i=i.replace("0x","#")),i)}function fo(i){if(Array.isArray(i)){for(var t=0;t<i.length;++t)i[t]=ff(i[t]);return i}else return ff(i)}function py(i,t){if(!Array.isArray(i)||!Array.isArray(t)||i.length!==t.length)return!1;for(var e=0;e<i.length;++e)if(i[e]!==t[e])return!1;return!0}function co(i,t,e){for(var r in e)Array.isArray(t[r])?i[r]=t[r].slice():i[r]=t[r]}var pn={willReadFrequently:!0},le=function(){function i(t,e,r,n,s,a,o,h,u){this.text=t,this.style=e,this.width=r,this.height=n,this.lines=s,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=u}return i.measureText=function(t,e,r,n){n===void 0&&(n=i._canvas),r=r??e.wordWrap;var s=e.toFontString(),a=i.measureFont(s);a.fontSize===0&&(a.fontSize=e.fontSize,a.ascent=e.fontSize);var o=n.getContext("2d",pn);o.font=s;for(var h=r?i.wordWrap(t,e,n):t,u=h.split(/(?:\r\n|\r|\n)/),l=new Array(u.length),c=0,f=0;f<u.length;f++){var d=o.measureText(u[f]).width+(u[f].length-1)*e.letterSpacing;l[f]=d,c=Math.max(c,d)}var v=c+e.strokeThickness;e.dropShadow&&(v+=e.dropShadowDistance);var _=e.lineHeight||a.fontSize+e.strokeThickness,p=Math.max(_,a.fontSize+e.strokeThickness)+(u.length-1)*(_+e.leading);return e.dropShadow&&(p+=e.dropShadowDistance),new i(t,e,v,p,u,l,_+e.leading,c,a)},i.wordWrap=function(t,e,r){r===void 0&&(r=i._canvas);for(var n=r.getContext("2d",pn),s=0,a="",o="",h=Object.create(null),u=e.letterSpacing,l=e.whiteSpace,c=i.collapseSpaces(l),f=i.collapseNewlines(l),d=!c,v=e.wordWrapWidth+u,_=i.tokenize(t),p=0;p<_.length;p++){var g=_[p];if(i.isNewline(g)){if(!f){o+=i.addLine(a),d=!c,a="",s=0;continue}g=" "}if(c){var y=i.isBreakingSpace(g),T=i.isBreakingSpace(a[a.length-1]);if(y&&T)continue}var I=i.getFromCache(g,u,h,n);if(I>v)if(a!==""&&(o+=i.addLine(a),a="",s=0),i.canBreakWords(g,e.breakWords))for(var m=i.wordWrapSplit(g),S=0;S<m.length;S++){for(var x=m[S],N=1;m[S+N];){var D=m[S+N],F=x[x.length-1];if(!i.canBreakChars(F,D,g,S,e.breakWords))x+=D;else break;N++}S+=x.length-1;var k=i.getFromCache(x,u,h,n);k+s>v&&(o+=i.addLine(a),d=!1,a="",s=0),a+=x,s+=k}else{a.length>0&&(o+=i.addLine(a),a="",s=0);var L=p===_.length-1;o+=i.addLine(g,!L),d=!1,a="",s=0}else I+s>v&&(d=!1,o+=i.addLine(a),a="",s=0),(a.length>0||!i.isBreakingSpace(g)||d)&&(a+=g,s+=I)}return o+=i.addLine(a,!1),o},i.addLine=function(t,e){return e===void 0&&(e=!0),t=i.trimRight(t),t=e?t+`
541
- `:t,t},i.getFromCache=function(t,e,r,n){var s=r[t];if(typeof s!="number"){var a=t.length*e;s=n.measureText(t).width+a,r[t]=s}return s},i.collapseSpaces=function(t){return t==="normal"||t==="pre-line"},i.collapseNewlines=function(t){return t==="normal"},i.trimRight=function(t){if(typeof t!="string")return"";for(var e=t.length-1;e>=0;e--){var r=t[e];if(!i.isBreakingSpace(r))break;t=t.slice(0,-1)}return t},i.isNewline=function(t){return typeof t!="string"?!1:i._newlines.indexOf(t.charCodeAt(0))>=0},i.isBreakingSpace=function(t,e){return typeof t!="string"?!1:i._breakingSpaces.indexOf(t.charCodeAt(0))>=0},i.tokenize=function(t){var e=[],r="";if(typeof t!="string")return e;for(var n=0;n<t.length;n++){var s=t[n],a=t[n+1];if(i.isBreakingSpace(s,a)||i.isNewline(s)){r!==""&&(e.push(r),r=""),e.push(s);continue}r+=s}return r!==""&&e.push(r),e},i.canBreakWords=function(t,e){return e},i.canBreakChars=function(t,e,r,n,s){return!0},i.wordWrapSplit=function(t){return t.split("")},i.measureFont=function(t){if(i._fonts[t])return i._fonts[t];var e={ascent:0,descent:0,fontSize:0},r=i._canvas,n=i._context;n.font=t;var s=i.METRICS_STRING+i.BASELINE_SYMBOL,a=Math.ceil(n.measureText(s).width),o=Math.ceil(n.measureText(i.BASELINE_SYMBOL).width),h=Math.ceil(i.HEIGHT_MULTIPLIER*o);o=o*i.BASELINE_MULTIPLIER|0,r.width=a,r.height=h,n.fillStyle="#f00",n.fillRect(0,0,a,h),n.font=t,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText(s,0,o);var u=n.getImageData(0,0,a,h).data,l=u.length,c=a*4,f=0,d=0,v=!1;for(f=0;f<o;++f){for(var _=0;_<c;_+=4)if(u[d+_]!==255){v=!0;break}if(!v)d+=c;else break}for(e.ascent=o-f,d=l-c,v=!1,f=h;f>o;--f){for(var _=0;_<c;_+=4)if(u[d+_]!==255){v=!0;break}if(!v)d-=c;else break}return e.descent=f-o,e.fontSize=e.ascent+e.descent,i._fonts[t]=e,e},i.clearMetrics=function(t){t===void 0&&(t=""),t?delete i._fonts[t]:i._fonts={}},Object.defineProperty(i,"_canvas",{get:function(){if(!i.__canvas){var t=void 0;try{var e=new OffscreenCanvas(0,0),r=e.getContext("2d",pn);if(r&&r.measureText)return i.__canvas=e,e;t=z.ADAPTER.createCanvas()}catch{t=z.ADAPTER.createCanvas()}t.width=t.height=10,i.__canvas=t}return i.__canvas},enumerable:!1,configurable:!0}),Object.defineProperty(i,"_context",{get:function(){return i.__context||(i.__context=i._canvas.getContext("2d",pn)),i.__context},enumerable:!1,configurable:!0}),i}();le._fonts={},le.METRICS_STRING="|ÉqÅ",le.BASELINE_SYMBOL="M",le.BASELINE_MULTIPLIER=1.4,le.HEIGHT_MULTIPLIER=2,le._newlines=[10,13],le._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];var vy={texture:!0,children:!1,baseTexture:!0},po=function(i){cy(t,i);function t(e,r,n){var s=this,a=!1;n||(n=z.ADAPTER.createCanvas(),a=!0),n.width=3,n.height=3;var o=it.from(n);return o.orig=new ut,o.trim=new ut,s=i.call(this,o)||this,s._ownCanvas=a,s.canvas=n,s.context=n.getContext("2d",{willReadFrequently:!0}),s._resolution=z.RESOLUTION,s._autoResolution=!0,s._text=null,s._style=null,s._styleListener=null,s._font="",s.text=e,s.style=r,s.localStyleID=-1,s}return t.prototype.updateText=function(e){var r=this._style;if(this.localStyleID!==r.styleID&&(this.dirty=!0,this.localStyleID=r.styleID),!(!this.dirty&&e)){this._font=this._style.toFontString();var n=this.context,s=le.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),a=s.width,o=s.height,h=s.lines,u=s.lineHeight,l=s.lineWidths,c=s.maxLineWidth,f=s.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,a)+r.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,o)+r.padding*2)*this._resolution),n.scale(this._resolution,this._resolution),n.clearRect(0,0,this.canvas.width,this.canvas.height),n.font=this._font,n.lineWidth=r.strokeThickness,n.textBaseline=r.textBaseline,n.lineJoin=r.lineJoin,n.miterLimit=r.miterLimit;for(var d,v,_=r.dropShadow?2:1,p=0;p<_;++p){var g=r.dropShadow&&p===0,y=g?Math.ceil(Math.max(1,o)+r.padding*2):0,T=y*this._resolution;if(g){n.fillStyle="black",n.strokeStyle="black";var I=r.dropShadowColor,m=He(typeof I=="number"?I:ds(I)),S=r.dropShadowBlur*this._resolution,x=r.dropShadowDistance*this._resolution;n.shadowColor="rgba("+m[0]*255+","+m[1]*255+","+m[2]*255+","+r.dropShadowAlpha+")",n.shadowBlur=S,n.shadowOffsetX=Math.cos(r.dropShadowAngle)*x,n.shadowOffsetY=Math.sin(r.dropShadowAngle)*x+T}else n.fillStyle=this._generateFillStyle(r,h,s),n.strokeStyle=r.stroke,n.shadowColor="black",n.shadowBlur=0,n.shadowOffsetX=0,n.shadowOffsetY=0;var N=(u-f.fontSize)/2;(!t.nextLineHeightBehavior||u-f.fontSize<0)&&(N=0);for(var D=0;D<h.length;D++)d=r.strokeThickness/2,v=r.strokeThickness/2+D*u+f.ascent+N,r.align==="right"?d+=c-l[D]:r.align==="center"&&(d+=(c-l[D])/2),r.stroke&&r.strokeThickness&&this.drawLetterSpacing(h[D],d+r.padding,v+r.padding-y,!0),r.fill&&this.drawLetterSpacing(h[D],d+r.padding,v+r.padding-y)}this.updateTexture()}},t.prototype.drawLetterSpacing=function(e,r,n,s){s===void 0&&(s=!1);var a=this._style,o=a.letterSpacing,h=t.experimentalLetterSpacing&&("letterSpacing"in CanvasRenderingContext2D.prototype||"textLetterSpacing"in CanvasRenderingContext2D.prototype);if(o===0||h){h&&(this.context.letterSpacing=o,this.context.textLetterSpacing=o),s?this.context.strokeText(e,r,n):this.context.fillText(e,r,n);return}for(var u=r,l=Array.from?Array.from(e):e.split(""),c=this.context.measureText(e).width,f=0,d=0;d<l.length;++d){var v=l[d];s?this.context.strokeText(v,u,n):this.context.fillText(v,u,n);for(var _="",p=d+1;p<l.length;++p)_+=l[p];f=this.context.measureText(_).width,u+=c-f+o,c=f}},t.prototype.updateTexture=function(){var e=this.canvas;if(this._style.trim){var r=jh(e);r.data&&(e.width=r.width,e.height=r.height,this.context.putImageData(r.data,0,0))}var n=this._texture,s=this._style,a=s.trim?0:s.padding,o=n.baseTexture;n.trim.width=n._frame.width=e.width/this._resolution,n.trim.height=n._frame.height=e.height/this._resolution,n.trim.x=-a,n.trim.y=-a,n.orig.width=n._frame.width-a*2,n.orig.height=n._frame.height-a*2,this._onTextureUpdate(),o.setRealSize(e.width,e.height,this._resolution),n.updateUvs(),this.dirty=!1},t.prototype._render=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),i.prototype._render.call(this,e)},t.prototype.updateTransform=function(){this.updateText(!0),i.prototype.updateTransform.call(this)},t.prototype.getBounds=function(e,r){return this.updateText(!0),this._textureID===-1&&(e=!1),i.prototype.getBounds.call(this,e,r)},t.prototype.getLocalBounds=function(e){return this.updateText(!0),i.prototype.getLocalBounds.call(this,e)},t.prototype._calculateBounds=function(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)},t.prototype._generateFillStyle=function(e,r,n){var s=e.fill;if(Array.isArray(s)){if(s.length===1)return s[0]}else return s;var a,o=e.dropShadow?e.dropShadowDistance:0,h=e.padding||0,u=this.canvas.width/this._resolution-o-h*2,l=this.canvas.height/this._resolution-o-h*2,c=s.slice(),f=e.fillGradientStops.slice();if(!f.length)for(var d=c.length+1,v=1;v<d;++v)f.push(v/d);if(c.unshift(s[0]),f.unshift(0),c.push(s[s.length-1]),f.push(1),e.fillGradientType===Cr.LINEAR_VERTICAL){a=this.context.createLinearGradient(u/2,h,u/2,l+h);for(var _=n.fontProperties.fontSize+e.strokeThickness,v=0;v<r.length;v++){var p=n.lineHeight*(v-1)+_,g=n.lineHeight*v,y=g;v>0&&p>g&&(y=(g+p)/2);var T=g+_,I=n.lineHeight*(v+1),m=T;v+1<r.length&&I<T&&(m=(T+I)/2);for(var S=(m-y)/l,x=0;x<c.length;x++){var N=0;typeof f[x]=="number"?N=f[x]:N=x/c.length;var D=Math.min(1,Math.max(0,y/l+N*S));D=Number(D.toFixed(5)),a.addColorStop(D,c[x])}}}else{a=this.context.createLinearGradient(h,l/2,u+h,l/2);for(var F=c.length+1,k=1,v=0;v<c.length;v++){var L=void 0;typeof f[v]=="number"?L=f[v]:L=k/F,a.addColorStop(L,c[v]),k++}}return a},t.prototype.destroy=function(e){typeof e=="boolean"&&(e={children:e}),e=Object.assign({},vy,e),i.prototype.destroy.call(this,e),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null},Object.defineProperty(t.prototype,"width",{get:function(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width},set:function(e){this.updateText(!0);var r=je(this.scale.x)||1;this.scale.x=r*e/this._texture.orig.width,this._width=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height},set:function(e){this.updateText(!0);var r=je(this.scale.y)||1;this.scale.y=r*e/this._texture.orig.height,this._height=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"style",{get:function(){return this._style},set:function(e){e=e||{},e instanceof lr?this._style=e:this._style=new lr(e),this.localStyleID=-1,this.dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"text",{get:function(){return this._text},set:function(e){e=String(e??""),this._text!==e&&(this._text=e,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resolution",{get:function(){return this._resolution},set:function(e){this._autoResolution=!1,this._resolution!==e&&(this._resolution=e,this.dirty=!0)},enumerable:!1,configurable:!0}),t.nextLineHeightBehavior=!1,t.experimentalLetterSpacing=!1,t}(wr);z.UPLOADS_PER_FRAME=4;var vo=function(i,t){return vo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},vo(i,t)};function _y(i,t){vo(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var cf=function(){function i(t){this.maxItemsPerFrame=t,this.itemsLeft=0}return i.prototype.beginFrame=function(){this.itemsLeft=this.maxItemsPerFrame},i.prototype.allowedToUpload=function(){return this.itemsLeft-- >0},i}();function gy(i,t){var e=!1;if(i&&i._textures&&i._textures.length){for(var r=0;r<i._textures.length;r++)if(i._textures[r]instanceof it){var n=i._textures[r].baseTexture;t.indexOf(n)===-1&&(t.push(n),e=!0)}}return e}function my(i,t){if(i.baseTexture instanceof lt){var e=i.baseTexture;return t.indexOf(e)===-1&&t.push(e),!0}return!1}function yy(i,t){if(i._texture&&i._texture instanceof it){var e=i._texture.baseTexture;return t.indexOf(e)===-1&&t.push(e),!0}return!1}function xy(i,t){return t instanceof po?(t.updateText(!0),!0):!1}function by(i,t){if(t instanceof lr){var e=t.toFontString();return le.measureFont(e),!0}return!1}function Ty(i,t){if(i instanceof po){t.indexOf(i.style)===-1&&t.push(i.style),t.indexOf(i)===-1&&t.push(i);var e=i._texture.baseTexture;return t.indexOf(e)===-1&&t.push(e),!0}return!1}function Ey(i,t){return i instanceof lr?(t.indexOf(i)===-1&&t.push(i),!0):!1}var df=function(){function i(t){var e=this;this.limiter=new cf(z.UPLOADS_PER_FRAME),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=function(){e.queue&&e.prepareItems()},this.registerFindHook(Ty),this.registerFindHook(Ey),this.registerFindHook(gy),this.registerFindHook(my),this.registerFindHook(yy),this.registerUploadHook(xy),this.registerUploadHook(by)}return i.prototype.upload=function(t,e){var r=this;return typeof t=="function"&&(e=t,t=null),e&&Bt("6.5.0","BasePrepare.upload callback is deprecated, use the return Promise instead."),new Promise(function(n){t&&r.add(t);var s=function(){e==null||e(),n()};r.queue.length?(r.completes.push(s),r.ticking||(r.ticking=!0,Ot.system.addOnce(r.tick,r,de.UTILITY))):s()})},i.prototype.tick=function(){setTimeout(this.delayedTick,0)},i.prototype.prepareItems=function(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){var t=this.queue[0],e=!1;if(t&&!t._destroyed){for(var r=0,n=this.uploadHooks.length;r<n;r++)if(this.uploadHooks[r](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)Ot.system.addOnce(this.tick,this,de.UTILITY);else{this.ticking=!1;var s=this.completes.slice(0);this.completes.length=0;for(var r=0,n=s.length;r<n;r++)s[r]()}},i.prototype.registerFindHook=function(t){return t&&this.addHooks.push(t),this},i.prototype.registerUploadHook=function(t){return t&&this.uploadHooks.push(t),this},i.prototype.add=function(t){for(var e=0,r=this.addHooks.length;e<r&&!this.addHooks[e](t,this.queue);e++);if(t instanceof Zt)for(var e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this},i.prototype.destroy=function(){this.ticking&&Ot.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null},i}();function pf(i,t){return t instanceof lt?(t._glTextures[i.CONTEXT_UID]||i.texture.bind(t),!0):!1}function Sy(i,t){if(!(t instanceof vi))return!1;var e=t.geometry;t.finishPoly(),e.updateBatches();for(var r=e.batches,n=0;n<r.length;n++){var s=r[n].style.texture;s&&pf(i,s.baseTexture)}return e.batchable||i.geometry.bind(e,t._resolveDirectShader(i)),!0}function Py(i,t){return i instanceof vi?(t.push(i),!0):!1}var vf=function(i){_y(t,i);function t(e){var r=i.call(this,e)||this;return r.uploadHookHelper=r.renderer,r.registerFindHook(Py),r.registerUploadHook(pf),r.registerUploadHook(Sy),r}return t.extension={name:"prepare",type:dt.RendererPlugin},t}(df),wy=function(){function i(t){this.maxMilliseconds=t,this.frameStart=0}return i.prototype.beginFrame=function(){this.frameStart=Date.now()},i.prototype.allowedToUpload=function(){return Date.now()-this.frameStart<this.maxMilliseconds},i}();var _f=function(){function i(t,e,r){r===void 0&&(r=null),this.linkedSheets=[],this._texture=t instanceof it?t:null,this.baseTexture=t instanceof lt?t:this._texture.baseTexture,this.textures={},this.animations={},this.data=e;var n=this.baseTexture.resource;this.resolution=this._updateResolution(r||(n?n.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}return i.prototype._updateResolution=function(t){t===void 0&&(t=null);var e=this.data.meta.scale,r=Gr(t,null);return r===null&&(r=e!==void 0?parseFloat(e):1),r!==1&&this.baseTexture.setResolution(r),r},i.prototype.parse=function(t){var e=this;return t&&Bt("6.5.0","Spritesheet.parse callback is deprecated, use the return Promise instead."),new Promise(function(r){e._callback=function(n){t==null||t(n),r(n)},e._batchIndex=0,e._frameKeys.length<=i.BATCH_SIZE?(e._processFrames(0),e._processAnimations(),e._parseComplete()):e._nextBatch()})},i.prototype._processFrames=function(t){for(var e=t,r=i.BATCH_SIZE;e-t<r&&e<this._frameKeys.length;){var n=this._frameKeys[e],s=this._frames[n],a=s.frame;if(a){var o=null,h=null,u=s.trimmed!==!1&&s.sourceSize?s.sourceSize:s.frame,l=new ut(0,0,Math.floor(u.w)/this.resolution,Math.floor(u.h)/this.resolution);s.rotated?o=new ut(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):o=new ut(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),s.trimmed!==!1&&s.spriteSourceSize&&(h=new ut(Math.floor(s.spriteSourceSize.x)/this.resolution,Math.floor(s.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[n]=new it(this.baseTexture,o,l,h,s.rotated?2:0,s.anchor),it.addToCache(this.textures[n],n)}e++}},i.prototype._processAnimations=function(){var t=this.data.animations||{};for(var e in t){this.animations[e]=[];for(var r=0;r<t[e].length;r++){var n=t[e][r];this.animations[e].push(this.textures[n])}}},i.prototype._parseComplete=function(){var t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)},i.prototype._nextBatch=function(){var t=this;this._processFrames(this._batchIndex*i.BATCH_SIZE),this._batchIndex++,setTimeout(function(){t._batchIndex*i.BATCH_SIZE<t._frameKeys.length?t._nextBatch():(t._processAnimations(),t._parseComplete())},0)},i.prototype.destroy=function(t){var e;t===void 0&&(t=!1);for(var r in this.textures)this.textures[r].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)===null||e===void 0||e.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]},i.BATCH_SIZE=1e3,i}(),gf=function(){function i(){}return i.use=function(t,e){var r,n,s=this,a=t.name+"_image";if(!t.data||t.type!==wt.TYPE.JSON||!t.data.frames||s.resources[a]){e();return}var o=(n=(r=t.data)===null||r===void 0?void 0:r.meta)===null||n===void 0?void 0:n.related_multi_packs;if(Array.isArray(o))for(var h=function(v){if(typeof v!="string")return"continue";var _=v.replace(".json",""),p=ce.resolve(t.url.replace(s.baseUrl,""),v);if(s.resources[_]||Object.values(s.resources).some(function(y){return ce.format(ce.parse(y.url))===p}))return"continue";var g={crossOrigin:t.crossOrigin,loadType:wt.LOAD_TYPE.XHR,xhrType:wt.XHR_RESPONSE_TYPE.JSON,parentResource:t,metadata:t.metadata};s.add(_,p,g)},u=0,l=o;u<l.length;u++){var c=l[u];h(c)}var f={crossOrigin:t.crossOrigin,metadata:t.metadata.imageMetadata,parentResource:t},d=i.getResourcePath(t,s.baseUrl);s.add(a,d,f,function(_){if(_.error){e(_.error);return}var p=new _f(_.texture,t.data,t.url);p.parse().then(function(){t.spritesheet=p,t.textures=p.textures,e()})})},i.getResourcePath=function(t,e){return t.isDataUrl?t.data.meta.image:ce.resolve(t.url.replace(e,""),t.data.meta.image)},i.extension=dt.Loader,i}();var _o=function(i,t){return _o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},_o(i,t)};function mf(i,t){_o(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var gi=new vt,Cy=function(i){mf(t,i);function t(e,r,n){r===void 0&&(r=100),n===void 0&&(n=100);var s=i.call(this,e)||this;return s.tileTransform=new Mi,s._width=r,s._height=n,s.uvMatrix=s.texture.uvMatrix||new Gi(e),s.pluginName="tilingSprite",s.uvRespectAnchor=!1,s}return Object.defineProperty(t.prototype,"clampMargin",{get:function(){return this.uvMatrix.clampMargin},set:function(e){this.uvMatrix.clampMargin=e,this.uvMatrix.update(!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tileScale",{get:function(){return this.tileTransform.scale},set:function(e){this.tileTransform.scale.copyFrom(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tilePosition",{get:function(){return this.tileTransform.position},set:function(e){this.tileTransform.position.copyFrom(e)},enumerable:!1,configurable:!0}),t.prototype._onTextureUpdate=function(){this.uvMatrix&&(this.uvMatrix.texture=this._texture),this._cachedTint=16777215},t.prototype._render=function(e){var r=this._texture;!r||!r.valid||(this.tileTransform.updateLocalTransform(),this.uvMatrix.update(),e.batch.setObjectRenderer(e.plugins[this.pluginName]),e.plugins[this.pluginName].render(this))},t.prototype._calculateBounds=function(){var e=this._width*-this._anchor._x,r=this._height*-this._anchor._y,n=this._width*(1-this._anchor._x),s=this._height*(1-this._anchor._y);this._bounds.addFrame(this.transform,e,r,n,s)},t.prototype.getLocalBounds=function(e){return this.children.length===0?(this._bounds.minX=this._width*-this._anchor._x,this._bounds.minY=this._height*-this._anchor._y,this._bounds.maxX=this._width*(1-this._anchor._x),this._bounds.maxY=this._height*(1-this._anchor._y),e||(this._localBoundsRect||(this._localBoundsRect=new ut),e=this._localBoundsRect),this._bounds.getRectangle(e)):i.prototype.getLocalBounds.call(this,e)},t.prototype.containsPoint=function(e){this.worldTransform.applyInverse(e,gi);var r=this._width,n=this._height,s=-r*this.anchor._x;if(gi.x>=s&&gi.x<s+r){var a=-n*this.anchor._y;if(gi.y>=a&&gi.y<a+n)return!0}return!1},t.prototype.destroy=function(e){i.prototype.destroy.call(this,e),this.tileTransform=null,this.uvMatrix=null},t.from=function(e,r){var n=e instanceof it?e:it.from(e,r);return new t(n,r.width,r.height)},Object.defineProperty(t.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e},enumerable:!1,configurable:!0}),t}(wr),Iy=`#version 100
542
- #define SHADER_NAME Tiling-Sprite-Simple-100
607
+ result.a = (m[15] * c.r);
608
+ result.a += (m[16] * c.g);
609
+ result.a += (m[17] * c.b);
610
+ result.a += (m[18] * c.a);
611
+ result.a += m[19];
543
612
 
544
- precision lowp float;
613
+ vec3 rgb = mix(c.rgb, result.rgb, uAlpha);
614
+
615
+ // Premultiply alpha again.
616
+ rgb *= result.a;
545
617
 
618
+ gl_FragColor = vec4(rgb, result.a);
619
+ }
620
+ `;class Rs extends kt{constructor(){const t={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};super(Qa,Em,t),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,r,n]=gt.shared.setValue(t).toArray(),a=[i,0,0,0,0,0,r,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(a,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),r=Math.sin(t),n=Math.sqrt,a=1/3,o=n(a),h=i+(1-i)*a,l=a*(1-i)-o*r,u=a*(1-i)+o*r,c=a*(1-i)+o*r,d=i+a*(1-i),f=a*(1-i)-o*r,p=a*(1-i)-o*r,g=a*(1-i)+o*r,m=i+a*(1-i),_=[h,l,u,0,0,c,d,f,0,0,p,g,m,0,0,0,0,0,1,0];this._loadMatrix(_,e)}contrast(t,e){const i=(t||0)+1,r=-.5*(i-1),n=[i,0,0,0,r,0,i,0,0,r,0,0,i,0,r,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,r=(i-1)*-.5,n=[i,r,r,0,0,r,i,r,0,0,r,r,i,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,i,r,n){t=t||.2,e=e||.15,i=i||16770432,r=r||3375104;const a=gt.shared,[o,h,l]=a.setValue(i).toArray(),[u,c,d]=a.setValue(r).toArray(),f=[.3,.59,.11,0,0,o,h,l,t,0,u,c,d,e,0,o-u,h-c,l-d,0,0];this._loadMatrix(f,n)}night(t,e){t=t||.1;const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}Rs.prototype.grayscale=Rs.prototype.greyscale;var wm=`varying vec2 vFilterCoord;
546
621
  varying vec2 vTextureCoord;
547
622
 
623
+ uniform vec2 scale;
624
+ uniform mat2 rotation;
548
625
  uniform sampler2D uSampler;
549
- uniform vec4 uColor;
626
+ uniform sampler2D mapSampler;
627
+
628
+ uniform highp vec4 inputSize;
629
+ uniform vec4 inputClamp;
550
630
 
551
631
  void main(void)
552
632
  {
553
- vec4 texSample = texture2D(uSampler, vTextureCoord);
554
- gl_FragColor = texSample * uColor;
555
- }
556
- `,yf=`#version 100
557
- #define SHADER_NAME Tiling-Sprite-100
633
+ vec4 map = texture2D(mapSampler, vFilterCoord);
558
634
 
559
- precision lowp float;
635
+ map -= 0.5;
636
+ map.xy = scale * inputSize.zw * (rotation * map.xy);
560
637
 
561
- attribute vec2 aVertexPosition;
562
- attribute vec2 aTextureCoord;
638
+ gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));
639
+ }
640
+ `,Cm=`attribute vec2 aVertexPosition;
563
641
 
564
642
  uniform mat3 projectionMatrix;
565
- uniform mat3 translationMatrix;
566
- uniform mat3 uTransform;
643
+ uniform mat3 filterMatrix;
567
644
 
568
645
  varying vec2 vTextureCoord;
646
+ varying vec2 vFilterCoord;
569
647
 
570
- void main(void)
648
+ uniform vec4 inputSize;
649
+ uniform vec4 outputFrame;
650
+
651
+ vec4 filterVertexPosition( void )
571
652
  {
572
- gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
653
+ vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
573
654
 
574
- vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
655
+ return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
575
656
  }
576
- `,Ay=`#version 100
577
- #ifdef GL_EXT_shader_texture_lod
578
- #extension GL_EXT_shader_texture_lod : enable
579
- #endif
580
- #define SHADER_NAME Tiling-Sprite-100
581
-
582
- precision lowp float;
583
-
584
- varying vec2 vTextureCoord;
585
657
 
586
- uniform sampler2D uSampler;
587
- uniform vec4 uColor;
588
- uniform mat3 uMapCoord;
589
- uniform vec4 uClampFrame;
590
- uniform vec2 uClampOffset;
658
+ vec2 filterTextureCoord( void )
659
+ {
660
+ return aVertexPosition * (outputFrame.zw * inputSize.zw);
661
+ }
591
662
 
592
663
  void main(void)
593
664
  {
594
- vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
595
- coord = (uMapCoord * vec3(coord, 1.0)).xy;
596
- vec2 unclamped = coord;
597
- coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
598
-
599
- #ifdef GL_EXT_shader_texture_lod
600
- vec4 texSample = unclamped == coord
601
- ? texture2D(uSampler, coord)
602
- : texture2DLodEXT(uSampler, coord, 0);
603
- #else
604
- vec4 texSample = texture2D(uSampler, coord);
605
- #endif
606
-
607
- gl_FragColor = texSample * uColor;
608
- }
609
- `,My=`#version 300 es
610
- #define SHADER_NAME Tiling-Sprite-300
611
-
612
- precision lowp float;
613
-
614
- in vec2 aVertexPosition;
615
- in vec2 aTextureCoord;
616
-
617
- uniform mat3 projectionMatrix;
618
- uniform mat3 translationMatrix;
619
- uniform mat3 uTransform;
620
-
621
- out vec2 vTextureCoord;
622
-
623
- void main(void)
624
- {
625
- gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
626
-
627
- vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
628
- }
629
- `,Ry=`#version 300 es
630
- #define SHADER_NAME Tiling-Sprite-100
631
-
632
- precision lowp float;
633
-
634
- in vec2 vTextureCoord;
635
-
636
- out vec4 fragmentColor;
637
-
638
- uniform sampler2D uSampler;
639
- uniform vec4 uColor;
640
- uniform mat3 uMapCoord;
641
- uniform vec4 uClampFrame;
642
- uniform vec2 uClampOffset;
643
-
644
- void main(void)
645
- {
646
- vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
647
- coord = (uMapCoord * vec3(coord, 1.0)).xy;
648
- vec2 unclamped = coord;
649
- coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
650
-
651
- vec4 texSample = texture(uSampler, coord, unclamped == coord ? 0.0f : -32.0f);// lod-bias very negative to force lod 0
652
-
653
- fragmentColor = texSample * uColor;
654
- }
655
- `,vn=new bt,xf=function(i){mf(t,i);function t(e){var r=i.call(this,e)||this;return e.runners.contextChange.add(r),r.quad=new Ls,r.state=Oe.for2d(),r}return t.prototype.contextChange=function(){var e=this.renderer,r={globals:e.globalUniforms};this.simpleShader=be.from(yf,Iy,r),this.shader=e.context.webGLVersion>1?be.from(My,Ry,r):be.from(yf,Ay,r)},t.prototype.render=function(e){var r=this.renderer,n=this.quad,s=n.vertices;s[0]=s[6]=e._width*-e.anchor.x,s[1]=s[3]=e._height*-e.anchor.y,s[2]=s[4]=e._width*(1-e.anchor.x),s[5]=s[7]=e._height*(1-e.anchor.y);var a=e.uvRespectAnchor?e.anchor.x:0,o=e.uvRespectAnchor?e.anchor.y:0;s=n.uvs,s[0]=s[6]=-a,s[1]=s[3]=-o,s[2]=s[4]=1-a,s[5]=s[7]=1-o,n.invalidate();var h=e._texture,u=h.baseTexture,l=u.alphaMode>0,c=e.tileTransform.localTransform,f=e.uvMatrix,d=u.isPowerOfTwo&&h.frame.width===u.width&&h.frame.height===u.height;d&&(u._glTextures[r.CONTEXT_UID]?d=u.wrapMode!==ne.CLAMP:u.wrapMode===ne.CLAMP&&(u.wrapMode=ne.REPEAT));var v=d?this.simpleShader:this.shader,_=h.width,p=h.height,g=e._width,y=e._height;vn.set(c.a*_/g,c.b*_/y,c.c*p/g,c.d*p/y,c.tx/g,c.ty/y),vn.invert(),d?vn.prepend(f.mapCoord):(v.uniforms.uMapCoord=f.mapCoord.toArray(!0),v.uniforms.uClampFrame=f.uClampFrame,v.uniforms.uClampOffset=f.uClampOffset),v.uniforms.uTransform=vn.toArray(!0),v.uniforms.uColor=_s(e.tint,e.worldAlpha,v.uniforms.uColor,l),v.uniforms.translationMatrix=e.transform.worldTransform.toArray(!0),v.uniforms.uSampler=h,r.shader.bind(v),r.geometry.bind(n),this.state.blendMode=vs(e.blendMode,l),r.state.set(this.state),r.geometry.draw(this.renderer.gl.TRIANGLES,6,0)},t.extension={name:"tilingSprite",type:dt.RendererPlugin},t}(zr);var go=function(i,t){return go=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},go(i,t)};function mo(i,t){go(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var bf=function(){function i(t,e){this.uvBuffer=t,this.uvMatrix=e,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}return i.prototype.update=function(t){if(!(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)){this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;var e=this.uvBuffer.data;(!this.data||this.data.length!==e.length)&&(this.data=new Float32Array(e.length)),this.uvMatrix.multiplyUvs(e,this.data),this._updateID++}},i}(),yo=new vt,Tf=new Hr,Ir=function(i){mo(t,i);function t(e,r,n,s){s===void 0&&(s=jt.TRIANGLES);var a=i.call(this)||this;return a.geometry=e,a.shader=r,a.state=n||Oe.for2d(),a.drawMode=s,a.start=0,a.size=0,a.uvs=null,a.indices=null,a.vertexData=new Float32Array(1),a.vertexDirty=-1,a._transformID=-1,a._roundPixels=z.ROUND_PIXELS,a.batchUvs=null,a}return Object.defineProperty(t.prototype,"geometry",{get:function(){return this._geometry},set:function(e){this._geometry!==e&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=e,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uvBuffer",{get:function(){return this.geometry.buffers[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"verticesBuffer",{get:function(){return this.geometry.buffers[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this.shader},set:function(e){this.shader=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendMode",{get:function(){return this.state.blendMode},set:function(e){this.state.blendMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roundPixels",{get:function(){return this._roundPixels},set:function(e){this._roundPixels!==e&&(this._transformID=-1),this._roundPixels=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tint",{get:function(){return"tint"in this.shader?this.shader.tint:null},set:function(e){this.shader.tint=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"texture",{get:function(){return"texture"in this.shader?this.shader.texture:null},set:function(e){this.shader.texture=e},enumerable:!1,configurable:!0}),t.prototype._render=function(e){var r=this.geometry.buffers[0].data,n=this.shader;n.batchable&&this.drawMode===jt.TRIANGLES&&r.length<t.BATCHABLE_SIZE*2?this._renderToBatch(e):this._renderDefault(e)},t.prototype._renderDefault=function(e){var r=this.shader;r.alpha=this.worldAlpha,r.update&&r.update(),e.batch.flush(),r.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),e.shader.bind(r),e.state.set(this.state),e.geometry.bind(this.geometry,r),e.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)},t.prototype._renderToBatch=function(e){var r=this.geometry,n=this.shader;n.uvMatrix&&(n.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=r.indexBuffer.data,this._tintRGB=n._tintRGB,this._texture=n.texture;var s=this.material.pluginName;e.batch.setObjectRenderer(e.plugins[s]),e.plugins[s].render(this)},t.prototype.calculateVertices=function(){var e=this.geometry,r=e.buffers[0],n=r.data,s=r._updateID;if(!(s===this.vertexDirty&&this._transformID===this.transform._worldID)){this._transformID=this.transform._worldID,this.vertexData.length!==n.length&&(this.vertexData=new Float32Array(n.length));for(var a=this.transform.worldTransform,o=a.a,h=a.b,u=a.c,l=a.d,c=a.tx,f=a.ty,d=this.vertexData,v=0;v<d.length/2;v++){var _=n[v*2],p=n[v*2+1];d[v*2]=o*_+u*p+c,d[v*2+1]=h*_+l*p+f}if(this._roundPixels)for(var g=z.RESOLUTION,v=0;v<d.length;++v)d[v]=Math.round((d[v]*g|0)/g);this.vertexDirty=s}},t.prototype.calculateUvs=function(){var e=this.geometry.buffers[1],r=this.shader;r.uvMatrix.isSimple?this.uvs=e.data:(this.batchUvs||(this.batchUvs=new bf(e,r.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)},t.prototype._calculateBounds=function(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)},t.prototype.containsPoint=function(e){if(!this.getBounds().contains(e.x,e.y))return!1;this.worldTransform.applyInverse(e,yo);for(var r=this.geometry.getBuffer("aVertexPosition").data,n=Tf.points,s=this.geometry.getIndex().data,a=s.length,o=this.drawMode===4?3:1,h=0;h+2<a;h+=o){var u=s[h]*2,l=s[h+1]*2,c=s[h+2]*2;if(n[0]=r[u],n[1]=r[u+1],n[2]=r[l],n[3]=r[l+1],n[4]=r[c],n[5]=r[c+1],Tf.contains(yo.x,yo.y))return!0}return!1},t.prototype.destroy=function(e){i.prototype.destroy.call(this,e),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null},t.BATCHABLE_SIZE=100,t}(Zt),Oy=`varying vec2 vTextureCoord;
656
- uniform vec4 uColor;
657
-
658
- uniform sampler2D uSampler;
659
-
660
- void main(void)
661
- {
662
- gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
663
- }
664
- `,Dy=`attribute vec2 aVertexPosition;
665
- attribute vec2 aTextureCoord;
666
-
667
- uniform mat3 projectionMatrix;
668
- uniform mat3 translationMatrix;
669
- uniform mat3 uTextureMatrix;
670
-
671
- varying vec2 vTextureCoord;
672
-
673
- void main(void)
674
- {
675
- gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
676
-
677
- vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
678
- }
679
- `,Ar=function(i){mo(t,i);function t(e,r){var n=this,s={uSampler:e,alpha:1,uTextureMatrix:bt.IDENTITY,uColor:new Float32Array([1,1,1,1])};return r=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},r),r.uniforms&&Object.assign(s,r.uniforms),n=i.call(this,r.program||_r.from(Dy,Oy),s)||this,n._colorDirty=!1,n.uvMatrix=new Gi(e),n.batchable=r.program===void 0,n.pluginName=r.pluginName,n.tint=r.tint,n.alpha=r.alpha,n}return Object.defineProperty(t.prototype,"texture",{get:function(){return this.uniforms.uSampler},set:function(e){this.uniforms.uSampler!==e&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!e.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=e,this.uvMatrix.texture=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alpha",{get:function(){return this._alpha},set:function(e){e!==this._alpha&&(this._alpha=e,this._colorDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tint",{get:function(){return this._tint},set:function(e){e!==this._tint&&(this._tint=e,this._tintRGB=(e>>16)+(e&65280)+((e&255)<<16),this._colorDirty=!0)},enumerable:!1,configurable:!0}),t.prototype.update=function(){if(this._colorDirty){this._colorDirty=!1;var e=this.texture.baseTexture;_s(this._tint,this._alpha,this.uniforms.uColor,e.alphaMode)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)},t}(be),mi=function(i){mo(t,i);function t(e,r,n){var s=i.call(this)||this,a=new Mt(e),o=new Mt(r,!0),h=new Mt(n,!0,!0);return s.addAttribute("aVertexPosition",a,2,!1,Q.FLOAT).addAttribute("aTextureCoord",o,2,!1,Q.FLOAT).addIndex(h),s._updateId=-1,s}return Object.defineProperty(t.prototype,"vertexDirtyId",{get:function(){return this.buffers[0]._updateID},enumerable:!1,configurable:!0}),t}(vr);var xo=function(i,t){return xo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},xo(i,t)};function Fy(i,t){xo(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var yi=function(){function i(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}return i}(),Ef=function(){function i(){}return i.test=function(t){return typeof t=="string"&&t.indexOf("info face=")===0},i.parse=function(t){var e=t.match(/^[a-z]+\s+.+$/gm),r={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(var n in e){var s=e[n].match(/^[a-z]+/gm)[0],a=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),o={};for(var h in a){var u=a[h].split("="),l=u[0],c=u[1].replace(/"/gm,""),f=parseFloat(c),d=isNaN(f)?c:f;o[l]=d}r[s].push(o)}var v=new yi;return r.info.forEach(function(_){return v.info.push({face:_.face,size:parseInt(_.size,10)})}),r.common.forEach(function(_){return v.common.push({lineHeight:parseInt(_.lineHeight,10)})}),r.page.forEach(function(_){return v.page.push({id:parseInt(_.id,10),file:_.file})}),r.char.forEach(function(_){return v.char.push({id:parseInt(_.id,10),page:parseInt(_.page,10),x:parseInt(_.x,10),y:parseInt(_.y,10),width:parseInt(_.width,10),height:parseInt(_.height,10),xoffset:parseInt(_.xoffset,10),yoffset:parseInt(_.yoffset,10),xadvance:parseInt(_.xadvance,10)})}),r.kerning.forEach(function(_){return v.kerning.push({first:parseInt(_.first,10),second:parseInt(_.second,10),amount:parseInt(_.amount,10)})}),r.distanceField.forEach(function(_){return v.distanceField.push({distanceRange:parseInt(_.distanceRange,10),fieldType:_.fieldType})}),v},i}(),_n=function(){function i(){}return i.test=function(t){return t instanceof XMLDocument&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},i.parse=function(t){for(var e=new yi,r=t.getElementsByTagName("info"),n=t.getElementsByTagName("common"),s=t.getElementsByTagName("page"),a=t.getElementsByTagName("char"),o=t.getElementsByTagName("kerning"),h=t.getElementsByTagName("distanceField"),u=0;u<r.length;u++)e.info.push({face:r[u].getAttribute("face"),size:parseInt(r[u].getAttribute("size"),10)});for(var u=0;u<n.length;u++)e.common.push({lineHeight:parseInt(n[u].getAttribute("lineHeight"),10)});for(var u=0;u<s.length;u++)e.page.push({id:parseInt(s[u].getAttribute("id"),10)||0,file:s[u].getAttribute("file")});for(var u=0;u<a.length;u++){var l=a[u];e.char.push({id:parseInt(l.getAttribute("id"),10),page:parseInt(l.getAttribute("page"),10)||0,x:parseInt(l.getAttribute("x"),10),y:parseInt(l.getAttribute("y"),10),width:parseInt(l.getAttribute("width"),10),height:parseInt(l.getAttribute("height"),10),xoffset:parseInt(l.getAttribute("xoffset"),10),yoffset:parseInt(l.getAttribute("yoffset"),10),xadvance:parseInt(l.getAttribute("xadvance"),10)})}for(var u=0;u<o.length;u++)e.kerning.push({first:parseInt(o[u].getAttribute("first"),10),second:parseInt(o[u].getAttribute("second"),10),amount:parseInt(o[u].getAttribute("amount"),10)});for(var u=0;u<h.length;u++)e.distanceField.push({fieldType:h[u].getAttribute("fieldType"),distanceRange:parseInt(h[u].getAttribute("distanceRange"),10)});return e},i}(),Sf=function(){function i(){}return i.test=function(t){if(typeof t=="string"&&t.indexOf("<font>")>-1){var e=new globalThis.DOMParser().parseFromString(t,"text/xml");return _n.test(e)}return!1},i.parse=function(t){var e=new globalThis.DOMParser().parseFromString(t,"text/xml");return _n.parse(e)},i}(),bo=[Ef,_n,Sf];function To(i){for(var t=0;t<bo.length;t++)if(bo[t].test(i))return bo[t];return null}function Ly(i,t,e,r,n,s){var a=e.fill;if(Array.isArray(a)){if(a.length===1)return a[0]}else return a;var o,h=e.dropShadow?e.dropShadowDistance:0,u=e.padding||0,l=i.width/r-h-u*2,c=i.height/r-h-u*2,f=a.slice(),d=e.fillGradientStops.slice();if(!d.length)for(var v=f.length+1,_=1;_<v;++_)d.push(_/v);if(f.unshift(a[0]),d.unshift(0),f.push(a[a.length-1]),d.push(1),e.fillGradientType===Cr.LINEAR_VERTICAL){o=t.createLinearGradient(l/2,u,l/2,c+u);for(var p=0,g=s.fontProperties.fontSize+e.strokeThickness,y=g/c,_=0;_<n.length;_++)for(var T=s.lineHeight*_,I=0;I<f.length;I++){var m=0;typeof d[I]=="number"?m=d[I]:m=I/f.length;var S=T/c+m*y,x=Math.max(p,S);x=Math.min(x,1),o.addColorStop(x,f[I]),p=x}}else{o=t.createLinearGradient(u,c/2,l+u,c/2);for(var N=f.length+1,D=1,_=0;_<f.length;_++){var F=void 0;typeof d[_]=="number"?F=d[_]:F=D/N,o.addColorStop(F,f[_]),D++}}return o}function By(i,t,e,r,n,s,a){var o=e.text,h=e.fontProperties;t.translate(r,n),t.scale(s,s);var u=a.strokeThickness/2,l=-(a.strokeThickness/2);if(t.font=a.toFontString(),t.lineWidth=a.strokeThickness,t.textBaseline=a.textBaseline,t.lineJoin=a.lineJoin,t.miterLimit=a.miterLimit,t.fillStyle=Ly(i,t,a,s,[o],e),t.strokeStyle=a.stroke,a.dropShadow){var c=a.dropShadowColor,f=He(typeof c=="number"?c:ds(c)),d=a.dropShadowBlur*s,v=a.dropShadowDistance*s;t.shadowColor="rgba("+f[0]*255+","+f[1]*255+","+f[2]*255+","+a.dropShadowAlpha+")",t.shadowBlur=d,t.shadowOffsetX=Math.cos(a.dropShadowAngle)*v,t.shadowOffsetY=Math.sin(a.dropShadowAngle)*v}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;a.stroke&&a.strokeThickness&&t.strokeText(o,u,l+e.lineHeight-h.descent),a.fill&&t.fillText(o,u,l+e.lineHeight-h.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Pf(i){return Array.from?Array.from(i):i.split("")}function Ny(i){typeof i=="string"&&(i=[i]);for(var t=[],e=0,r=i.length;e<r;e++){var n=i[e];if(Array.isArray(n)){if(n.length!==2)throw new Error("[BitmapFont]: Invalid character range length, expecting 2 got "+n.length+".");var s=n[0].charCodeAt(0),a=n[1].charCodeAt(0);if(a<s)throw new Error("[BitmapFont]: Invalid character range.");for(var o=s,h=a;o<=h;o++)t.push(String.fromCharCode(o))}else t.push.apply(t,Pf(n))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}function gn(i){return i.codePointAt?i.codePointAt(0):i.charCodeAt(0)}var we=function(){function i(t,e,r){var n,s,a=t.info[0],o=t.common[0],h=t.page[0],u=t.distanceField[0],l=Gr(h.file),c={};this._ownsTextures=r,this.font=a.face,this.size=a.size,this.lineHeight=o.lineHeight/l,this.chars={},this.pageTextures=c;for(var f=0;f<t.page.length;f++){var d=t.page[f],v=d.id,_=d.file;c[v]=e instanceof Array?e[f]:e[_],u!=null&&u.fieldType&&u.fieldType!=="none"&&(c[v].baseTexture.alphaMode=Wt.NO_PREMULTIPLIED_ALPHA,c[v].baseTexture.mipmap=zt.OFF)}for(var f=0;f<t.char.length;f++){var p=t.char[f],v=p.id,g=p.page,y=t.char[f],T=y.x,I=y.y,m=y.width,S=y.height,x=y.xoffset,N=y.yoffset,D=y.xadvance;T/=l,I/=l,m/=l,S/=l,x/=l,N/=l,D/=l;var F=new ut(T+c[g].frame.x/l,I+c[g].frame.y/l,m,S);this.chars[v]={xOffset:x,yOffset:N,xAdvance:D,kerning:{},texture:new it(c[g].baseTexture,F),page:g}}for(var f=0;f<t.kerning.length;f++){var k=t.kerning[f],L=k.first,q=k.second,Z=k.amount;L/=l,q/=l,Z/=l,this.chars[q]&&(this.chars[q].kerning[L]=Z)}this.distanceFieldRange=u==null?void 0:u.distanceRange,this.distanceFieldType=(s=(n=u==null?void 0:u.fieldType)===null||n===void 0?void 0:n.toLowerCase())!==null&&s!==void 0?s:"none"}return i.prototype.destroy=function(){for(var t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(var t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null},i.install=function(t,e,r){var n;if(t instanceof yi)n=t;else{var s=To(t);if(!s)throw new Error("Unrecognized data format for font.");n=s.parse(t)}e instanceof it&&(e=[e]);var a=new i(n,e,r);return i.available[a.font]=a,a},i.uninstall=function(t){var e=i.available[t];if(!e)throw new Error("No font found named '"+t+"'");e.destroy(),delete i.available[t]},i.from=function(t,e,r){if(!t)throw new Error("[BitmapFont] Property `name` is required.");var n=Object.assign({},i.defaultOptions,r),s=n.chars,a=n.padding,o=n.resolution,h=n.textureWidth,u=n.textureHeight,l=Ny(s),c=e instanceof lr?e:new lr(e),f=h,d=new yi;d.info[0]={face:c.fontFamily,size:c.fontSize},d.common[0]={lineHeight:c.fontSize};for(var v=0,_=0,p,g,y,T=0,I=[],m=0;m<l.length;m++){p||(p=z.ADAPTER.createCanvas(),p.width=h,p.height=u,g=p.getContext("2d"),y=new lt(p,{resolution:o}),I.push(new it(y)),d.page.push({id:I.length-1,file:""}));var S=l[m],x=le.measureText(S,c,!1,p),N=x.width,D=Math.ceil(x.height),F=Math.ceil((c.fontStyle==="italic"?2:1)*N);if(_>=u-D*o){if(_===0)throw new Error("[BitmapFont] textureHeight "+u+"px is too small "+("(fontFamily: '"+c.fontFamily+"', fontSize: "+c.fontSize+"px, char: '"+S+"')"));--m,p=null,g=null,y=null,_=0,v=0,T=0;continue}if(T=Math.max(D+x.fontProperties.descent,T),F*o+v>=f){if(v===0)throw new Error("[BitmapFont] textureWidth "+h+"px is too small "+("(fontFamily: '"+c.fontFamily+"', fontSize: "+c.fontSize+"px, char: '"+S+"')"));--m,_+=T*o,_=Math.ceil(_),v=0,T=0;continue}By(p,g,x,v,_,o,c);var k=gn(x.text);d.char.push({id:k,page:I.length-1,x:v/o,y:_/o,width:F,height:D,xoffset:0,yoffset:0,xadvance:Math.ceil(N-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0))}),v+=(F+2*a)*o,v=Math.ceil(v)}if(!(r!=null&&r.skipKerning))for(var m=0,L=l.length;m<L;m++)for(var q=l[m],Z=0;Z<L;Z++){var G=l[Z],b=g.measureText(q).width,P=g.measureText(G).width,E=g.measureText(q+G).width,A=E-(b+P);A&&d.kerning.push({first:gn(q),second:gn(G),amount:A})}var C=new i(d,I,!0);return i.available[t]!==void 0&&i.uninstall(t),i.available[t]=C,C},i.ALPHA=[["a","z"],["A","Z"]," "],i.NUMERIC=[["0","9"]],i.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],i.ASCII=[[" ","~"]],i.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:i.ALPHANUMERIC},i.available={},i}(),Uy=`// Pixi texture info\r
680
- varying vec2 vTextureCoord;\r
681
- uniform sampler2D uSampler;\r
682
- \r
683
- // Tint\r
684
- uniform vec4 uColor;\r
685
- \r
686
- // on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\r
687
- uniform float uFWidth;\r
688
- \r
689
- void main(void) {\r
690
- \r
691
- // To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\r
692
- vec4 texColor = texture2D(uSampler, vTextureCoord);\r
693
- \r
694
- // MSDF\r
695
- float median = texColor.r + texColor.g + texColor.b -\r
696
- min(texColor.r, min(texColor.g, texColor.b)) -\r
697
- max(texColor.r, max(texColor.g, texColor.b));\r
698
- // SDF\r
699
- median = min(median, texColor.a);\r
700
- \r
701
- float screenPxDistance = uFWidth * (median - 0.5);\r
702
- float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\r
703
- if (median < 0.01) {\r
704
- alpha = 0.0;\r
705
- } else if (median > 0.99) {\r
706
- alpha = 1.0;\r
707
- }\r
708
- \r
709
- // NPM Textures, NPM outputs\r
710
- gl_FragColor = vec4(uColor.rgb, uColor.a * alpha);\r
711
- \r
712
- }\r
713
- `,ky=`// Mesh material default fragment\r
714
- attribute vec2 aVertexPosition;\r
715
- attribute vec2 aTextureCoord;\r
716
- \r
717
- uniform mat3 projectionMatrix;\r
718
- uniform mat3 translationMatrix;\r
719
- uniform mat3 uTextureMatrix;\r
720
- \r
721
- varying vec2 vTextureCoord;\r
722
- \r
723
- void main(void)\r
724
- {\r
725
- gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\r
726
- \r
727
- vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
728
- }\r
729
- `,wf=[],Cf=[],If=[],Gy=function(i){Fy(t,i);function t(e,r){r===void 0&&(r={});var n=i.call(this)||this;n._tint=16777215;var s=Object.assign({},t.styleDefaults,r),a=s.align,o=s.tint,h=s.maxWidth,u=s.letterSpacing,l=s.fontName,c=s.fontSize;if(!we.available[l])throw new Error('Missing BitmapFont "'+l+'"');return n._activePagesMeshData=[],n._textWidth=0,n._textHeight=0,n._align=a,n._tint=o,n._font=void 0,n._fontName=l,n._fontSize=c,n.text=e,n._maxWidth=h,n._maxLineHeight=0,n._letterSpacing=u,n._anchor=new Ae(function(){n.dirty=!0},n,0,0),n._roundPixels=z.ROUND_PIXELS,n.dirty=!0,n._resolution=z.RESOLUTION,n._autoResolution=!0,n._textureCache={},n}return t.prototype.updateText=function(){for(var e,r=we.available[this._fontName],n=this.fontSize,s=n/r.size,a=new vt,o=[],h=[],u=[],l=this._text.replace(/(?:\r\n|\r)/g,`
730
- `)||" ",c=Pf(l),f=this._maxWidth*r.size/n,d=r.distanceFieldType==="none"?wf:Cf,v=null,_=0,p=0,g=0,y=-1,T=0,I=0,m=0,S=0,x=0;x<c.length;x++){var N=c[x],D=gn(N);if(/(?:\s)/.test(N)&&(y=x,T=_,S++),N==="\r"||N===`
731
- `){h.push(_),u.push(-1),p=Math.max(p,_),++g,++I,a.x=0,a.y+=r.lineHeight,v=null,S=0;continue}var F=r.chars[D];if(F){v&&F.kerning[v]&&(a.x+=F.kerning[v]);var k=If.pop()||{texture:it.EMPTY,line:0,charCode:0,prevSpaces:0,position:new vt};k.texture=F.texture,k.line=g,k.charCode=D,k.position.x=a.x+F.xOffset+this._letterSpacing/2,k.position.y=a.y+F.yOffset,k.prevSpaces=S,o.push(k),_=k.position.x+Math.max(F.xAdvance-F.xOffset,F.texture.orig.width),a.x+=F.xAdvance+this._letterSpacing,m=Math.max(m,F.yOffset+F.texture.height),v=D,y!==-1&&f>0&&a.x>f&&(++I,Ve(o,1+y-I,1+x-y),x=y,y=-1,h.push(T),u.push(o.length>0?o[o.length-1].prevSpaces:0),p=Math.max(p,T),g++,a.x=0,a.y+=r.lineHeight,v=null,S=0)}}var L=c[c.length-1];L!=="\r"&&L!==`
732
- `&&(/(?:\s)/.test(L)&&(_=T),h.push(_),p=Math.max(p,_),u.push(-1));for(var q=[],x=0;x<=g;x++){var Z=0;this._align==="right"?Z=p-h[x]:this._align==="center"?Z=(p-h[x])/2:this._align==="justify"&&(Z=u[x]<0?0:(p-h[x])/u[x]),q.push(Z)}var G=o.length,b={},P=[],E=this._activePagesMeshData;d.push.apply(d,E);for(var x=0;x<G;x++){var A=o[x].texture,C=A.baseTexture.uid;if(!b[C]){var w=d.pop();if(!w){var M=new mi,R=void 0,U=void 0;r.distanceFieldType==="none"?(R=new Ar(it.EMPTY),U=tt.NORMAL):(R=new Ar(it.EMPTY,{program:_r.from(ky,Uy),uniforms:{uFWidth:0}}),U=tt.NORMAL_NPM);var X=new Ir(M,R);X.blendMode=U,w={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:X,vertices:null,uvs:null,indices:null}}w.index=0,w.indexCount=0,w.vertexCount=0,w.uvsCount=0,w.total=0;var W=this._textureCache;W[C]=W[C]||new it(A.baseTexture),w.mesh.texture=W[C],w.mesh.tint=this._tint,P.push(w),b[C]=w}b[C].total++}for(var x=0;x<E.length;x++)P.indexOf(E[x])===-1&&this.removeChild(E[x].mesh);for(var x=0;x<P.length;x++)P[x].mesh.parent!==this&&this.addChild(P[x].mesh);this._activePagesMeshData=P;for(var x in b){var w=b[x],V=w.total;if(!(((e=w.indices)===null||e===void 0?void 0:e.length)>6*V)||w.vertices.length<Ir.BATCHABLE_SIZE*2)w.vertices=new Float32Array(4*2*V),w.uvs=new Float32Array(4*2*V),w.indices=new Uint16Array(6*V);else for(var Y=w.total,K=w.vertices,j=Y*4*2;j<K.length;j++)K[j]=0;w.mesh.size=6*V}for(var x=0;x<G;x++){var N=o[x],et=N.position.x+q[N.line]*(this._align==="justify"?N.prevSpaces:1);this._roundPixels&&(et=Math.round(et));var nt=et*s,ft=N.position.y*s,A=N.texture,J=b[A.baseTexture.uid],$=A.frame,rt=A._uvs,ot=J.index++;J.indices[ot*6+0]=0+ot*4,J.indices[ot*6+1]=1+ot*4,J.indices[ot*6+2]=2+ot*4,J.indices[ot*6+3]=0+ot*4,J.indices[ot*6+4]=2+ot*4,J.indices[ot*6+5]=3+ot*4,J.vertices[ot*8+0]=nt,J.vertices[ot*8+1]=ft,J.vertices[ot*8+2]=nt+$.width*s,J.vertices[ot*8+3]=ft,J.vertices[ot*8+4]=nt+$.width*s,J.vertices[ot*8+5]=ft+$.height*s,J.vertices[ot*8+6]=nt,J.vertices[ot*8+7]=ft+$.height*s,J.uvs[ot*8+0]=rt.x0,J.uvs[ot*8+1]=rt.y0,J.uvs[ot*8+2]=rt.x1,J.uvs[ot*8+3]=rt.y1,J.uvs[ot*8+4]=rt.x2,J.uvs[ot*8+5]=rt.y2,J.uvs[ot*8+6]=rt.x3,J.uvs[ot*8+7]=rt.y3}this._textWidth=p*s,this._textHeight=(a.y+r.lineHeight)*s;for(var x in b){var w=b[x];if(this.anchor.x!==0||this.anchor.y!==0)for(var Ht=0,Ue=this._textWidth*this.anchor.x,Rr=this._textHeight*this.anchor.y,yn=0;yn<w.total;yn++)w.vertices[Ht++]-=Ue,w.vertices[Ht++]-=Rr,w.vertices[Ht++]-=Ue,w.vertices[Ht++]-=Rr,w.vertices[Ht++]-=Ue,w.vertices[Ht++]-=Rr,w.vertices[Ht++]-=Ue,w.vertices[Ht++]-=Rr;this._maxLineHeight=m*s;var xn=w.mesh.geometry.getBuffer("aVertexPosition"),bn=w.mesh.geometry.getBuffer("aTextureCoord"),xi=w.mesh.geometry.getIndex();xn.data=w.vertices,bn.data=w.uvs,xi.data=w.indices,xn.update(),bn.update(),xi.update()}for(var x=0;x<o.length;x++)If.push(o[x]);this._font=r,this.dirty=!1},t.prototype.updateTransform=function(){this.validate(),this.containerUpdateTransform()},t.prototype._render=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0);var r=we.available[this._fontName],n=r.distanceFieldRange,s=r.distanceFieldType,a=r.size;if(s!=="none")for(var o=this.worldTransform,h=o.a,u=o.b,l=o.c,c=o.d,f=Math.sqrt(h*h+u*u),d=Math.sqrt(l*l+c*c),v=(Math.abs(f)+Math.abs(d))/2,_=this.fontSize/a,p=0,g=this._activePagesMeshData;p<g.length;p++){var y=g[p];y.mesh.shader.uniforms.uFWidth=v*n*_*this._resolution}i.prototype._render.call(this,e)},t.prototype.getLocalBounds=function(){return this.validate(),i.prototype.getLocalBounds.call(this)},t.prototype.validate=function(){var e=we.available[this._fontName];if(!e)throw new Error('Missing BitmapFont "'+this._fontName+'"');this._font!==e&&(this.dirty=!0),this.dirty&&this.updateText()},Object.defineProperty(t.prototype,"tint",{get:function(){return this._tint},set:function(e){if(this._tint!==e){this._tint=e;for(var r=0;r<this._activePagesMeshData.length;r++)this._activePagesMeshData[r].mesh.tint=e}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"align",{get:function(){return this._align},set:function(e){this._align!==e&&(this._align=e,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontName",{get:function(){return this._fontName},set:function(e){if(!we.available[e])throw new Error('Missing BitmapFont "'+e+'"');this._fontName!==e&&(this._fontName=e,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontSize",{get:function(){var e;return(e=this._fontSize)!==null&&e!==void 0?e:we.available[this._fontName].size},set:function(e){this._fontSize!==e&&(this._fontSize=e,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"anchor",{get:function(){return this._anchor},set:function(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"text",{get:function(){return this._text},set:function(e){e=String(e??""),this._text!==e&&(this._text=e,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxWidth",{get:function(){return this._maxWidth},set:function(e){this._maxWidth!==e&&(this._maxWidth=e,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxLineHeight",{get:function(){return this.validate(),this._maxLineHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textWidth",{get:function(){return this.validate(),this._textWidth},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"letterSpacing",{get:function(){return this._letterSpacing},set:function(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roundPixels",{get:function(){return this._roundPixels},set:function(e){e!==this._roundPixels&&(this._roundPixels=e,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textHeight",{get:function(){return this.validate(),this._textHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resolution",{get:function(){return this._resolution},set:function(e){this._autoResolution=!1,this._resolution!==e&&(this._resolution=e,this.dirty=!0)},enumerable:!1,configurable:!0}),t.prototype.destroy=function(e){var r=this._textureCache,n=we.available[this._fontName],s=n.distanceFieldType==="none"?wf:Cf;s.push.apply(s,this._activePagesMeshData);for(var a=0,o=this._activePagesMeshData;a<o.length;a++){var h=o[a];this.removeChild(h.mesh)}this._activePagesMeshData=[],s.filter(function(c){return r[c.mesh.texture.baseTexture.uid]}).forEach(function(c){c.mesh.texture=it.EMPTY});for(var u in r){var l=r[u];l.destroy(),delete r[u]}this._font=null,this._textureCache=null,i.prototype.destroy.call(this,e)},t.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0},t}(Zt),Af=function(){function i(){}return i.add=function(){wt.setExtensionXhrType("fnt",wt.XHR_RESPONSE_TYPE.TEXT)},i.use=function(t,e){var r=To(t.data);if(!r){e();return}for(var n=i.getBaseUrl(this,t),s=r.parse(t.data),a={},o=function(_){a[_.metadata.pageFile]=_.texture,Object.keys(a).length===s.page.length&&(t.bitmapFont=we.install(s,a,!0),e())},h=0;h<s.page.length;++h){var u=s.page[h].file,l=n+u,c=!1;for(var f in this.resources){var d=this.resources[f];if(d.url===l){d.metadata.pageFile=u,d.texture?o(d):d.onAfterMiddleware.add(o),c=!0;break}}if(!c){var v={crossOrigin:t.crossOrigin,loadType:wt.LOAD_TYPE.IMAGE,metadata:Object.assign({pageFile:u},t.metadata.imageMetadata),parentResource:t};this.add(l,v,o)}}},i.getBaseUrl=function(t,e){var r=e.isDataUrl?"":i.dirname(e.url);return e.isDataUrl&&(r==="."&&(r=""),t.baseUrl&&r&&t.baseUrl.charAt(t.baseUrl.length-1)==="/"&&(r+="/")),r=r.replace(t.baseUrl,""),r&&r.charAt(r.length-1)!=="/"&&(r+="/"),r},i.dirname=function(t){var e=t.replace(/\\/g,"/").replace(/\/$/,"").replace(/\/[^\/]*$/,"");return e===t?".":e===""?"/":e},i.extension=dt.Loader,i}();var Eo=function(i,t){return Eo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},Eo(i,t)};function Xy(i,t){Eo(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Hy=`varying vec2 vTextureCoord;
733
-
734
- uniform sampler2D uSampler;
735
- uniform float uAlpha;
736
-
737
- void main(void)
738
- {
739
- gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
740
- }
741
- `,Vy=function(i){Xy(t,i);function t(e){e===void 0&&(e=1);var r=i.call(this,Du,Hy,{uAlpha:1})||this;return r.alpha=e,r}return Object.defineProperty(t.prototype,"alpha",{get:function(){return this.uniforms.uAlpha},set:function(e){this.uniforms.uAlpha=e},enumerable:!1,configurable:!0}),t}(Te);var So=function(i,t){return So=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},So(i,t)};function Mf(i,t){So(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var jy=`
742
- attribute vec2 aVertexPosition;
743
-
744
- uniform mat3 projectionMatrix;
745
-
746
- uniform float strength;
747
-
748
- varying vec2 vBlurTexCoords[%size%];
749
-
750
- uniform vec4 inputSize;
751
- uniform vec4 outputFrame;
752
-
753
- vec4 filterVertexPosition( void )
754
- {
755
- vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
756
-
757
- return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
758
- }
759
-
760
- vec2 filterTextureCoord( void )
761
- {
762
- return aVertexPosition * (outputFrame.zw * inputSize.zw);
763
- }
764
-
765
- void main(void)
766
- {
767
- gl_Position = filterVertexPosition();
768
-
769
- vec2 textureCoord = filterTextureCoord();
770
- %blur%
771
- }`;function zy(i,t){var e=Math.ceil(i/2),r=jy,n="",s;t?s="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":s="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(var a=0;a<i;a++){var o=s.replace("%index%",a.toString());o=o.replace("%sampleIndex%",a-(e-1)+".0"),n+=o,n+=`
772
- `}return r=r.replace("%blur%",n),r=r.replace("%size%",i.toString()),r}var Wy={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},Yy=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
773
- `);function qy(i){for(var t=Wy[i],e=t.length,r=Yy,n="",s="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;",a,o=0;o<i;o++){var h=s.replace("%index%",o.toString());a=o,o>=e&&(a=i-o-1),h=h.replace("%value%",t[a].toString()),n+=h,n+=`
774
- `}return r=r.replace("%blur%",n),r=r.replace("%size%",i.toString()),r}var Po=function(i){Mf(t,i);function t(e,r,n,s,a){r===void 0&&(r=8),n===void 0&&(n=4),s===void 0&&(s=z.FILTER_RESOLUTION),a===void 0&&(a=5);var o=this,h=zy(a,e),u=qy(a);return o=i.call(this,h,u)||this,o.horizontal=e,o.resolution=s,o._quality=0,o.quality=n,o.blur=r,o}return t.prototype.apply=function(e,r,n,s){if(n?this.horizontal?this.uniforms.strength=1/n.width*(n.width/r.width):this.uniforms.strength=1/n.height*(n.height/r.height):this.horizontal?this.uniforms.strength=1/e.renderer.width*(e.renderer.width/r.width):this.uniforms.strength=1/e.renderer.height*(e.renderer.height/r.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)e.applyFilter(this,r,n,s);else{var a=e.getFilterTexture(),o=e.renderer,h=r,u=a;this.state.blend=!1,e.applyFilter(this,h,u,Yt.CLEAR);for(var l=1;l<this.passes-1;l++){e.bindAndClear(h,Yt.BLIT),this.uniforms.uSampler=u;var c=u;u=h,h=c,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,e.applyFilter(this,u,n,s),e.returnFilterTexture(a)}},Object.defineProperty(t.prototype,"blur",{get:function(){return this.strength},set:function(e){this.padding=1+Math.abs(e)*2,this.strength=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"quality",{get:function(){return this._quality},set:function(e){this._quality=e,this.passes=e},enumerable:!1,configurable:!0}),t}(Te),$y=function(i){Mf(t,i);function t(e,r,n,s){e===void 0&&(e=8),r===void 0&&(r=4),n===void 0&&(n=z.FILTER_RESOLUTION),s===void 0&&(s=5);var a=i.call(this)||this;return a.blurXFilter=new Po(!0,e,r,n,s),a.blurYFilter=new Po(!1,e,r,n,s),a.resolution=n,a.quality=r,a.blur=e,a.repeatEdgePixels=!1,a}return t.prototype.apply=function(e,r,n,s){var a=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(a&&o){var h=e.getFilterTexture();this.blurXFilter.apply(e,r,h,Yt.CLEAR),this.blurYFilter.apply(e,h,n,s),e.returnFilterTexture(h)}else o?this.blurYFilter.apply(e,r,n,s):this.blurXFilter.apply(e,r,n,s)},t.prototype.updatePadding=function(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2},Object.defineProperty(t.prototype,"blur",{get:function(){return this.blurXFilter.blur},set:function(e){this.blurXFilter.blur=this.blurYFilter.blur=e,this.updatePadding()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"quality",{get:function(){return this.blurXFilter.quality},set:function(e){this.blurXFilter.quality=this.blurYFilter.quality=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurX",{get:function(){return this.blurXFilter.blur},set:function(e){this.blurXFilter.blur=e,this.updatePadding()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurY",{get:function(){return this.blurYFilter.blur},set:function(e){this.blurYFilter.blur=e,this.updatePadding()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendMode",{get:function(){return this.blurYFilter.blendMode},set:function(e){this.blurYFilter.blendMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"repeatEdgePixels",{get:function(){return this._repeatEdgePixels},set:function(e){this._repeatEdgePixels=e,this.updatePadding()},enumerable:!1,configurable:!0}),t}(Te);var wo=function(i,t){return wo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},wo(i,t)};function Ky(i,t){wo(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Zy=`varying vec2 vTextureCoord;
775
- uniform sampler2D uSampler;
776
- uniform float m[20];
777
- uniform float uAlpha;
778
-
779
- void main(void)
780
- {
781
- vec4 c = texture2D(uSampler, vTextureCoord);
782
-
783
- if (uAlpha == 0.0) {
784
- gl_FragColor = c;
785
- return;
786
- }
787
-
788
- // Un-premultiply alpha before applying the color matrix. See issue #3539.
789
- if (c.a > 0.0) {
790
- c.rgb /= c.a;
791
- }
792
-
793
- vec4 result;
794
-
795
- result.r = (m[0] * c.r);
796
- result.r += (m[1] * c.g);
797
- result.r += (m[2] * c.b);
798
- result.r += (m[3] * c.a);
799
- result.r += m[4];
800
-
801
- result.g = (m[5] * c.r);
802
- result.g += (m[6] * c.g);
803
- result.g += (m[7] * c.b);
804
- result.g += (m[8] * c.a);
805
- result.g += m[9];
806
-
807
- result.b = (m[10] * c.r);
808
- result.b += (m[11] * c.g);
809
- result.b += (m[12] * c.b);
810
- result.b += (m[13] * c.a);
811
- result.b += m[14];
812
-
813
- result.a = (m[15] * c.r);
814
- result.a += (m[16] * c.g);
815
- result.a += (m[17] * c.b);
816
- result.a += (m[18] * c.a);
817
- result.a += m[19];
818
-
819
- vec3 rgb = mix(c.rgb, result.rgb, uAlpha);
820
-
821
- // Premultiply alpha again.
822
- rgb *= result.a;
823
-
824
- gl_FragColor = vec4(rgb, result.a);
825
- }
826
- `,Co=function(i){Ky(t,i);function t(){var e=this,r={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};return e=i.call(this,oa,Zy,r)||this,e.alpha=1,e}return t.prototype._loadMatrix=function(e,r){r===void 0&&(r=!1);var n=e;r&&(this._multiply(n,this.uniforms.m,e),n=this._colorMatrix(n)),this.uniforms.m=n},t.prototype._multiply=function(e,r,n){return e[0]=r[0]*n[0]+r[1]*n[5]+r[2]*n[10]+r[3]*n[15],e[1]=r[0]*n[1]+r[1]*n[6]+r[2]*n[11]+r[3]*n[16],e[2]=r[0]*n[2]+r[1]*n[7]+r[2]*n[12]+r[3]*n[17],e[3]=r[0]*n[3]+r[1]*n[8]+r[2]*n[13]+r[3]*n[18],e[4]=r[0]*n[4]+r[1]*n[9]+r[2]*n[14]+r[3]*n[19]+r[4],e[5]=r[5]*n[0]+r[6]*n[5]+r[7]*n[10]+r[8]*n[15],e[6]=r[5]*n[1]+r[6]*n[6]+r[7]*n[11]+r[8]*n[16],e[7]=r[5]*n[2]+r[6]*n[7]+r[7]*n[12]+r[8]*n[17],e[8]=r[5]*n[3]+r[6]*n[8]+r[7]*n[13]+r[8]*n[18],e[9]=r[5]*n[4]+r[6]*n[9]+r[7]*n[14]+r[8]*n[19]+r[9],e[10]=r[10]*n[0]+r[11]*n[5]+r[12]*n[10]+r[13]*n[15],e[11]=r[10]*n[1]+r[11]*n[6]+r[12]*n[11]+r[13]*n[16],e[12]=r[10]*n[2]+r[11]*n[7]+r[12]*n[12]+r[13]*n[17],e[13]=r[10]*n[3]+r[11]*n[8]+r[12]*n[13]+r[13]*n[18],e[14]=r[10]*n[4]+r[11]*n[9]+r[12]*n[14]+r[13]*n[19]+r[14],e[15]=r[15]*n[0]+r[16]*n[5]+r[17]*n[10]+r[18]*n[15],e[16]=r[15]*n[1]+r[16]*n[6]+r[17]*n[11]+r[18]*n[16],e[17]=r[15]*n[2]+r[16]*n[7]+r[17]*n[12]+r[18]*n[17],e[18]=r[15]*n[3]+r[16]*n[8]+r[17]*n[13]+r[18]*n[18],e[19]=r[15]*n[4]+r[16]*n[9]+r[17]*n[14]+r[18]*n[19]+r[19],e},t.prototype._colorMatrix=function(e){var r=new Float32Array(e);return r[4]/=255,r[9]/=255,r[14]/=255,r[19]/=255,r},t.prototype.brightness=function(e,r){var n=[e,0,0,0,0,0,e,0,0,0,0,0,e,0,0,0,0,0,1,0];this._loadMatrix(n,r)},t.prototype.tint=function(e,r){var n=e>>16&255,s=e>>8&255,a=e&255,o=[n/255,0,0,0,0,0,s/255,0,0,0,0,0,a/255,0,0,0,0,0,1,0];this._loadMatrix(o,r)},t.prototype.greyscale=function(e,r){var n=[e,e,e,0,0,e,e,e,0,0,e,e,e,0,0,0,0,0,1,0];this._loadMatrix(n,r)},t.prototype.blackAndWhite=function(e){var r=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(r,e)},t.prototype.hue=function(e,r){e=(e||0)/180*Math.PI;var n=Math.cos(e),s=Math.sin(e),a=Math.sqrt,o=1/3,h=a(o),u=n+(1-n)*o,l=o*(1-n)-h*s,c=o*(1-n)+h*s,f=o*(1-n)+h*s,d=n+o*(1-n),v=o*(1-n)-h*s,_=o*(1-n)-h*s,p=o*(1-n)+h*s,g=n+o*(1-n),y=[u,l,c,0,0,f,d,v,0,0,_,p,g,0,0,0,0,0,1,0];this._loadMatrix(y,r)},t.prototype.contrast=function(e,r){var n=(e||0)+1,s=-.5*(n-1),a=[n,0,0,0,s,0,n,0,0,s,0,0,n,0,s,0,0,0,1,0];this._loadMatrix(a,r)},t.prototype.saturate=function(e,r){e===void 0&&(e=0);var n=e*2/3+1,s=(n-1)*-.5,a=[n,s,s,0,0,s,n,s,0,0,s,s,n,0,0,0,0,0,1,0];this._loadMatrix(a,r)},t.prototype.desaturate=function(){this.saturate(-1)},t.prototype.negative=function(e){var r=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(r,e)},t.prototype.sepia=function(e){var r=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(r,e)},t.prototype.technicolor=function(e){var r=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(r,e)},t.prototype.polaroid=function(e){var r=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(r,e)},t.prototype.toBGR=function(e){var r=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(r,e)},t.prototype.kodachrome=function(e){var r=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(r,e)},t.prototype.browni=function(e){var r=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(r,e)},t.prototype.vintage=function(e){var r=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(r,e)},t.prototype.colorTone=function(e,r,n,s,a){e=e||.2,r=r||.15,n=n||16770432,s=s||3375104;var o=(n>>16&255)/255,h=(n>>8&255)/255,u=(n&255)/255,l=(s>>16&255)/255,c=(s>>8&255)/255,f=(s&255)/255,d=[.3,.59,.11,0,0,o,h,u,e,0,l,c,f,r,0,o-l,h-c,u-f,0,0];this._loadMatrix(d,a)},t.prototype.night=function(e,r){e=e||.1;var n=[e*-2,-e,0,0,0,-e,0,e,0,0,0,e,e*2,0,0,0,0,0,1,0];this._loadMatrix(n,r)},t.prototype.predator=function(e,r){var n=[11.224130630493164*e,-4.794486999511719*e,-2.8746118545532227*e,0*e,.40342438220977783*e,-3.6330697536468506*e,9.193157196044922*e,-2.951810836791992*e,0*e,-1.316135048866272*e,-3.2184197902679443*e,-4.2375030517578125*e,7.476448059082031*e,0*e,.8044459223747253*e,0,0,0,1,0];this._loadMatrix(n,r)},t.prototype.lsd=function(e){var r=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(r,e)},t.prototype.reset=function(){var e=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(e,!1)},Object.defineProperty(t.prototype,"matrix",{get:function(){return this.uniforms.m},set:function(e){this.uniforms.m=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alpha",{get:function(){return this.uniforms.uAlpha},set:function(e){this.uniforms.uAlpha=e},enumerable:!1,configurable:!0}),t}(Te);Co.prototype.grayscale=Co.prototype.greyscale;var Io=function(i,t){return Io=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},Io(i,t)};function Jy(i,t){Io(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Qy=`varying vec2 vFilterCoord;
827
- varying vec2 vTextureCoord;
828
-
829
- uniform vec2 scale;
830
- uniform mat2 rotation;
831
- uniform sampler2D uSampler;
832
- uniform sampler2D mapSampler;
833
-
834
- uniform highp vec4 inputSize;
835
- uniform vec4 inputClamp;
836
-
837
- void main(void)
838
- {
839
- vec4 map = texture2D(mapSampler, vFilterCoord);
840
-
841
- map -= 0.5;
842
- map.xy = scale * inputSize.zw * (rotation * map.xy);
843
-
844
- gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));
845
- }
846
- `,t0=`attribute vec2 aVertexPosition;
847
-
848
- uniform mat3 projectionMatrix;
849
- uniform mat3 filterMatrix;
850
-
851
- varying vec2 vTextureCoord;
852
- varying vec2 vFilterCoord;
853
-
854
- uniform vec4 inputSize;
855
- uniform vec4 outputFrame;
856
-
857
- vec4 filterVertexPosition( void )
858
- {
859
- vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
860
-
861
- return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
862
- }
863
-
864
- vec2 filterTextureCoord( void )
865
- {
866
- return aVertexPosition * (outputFrame.zw * inputSize.zw);
867
- }
868
-
869
- void main(void)
870
- {
871
- gl_Position = filterVertexPosition();
872
- vTextureCoord = filterTextureCoord();
873
- vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;
874
- }
875
- `,e0=function(i){Jy(t,i);function t(e,r){var n=this,s=new bt;return e.renderable=!1,n=i.call(this,t0,Qy,{mapSampler:e._texture,filterMatrix:s,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])})||this,n.maskSprite=e,n.maskMatrix=s,r==null&&(r=20),n.scale=new vt(r,r),n}return t.prototype.apply=function(e,r,n,s){this.uniforms.filterMatrix=e.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;var a=this.maskSprite.worldTransform,o=Math.sqrt(a.a*a.a+a.b*a.b),h=Math.sqrt(a.c*a.c+a.d*a.d);o!==0&&h!==0&&(this.uniforms.rotation[0]=a.a/o,this.uniforms.rotation[1]=a.b/o,this.uniforms.rotation[2]=a.c/h,this.uniforms.rotation[3]=a.d/h),e.applyFilter(this,r,n,s)},Object.defineProperty(t.prototype,"map",{get:function(){return this.uniforms.mapSampler},set:function(e){this.uniforms.mapSampler=e},enumerable:!1,configurable:!0}),t}(Te);var Ao=function(i,t){return Ao=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},Ao(i,t)};function r0(i,t){Ao(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var i0=`
876
- attribute vec2 aVertexPosition;
877
-
878
- uniform mat3 projectionMatrix;
879
-
880
- varying vec2 v_rgbNW;
881
- varying vec2 v_rgbNE;
882
- varying vec2 v_rgbSW;
883
- varying vec2 v_rgbSE;
884
- varying vec2 v_rgbM;
885
-
886
- varying vec2 vFragCoord;
887
-
888
- uniform vec4 inputSize;
889
- uniform vec4 outputFrame;
890
-
891
- vec4 filterVertexPosition( void )
892
- {
893
- vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
894
-
895
- return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
896
- }
897
-
898
- void texcoords(vec2 fragCoord, vec2 inverseVP,
899
- out vec2 v_rgbNW, out vec2 v_rgbNE,
900
- out vec2 v_rgbSW, out vec2 v_rgbSE,
901
- out vec2 v_rgbM) {
902
- v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;
903
- v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;
904
- v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;
905
- v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;
906
- v_rgbM = vec2(fragCoord * inverseVP);
907
- }
908
-
909
- void main(void) {
910
-
911
- gl_Position = filterVertexPosition();
912
-
913
- vFragCoord = aVertexPosition * outputFrame.zw;
914
-
915
- texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
665
+ gl_Position = filterVertexPosition();
666
+ vTextureCoord = filterTextureCoord();
667
+ vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;
916
668
  }
917
- `,n0=`varying vec2 v_rgbNW;
669
+ `;class Uu extends kt{constructor(t,e){const i=new vt;t.renderable=!1,super(Cm,wm,{mapSampler:t._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=i,e==null&&(e=20),this.scale=new ft(e,e)}apply(t,e,i,r){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const n=this.maskSprite.worldTransform,a=Math.sqrt(n.a*n.a+n.b*n.b),o=Math.sqrt(n.c*n.c+n.d*n.d);a!==0&&o!==0&&(this.uniforms.rotation[0]=n.a/a,this.uniforms.rotation[1]=n.b/a,this.uniforms.rotation[2]=n.c/o,this.uniforms.rotation[3]=n.d/o),t.applyFilter(this,e,i,r)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var Am=`varying vec2 v_rgbNW;
918
670
  varying vec2 v_rgbNE;
919
671
  varying vec2 v_rgbSW;
920
672
  varying vec2 v_rgbSE;
@@ -1035,7 +787,49 @@ void main() {
1035
787
 
1036
788
  gl_FragColor = color;
1037
789
  }
1038
- `,s0=function(i){r0(t,i);function t(){return i.call(this,i0,n0)||this}return t}(Te);var Mo=function(i,t){return Mo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},Mo(i,t)};function a0(i,t){Mo(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var o0=`precision highp float;
790
+ `,Sm=`
791
+ attribute vec2 aVertexPosition;
792
+
793
+ uniform mat3 projectionMatrix;
794
+
795
+ varying vec2 v_rgbNW;
796
+ varying vec2 v_rgbNE;
797
+ varying vec2 v_rgbSW;
798
+ varying vec2 v_rgbSE;
799
+ varying vec2 v_rgbM;
800
+
801
+ varying vec2 vFragCoord;
802
+
803
+ uniform vec4 inputSize;
804
+ uniform vec4 outputFrame;
805
+
806
+ vec4 filterVertexPosition( void )
807
+ {
808
+ vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
809
+
810
+ return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
811
+ }
812
+
813
+ void texcoords(vec2 fragCoord, vec2 inverseVP,
814
+ out vec2 v_rgbNW, out vec2 v_rgbNE,
815
+ out vec2 v_rgbSW, out vec2 v_rgbSE,
816
+ out vec2 v_rgbM) {
817
+ v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;
818
+ v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;
819
+ v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;
820
+ v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;
821
+ v_rgbM = vec2(fragCoord * inverseVP);
822
+ }
823
+
824
+ void main(void) {
825
+
826
+ gl_Position = filterVertexPosition();
827
+
828
+ vFragCoord = aVertexPosition * outputFrame.zw;
829
+
830
+ texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
831
+ }
832
+ `;class Gu extends kt{constructor(){super(Sm,Am)}}var Pm=`precision highp float;
1039
833
 
1040
834
  varying vec2 vTextureCoord;
1041
835
  varying vec4 vColor;
@@ -1069,4 +863,303 @@ void main()
1069
863
 
1070
864
  gl_FragColor = color;
1071
865
  }
1072
- `,h0=function(i){a0(t,i);function t(e,r){e===void 0&&(e=.5),r===void 0&&(r=Math.random());var n=i.call(this,oa,o0,{uNoise:0,uSeed:0})||this;return n.noise=e,n.seed=r,n}return Object.defineProperty(t.prototype,"noise",{get:function(){return this.uniforms.uNoise},set:function(e){this.uniforms.uNoise=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"seed",{get:function(){return this.uniforms.uSeed},set:function(e){this.uniforms.uSeed=e},enumerable:!1,configurable:!0}),t}(Te);var Rf=new bt;Ct.prototype._cacheAsBitmap=!1,Ct.prototype._cacheData=null,Ct.prototype._cacheAsBitmapResolution=null,Ct.prototype._cacheAsBitmapMultisample=xt.NONE;var u0=function(){function i(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}return i}();Object.defineProperties(Ct.prototype,{cacheAsBitmapResolution:{get:function(){return this._cacheAsBitmapResolution},set:function(i){i!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=i,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get:function(){return this._cacheAsBitmapMultisample},set:function(i){i!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=i,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(i){if(this._cacheAsBitmap!==i){this._cacheAsBitmap=i;var t;i?(this._cacheData||(this._cacheData=new u0),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}}}),Ct.prototype._renderCached=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(t),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(t))},Ct.prototype._initCachedDisplayObject=function(t){var e;if(!(this._cacheData&&this._cacheData.sprite)){var r=this.alpha;this.alpha=1,t.batch.flush();var n=this.getLocalBounds(null,!0).clone();if(this.filters&&this.filters.length){var s=this.filters[0].padding;n.pad(s)}n.ceil(z.RESOLUTION);var a=t.renderTexture.current,o=t.renderTexture.sourceFrame.clone(),h=t.renderTexture.destinationFrame.clone(),u=t.projection.transform,l=Me.create({width:n.width,height:n.height,resolution:this.cacheAsBitmapResolution||t.resolution,multisample:(e=this.cacheAsBitmapMultisample)!==null&&e!==void 0?e:t.multisample}),c="cacheAsBitmap_"+Ie();this._cacheData.textureCacheId=c,lt.addToCache(l.baseTexture,c),it.addToCache(l,c);var f=this.transform.localTransform.copyTo(Rf).invert().translate(-n.x,-n.y);this.render=this._cacheData.originalRender,t.render(this,{renderTexture:l,clear:!0,transform:f,skipUpdateTransform:!1}),t.framebuffer.blit(),t.projection.transform=u,t.renderTexture.bind(a,o,h),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=r;var d=new wr(l);d.transform.worldTransform=this.transform.worldTransform,d.anchor.x=-(n.x/n.width),d.anchor.y=-(n.y/n.height),d.alpha=r,d._bounds=this._bounds,this._cacheData.sprite=d,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=d.containsPoint.bind(d)}},Ct.prototype._renderCachedCanvas=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(t),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(t))},Ct.prototype._initCachedDisplayObjectCanvas=function(t){if(!(this._cacheData&&this._cacheData.sprite)){var e=this.getLocalBounds(null,!0),r=this.alpha;this.alpha=1;var n=t.context,s=t._projTransform;e.ceil(z.RESOLUTION);var a=Me.create({width:e.width,height:e.height}),o="cacheAsBitmap_"+Ie();this._cacheData.textureCacheId=o,lt.addToCache(a.baseTexture,o),it.addToCache(a,o);var h=Rf;this.transform.localTransform.copyTo(h),h.invert(),h.tx-=e.x,h.ty-=e.y,this.renderCanvas=this._cacheData.originalRenderCanvas,t.render(this,{renderTexture:a,clear:!0,transform:h,skipUpdateTransform:!1}),t.context=n,t._projTransform=s,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=r;var u=new wr(a);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(e.x/e.width),u.anchor.y=-(e.y/e.height),u.alpha=r,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=t._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=u.containsPoint.bind(u)}},Ct.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Ct.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Ct.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,lt.removeFromCache(this._cacheData.textureCacheId),it.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Ct.prototype._cacheAsBitmapDestroy=function(t){this.cacheAsBitmap=!1,this.destroy(t)};Ct.prototype.name=null,Zt.prototype.getChildByName=function(t,e){for(var r=0,n=this.children.length;r<n;r++)if(this.children[r].name===t)return this.children[r];if(e)for(var r=0,n=this.children.length;r<n;r++){var s=this.children[r];if(s.getChildByName){var a=s.getChildByName(t,!0);if(a)return a}}return null};Ct.prototype.getGlobalPosition=function(t,e){return t===void 0&&(t=new vt),e===void 0&&(e=!1),this.parent?this.parent.toGlobal(this.position,t,e):(t.x=this.position.x,t.y=this.position.y),t};var Of=function(){function i(){}return i.init=function(t){var e=this;Object.defineProperty(this,"resizeTo",{set:function(r){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=r,r&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get:function(){return this._resizeTo}}),this.queueResize=function(){e._resizeTo&&(e.cancelResize(),e._resizeId=requestAnimationFrame(function(){return e.resize()}))},this.cancelResize=function(){e._resizeId&&(cancelAnimationFrame(e._resizeId),e._resizeId=null)},this.resize=function(){if(e._resizeTo){e.cancelResize();var r,n;if(e._resizeTo===globalThis.window)r=globalThis.innerWidth,n=globalThis.innerHeight;else{var s=e._resizeTo,a=s.clientWidth,o=s.clientHeight;r=a,n=o}e.renderer.resize(r,n)}},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null},i.destroy=function(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null},i.extension=dt.Application,i}(),Ro=function(){function i(t){var e=this;this.stage=new Zt,t=Object.assign({forceCanvas:!1},t),this.renderer=Ou(t),i._plugins.forEach(function(r){r.init.call(e,t)})}return i.registerPlugin=function(t){Bt("6.5.0","Application.registerPlugin() is deprecated, use extensions.add()"),Kt.add({type:dt.Application,ref:t})},i.prototype.render=function(){this.renderer.render(this.stage)},Object.defineProperty(i.prototype,"view",{get:function(){return this.renderer.view},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"screen",{get:function(){return this.renderer.screen},enumerable:!1,configurable:!0}),i.prototype.destroy=function(t,e){var r=this,n=i._plugins.slice(0);n.reverse(),n.forEach(function(s){s.destroy.call(r)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null},i._plugins=[],i}();Kt.handleByList(dt.Application,Ro._plugins),Kt.add(Of);var Oo=function(i,t){return Oo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},Oo(i,t)};function Mr(i,t){Oo(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Df=function(i){Mr(t,i);function t(e,r,n,s){e===void 0&&(e=100),r===void 0&&(r=100),n===void 0&&(n=10),s===void 0&&(s=10);var a=i.call(this)||this;return a.segWidth=n,a.segHeight=s,a.width=e,a.height=r,a.build(),a}return t.prototype.build=function(){for(var e=this.segWidth*this.segHeight,r=[],n=[],s=[],a=this.segWidth-1,o=this.segHeight-1,h=this.width/a,u=this.height/o,l=0;l<e;l++){var c=l%this.segWidth,f=l/this.segWidth|0;r.push(c*h,f*u),n.push(c/a,f/o)}for(var d=a*o,l=0;l<d;l++){var v=l%a,_=l/a|0,p=_*this.segWidth+v,g=_*this.segWidth+v+1,y=(_+1)*this.segWidth+v,T=(_+1)*this.segWidth+v+1;s.push(p,g,y,g,T,y)}this.buffers[0].data=new Float32Array(r),this.buffers[1].data=new Float32Array(n),this.indexBuffer.data=new Uint16Array(s),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()},t}(mi),Ff=function(i){Mr(t,i);function t(e,r,n){e===void 0&&(e=200),n===void 0&&(n=0);var s=i.call(this,new Float32Array(r.length*4),new Float32Array(r.length*4),new Uint16Array((r.length-1)*6))||this;return s.points=r,s._width=e,s.textureScale=n,s.build(),s}return Object.defineProperty(t.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),t.prototype.build=function(){var e=this.points;if(e){var r=this.getBuffer("aVertexPosition"),n=this.getBuffer("aTextureCoord"),s=this.getIndex();if(!(e.length<1)){r.data.length/4!==e.length&&(r.data=new Float32Array(e.length*4),n.data=new Float32Array(e.length*4),s.data=new Uint16Array((e.length-1)*6));var a=n.data,o=s.data;a[0]=0,a[1]=0,a[2]=0,a[3]=1;for(var h=0,u=e[0],l=this._width*this.textureScale,c=e.length,f=0;f<c;f++){var d=f*4;if(this.textureScale>0){var v=u.x-e[f].x,_=u.y-e[f].y,p=Math.sqrt(v*v+_*_);u=e[f],h+=p/l}else h=f/(c-1);a[d]=h,a[d+1]=0,a[d+2]=h,a[d+3]=1}for(var g=0,f=0;f<c-1;f++){var d=f*2;o[g++]=d,o[g++]=d+1,o[g++]=d+2,o[g++]=d+2,o[g++]=d+1,o[g++]=d+3}n.update(),s.update(),this.updateVertices()}}},t.prototype.updateVertices=function(){var e=this.points;if(!(e.length<1)){for(var r=e[0],n,s=0,a=0,o=this.buffers[0].data,h=e.length,u=0;u<h;u++){var l=e[u],c=u*4;u<e.length-1?n=e[u+1]:n=l,a=-(n.x-r.x),s=n.y-r.y;var f=Math.sqrt(s*s+a*a),d=this.textureScale>0?this.textureScale*this._width/2:this._width/2;s/=f,a/=f,s*=d,a*=d,o[c]=l.x+s,o[c+1]=l.y+a,o[c+2]=l.x-s,o[c+3]=l.y-a,r=l}this.buffers[0].update()}},t.prototype.update=function(){this.textureScale>0?this.build():this.updateVertices()},t}(mi),l0=function(i){Mr(t,i);function t(e,r,n){n===void 0&&(n=0);var s=this,a=new Ff(e.height,r,n),o=new Ar(e);return n>0&&(e.baseTexture.wrapMode=ne.REPEAT),s=i.call(this,a,o)||this,s.autoUpdate=!0,s}return t.prototype._render=function(e){var r=this.geometry;(this.autoUpdate||r._width!==this.shader.texture.height)&&(r._width=this.shader.texture.height,r.update()),i.prototype._render.call(this,e)},t}(Ir),Lf=function(i){Mr(t,i);function t(e,r,n){var s=this,a=new Df(e.width,e.height,r,n),o=new Ar(it.WHITE);return s=i.call(this,a,o)||this,s.texture=e,s.autoResize=!0,s}return t.prototype.textureUpdated=function(){this._textureID=this.shader.texture._updateID;var e=this.geometry,r=this.shader.texture,n=r.width,s=r.height;this.autoResize&&(e.width!==n||e.height!==s)&&(e.width=this.shader.texture.width,e.height=this.shader.texture.height,e.build())},Object.defineProperty(t.prototype,"texture",{get:function(){return this.shader.texture},set:function(e){this.shader.texture!==e&&(this.shader.texture=e,this._textureID=-1,e.baseTexture.valid?this.textureUpdated():e.once("update",this.textureUpdated,this))},enumerable:!1,configurable:!0}),t.prototype._render=function(e){this._textureID!==this.shader.texture._updateID&&this.textureUpdated(),i.prototype._render.call(this,e)},t.prototype.destroy=function(e){this.shader.texture.off("update",this.textureUpdated,this),i.prototype.destroy.call(this,e)},t}(Ir),f0=function(i){Mr(t,i);function t(e,r,n,s,a){e===void 0&&(e=it.EMPTY);var o=this,h=new mi(r,n,s);h.getBuffer("aVertexPosition").static=!1;var u=new Ar(e);return o=i.call(this,h,u,null,a)||this,o.autoUpdate=!0,o}return Object.defineProperty(t.prototype,"vertices",{get:function(){return this.geometry.getBuffer("aVertexPosition").data},set:function(e){this.geometry.getBuffer("aVertexPosition").data=e},enumerable:!1,configurable:!0}),t.prototype._render=function(e){this.autoUpdate&&this.geometry.getBuffer("aVertexPosition").update(),i.prototype._render.call(this,e)},t}(Ir),mn=10,c0=function(i){Mr(t,i);function t(e,r,n,s,a){r===void 0&&(r=mn),n===void 0&&(n=mn),s===void 0&&(s=mn),a===void 0&&(a=mn);var o=i.call(this,it.WHITE,4,4)||this;return o._origWidth=e.orig.width,o._origHeight=e.orig.height,o._width=o._origWidth,o._height=o._origHeight,o._leftWidth=r,o._rightWidth=s,o._topHeight=n,o._bottomHeight=a,o.texture=e,o}return t.prototype.textureUpdated=function(){this._textureID=this.shader.texture._updateID,this._refresh()},Object.defineProperty(t.prototype,"vertices",{get:function(){return this.geometry.getBuffer("aVertexPosition").data},set:function(e){this.geometry.getBuffer("aVertexPosition").data=e},enumerable:!1,configurable:!0}),t.prototype.updateHorizontalVertices=function(){var e=this.vertices,r=this._getMinScale();e[9]=e[11]=e[13]=e[15]=this._topHeight*r,e[17]=e[19]=e[21]=e[23]=this._height-this._bottomHeight*r,e[25]=e[27]=e[29]=e[31]=this._height},t.prototype.updateVerticalVertices=function(){var e=this.vertices,r=this._getMinScale();e[2]=e[10]=e[18]=e[26]=this._leftWidth*r,e[4]=e[12]=e[20]=e[28]=this._width-this._rightWidth*r,e[6]=e[14]=e[22]=e[30]=this._width},t.prototype._getMinScale=function(){var e=this._leftWidth+this._rightWidth,r=this._width>e?1:this._width/e,n=this._topHeight+this._bottomHeight,s=this._height>n?1:this._height/n,a=Math.min(r,s);return a},Object.defineProperty(t.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"leftWidth",{get:function(){return this._leftWidth},set:function(e){this._leftWidth=e,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rightWidth",{get:function(){return this._rightWidth},set:function(e){this._rightWidth=e,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"topHeight",{get:function(){return this._topHeight},set:function(e){this._topHeight=e,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bottomHeight",{get:function(){return this._bottomHeight},set:function(e){this._bottomHeight=e,this._refresh()},enumerable:!1,configurable:!0}),t.prototype._refresh=function(){var e=this.texture,r=this.geometry.buffers[1].data;this._origWidth=e.orig.width,this._origHeight=e.orig.height;var n=1/this._origWidth,s=1/this._origHeight;r[0]=r[8]=r[16]=r[24]=0,r[1]=r[3]=r[5]=r[7]=0,r[6]=r[14]=r[22]=r[30]=1,r[25]=r[27]=r[29]=r[31]=1,r[2]=r[10]=r[18]=r[26]=n*this._leftWidth,r[4]=r[12]=r[20]=r[28]=1-n*this._rightWidth,r[9]=r[11]=r[13]=r[15]=s*this._topHeight,r[17]=r[19]=r[21]=r[23]=1-s*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.geometry.buffers[0].update(),this.geometry.buffers[1].update()},t}(Lf);var Do=function(i,t){return Do=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])},Do(i,t)};function d0(i,t){Do(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var p0=function(i){d0(t,i);function t(e,r){r===void 0&&(r=!0);var n=i.call(this,e[0]instanceof it?e[0]:e[0].texture)||this;return n._textures=null,n._durations=null,n._autoUpdate=r,n._isConnectedToTicker=!1,n.animationSpeed=1,n.loop=!0,n.updateAnchor=!1,n.onComplete=null,n.onFrameChange=null,n.onLoop=null,n._currentTime=0,n._playing=!1,n._previousFrame=null,n.textures=e,n}return t.prototype.stop=function(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(Ot.shared.remove(this.update,this),this._isConnectedToTicker=!1))},t.prototype.play=function(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(Ot.shared.add(this.update,this,de.HIGH),this._isConnectedToTicker=!0))},t.prototype.gotoAndStop=function(e){this.stop();var r=this.currentFrame;this._currentTime=e,r!==this.currentFrame&&this.updateTexture()},t.prototype.gotoAndPlay=function(e){var r=this.currentFrame;this._currentTime=e,r!==this.currentFrame&&this.updateTexture(),this.play()},t.prototype.update=function(e){if(this._playing){var r=this.animationSpeed*e,n=this.currentFrame;if(this._durations!==null){var s=this._currentTime%1*this._durations[this.currentFrame];for(s+=r/60*1e3;s<0;)this._currentTime--,s+=this._durations[this.currentFrame];var a=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);s>=this._durations[this.currentFrame];)s-=this._durations[this.currentFrame]*a,this._currentTime+=a;this._currentTime+=s/this._durations[this.currentFrame]}else this._currentTime+=r;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):n!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<n?this.onLoop():this.animationSpeed<0&&this.currentFrame>n&&this.onLoop()),this.updateTexture())}},t.prototype.updateTexture=function(){var e=this.currentFrame;this._previousFrame!==e&&(this._previousFrame=e,this._texture=this._textures[e],this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this.uvs=this._texture._uvs.uvsFloat32,this.updateAnchor&&this._anchor.copyFrom(this._texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))},t.prototype.destroy=function(e){this.stop(),i.prototype.destroy.call(this,e),this.onComplete=null,this.onFrameChange=null,this.onLoop=null},t.fromFrames=function(e){for(var r=[],n=0;n<e.length;++n)r.push(it.from(e[n]));return new t(r)},t.fromImages=function(e){for(var r=[],n=0;n<e.length;++n)r.push(it.from(e[n]));return new t(r)},Object.defineProperty(t.prototype,"totalFrames",{get:function(){return this._textures.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textures",{get:function(){return this._textures},set:function(e){if(e[0]instanceof it)this._textures=e,this._durations=null;else{this._textures=[],this._durations=[];for(var r=0;r<e.length;r++)this._textures.push(e[r].texture),this._durations.push(e[r].time)}this._previousFrame=null,this.gotoAndStop(0),this.updateTexture()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentFrame",{get:function(){var e=Math.floor(this._currentTime)%this._textures.length;return e<0&&(e+=this._textures.length),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"playing",{get:function(){return this._playing},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"autoUpdate",{get:function(){return this._autoUpdate},set:function(e){e!==this._autoUpdate&&(this._autoUpdate=e,!this._autoUpdate&&this._isConnectedToTicker?(Ot.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(Ot.shared.add(this.update,this),this._isConnectedToTicker=!0))},enumerable:!1,configurable:!0}),t}(wr);Kt.add(Al,Ol,Ha,tf,vf,ua,xf,Af,Hl,Kl,Zl,gf,Es,Ul);var v0={AlphaFilter:Vy,BlurFilter:$y,BlurFilterPass:Po,ColorMatrixFilter:Co,DisplacementFilter:e0,FXAAFilter:s0,NoiseFilter:h0};const _0=Object.freeze(Object.defineProperty({__proto__:null,get ALPHA_MODES(){return Wt},AbstractBatchRenderer:Fu,AbstractMultiResource:Oi,AbstractRenderer:Ru,AccessibilityManager:Al,AnimatedSprite:p0,AppLoaderPlugin:Ul,Application:Ro,ArrayResource:ws,Attribute:Fs,get BLEND_MODES(){return tt},get BUFFER_BITS(){return Fr},get BUFFER_TYPE(){return se},BaseImageResource:pe,BasePrepare:df,BaseRenderTexture:Os,BaseTexture:lt,BatchDrawCall:Vi,BatchGeometry:ha,BatchPluginFactory:Uu,BatchRenderer:ua,BatchShaderGenerator:Lu,BatchSystem:Us,BatchTextureArray:ji,BitmapFont:we,BitmapFontData:yi,BitmapFontLoader:Af,BitmapText:Gy,BlobResource:Xl,Bounds:$r,BrowserAdapter:Vo,Buffer:Mt,BufferResource:Ke,get CLEAR_MODES(){return Yt},get COLOR_MASK_BITS(){return Pn},CanvasResource:Cs,Circle:$h,CompressedTextureLoader:Hl,CompressedTextureResource:hn,Container:Zt,ContextSystem:ks,CountLimiter:cf,CubeResource:Is,DDSLoader:Kl,DEG_TO_RAD:qh,get DRAW_MODES(){return jt},DisplayObject:Ct,get ENV(){return Ut},Ellipse:Kh,get ExtensionType(){return dt},Extract:Ol,get FORMATS(){return H},FORMATS_TO_COMPONENTS:Yl,FillStyle:Qa,Filter:Te,FilterState:su,FilterSystem:Ns,Framebuffer:Fi,FramebufferSystem:Gs,get GC_MODES(){return Br},GLFramebuffer:ou,GLProgram:Iu,GLTexture:Hi,GRAPHICS_CURVES:Er,Geometry:vr,GeometrySystem:Hs,Graphics:vi,GraphicsData:ao,GraphicsGeometry:uf,IGLUniformData:e_,INSTALLED:jr,get INTERNAL_FORMATS(){return at},INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:li,ImageBitmapResource:Rs,ImageResource:Di,InteractionData:Ga,InteractionEvent:Ml,InteractionManager:Ha,InteractionTrackingData:rn,KTXLoader:Zl,get LINE_CAP(){return Pe},get LINE_JOIN(){return me},LineStyle:lf,Loader:ui,get LoaderResource(){return wt},get MASK_TYPES(){return It},get MIPMAP_MODES(){return zt},get MSAA_QUALITY(){return xt},MaskData:hu,MaskSystem:Ks,Matrix:bt,Mesh:Ir,MeshBatchUvs:bf,MeshGeometry:mi,MeshMaterial:Ar,NineSlicePlane:c0,ObjectRenderer:zr,ObservablePoint:Ae,PI_2:Xr,get PRECISION(){return kt},ParticleContainer:iy,ParticleRenderer:tf,PlaneGeometry:Df,Point:vt,Polygon:Hr,Prepare:vf,Program:_r,ProjectionSystem:Qs,Quad:nu,QuadUv:Ls,RAD_TO_DEG:Yh,get RENDERER_TYPE(){return cr},Rectangle:ut,RenderTexture:Me,RenderTexturePool:ru,RenderTextureSystem:ta,Renderer:aa,ResizePlugin:Of,Resource:$e,RopeGeometry:Ff,RoundedRectangle:Zh,Runner:Dt,get SAMPLER_TYPES(){return Lr},get SCALE_MODES(){return ie},get SHAPES(){return Rt},SVGResource:As,ScissorSystem:Zs,Shader:be,ShaderSystem:ea,SimpleMesh:f0,SimplePlane:Lf,SimpleRope:l0,Sprite:wr,SpriteMaskFilter:xu,Spritesheet:_f,SpritesheetLoader:gf,State:Oe,StateSystem:ra,StencilSystem:Js,System:g_,get TARGETS(){return Ce},get TEXT_GRADIENT(){return Cr},get TYPES(){return Q},TYPES_TO_BYTES_PER_COMPONENT:Za,TYPES_TO_BYTES_PER_PIXEL:ql,TemporaryDisplayObject:da,Text:po,TextFormat:Ef,TextMetrics:le,TextStyle:lr,Texture:it,TextureGCSystem:ia,TextureLoader:kl,TextureMatrix:Gi,TextureSystem:na,TextureUvs:Ds,Ticker:Ot,TickerPlugin:Es,TilingSprite:Cy,TilingSpriteRenderer:xf,TimeLimiter:wy,Transform:Mi,get UPDATE_PRIORITY(){return de},UniformGroup:Re,VERSION:x_,VideoResource:Ms,ViewableBuffer:zi,get WRAP_MODES(){return ne},XMLFormat:_n,XMLStringFormat:Sf,accessibleTarget:wl,autoDetectFormat:To,autoDetectRenderer:Ou,autoDetectResource:Ri,checkMaxIfStatementsInShader:mu,createUBOElements:Pu,defaultFilterVertex:oa,defaultVertex:Du,extensions:Kt,filters:v0,generateProgram:Au,generateUniformBufferSync:Cu,getTestContext:du,getUBOData:wu,graphicsUtils:uy,groupD8:Tt,interactiveTarget:Rl,isMobile:qt,parseDDS:zl,parseKTX:$l,resources:ku,settings:z,systems:Gu,uniformParsers:Ze,utils:Pv},Symbol.toStringTag,{value:"Module"}));async function Bf(i){const{models:t,element_id:e,auto_fit:r=!0,auto_motion:n=!0,mouse_tracking:s=!0}=i,a=new Ro({view:document.getElementById(e),width:300,height:300,backgroundAlpha:0,autoDensity:!0,antialias:!0}),o=await Qr.from(t[0]);if(a.stage.addChild(o),r){const h=Math.min(300/o.width,300/o.height);o.scale.set(h),o.x=(300-o.width*h)/2,o.y=(300-o.height*h)/2}return s&&g0(o,a.view),n&&await m0(o),o}function g0(i,t){document.addEventListener("mousemove",e=>{var h;const r=t.getBoundingClientRect(),n=r.left+r.width/2,s=r.top+r.height/2,a=(e.clientX-n)/r.width,o=(e.clientY-s)/r.height;i.internalModel&&((h=i.internalModel.focusController)==null||h.focus(a,o))})}async function m0(i){var t;try{const e=(t=i.internalModel)==null?void 0:t.motionManager.definitions;if(e)if(e.idle)await i.motion("idle");else if(e.tap_body)await i.motion("tap_body");else{const r=Object.keys(e)[0];r&&await i.motion(r)}}catch(e){console.warn("Failed to start idle animation:",e)}}async function Nf(i){Qr.registerTicker(Ot),Kt.add(Es),Kt.add(Ha)}const y0={createLive2dModel:Bf,initializeLive2D:Nf,Live2DModel:Qr,MotionManager:gr};re.Live2DModel=Qr,re.MotionManager=gr,re.PIXI=_0,re.createLive2dModel=Bf,re.default=y0,re.initializeLive2D=Nf,Object.defineProperties(re,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
866
+ `;class Vu extends kt{constructor(t=.5,e=Math.random()){super(Qa,Pm,{uNoise:0,uSeed:0}),this.noise=t,this.seed=e}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}const ho={AlphaFilter:ku,BlurFilter:Nu,BlurFilterPass:Is,ColorMatrixFilter:Rs,DisplacementFilter:Uu,FXAAFilter:Gu,NoiseFilter:Vu};Object.entries(ho).forEach(([s,t])=>{Object.defineProperty(ho,s,{get(){return ot("7.1.0",`filters.${s} has moved to ${s}`),t}})});class Mm{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||(Pt.system.add(this.tickerUpdate,this,Pe.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(Pt.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const ti=new Mm;class Li{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Li.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ft,this.page=new ft,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,r,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class Sr extends Li{constructor(){super(...arguments),this.client=new ft,this.movement=new ft,this.offset=new ft,this.global=new ft,this.screen=new ft}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,r,n,a,o,h,l,u,c,d,f,p,g){throw new Error("Method not implemented.")}}class te extends Sr{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class xi extends Sr{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}xi.DOM_DELTA_PIXEL=0,xi.DOM_DELTA_LINE=1,xi.DOM_DELTA_PAGE=2;const Im=2048,Rm=new ft,lo=new ft;class Hu{constructor(t){this.dispatch=new Ee,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,r)=>i.priority-r.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,r=e.length;i<r;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){ti.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",r=this[i](this.rootTarget,this.rootTarget.eventMode,Rm.set(t,e),this.hitTestFn,this.hitPruneFn);return r&&r[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let r=0,n=i.length-1;r<n;r++)if(t.currentTarget=i[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let r=i.length-2;r>=0;r--)if(t.currentTarget=i[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const r=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)r.forEach(a=>{t.currentTarget=i[n],this.notifyTarget(t,a)})}propagationPath(t){const e=[t];for(let i=0;i<Im&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,r,n,a=!1){let o=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(ti.pauseUpdate=!1),t.interactiveChildren&&t.children){const u=t.children;for(let c=u.length-1;c>=0;c--){const d=u[c],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,r,n,a||n(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=t.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),o=!0}}}const h=this._isInteractive(e),l=t.isInteractive();return h&&l&&this._allInteractiveElements.push(t),a||this._hitElements.length>0?null:o?this._hitElements:h&&!n(t,i)&&r(t,i)?l?[t]:[]:null}hitTestRecursive(t,e,i,r,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(ti.pauseUpdate=!1),t.interactiveChildren&&t.children){const h=t.children;for(let l=h.length-1;l>=0;l--){const u=h[l],c=this.hitTestRecursive(u,this._isInteractive(e)?e:u.eventMode,i,r,n);if(c){if(c.length>0&&!c[c.length-1].parent)continue;const d=t.isInteractive();return(c.length>0||d)&&c.push(t),c}}}const a=this._isInteractive(e),o=t.isInteractive();return a&&r(t,i)?o?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,e){var i;if(t.hitArea&&(t.worldTransform.applyInverse(e,lo),!t.hitArea.contains(lo.x,lo.y)))return!0;if(t._mask){const r=t._mask.isMaskData?t._mask.maskObject:t._mask;if(r&&!((i=r.containsPoint)!=null&&i.call(r,e)))return!0}return!1}hitTestFn(t,e){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){var n,a;e=e??t.type;const i=`on${e}`;(a=(n=t.currentTarget)[i])==null||a.call(n,t);const r=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,r),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof te)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const r=e.button===2;this.dispatchEvent(e,r?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var h,l;if(!(t instanceof te)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=e.pointerType==="mouse"||e.pointerType==="pen",r=this.trackingData(t.pointerId),n=this.findMountedTarget(r.overTargets);if(((h=r.overTargets)==null?void 0:h.length)>0&&n!==e.target){const u=t.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(t,u,n);if(this.dispatchEvent(c,"pointerout"),i&&this.dispatchEvent(c,"mouseout"),!e.composedPath().includes(n)){const d=this.createPointerEvent(t,"pointerleave",n);for(d.eventPhase=d.AT_TARGET;d.target&&!e.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),i&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(c)}if(n!==e.target){const u=t.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(e,u);this.dispatchEvent(c,"pointerover"),i&&this.dispatchEvent(c,"mouseover");let d=n==null?void 0:n.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(e,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==n&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),i&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(c)}const a=[],o=this.enableGlobalMoveEvents??!0;this.moveOnAll?a.push("pointermove"):this.dispatchEvent(e,"pointermove"),o&&a.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?a.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),o&&a.push("globaltouchmove")),i&&(this.moveOnAll?a.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),o&&a.push("globalmousemove"),this.cursor=(l=e.target)==null?void 0:l.cursor),a.length>0&&this.all(e,a),this._allInteractiveElements.length=0,this._hitElements.length=0,r.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var a;if(!(t instanceof te)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),r=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),r&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(a=i.target)==null?void 0:a.cursor);const n=this.clonePointerEvent(i,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),r&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof te)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",r=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",r);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const a=this.createPointerEvent(t,"pointerleave",r);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),i&&this.notifyTarget(a,"mouseleave"),a.target=a.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(a)}this.cursor=null}mapPointerUp(t){if(!(t instanceof te)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const o=i.button===2;this.dispatchEvent(i,o?"rightup":"mouseup")}const r=this.trackingData(t.pointerId),n=this.findMountedTarget(r.pressTargetsByButton[t.button]);let a=n;if(n&&!i.composedPath().includes(n)){let o=n;for(;o&&!i.composedPath().includes(o);){if(i.currentTarget=o,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const h=i.button===2;this.notifyTarget(i,h?"rightupoutside":"mouseupoutside")}o=o.parent}delete r.pressTargetsByButton[t.button],a=o}if(a){const o=this.clonePointerEvent(i,"click");o.target=a,o.path=null,r.clicksByButton[t.button]||(r.clicksByButton[t.button]={clickCount:0,target:o.target,timeStamp:e});const h=r.clicksByButton[t.button];if(h.target===o.target&&e-h.timeStamp<200?++h.clickCount:h.clickCount=1,h.target=o.target,h.timeStamp=e,o.detail=h.clickCount,o.pointerType==="mouse"){const l=o.button===2;this.dispatchEvent(o,l?"rightclick":"click")}else o.pointerType==="touch"&&this.dispatchEvent(o,"tap");this.dispatchEvent(o,"pointertap"),this.freeEvent(o)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof te)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),r=this.createPointerEvent(t);if(i){let n=i;for(;n;)r.currentTarget=n,this.notifyTarget(r,"pointerupoutside"),r.pointerType==="touch"?this.notifyTarget(r,"touchendoutside"):(r.pointerType==="mouse"||r.pointerType==="pen")&&this.notifyTarget(r,r.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(r)}mapWheel(t){if(!(t instanceof xi)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const r=this.allocateEvent(te);return this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=i??this.hitTest(r.global.x,r.global.y)??this._hitElements[0],typeof e=="string"&&(r.type=e),r}createWheelEvent(t){const e=this.allocateEvent(xi);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(te);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof te&&e instanceof te&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof Sr&&e instanceof Sr&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let r=0,n=i.length;r<n&&!t.propagationImmediatelyStopped;r++)i[r].once&&t.currentTarget.removeListener(e,i[r].fn,void 0,!0),i[r].fn.call(i[r].context,t)}}const Dm=1,Fm={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},uo=class gh{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Hu(null),ti.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new te(null),this.rootWheelEvent=new xi(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...gh.defaultEventFeatures},{set:(e,i,r)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=r),e[i]=r,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{view:e,resolution:i}=this.renderer;this.setTargetElement(e),this.resolution=i,gh._defaultEventMode=t.eventMode??"auto",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,r=e.length;i<r;i++){const n=e[i],a=this.bootstrapEvent(this.rootPointerEvent,n);this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,ti.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,r=e.length;i<r;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",r=this.normalizeToPointerData(t);for(let n=0,a=r.length;n<a;n++){const o=this.bootstrapEvent(this.rootPointerEvent,r[n]);o.type+=i,this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let i=0,r=e.length;i<r;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,ti.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;ti.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;ti.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,e,i){const r=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-r.left)*(this.domElement.width/r.width)*n,t.y=(i-r.top)*(this.domElement.height/r.height)*n}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,r=t.changedTouches.length;i<r;i++){const n=t.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=Dm),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}else e.push(t);return e}normalizeWheelEvent(t){const e=this.rootWheelEvent;return this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=Fm[t.type]||t.type),t}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};uo.extension={name:"events",type:[$.RendererSystem,$.CanvasRendererSystem]},uo.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Ds=uo;Q.add(Ds);function Xu(s){return s==="dynamic"||s==="static"}const zu={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??Xu(Ds.defaultEventMode)},set interactive(s){ot("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=s,this.eventMode=s?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Ds.defaultEventMode},set eventMode(s){this._internalInteractive=Xu(s),this._internalEventMode=s},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(s,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,r=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,a=typeof t=="function"?void 0:t;s=i?`${s}capture`:s;const o=typeof t=="function"?t:t.handleEvent,h=this;r&&r.addEventListener("abort",()=>{h.off(s,o,a)}),n?h.once(s,o,a):h.on(s,o,a)},removeEventListener(s,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,r=typeof t=="function"?void 0:t;s=i?`${s}capture`:s,t=typeof t=="function"?t:t.handleEvent,this.off(s,t,r)},dispatchEvent(s){if(!(s instanceof Li))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return s.defaultPrevented=!1,s.path=null,s.target=this,s.manager.dispatchEvent(s),!s.defaultPrevented}};Et.mixin(zu);const Wu={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Et.mixin(Wu);const Bm=9,Fs=100,Lm=0,Om=0,$u=2,ju=1,km=-1e3,Nm=-1e3,Um=2;class co{constructor(t){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(ce.tablet||ce.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${Fs}px`,e.style.height=`${Fs}px`,e.style.position="absolute",e.style.top=`${Lm}px`,e.style.left=`${Om}px`,e.style.zIndex=$u.toString(),this.div=e,this.renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}createTouchHook(){const t=document.createElement("button");t.style.width=`${ju}px`,t.style.height=`${ju}px`,t.style.position="absolute",t.style.top=`${km}px`,t.style.left=`${Nm}px`,t.style.zIndex=Um.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),(t=this.renderer.view.parentNode)==null||t.appendChild(this.div))}deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),(t=this.div.parentNode)==null||t.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this.updateAccessibleObjects(e[i])}update(){const t=performance.now();if(ce.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:e,y:i,width:r,height:n}=this.renderer.view.getBoundingClientRect(),{width:a,height:o,resolution:h}=this.renderer,l=r/a*h,u=n/o*h;let c=this.div;c.style.left=`${e}px`,c.style.top=`${i}px`,c.style.width=`${a}px`,c.style.height=`${o}px`;for(let d=0;d<this.children.length;d++){const f=this.children[d];if(f.renderId!==this.renderId)f._accessibleActive=!1,di(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{c=f._accessibleDiv;let p=f.hitArea;const g=f.worldTransform;f.hitArea?(c.style.left=`${(g.tx+p.x*g.a)*l}px`,c.style.top=`${(g.ty+p.y*g.d)*u}px`,c.style.width=`${p.width*g.a*l}px`,c.style.height=`${p.height*g.d*u}px`):(p=f.getBounds(),this.capHitArea(p),c.style.left=`${p.x*l}px`,c.style.top=`${p.y*u}px`,c.style.width=`${p.width*l}px`,c.style.height=`${p.height*u}px`,c.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(c.title=f.accessibleTitle),c.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&c.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==c.title||f.tabIndex!==c.tabIndex)&&(c.title=f.accessibleTitle,c.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(c))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=`${Fs}px`,e.style.height=`${Fs}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=$u.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{displayObject:i}=t.target,r=this.renderer.events.rootBoundary,n=Object.assign(new Li(r),{target:i});r.rootTarget=this.renderer.lastObjectRendered,e.forEach(a=>r.dispatchEvent(n,a))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===Bm&&this.activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this.deactivate()}destroy(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null}}co.extension={name:"accessibility",type:[$.RendererPlugin,$.CanvasRendererPlugin]},Q.add(co);const Yu=class _h{constructor(t){this.stage=new Vt,t=Object.assign({forceCanvas:!1},t),this.renderer=Mu(t),_h._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render(this.stage)}get view(){var t;return(t=this.renderer)==null?void 0:t.view}get screen(){var t;return(t=this.renderer)==null?void 0:t.screen}destroy(t,e){const i=_h._plugins.slice(0);i.reverse(),i.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Yu._plugins=[];let fo=Yu;Q.handleByList($.Application,fo._plugins);class po{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:r,clientHeight:n}=this._resizeTo;e=r,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}po.extension=$.Application,Q.add(po);const qu={loader:$.LoadParser,resolver:$.ResolveParser,cache:$.CacheParser,detection:$.DetectionParser};Q.handle($.Asset,s=>{const t=s.ref;Object.entries(qu).filter(([e])=>!!t[e]).forEach(([e,i])=>Q.add(Object.assign(t[e],{extension:t[e].extension??i})))},s=>{const t=s.ref;Object.keys(qu).filter(e=>!!t[e]).forEach(e=>Q.remove(t[e]))});class Gm{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}function bi(s,t){if(Array.isArray(t)){for(const e of t)if(s.startsWith(`data:${e}`))return!0;return!1}return s.startsWith(`data:${t}`)}function Ve(s,t){const e=s.split("?")[0],i=Rt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const ee=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s),Bs=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s};function Ku(s,t,e,i,r){const n=t[e];for(let a=0;a<n.length;a++){const o=n[a];e<t.length-1?Ku(s.replace(i[e],o),t,e+1,i,r):r.push(s.replace(i[e],o))}}function Zu(s){const t=/\{(.*?)\}/g,e=s.match(t),i=[];if(e){const r=[];e.forEach(n=>{const a=n.substring(1,n.length-1).split(",");r.push(a)}),Ku(s,r,0,e,i)}else i.push(s);return i}const Pr=s=>!Array.isArray(s);class Vm{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||console.warn(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=ee(t);let r;for(let o=0;o<this.parsers.length;o++){const h=this.parsers[o];if(h.test(e)){r=h.getCacheableAssets(i,e);break}}r||(r={},i.forEach(o=>{r[o]=e}));const n=Object.keys(r),a={cacheKeys:n,keys:i};if(i.forEach(o=>{this._cacheMap.set(o,a)}),n.forEach(o=>{const h=r?r[o]:e;this._cache.has(o)&&this._cache.get(o)!==h&&console.warn("[Cache] already has key:",o),this._cache.set(o,r[o])}),e instanceof j){const o=e;i.forEach(h=>{o.baseTexture!==j.EMPTY.baseTexture&&lt.addToCache(o.baseTexture,h),j.addToCache(o,h)})}}remove(t){if(!this._cacheMap.has(t)){console.warn(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const ei=new Vm;class Hm{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var a,o;let r=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.load&&((a=l.test)!=null&&a.call(l,t,e,this))){n=l;break}}if(!n)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}r=await n.load(t,e,this),i.parser=n;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];l.parse&&l.parse&&await((o=l.testParse)==null?void 0:o.call(l,r,e,this))&&(r=await l.parse(r,e,this)||r,i.parser=l)}return r})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const r={},n=Pr(t),a=ee(t,l=>({alias:[l],src:l})),o=a.length,h=a.map(async l=>{const u=Rt.toAbsolute(l.src);if(!r[l.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,l)),r[l.src]=await this.promiseCache[u].promise,e&&e(++i/o)}catch(c){throw delete this.promiseCache[u],delete r[l.src],new Error(`[Loader.load] Failed to load ${u}.
867
+ ${c}`)}});return await Promise.all(h),n?r[a[0].src]:r}async unload(t){const e=ee(t,i=>({alias:[i],src:i})).map(async i=>{var a,o;const r=Rt.toAbsolute(i.src),n=this.promiseCache[r];if(n){const h=await n.promise;delete this.promiseCache[r],(o=(a=n.parser)==null?void 0:a.unload)==null||o.call(a,h,i,this)}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(t[e.name]&&console.warn(`[Assets] loadParser name conflict "${e.name}"`),{...t,[e.name]:e}),{})}}var ie=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(ie||{});const Xm=".json",zm="application/json",Ju={extension:{type:$.LoadParser,priority:ie.Low},name:"loadJson",test(s){return bi(s,zm)||Ve(s,Xm)},async load(s){return await(await q.ADAPTER.fetch(s)).json()}};Q.add(Ju);const Wm=".txt",$m="text/plain",Qu={name:"loadTxt",extension:{type:$.LoadParser,priority:ie.Low},test(s){return bi(s,$m)||Ve(s,Wm)},async load(s){return await(await q.ADAPTER.fetch(s)).text()}};Q.add(Qu);const jm=["normal","bold","100","200","300","400","500","600","700","800","900"],Ym=[".ttf",".otf",".woff",".woff2"],qm=["font/ttf","font/otf","font/woff","font/woff2"],Km=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function tc(s){const t=Rt.extname(s),e=Rt.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=e.length>0;for(const n of e)if(!n.match(Km)){i=!1;break}let r=e.join(" ");return i||(r=`"${r.replace(/[\\"]/g,"\\$&")}"`),r}const Zm=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Jm(s){return Zm.test(s)?s:encodeURI(s)}const ec={extension:{type:$.LoadParser,priority:ie.Low},name:"loadWebFont",test(s){return bi(s,qm)||Ve(s,Ym)},async load(s,t){var i,r,n;const e=q.ADAPTER.getFontFaceSet();if(e){const a=[],o=((i=t.data)==null?void 0:i.family)??tc(s),h=((n=(r=t.data)==null?void 0:r.weights)==null?void 0:n.filter(u=>jm.includes(u)))??["normal"],l=t.data??{};for(let u=0;u<h.length;u++){const c=h[u],d=new FontFace(o,`url(${Jm(s)})`,{...l,weight:c});await d.load(),e.add(d),a.push(d)}return a.length===1?a[0]:a}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(s){(Array.isArray(s)?s:[s]).forEach(t=>q.ADAPTER.getFontFaceSet().delete(t))}};Q.add(ec);const Qm=`(function() {
868
+ "use strict";
869
+ const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
870
+ async function checkImageBitmap() {
871
+ try {
872
+ if (typeof createImageBitmap != "function")
873
+ return !1;
874
+ const imageBlob = await (await fetch(WHITE_PNG)).blob(), imageBitmap = await createImageBitmap(imageBlob);
875
+ return imageBitmap.width === 1 && imageBitmap.height === 1;
876
+ } catch {
877
+ return !1;
878
+ }
879
+ }
880
+ checkImageBitmap().then((result) => {
881
+ self.postMessage(result);
882
+ });
883
+ })();
884
+ `;let Oi=null,mo=class{constructor(){Oi||(Oi=URL.createObjectURL(new Blob([Qm],{type:"application/javascript"}))),this.worker=new Worker(Oi)}};mo.revokeObjectURL=function(){Oi&&(URL.revokeObjectURL(Oi),Oi=null)};const tg=`(function() {
885
+ "use strict";
886
+ async function loadImageBitmap(url) {
887
+ const response = await fetch(url);
888
+ if (!response.ok)
889
+ throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`);
890
+ const imageBlob = await response.blob();
891
+ return await createImageBitmap(imageBlob);
892
+ }
893
+ self.onmessage = async (event) => {
894
+ try {
895
+ const imageBitmap = await loadImageBitmap(event.data.data[0]);
896
+ self.postMessage({
897
+ data: imageBitmap,
898
+ uuid: event.data.uuid,
899
+ id: event.data.id
900
+ }, [imageBitmap]);
901
+ } catch (e) {
902
+ self.postMessage({
903
+ error: e,
904
+ uuid: event.data.uuid,
905
+ id: event.data.id
906
+ });
907
+ }
908
+ };
909
+ })();
910
+ `;let ki=null;class ic{constructor(){ki||(ki=URL.createObjectURL(new Blob([tg],{type:"application/javascript"}))),this.worker=new Worker(ki)}}ic.revokeObjectURL=function(){ki&&(URL.revokeObjectURL(ki),ki=null)};let rc=0,go;class eg{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new mo;e.addEventListener("message",i=>{e.terminate(),mo.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){go===void 0&&(go=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<go&&(this._createdWorkers++,t=new ic().worker,t.addEventListener("message",e=>{this.complete(e.data),this.returnWorker(e.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((r,n)=>{this.queue.push({id:t,arguments:e,resolve:r,reject:n})});return this.next(),i}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),i=e.id;this.resolveHash[rc]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:rc++,id:i})}}const sc=new eg;function Ni(s,t,e){s.resource.internal=!0;const i=new j(s),r=()=>{delete t.promiseCache[e],ei.has(e)&&ei.remove(e)};return i.baseTexture.once("destroyed",()=>{e in t.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),r())}),i.once("destroyed",()=>{s.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),i}const ig=[".jpeg",".jpg",".png",".webp",".avif"],rg=["image/jpeg","image/png","image/webp","image/avif"];async function nc(s){const t=await q.ADAPTER.fetch(s);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const Mr={name:"loadTextures",extension:{type:$.LoadParser,priority:ie.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return bi(s,rg)||Ve(s,ig)},async load(s,t,e){var o;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let r;i?this.config.preferWorkers&&await sc.isImageBitmapSupported()?r=await sc.loadImageBitmap(s):r=await nc(s):r=await new Promise((h,l)=>{const u=new Image;u.crossOrigin=this.config.crossOrigin,u.src=s,u.complete?h(u):(u.onload=()=>h(u),u.onerror=c=>l(c))});const n={...t.data};n.resolution??(n.resolution=Ce(s)),i&&((o=n.resourceOptions)==null?void 0:o.ownsImageBitmap)===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const a=new lt(r,n);return a.resource.src=s,Ni(a,e,s)},unload(s){s.destroy(!0)}};Q.add(Mr);const sg=".svg",ng="image/svg+xml",ac={extension:{type:$.LoadParser,priority:ie.High},name:"loadSVG",test(s){return bi(s,ng)||Ve(s,sg)},async testParse(s){return Ms.test(s)},async parse(s,t,e){var n;const i=new Ms(s,(n=t==null?void 0:t.data)==null?void 0:n.resourceOptions);await i.load();const r=new lt(i,{resolution:Ce(s),...t==null?void 0:t.data});return r.resource.src=t.src,Ni(r,e,t.src)},async load(s,t){return(await q.ADAPTER.fetch(s)).text()},unload:Mr.unload};Q.add(ac);const ag=[".mp4",".m4v",".webm",".ogv"],og=["video/mp4","video/webm","video/ogg"],oc={name:"loadVideo",extension:{type:$.LoadParser,priority:ie.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(s){return bi(s,og)||Ve(s,ag)},async load(s,t,e){var a;let i;const r=await(await q.ADAPTER.fetch(s)).blob(),n=URL.createObjectURL(r);try{const o={autoPlay:this.config.defaultAutoPlay,updateFPS:this.config.defaultUpdateFPS,loop:this.config.defaultLoop,muted:this.config.defaultMuted,playsinline:this.config.defaultPlaysinline,...(a=t==null?void 0:t.data)==null?void 0:a.resourceOptions,autoLoad:!0},h=new ao(n,o);await h.load();const l=new lt(h,{alphaMode:await vl(),resolution:Ce(s),...t==null?void 0:t.data});l.resource.src=s,i=Ni(l,e,s),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(o){throw URL.revokeObjectURL(n),o}return i},unload(s){s.destroy(!0)}};Q.add(oc);class hg{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,name:i,src:r,srcs:n}=t;return ee(e||i||r||n,a=>typeof a=="string"?a:Array.isArray(a)?a.map(o=>(o==null?void 0:o.src)??(o==null?void 0:o.srcs)??o):a!=null&&a.src||a!=null&&a.srcs?a.src??a.srcs:a,!0)}addManifest(t){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];Array.isArray(e)?e.forEach(r=>{const n=r.src??r.srcs,a=r.alias??r.name;let o;if(typeof a=="string"){const h=this._createBundleAssetId(t,a);i.push(h),o=[a,h]}else{const h=a.map(l=>this._createBundleAssetId(t,l));i.push(...h),o=[...a,...h]}this.add({...r,alias:o,src:n})}):Object.keys(e).forEach(r=>{const n=[r,this._createBundleAssetId(t,r)];if(typeof e[r]=="string")this.add({alias:n,src:e[r]});else if(Array.isArray(e[r]))this.add({alias:n,src:e[r]});else{const a=e[r],o=a.src??a.srcs;this.add({...a,alias:n,src:Array.isArray(o)?o:[o]})}i.push(...n)}),this._bundles[t]=i}add(t,e,i,r,n){const a=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(ot("7.2.0",`Assets.add now uses an object instead of individual parameters.
911
+ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),a.push({alias:t,src:e,data:i,format:r,loadParser:n})):Array.isArray(t)?a.push(...t):a.push(t);let o;o=h=>{this.hasKey(h)&&console.warn(`[Resolver] already has key: ${h} overwriting`)},ee(a).forEach(h=>{const{src:l,srcs:u}=h;let{data:c,format:d,loadParser:f}=h;const p=ee(l||u).map(_=>typeof _=="string"?Zu(_):Array.isArray(_)?_:[_]),g=this.getAlias(h);Array.isArray(g)?g.forEach(o):o(g);const m=[];p.forEach(_=>{_.forEach(b=>{let y={};if(typeof b!="object"){y.src=b;for(let E=0;E<this._parsers.length;E++){const v=this._parsers[E];if(v.test(b)){y=v.parse(b);break}}}else c=b.data??c,d=b.format??d,f=b.loadParser??f,y={...y,...b};if(!g)throw new Error(`[Resolver] alias is undefined for this asset: ${y.src}`);y=this.buildResolvedAsset(y,{aliases:g,data:c,format:d,loadParser:f}),m.push(y)})}),g.forEach(_=>{this._assetMap[_]=m})})}resolveBundle(t){const e=Pr(t);t=ee(t);const i={};return t.forEach(r=>{const n=this._bundles[r];if(n){const a=this.resolve(n),o={};for(const h in a){const l=a[h];o[this._extractAssetIdFromBundle(r,h)]=l}i[r]=o}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const r in e)i[r]=e[r].src;return i}return e.src}resolve(t){const e=Pr(t);t=ee(t);const i={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const a=n[0],o=this._getPreferredOrder(n);o==null||o.priority.forEach(h=>{o.params[h].forEach(l=>{const u=n.filter(c=>c[h]?c[h]===l:!1);u.length&&(n=u)})}),this._resolverHash[r]=n[0]??a}else this._resolverHash[r]=this.buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],r=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}buildResolvedAsset(t,e){const{aliases:i,data:r,loadParser:n,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=Rt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...r||{},...t.data},t.loadParser=n??t.loadParser,t.format=a??t.format??Rt.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class hc{constructor(){this._detections=[],this._initialized=!1,this.resolver=new hg,this.loader=new Hm,this.cache=ei,this._backgroundLoader=new Gm(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,a;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let o=t.manifest;typeof o=="string"&&(o=await this.load(o)),this.resolver.addManifest(o)}const e=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,r=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:r,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,i,r,n){this.resolver.add(t,e,i,r,n)}async load(t,e){this._initialized||await this.init();const i=Pr(t),r=ee(t).map(o=>{if(typeof o!="string"){const h=this.resolver.getAlias(o);return h.some(l=>!this.resolver.hasKey(l))&&this.add(o),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),n=this.resolver.resolve(r),a=await this._mapLoadToResolve(n,e);return i?a[r[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const r=this.resolver.resolveBundle(t),n={},a=Object.keys(r);let o=0,h=0;const l=()=>{e==null||e(++o/h)},u=a.map(c=>{const d=r[c];return h+=Object.keys(d).length,this._mapLoadToResolve(d,l).then(f=>{n[c]=f})});return await Promise.all(u),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return ei.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=ei.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=Object.values(t),r=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const a={};return i.forEach((o,h)=>{const l=n[o.src],u=[o.src];o.alias&&u.push(...o.alias),a[r[h]]=l,ei.set(u,l)}),a}async unload(t){this._initialized||await this.init();const e=ee(t).map(r=>typeof r!="string"?r.src:r),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=ee(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{ei.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,r)=>e.indexOf(i)===r),e}get detections(){return this._detections}get preferWorkers(){return Mr.config.preferWorkers}set preferWorkers(t){ot("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:t})}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const Ir=new hc;Q.handleByList($.LoadParser,Ir.loader.parsers).handleByList($.ResolveParser,Ir.resolver.parsers).handleByList($.CacheParser,Ir.cache.parsers).handleByList($.DetectionParser,Ir.detections);const lc={extension:$.CacheParser,test:s=>Array.isArray(s)&&s.every(t=>t instanceof j),getCacheableAssets:(s,t)=>{const e={};return s.forEach(i=>{t.forEach((r,n)=>{e[i+(n===0?"":n+1)]=r})}),e}};Q.add(lc);async function uc(s){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const cc={extension:{type:$.DetectionParser,priority:1},test:async()=>uc("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")};Q.add(cc);const dc={extension:{type:$.DetectionParser,priority:0},test:async()=>uc("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")};Q.add(dc);const fc=["png","jpg","jpeg"],pc={extension:{type:$.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...fc],remove:async s=>s.filter(t=>!fc.includes(t))};Q.add(pc);const lg="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function _o(s){return lg?!1:document.createElement("video").canPlayType(s)!==""}const mc={extension:{type:$.DetectionParser,priority:0},test:async()=>_o("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")};Q.add(mc);const gc={extension:{type:$.DetectionParser,priority:0},test:async()=>_o("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")};Q.add(gc);const _c={extension:{type:$.DetectionParser,priority:0},test:async()=>_o("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")};Q.add(_c);const yc={extension:$.ResolveParser,test:Mr.test,parse:s=>{var t;return{resolution:parseFloat(((t=q.RETINA_PREFIX.exec(s))==null?void 0:t[1])??"1"),format:Rt.extname(s).slice(1),src:s}}};Q.add(yc);var Lt=(s=>(s[s.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",s[s.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",s[s.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",s[s.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",s[s.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",s[s.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",s[s.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",s[s.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",s[s.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",s[s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",s[s.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",s[s.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",s[s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",s[s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",s[s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",s[s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",s[s.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",s[s.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",s[s.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35987]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",s[s.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",s[s.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",s[s.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",s[s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",s[s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",s[s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",s))(Lt||{});const Rr={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35987:1,34798:1,37808:1,36492:1,36493:1,36494:1,36495:1};let Me,Ui;function vc(){Ui={bptc:Me.getExtension("EXT_texture_compression_bptc"),astc:Me.getExtension("WEBGL_compressed_texture_astc"),etc:Me.getExtension("WEBGL_compressed_texture_etc"),s3tc:Me.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Me.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:Me.getExtension("WEBGL_compressed_texture_pvrtc")||Me.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:Me.getExtension("WEBGL_compressed_texture_etc1"),atc:Me.getExtension("WEBGL_compressed_texture_atc")}}const xc={extension:{type:$.DetectionParser,priority:2},test:async()=>{const s=q.ADAPTER.createCanvas().getContext("webgl");return s?(Me=s,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async s=>{Ui||vc();const t=[];for(const e in Ui)Ui[e]&&t.push(e);return[...t,...s]},remove:async s=>(Ui||vc(),s.filter(t=>!(t in Ui)))};Q.add(xc);class bc extends ur{constructor(t,e={width:1,height:1,autoLoad:!0}){let i,r;typeof t=="string"?(i=t,r=new Uint8Array):(i=null,r=t),super(r,e),this.origin=i,this.buffer=r?new us(r):null,this._load=null,this.loaded=!1,this.origin!==null&&e.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(t=>t.blob()).then(t=>t.arrayBuffer()).then(t=>(this.data=new Uint32Array(t),this.buffer=new us(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class ii extends bc{constructor(t,e){super(t,e),this.format=e.format,this.levels=e.levels||1,this._width=e.width,this._height=e.height,this._extension=ii._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||ii._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){const r=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;r.pixelStorei(r.UNPACK_ALIGNMENT,4);for(let n=0,a=this.levels;n<a;n++){const{levelID:o,levelWidth:h,levelHeight:l,levelBuffer:u}=this._levelBuffers[n];r.compressedTexImage2D(r.TEXTURE_2D,o,this.format,h,l,0,u)}return!0}onBlobLoaded(){this._levelBuffers=ii._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,e,i,r,n,a,o){const h=new Array(i);let l=t.byteOffset,u=a,c=o,d=u+r-1&~(r-1),f=c+n-1&~(n-1),p=d*f*Rr[e];for(let g=0;g<i;g++)h[g]={levelID:g,levelWidth:i>1?u:d,levelHeight:i>1?c:f,levelBuffer:new Uint8Array(t.buffer,l,p)},l+=p,u=u>>1||1,c=c>>1||1,d=u+r-1&~(r-1),f=c+n-1&~(n-1),p=d*f*Rr[e];return h}}const yo=4,Ls=124,ug=32,Tc=20,cg=542327876,Os={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},dg={FOURCC:2},ks={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},fg=1,pg=2,mg=4,gg=64,_g=512,yg=131072,vg=827611204,xg=861165636,bg=894720068,Tg=808540228,Eg=4,wg={[vg]:Lt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[xg]:Lt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[bg]:Lt.COMPRESSED_RGBA_S3TC_DXT5_EXT},Cg={70:Lt.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Lt.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Lt.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Lt.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Lt.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Lt.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Lt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Lt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Lt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:Lt.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:Lt.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:Lt.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:Lt.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function Ec(s){const t=new Uint32Array(s);if(t[0]!==cg)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(s,0,Ls/Uint32Array.BYTES_PER_ELEMENT),i=e[Os.HEIGHT],r=e[Os.WIDTH],n=e[Os.MIPMAP_COUNT],a=new Uint32Array(s,Os.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,ug/Uint32Array.BYTES_PER_ELEMENT),o=a[fg];if(o&mg){const h=a[dg.FOURCC];if(h!==Tg){const b=wg[h],y=yo+Ls,E=new Uint8Array(s,y);return[new ii(E,{format:b,width:r,height:i,levels:n})]}const l=yo+Ls,u=new Uint32Array(t.buffer,l,Tc/Uint32Array.BYTES_PER_ELEMENT),c=u[ks.DXGI_FORMAT],d=u[ks.RESOURCE_DIMENSION],f=u[ks.MISC_FLAG],p=u[ks.ARRAY_SIZE],g=Cg[c];if(g===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(f===Eg)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const m=new Array,_=yo+Ls+Tc;if(p===1)m.push(new Uint8Array(s,_));else{const b=Rr[g];let y=0,E=r,v=i;for(let T=0;T<n;T++){const P=Math.max(1,E+3&-4),N=Math.max(1,v+3&-4),G=P*N*b;y+=G,E=E>>>1,v=v>>>1}let M=_;for(let T=0;T<p;T++)m.push(new Uint8Array(s,M,y)),M+=y}return m.map(b=>new ii(b,{format:g,width:r,height:i,levels:n}))}throw o&gg?new Error("DDSParser does not support uncompressed texture data."):o&_g?new Error("DDSParser does not supported YUV uncompressed texture data."):o&yg?new Error("DDSParser does not support single-channel (lumninance) texture data!"):o&pg?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const wc=[171,75,84,88,32,49,49,187,13,10,26,10],Ag=67305985,ge={ENDIANNESS:12,GL_TYPE:16,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},vo=64,xo={[it.UNSIGNED_BYTE]:1,[it.UNSIGNED_SHORT]:2,[it.INT]:4,[it.UNSIGNED_INT]:4,[it.FLOAT]:4,[it.HALF_FLOAT]:8},Cc={[H.RGBA]:4,[H.RGB]:3,[H.RG]:2,[H.RED]:1,[H.LUMINANCE]:1,[H.LUMINANCE_ALPHA]:2,[H.ALPHA]:1},Ac={[it.UNSIGNED_SHORT_4_4_4_4]:2,[it.UNSIGNED_SHORT_5_5_5_1]:2,[it.UNSIGNED_SHORT_5_6_5]:2};function Sc(s,t,e=!1){const i=new DataView(t);if(!Sg(s,i))return null;const r=i.getUint32(ge.ENDIANNESS,!0)===Ag,n=i.getUint32(ge.GL_TYPE,r),a=i.getUint32(ge.GL_FORMAT,r),o=i.getUint32(ge.GL_INTERNAL_FORMAT,r),h=i.getUint32(ge.PIXEL_WIDTH,r),l=i.getUint32(ge.PIXEL_HEIGHT,r)||1,u=i.getUint32(ge.PIXEL_DEPTH,r)||1,c=i.getUint32(ge.NUMBER_OF_ARRAY_ELEMENTS,r)||1,d=i.getUint32(ge.NUMBER_OF_FACES,r),f=i.getUint32(ge.NUMBER_OF_MIPMAP_LEVELS,r),p=i.getUint32(ge.BYTES_OF_KEY_VALUE_DATA,r);if(l===0||u!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(c!==1)throw new Error("WebGL does not support array textures");const g=4,m=4,_=h+3&-4,b=l+3&-4,y=new Array(c);let E=h*l;n===0&&(E=_*b);let v;if(n!==0?xo[n]?v=xo[n]*Cc[a]:v=Ac[n]:v=Rr[o],v===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const M=e?Mg(i,p,r):null;let T=E*v,P=h,N=l,G=_,z=b,D=vo+p;for(let O=0;O<f;O++){const V=i.getUint32(D,r);let W=D+4;for(let w=0;w<c;w++){let C=y[w];C||(C=y[w]=new Array(f)),C[O]={levelID:O,levelWidth:f>1||n!==0?P:G,levelHeight:f>1||n!==0?N:z,levelBuffer:new Uint8Array(t,W,T)},W+=T}D+=V+4,D=D%4!==0?D+4-D%4:D,P=P>>1||1,N=N>>1||1,G=P+g-1&-4,z=N+m-1&-4,T=G*z*v}return n!==0?{uncompressed:y.map(O=>{let V=O[0].levelBuffer,W=!1;return n===it.FLOAT?V=new Float32Array(O[0].levelBuffer.buffer,O[0].levelBuffer.byteOffset,O[0].levelBuffer.byteLength/4):n===it.UNSIGNED_INT?(W=!0,V=new Uint32Array(O[0].levelBuffer.buffer,O[0].levelBuffer.byteOffset,O[0].levelBuffer.byteLength/4)):n===it.INT&&(W=!0,V=new Int32Array(O[0].levelBuffer.buffer,O[0].levelBuffer.byteOffset,O[0].levelBuffer.byteLength/4)),{resource:new ur(V,{width:O[0].levelWidth,height:O[0].levelHeight}),type:n,format:W?Pg(a):a}}),kvData:M}:{compressed:y.map(O=>new ii(null,{format:o,width:h,height:l,levels:f,levelBuffers:O})),kvData:M}}function Sg(s,t){for(let e=0;e<wc.length;e++)if(t.getUint8(e)!==wc[e])return console.error(`${s} is not a valid *.ktx file!`),!1;return!0}function Pg(s){switch(s){case H.RGBA:return H.RGBA_INTEGER;case H.RGB:return H.RGB_INTEGER;case H.RG:return H.RG_INTEGER;case H.RED:return H.RED_INTEGER;default:return s}}function Mg(s,t,e){const i=new Map;let r=0;for(;r<t;){const n=s.getUint32(vo+r,e),a=vo+r+4,o=3-(n+3)%4;if(n===0||n>t-r){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let h=0;for(;h<n&&s.getUint8(a+h)!==0;h++);if(h===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const l=new TextDecoder().decode(new Uint8Array(s.buffer,a,h)),u=new DataView(s.buffer,a+h+1,n-h-1);i.set(l,u),r+=4+n+o}return i}const Pc={extension:{type:$.LoadParser,priority:ie.High},name:"loadDDS",test(s){return Ve(s,".dds")},async load(s,t,e){const i=await(await q.ADAPTER.fetch(s)).arrayBuffer(),r=Ec(i).map(n=>{const a=new lt(n,{mipmap:he.OFF,alphaMode:Nt.NO_PREMULTIPLIED_ALPHA,resolution:Ce(s),...t.data});return Ni(a,e,s)});return r.length===1?r[0]:r},unload(s){Array.isArray(s)?s.forEach(t=>t.destroy(!0)):s.destroy(!0)}};Q.add(Pc);const Mc={extension:{type:$.LoadParser,priority:ie.High},name:"loadKTX",test(s){return Ve(s,".ktx")},async load(s,t,e){const i=await(await q.ADAPTER.fetch(s)).arrayBuffer(),{compressed:r,uncompressed:n,kvData:a}=Sc(s,i),o=r??n,h={mipmap:he.OFF,alphaMode:Nt.NO_PREMULTIPLIED_ALPHA,resolution:Ce(s),...t.data},l=o.map(u=>{o===n&&Object.assign(h,{type:u.type,format:u.format});const c=u.resource??u,d=new lt(c,h);return d.ktxKeyValueData=a,Ni(d,e,s)});return l.length===1?l[0]:l},unload(s){Array.isArray(s)?s.forEach(t=>t.destroy(!0)):s.destroy(!0)}};Q.add(Mc);const Ig=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],Ic={extension:$.ResolveParser,test:s=>{const t=Rt.extname(s).slice(1);return["basis","ktx","dds"].includes(t)},parse:s=>{var i,r;const t=s.split("."),e=t.pop();if(["ktx","dds"].includes(e)){const n=t.pop();if(Ig.includes(n))return{resolution:parseFloat(((i=q.RETINA_PREFIX.exec(s))==null?void 0:i[1])??"1"),format:n,src:s}}return{resolution:parseFloat(((r=q.RETINA_PREFIX.exec(s))==null?void 0:r[1])??"1"),format:e,src:s}}};Q.add(Ic);const Ns=new ut,Rg=4,Rc=class ts{constructor(t){this.renderer=t,this._rendererPremultipliedAlpha=!1}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(t,e,i,r){const n=new Image;return n.src=await this.base64(t,e,i,r),n}async base64(t,e,i,r){const n=this.canvas(t,r);if(n.toBlob!==void 0)return new Promise((a,o)=>{n.toBlob(h=>{if(!h){o(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>a(l.result),l.onerror=o,l.readAsDataURL(h)},e,i)});if(n.toDataURL!==void 0)return n.toDataURL(e,i);if(n.convertToBlob!==void 0){const a=await n.convertToBlob({type:e,quality:i});return new Promise((o,h)=>{const l=new FileReader;l.onload=()=>o(l.result),l.onerror=h,l.readAsDataURL(a)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const{pixels:i,width:r,height:n,flipY:a,premultipliedAlpha:o}=this._rawPixels(t,e);a&&ts._flipY(i,r,n),o&&ts._unpremultiplyAlpha(i);const h=new Ll(r,n,1),l=new ImageData(new Uint8ClampedArray(i.buffer),r,n);return h.context.putImageData(l,0,0),h.canvas}pixels(t,e){const{pixels:i,width:r,height:n,flipY:a,premultipliedAlpha:o}=this._rawPixels(t,e);return a&&ts._flipY(i,r,n),o&&ts._unpremultiplyAlpha(i),i}_rawPixels(t,e){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let r,n=!1,a=!1,o,h=!1;t&&(t instanceof Je?o=t:(o=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),h=!0,e&&(Ns.width=e.width,Ns.height=e.height,e=Ns)));const l=i.gl;if(o){if(r=o.baseTexture.resolution,e=e??o.frame,n=!1,a=o.baseTexture.alphaMode>0&&o.baseTexture.format===H.RGBA,!h){i.renderTexture.bind(o);const f=o.framebuffer.glFramebuffers[i.CONTEXT_UID];f.blitFramebuffer&&i.framebuffer.bind(f.blitFramebuffer)}}else r=i.resolution,e||(e=Ns,e.width=i.width/r,e.height=i.height/r),n=!0,a=this._rendererPremultipliedAlpha,i.renderTexture.bind();const u=Math.max(Math.round(e.width*r),1),c=Math.max(Math.round(e.height*r),1),d=new Uint8Array(Rg*u*c);return l.readPixels(Math.round(e.x*r),Math.round(e.y*r),u,c,l.RGBA,l.UNSIGNED_BYTE,d),h&&(o==null||o.destroy(!0)),{pixels:d,width:u,height:c,flipY:n,premultipliedAlpha:a}}destroy(){this.renderer=null}static _flipY(t,e,i){const r=e<<2,n=i>>1,a=new Uint8Array(r);for(let o=0;o<n;o++){const h=o*r,l=(i-o-1)*r;a.set(t.subarray(h,h+r)),t.copyWithin(h,l,l+r),t.set(a,l)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const e=t.length;for(let i=0;i<e;i+=4){const r=t[i+3];if(r!==0){const n=255.001/r;t[i]=t[i]*n+.5,t[i+1]=t[i+1]*n+.5,t[i+2]=t[i+2]*n+.5}}}};Rc.extension={name:"extract",type:$.RendererSystem};let Dc=Rc;Q.add(Dc);const Dr={build(s){const t=s.points;let e,i,r,n,a,o;if(s.type===Bt.CIRC){const p=s.shape;e=p.x,i=p.y,a=o=p.radius,r=n=0}else if(s.type===Bt.ELIP){const p=s.shape;e=p.x,i=p.y,a=p.width,o=p.height,r=n=0}else{const p=s.shape,g=p.width/2,m=p.height/2;e=p.x+g,i=p.y+m,a=o=Math.max(0,Math.min(p.radius,Math.min(g,m))),r=g-a,n=m-o}if(!(a>=0&&o>=0&&r>=0&&n>=0)){t.length=0;return}const h=Math.ceil(2.3*Math.sqrt(a+o)),l=h*8+(r?4:0)+(n?4:0);if(t.length=l,l===0)return;if(h===0){t.length=8,t[0]=t[6]=e+r,t[1]=t[3]=i+n,t[2]=t[4]=e-r,t[5]=t[7]=i-n;return}let u=0,c=h*4+(r?2:0)+2,d=c,f=l;{const p=r+a,g=n,m=e+p,_=e-p,b=i+g;if(t[u++]=m,t[u++]=b,t[--c]=b,t[--c]=_,n){const y=i-g;t[d++]=_,t[d++]=y,t[--f]=y,t[--f]=m}}for(let p=1;p<h;p++){const g=Math.PI/2*(p/h),m=r+Math.cos(g)*a,_=n+Math.sin(g)*o,b=e+m,y=e-m,E=i+_,v=i-_;t[u++]=b,t[u++]=E,t[--c]=E,t[--c]=y,t[d++]=y,t[d++]=v,t[--f]=v,t[--f]=b}{const p=r,g=n+o,m=e+p,_=e-p,b=i+g,y=i-g;t[u++]=m,t[u++]=b,t[--f]=y,t[--f]=m,r&&(t[u++]=_,t[u++]=b,t[--f]=y,t[--f]=_)}},triangulate(s,t){const e=s.points,i=t.points,r=t.indices;if(e.length===0)return;let n=i.length/2;const a=n;let o,h;if(s.type!==Bt.RREC){const u=s.shape;o=u.x,h=u.y}else{const u=s.shape;o=u.x+u.width/2,h=u.y+u.height/2}const l=s.matrix;i.push(s.matrix?l.a*o+l.c*h+l.tx:o,s.matrix?l.b*o+l.d*h+l.ty:h),n++,i.push(e[0],e[1]);for(let u=2;u<e.length;u+=2)i.push(e[u],e[u+1]),r.push(n++,a,n);r.push(a+1,a,n)}};function Fc(s,t=!1){const e=s.length;if(e<6)return;let i=0;for(let r=0,n=s[e-2],a=s[e-1];r<e;r+=2){const o=s[r],h=s[r+1];i+=(o-n)*(h+a),n=o,a=h}if(!t&&i>0||t&&i<=0){const r=e/2;for(let n=r+r%2;n<e;n+=2){const a=e-n-2,o=e-n-1,h=n,l=n+1;[s[a],s[h]]=[s[h],s[a]],[s[o],s[l]]=[s[l],s[o]]}}}const bo={build(s){s.points=s.shape.points.slice()},triangulate(s,t){let e=s.points;const i=s.holes,r=t.points,n=t.indices;if(e.length>=6){Fc(e,!1);const a=[];for(let l=0;l<i.length;l++){const u=i[l];Fc(u.points,!0),a.push(e.length/2),e=e.concat(u.points)}const o=Nh(e,a,2);if(!o)return;const h=r.length/2;for(let l=0;l<o.length;l+=3)n.push(o[l]+h),n.push(o[l+1]+h),n.push(o[l+2]+h);for(let l=0;l<e.length;l++)r.push(e[l])}}},Bc={build(s){const t=s.shape,e=t.x,i=t.y,r=t.width,n=t.height,a=s.points;a.length=0,r>=0&&n>=0&&a.push(e,i,e+r,i,e+r,i+n,e,i+n)},triangulate(s,t){const e=s.points,i=t.points;if(e.length===0)return;const r=i.length/2;i.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(r,r+1,r+2,r+1,r+2,r+3)}},Lc={build(s){Dr.build(s)},triangulate(s,t){Dr.triangulate(s,t)}};var $t=(s=>(s.MITER="miter",s.BEVEL="bevel",s.ROUND="round",s))($t||{}),He=(s=>(s.BUTT="butt",s.ROUND="round",s.SQUARE="square",s))(He||{});const ri={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(s,t=20){if(!this.adaptive||!s||isNaN(s))return t;let e=Math.ceil(s/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}},Dg=ri;class To{static curveTo(t,e,i,r,n,a){const o=a[a.length-2],h=a[a.length-1]-e,l=o-t,u=r-e,c=i-t,d=Math.abs(h*c-l*u);if(d<1e-8||n===0)return(a[a.length-2]!==t||a[a.length-1]!==e)&&a.push(t,e),null;const f=h*h+l*l,p=u*u+c*c,g=h*u+l*c,m=n*Math.sqrt(f)/d,_=n*Math.sqrt(p)/d,b=m*g/f,y=_*g/p,E=m*c+_*l,v=m*u+_*h,M=l*(_+b),T=h*(_+b),P=c*(m+y),N=u*(m+y),G=Math.atan2(T-v,M-E),z=Math.atan2(N-v,P-E);return{cx:E+t,cy:v+e,radius:n,startAngle:G,endAngle:z,anticlockwise:l*u>c*h}}static arc(t,e,i,r,n,a,o,h,l){const u=o-a,c=ri._segmentsCount(Math.abs(u)*n,Math.ceil(Math.abs(u)/dr)*40),d=u/(c*2),f=d*2,p=Math.cos(d),g=Math.sin(d),m=c-1,_=m%1/m;for(let b=0;b<=m;++b){const y=b+_*b,E=d+a+f*y,v=Math.cos(E),M=-Math.sin(E);l.push((p*v+g*M)*n+i,(p*-M+g*v)*n+r)}}}class Oc{constructor(){this.reset()}begin(t,e,i){this.reset(),this.style=t,this.start=e,this.attribStart=i}end(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class Us{static curveLength(t,e,i,r,n,a,o,h){let l=0,u=0,c=0,d=0,f=0,p=0,g=0,m=0,_=0,b=0,y=0,E=t,v=e;for(let M=1;M<=10;++M)u=M/10,c=u*u,d=c*u,f=1-u,p=f*f,g=p*f,m=g*t+3*p*u*i+3*f*c*n+d*o,_=g*e+3*p*u*r+3*f*c*a+d*h,b=E-m,y=v-_,E=m,v=_,l+=Math.sqrt(b*b+y*y);return l}static curveTo(t,e,i,r,n,a,o){const h=o[o.length-2],l=o[o.length-1];o.length-=2;const u=ri._segmentsCount(Us.curveLength(h,l,t,e,i,r,n,a));let c=0,d=0,f=0,p=0,g=0;o.push(h,l);for(let m=1,_=0;m<=u;++m)_=m/u,c=1-_,d=c*c,f=d*c,p=_*_,g=p*_,o.push(f*h+3*d*_*t+3*c*p*i+g*n,f*l+3*d*_*e+3*c*p*r+g*a)}}function kc(s,t,e,i,r,n,a,o){const h=s-e*r,l=t-i*r,u=s+e*n,c=t+i*n;let d,f;a?(d=i,f=-e):(d=-i,f=e);const p=h+d,g=l+f,m=u+d,_=c+f;return o.push(p,g,m,_),2}function Ti(s,t,e,i,r,n,a,o){const h=e-s,l=i-t;let u=Math.atan2(h,l),c=Math.atan2(r-s,n-t);o&&u<c?u+=Math.PI*2:!o&&u>c&&(c+=Math.PI*2);let d=u;const f=c-u,p=Math.abs(f),g=Math.sqrt(h*h+l*l),m=(15*p*Math.sqrt(g)/Math.PI>>0)+1,_=f/m;if(d+=_,o){a.push(s,t,e,i);for(let b=1,y=d;b<m;b++,y+=_)a.push(s,t,s+Math.sin(y)*g,t+Math.cos(y)*g);a.push(s,t,r,n)}else{a.push(e,i,s,t);for(let b=1,y=d;b<m;b++,y+=_)a.push(s+Math.sin(y)*g,t+Math.cos(y)*g,s,t);a.push(r,n,s,t)}return m*2}function Fg(s,t){const e=s.shape;let i=s.points||e.points.slice();const r=t.closePointEps;if(i.length===0)return;const n=s.lineStyle,a=new ft(i[0],i[1]),o=new ft(i[i.length-2],i[i.length-1]),h=e.type!==Bt.POLY||e.closeStroke,l=Math.abs(a.x-o.x)<r&&Math.abs(a.y-o.y)<r;if(h){i=i.slice(),l&&(i.pop(),i.pop(),o.set(i[i.length-2],i[i.length-1]));const C=(a.x+o.x)*.5,x=(o.y+a.y)*.5;i.unshift(C,x),i.push(C,x)}const u=t.points,c=i.length/2;let d=i.length;const f=u.length/2,p=n.width/2,g=p*p,m=n.miterLimit*n.miterLimit;let _=i[0],b=i[1],y=i[2],E=i[3],v=0,M=0,T=-(b-E),P=_-y,N=0,G=0,z=Math.sqrt(T*T+P*P);T/=z,P/=z,T*=p,P*=p;const D=n.alignment,O=(1-D)*2,V=D*2;h||(n.cap===He.ROUND?d+=Ti(_-T*(O-V)*.5,b-P*(O-V)*.5,_-T*O,b-P*O,_+T*V,b+P*V,u,!0)+2:n.cap===He.SQUARE&&(d+=kc(_,b,T,P,O,V,!0,u))),u.push(_-T*O,b-P*O,_+T*V,b+P*V);for(let C=1;C<c-1;++C){_=i[(C-1)*2],b=i[(C-1)*2+1],y=i[C*2],E=i[C*2+1],v=i[(C+1)*2],M=i[(C+1)*2+1],T=-(b-E),P=_-y,z=Math.sqrt(T*T+P*P),T/=z,P/=z,T*=p,P*=p,N=-(E-M),G=y-v,z=Math.sqrt(N*N+G*G),N/=z,G/=z,N*=p,G*=p;const x=y-_,R=b-E,A=y-v,S=M-E,F=x*A+R*S,L=R*A-S*x,U=L<0;if(Math.abs(L)<.001*Math.abs(F)){u.push(y-T*O,E-P*O,y+T*V,E+P*V),F>=0&&(n.join===$t.ROUND?d+=Ti(y,E,y-T*O,E-P*O,y-N*O,E-G*O,u,!1)+4:d+=2,u.push(y-N*V,E-G*V,y+N*O,E+G*O));continue}const X=(-T+_)*(-P+E)-(-T+y)*(-P+b),J=(-N+v)*(-G+E)-(-N+y)*(-G+M),Z=(x*J-A*X)/L,tt=(S*X-R*J)/L,st=(Z-y)*(Z-y)+(tt-E)*(tt-E),K=y+(Z-y)*O,ht=E+(tt-E)*O,dt=y-(Z-y)*V,bt=E-(tt-E)*V,_t=Math.min(x*x+R*R,A*A+S*S),rt=U?O:V,ct=_t+rt*rt*g,Ye=st<=ct;let oi=n.join;if(oi===$t.MITER&&st/g>m&&(oi=$t.BEVEL),Ye)switch(oi){case $t.MITER:{u.push(K,ht,dt,bt);break}case $t.BEVEL:{U?u.push(K,ht,y+T*V,E+P*V,K,ht,y+N*V,E+G*V):u.push(y-T*O,E-P*O,dt,bt,y-N*O,E-G*O,dt,bt),d+=2;break}case $t.ROUND:{U?(u.push(K,ht,y+T*V,E+P*V),d+=Ti(y,E,y+T*V,E+P*V,y+N*V,E+G*V,u,!0)+4,u.push(K,ht,y+N*V,E+G*V)):(u.push(y-T*O,E-P*O,dt,bt),d+=Ti(y,E,y-T*O,E-P*O,y-N*O,E-G*O,u,!1)+4,u.push(y-N*O,E-G*O,dt,bt));break}}else{switch(u.push(y-T*O,E-P*O,y+T*V,E+P*V),oi){case $t.MITER:{U?u.push(dt,bt,dt,bt):u.push(K,ht,K,ht),d+=2;break}case $t.ROUND:{U?d+=Ti(y,E,y+T*V,E+P*V,y+N*V,E+G*V,u,!0)+2:d+=Ti(y,E,y-T*O,E-P*O,y-N*O,E-G*O,u,!1)+2;break}}u.push(y-N*O,E-G*O,y+N*V,E+G*V),d+=2}}_=i[(c-2)*2],b=i[(c-2)*2+1],y=i[(c-1)*2],E=i[(c-1)*2+1],T=-(b-E),P=_-y,z=Math.sqrt(T*T+P*P),T/=z,P/=z,T*=p,P*=p,u.push(y-T*O,E-P*O,y+T*V,E+P*V),h||(n.cap===He.ROUND?d+=Ti(y-T*(O-V)*.5,E-P*(O-V)*.5,y-T*O,E-P*O,y+T*V,E+P*V,u,!1)+2:n.cap===He.SQUARE&&(d+=kc(y,E,T,P,O,V,!1,u)));const W=t.indices,w=ri.epsilon*ri.epsilon;for(let C=f;C<d+f-2;++C)_=u[C*2],b=u[C*2+1],y=u[(C+1)*2],E=u[(C+1)*2+1],v=u[(C+2)*2],M=u[(C+2)*2+1],!(Math.abs(_*(E-M)+y*(M-b)+v*(b-E))<w)&&W.push(C,C+1,C+2)}function Bg(s,t){let e=0;const i=s.shape,r=s.points||i.points,n=i.type!==Bt.POLY||i.closeStroke;if(r.length===0)return;const a=t.points,o=t.indices,h=r.length/2,l=a.length/2;let u=l;for(a.push(r[0],r[1]),e=1;e<h;e++)a.push(r[e*2],r[e*2+1]),o.push(u,u+1),u++;n&&o.push(u,l)}function Eo(s,t){s.lineStyle.native?Bg(s,t):Fg(s,t)}class Gs{static curveLength(t,e,i,r,n,a){const o=t-2*i+n,h=e-2*r+a,l=2*i-2*t,u=2*r-2*e,c=4*(o*o+h*h),d=4*(o*l+h*u),f=l*l+u*u,p=2*Math.sqrt(c+d+f),g=Math.sqrt(c),m=2*c*g,_=2*Math.sqrt(f),b=d/g;return(m*p+g*d*(p-_)+(4*f*c-d*d)*Math.log((2*g+b+p)/(b+_)))/(4*m)}static curveTo(t,e,i,r,n){const a=n[n.length-2],o=n[n.length-1],h=ri._segmentsCount(Gs.curveLength(a,o,t,e,i,r));let l=0,u=0;for(let c=1;c<=h;++c){const d=c/h;l=a+(t-a)*d,u=o+(e-o)*d,n.push(l+(t+(i-t)*d-l)*d,u+(e+(r-e)*d-u)*d)}}}const Vs={[Bt.POLY]:bo,[Bt.CIRC]:Dr,[Bt.ELIP]:Dr,[Bt.RECT]:Bc,[Bt.RREC]:Lc},wo=[],Fr=[];class Br{constructor(t,e=null,i=null,r=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=r,this.type=t.type}clone(){return new Br(this.shape,this.fillStyle,this.lineStyle,this.matrix)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const Gi=new ft,Nc=class lf extends Sa{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new Cr,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),Fr.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),wo.push(e)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,i=null,r=null){const n=new Br(t,e,i,r);return this.graphicsData.push(n),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new Br(t,null,null,e),r=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=r.lineStyle,r.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const e=this.graphicsData;for(let i=0;i<e.length;++i){const r=e[i];if(r.fillStyle.visible&&r.shape&&(r.matrix?r.matrix.applyInverse(t,Gi):Gi.copyFrom(t),r.shape.contains(Gi.x,Gi.y))){let n=!1;if(r.holes){for(let a=0;a<r.holes.length;a++)if(r.holes[a].shape.contains(Gi.x,Gi.y)){n=!0;break}}if(!n)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let i=null,r=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],r=i.style);for(let h=this.shapeIndex;h<e.length;h++){this.shapeIndex++;const l=e[h],u=l.fillStyle,c=l.lineStyle;Vs[l.type].build(l),l.matrix&&this.transformPoints(l.points,l.matrix),(u.visible||c.visible)&&this.processHoles(l.holes);for(let d=0;d<2;d++){const f=d===0?u:c;if(!f.visible)continue;const p=f.texture.baseTexture,g=this.indices.length,m=this.points.length/2;p.wrapMode=Te.REPEAT,d===0?this.processFill(l):this.processLine(l);const _=this.points.length/2-m;_!==0&&(i&&!this._compareStyles(r,f)&&(i.end(g,m),i=null),i||(i=wo.pop()||new Oc,i.begin(f,g,m),this.batches.push(i),r=f),this.addUvs(this.points,t,f.texture,m,_,f.matrix))}}const n=this.indices.length,a=this.points.length/2;if(i&&i.end(n,a),this.batches.length===0){this.batchable=!0;return}const o=a>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&o===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=o?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const i=this.graphicsData[t],r=i.fillStyle,n=i.lineStyle;if(r&&!r.texture.baseTexture.valid||n&&!n.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,i=t.length;e<i;e++){const r=t[e];for(let n=0;n<r.size;n++){const a=r.start+n;this.indicesUint16[a]=this.indicesUint16[a]-r.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let e=0;e<t.length;e++)if(t[e].style.native)return!1;return this.points.length<lf.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++lt._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),Fr.push(this.drawCalls[c]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let r=Fr.pop();r||(r=new ds,r.texArray=new ys),r.texArray.count=0,r.start=0,r.size=0,r.type=oe.TRIANGLES;let n=0,a=null,o=0,h=!1,l=oe.TRIANGLES,u=0;this.drawCalls.push(r);for(let c=0;c<this.batches.length;c++){const d=this.batches[c],f=8,p=d.style,g=p.texture.baseTexture;h!==!!p.native&&(h=!!p.native,l=h?oe.LINES:oe.TRIANGLES,a=null,n=f,t++),a!==g&&(a=g,g._batchEnabled!==t&&(n===f&&(t++,n=0,r.size>0&&(r=Fr.pop(),r||(r=new ds,r.texArray=new ys),this.drawCalls.push(r)),r.start=u,r.size=0,r.texArray.count=0,r.type=l),g.touched=1,g._batchEnabled=t,g._batchLocation=n,g.wrapMode=Te.REPEAT,r.texArray.elements[r.texArray.count++]=g,n++)),r.size+=d.size,u+=d.size,o=g._batchLocation,this.addColors(e,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,o,d.attribSize,d.attribStart)}lt._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=this.colors,r=this.textureIds,n=new ArrayBuffer(t.length*3*4),a=new Float32Array(n),o=new Uint32Array(n);let h=0;for(let l=0;l<t.length/2;l++)a[h++]=t[l*2],a[h++]=t[l*2+1],a[h++]=e[l*2],a[h++]=e[l*2+1],o[h++]=i[l],a[h++]=r[l];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?bo.triangulate(t,this):Vs[t.type].triangulate(t,this)}processLine(t){Eo(t,this);for(let e=0;e<t.holes.length;e++)Eo(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];Vs[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,e){for(let i=0;i<t.length/2;i++){const r=t[i*2],n=t[i*2+1];t[i*2]=e.a*r+e.c*n+e.tx,t[i*2+1]=e.b*r+e.d*n+e.ty}}addColors(t,e,i,r,n=0){const a=gt.shared.setValue(e).toLittleEndianNumber(),o=gt.shared.setValue(a).toPremultiplied(i);t.length=Math.max(t.length,n+r);for(let h=0;h<r;h++)t[n+h]=o}addTextureIds(t,e,i,r=0){t.length=Math.max(t.length,r+i);for(let n=0;n<i;n++)t[r+n]=e}addUvs(t,e,i,r,n,a=null){let o=0;const h=e.length,l=i.frame;for(;o<n;){let c=t[(r+o)*2],d=t[(r+o)*2+1];if(a){const f=a.a*c+a.c*d+a.tx;d=a.b*c+a.d*d+a.ty,c=f}o++,e.push(c/l.width,d/l.height)}const u=i.baseTexture;(l.width<u.width||l.height<u.height)&&this.adjustUvs(e,i,h,n)}adjustUvs(t,e,i,r){const n=e.baseTexture,a=1e-6,o=i+r*2,h=e.frame,l=h.width/n.width,u=h.height/n.height;let c=h.x/h.width,d=h.y/h.height,f=Math.floor(t[i]+a),p=Math.floor(t[i+1]+a);for(let g=i+2;g<o;g+=2)f=Math.min(f,Math.floor(t[g]+a)),p=Math.min(p,Math.floor(t[g+1]+a));c-=f,d-=p;for(let g=i;g<o;g+=2)t[g]=(t[g]+c)*l,t[g+1]=(t[g+1]+d)*u}};Nc.BATCHABLE_SIZE=100;let Uc=Nc;class Lr{constructor(){this.color=16777215,this.alpha=1,this.texture=j.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Lr;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=j.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class Hs extends Lr{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=He.BUTT,this.join=$t.MITER,this.miterLimit=10}clone(){const t=new Hs;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=He.BUTT,this.join=$t.MITER,this.miterLimit=10}}const Co={},Ao=class yn extends Vt{constructor(t=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new Lr,this._lineStyle=new Hs,this._matrix=null,this._holeMode=!1,this.state=fe.for2d(),this._geometry=t||new Uc,this._geometry.refCount++,this._transformID=-1,this._tintColor=new gt(16777215),this.blendMode=nt.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new yn(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,r=.5,n=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:i,alignment:r,native:n}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:j.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:He.BUTT,join:$t.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new Ke,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Ke,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,r=i[i.length-2],n=i[i.length-1];return(r!==t||n!==e)&&i.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,i,r){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),Gs.curveTo(t,e,i,r,n),this}bezierCurveTo(t,e,i,r,n,a){return this._initCurve(),Us.curveTo(t,e,i,r,n,a,this.currentPath.points),this}arcTo(t,e,i,r,n){this._initCurve(t,e);const a=this.currentPath.points,o=To.curveTo(t,e,i,r,n,a);if(o){const{cx:h,cy:l,radius:u,startAngle:c,endAngle:d,anticlockwise:f}=o;this.arc(h,l,u,c,d,f)}return this}arc(t,e,i,r,n,a=!1){if(r===n)return this;if(!a&&n<=r?n+=dr:a&&r<=n&&(r+=dr),n-r===0)return this;const o=t+Math.cos(r)*i,h=e+Math.sin(r)*i,l=this._geometry.closePointEps;let u=this.currentPath?this.currentPath.points:null;if(u){const c=Math.abs(u[u.length-2]-o),d=Math.abs(u[u.length-1]-h);c<l&&d<l||u.push(o,h)}else this.moveTo(o,h),u=this.currentPath.points;return To.arc(o,h,t,e,i,r,n,a,u),this}beginFill(t=0,e){return this.beginTextureFill({texture:j.WHITE,color:t,alpha:e})}normalizeColor(t){const e=gt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:j.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,r){return this.drawShape(new ut(t,e,i,r))}drawRoundedRect(t,e,i,r,n){return this.drawShape(new mr(t,e,i,r,n))}drawCircle(t,e,i){return this.drawShape(new fr(t,e,i))}drawEllipse(t,e,i,r){return this.drawShape(new pr(t,e,i,r))}drawPolygon(...t){let e,i=!0;const r=t[0];r.points?(i=r.closeStroke,e=r.points):Array.isArray(t[0])?e=t[0]:e=t;const n=new Ke(e);return n.closeStroke=i,this.drawShape(n),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Bt.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const e=this._geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,e=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let r=0;r<i;r++){const n=t.batches[r],a=n.style.color,o=new Float32Array(this.vertexData.buffer,n.attribStart*4*2,n.attribSize*2),h=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),l=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),u={vertexData:o,blendMode:e,indices:l,uvs:h,_batchRGB:gt.shared.setValue(a).toRgbArray(),_tintRGB:a,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[r]=u}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,i=this.batches.length;e<i;e++){const r=this.batches[e];r.worldAlpha=this.worldAlpha*r.alpha,t.plugins[this.pluginName].render(r)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,r=this.worldAlpha,n=e.uniforms,a=i.drawCalls;n.translationMatrix=this.transform.worldTransform,gt.shared.setValue(this._tintColor).premultiply(r).toArray(n.tint),t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(let o=0,h=a.length;o<h;o++)this._renderDrawCallDirect(t,i.drawCalls[o])}_renderDrawCallDirect(t,e){const{texArray:i,type:r,size:n,start:a}=e,o=i.count;for(let h=0;h<o;h++)t.texture.bind(i.elements[h],h);t.geometry.draw(r,n,a)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!Co[i]){const{maxTextures:r}=t.plugins[i],n=new Int32Array(r);for(let h=0;h<r;h++)n[h]=h;const a={tint:new Float32Array([1,1,1,1]),translationMatrix:new vt,default:Qt.from({uSamplers:n},!0)},o=t.plugins[i]._shader.program;Co[i]=new me(o,a)}e=Co[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:r,maxY:n}=t.bounds;this._bounds.addFrame(this.transform,e,i,r,n)}containsPoint(t){return this.worldTransform.applyInverse(t,yn._TEMP_POINT),this._geometry.containsPoint(yn._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e._tintRGB=gt.shared.setValue(this._tintColor).multiply(e._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const e=this.transform.worldTransform,i=e.a,r=e.b,n=e.c,a=e.d,o=e.tx,h=e.ty,l=this._geometry.points,u=this.vertexData;let c=0;for(let d=0;d<l.length;d+=2){const f=l[d],p=l[d+1];u[c++]=i*f+n*p+o,u[c++]=a*p+r*f+h}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(t)}};Ao.curves=ri,Ao._TEMP_POINT=new ft;let So=Ao;const Lg={buildPoly:bo,buildCircle:Dr,buildRectangle:Bc,buildRoundedRectangle:Lc,buildLine:Eo,ArcUtils:To,BezierUtils:Us,QuadraticUtils:Gs,BatchPart:Oc,FILL_COMMANDS:Vs,BATCH_POOL:wo,DRAW_CALL_POOL:Fr};class Gc{constructor(t,e){this.uvBuffer=t,this.uvMatrix=e,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const e=this.uvBuffer.data;(!this.data||this.data.length!==e.length)&&(this.data=new Float32Array(e.length)),this.uvMatrix.multiplyUvs(e,this.data),this._updateID++}}const Po=new ft,Vc=new Ke,Hc=class uf extends Vt{constructor(t,e,i,r=oe.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||fe.for2d(),this.drawMode=r,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=q.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const e=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===oe.TRIANGLES&&e.length<uf.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const e=this.shader;e.alpha=this.worldAlpha,e.update&&e.update(),t.batch.flush(),e.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(e),t.state.set(this.state),t.geometry.bind(this.geometry,e),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const e=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const r=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[r]),t.plugins[r].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,i=t._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==e.length&&(this.vertexData=new Float32Array(e.length));const r=this.transform.worldTransform,n=r.a,a=r.b,o=r.c,h=r.d,l=r.tx,u=r.ty,c=this.vertexData;for(let d=0;d<c.length/2;d++){const f=e[d*2],p=e[d*2+1];c[d*2]=n*f+o*p+l,c[d*2+1]=a*f+h*p+u}if(this._roundPixels){const d=q.RESOLUTION;for(let f=0;f<c.length;++f)c[f]=Math.round(c[f]*d)/d}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new Gc(t,e.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,Po);const e=this.geometry.getBuffer("aVertexPosition").data,i=Vc.points,r=this.geometry.getIndex().data,n=r.length,a=this.drawMode===4?3:1;for(let o=0;o+2<n;o+=a){const h=r[o]*2,l=r[o+1]*2,u=r[o+2]*2;if(i[0]=e[h],i[1]=e[h+1],i[2]=e[l],i[3]=e[l+1],i[4]=e[u],i[5]=e[u+1],Vc.contains(Po.x,Po.y))return!0}return!1}destroy(t){super.destroy(t),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};Hc.BATCHABLE_SIZE=100;let Vi=Hc;class Or extends Ue{constructor(t,e,i){super();const r=new At(t),n=new At(e,!0),a=new At(i,!0,!0);this.addAttribute("aVertexPosition",r,2,!1,it.FLOAT).addAttribute("aTextureCoord",n,2,!1,it.FLOAT).addIndex(a),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var Og=`varying vec2 vTextureCoord;
912
+ uniform vec4 uColor;
913
+
914
+ uniform sampler2D uSampler;
915
+
916
+ void main(void)
917
+ {
918
+ gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
919
+ }
920
+ `,kg=`attribute vec2 aVertexPosition;
921
+ attribute vec2 aTextureCoord;
922
+
923
+ uniform mat3 projectionMatrix;
924
+ uniform mat3 translationMatrix;
925
+ uniform mat3 uTextureMatrix;
926
+
927
+ varying vec2 vTextureCoord;
928
+
929
+ void main(void)
930
+ {
931
+ gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
932
+
933
+ vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
934
+ }
935
+ `;class Hi extends me{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:vt.IDENTITY,uColor:new Float32Array([1,1,1,1])};e=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},e),e.uniforms&&Object.assign(i,e.uniforms),super(e.program||Ae.from(kg,Og),i),this._colorDirty=!1,this.uvMatrix=new Es(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new gt(e.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=e.alpha}get texture(){return this.uniforms.uSampler}set texture(t){this.uniforms.uSampler!==t&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!t.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=t,this.uvMatrix.texture=t)}set alpha(t){t!==this._alpha&&(this._alpha=t,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(t){t!==this.tint&&(this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0)}get tint(){return this._tintColor.value}get tintValue(){return this._tintColor.toNumber()}update(){if(this._colorDirty){this._colorDirty=!1;const t=this.texture.baseTexture.alphaMode;gt.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class Xc extends Or{constructor(t=100,e=100,i=10,r=10){super(),this.segWidth=i,this.segHeight=r,this.width=t,this.height=e,this.build()}build(){const t=this.segWidth*this.segHeight,e=[],i=[],r=[],n=this.segWidth-1,a=this.segHeight-1,o=this.width/n,h=this.height/a;for(let u=0;u<t;u++){const c=u%this.segWidth,d=u/this.segWidth|0;e.push(c*o,d*h),i.push(c/n,d/a)}const l=n*a;for(let u=0;u<l;u++){const c=u%n,d=u/n|0,f=d*this.segWidth+c,p=d*this.segWidth+c+1,g=(d+1)*this.segWidth+c,m=(d+1)*this.segWidth+c+1;r.push(f,p,g,p,m,g)}this.buffers[0].data=new Float32Array(e),this.buffers[1].data=new Float32Array(i),this.indexBuffer.data=new Uint16Array(r),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}}class zc extends Or{constructor(t=200,e,i=0){super(new Float32Array(e.length*4),new Float32Array(e.length*4),new Uint16Array((e.length-1)*6)),this.points=e,this._width=t,this.textureScale=i,this.build()}get width(){return this._width}build(){const t=this.points;if(!t)return;const e=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),r=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),r.data=new Uint16Array((t.length-1)*6));const n=i.data,a=r.data;n[0]=0,n[1]=0,n[2]=0,n[3]=1;let o=0,h=t[0];const l=this._width*this.textureScale,u=t.length;for(let d=0;d<u;d++){const f=d*4;if(this.textureScale>0){const p=h.x-t[d].x,g=h.y-t[d].y,m=Math.sqrt(p*p+g*g);h=t[d],o+=m/l}else o=d/(u-1);n[f]=o,n[f+1]=0,n[f+2]=o,n[f+3]=1}let c=0;for(let d=0;d<u-1;d++){const f=d*2;a[c++]=f,a[c++]=f+1,a[c++]=f+2,a[c++]=f+2,a[c++]=f+1,a[c++]=f+3}i.update(),r.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let e=t[0],i,r=0,n=0;const a=this.buffers[0].data,o=t.length,h=this.textureScale>0?this.textureScale*this._width/2:this._width/2;for(let l=0;l<o;l++){const u=t[l],c=l*4;l<t.length-1?i=t[l+1]:i=u,n=-(i.x-e.x),r=i.y-e.y;const d=Math.sqrt(r*r+n*n);d<1e-6?(r=0,n=0):(r/=d,n/=d,r*=h,n*=h),a[c]=u.x+r,a[c+1]=u.y+n,a[c+2]=u.x-r,a[c+3]=u.y-n,e=u}this.buffers[0].update()}update(){this.textureScale>0?this.build():this.updateVertices()}}class Wc extends Vi{constructor(t,e,i){const r=new Xc(t.width,t.height,e,i),n=new Hi(j.WHITE);super(r,n),this.texture=t,this.autoResize=!0}textureUpdated(){this._textureID=this.shader.texture._updateID;const t=this.geometry,{width:e,height:i}=this.shader.texture;this.autoResize&&(t.width!==e||t.height!==i)&&(t.width=this.shader.texture.width,t.height=this.shader.texture.height,t.build())}set texture(t){this.shader.texture!==t&&(this.shader.texture=t,this._textureID=-1,t.baseTexture.valid?this.textureUpdated():t.once("update",this.textureUpdated,this))}get texture(){return this.shader.texture}_render(t){this._textureID!==this.shader.texture._updateID&&this.textureUpdated(),super._render(t)}destroy(t){this.shader.texture.off("update",this.textureUpdated,this),super.destroy(t)}}const Xs=10;class Ng extends Wc{constructor(t,e,i,r,n){var a,o,h,l;super(j.WHITE,4,4),this._origWidth=t.orig.width,this._origHeight=t.orig.height,this._width=this._origWidth,this._height=this._origHeight,this._leftWidth=e??((a=t.defaultBorders)==null?void 0:a.left)??Xs,this._rightWidth=r??((o=t.defaultBorders)==null?void 0:o.right)??Xs,this._topHeight=i??((h=t.defaultBorders)==null?void 0:h.top)??Xs,this._bottomHeight=n??((l=t.defaultBorders)==null?void 0:l.bottom)??Xs,this.texture=t}textureUpdated(){this._textureID=this.shader.texture._updateID,this._refresh()}get vertices(){return this.geometry.getBuffer("aVertexPosition").data}set vertices(t){this.geometry.getBuffer("aVertexPosition").data=t}updateHorizontalVertices(){const t=this.vertices,e=this._getMinScale();t[9]=t[11]=t[13]=t[15]=this._topHeight*e,t[17]=t[19]=t[21]=t[23]=this._height-this._bottomHeight*e,t[25]=t[27]=t[29]=t[31]=this._height}updateVerticalVertices(){const t=this.vertices,e=this._getMinScale();t[2]=t[10]=t[18]=t[26]=this._leftWidth*e,t[4]=t[12]=t[20]=t[28]=this._width-this._rightWidth*e,t[6]=t[14]=t[22]=t[30]=this._width}_getMinScale(){const t=this._leftWidth+this._rightWidth,e=this._width>t?1:this._width/t,i=this._topHeight+this._bottomHeight,r=this._height>i?1:this._height/i;return Math.min(e,r)}get width(){return this._width}set width(t){this._width=t,this._refresh()}get height(){return this._height}set height(t){this._height=t,this._refresh()}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this._refresh()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this._refresh()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this._refresh()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this._refresh()}_refresh(){const t=this.texture,e=this.geometry.buffers[1].data;this._origWidth=t.orig.width,this._origHeight=t.orig.height;const i=1/this._origWidth,r=1/this._origHeight;e[0]=e[8]=e[16]=e[24]=0,e[1]=e[3]=e[5]=e[7]=0,e[6]=e[14]=e[22]=e[30]=1,e[25]=e[27]=e[29]=e[31]=1,e[2]=e[10]=e[18]=e[26]=i*this._leftWidth,e[4]=e[12]=e[20]=e[28]=1-i*this._rightWidth,e[9]=e[11]=e[13]=e[15]=r*this._topHeight,e[17]=e[19]=e[21]=e[23]=1-r*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.geometry.buffers[0].update(),this.geometry.buffers[1].update()}}class Ug extends Vi{constructor(t=j.EMPTY,e,i,r,n){const a=new Or(e,i,r);a.getBuffer("aVertexPosition").static=!1;const o=new Hi(t);super(a,o,null,n),this.autoUpdate=!0}get vertices(){return this.geometry.getBuffer("aVertexPosition").data}set vertices(t){this.geometry.getBuffer("aVertexPosition").data=t}_render(t){this.autoUpdate&&this.geometry.getBuffer("aVertexPosition").update(),super._render(t)}}class Gg extends Vi{constructor(t,e,i=0){const r=new zc(t.height,e,i),n=new Hi(t);i>0&&(t.baseTexture.wrapMode=Te.REPEAT),super(r,n),this.autoUpdate=!0}_render(t){const e=this.geometry;(this.autoUpdate||e._width!==this.shader.texture.height)&&(e._width=this.shader.texture.height,e.update()),super._render(t)}}class Vg extends Vt{constructor(t=1500,e,i=16384,r=!1){super();const n=16384;i>n&&(i=n),this._properties=[!1,!0,!1,!1,!1],this._maxSize=t,this._batchSize=i,this._buffers=null,this._bufferUpdateIDs=[],this._updateID=0,this.interactiveChildren=!1,this.blendMode=nt.NORMAL,this.autoResize=r,this.roundPixels=!0,this.baseTexture=null,this.setProperties(e),this._tintColor=new gt(0),this.tintRgb=new Float32Array(3),this.tint=16777215}setProperties(t){t&&(this._properties[0]="vertices"in t||"scale"in t?!!t.vertices||!!t.scale:this._properties[0],this._properties[1]="position"in t?!!t.position:this._properties[1],this._properties[2]="rotation"in t?!!t.rotation:this._properties[2],this._properties[3]="uvs"in t?!!t.uvs:this._properties[3],this._properties[4]="tint"in t||"alpha"in t?!!t.tint||!!t.alpha:this._properties[4])}updateTransform(){this.displayObjectUpdateTransform()}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintColor.toRgbArray(this.tintRgb)}render(t){!this.visible||this.worldAlpha<=0||!this.children.length||!this.renderable||(this.baseTexture||(this.baseTexture=this.children[0]._texture.baseTexture,this.baseTexture.valid||this.baseTexture.once("update",()=>this.onChildrenChange(0))),t.batch.setObjectRenderer(t.plugins.particle),t.plugins.particle.render(this))}onChildrenChange(t){const e=Math.floor(t/this._batchSize);for(;this._bufferUpdateIDs.length<e;)this._bufferUpdateIDs.push(0);this._bufferUpdateIDs[e]=++this._updateID}dispose(){if(this._buffers){for(let t=0;t<this._buffers.length;++t)this._buffers[t].destroy();this._buffers=null}}destroy(t){super.destroy(t),this.dispose(),this._properties=null,this._buffers=null,this._bufferUpdateIDs=null}}class $c{constructor(t,e,i){this.geometry=new Ue,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let r=0;r<t.length;++r){let n=t[r];n={attributeName:n.attributeName,size:n.size,uploadFunction:n.uploadFunction,type:n.type||it.FLOAT,offset:n.offset},e[r]?this.dynamicProperties.push(n):this.staticProperties.push(n)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const t=this.geometry;let e=0;this.indexBuffer=new At(Bl(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(let a=0;a<this.dynamicProperties.length;++a){const o=this.dynamicProperties[a];o.offset=e,e+=o.size,this.dynamicStride+=o.size}const i=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(i),this.dynamicDataUint32=new Uint32Array(i),this.dynamicBuffer=new At(this.dynamicData,!1,!1);let r=0;this.staticStride=0;for(let a=0;a<this.staticProperties.length;++a){const o=this.staticProperties[a];o.offset=r,r+=o.size,this.staticStride+=o.size}const n=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(n),this.staticDataUint32=new Uint32Array(n),this.staticBuffer=new At(this.staticData,!0,!1);for(let a=0;a<this.dynamicProperties.length;++a){const o=this.dynamicProperties[a];t.addAttribute(o.attributeName,this.dynamicBuffer,0,o.type===it.UNSIGNED_BYTE,o.type,this.dynamicStride*4,o.offset*4)}for(let a=0;a<this.staticProperties.length;++a){const o=this.staticProperties[a];t.addAttribute(o.attributeName,this.staticBuffer,0,o.type===it.UNSIGNED_BYTE,o.type,this.staticStride*4,o.offset*4)}}uploadDynamic(t,e,i){for(let r=0;r<this.dynamicProperties.length;r++){const n=this.dynamicProperties[r];n.uploadFunction(t,e,i,n.type===it.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,n.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,i){for(let r=0;r<this.staticProperties.length;r++){const n=this.staticProperties[r];n.uploadFunction(t,e,i,n.type===it.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,n.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var Hg=`varying vec2 vTextureCoord;
936
+ varying vec4 vColor;
937
+
938
+ uniform sampler2D uSampler;
939
+
940
+ void main(void){
941
+ vec4 color = texture2D(uSampler, vTextureCoord) * vColor;
942
+ gl_FragColor = color;
943
+ }`,Xg=`attribute vec2 aVertexPosition;
944
+ attribute vec2 aTextureCoord;
945
+ attribute vec4 aColor;
946
+
947
+ attribute vec2 aPositionCoord;
948
+ attribute float aRotation;
949
+
950
+ uniform mat3 translationMatrix;
951
+ uniform vec4 uColor;
952
+
953
+ varying vec2 vTextureCoord;
954
+ varying vec4 vColor;
955
+
956
+ void main(void){
957
+ float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);
958
+ float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);
959
+
960
+ vec2 v = vec2(x, y);
961
+ v = v + aPositionCoord;
962
+
963
+ gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
964
+
965
+ vTextureCoord = aTextureCoord;
966
+ vColor = aColor * uColor;
967
+ }
968
+ `;class Mo extends _r{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new vt,this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:it.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=me.from(Xg,Hg,{}),this.state=fe.for2d()}render(t){const e=t.children,i=t._maxSize,r=t._batchSize,n=this.renderer;let a=e.length;if(a===0)return;a>i&&!t.autoResize&&(a=i);let o=t._buffers;o||(o=t._buffers=this.generateBuffers(t));const h=e[0]._texture.baseTexture,l=h.alphaMode>0;this.state.blendMode=da(t.blendMode,l),n.state.set(this.state);const u=n.gl,c=t.worldTransform.copyTo(this.tempMatrix);c.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=c.toArray(!0),this.shader.uniforms.uColor=gt.shared.setValue(t.tintRgb).premultiply(t.worldAlpha,l).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=h,this.renderer.shader.bind(this.shader);let d=!1;for(let f=0,p=0;f<a;f+=r,p+=1){let g=a-f;g>r&&(g=r),p>=o.length&&o.push(this._generateOneMoreBuffer(t));const m=o[p];m.uploadDynamic(e,f,g);const _=t._bufferUpdateIDs[p]||0;d=d||m._updateID<_,d&&(m._updateID=t._updateID,m.uploadStatic(e,f,g)),n.geometry.bind(m.geometry),u.drawElements(u.TRIANGLES,g*6,u.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],i=t._maxSize,r=t._batchSize,n=t._properties;for(let a=0;a<i;a+=r)e.push(new $c(this.properties,n,r));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new $c(this.properties,i,e)}uploadVertices(t,e,i,r,n,a){let o=0,h=0,l=0,u=0;for(let c=0;c<i;++c){const d=t[e+c],f=d._texture,p=d.scale.x,g=d.scale.y,m=f.trim,_=f.orig;m?(h=m.x-d.anchor.x*_.width,o=h+m.width,u=m.y-d.anchor.y*_.height,l=u+m.height):(o=_.width*(1-d.anchor.x),h=_.width*-d.anchor.x,l=_.height*(1-d.anchor.y),u=_.height*-d.anchor.y),r[a]=h*p,r[a+1]=u*g,r[a+n]=o*p,r[a+n+1]=u*g,r[a+n*2]=o*p,r[a+n*2+1]=l*g,r[a+n*3]=h*p,r[a+n*3+1]=l*g,a+=n*4}}uploadPosition(t,e,i,r,n,a){for(let o=0;o<i;o++){const h=t[e+o].position;r[a]=h.x,r[a+1]=h.y,r[a+n]=h.x,r[a+n+1]=h.y,r[a+n*2]=h.x,r[a+n*2+1]=h.y,r[a+n*3]=h.x,r[a+n*3+1]=h.y,a+=n*4}}uploadRotation(t,e,i,r,n,a){for(let o=0;o<i;o++){const h=t[e+o].rotation;r[a]=h,r[a+n]=h,r[a+n*2]=h,r[a+n*3]=h,a+=n*4}}uploadUvs(t,e,i,r,n,a){for(let o=0;o<i;++o){const h=t[e+o]._texture._uvs;h?(r[a]=h.x0,r[a+1]=h.y0,r[a+n]=h.x1,r[a+n+1]=h.y1,r[a+n*2]=h.x2,r[a+n*2+1]=h.y2,r[a+n*3]=h.x3,r[a+n*3+1]=h.y3,a+=n*4):(r[a]=0,r[a+1]=0,r[a+n]=0,r[a+n+1]=0,r[a+n*2]=0,r[a+n*2+1]=0,r[a+n*3]=0,r[a+n*3+1]=0,a+=n*4)}}uploadTint(t,e,i,r,n,a){for(let o=0;o<i;++o){const h=t[e+o],l=gt.shared.setValue(h._tintRGB).toPremultiplied(h.alpha,h.texture.baseTexture.alphaMode>0);r[a]=l,r[a+n]=l,r[a+n*2]=l,r[a+n*3]=l,a+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}Mo.extension={name:"particle",type:$.RendererPlugin},Q.add(Mo);var kr=(s=>(s[s.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",s[s.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",s))(kr||{});const zs={willReadFrequently:!0},Ie=class et{static get experimentalLetterSpacingSupported(){let t=et._experimentalLetterSpacingSupported;if(t!==void 0){const e=q.ADAPTER.getCanvasRenderingContext2D().prototype;t=et._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,r,n,a,o,h,l){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=n,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=l}static measureText(t,e,i,r=et._canvas){i=i??e.wordWrap;const n=e.toFontString(),a=et.measureFont(n);a.fontSize===0&&(a.fontSize=e.fontSize,a.ascent=e.fontSize);const o=r.getContext("2d",zs);o.font=n;const h=(i?et.wordWrap(t,e,r):t).split(/(?:\r\n|\r|\n)/),l=new Array(h.length);let u=0;for(let p=0;p<h.length;p++){const g=et._measureText(h[p],e.letterSpacing,o);l[p]=g,u=Math.max(u,g)}let c=u+e.strokeThickness;e.dropShadow&&(c+=e.dropShadowDistance);const d=e.lineHeight||a.fontSize+e.strokeThickness;let f=Math.max(d,a.fontSize+e.strokeThickness*2)+e.leading+(h.length-1)*(d+e.leading);return e.dropShadow&&(f+=e.dropShadowDistance),new et(t,e,c,f,h,l,d+e.leading,u,a)}static _measureText(t,e,i){let r=!1;et.experimentalLetterSpacingSupported&&(et.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,r=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let n=i.measureText(t).width;return n>0&&(r?n-=e:n+=(et.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=et._canvas){const r=i.getContext("2d",zs);let n=0,a="",o="";const h=Object.create(null),{letterSpacing:l,whiteSpace:u}=e,c=et.collapseSpaces(u),d=et.collapseNewlines(u);let f=!c;const p=e.wordWrapWidth+l,g=et.tokenize(t);for(let m=0;m<g.length;m++){let _=g[m];if(et.isNewline(_)){if(!d){o+=et.addLine(a),f=!c,a="",n=0;continue}_=" "}if(c){const y=et.isBreakingSpace(_),E=et.isBreakingSpace(a[a.length-1]);if(y&&E)continue}const b=et.getFromCache(_,l,h,r);if(b>p)if(a!==""&&(o+=et.addLine(a),a="",n=0),et.canBreakWords(_,e.breakWords)){const y=et.wordWrapSplit(_);for(let E=0;E<y.length;E++){let v=y[E],M=v,T=1;for(;y[E+T];){const N=y[E+T];if(!et.canBreakChars(M,N,_,E,e.breakWords))v+=N;else break;M=N,T++}E+=T-1;const P=et.getFromCache(v,l,h,r);P+n>p&&(o+=et.addLine(a),f=!1,a="",n=0),a+=v,n+=P}}else{a.length>0&&(o+=et.addLine(a),a="",n=0);const y=m===g.length-1;o+=et.addLine(_,!y),f=!1,a="",n=0}else b+n>p&&(f=!1,o+=et.addLine(a),a="",n=0),(a.length>0||!et.isBreakingSpace(_)||f)&&(a+=_,n+=b)}return o+=et.addLine(a,!1),o}static addLine(t,e=!0){return t=et.trimRight(t),t=e?`${t}
969
+ `:t,t}static getFromCache(t,e,i,r){let n=i[t];return typeof n!="number"&&(n=et._measureText(t,e,r)+e,i[t]=n),n}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!et.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:et._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:et._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let r=0;r<t.length;r++){const n=t[r],a=t[r+1];if(et.isBreakingSpace(n,a)||et.isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,r,n){return!0}static wordWrapSplit(t){return et.graphemeSegmenter(t)}static measureFont(t){if(et._fonts[t])return et._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=et._canvas,r=et._context;r.font=t;const n=et.METRICS_STRING+et.BASELINE_SYMBOL,a=Math.ceil(r.measureText(n).width);let o=Math.ceil(r.measureText(et.BASELINE_SYMBOL).width);const h=Math.ceil(et.HEIGHT_MULTIPLIER*o);if(o=o*et.BASELINE_MULTIPLIER|0,a===0||h===0)return et._fonts[t]=e,e;i.width=a,i.height=h,r.fillStyle="#f00",r.fillRect(0,0,a,h),r.font=t,r.textBaseline="alphabetic",r.fillStyle="#000",r.fillText(n,0,o);const l=r.getImageData(0,0,a,h).data,u=l.length,c=a*4;let d=0,f=0,p=!1;for(d=0;d<o;++d){for(let g=0;g<c;g+=4)if(l[f+g]!==255){p=!0;break}if(!p)f+=c;else break}for(e.ascent=o-d,f=u-c,p=!1,d=h;d>o;--d){for(let g=0;g<c;g+=4)if(l[f+g]!==255){p=!0;break}if(!p)f-=c;else break}return e.descent=d-o,e.fontSize=e.ascent+e.descent,et._fonts[t]=e,e}static clearMetrics(t=""){t?delete et._fonts[t]:et._fonts={}}static get _canvas(){var t;if(!et.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",zs))!=null&&t.measureText)return et.__canvas=i,i;e=q.ADAPTER.createCanvas()}catch{e=q.ADAPTER.createCanvas()}e.width=e.height=10,et.__canvas=e}return et.__canvas}static get _context(){return et.__context||(et.__context=et._canvas.getContext("2d",zs)),et.__context}};Ie.METRICS_STRING="|ÉqÅ",Ie.BASELINE_SYMBOL="M",Ie.BASELINE_MULTIPLIER=1.4,Ie.HEIGHT_MULTIPLIER=2,Ie.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>[...s.segment(t)].map(e=>e.segment)}return s=>[...s]})(),Ie.experimentalLetterSpacing=!1,Ie._fonts={},Ie._newlines=[10,13],Ie._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Xe=Ie;const zg=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],jc=class es{constructor(t){this.styleID=0,this.reset(),Ro(this,t,t)}clone(){const t={};return Ro(t,this,es.defaultStyle),new es(t)}reset(){Ro(this,es.defaultStyle,es.defaultStyle)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(t){const e=Io(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)}get fill(){return this._fill}set fill(t){const e=Io(t);this._fill!==e&&(this._fill=e,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(t){Wg(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.styleID++)}get stroke(){return this._stroke}set stroke(t){const e=Io(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let r=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!zg.includes(r)&&(r=`"${r}"`),e[i]=r}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};jc.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:kr.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let ze=jc;function Io(s){const t=gt.shared,e=i=>{const r=t.setValue(i);return r.alpha===1?r.toHex():r.toRgbaString()};return Array.isArray(s)?s.map(e):e(s)}function Wg(s,t){if(!Array.isArray(s)||!Array.isArray(t)||s.length!==t.length)return!1;for(let e=0;e<s.length;++e)if(s[e]!==t[e])return!1;return!0}function Ro(s,t,e){for(const i in e)Array.isArray(t[i])?s[i]=t[i].slice():s[i]=t[i]}const $g={texture:!0,children:!1,baseTexture:!0},Yc=class yh extends Ge{constructor(t,e,i){let r=!1;i||(i=q.ADAPTER.createCanvas(),r=!0),i.width=3,i.height=3;const n=j.from(i);n.orig=new ut,n.trim=new ut,super(n),this._ownCanvas=r,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=yh.defaultResolution??q.RESOLUTION,this._autoResolution=yh.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=e,this.localStyleID=-1}static get experimentalLetterSpacing(){return Xe.experimentalLetterSpacing}static set experimentalLetterSpacing(t){ot("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Xe.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,r=Xe.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=r.width,a=r.height,o=r.lines,h=r.lineHeight,l=r.lineWidths,u=r.maxLineWidth,c=r.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,n)+e.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,a)+e.padding*2)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=e.strokeThickness,i.textBaseline=e.textBaseline,i.lineJoin=e.lineJoin,i.miterLimit=e.miterLimit;let d,f;const p=e.dropShadow?2:1;for(let g=0;g<p;++g){const m=e.dropShadow&&g===0,_=m?Math.ceil(Math.max(1,a)+e.padding*2):0,b=_*this._resolution;if(m){i.fillStyle="black",i.strokeStyle="black";const E=e.dropShadowColor,v=e.dropShadowBlur*this._resolution,M=e.dropShadowDistance*this._resolution;i.shadowColor=gt.shared.setValue(E).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=v,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*M,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*M+b}else i.fillStyle=this._generateFillStyle(e,o,r),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let y=(h-c.fontSize)/2;h-c.fontSize<0&&(y=0);for(let E=0;E<o.length;E++)d=e.strokeThickness/2,f=e.strokeThickness/2+E*h+c.ascent+y,e.align==="right"?d+=u-l[E]:e.align==="center"&&(d+=(u-l[E])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(o[E],d+e.padding,f+e.padding-_,!0),e.fill&&this.drawLetterSpacing(o[E],d+e.padding,f+e.padding-_)}this.updateTexture()}drawLetterSpacing(t,e,i,r=!1){const n=this._style.letterSpacing;let a=!1;if(Xe.experimentalLetterSpacingSupported&&(Xe.experimentalLetterSpacing?(this.context.letterSpacing=`${n}px`,this.context.textLetterSpacing=`${n}px`,a=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),n===0||a){r?this.context.strokeText(t,e,i):this.context.fillText(t,e,i);return}let o=e;const h=Xe.graphemeSegmenter(t);let l=this.context.measureText(t).width,u=0;for(let c=0;c<h.length;++c){const d=h[c];r?this.context.strokeText(d,o,i):this.context.fillText(d,o,i);let f="";for(let p=c+1;p<h.length;++p)f+=h[p];u=this.context.measureText(f).width,o+=l-u+n,l=u}}updateTexture(){const t=this.canvas;if(this._style.trim){const a=Ul(t);a.data&&(t.width=a.width,t.height=a.height,this.context.putImageData(a.data,0,0))}const e=this._texture,i=this._style,r=i.trim?0:i.padding,n=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-r,e.trim.y=-r,e.orig.width=e._frame.width-r*2,e.orig.height=e._frame.height-r*2,this._onTextureUpdate(),n.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,i){const r=t.fill;if(Array.isArray(r)){if(r.length===1)return r[0]}else return r;let n;const a=t.dropShadow?t.dropShadowDistance:0,o=t.padding||0,h=this.canvas.width/this._resolution-a-o*2,l=this.canvas.height/this._resolution-a-o*2,u=r.slice(),c=t.fillGradientStops.slice();if(!c.length){const d=u.length+1;for(let f=1;f<d;++f)c.push(f/d)}if(u.unshift(r[0]),c.unshift(0),u.push(r[r.length-1]),c.push(1),t.fillGradientType===kr.LINEAR_VERTICAL){n=this.context.createLinearGradient(h/2,o,h/2,l+o);const d=i.fontProperties.fontSize+t.strokeThickness;for(let f=0;f<e.length;f++){const p=i.lineHeight*(f-1)+d,g=i.lineHeight*f;let m=g;f>0&&p>g&&(m=(g+p)/2);const _=g+d,b=i.lineHeight*(f+1);let y=_;f+1<e.length&&b<_&&(y=(_+b)/2);const E=(y-m)/l;for(let v=0;v<u.length;v++){let M=0;typeof c[v]=="number"?M=c[v]:M=v/u.length;let T=Math.min(1,Math.max(0,m/l+M*E));T=Number(T.toFixed(5)),n.addColorStop(T,u[v])}}}else{n=this.context.createLinearGradient(o,l/2,h+o,l/2);const d=u.length+1;let f=1;for(let p=0;p<u.length;p++){let g;typeof c[p]=="number"?g=c[p]:g=f/d,n.addColorStop(g,u[p]),f++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},$g,t),super.destroy(t),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this.updateText(!0);const e=Ne(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const e=Ne(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},t instanceof ze?this._style=t:this._style=new ze(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}};Yc.defaultAutoResolution=!0;let Do=Yc;class qc{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function jg(s,t){var i;let e=!1;if((i=s==null?void 0:s._textures)!=null&&i.length){for(let r=0;r<s._textures.length;r++)if(s._textures[r]instanceof j){const n=s._textures[r].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function Yg(s,t){if(s.baseTexture instanceof lt){const e=s.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function qg(s,t){if(s._texture&&s._texture instanceof j){const e=s._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function Kg(s,t){return t instanceof Do?(t.updateText(!0),!0):!1}function Zg(s,t){if(t instanceof ze){const e=t.toFontString();return Xe.measureFont(e),!0}return!1}function Jg(s,t){if(s instanceof Do){t.includes(s.style)||t.push(s.style),t.includes(s)||t.push(s);const e=s._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function Qg(s,t){return s instanceof ze?(t.includes(s)||t.push(s),!0):!1}const Kc=class cf{constructor(t){this.limiter=new qc(cf.uploadsPerFrame),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(Jg),this.registerFindHook(Qg),this.registerFindHook(jg),this.registerFindHook(Yg),this.registerFindHook(qg),this.registerUploadHook(Kg),this.registerUploadHook(Zg)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,Pt.system.addOnce(this.tick,this,Pe.UTILITY))):e()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let e=!1;if(t&&!t._destroyed){for(let i=0,r=this.uploadHooks.length;i<r;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)Pt.system.addOnce(this.tick,this,Pe.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,i=t.length;e<i;e++)t[e]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof Vt)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&Pt.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};Kc.uploadsPerFrame=4;let Ws=Kc;Object.defineProperties(q,{UPLOADS_PER_FRAME:{get(){return Ws.uploadsPerFrame},set(s){ot("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),Ws.uploadsPerFrame=s}}});function Zc(s,t){return t instanceof lt?(t._glTextures[s.CONTEXT_UID]||s.texture.bind(t),!0):!1}function t_(s,t){if(!(t instanceof So))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:i}=e;for(let r=0;r<i.length;r++){const{texture:n}=i[r].style;n&&Zc(s,n.baseTexture)}return e.batchable||s.geometry.bind(e,t._resolveDirectShader(s)),!0}function e_(s,t){return s instanceof So?(t.push(s),!0):!1}class Fo extends Ws{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(e_),this.registerUploadHook(Zc),this.registerUploadHook(t_)}}Fo.extension={name:"prepare",type:$.RendererSystem},Q.add(Fo);class i_{constructor(t){this.maxMilliseconds=t,this.frameStart=0}beginFrame(){this.frameStart=Date.now()}allowedToUpload(){return Date.now()-this.frameStart<this.maxMilliseconds}}class $s extends Ge{constructor(t,e=!0){super(t[0]instanceof j?t[0]:t[0].texture),this._textures=null,this._durations=null,this._autoUpdate=e,this._isConnectedToTicker=!1,this.animationSpeed=1,this.loop=!0,this.updateAnchor=!1,this.onComplete=null,this.onFrameChange=null,this.onLoop=null,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=t}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(Pt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(Pt.shared.add(this.update,this,Pe.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=this.animationSpeed*t,i=this.currentFrame;if(this._durations!==null){let r=this._currentTime%1*this._durations[this.currentFrame];for(r+=e/60*1e3;r<0;)this._currentTime--,r+=this._durations[this.currentFrame];const n=Math.sign(this.animationSpeed*t);for(this._currentTime=Math.floor(this._currentTime);r>=this._durations[this.currentFrame];)r-=this._durations[this.currentFrame]*n,this._currentTime+=n;this._currentTime+=r/this._durations[this.currentFrame]}else this._currentTime+=e;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):i!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<i||this.animationSpeed<0&&this.currentFrame>i)&&this.onLoop(),this.updateTexture())}updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this._texture=this._textures[t],this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this.uvs=this._texture._uvs.uvsFloat32,this.updateAnchor&&this._anchor.copyFrom(this._texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t){this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let i=0;i<t.length;++i)e.push(j.from(t[i]));return new $s(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(j.from(t[i]));return new $s(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof j)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(let e=0;e<t.length;e++)this._textures.push(t[e].texture),this._durations.push(t[e].time)}this._previousFrame=null,this.gotoAndStop(0),this.updateTexture()}get currentFrame(){let t=Math.floor(this._currentTime)%this._textures.length;return t<0&&(t+=this._textures.length),t}set currentFrame(t){if(t<0||t>this.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this.updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(Pt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(Pt.shared.add(this.update,this),this._isConnectedToTicker=!0))}}const Nr=new ft;class Bo extends Ge{constructor(t,e=100,i=100){super(t),this.tileTransform=new Fi,this._width=e,this._height=i,this.uvMatrix=this.texture.uvMatrix||new Es(t),this.pluginName="tilingSprite",this.uvRespectAnchor=!1}get clampMargin(){return this.uvMatrix.clampMargin}set clampMargin(t){this.uvMatrix.clampMargin=t,this.uvMatrix.update(!0)}get tileScale(){return this.tileTransform.scale}set tileScale(t){this.tileTransform.scale.copyFrom(t)}get tilePosition(){return this.tileTransform.position}set tilePosition(t){this.tileTransform.position.copyFrom(t)}_onTextureUpdate(){this.uvMatrix&&(this.uvMatrix.texture=this._texture),this._cachedTint=16777215}_render(t){const e=this._texture;!e||!e.valid||(this.tileTransform.updateLocalTransform(),this.uvMatrix.update(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this))}_calculateBounds(){const t=this._width*-this._anchor._x,e=this._height*-this._anchor._y,i=this._width*(1-this._anchor._x),r=this._height*(1-this._anchor._y);this._bounds.addFrame(this.transform,t,e,i,r)}getLocalBounds(t){return this.children.length===0?(this._bounds.minX=this._width*-this._anchor._x,this._bounds.minY=this._height*-this._anchor._y,this._bounds.maxX=this._width*(1-this._anchor._x),this._bounds.maxY=this._height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new ut),t=this._localBoundsRect),this._bounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,Nr);const e=this._width,i=this._height,r=-e*this.anchor._x;if(Nr.x>=r&&Nr.x<r+e){const n=-i*this.anchor._y;if(Nr.y>=n&&Nr.y<n+i)return!0}return!1}destroy(t){super.destroy(t),this.tileTransform=null,this.uvMatrix=null}static from(t,e){const i=t instanceof j?t:j.from(t,e);return new Bo(i,e.width,e.height)}get width(){return this._width}set width(t){this._width=t}get height(){return this._height}set height(t){this._height=t}}var r_=`#version 300 es
970
+ #define SHADER_NAME Tiling-Sprite-100
971
+
972
+ precision lowp float;
973
+
974
+ in vec2 vTextureCoord;
975
+
976
+ out vec4 fragmentColor;
977
+
978
+ uniform sampler2D uSampler;
979
+ uniform vec4 uColor;
980
+ uniform mat3 uMapCoord;
981
+ uniform vec4 uClampFrame;
982
+ uniform vec2 uClampOffset;
983
+
984
+ void main(void)
985
+ {
986
+ vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
987
+ coord = (uMapCoord * vec3(coord, 1.0)).xy;
988
+ vec2 unclamped = coord;
989
+ coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
990
+
991
+ vec4 texSample = texture(uSampler, coord, unclamped == coord ? 0.0f : -32.0f);// lod-bias very negative to force lod 0
992
+
993
+ fragmentColor = texSample * uColor;
994
+ }
995
+ `,s_=`#version 300 es
996
+ #define SHADER_NAME Tiling-Sprite-300
997
+
998
+ precision lowp float;
999
+
1000
+ in vec2 aVertexPosition;
1001
+ in vec2 aTextureCoord;
1002
+
1003
+ uniform mat3 projectionMatrix;
1004
+ uniform mat3 translationMatrix;
1005
+ uniform mat3 uTransform;
1006
+
1007
+ out vec2 vTextureCoord;
1008
+
1009
+ void main(void)
1010
+ {
1011
+ gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
1012
+
1013
+ vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1014
+ }
1015
+ `,n_=`#version 100
1016
+ #ifdef GL_EXT_shader_texture_lod
1017
+ #extension GL_EXT_shader_texture_lod : enable
1018
+ #endif
1019
+ #define SHADER_NAME Tiling-Sprite-100
1020
+
1021
+ precision lowp float;
1022
+
1023
+ varying vec2 vTextureCoord;
1024
+
1025
+ uniform sampler2D uSampler;
1026
+ uniform vec4 uColor;
1027
+ uniform mat3 uMapCoord;
1028
+ uniform vec4 uClampFrame;
1029
+ uniform vec2 uClampOffset;
1030
+
1031
+ void main(void)
1032
+ {
1033
+ vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
1034
+ coord = (uMapCoord * vec3(coord, 1.0)).xy;
1035
+ vec2 unclamped = coord;
1036
+ coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
1037
+
1038
+ #ifdef GL_EXT_shader_texture_lod
1039
+ vec4 texSample = unclamped == coord
1040
+ ? texture2D(uSampler, coord)
1041
+ : texture2DLodEXT(uSampler, coord, 0);
1042
+ #else
1043
+ vec4 texSample = texture2D(uSampler, coord);
1044
+ #endif
1045
+
1046
+ gl_FragColor = texSample * uColor;
1047
+ }
1048
+ `,Jc=`#version 100
1049
+ #define SHADER_NAME Tiling-Sprite-100
1050
+
1051
+ precision lowp float;
1052
+
1053
+ attribute vec2 aVertexPosition;
1054
+ attribute vec2 aTextureCoord;
1055
+
1056
+ uniform mat3 projectionMatrix;
1057
+ uniform mat3 translationMatrix;
1058
+ uniform mat3 uTransform;
1059
+
1060
+ varying vec2 vTextureCoord;
1061
+
1062
+ void main(void)
1063
+ {
1064
+ gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
1065
+
1066
+ vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1067
+ }
1068
+ `,a_=`#version 100
1069
+ #define SHADER_NAME Tiling-Sprite-Simple-100
1070
+
1071
+ precision lowp float;
1072
+
1073
+ varying vec2 vTextureCoord;
1074
+
1075
+ uniform sampler2D uSampler;
1076
+ uniform vec4 uColor;
1077
+
1078
+ void main(void)
1079
+ {
1080
+ vec4 texSample = texture2D(uSampler, vTextureCoord);
1081
+ gl_FragColor = texSample * uColor;
1082
+ }
1083
+ `;const js=new vt;class Lo extends _r{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new ka,this.state=fe.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=me.from(Jc,a_,e),this.shader=t.context.webGLVersion>1?me.from(s_,r_,e):me.from(Jc,n_,e)}render(t){const e=this.renderer,i=this.quad;let r=i.vertices;r[0]=r[6]=t._width*-t.anchor.x,r[1]=r[3]=t._height*-t.anchor.y,r[2]=r[4]=t._width*(1-t.anchor.x),r[5]=r[7]=t._height*(1-t.anchor.y);const n=t.uvRespectAnchor?t.anchor.x:0,a=t.uvRespectAnchor?t.anchor.y:0;r=i.uvs,r[0]=r[6]=-n,r[1]=r[3]=-a,r[2]=r[4]=1-n,r[5]=r[7]=1-a,i.invalidate();const o=t._texture,h=o.baseTexture,l=h.alphaMode>0,u=t.tileTransform.localTransform,c=t.uvMatrix;let d=h.isPowerOfTwo&&o.frame.width===h.width&&o.frame.height===h.height;d&&(h._glTextures[e.CONTEXT_UID]?d=h.wrapMode!==Te.CLAMP:h.wrapMode===Te.CLAMP&&(h.wrapMode=Te.REPEAT));const f=d?this.simpleShader:this.shader,p=o.width,g=o.height,m=t._width,_=t._height;js.set(u.a*p/m,u.b*p/_,u.c*g/m,u.d*g/_,u.tx/m,u.ty/_),js.invert(),d?js.prepend(c.mapCoord):(f.uniforms.uMapCoord=c.mapCoord.toArray(!0),f.uniforms.uClampFrame=c.uClampFrame,f.uniforms.uClampOffset=c.uClampOffset),f.uniforms.uTransform=js.toArray(!0),f.uniforms.uColor=gt.shared.setValue(t.tint).premultiply(t.worldAlpha,l).toArray(f.uniforms.uColor),f.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),f.uniforms.uSampler=o,e.shader.bind(f),e.geometry.bind(i),this.state.blendMode=da(t.blendMode,l),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}Lo.extension={name:"tilingSprite",type:$.RendererPlugin},Q.add(Lo);const Qc=class is{constructor(t,e,i){this.linkedSheets=[],(t instanceof lt||t instanceof j)&&(t={texture:t,data:e,resolutionFilename:i});const{texture:r,data:n,resolutionFilename:a=null,cachePrefix:o=""}=t;this.cachePrefix=o,this._texture=r instanceof j?r:null,this.baseTexture=r instanceof lt?r:this._texture.baseTexture,this.textures={},this.animations={},this.data=n;const h=this.baseTexture.resource;this.resolution=this._updateResolution(a||(h?h.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(t=null){const{scale:e}=this.data.meta;let i=Ce(t,null);return i===null&&(i=typeof e=="number"?e:parseFloat(e??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=is.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=is.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const r=this._frameKeys[e],n=this._frames[r],a=n.frame;if(a){let o=null,h=null;const l=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,u=new ut(0,0,Math.floor(l.w)/this.resolution,Math.floor(l.h)/this.resolution);n.rotated?o=new ut(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):o=new ut(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(h=new ut(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[r]=new j(this.baseTexture,o,u,h,n.rotated?2:0,n.anchor,n.borders),j.addToCache(this.textures[r],this.cachePrefix+r.toString())}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const r=t[e][i];this.animations[e].push(this.textures[r])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*is.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*is.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};Qc.BATCH_SIZE=1e3;let Oo=Qc;const o_=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function td(s,t,e){const i={};if(s.forEach(r=>{i[r]=t}),Object.keys(t.textures).forEach(r=>{i[`${t.cachePrefix}${r}`]=t.textures[r]}),!e){const r=Rt.dirname(s[0]);t.linkedSheets.forEach((n,a)=>{Object.assign(i,td([`${r}/${t.data.meta.related_multi_packs[a]}`],n,!0))})}return i}const ed={extension:$.Asset,cache:{test:s=>s instanceof Oo,getCacheableAssets:(s,t)=>td(s,t,!1)},resolver:{test:s=>{const t=s.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&o_.includes(i)},parse:s=>{var e;const t=s.split(".");return{resolution:parseFloat(((e=q.RETINA_PREFIX.exec(s))==null?void 0:e[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",extension:{type:$.LoadParser,priority:ie.Normal},async testParse(s,t){return Rt.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){var u,c;const{texture:i,imageFilename:r,cachePrefix:n}=(t==null?void 0:t.data)??{};let a=Rt.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let o;if(i&&i.baseTexture)o=i;else{const d=Bs(a+(r??s.meta.image),t.src);o=(await e.load([d]))[d]}const h=new Oo({texture:o.baseTexture,data:s,resolutionFilename:t.src,cachePrefix:n});await h.parse();const l=(u=s==null?void 0:s.meta)==null?void 0:u.related_multi_packs;if(Array.isArray(l)){const d=[];for(const p of l){if(typeof p!="string")continue;let g=a+p;(c=t.data)!=null&&c.ignoreMultiPack||(g=Bs(g,t.src),d.push(e.load({src:g,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);h.linkedSheets=f,f.forEach(p=>{p.linkedSheets=[h].concat(h.linkedSheets.filter(g=>g!==p))})}return h},unload(s){s.destroy(!0)}}};Q.add(ed);class Ur{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Gr{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const a=e[n].match(/^[a-z]+/gm)[0],o=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),h={};for(const l in o){const u=o[l].split("="),c=u[0],d=u[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;h[c]=p}i[a].push(h)}const r=new Ur;return i.info.forEach(n=>r.info.push({face:n.face,size:parseInt(n.size,10)})),i.common.forEach(n=>r.common.push({lineHeight:parseInt(n.lineHeight,10)})),i.page.forEach(n=>r.page.push({id:parseInt(n.id,10),file:n.file})),i.char.forEach(n=>r.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),i.kerning.forEach(n=>r.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),i.distanceField.forEach(n=>r.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),r}}class Ys{static test(t){const e=t;return typeof t!="string"&&"getElementsByTagName"in t&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const e=new Ur,i=t.getElementsByTagName("info"),r=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),a=t.getElementsByTagName("char"),o=t.getElementsByTagName("kerning"),h=t.getElementsByTagName("distanceField");for(let l=0;l<i.length;l++)e.info.push({face:i[l].getAttribute("face"),size:parseInt(i[l].getAttribute("size"),10)});for(let l=0;l<r.length;l++)e.common.push({lineHeight:parseInt(r[l].getAttribute("lineHeight"),10)});for(let l=0;l<n.length;l++)e.page.push({id:parseInt(n[l].getAttribute("id"),10)||0,file:n[l].getAttribute("file")});for(let l=0;l<a.length;l++){const u=a[l];e.char.push({id:parseInt(u.getAttribute("id"),10),page:parseInt(u.getAttribute("page"),10)||0,x:parseInt(u.getAttribute("x"),10),y:parseInt(u.getAttribute("y"),10),width:parseInt(u.getAttribute("width"),10),height:parseInt(u.getAttribute("height"),10),xoffset:parseInt(u.getAttribute("xoffset"),10),yoffset:parseInt(u.getAttribute("yoffset"),10),xadvance:parseInt(u.getAttribute("xadvance"),10)})}for(let l=0;l<o.length;l++)e.kerning.push({first:parseInt(o[l].getAttribute("first"),10),second:parseInt(o[l].getAttribute("second"),10),amount:parseInt(o[l].getAttribute("amount"),10)});for(let l=0;l<h.length;l++)e.distanceField.push({fieldType:h[l].getAttribute("fieldType"),distanceRange:parseInt(h[l].getAttribute("distanceRange"),10)});return e}}class qs{static test(t){return typeof t=="string"&&t.includes("<font>")?Ys.test(q.ADAPTER.parseXML(t)):!1}static parse(t){return Ys.parse(q.ADAPTER.parseXML(t))}}const ko=[Gr,Ys,qs];function id(s){for(let t=0;t<ko.length;t++)if(ko[t].test(s))return ko[t];return null}function h_(s,t,e,i,r,n){const a=e.fill;if(Array.isArray(a)){if(a.length===1)return a[0]}else return a;let o;const h=e.dropShadow?e.dropShadowDistance:0,l=e.padding||0,u=s.width/i-h-l*2,c=s.height/i-h-l*2,d=a.slice(),f=e.fillGradientStops.slice();if(!f.length){const p=d.length+1;for(let g=1;g<p;++g)f.push(g/p)}if(d.unshift(a[0]),f.unshift(0),d.push(a[a.length-1]),f.push(1),e.fillGradientType===kr.LINEAR_VERTICAL){o=t.createLinearGradient(u/2,l,u/2,c+l);let p=0;const g=(n.fontProperties.fontSize+e.strokeThickness)/c;for(let m=0;m<r.length;m++){const _=n.lineHeight*m;for(let b=0;b<d.length;b++){let y=0;typeof f[b]=="number"?y=f[b]:y=b/d.length;const E=_/c+y*g;let v=Math.max(p,E);v=Math.min(v,1),o.addColorStop(v,d[b]),p=v}}}else{o=t.createLinearGradient(l,c/2,u+l,c/2);const p=d.length+1;let g=1;for(let m=0;m<d.length;m++){let _;typeof f[m]=="number"?_=f[m]:_=g/p,o.addColorStop(_,d[m]),g++}}return o}function l_(s,t,e,i,r,n,a){const o=e.text,h=e.fontProperties;t.translate(i,r),t.scale(n,n);const l=a.strokeThickness/2,u=-(a.strokeThickness/2);if(t.font=a.toFontString(),t.lineWidth=a.strokeThickness,t.textBaseline=a.textBaseline,t.lineJoin=a.lineJoin,t.miterLimit=a.miterLimit,t.fillStyle=h_(s,t,a,n,[o],e),t.strokeStyle=a.stroke,a.dropShadow){const c=a.dropShadowColor,d=a.dropShadowBlur*n,f=a.dropShadowDistance*n;t.shadowColor=gt.shared.setValue(c).setAlpha(a.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(a.dropShadowAngle)*f,t.shadowOffsetY=Math.sin(a.dropShadowAngle)*f}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;a.stroke&&a.strokeThickness&&t.strokeText(o,l,u+e.lineHeight-h.descent),a.fill&&t.fillText(o,l,u+e.lineHeight-h.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Ks(s){return s.codePointAt?s.codePointAt(0):s.charCodeAt(0)}function rd(s){return Array.from?Array.from(s):s.split("")}function u_(s){typeof s=="string"&&(s=[s]);const t=[];for(let e=0,i=s.length;e<i;e++){const r=s[e];if(Array.isArray(r)){if(r.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${r.length}.`);const n=r[0].charCodeAt(0),a=r[1].charCodeAt(0);if(a<n)throw new Error("[BitmapFont]: Invalid character range.");for(let o=n,h=a;o<=h;o++)t.push(String.fromCharCode(o))}else t.push(...rd(r))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const si=class Le{constructor(t,e,i){var u;const[r]=t.info,[n]=t.common,[a]=t.page,[o]=t.distanceField,h=Ce(a.file),l={};this._ownsTextures=i,this.font=r.face,this.size=r.size,this.lineHeight=n.lineHeight/h,this.chars={},this.pageTextures=l;for(let c=0;c<t.page.length;c++){const{id:d,file:f}=t.page[c];l[d]=e instanceof Array?e[c]:e[f],o!=null&&o.fieldType&&o.fieldType!=="none"&&(l[d].baseTexture.alphaMode=Nt.NO_PREMULTIPLIED_ALPHA,l[d].baseTexture.mipmap=he.OFF)}for(let c=0;c<t.char.length;c++){const{id:d,page:f}=t.char[c];let{x:p,y:g,width:m,height:_,xoffset:b,yoffset:y,xadvance:E}=t.char[c];p/=h,g/=h,m/=h,_/=h,b/=h,y/=h,E/=h;const v=new ut(p+l[f].frame.x/h,g+l[f].frame.y/h,m,_);this.chars[d]={xOffset:b,yOffset:y,xAdvance:E,kerning:{},texture:new j(l[f].baseTexture,v),page:f}}for(let c=0;c<t.kerning.length;c++){let{first:d,second:f,amount:p}=t.kerning[c];d/=h,f/=h,p/=h,this.chars[f]&&(this.chars[f].kerning[d]=p)}this.distanceFieldRange=o==null?void 0:o.distanceRange,this.distanceFieldType=((u=o==null?void 0:o.fieldType)==null?void 0:u.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,i){let r;if(t instanceof Ur)r=t;else{const a=id(t);if(!a)throw new Error("Unrecognized data format for font.");r=a.parse(t)}e instanceof j&&(e=[e]);const n=new Le(r,e,i);return Le.available[n.font]=n,n}static uninstall(t){const e=Le.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete Le.available[t]}static from(t,e,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:r,padding:n,resolution:a,textureWidth:o,textureHeight:h,...l}=Object.assign({},Le.defaultOptions,i),u=u_(r),c=e instanceof ze?e:new ze(e),d=o,f=new Ur;f.info[0]={face:c.fontFamily,size:c.fontSize},f.common[0]={lineHeight:c.fontSize};let p=0,g=0,m,_,b,y=0;const E=[];for(let M=0;M<u.length;M++){m||(m=q.ADAPTER.createCanvas(),m.width=o,m.height=h,_=m.getContext("2d"),b=new lt(m,{resolution:a,...l}),E.push(new j(b)),f.page.push({id:E.length-1,file:""}));const T=u[M],P=Xe.measureText(T,c,!1,m),N=P.width,G=Math.ceil(P.height),z=Math.ceil((c.fontStyle==="italic"?2:1)*N);if(g>=h-G*a){if(g===0)throw new Error(`[BitmapFont] textureHeight ${h}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${T}')`);--M,m=null,_=null,b=null,g=0,p=0,y=0;continue}if(y=Math.max(G+P.fontProperties.descent,y),z*a+p>=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${o}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${T}')`);--M,g+=y*a,g=Math.ceil(g),p=0,y=0;continue}l_(m,_,P,p,g,a,c);const D=Ks(P.text);f.char.push({id:D,page:E.length-1,x:p/a,y:g/a,width:z,height:G,xoffset:0,yoffset:0,xadvance:N-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0)}),p+=(z+2*n)*a,p=Math.ceil(p)}if(!(i!=null&&i.skipKerning))for(let M=0,T=u.length;M<T;M++){const P=u[M];for(let N=0;N<T;N++){const G=u[N],z=_.measureText(P).width,D=_.measureText(G).width,O=_.measureText(P+G).width-(z+D);O&&f.kerning.push({first:Ks(P),second:Ks(G),amount:O})}}const v=new Le(f,E,!0);return Le.available[t]!==void 0&&Le.uninstall(t),Le.available[t]=v,v}};si.ALPHA=[["a","z"],["A","Z"]," "],si.NUMERIC=[["0","9"]],si.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],si.ASCII=[[" ","~"]],si.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:si.ALPHANUMERIC},si.available={};let We=si;var c_=`// Pixi texture info\r
1084
+ varying vec2 vTextureCoord;\r
1085
+ uniform sampler2D uSampler;\r
1086
+ \r
1087
+ // Tint\r
1088
+ uniform vec4 uColor;\r
1089
+ \r
1090
+ // on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\r
1091
+ uniform float uFWidth;\r
1092
+ \r
1093
+ void main(void) {\r
1094
+ \r
1095
+ // To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\r
1096
+ vec4 texColor = texture2D(uSampler, vTextureCoord);\r
1097
+ \r
1098
+ // MSDF\r
1099
+ float median = texColor.r + texColor.g + texColor.b -\r
1100
+ min(texColor.r, min(texColor.g, texColor.b)) -\r
1101
+ max(texColor.r, max(texColor.g, texColor.b));\r
1102
+ // SDF\r
1103
+ median = min(median, texColor.a);\r
1104
+ \r
1105
+ float screenPxDistance = uFWidth * (median - 0.5);\r
1106
+ float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\r
1107
+ if (median < 0.01) {\r
1108
+ alpha = 0.0;\r
1109
+ } else if (median > 0.99) {\r
1110
+ alpha = 1.0;\r
1111
+ }\r
1112
+ \r
1113
+ // Gamma correction for coverage-like alpha\r
1114
+ float luma = dot(uColor.rgb, vec3(0.299, 0.587, 0.114));\r
1115
+ float gamma = mix(1.0, 1.0 / 2.2, luma);\r
1116
+ float coverage = pow(uColor.a * alpha, gamma); \r
1117
+ \r
1118
+ // NPM Textures, NPM outputs\r
1119
+ gl_FragColor = vec4(uColor.rgb, coverage);\r
1120
+ }\r
1121
+ `,d_=`// Mesh material default fragment\r
1122
+ attribute vec2 aVertexPosition;\r
1123
+ attribute vec2 aTextureCoord;\r
1124
+ \r
1125
+ uniform mat3 projectionMatrix;\r
1126
+ uniform mat3 translationMatrix;\r
1127
+ uniform mat3 uTextureMatrix;\r
1128
+ \r
1129
+ varying vec2 vTextureCoord;\r
1130
+ \r
1131
+ void main(void)\r
1132
+ {\r
1133
+ gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\r
1134
+ \r
1135
+ vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
1136
+ }\r
1137
+ `;const sd=[],nd=[],ad=[],od=class df extends Vt{constructor(t,e={}){super();const{align:i,tint:r,maxWidth:n,letterSpacing:a,fontName:o,fontSize:h}=Object.assign({},df.styleDefaults,e);if(!We.available[o])throw new Error(`Missing BitmapFont "${o}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new gt(r),this._font=void 0,this._fontName=o,this._fontSize=h,this.text=t,this._maxWidth=n,this._maxLineHeight=0,this._letterSpacing=a,this._anchor=new pe(()=>{this.dirty=!0},this,0,0),this._roundPixels=q.ROUND_PIXELS,this.dirty=!0,this._resolution=q.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var z;const t=We.available[this._fontName],e=this.fontSize,i=e/t.size,r=new ft,n=[],a=[],o=[],h=this._text.replace(/(?:\r\n|\r)/g,`
1138
+ `)||" ",l=rd(h),u=this._maxWidth*t.size/e,c=t.distanceFieldType==="none"?sd:nd;let d=null,f=0,p=0,g=0,m=-1,_=0,b=0,y=0,E=0;for(let D=0;D<l.length;D++){const O=l[D],V=Ks(O);if(/(?:\s)/.test(O)&&(m=D,_=f,E++),O==="\r"||O===`
1139
+ `){a.push(f),o.push(-1),p=Math.max(p,f),++g,++b,r.x=0,r.y+=t.lineHeight,d=null,E=0;continue}const W=t.chars[V];if(!W)continue;d&&W.kerning[d]&&(r.x+=W.kerning[d]);const w=ad.pop()||{texture:j.EMPTY,line:0,charCode:0,prevSpaces:0,position:new ft};w.texture=W.texture,w.line=g,w.charCode=V,w.position.x=Math.round(r.x+W.xOffset+this._letterSpacing/2),w.position.y=Math.round(r.y+W.yOffset),w.prevSpaces=E,n.push(w),f=w.position.x+Math.max(W.xAdvance-W.xOffset,W.texture.orig.width),r.x+=W.xAdvance+this._letterSpacing,y=Math.max(y,W.yOffset+W.texture.height),d=V,m!==-1&&u>0&&r.x>u&&(++b,di(n,1+m-b,1+D-m),D=m,m=-1,a.push(_),o.push(n.length>0?n[n.length-1].prevSpaces:0),p=Math.max(p,_),g++,r.x=0,r.y+=t.lineHeight,d=null,E=0)}const v=l[l.length-1];v!=="\r"&&v!==`
1140
+ `&&(/(?:\s)/.test(v)&&(f=_),a.push(f),p=Math.max(p,f),o.push(-1));const M=[];for(let D=0;D<=g;D++){let O=0;this._align==="right"?O=p-a[D]:this._align==="center"?O=(p-a[D])/2:this._align==="justify"&&(O=o[D]<0?0:(p-a[D])/o[D]),M.push(O)}const T=n.length,P={},N=[],G=this._activePagesMeshData;c.push(...G);for(let D=0;D<T;D++){const O=n[D].texture,V=O.baseTexture.uid;if(!P[V]){let W=c.pop();if(!W){const C=new Or;let x,R;t.distanceFieldType==="none"?(x=new Hi(j.EMPTY),R=nt.NORMAL):(x=new Hi(j.EMPTY,{program:Ae.from(d_,c_),uniforms:{uFWidth:0}}),R=nt.NORMAL_NPM);const A=new Vi(C,x);A.blendMode=R,W={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:A,vertices:null,uvs:null,indices:null}}W.index=0,W.indexCount=0,W.vertexCount=0,W.uvsCount=0,W.total=0;const{_textureCache:w}=this;w[V]=w[V]||new j(O.baseTexture),W.mesh.texture=w[V],W.mesh.tint=this._tintColor.value,N.push(W),P[V]=W}P[V].total++}for(let D=0;D<G.length;D++)N.includes(G[D])||this.removeChild(G[D].mesh);for(let D=0;D<N.length;D++)N[D].mesh.parent!==this&&this.addChild(N[D].mesh);this._activePagesMeshData=N;for(const D in P){const O=P[D],V=O.total;if(!(((z=O.indices)==null?void 0:z.length)>6*V)||O.vertices.length<Vi.BATCHABLE_SIZE*2)O.vertices=new Float32Array(4*2*V),O.uvs=new Float32Array(4*2*V),O.indices=new Uint16Array(6*V);else{const W=O.total,w=O.vertices;for(let C=W*4*2;C<w.length;C++)w[C]=0}O.mesh.size=6*V}for(let D=0;D<T;D++){const O=n[D];let V=O.position.x+M[O.line]*(this._align==="justify"?O.prevSpaces:1);this._roundPixels&&(V=Math.round(V));const W=V*i,w=O.position.y*i,C=O.texture,x=P[C.baseTexture.uid],R=C.frame,A=C._uvs,S=x.index++;x.indices[S*6+0]=0+S*4,x.indices[S*6+1]=1+S*4,x.indices[S*6+2]=2+S*4,x.indices[S*6+3]=0+S*4,x.indices[S*6+4]=2+S*4,x.indices[S*6+5]=3+S*4,x.vertices[S*8+0]=W,x.vertices[S*8+1]=w,x.vertices[S*8+2]=W+R.width*i,x.vertices[S*8+3]=w,x.vertices[S*8+4]=W+R.width*i,x.vertices[S*8+5]=w+R.height*i,x.vertices[S*8+6]=W,x.vertices[S*8+7]=w+R.height*i,x.uvs[S*8+0]=A.x0,x.uvs[S*8+1]=A.y0,x.uvs[S*8+2]=A.x1,x.uvs[S*8+3]=A.y1,x.uvs[S*8+4]=A.x2,x.uvs[S*8+5]=A.y2,x.uvs[S*8+6]=A.x3,x.uvs[S*8+7]=A.y3}this._textWidth=p*i,this._textHeight=(r.y+t.lineHeight)*i;for(const D in P){const O=P[D];if(this.anchor.x!==0||this.anchor.y!==0){let C=0;const x=this._textWidth*this.anchor.x,R=this._textHeight*this.anchor.y;for(let A=0;A<O.total;A++)O.vertices[C++]-=x,O.vertices[C++]-=R,O.vertices[C++]-=x,O.vertices[C++]-=R,O.vertices[C++]-=x,O.vertices[C++]-=R,O.vertices[C++]-=x,O.vertices[C++]-=R}this._maxLineHeight=y*i;const V=O.mesh.geometry.getBuffer("aVertexPosition"),W=O.mesh.geometry.getBuffer("aTextureCoord"),w=O.mesh.geometry.getIndex();V.data=O.vertices,W.data=O.uvs,w.data=O.indices,V.update(),W.update(),w.update()}for(let D=0;D<n.length;D++)ad.push(n[D]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:e,distanceFieldType:i,size:r}=We.available[this._fontName];if(i!=="none"){const{a:n,b:a,c:o,d:h}=this.worldTransform,l=Math.sqrt(n*n+a*a),u=Math.sqrt(o*o+h*h),c=(Math.abs(l)+Math.abs(u))/2,d=this.fontSize/r,f=t._view.resolution;for(const p of this._activePagesMeshData)p.mesh.shader.uniforms.uFWidth=c*e*d*f}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=We.available[this._fontName];if(!t)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==t&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(t){if(this.tint!==t){this._tintColor.setValue(t);for(let e=0;e<this._activePagesMeshData.length;e++)this._activePagesMeshData[e].mesh.tint=t}}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.dirty=!0)}get fontName(){return this._fontName}set fontName(t){if(!We.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??We.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:e}=this,i=We.available[this._fontName].distanceFieldType==="none"?sd:nd;i.push(...this._activePagesMeshData);for(const r of this._activePagesMeshData)this.removeChild(r.mesh);this._activePagesMeshData=[],i.filter(r=>e[r.mesh.texture.baseTexture.uid]).forEach(r=>{r.mesh.texture=j.EMPTY});for(const r in e)e[r].destroy(),delete e[r];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};od.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};let f_=od;const p_=[".xml",".fnt"],hd={extension:{type:$.LoadParser,priority:ie.Normal},name:"loadBitmapFont",test(s){return p_.includes(Rt.extname(s).toLowerCase())},async testParse(s){return Gr.test(s)||qs.test(s)},async parse(s,t,e){const i=Gr.test(s)?Gr.parse(s):qs.parse(s),{src:r}=t,{page:n}=i,a=[];for(let l=0;l<n.length;++l){const u=n[l].file;let c=Rt.join(Rt.dirname(r),u);c=Bs(c,r),a.push(c)}const o=await e.load(a),h=a.map(l=>o[l]);return We.install(i,h,!0)},async load(s,t){return(await q.ADAPTER.fetch(s)).text()},unload(s){s.destroy()}};Q.add(hd);const No=class ir extends ze{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new ir(Object.keys(ir.defaultOptions).reduce((e,i)=>({...e,[i]:t[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(t=>{URL.revokeObjectURL(t.src),t.refs--,t.refs===0&&(t.fontFace&&document.fonts.delete(t.fontFace),delete ir.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=ir;if(i[t]){const r=i[t];return this._fonts.push(r),r.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return q.ADAPTER.fetch(t).then(r=>r.blob()).then(async r=>new Promise((n,a)=>{const o=URL.createObjectURL(r),h=new FileReader;h.onload=()=>n([o,h.result]),h.onerror=a,h.readAsDataURL(r)})).then(async([r,n])=>{const a=Object.assign({family:Rt.basename(t,Rt.extname(t)),weight:"normal",style:"normal",display:"auto",src:r,dataSrc:n,refs:1,originalUrl:t,fontFace:null},e);i[t]=a,this._fonts.push(a),this.styleID++;const o=new FontFace(a.family,`url(${a.src})`,{weight:a.weight,style:a.style,display:a.display});a.fontFace=o,await o.load(),document.fonts.add(o),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...t){const e=t.filter(i=>!this._overrides.includes(i));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter(i=>this._overrides.includes(i));e.length>0&&(this._overrides=this._overrides.filter(i=>!e.includes(i)),this.styleID++)}toCSS(t){return[`transform: scale(${t})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((t,e)=>`${t}
1141
+ @font-face {
1142
+ font-family: "${e.family}";
1143
+ src: url('${e.dataSrc}');
1144
+ font-weight: ${e.weight};
1145
+ font-style: ${e.style};
1146
+ font-display: ${e.display};
1147
+ }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=Dl(t)),typeof t=="number"?Rl(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),r=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${i}px ${r}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,ir.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(e=>setTimeout(e,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=q.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};No.availableFonts={},No.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let Zs=No;const Vr=class rr extends Ge{constructor(t="",e={}){super(j.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,r=j.from(i,{scaleMode:q.SCALE_MODE,resourceOptions:{autoLoad:!1}});r.orig=new ut,r.trim=new ut,this.texture=r;const n="http://www.w3.org/2000/svg",a="http://www.w3.org/1999/xhtml",o=document.createElementNS(n,"svg"),h=document.createElementNS(n,"foreignObject"),l=document.createElementNS(a,"div"),u=document.createElementNS(a,"style");h.setAttribute("width","10000"),h.setAttribute("height","10000"),h.style.overflow="hidden",o.appendChild(h),this.maxWidth=rr.defaultMaxWidth,this.maxHeight=rr.defaultMaxHeight,this._domElement=l,this._styleElement=u,this._svgRoot=o,this._foreignObject=h,this._foreignObject.appendChild(u),this._foreignObject.appendChild(l),this._image=i,this._loadImage=new Image,this._autoResolution=rr.defaultAutoResolution,this._resolution=rr.defaultResolution??q.RESOLUTION,this.text=t,this.style=e}measureText(t){var u,c;const{text:e,style:i,resolution:r}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(r)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:a,height:o}=n;(a>this.maxWidth||o>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const h=Math.min(this.maxWidth,Math.ceil(a)),l=Math.min(this.maxHeight,Math.ceil(o));return this._svgRoot.setAttribute("width",h.toString()),this._svgRoot.setAttribute("height",l.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:(u=this._style)==null?void 0:u.toCSS(r)}),this._styleElement.textContent=(c=this._style)==null?void 0:c.toGlobalCSS()),{width:h+i.padding*2,height:l+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:r}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:a}=this.measureText();i.width=r.width=Math.ceil(Math.max(1,n)),i.height=r.height=Math.ceil(Math.max(1,a)),this._updateID++;const o=this._updateID;await new Promise(h=>{r.onload=async()=>{if(o<this._updateID){h();return}await e.onBeforeDraw(),i.src=r.src,r.onload=null,r.src="",this.updateTexture(),h()};const l=new XMLSerializer().serializeToString(this._svgRoot);r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(l)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:r}=this,{padding:n}=t,{baseTexture:a}=e;e.trim.width=e._frame.width=i.width/r,e.trim.height=e._frame.height=i.height/r,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),a.setRealSize(i.width,i.height,r),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){var i,r,n,a,o;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},rr.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(r=this._svgRoot)==null||r.remove(),this._svgRoot=e,(n=this._domElement)==null||n.remove(),this._domElement=e,(a=this._foreignObject)==null||a.remove(),this._foreignObject=e,(o=this._styleElement)==null||o.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=Ne(this.scale.x)||1;this.scale.x=e*t/this._image.width/this.resolution,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(t){this.updateText(!0);const e=Ne(this.scale.y)||1;this.scale.y=e*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof Zs?(this.ownsStyle=!1,this._style=t):t instanceof ze?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Zs.from(t)):(this.ownsStyle=!0,this._style=new Zs(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")}};Vr.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Vr.defaultMaxWidth=2024,Vr.defaultMaxHeight=2024,Vr.defaultAutoResolution=!0;const m_=Object.freeze(Object.defineProperty({__proto__:null,ALPHA_MODES:Nt,AbstractMultiResource:ro,AccessibilityManager:co,AlphaFilter:ku,AnimatedSprite:$s,Application:fo,ArrayResource:Ru,Assets:Ir,AssetsClass:hc,Attribute:cr,BLEND_MODES:nt,BUFFER_BITS:rs,BUFFER_TYPE:ue,BackgroundSystem:vr,BaseImageResource:Se,BasePrepare:Ws,BaseRenderTexture:Ba,BaseTexture:lt,BatchDrawCall:ds,BatchGeometry:Sa,BatchRenderer:Ze,BatchShaderGenerator:ru,BatchSystem:Fa,BatchTextureArray:ys,BitmapFont:We,BitmapFontData:Ur,BitmapText:f_,BlobResource:bc,BlurFilter:Nu,BlurFilterPass:Is,Bounds:Cr,BrowserAdapter:Th,Buffer:At,BufferResource:ur,BufferSystem:eo,CLEAR_MODES:le,COLOR_MASK_BITS:bh,Cache:ei,CanvasResource:Du,Circle:fr,Color:gt,ColorMatrixFilter:Rs,CompressedTextureResource:ii,Container:Vt,ContextSystem:xr,CountLimiter:qc,CubeResource:Bu,DEG_TO_RAD:Wl,DRAW_MODES:oe,DisplacementFilter:Uu,DisplayObject:Et,ENV:Zt,Ellipse:pr,EventBoundary:Hu,EventSystem:Ds,ExtensionType:$,Extract:Dc,FORMATS:H,FORMATS_TO_COMPONENTS:Cc,FXAAFilter:Gu,FederatedDisplayObject:zu,FederatedEvent:Li,FederatedMouseEvent:Sr,FederatedPointerEvent:te,FederatedWheelEvent:xi,FillStyle:Lr,Filter:kt,FilterState:ou,FilterSystem:Ua,Framebuffer:vs,FramebufferSystem:Ga,GC_MODES:ss,GLFramebuffer:hu,GLProgram:yu,GLTexture:Cs,GRAPHICS_CURVES:Dg,GenerateTextureSystem:ja,Geometry:Ue,GeometrySystem:Ha,Graphics:So,GraphicsData:Br,GraphicsGeometry:Uc,HTMLText:Vr,HTMLTextStyle:Zs,IGLUniformData:$p,INSTALLED:cs,INTERNAL_FORMATS:Lt,INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:Rr,ImageBitmapResource:vi,ImageResource:La,LINE_CAP:He,LINE_JOIN:$t,LineStyle:Hs,LoaderParserPriority:ie,MASK_TYPES:It,MIPMAP_MODES:he,MSAA_QUALITY:St,MaskData:cu,MaskSystem:Xa,Matrix:vt,Mesh:Vi,MeshBatchUvs:Gc,MeshGeometry:Or,MeshMaterial:Hi,MultisampleSystem:to,NineSlicePlane:Ng,NoiseFilter:Vu,ObjectRenderer:_r,ObjectRendererSystem:io,ObservablePoint:pe,PI_2:dr,PRECISION:Xt,ParticleContainer:Vg,ParticleRenderer:Mo,PlaneGeometry:Xc,PluginSystem:Wa,Point:ft,Polygon:Ke,Prepare:Fo,Program:Ae,ProjectionSystem:$a,Quad:au,QuadUv:ka,RAD_TO_DEG:zl,RENDERER_TYPE:bn,Rectangle:ut,RenderTexture:Je,RenderTexturePool:Oa,RenderTextureSystem:Ya,Renderer:Ps,ResizePlugin:po,Resource:Di,RopeGeometry:zc,RoundedRectangle:mr,Runner:Wt,SAMPLER_TYPES:Y,SCALE_MODES:be,SHAPES:Bt,SVGResource:Ms,ScissorSystem:gu,Shader:me,ShaderSystem:qa,SimpleMesh:Ug,SimplePlane:Wc,SimpleRope:Gg,Sprite:Ge,SpriteMaskFilter:uu,Spritesheet:Oo,StartupSystem:Tr,State:fe,StateSystem:Cu,StencilSystem:za,SystemManager:Au,TARGETS:ui,TEXT_GRADIENT:kr,TYPES:it,TYPES_TO_BYTES_PER_COMPONENT:xo,TYPES_TO_BYTES_PER_PIXEL:Ac,TemporaryDisplayObject:oo,Text:Do,TextFormat:Gr,TextMetrics:Xe,TextStyle:ze,Texture:j,TextureGCSystem:Qe,TextureMatrix:Es,TextureSystem:Ka,TextureUvs:xs,Ticker:Pt,TickerPlugin:As,TilingSprite:Bo,TilingSpriteRenderer:Lo,TimeLimiter:i_,Transform:Fi,TransformFeedback:cm,TransformFeedbackSystem:Za,UPDATE_PRIORITY:Pe,UniformGroup:Qt,VERSION:dm,VideoResource:ao,ViewSystem:wr,ViewableBuffer:us,WRAP_MODES:Te,XMLFormat:Ys,XMLStringFormat:qs,accessibleTarget:Wu,autoDetectFormat:id,autoDetectRenderer:Mu,autoDetectResource:Ca,cacheTextureArray:lc,checkDataUrl:bi,checkExtension:Ve,checkMaxIfStatementsInShader:Hl,convertToList:ee,copySearchParams:Bs,createStringVariations:Zu,createTexture:Ni,createUBOElements:bu,curves:ri,defaultFilterVertex:Qa,defaultVertex:Iu,detectAvif:cc,detectCompressedTextures:xc,detectDefaults:pc,detectMp4:gc,detectOgv:_c,detectWebm:mc,detectWebp:dc,extensions:Q,filters:ho,generateProgram:vu,generateUniformBufferSync:Eu,getFontFamilyName:tc,getTestContext:Kl,getUBOData:Tu,graphicsUtils:Lg,groupD8:wt,isMobile:ce,isSingleItem:Pr,loadBitmapFont:hd,loadDDS:Pc,loadImageBitmap:nc,loadJson:Ju,loadKTX:Mc,loadSVG:ac,loadTextures:Mr,loadTxt:Qu,loadVideo:oc,loadWebFont:ec,parseDDS:Ec,parseKTX:Sc,resolveCompressedTextureUrl:Ic,resolveTextureUrl:yc,settings:q,spritesheetAsset:ed,uniformParsers:_i,unsafeEvalSupported:iu,utils:gp},Symbol.toStringTag,{value:"Module"}));var ld=function(){function s(){this.pressure=0,this.rotationAngle=0,this.twist=0,this.tangentialPressure=0,this.global=new ft,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(s.prototype,"pointerId",{get:function(){return this.identifier},enumerable:!1,configurable:!0}),s.prototype.getLocalPosition=function(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)},s.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},s.prototype.reset=function(){this.isPrimary=!1},s}();var Uo=function(s,t){return Uo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])},Uo(s,t)};function g_(s,t){Uo(s,t);function e(){this.constructor=s}s.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var __=function(){function s(){this.stopped=!1,this.stopsPropagatingAt=null,this.stopPropagationHint=!1,this.target=null,this.currentTarget=null,this.type=null,this.data=null}return s.prototype.stopPropagation=function(){this.stopped=!0,this.stopPropagationHint=!0,this.stopsPropagatingAt=this.currentTarget},s.prototype.reset=function(){this.stopped=!1,this.stopsPropagatingAt=null,this.stopPropagationHint=!1,this.currentTarget=null,this.target=null},s}(),Go=function(){function s(t){this._pointerId=t,this._flags=s.FLAGS.NONE}return s.prototype._doSet=function(t,e){e?this._flags=this._flags|t:this._flags=this._flags&~t},Object.defineProperty(s.prototype,"pointerId",{get:function(){return this._pointerId},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"flags",{get:function(){return this._flags},set:function(t){this._flags=t},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"none",{get:function(){return this._flags===s.FLAGS.NONE},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"over",{get:function(){return(this._flags&s.FLAGS.OVER)!==0},set:function(t){this._doSet(s.FLAGS.OVER,t)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"rightDown",{get:function(){return(this._flags&s.FLAGS.RIGHT_DOWN)!==0},set:function(t){this._doSet(s.FLAGS.RIGHT_DOWN,t)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"leftDown",{get:function(){return(this._flags&s.FLAGS.LEFT_DOWN)!==0},set:function(t){this._doSet(s.FLAGS.LEFT_DOWN,t)},enumerable:!1,configurable:!0}),s.FLAGS=Object.freeze({NONE:0,OVER:1,LEFT_DOWN:2,RIGHT_DOWN:4}),s}(),y_=function(){function s(){this._tempPoint=new ft}return s.prototype.recursiveFindHit=function(t,e,i,r,n){var a;if(!e||!e.visible)return!1;var o=t.data.global;n=e.interactive||n;var h=!1,l=n,u=!0;if(e.hitArea)r&&(e.worldTransform.applyInverse(o,this._tempPoint),e.hitArea.contains(this._tempPoint.x,this._tempPoint.y)?h=!0:(r=!1,u=!1)),l=!1;else if(e._mask&&r){var c=e._mask.isMaskData?e._mask.maskObject:e._mask;c&&!(!((a=c.containsPoint)===null||a===void 0)&&a.call(c,o))&&(r=!1)}if(u&&e.interactiveChildren&&e.children)for(var d=e.children,f=d.length-1;f>=0;f--){var p=d[f],g=this.recursiveFindHit(t,p,i,r,l);if(g){if(!p.parent)continue;l=!1,g&&(t.target&&(r=!1),h=!0)}}return n&&(r&&!t.target&&!e.hitArea&&e.containsPoint&&e.containsPoint(o)&&(h=!0),e.interactive&&(h&&!t.target&&(t.target=e),i&&i(t,e,!!h))),h},s.prototype.findHit=function(t,e,i,r){this.recursiveFindHit(t,e,i,r,!1)},s}(),v_={interactive:!1,interactiveChildren:!0,hitArea:null,get buttonMode(){return this.cursor==="pointer"},set buttonMode(s){s?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};Et.mixin(v_);var Js=1,Qs={target:null,data:{global:null}},x_=function(s){g_(t,s);function t(e,i){var r=s.call(this)||this;return i=i||{},r.renderer=e,r.autoPreventDefault=i.autoPreventDefault!==void 0?i.autoPreventDefault:!0,r.interactionFrequency=i.interactionFrequency||10,r.mouse=new ld,r.mouse.identifier=Js,r.mouse.global.set(-999999),r.activeInteractionData={},r.activeInteractionData[Js]=r.mouse,r.interactionDataPool=[],r.eventData=new __,r.interactionDOMElement=null,r.moveWhenInside=!1,r.eventsAdded=!1,r.tickerAdded=!1,r.mouseOverRenderer=!("PointerEvent"in globalThis),r.supportsTouchEvents="ontouchstart"in globalThis,r.supportsPointerEvents=!!globalThis.PointerEvent,r.onPointerUp=r.onPointerUp.bind(r),r.processPointerUp=r.processPointerUp.bind(r),r.onPointerCancel=r.onPointerCancel.bind(r),r.processPointerCancel=r.processPointerCancel.bind(r),r.onPointerDown=r.onPointerDown.bind(r),r.processPointerDown=r.processPointerDown.bind(r),r.onPointerMove=r.onPointerMove.bind(r),r.processPointerMove=r.processPointerMove.bind(r),r.onPointerOut=r.onPointerOut.bind(r),r.processPointerOverOut=r.processPointerOverOut.bind(r),r.onPointerOver=r.onPointerOver.bind(r),r.cursorStyles={default:"inherit",pointer:"pointer"},r.currentCursorMode=null,r.cursor=null,r.resolution=1,r.delayedEvents=[],r.search=new y_,r._tempDisplayObject=new oo,r._eventListenerOptions={capture:!0,passive:!1},r._useSystemTicker=i.useSystemTicker!==void 0?i.useSystemTicker:!0,r.setTargetElement(r.renderer.view,r.renderer.resolution),r}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,i){return Qs.target=null,Qs.data.global=e,i||(i=this.lastObjectRendered),this.processInteractive(Qs,i,null,!0),Qs.target},t.prototype.setTargetElement=function(e,i){i===void 0&&(i=1),this.removeTickerListener(),this.removeEvents(),this.interactionDOMElement=e,this.resolution=i,this.addEvents(),this.addTickerListener()},t.prototype.addTickerListener=function(){this.tickerAdded||!this.interactionDOMElement||!this._useSystemTicker||(Pt.system.add(this.tickerUpdate,this,Pe.INTERACTION),this.tickerAdded=!0)},t.prototype.removeTickerListener=function(){this.tickerAdded&&(Pt.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._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())},t.prototype.update=function(){if(this.interactionDOMElement){if(this._didMove){this._didMove=!1;return}this.cursor=null;for(var e in this.activeInteractionData)if(this.activeInteractionData.hasOwnProperty(e)){var i=this.activeInteractionData[e];if(i.originalEvent&&i.pointerType!=="touch"){var r=this.configureInteractionEventForDOMEvent(this.eventData,i.originalEvent,i);this.processInteractive(r,this.lastObjectRendered,this.processPointerOverOut,!0)}}this.setCursorMode(this.cursor)}},t.prototype.setCursorMode=function(e){e=e||"default";var i=!0;if(globalThis.OffscreenCanvas&&this.interactionDOMElement instanceof OffscreenCanvas&&(i=!1),this.currentCursorMode!==e){this.currentCursorMode=e;var r=this.cursorStyles[e];if(r)switch(typeof r){case"string":i&&(this.interactionDOMElement.style.cursor=r);break;case"function":r(e);break;case"object":i&&Object.assign(this.interactionDOMElement.style,r);break}else i&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.interactionDOMElement.style.cursor=e)}},t.prototype.dispatchEvent=function(e,i,r){(!r.stopPropagationHint||e===r.stopsPropagatingAt)&&(r.currentTarget=e,r.type=i,e.emit(i,r),e[i]&&e[i](r))},t.prototype.delayDispatchEvent=function(e,i,r){this.delayedEvents.push({displayObject:e,eventString:i,eventData:r})},t.prototype.mapPositionToPoint=function(e,i,r){var n;this.interactionDOMElement.parentElement?n=this.interactionDOMElement.getBoundingClientRect():n={x:0,y:0,width:this.interactionDOMElement.width,height:this.interactionDOMElement.height,left:0,top:0};var a=1/this.resolution;e.x=(i-n.left)*(this.interactionDOMElement.width/n.width)*a,e.y=(r-n.top)*(this.interactionDOMElement.height/n.height)*a},t.prototype.processInteractive=function(e,i,r,n){var a=this.search.findHit(e,i,r,n),o=this.delayedEvents;if(!o.length)return a;e.stopPropagationHint=!1;var h=o.length;this.delayedEvents=[];for(var l=0;l<h;l++){var u=o[l],c=u.displayObject,d=u.eventString,f=u.eventData;f.stopsPropagatingAt===c&&(f.stopPropagationHint=!0),this.dispatchEvent(c,d,f)}return a},t.prototype.onPointerDown=function(e){if(!(this.supportsTouchEvents&&e.pointerType==="touch")){var i=this.normalizeToPointerData(e);if(this.autoPreventDefault&&i[0].isNormalized){var r=e.cancelable||!("cancelable"in e);r&&e.preventDefault()}for(var n=i.length,a=0;a<n;a++){var o=i[a],h=this.getInteractionDataForPointerId(o),l=this.configureInteractionEventForDOMEvent(this.eventData,o,h);if(l.data.originalEvent=e,this.processInteractive(l,this.lastObjectRendered,this.processPointerDown,!0),this.emit("pointerdown",l),o.pointerType==="touch")this.emit("touchstart",l);else if(o.pointerType==="mouse"||o.pointerType==="pen"){var u=o.button===2;this.emit(u?"rightdown":"mousedown",this.eventData)}}}},t.prototype.processPointerDown=function(e,i,r){var n=e.data,a=e.data.identifier;if(r){if(i.trackedPointers[a]||(i.trackedPointers[a]=new Go(a)),this.dispatchEvent(i,"pointerdown",e),n.pointerType==="touch")this.dispatchEvent(i,"touchstart",e);else if(n.pointerType==="mouse"||n.pointerType==="pen"){var o=n.button===2;o?i.trackedPointers[a].rightDown=!0:i.trackedPointers[a].leftDown=!0,this.dispatchEvent(i,o?"rightdown":"mousedown",e)}}},t.prototype.onPointerComplete=function(e,i,r){var n=this.normalizeToPointerData(e),a=n.length,o=e.target;e.composedPath&&e.composedPath().length>0&&(o=e.composedPath()[0]);for(var h=o!==this.interactionDOMElement?"outside":"",l=0;l<a;l++){var u=n[l],c=this.getInteractionDataForPointerId(u),d=this.configureInteractionEventForDOMEvent(this.eventData,u,c);if(d.data.originalEvent=e,this.processInteractive(d,this.lastObjectRendered,r,i||!h),this.emit(i?"pointercancel":"pointerup"+h,d),u.pointerType==="mouse"||u.pointerType==="pen"){var f=u.button===2;this.emit(f?"rightup"+h:"mouseup"+h,d)}else u.pointerType==="touch"&&(this.emit(i?"touchcancel":"touchend"+h,d),this.releaseInteractionDataForPointerId(u.pointerId))}},t.prototype.onPointerCancel=function(e){this.supportsTouchEvents&&e.pointerType==="touch"||this.onPointerComplete(e,!0,this.processPointerCancel)},t.prototype.processPointerCancel=function(e,i){var r=e.data,n=e.data.identifier;i.trackedPointers[n]!==void 0&&(delete i.trackedPointers[n],this.dispatchEvent(i,"pointercancel",e),r.pointerType==="touch"&&this.dispatchEvent(i,"touchcancel",e))},t.prototype.onPointerUp=function(e){this.supportsTouchEvents&&e.pointerType==="touch"||this.onPointerComplete(e,!1,this.processPointerUp)},t.prototype.processPointerUp=function(e,i,r){var n=e.data,a=e.data.identifier,o=i.trackedPointers[a],h=n.pointerType==="touch",l=n.pointerType==="mouse"||n.pointerType==="pen",u=!1;if(l){var c=n.button===2,d=Go.FLAGS,f=c?d.RIGHT_DOWN:d.LEFT_DOWN,p=o!==void 0&&o.flags&f;r?(this.dispatchEvent(i,c?"rightup":"mouseup",e),p&&(this.dispatchEvent(i,c?"rightclick":"click",e),u=!0)):p&&this.dispatchEvent(i,c?"rightupoutside":"mouseupoutside",e),o&&(c?o.rightDown=!1:o.leftDown=!1)}r?(this.dispatchEvent(i,"pointerup",e),h&&this.dispatchEvent(i,"touchend",e),o&&((!l||u)&&this.dispatchEvent(i,"pointertap",e),h&&(this.dispatchEvent(i,"tap",e),o.over=!1))):o&&(this.dispatchEvent(i,"pointerupoutside",e),h&&this.dispatchEvent(i,"touchendoutside",e)),o&&o.none&&delete i.trackedPointers[a]},t.prototype.onPointerMove=function(e){if(!(this.supportsTouchEvents&&e.pointerType==="touch")){var i=this.normalizeToPointerData(e);(i[0].pointerType==="mouse"||i[0].pointerType==="pen")&&(this._didMove=!0,this.cursor=null);for(var r=i.length,n=0;n<r;n++){var a=i[n],o=this.getInteractionDataForPointerId(a),h=this.configureInteractionEventForDOMEvent(this.eventData,a,o);h.data.originalEvent=e,this.processInteractive(h,this.lastObjectRendered,this.processPointerMove,!0),this.emit("pointermove",h),a.pointerType==="touch"&&this.emit("touchmove",h),(a.pointerType==="mouse"||a.pointerType==="pen")&&this.emit("mousemove",h)}i[0].pointerType==="mouse"&&this.setCursorMode(this.cursor)}},t.prototype.processPointerMove=function(e,i,r){var n=e.data,a=n.pointerType==="touch",o=n.pointerType==="mouse"||n.pointerType==="pen";o&&this.processPointerOverOut(e,i,r),(!this.moveWhenInside||r)&&(this.dispatchEvent(i,"pointermove",e),a&&this.dispatchEvent(i,"touchmove",e),o&&this.dispatchEvent(i,"mousemove",e))},t.prototype.onPointerOut=function(e){if(!(this.supportsTouchEvents&&e.pointerType==="touch")){var i=this.normalizeToPointerData(e),r=i[0];r.pointerType==="mouse"&&(this.mouseOverRenderer=!1,this.setCursorMode(null));var n=this.getInteractionDataForPointerId(r),a=this.configureInteractionEventForDOMEvent(this.eventData,r,n);a.data.originalEvent=r,this.processInteractive(a,this.lastObjectRendered,this.processPointerOverOut,!1),this.emit("pointerout",a),r.pointerType==="mouse"||r.pointerType==="pen"?this.emit("mouseout",a):this.releaseInteractionDataForPointerId(n.identifier)}},t.prototype.processPointerOverOut=function(e,i,r){var n=e.data,a=e.data.identifier,o=n.pointerType==="mouse"||n.pointerType==="pen",h=i.trackedPointers[a];r&&!h&&(h=i.trackedPointers[a]=new Go(a)),h!==void 0&&(r&&this.mouseOverRenderer?(h.over||(h.over=!0,this.delayDispatchEvent(i,"pointerover",e),o&&this.delayDispatchEvent(i,"mouseover",e)),o&&this.cursor===null&&(this.cursor=i.cursor)):h.over&&(h.over=!1,this.dispatchEvent(i,"pointerout",this.eventData),o&&this.dispatchEvent(i,"mouseout",e),h.none&&delete i.trackedPointers[a]))},t.prototype.onPointerOver=function(e){if(!(this.supportsTouchEvents&&e.pointerType==="touch")){var i=this.normalizeToPointerData(e),r=i[0],n=this.getInteractionDataForPointerId(r),a=this.configureInteractionEventForDOMEvent(this.eventData,r,n);a.data.originalEvent=r,r.pointerType==="mouse"&&(this.mouseOverRenderer=!0),this.emit("pointerover",a),(r.pointerType==="mouse"||r.pointerType==="pen")&&this.emit("mouseover",a)}},t.prototype.getInteractionDataForPointerId=function(e){var i=e.pointerId,r;return i===Js||e.pointerType==="mouse"?r=this.mouse:this.activeInteractionData[i]?r=this.activeInteractionData[i]:(r=this.interactionDataPool.pop()||new ld,r.identifier=i,this.activeInteractionData[i]=r),r.copyEvent(e),r},t.prototype.releaseInteractionDataForPointerId=function(e){var i=this.activeInteractionData[e];i&&(delete this.activeInteractionData[e],i.reset(),this.interactionDataPool.push(i))},t.prototype.configureInteractionEventForDOMEvent=function(e,i,r){return e.data=r,this.mapPositionToPoint(r.global,i.clientX,i.clientY),i.pointerType==="touch"&&(i.globalX=r.global.x,i.globalY=r.global.y),r.originalEvent=i,e.reset(),e},t.prototype.normalizeToPointerData=function(e){var i=[];if(this.supportsTouchEvents&&e instanceof TouchEvent)for(var r=0,n=e.changedTouches.length;r<n;r++){var a=e.changedTouches[r];typeof a.button>"u"&&(a.button=e.touches.length?1:0),typeof a.buttons>"u"&&(a.buttons=e.touches.length?1:0),typeof a.isPrimary>"u"&&(a.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof a.width>"u"&&(a.width=a.radiusX||1),typeof a.height>"u"&&(a.height=a.radiusY||1),typeof a.tiltX>"u"&&(a.tiltX=0),typeof a.tiltY>"u"&&(a.tiltY=0),typeof a.pointerType>"u"&&(a.pointerType="touch"),typeof a.pointerId>"u"&&(a.pointerId=a.identifier||0),typeof a.pressure>"u"&&(a.pressure=a.force||.5),typeof a.twist>"u"&&(a.twist=0),typeof a.tangentialPressure>"u"&&(a.tangentialPressure=0),typeof a.layerX>"u"&&(a.layerX=a.offsetX=a.clientX),typeof a.layerY>"u"&&(a.layerY=a.offsetY=a.clientY),a.isNormalized=!0,i.push(a)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){var o=e;typeof o.isPrimary>"u"&&(o.isPrimary=!0),typeof o.width>"u"&&(o.width=1),typeof o.height>"u"&&(o.height=1),typeof o.tiltX>"u"&&(o.tiltX=0),typeof o.tiltY>"u"&&(o.tiltY=0),typeof o.pointerType>"u"&&(o.pointerType="mouse"),typeof o.pointerId>"u"&&(o.pointerId=Js),typeof o.pressure>"u"&&(o.pressure=.5),typeof o.twist>"u"&&(o.twist=0),typeof o.tangentialPressure>"u"&&(o.tangentialPressure=0),o.isNormalized=!0,i.push(o)}else i.push(e);return i},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:[$.RendererPlugin,$.CanvasRendererPlugin]},t}(Ee),b_=Object.defineProperty,Ei=Math.pow,T_=(s,t,e)=>t in s?b_(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,I=(s,t,e)=>(T_(s,typeof t!="symbol"?t+"":t,e),e),Ct=(s,t,e)=>new Promise((i,r)=>{var n=h=>{try{o(e.next(h))}catch(l){r(l)}},a=h=>{try{o(e.throw(h))}catch(l){r(l)}},o=h=>h.done?i(h.value):Promise.resolve(h.value).then(n,a);o((e=e.apply(s,t)).next())});const ud=2,cd=2;var tn;(s=>{s.supportMoreMaskDivisions=!0,s.setOpacityFromMotion=!1})(tn||(tn={}));const Xi={motionFadingDuration:500,idleMotionFadingDuration:2e3,expressionFadingDuration:500},xt={log(s,...t){},warn(s,...t){console.warn(`[${s}]`,...t)},error(s,...t){console.error(`[${s}]`,...t)}};function zi(s,t,e){return s<t?t:s>e?e:s}function E_(s,t){return Math.random()*(t-s)+s}function Hr(s,t,e,i,r){const n=t[i];n!==null&&typeof n===s&&(e[r]=n)}function Xr(s,t,e,i,r){const n=t[i];Array.isArray(n)&&(e[r]=n.filter(a=>a!==null&&typeof a===s))}function w_(s,t){t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(i=>{i!=="constructor"&&Object.defineProperty(s.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i))})})}function C_(s){let t=s.lastIndexOf("/");return t!=-1&&(s=s.slice(0,t)),t=s.lastIndexOf("/"),t!==-1&&(s=s.slice(t+1)),s}function A_(s,t){const e=s.indexOf(t);e!==-1&&s.splice(e,1)}class Vo extends Ee{constructor(t,e){super(),I(this,"tag"),I(this,"settings"),I(this,"expressions",[]),I(this,"defaultExpression"),I(this,"currentExpression"),I(this,"reserveExpressionIndex",-1),I(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 Ct(this,null,function*(){if(!this.definitions[t]){xt.warn(this.tag,`Undefined expression at [${t}]`);return}if(this.expressions[t]===null){xt.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 Ct(this,null,function*(){if(this.definitions.length){const t=[];for(let e=0;e<this.definitions.length;e++)this.expressions[e]!==null&&this.expressions[e]!==this.currentExpression&&e!==this.reserveExpressionIndex&&t.push(e);if(t.length){const e=Math.floor(Math.random()*t.length);return this.setExpression(e)}}return!1})}resetExpression(){this._setExpression(this.defaultExpression)}restoreExpression(){this._setExpression(this.currentExpression)}setExpression(t){return Ct(this,null,function*(){if(typeof t!="number"&&(t=this.getExpressionIndex(t)),!(t>-1&&t<this.definitions.length)||t===this.expressions.indexOf(this.currentExpression))return!1;this.reserveExpressionIndex=t;const e=yield this.loadExpression(t);return!e||this.reserveExpressionIndex!==t?!1:(this.reserveExpressionIndex=-1,this.currentExpression=e,this._setExpression(e),!0)})}update(t,e){return this.isFinished()?!1:this.updateParameters(t,e)}destroy(){this.destroyed=!0,this.emit("destroy");const t=this;t.definitions=void 0,t.expressions=void 0}}const dd=.01,S_=40/7.5,P_=1/(.15*1e3);class M_{constructor(){I(this,"targetX",0),I(this,"targetY",0),I(this,"x",0),I(this,"y",0),I(this,"vx",0),I(this,"vy",0)}focus(t,e,i=!1){this.targetX=zi(t,-1,1),this.targetY=zi(e,-1,1),i&&(this.x=this.targetX,this.y=this.targetY)}update(t){const e=this.targetX-this.x,i=this.targetY-this.y;if(Math.abs(e)<dd&&Math.abs(i)<dd)return;const r=Math.sqrt(Ei(e,2)+Ei(i,2)),n=S_/(1e3/t);let a=n*(e/r)-this.vx,o=n*(i/r)-this.vy;const h=Math.sqrt(Ei(a,2)+Ei(o,2)),l=n*P_*t;h>l&&(a*=l/h,o*=l/h),this.vx+=a,this.vy+=o;const u=Math.sqrt(Ei(this.vx,2)+Ei(this.vy,2)),c=.5*(Math.sqrt(Ei(l,2)+8*l*r)-l);u>c&&(this.vx*=c/u,this.vy*=c/u),this.x+=this.vx,this.y+=this.vy}}class en{constructor(t){I(this,"json"),I(this,"name"),I(this,"url"),I(this,"pose"),I(this,"physics"),this.json=t;const 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=C_(this.url)}resolveURL(t){return os.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<this.textures.length;e++)this.textures[e]=t(this.textures[e],`textures[${e}]`)}getDefinedFiles(){const t=[];return this.replaceFiles(e=>(t.push(e),e)),t}validateFiles(t){const e=(n,a)=>{const o=this.resolveURL(n);if(!t.includes(o)){if(a)throw new Error(`File "${n}" is defined in settings, but doesn't exist in given files`);return!1}return!0};return[this.moc,...this.textures].forEach(n=>e(n,!0)),this.getDefinedFiles().filter(n=>e(n,!1))}}var rn=(s=>(s[s.NONE=0]="NONE",s[s.IDLE=1]="IDLE",s[s.NORMAL=2]="NORMAL",s[s.FORCE=3]="FORCE",s))(rn||{});class I_{constructor(){I(this,"tag"),I(this,"debug",!1),I(this,"currentPriority",0),I(this,"reservePriority",0),I(this,"currentGroup"),I(this,"currentIndex"),I(this,"reservedGroup"),I(this,"reservedIndex"),I(this,"reservedIdleGroup"),I(this,"reservedIdleIndex")}reserve(t,e,i){if(i<=0)return xt.log(this.tag,"Cannot start a motion with MotionPriority.NONE."),!1;if(t===this.currentGroup&&e===this.currentIndex)return xt.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 xt.log(this.tag,"Motion is already reserved.",this.dump(t,e)),!1;if(i===1){if(this.currentPriority!==0)return xt.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(t,e)),!1;if(this.reservedIdleGroup!==void 0)return xt.log(this.tag,"Cannot start idle motion because another idle motion has reserved.",this.dump(t,e)),!1;this.setReservedIdle(t,e)}else{if(i<3){if(i<=this.currentPriority)return xt.log(this.tag,"Cannot start motion because another motion is playing as an equivalent or higher priority.",this.dump(t,e)),!1;if(i<=this.reservePriority)return xt.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,i)}return!0}start(t,e,i,r){if(r===1){if(this.setReservedIdle(void 0,void 0),this.currentPriority!==0)return xt.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(e,i)),!1}else{if(e!==this.reservedGroup||i!==this.reservedIndex)return xt.log(this.tag,"Cannot start motion because another motion has taken the place.",this.dump(e,i)),!1;this.setReserved(void 0,void 0,0)}return t?(this.setCurrent(e,i,r),!0):!1}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(t,e,i){this.currentPriority=i,this.currentGroup=t,this.currentIndex=e}setReserved(t,e,i){this.reservePriority=i,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!1}dump(t,e){if(this.debug){const i=["currentPriority","reservePriority","currentGroup","currentIndex","reservedGroup","reservedIndex","reservedIdleGroup","reservedIdleIndex"];return`
1148
+ <Requested> group = "${t}", index = ${e}
1149
+ `+i.map(r=>"["+r+"] "+this[r]).join(`
1150
+ `)}return""}}const R_="SoundManager",Wi=.5;class Dt{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,i,r){const n=new Audio(t);return n.volume=this._volume,n.preload="auto",n.crossOrigin=r,n.addEventListener("ended",()=>{this.dispose(n),e==null||e()}),n.addEventListener("error",a=>{this.dispose(n),xt.warn(R_,`Error occurred on "${t}"`,a.error),i==null||i(a.error)}),this.audios.push(n),n}static play(t){return new Promise((e,i)=>{var r;(r=t.play())==null||r.catch(n=>{t.dispatchEvent(new ErrorEvent("error",{error:n})),i(n)}),t.readyState===t.HAVE_ENOUGH_DATA?e():t.addEventListener("canplaythrough",e)})}static addContext(t){const e=new AudioContext;return this.contexts.push(e),e}static addAnalyzer(t,e){const i=e.createMediaElementSource(t),r=e.createAnalyser();return r.fftSize=256,r.minDecibels=-90,r.maxDecibels=-10,r.smoothingTimeConstant=.85,i.connect(r),r.connect(e.destination),this.analysers.push(r),r}static analyze(t){if(t!=null){const e=new Float32Array(t.fftSize);let i=0;t.getFloatTimeDomainData(e);for(const r of e)i+=r*r;return parseFloat(Math.sqrt(i/e.length*20).toFixed(1))}else return parseFloat(Math.random().toFixed(1))}static dispose(t){t.pause(),t.removeAttribute("src"),A_(this.audios,t)}static destroy(){for(let t=this.contexts.length-1;t>=0;t--)this.contexts[t].close();for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}}I(Dt,"audios",[]),I(Dt,"analysers",[]),I(Dt,"contexts",[]),I(Dt,"_volume",Wi);class zr extends Ee{constructor(t,e){super(),I(this,"tag"),I(this,"settings"),I(this,"motionGroups",{}),I(this,"state",new I_),I(this,"currentAudio"),I(this,"currentAnalyzer"),I(this,"currentContext"),I(this,"playing",!1),I(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 i of Object.keys(this.definitions))this.motionGroups[i]=[];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 i of e)if(this.definitions[i])for(let r=0;r<this.definitions[i].length;r++)this.loadMotion(i,r).then()}loadMotion(t,e){return Ct(this,null,function*(){var i;if(!((i=this.definitions[t])!=null&&i[e])){xt.warn(this.tag,`Undefined motion at "${t}"[${e}]`);return}if(this.motionGroups[t][e]===null){xt.warn(this.tag,`Cannot start motion at "${t}"[${e}] because it's already failed in loading.`);return}if(this.motionGroups[t][e])return this.motionGroups[t][e];const r=yield this._loadMotion(t,e);if(!this.destroyed)return this.motionGroups[t][e]=r??null,r})}_loadMotion(t,e){throw new Error("Not implemented.")}speak(t){return Ct(this,arguments,function*(e,{volume:i=Wi,expression:r,resetExpression:n=!0,crossOrigin:a,onFinish:o,onError:h}={}){let l,u,c;if(this.currentAudio&&!this.currentAudio.ended)return!1;let d;const f=e&&e.startsWith("data:");if(console.log(o),e&&!f){const g=document.createElement("a");g.href=e,e=g.href,d=e}else d="data:audio/";const p=e;if(p)try{l=Dt.add(p,(g=this)=>{console.log("Audio finished playing"),o==null||o(),n&&r&&g.expressionManager&&g.expressionManager.resetExpression(),g.currentAudio=void 0},(g,m=this)=>{console.log("Error during audio playback:",g),h==null||h(g),n&&r&&m.expressionManager&&m.expressionManager.resetExpression(),m.currentAudio=void 0},a),this.currentAudio=l,Dt.volume=i,c=Dt.addContext(this.currentAudio),this.currentContext=c,u=Dt.addAnalyzer(this.currentAudio,this.currentContext),this.currentAnalyzer=u}catch(g){return xt.warn(this.tag,"Failed to create audio",d,g),!1}if(l){let g=!0;if(yield Dt.play(l).catch(_=>{xt.warn(this.tag,"Failed to play audio",l.src,_),g=!1}),!g)return!1}return this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),r&&this.expressionManager&&this.expressionManager.setExpression(r),this.playing=!0,!0})}startMotion(t,e){return Ct(this,arguments,function*(i,r,n=rn.NORMAL,{sound:a=void 0,volume:o=Wi,expression:h=void 0,resetExpression:l=!0,crossOrigin:u,onFinish:c,onError:d}={}){var f;if(!this.state.reserve(i,r,n)||this.currentAudio&&!this.currentAudio.ended&&n!=rn.FORCE)return!1;const p=(f=this.definitions[i])==null?void 0:f[r];if(!p)return!1;this.currentAudio&&Dt.dispose(this.currentAudio);let g,m,_,b;const y=a&&a.startsWith("data:");if(a&&!y){const M=document.createElement("a");M.href=a,a=M.href,b=a}else b=this.getSoundFile(p),b&&(b=this.settings.resolveURL(b));const E=b;if(E)try{g=Dt.add(E,(M=this)=>{console.log("Audio finished playing"),c==null||c(),console.log(c),l&&h&&M.expressionManager&&M.expressionManager.resetExpression(),M.currentAudio=void 0},(M,T=this)=>{console.log("Error during audio playback:",M),d==null||d(M),l&&h&&T.expressionManager&&T.expressionManager.resetExpression(),T.currentAudio=void 0},u),this.currentAudio=g,Dt.volume=o,_=Dt.addContext(this.currentAudio),this.currentContext=_,m=Dt.addAnalyzer(this.currentAudio,this.currentContext),this.currentAnalyzer=m}catch(M){xt.warn(this.tag,"Failed to create audio",b,M)}const v=yield this.loadMotion(i,r);return g&&(yield Dt.play(g).catch(T=>xt.warn(this.tag,"Failed to play audio",g.src,T))),this.state.start(v,i,r,n)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),xt.log(this.tag,"Start motion:",this.getMotionName(p)),this.emit("motionStart",i,r,g),h&&this.expressionManager&&this.state.shouldOverrideExpression()&&this.expressionManager.setExpression(h),this.playing=!0,this._startMotion(v),!0):(g&&(Dt.dispose(g),this.currentAudio=void 0),!1)})}startRandomMotion(t,e){return Ct(this,arguments,function*(i,r,{sound:n,volume:a=Wi,expression:o,resetExpression:h=!0,crossOrigin:l,onFinish:u,onError:c}={}){const d=this.definitions[i];if(d!=null&&d.length){const f=[];for(let p=0;p<d.length;p++)this.motionGroups[i][p]!==null&&!this.state.isActive(i,p)&&f.push(p);if(f.length){const p=f[Math.floor(Math.random()*f.length)];return this.startMotion(i,p,r,{sound:n,volume:a,expression:o,resetExpression:h,crossOrigin:l,onFinish:u,onError:c})}}return!1})}stopSpeaking(){this.currentAudio&&(Dt.dispose(this.currentAudio),this.currentAudio=void 0)}stopAllMotions(){this._stopAllMotions(),this.state.reset(),this.stopSpeaking()}update(t,e){var i;return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.shouldOverrideExpression()&&((i=this.expressionManager)==null||i.restoreExpression()),this.state.complete(),this.state.shouldRequestIdleMotion()&&this.startRandomMotion(this.groups.idle,rn.IDLE)),this.updateParameters(t,e)}mouthSync(){return this.currentAnalyzer?Dt.analyze(this.currentAnalyzer):0}destroy(){var t;this.destroyed=!0,this.emit("destroy"),this.stopAllMotions(),(t=this.expressionManager)==null||t.destroy();const e=this;e.definitions=void 0,e.motionGroups=void 0}}const D_={x:0,y:0,width:0,height:0};class fd extends Ee{constructor(){super(...arguments),I(this,"focusController",new M_),I(this,"pose"),I(this,"physics"),I(this,"originalWidth",0),I(this,"originalHeight",0),I(this,"width",0),I(this,"height",0),I(this,"localTransform",new vt),I(this,"drawingMatrix",new vt),I(this,"hitAreas",{}),I(this,"textureFlipY",!1),I(this,"viewport",[0,0,0,0]),I(this,"destroyed",!1)}init(){this.setupLayout(),this.setupHitAreas()}setupLayout(){const t=this,e=this.getSize();t.originalWidth=e[0],t.originalHeight=e[1];const i=Object.assign({width:ud,height:cd},this.getLayout());this.localTransform.scale(i.width/ud,i.height/cd),t.width=this.originalWidth*this.localTransform.a,t.height=this.originalHeight*this.localTransform.d;const r=i.x!==void 0&&i.x-i.width/2||i.centerX!==void 0&&i.centerX||i.left!==void 0&&i.left-i.width/2||i.right!==void 0&&i.right+i.width/2||0,n=i.y!==void 0&&i.y-i.height/2||i.centerY!==void 0&&i.centerY||i.top!==void 0&&i.top-i.height/2||i.bottom!==void 0&&i.bottom+i.height/2||0;this.localTransform.translate(this.width*r,-this.height*n)}setupHitAreas(){const t=this.getHitAreaDefs().filter(e=>e.index>=0);for(const e of t)this.hitAreas[e.name]=e}hitTest(t,e){return Object.keys(this.hitAreas).filter(i=>this.isHit(i,t,e))}isHit(t,e,i){if(!this.hitAreas[t])return!1;const r=this.hitAreas[t].index,n=this.getDrawableBounds(r,D_);return n.x<=e&&e<=n.x+n.width&&n.y<=i&&i<=n.y+n.height}getDrawableBounds(t,e){const i=this.getDrawableVertices(t);let r=i[0],n=i[0],a=i[1],o=i[1];for(let h=0;h<i.length;h+=2){const l=i[h],u=i[h+1];r=Math.min(l,r),n=Math.max(l,n),a=Math.min(u,a),o=Math.max(u,o)}return e??(e={}),e.x=r,e.y=a,e.width=n-r,e.height=o-a,e}updateTransform(t){this.drawingMatrix.copyFrom(t).append(this.localTransform)}update(t,e){this.focusController.update(t)}destroy(){this.destroyed=!0,this.emit("destroy"),this.motionManager.destroy(),this.motionManager=void 0}}const F_="XHRLoader";class pd extends Error{constructor(t,e,i,r=!1){super(t),this.url=e,this.status=i,this.aborted=r}}const Wr=class Ht{static createXHR(t,e,i,r,n){const a=new XMLHttpRequest;if(Ht.allXhrSet.add(a),t){let o=Ht.xhrMap.get(t);o?o.add(a):(o=new Set([a]),Ht.xhrMap.set(t,o)),t.listeners("destroy").includes(Ht.cancelXHRs)||t.once("destroy",Ht.cancelXHRs)}return a.open("GET",e),a.responseType=i,a.onload=()=>{(a.status===200||a.status===0)&&a.response?r(a.response):a.onerror()},a.onerror=()=>{xt.warn(F_,`Failed to load resource as ${a.responseType} (Status ${a.status}): ${e}`),n(new pd("Network error.",e,a.status))},a.onabort=()=>n(new pd("Aborted.",e,a.status,!0)),a.onloadend=()=>{var o;Ht.allXhrSet.delete(a),t&&((o=Ht.xhrMap.get(t))==null||o.delete(a))},a}static cancelXHRs(){var t;(t=Ht.xhrMap.get(this))==null||t.forEach(e=>{e.abort(),Ht.allXhrSet.delete(e)}),Ht.xhrMap.delete(this)}static release(){Ht.allXhrSet.forEach(t=>t.abort()),Ht.allXhrSet.clear(),Ht.xhrMap=new WeakMap}};I(Wr,"xhrMap",new WeakMap),I(Wr,"allXhrSet",new Set),I(Wr,"loader",(s,t)=>new Promise((e,i)=>{Wr.createXHR(s.target,s.settings?s.settings.resolveURL(s.url):s.url,s.type,n=>{s.result=n,e()},i).send()}));let B_=Wr;function md(s,t){let e=-1;return i(0);function i(r,n){if(n)return Promise.reject(n);if(r<=e)return Promise.reject(new Error("next() called multiple times"));e=r;const a=s[r];if(!a)return Promise.resolve();try{return Promise.resolve(a(t,i.bind(null,r+1)))}catch(o){return Promise.reject(o)}}}class ni{static load(t){return md(this.middlewares,t).then(()=>t.result)}}I(ni,"middlewares",[B_.loader]);function L_(s,t={}){var e;const i={resourceOptions:{crossorigin:t.crossOrigin}};if(j.fromURL)return j.fromURL(s,i).catch(a=>{if(a instanceof Error)throw a;const o=new Error("Texture loading error");throw o.event=a,o});i.resourceOptions.autoLoad=!1;const r=j.from(s,i);if(r.baseTexture.valid)return Promise.resolve(r);const n=r.baseTexture.resource;return(e=n._live2d_load)!=null||(n._live2d_load=new Promise((a,o)=>{const h=l=>{n.source.removeEventListener("error",h);const u=new Error("Texture loading error");u.event=l,o(u)};n.source.addEventListener("error",h),n.load().then(()=>a(r)).catch(h)})),n._live2d_load}function O_(){}const gd="Live2DFactory",_d=(s,t)=>Ct(void 0,null,function*(){if(typeof s.source=="string"){const e=yield ni.load({url:s.source,type:"json",target:s.live2dModel});e.url=s.source,s.source=e,s.live2dModel.emit("settingsJSONLoaded",e)}return t()}),yd=(s,t)=>Ct(void 0,null,function*(){if(s.source instanceof en)return s.settings=s.source,t();if(typeof s.source=="object"){const e=jt.findRuntime(s.source);if(e){const i=e.createModelSettings(s.source);return s.settings=i,s.live2dModel.emit("settingsLoaded",i),t()}}throw new TypeError("Unknown settings format.")}),vd=(s,t)=>{if(s.settings){const e=jt.findRuntime(s.settings);if(e)return e.ready().then(t)}return t()},xd=(s,t)=>Ct(void 0,null,function*(){yield t();const e=s.internalModel;if(e){const i=s.settings,r=jt.findRuntime(i);if(r){const n=[];i.pose&&n.push(ni.load({settings:i,url:i.pose,type:"json",target:e}).then(a=>{e.pose=r.createPose(e.coreModel,a),s.live2dModel.emit("poseLoaded",e.pose)}).catch(a=>{s.live2dModel.emit("poseLoadError",a),xt.warn(gd,"Failed to load pose.",a)})),i.physics&&n.push(ni.load({settings:i,url:i.physics,type:"json",target:e}).then(a=>{e.physics=r.createPhysics(e.coreModel,a),s.live2dModel.emit("physicsLoaded",e.physics)}).catch(a=>{s.live2dModel.emit("physicsLoadError",a),xt.warn(gd,"Failed to load physics.",a)})),n.length&&(yield Promise.all(n))}}}),bd=(s,t)=>Ct(void 0,null,function*(){if(s.settings){const e=s.live2dModel,i=Promise.all(s.settings.textures.map(r=>{const n=s.settings.resolveURL(r);return L_(n,{crossOrigin:s.options.crossOrigin})}));if(i.catch(O_),yield t(),s.internalModel)e.internalModel=s.internalModel,e.emit("modelLoaded",s.internalModel);else throw new TypeError("Missing internal model.");e.textures=yield i,e.emit("textureLoaded",e.textures)}else throw new TypeError("Missing settings.")}),Td=(s,t)=>Ct(void 0,null,function*(){const e=s.settings;if(e instanceof en){const i=jt.findRuntime(e);if(!i)throw new TypeError("Unknown model settings.");const r=yield ni.load({settings:e,url:e.moc,type:"arraybuffer",target:s.live2dModel});if(!i.isValidMoc(r))throw new Error("Invalid moc data");const n=i.createCoreModel(r);return s.internalModel=i.createInternalModel(n,e,s.options),t()}throw new TypeError("Missing settings.")}),Gt=class sr{static unzip(t,e){return Ct(this,null,function*(){const i=yield sr.getFilePaths(t),r=[];for(const a of e.getDefinedFiles()){const o=decodeURI(os.resolve(e.url,a));i.includes(o)&&r.push(o)}const n=yield sr.getFiles(t,r);for(let a=0;a<n.length;a++){const o=r[a],h=n[a];Object.defineProperty(h,"webkitRelativePath",{value:o})}return n})}static createSettings(t){return Ct(this,null,function*(){const i=(yield sr.getFilePaths(t)).find(o=>o.endsWith("model.json")||o.endsWith("model3.json"));if(!i)throw new Error("Settings file not found");const r=yield sr.readText(t,i);if(!r)throw new Error("Empty settings file: "+i);const n=JSON.parse(r);n.url=i;const a=sr.live2dFactory.findRuntime(n);if(!a)throw new Error("Unknown settings JSON");return a.createModelSettings(n)})}static zipReader(t,e){return Ct(this,null,function*(){throw new Error("Not implemented")})}static getFilePaths(t){return Ct(this,null,function*(){throw new Error("Not implemented")})}static getFiles(t,e){return Ct(this,null,function*(){throw new Error("Not implemented")})}static readText(t,e){return Ct(this,null,function*(){throw new Error("Not implemented")})}static releaseReader(t){}};I(Gt,"live2dFactory"),I(Gt,"ZIP_PROTOCOL","zip://"),I(Gt,"uid",0),I(Gt,"factory",(s,t)=>Ct(Gt,null,function*(){const e=s.source;let i,r,n;if(typeof e=="string"&&(e.endsWith(".zip")||e.startsWith(Gt.ZIP_PROTOCOL))?(e.startsWith(Gt.ZIP_PROTOCOL)?i=e.slice(Gt.ZIP_PROTOCOL.length):i=e,r=yield ni.load({url:i,type:"blob",target:s.live2dModel})):Array.isArray(e)&&e.length===1&&e[0]instanceof File&&e[0].name.endsWith(".zip")&&(r=e[0],i=URL.createObjectURL(r),n=e.settings),r){if(!r.size)throw new Error("Empty zip file");const a=yield Gt.zipReader(r,i);n||(n=yield Gt.createSettings(a)),n._objectURL=Gt.ZIP_PROTOCOL+Gt.uid+"/"+n.url;const o=yield Gt.unzip(a,n);o.settings=n,s.source=o,i.startsWith("blob:")&&s.live2dModel.once("modelLoaded",h=>{h.once("destroy",function(){URL.revokeObjectURL(i)})}),Gt.releaseReader(a)}return t()}));let Ed=Gt;const _e=class vn{static resolveURL(t,e){var i;const r=(i=vn.filesMap[t])==null?void 0:i[e];if(r===void 0)throw new Error("Cannot find this file from uploaded files: "+e);return r}static upload(t,e){return Ct(this,null,function*(){const i={};for(const r of e.getDefinedFiles()){const n=decodeURI(os.resolve(e.url,r)),a=t.find(o=>o.webkitRelativePath===n);a&&(i[r]=URL.createObjectURL(a))}vn.filesMap[e._objectURL]=i})}static createSettings(t){return Ct(this,null,function*(){const e=t.find(o=>o.name.endsWith("model.json")||o.name.endsWith("model3.json"));if(!e)throw new TypeError("Settings file not found");const i=yield vn.readText(e),r=JSON.parse(i);r.url=e.webkitRelativePath;const n=jt.findRuntime(r);if(!n)throw new Error("Unknown settings JSON");const a=n.createModelSettings(r);return a._objectURL=URL.createObjectURL(e),a})}static readText(t){return Ct(this,null,function*(){return new Promise((e,i)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=i,r.readAsText(t,"utf8")})})}};I(_e,"live2dFactory"),I(_e,"filesMap",{}),I(_e,"factory",(s,t)=>Ct(_e,null,function*(){if(Array.isArray(s.source)&&s.source[0]instanceof File){const e=s.source;let i=e.settings;if(!i)i=yield _e.createSettings(e);else if(!i._objectURL)throw new Error('"_objectURL" must be specified in ModelSettings');i.validateFiles(e.map(r=>encodeURI(r.webkitRelativePath))),yield _e.upload(e,i),i.resolveURL=function(r){return _e.resolveURL(this._objectURL,r)},s.source=i,s.live2dModel.once("modelLoaded",r=>{r.once("destroy",function(){const n=this.settings._objectURL;if(URL.revokeObjectURL(n),_e.filesMap[n])for(const a of Object.values(_e.filesMap[n]))URL.revokeObjectURL(a);delete _e.filesMap[n]})})}return t()}));let wd=_e;const ye=class Ot{static registerRuntime(t){Ot.runtimes.push(t),Ot.runtimes.sort((e,i)=>i.version-e.version)}static findRuntime(t){for(const e of Ot.runtimes)if(e.test(t))return e}static setupLive2DModel(t,e,i){return Ct(this,null,function*(){const r=new Promise(o=>t.once("textureLoaded",o)),n=new Promise(o=>t.once("modelLoaded",o)),a=Promise.all([r,n]).then(()=>t.emit("ready"));yield md(Ot.live2DModelMiddlewares,{live2dModel:t,source:e,options:i||{}}),yield a,t.emit("load")})}static loadMotion(t,e,i){var r,n;const a=o=>t.emit("motionLoadError",e,i,o);try{const o=(r=t.definitions[e])==null?void 0:r[i];if(!o)return Promise.resolve(void 0);t.listeners("destroy").includes(Ot.releaseTasks)||t.once("destroy",Ot.releaseTasks);let h=Ot.motionTasksMap.get(t);h||(h={},Ot.motionTasksMap.set(t,h));let l=h[e];l||(l=[],h[e]=l);const u=t.getMotionFile(o);return(n=l[i])!=null||(l[i]=ni.load({url:u,settings:t.settings,type:t.motionDataType,target:t}).then(c=>{var d;const f=(d=Ot.motionTasksMap.get(t))==null?void 0:d[e];f&&delete f[i];const p=t.createMotion(c,e,o);return t.emit("motionLoaded",e,i,p),p}).catch(c=>{xt.warn(t.tag,`Failed to load motion: ${u}
1151
+ `,c),a(c)})),l[i]}catch(o){xt.warn(t.tag,`Failed to load motion at "${e}"[${i}]
1152
+ `,o),a(o)}return Promise.resolve(void 0)}static loadExpression(t,e){var i;const r=n=>t.emit("expressionLoadError",e,n);try{const n=t.definitions[e];if(!n)return Promise.resolve(void 0);t.listeners("destroy").includes(Ot.releaseTasks)||t.once("destroy",Ot.releaseTasks);let a=Ot.expressionTasksMap.get(t);a||(a=[],Ot.expressionTasksMap.set(t,a));const o=t.getExpressionFile(n);return(i=a[e])!=null||(a[e]=ni.load({url:o,settings:t.settings,type:"json",target:t}).then(h=>{const l=Ot.expressionTasksMap.get(t);l&&delete l[e];const u=t.createExpression(h,n);return t.emit("expressionLoaded",e,u),u}).catch(h=>{xt.warn(t.tag,`Failed to load expression: ${o}
1153
+ `,h),r(h)})),a[e]}catch(n){xt.warn(t.tag,`Failed to load expression at [${e}]
1154
+ `,n),r(n)}return Promise.resolve(void 0)}static releaseTasks(){this instanceof zr?Ot.motionTasksMap.delete(this):Ot.expressionTasksMap.delete(this)}};I(ye,"runtimes",[]),I(ye,"urlToJSON",_d),I(ye,"jsonToSettings",yd),I(ye,"waitUntilReady",vd),I(ye,"setupOptionals",xd),I(ye,"setupEssentials",bd),I(ye,"createInternalModel",Td),I(ye,"live2DModelMiddlewares",[Ed.factory,wd.factory,_d,yd,vd,xd,bd,Td]),I(ye,"motionTasksMap",new WeakMap),I(ye,"expressionTasksMap",new WeakMap);let jt=ye;zr.prototype._loadMotion=function(s,t){return jt.loadMotion(this,s,t)},Vo.prototype._loadExpression=function(s){return jt.loadExpression(this,s)},wd.live2dFactory=jt,Ed.live2dFactory=jt;const Cd=class vh{constructor(t,{autoUpdate:e=!0,autoHitTest:i=!0,autoFocus:r=!0,autoInteract:n,ticker:a}={}){I(this,"model"),I(this,"destroyed",!1),I(this,"_ticker"),I(this,"_autoUpdate",!1),I(this,"_autoHitTest",!1),I(this,"_autoFocus",!1),a||(vh.defaultTicker?a=vh.defaultTicker:typeof PIXI<"u"&&(a=PIXI.Ticker.shared)),n!==void 0&&(i=n,r=n,xt.warn(t.tag,"options.autoInteract is deprecated since v0.5.0, use autoHitTest and autoFocus instead.")),this.model=t,this.ticker=a,this.autoUpdate=e,this.autoHitTest=i,this.autoFocus=r,(i||r)&&(this.model.eventMode="static")}get ticker(){return this._ticker}set ticker(t){var e;this._ticker&&this._ticker.remove(sn,this),this._ticker=t,this._autoUpdate&&((e=this._ticker)==null||e.add(sn,this))}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){var e;this.destroyed||(t?this._ticker?(this._ticker.add(sn,this),this._autoUpdate=!0):xt.warn(this.model.tag,"No Ticker to be used for automatic updates. Either set option.ticker when creating Live2DModel, or expose PIXI to global scope (window.PIXI = PIXI)."):((e=this._ticker)==null||e.remove(sn,this),this._autoUpdate=!1))}get autoHitTest(){return this._autoHitTest}set autoHitTest(t){t!==this.autoHitTest&&(t?this.model.on("pointertap",Sd,this):this.model.off("pointertap",Sd,this),this._autoHitTest=t)}get autoFocus(){return this._autoFocus}set autoFocus(t){t!==this.autoFocus&&(t?this.model.on("globalpointermove",Pd,this):this.model.off("globalpointermove",Pd,this),this._autoFocus=t)}get autoInteract(){return this._autoHitTest&&this._autoFocus}set autoInteract(t){this.autoHitTest=t,this.autoFocus=t}onTickerUpdate(){const t=this.ticker.deltaMS;this.model.update(t)}onTap(t){this.model.tap(t.global.x,t.global.y)}onPointerMove(t){this.model.focus(t.global.x,t.global.y)}destroy(){this.autoFocus=!1,this.autoHitTest=!1,this.autoUpdate=!1,this.ticker=void 0,this.destroyed=!0}};I(Cd,"defaultTicker");let Ad=Cd;function sn(){this.onTickerUpdate()}function Sd(s){this.onTap(s)}function Pd(s){this.onPointerMove(s)}class k_ extends Fi{}const re=new ft,N_=new vt;class Ho extends Vt{constructor(t){super(),I(this,"tag","Live2DModel(uninitialized)"),I(this,"internalModel"),I(this,"textures",[]),I(this,"transform",new k_),I(this,"anchor",new pe(this.onAnchorChange,this,0,0)),I(this,"glContextID",-1),I(this,"elapsedTime",0),I(this,"deltaTime",0),I(this,"automator"),this.automator=new Ad(this,t),this.once("modelLoaded",()=>this.init(t))}static from(t,e){const i=new this(e);return jt.setupLive2DModel(i,t,e).then(()=>i)}static fromSync(t,e){const i=new this(e);return jt.setupLive2DModel(i,t,e).then(e==null?void 0:e.onLoad).catch(e==null?void 0:e.onError),i}static registerTicker(t){Ad.defaultTicker=t.shared}init(t){this.tag=`Live2DModel(${this.internalModel.settings.name})`}onAnchorChange(){this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(t,e,i,{sound:r=void 0,volume:n=Wi,expression:a=void 0,resetExpression:o=!0,crossOrigin:h,onFinish:l,onError:u}={}){return e===void 0?this.internalModel.motionManager.startRandomMotion(t,i,{sound:r,volume:n,expression:a,resetExpression:o,crossOrigin:h,onFinish:l,onError:u}):this.internalModel.motionManager.startMotion(t,e,i,{sound:r,volume:n,expression:a,resetExpression:o,crossOrigin:h,onFinish:l,onError:u})}stopMotions(){return this.internalModel.motionManager.stopAllMotions()}speak(t,{volume:e=Wi,expression:i,resetExpression:r=!0,crossOrigin:n,onFinish:a,onError:o}={}){return this.internalModel.motionManager.speak(t,{volume:e,expression:i,resetExpression:r,crossOrigin:n,onFinish:a,onError:o})}stopSpeaking(){return this.internalModel.motionManager.stopSpeaking()}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,i=!1){re.x=t,re.y=e,this.toModelPosition(re,re,!0);const r=re.x/this.internalModel.originalWidth*2-1,n=re.y/this.internalModel.originalHeight*2-1,a=Math.atan2(n,r);this.internalModel.focusController.focus(Math.cos(a),-Math.sin(a),i)}tap(t,e){const i=this.hitTest(t,e);i.length&&(xt.log(this.tag,"Hit",i),this.emit("hit",i))}hitTest(t,e){return re.x=t,re.y=e,this.toModelPosition(re,re),this.internalModel.hitTest(re.x,re.y)}toModelPosition(t,e=t.clone(),i){return i||(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)}update(t){this.deltaTime+=t,this.elapsedTime+=t}_render(t){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 n=0;n<this.textures.length;n++){const a=this.textures[n];a.valid&&((e||!a.baseTexture._glTextures[this.glContextID])&&(t.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL,this.internalModel.textureFlipY),t.texture.bind(a.baseTexture,0)),this.internalModel.bindTexture(n,a.baseTexture._glTextures[this.glContextID].texture),a.baseTexture.touched=t.textureGC.count)}const i=t.framebuffer.viewport;this.internalModel.viewport=[i.x,i.y,i.width,i.height],this.deltaTime&&(this.internalModel.update(this.deltaTime,this.elapsedTime),this.deltaTime=0);const r=N_.copyFrom(t.globalUniforms.uniforms.projectionMatrix).append(this.worldTransform);this.internalModel.updateTransform(r),this.internalModel.draw(t.gl),t.state.reset(),t.texture.reset()}destroy(t){this.emit("destroy"),t!=null&&t.texture&&this.textures.forEach(e=>e.destroy(t.baseTexture)),this.automator.destroy(),this.internalModel.destroy(),super.destroy(t)}}if(!window.Live2D)throw new Error("Could not find Cubism 2 runtime. This plugin requires live2d.min.js to be loaded.");const U_=Live2DMotion.prototype.updateParam;Live2DMotion.prototype.updateParam=function(s,t){U_.call(this,s,t),t.isFinished()&&this.onFinishHandler&&(this.onFinishHandler(this),delete this.onFinishHandler)};class G_ extends AMotion{constructor(t){super(),I(this,"params",[]),this.setFadeIn(t.fade_in>0?t.fade_in:Xi.expressionFadingDuration),this.setFadeOut(t.fade_out>0?t.fade_out:Xi.expressionFadingDuration),Array.isArray(t.params)&&t.params.forEach(e=>{const i=e.calc||"add";if(i==="add"){const r=e.def||0;e.val-=r}else if(i==="mult"){const r=e.def||1;e.val/=r}this.params.push({calc:i,val:e.val,id:e.id})})}updateParamExe(t,e,i,r){this.params.forEach(n=>{t.setParamFloat(n.id,n.val*i)})}}class V_ extends Vo{constructor(t,e){var i;super(t,e),I(this,"queueManager",new MotionQueueManager),I(this,"definitions"),this.definitions=(i=this.settings.expressions)!=null?i:[],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 new G_(t)}_setExpression(t){return this.queueManager.startMotion(t)}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}}class H_ extends zr{constructor(t,e){super(t,e),I(this,"definitions"),I(this,"groups",{idle:"idle"}),I(this,"motionDataType","arraybuffer"),I(this,"queueManager",new MotionQueueManager),I(this,"lipSyncIds"),I(this,"expressionManager"),this.definitions=this.settings.motions,this.init(e),this.lipSyncIds=["PARAM_MOUTH_OPEN_Y"]}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new V_(this.settings,t))}isFinished(){return this.queueManager.isFinished()}createMotion(t,e,i){const r=Live2DMotion.loadMotion(t),n=e===this.groups.idle?Xi.idleMotionFadingDuration:Xi.motionFadingDuration;return r.setFadeIn(i.fade_in>0?i.fade_in:n),r.setFadeOut(i.fade_out>0?i.fade_out:n),r}getMotionFile(t){return t.file}getMotionName(t){return t.file}getSoundFile(t){return t.sound}_startMotion(t,e){return t.onFinishHandler=e,this.queueManager.stopAllMotions(),this.queueManager.startMotion(t)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}destroy(){super.destroy(),this.queueManager=void 0}}class X_{constructor(t){I(this,"leftParam"),I(this,"rightParam"),I(this,"blinkInterval",4e3),I(this,"closingDuration",100),I(this,"closedDuration",50),I(this,"openingDuration",150),I(this,"eyeState",0),I(this,"eyeParamValue",1),I(this,"closedTimer",0),I(this,"nextBlinkTimeLeft",this.blinkInterval),this.coreModel=t,this.leftParam=t.getParamIndex("PARAM_EYE_L_OPEN"),this.rightParam=t.getParamIndex("PARAM_EYE_R_OPEN")}setEyeParams(t){this.eyeParamValue=zi(t,0,1),this.coreModel.setParamFloat(this.leftParam,this.eyeParamValue),this.coreModel.setParamFloat(this.rightParam,this.eyeParamValue)}update(t){switch(this.eyeState){case 0:this.nextBlinkTimeLeft-=t,this.nextBlinkTimeLeft<0&&(this.eyeState=1,this.nextBlinkTimeLeft=this.blinkInterval+this.closingDuration+this.closedDuration+this.openingDuration+E_(0,2e3));break;case 1:this.setEyeParams(this.eyeParamValue+t/this.closingDuration),this.eyeParamValue<=0&&(this.eyeState=2,this.closedTimer=0);break;case 2:this.closedTimer+=t,this.closedTimer>=this.closedDuration&&(this.eyeState=3);break;case 3:this.setEyeParams(this.eyeParamValue+t/this.openingDuration),this.eyeParamValue>=1&&(this.eyeState=0)}}}const wi=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class z_ extends fd{constructor(t,e,i){super(),I(this,"settings"),I(this,"coreModel"),I(this,"motionManager"),I(this,"eyeBlink"),I(this,"eyeballXParamIndex"),I(this,"eyeballYParamIndex"),I(this,"angleXParamIndex"),I(this,"angleYParamIndex"),I(this,"angleZParamIndex"),I(this,"bodyAngleXParamIndex"),I(this,"breathParamIndex"),I(this,"textureFlipY",!0),I(this,"lipSync",!0),I(this,"drawDataCount",0),I(this,"disableCulling",!1),I(this,"hasDrawn",!1),this.coreModel=t,this.settings=e,this.motionManager=new H_(e,i),this.eyeBlink=new X_(t),this.eyeballXParamIndex=t.getParamIndex("PARAM_EYE_BALL_X"),this.eyeballYParamIndex=t.getParamIndex("PARAM_EYE_BALL_Y"),this.angleXParamIndex=t.getParamIndex("PARAM_ANGLE_X"),this.angleYParamIndex=t.getParamIndex("PARAM_ANGLE_Y"),this.angleZParamIndex=t.getParamIndex("PARAM_ANGLE_Z"),this.bodyAngleXParamIndex=t.getParamIndex("PARAM_BODY_ANGLE_X"),this.breathParamIndex=t.getParamIndex("PARAM_BREATH"),this.init()}init(){super.init(),this.settings.initParams&&this.settings.initParams.forEach(({id:n,value:a})=>this.coreModel.setParamFloat(n,a)),this.settings.initOpacities&&this.settings.initOpacities.forEach(({id:n,value:a})=>this.coreModel.setPartsOpacity(n,a)),this.coreModel.saveParam();const t=this.coreModel.getModelContext()._$aS;t!=null&&t.length&&(this.drawDataCount=t.length);let e=this.coreModel.drawParamWebGL.culling;Object.defineProperty(this.coreModel.drawParamWebGL,"culling",{set:n=>e=n,get:()=>this.disableCulling?!1:e});const i=this.coreModel.getModelContext().clipManager,r=i.setupClip;i.setupClip=(n,a)=>{r.call(i,n,a),a.gl.viewport(...this.viewport)}}getSize(){return[this.coreModel.getCanvasWidth(),this.coreModel.getCanvasHeight()]}getLayout(){const t={};if(this.settings.layout)for(const[e,i]of Object.entries(this.settings.layout)){let r=e;e==="center_x"?r="centerX":e==="center_y"&&(r="centerY"),t[r]=i}return t}updateWebGLContext(t,e){const i=this.coreModel.drawParamWebGL;i.firstDraw=!0,i.setGL(t),i.glno=e;for(const[a,o]of Object.entries(i))o instanceof WebGLBuffer&&(i[a]=null);const r=this.coreModel.getModelContext().clipManager;r.curFrameNo=e;const n=t.getParameter(t.FRAMEBUFFER_BINDING);r.getMaskRenderTexture(),t.bindFramebuffer(t.FRAMEBUFFER,n)}bindTexture(t,e){this.coreModel.setTexture(t,e)}getHitAreaDefs(){var t;return((t=this.settings.hitAreas)==null?void 0:t.map(e=>({id:e.id,name:e.name,index:this.coreModel.getDrawDataIndex(e.id)})))||[]}getDrawableIDs(){const t=this.coreModel.getModelContext(),e=[];for(let i=0;i<this.drawDataCount;i++){const r=t.getDrawData(i);r&&e.push(r.getDrawDataID().id)}return e}getDrawableIndex(t){return this.coreModel.getDrawDataIndex(t)}getDrawableVertices(t){if(typeof t=="string"&&(t=this.coreModel.getDrawDataIndex(t),t===-1))throw new TypeError("Unable to find drawable ID: "+t);return this.coreModel.getTransformedPoints(t).slice()}hitTest(t,e){return this.hasDrawn||xt.warn("Trying to hit-test a Cubism 2 model that has not been rendered yet. The result will always be empty since the draw data is not ready."),super.hitTest(t,e)}update(t,e){var i,r,n,a;super.update(t,e);const o=this.coreModel;this.emit("beforeMotionUpdate");const h=this.motionManager.update(this.coreModel,e);if(this.emit("afterMotionUpdate"),o.saveParam(),(i=this.motionManager.expressionManager)==null||i.update(o,e),h||(r=this.eyeBlink)==null||r.update(t),this.updateFocus(),this.updateNaturalMovements(t,e),this.lipSync&&this.motionManager.currentAudio){let l=this.motionManager.mouthSync(),u=0;const c=1,d=1.2,f=.7;l>0&&(u=.4),l=Math.pow(l,f),l=zi(l*d,u,c);for(let p=0;p<this.motionManager.lipSyncIds.length;++p)this.coreModel.setParamFloat(this.coreModel.getParamIndex(this.motionManager.lipSyncIds[p]),l)}(n=this.physics)==null||n.update(e),(a=this.pose)==null||a.update(t),this.emit("beforeModelUpdate"),o.update(),o.loadParam()}updateFocus(){this.coreModel.addToParamFloat(this.eyeballXParamIndex,this.focusController.x),this.coreModel.addToParamFloat(this.eyeballYParamIndex,this.focusController.y),this.coreModel.addToParamFloat(this.angleXParamIndex,this.focusController.x*30),this.coreModel.addToParamFloat(this.angleYParamIndex,this.focusController.y*30),this.coreModel.addToParamFloat(this.angleZParamIndex,this.focusController.x*this.focusController.y*-30),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,this.focusController.x*10)}updateNaturalMovements(t,e){const i=e/1e3*2*Math.PI;this.coreModel.addToParamFloat(this.angleXParamIndex,15*Math.sin(i/6.5345)*.5),this.coreModel.addToParamFloat(this.angleYParamIndex,8*Math.sin(i/3.5345)*.5),this.coreModel.addToParamFloat(this.angleZParamIndex,10*Math.sin(i/5.5345)*.5),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,4*Math.sin(i/15.5345)*.5),this.coreModel.setParamFloat(this.breathParamIndex,.5+.5*Math.sin(i/3.2345))}draw(t){const e=this.disableCulling;t.getParameter(t.FRAMEBUFFER_BINDING)&&(this.disableCulling=!0);const i=this.drawingMatrix;wi[0]=i.a,wi[1]=i.b,wi[4]=i.c,wi[5]=i.d,wi[12]=i.tx,wi[13]=i.ty,this.coreModel.setMatrix(wi),this.coreModel.draw(),this.hasDrawn=!0,this.disableCulling=e}destroy(){super.destroy(),this.coreModel=void 0}}class $r extends en{constructor(t){if(super(t),I(this,"moc"),I(this,"textures"),I(this,"layout"),I(this,"hitAreas"),I(this,"initParams"),I(this,"initOpacities"),I(this,"expressions"),I(this,"motions",{}),!$r.isValidJSON(t))throw new TypeError("Invalid JSON.");this.moc=t.model,Xr("string",t,this,"textures","textures"),this.copy(t)}static isValidJSON(t){var e;return!!t&&typeof t.model=="string"&&((e=t.textures)==null?void 0:e.length)>0&&t.textures.every(i=>typeof i=="string")}copy(t){Hr("string",t,this,"name","name"),Hr("string",t,this,"pose","pose"),Hr("string",t,this,"physics","physics"),Hr("object",t,this,"layout","layout"),Hr("object",t,this,"motions","motions"),Xr("object",t,this,"hit_areas","hitAreas"),Xr("object",t,this,"expressions","expressions"),Xr("object",t,this,"init_params","initParams"),Xr("object",t,this,"init_opacities","initOpacities")}replaceFiles(t){super.replaceFiles(t);for(const[e,i]of Object.entries(this.motions))for(let r=0;r<i.length;r++)i[r].file=t(i[r].file,`motions.${e}[${r}].file`),i[r].sound!==void 0&&(i[r].sound=t(i[r].sound,`motions.${e}[${r}].sound`));if(this.expressions)for(let e=0;e<this.expressions.length;e++)this.expressions[e].file=t(this.expressions[e].file,`expressions[${e}].file`)}}const W_={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE},$_={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE};class j_{constructor(t,e){I(this,"physicsHairs",[]),this.coreModel=t,e.physics_hair&&(this.physicsHairs=e.physics_hair.map(i=>{const r=new PhysicsHair;return r.setup(i.setup.length,i.setup.regist,i.setup.mass),i.src.forEach(({id:n,ptype:a,scale:o,weight:h})=>{const l=W_[a];l&&r.addSrcParam(l,n,o,h)}),i.targets.forEach(({id:n,ptype:a,scale:o,weight:h})=>{const l=$_[a];l&&r.addTargetParam(l,n,o,h)}),r}))}update(t){this.physicsHairs.forEach(e=>e.update(this.coreModel,t))}}class Md{constructor(t){I(this,"paramIndex",-1),I(this,"partsIndex",-1),I(this,"link",[]),this.id=t}initIndex(t){this.paramIndex=t.getParamIndex("VISIBLE:"+this.id),this.partsIndex=t.getPartsDataIndex(PartsDataID.getID(this.id)),t.setParamFloat(this.paramIndex,1)}}class Y_{constructor(t,e){I(this,"opacityAnimDuration",500),I(this,"partsGroups",[]),this.coreModel=t,e.parts_visible&&(this.partsGroups=e.parts_visible.map(({group:i})=>i.map(({id:r,link:n})=>{const a=new Md(r);return n&&(a.link=n.map(o=>new Md(o))),a})),this.init())}init(){this.partsGroups.forEach(t=>{t.forEach(e=>{if(e.initIndex(this.coreModel),e.paramIndex>=0){const i=this.coreModel.getParamFloat(e.paramIndex)!==0;this.coreModel.setPartsOpacity(e.partsIndex,i?1:0),this.coreModel.setParamFloat(e.paramIndex,i?1:0),e.link.length>0&&e.link.forEach(r=>r.initIndex(this.coreModel))}})})}normalizePartsOpacityGroup(t,e){const i=this.coreModel,r=.5,n=.15;let a=1,o=t.findIndex(({paramIndex:h,partsIndex:l})=>l>=0&&i.getParamFloat(h)!==0);if(o>=0){const h=i.getPartsOpacity(t[o].partsIndex);a=zi(h+e/this.opacityAnimDuration,0,1)}else o=0,a=1;t.forEach(({partsIndex:h},l)=>{if(h>=0)if(o==l)i.setPartsOpacity(h,a);else{let u=i.getPartsOpacity(h),c;a<r?c=a*(r-1)/r+1:c=(1-a)*r/(1-r),(1-c)*(1-a)>n&&(c=1-n/(1-a)),u>c&&(u=c),i.setPartsOpacity(h,u)}})}copyOpacity(t){const e=this.coreModel;t.forEach(({partsIndex:i,link:r})=>{if(i>=0&&r){const n=e.getPartsOpacity(i);r.forEach(({partsIndex:a})=>{a>=0&&e.setPartsOpacity(a,n)})}})}update(t){this.partsGroups.forEach(e=>{this.normalizePartsOpacityGroup(e,t),this.copyOpacity(e)})}}if(jt.registerRuntime({version:2,test(s){return s instanceof $r||$r.isValidJSON(s)},ready(){return Promise.resolve()},isValidMoc(s){if(s.byteLength<3)return!1;const t=new Int8Array(s,0,3);return String.fromCharCode(...t)==="moc"},createModelSettings(s){return new $r(s)},createCoreModel(s){const t=Live2DModelWebGL.loadModel(s),e=Live2D.getError();if(e)throw e;return t},createInternalModel(s,t,e){return new z_(s,t,e)},createPose(s,t){return new Y_(s,t)},createPhysics(s,t){return new j_(s,t)}}),!window.Live2DCubismCore)throw new Error("Could not find Cubism 4 runtime. This plugin requires live2dcubismcore.js to be loaded.");class at{constructor(t,e){this.x=t||0,this.y=e||0}add(t){const e=new at(0,0);return e.x=this.x+t.x,e.y=this.y+t.y,e}substract(t){const e=new at(0,0);return e.x=this.x-t.x,e.y=this.y-t.y,e}multiply(t){const e=new at(0,0);return e.x=this.x*t.x,e.y=this.y*t.y,e}multiplyByScaler(t){return this.multiply(new at(t,t))}division(t){const e=new at(0,0);return e.x=this.x/t.x,e.y=this.y/t.y,e}divisionByScalar(t){return this.division(new at(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 Id=class xn{static range(t,e,i){return t<e?t=e:t>i&&(t=i),t}static sin(t){return Math.sin(t)}static cos(t){return Math.cos(t)}static abs(t){return Math.abs(t)}static sqrt(t){return Math.sqrt(t)}static cbrt(t){if(t===0)return t;let e=t;const i=e<0;i&&(e=-e);let r;return e===1/0?r=1/0:(r=Math.exp(Math.log(e)/3),r=(e/(r*r)+2*r)/3),i?-r:r}static getEasingSine(t){return t<0?0:t>1?1:.5-.5*this.cos(t*Math.PI)}static max(t,e){return t>e?t:e}static min(t,e){return t>e?e:t}static degreesToRadian(t){return t/180*Math.PI}static radianToDegrees(t){return t*180/Math.PI}static directionToRadian(t,e){const i=Math.atan2(e.y,e.x),r=Math.atan2(t.y,t.x);let n=i-r;for(;n<-Math.PI;)n+=Math.PI*2;for(;n>Math.PI;)n-=Math.PI*2;return n}static directionToDegrees(t,e){const i=this.directionToRadian(t,e);let r=this.radianToDegrees(i);return e.x-t.x>0&&(r=-r),r}static radianToDirection(t){const e=new at;return e.x=this.sin(t),e.y=this.cos(t),e}static quadraticEquation(t,e,i){return this.abs(t)<xn.Epsilon?this.abs(e)<xn.Epsilon?-i:-i/e:-(e+this.sqrt(e*e-4*t*i))/(2*t)}static cardanoAlgorithmForBezier(t,e,i,r){if(this.sqrt(t)<xn.Epsilon)return this.range(this.quadraticEquation(e,i,r),0,1);const n=e/t,a=i/t,o=r/t,h=(3*a-n*n)/3,l=h/3,u=(2*n*n*n-9*n*a+27*o)/27,c=u/2,d=c*c+l*l*l,f=.5,p=f+.01;if(d<0){const y=-h/3,E=y*y*y,v=this.sqrt(E),M=-u/(2*v),T=this.range(M,-1,1),P=Math.acos(T),G=2*this.cbrt(v),z=G*this.cos(P/3)-n/3;if(this.abs(z-f)<p)return this.range(z,0,1);const D=G*this.cos((P+2*Math.PI)/3)-n/3;if(this.abs(D-f)<p)return this.range(D,0,1);const O=G*this.cos((P+4*Math.PI)/3)-n/3;return this.range(O,0,1)}if(d==0){let y;c<0?y=this.cbrt(-c):y=-this.cbrt(c);const E=2*y-n/3;if(this.abs(E-f)<p)return this.range(E,0,1);const v=-y-n/3;return this.range(v,0,1)}const g=this.sqrt(d),m=this.cbrt(g-c),_=this.cbrt(g+c),b=m-_-n/3;return this.range(b,0,1)}constructor(){}};Id.Epsilon=1e-5;let mt=Id;class se{constructor(){this._tr=new Float32Array(16),this.loadIdentity()}static multiply(t,e,i){const r=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),n=4;for(let a=0;a<n;++a)for(let o=0;o<n;++o)for(let h=0;h<n;++h)r[o+a*4]+=t[h+a*4]*e[o+h*4];for(let a=0;a<16;++a)i[a]=r[a]}loadIdentity(){const t=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);this.setMatrix(t)}setMatrix(t){for(let e=0;e<16;++e)this._tr[e]=t[e]}getArray(){return this._tr}getScaleX(){return this._tr[0]}getScaleY(){return this._tr[5]}getTranslateX(){return this._tr[12]}getTranslateY(){return this._tr[13]}transformX(t){return this._tr[0]*t+this._tr[12]}transformY(t){return this._tr[5]*t+this._tr[13]}invertTransformX(t){return(t-this._tr[12])/this._tr[0]}invertTransformY(t){return(t-this._tr[13])/this._tr[5]}translateRelative(t,e){const i=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,t,e,0,1]);se.multiply(i,this._tr,this._tr)}translate(t,e){this._tr[12]=t,this._tr[13]=e}translateX(t){this._tr[12]=t}translateY(t){this._tr[13]=t}scaleRelative(t,e){const i=new Float32Array([t,0,0,0,0,e,0,0,0,0,1,0,0,0,0,1]);se.multiply(i,this._tr,this._tr)}scale(t,e){this._tr[0]=t,this._tr[5]=e}multiplyByMatrix(t){se.multiply(t.getArray(),this._tr,this._tr)}clone(){const t=new se;for(let e=0;e<this._tr.length;e++)t._tr[e]=this._tr[e];return t}}class Xo{initialize(t){this._model=t}drawModel(){this.getModel()!=null&&(this.saveProfile(),this.doDrawModel(),this.restoreProfile())}setMvpMatrix(t){this._mvpMatrix4x4.setMatrix(t.getArray())}getMvpMatrix(){return this._mvpMatrix4x4}setModelColor(t,e,i,r){t<0?t=0:t>1&&(t=1),e<0?e=0:e>1&&(e=1),i<0?i=0:i>1&&(i=1),r<0?r=0:r>1&&(r=1),this._modelColor.R=t,this._modelColor.G=e,this._modelColor.B=i,this._modelColor.A=r}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._anisotropy=t}getAnisotropy(){return this._anisotropy}getModel(){return this._model}useHighPrecisionMask(t){this._useHighPrecisionMask=t}isUsingHighPrecisionMask(){return this._useHighPrecisionMask}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisotropy=0,this._modelColor=new Yt,this._useHighPrecisionMask=!1,this._mvpMatrix4x4=new se,this._mvpMatrix4x4.loadIdentity()}}var $e=(s=>(s[s.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",s[s.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",s[s.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",s))($e||{});class Yt{constructor(t=1,e=1,i=1,r=1){this.R=t,this.G=e,this.B=i,this.A=r}}let Re=!1,$i=!1,ji;const zo={vertexOffset:0,vertexStep:2};class jr{static startUp(t){if(Re)return Yr("CubismFramework.startUp() is already done."),Re;if(Live2DCubismCore._isStarted)return Re=!0,!0;if(Live2DCubismCore._isStarted=!0,ji=t,ji&&Live2DCubismCore.Logging.csmSetLogFunction(ji.logFunction),Re=!0,Re){const e=Live2DCubismCore.Version.csmGetVersion(),i=(e&4278190080)>>24,r=(e&16711680)>>16,n=e&65535,a=e;Yr("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+i).slice(-2),("00"+r).slice(-2),("0000"+n).slice(-4),a)}return Yr("CubismFramework.startUp() is complete."),Re}static cleanUp(){Re=!1,$i=!1,ji=void 0}static initialize(t=0){if(!Re){Ci("CubismFramework is not started.");return}if($i){Ci("CubismFramework.initialize() skipped, already initialized.");return}Live2DCubismCore.Memory.initializeAmountOfMemory(t),$i=!0,Yr("CubismFramework.initialize() is complete.")}static dispose(){if(!Re){Ci("CubismFramework is not started.");return}if(!$i){Ci("CubismFramework.dispose() skipped, not initialized.");return}Xo.staticRelease(),$i=!1,Yr("CubismFramework.dispose() is complete.")}static isStarted(){return Re}static isInitialized(){return $i}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return ji!=null?ji.loggingLevel:5}constructor(){}}var Yi=(s=>(s[s.LogLevel_Verbose=0]="LogLevel_Verbose",s[s.LogLevel_Debug=1]="LogLevel_Debug",s[s.LogLevel_Info=2]="LogLevel_Info",s[s.LogLevel_Warning=3]="LogLevel_Warning",s[s.LogLevel_Error=4]="LogLevel_Error",s[s.LogLevel_Off=5]="LogLevel_Off",s))(Yi||{});const qi=typeof process<"u"&&process.env.NODE_ENV==="production"?()=>{}:s=>console.assert(s);function Rd(s,...t){nn.print(Yi.LogLevel_Debug,"[CSM][D]"+s+`
1155
+ `,t)}function Yr(s,...t){nn.print(Yi.LogLevel_Info,"[CSM][I]"+s+`
1156
+ `,t)}function Ci(s,...t){nn.print(Yi.LogLevel_Warning,"[CSM][W]"+s+`
1157
+ `,t)}function De(s,...t){nn.print(Yi.LogLevel_Error,"[CSM][E]"+s+`
1158
+ `,t)}class nn{static print(t,e,i){if(t<jr.getLoggingLevel())return;const r=jr.coreLogFunction;if(!r)return;const n=e.replace(/{(\d+)}/g,(a,o)=>i[o]);r(n)}static dumpBytes(t,e,i){for(let r=0;r<i;r++)r%16==0&&r>0?this.print(t,`
1159
+ `):r%8==0&&r>0&&this.print(t," "),this.print(t,"{0} ",[e[r]&255]);this.print(t,`
1160
+ `)}constructor(){}}class Dd{constructor(){this._fadeInSeconds=-1,this._fadeOutSeconds=-1,this._weight=1,this._offsetSeconds=0,this._firedEventValues=[]}release(){this._weight=0}updateParameters(t,e,i){if(!e.isAvailable()||e.isFinished())return;if(!e.isStarted()){e.setIsStarted(!0),e.setStartTime(i-this._offsetSeconds),e.setFadeInStartTime(i);const o=this.getDuration();e.getEndTime()<0&&e.setEndTime(o<=0?-1:e.getStartTime()+o)}let r=this._weight;const n=this._fadeInSeconds==0?1:mt.getEasingSine((i-e.getFadeInStartTime())/this._fadeInSeconds),a=this._fadeOutSeconds==0||e.getEndTime()<0?1:mt.getEasingSine((e.getEndTime()-i)/this._fadeOutSeconds);r=r*n*a,e.setState(i,r),qi(0<=r&&r<=1),this.doUpdateParameters(t,i,r,e),e.getEndTime()>0&&e.getEndTime()<i&&e.setIsFinished(!0)}setFadeInTime(t){this._fadeInSeconds=t}setFadeOutTime(t){this._fadeOutSeconds=t}getFadeOutTime(){return this._fadeOutSeconds}getFadeInTime(){return this._fadeInSeconds}setWeight(t){this._weight=t}getWeight(){return this._weight}getDuration(){return-1}getLoopDuration(){return-1}setOffsetTime(t){this._offsetSeconds=t}getFiredEvent(t,e){return this._firedEventValues}setFinishedMotionHandler(t){this._onFinishedMotion=t}getFinishedMotionHandler(){return this._onFinishedMotion}isExistModelOpacity(){return!1}getModelOpacityIndex(){return-1}getModelOpacityId(t){}getModelOpacityValue(){return 1}}const Fd=1;class Wo extends Dd{static create(t){const e=new Wo;return e.parse(t),e}doUpdateParameters(t,e,i,r){for(let n=0;n<this._parameters.length;++n){const a=this._parameters[n];switch(a.blendType){case 0:{t.addParameterValueById(a.parameterId,a.value,i);break}case 1:{t.multiplyParameterValueById(a.parameterId,a.value,i);break}case 2:{t.setParameterValueById(a.parameterId,a.value,i);break}}}}parse(t){this.setFadeInTime(t.FadeInTime!=null?t.FadeInTime:Fd),this.setFadeOutTime(t.FadeOutTime!=null?t.FadeOutTime:Fd);const e=(t.Parameters||[]).length;for(let i=0;i<e;++i){const r=t.Parameters[i],n=r.Id,a=r.Value;let o;!r.Blend||r.Blend==="Add"?o=0:r.Blend==="Multiply"?o=1:r.Blend==="Overwrite"?o=2:o=0;const h={parameterId:n,blendType:o,value:a};this._parameters.push(h)}}constructor(){super(),this._parameters=[]}}class q_{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 i=e+t;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||i<this._endTimeSeconds)&&(this._endTimeSeconds=i)}isFinished(){return this._finished}isStarted(){return this._started}getStartTime(){return this._startTimeSeconds}getFadeInStartTime(){return this._fadeInStartTimeSeconds}getEndTime(){return this._endTimeSeconds}setStartTime(t){this._startTimeSeconds=t}setFadeInStartTime(t){this._fadeInStartTimeSeconds=t}setEndTime(t){this._endTimeSeconds=t}setIsFinished(t){this._finished=t}setIsStarted(t){this._started=t}isAvailable(){return this._available}setIsAvailable(t){this._available=t}setState(t,e){this._stateTimeSeconds=t,this._stateWeight=e}getStateTime(){return this._stateTimeSeconds}getStateWeight(){return this._stateWeight}getLastCheckEventSeconds(){return this._lastEventCheckSeconds}setLastCheckEventSeconds(t){this._lastEventCheckSeconds=t}isTriggeredFadeOut(){return this._isTriggeredFadeOut}getFadeOutSeconds(){return this._fadeOutSeconds}}class Bd{constructor(){this._userTimeSeconds=0,this._eventCustomData=null,this._motions=[]}release(){for(let t=0;t<this._motions.length;++t)this._motions[t]&&this._motions[t].release();this._motions=void 0}startMotion(t,e,i){if(t==null)return K_;let r;for(let n=0;n<this._motions.length;++n)r=this._motions[n],r!=null&&r.setFadeOut(r._motion.getFadeOutTime());return r=new q_,r._autoDelete=e,r._motion=t,this._motions.push(r),r._motionQueueEntryHandle}isFinished(){let t=0;for(;t<this._motions.length;){const e=this._motions[t];if(e==null){this._motions.splice(t,1);continue}if(e._motion==null){e.release(),this._motions.splice(t,1);continue}if(!e.isFinished())return!1;t++}return!0}isFinishedByHandle(t){for(let e=0;e<this._motions.length;e++){const i=this._motions[e];if(i!=null&&i._motionQueueEntryHandle==t&&!i.isFinished())return!1}return!0}stopAllMotions(){for(let t=0;t<this._motions.length;t++){const e=this._motions[t];e!=null&&e.release()}this._motions=[]}getCubismMotionQueueEntry(t){return this._motions.find(e=>e!=null&&e._motionQueueEntryHandle==t)}setEventCallback(t,e=null){this._eventCallBack=t,this._eventCustomData=e}doUpdateMotion(t,e){let i=!1,r=0;for(;r<this._motions.length;){const n=this._motions[r];if(n==null){this._motions.splice(r,1);continue}const a=n._motion;if(a==null){n.release(),this._motions.splice(r,1);continue}a.updateParameters(t,n,e),i=!0;const o=a.getFiredEvent(n.getLastCheckEventSeconds()-n.getStartTime(),e-n.getStartTime());for(let h=0;h<o.length;++h)this._eventCallBack(this,o[h],this._eventCustomData);n.setLastCheckEventSeconds(e),n.isFinished()?(n.release(),this._motions.splice(r,1)):(n.isTriggeredFadeOut()&&n.startFadeOut(n.getFadeOutSeconds(),e),r++)}return i}}const K_=-1;class Z_ extends Vo{constructor(t,e){var i;super(t,e),I(this,"queueManager",new Bd),I(this,"definitions"),this.definitions=(i=t.expressions)!=null?i:[],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 Wo.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)}}var Fe=(s=>(s[s.CubismMotionCurveTarget_Model=0]="CubismMotionCurveTarget_Model",s[s.CubismMotionCurveTarget_Parameter=1]="CubismMotionCurveTarget_Parameter",s[s.CubismMotionCurveTarget_PartOpacity=2]="CubismMotionCurveTarget_PartOpacity",s))(Fe||{}),Be=(s=>(s[s.CubismMotionSegmentType_Linear=0]="CubismMotionSegmentType_Linear",s[s.CubismMotionSegmentType_Bezier=1]="CubismMotionSegmentType_Bezier",s[s.CubismMotionSegmentType_Stepped=2]="CubismMotionSegmentType_Stepped",s[s.CubismMotionSegmentType_InverseStepped=3]="CubismMotionSegmentType_InverseStepped",s))(Be||{});class ai{constructor(t=0,e=0){this.time=t,this.value=e}}class J_{constructor(){this.basePointIndex=0,this.segmentType=0}}class Q_{constructor(){this.id="",this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}}class ty{constructor(){this.fireTime=0,this.value=""}}class ey{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 Ld{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 t==0?!!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 Od=(s=>(s[s.EvaluationOptionFlag_AreBeziersRistricted=0]="EvaluationOptionFlag_AreBeziersRistricted",s))(Od||{});const iy="EyeBlink",ry="LipSync",sy="Model",ny="Parameter",ay="PartOpacity",an="Opacity",oy=!1;function ne(s,t,e){const i=new ai;return i.time=s.time+(t.time-s.time)*e,i.value=s.value+(t.value-s.value)*e,i}function hy(s,t){let e=(t-s[0].time)/(s[1].time-s[0].time);return e<0&&(e=0),s[0].value+(s[1].value-s[0].value)*e}function ly(s,t){let e=(t-s[0].time)/(s[3].time-s[0].time);e<0&&(e=0);const i=ne(s[0],s[1],e),r=ne(s[1],s[2],e),n=ne(s[2],s[3],e),a=ne(i,r,e),o=ne(r,n,e);return ne(a,o,e).value}function uy(s,t){const e=t,i=s[0].time,r=s[3].time,n=s[1].time,a=s[2].time,o=r-3*a+3*n-i,h=3*a-6*n+3*i,l=3*n-3*i,u=i-e,c=mt.cardanoAlgorithmForBezier(o,h,l,u),d=ne(s[0],s[1],c),f=ne(s[1],s[2],c),p=ne(s[2],s[3],c),g=ne(d,f,c),m=ne(f,p,c);return ne(g,m,c).value}function cy(s,t){return s[0].value}function dy(s,t){return s[1].value}function $o(s,t,e){const i=s.curves[t];let r=-1;const n=i.baseSegmentIndex+i.segmentCount;let a=0;for(let h=i.baseSegmentIndex;h<n;++h)if(a=s.segments[h].basePointIndex+(s.segments[h].segmentType==Be.CubismMotionSegmentType_Bezier?3:1),s.points[a].time>e){r=h;break}if(r==-1)return s.points[a].value;const o=s.segments[r];return o.evaluate(s.points.slice(o.basePointIndex),e)}class jo extends Dd{constructor(){super(),this._eyeBlinkParameterIds=[],this._lipSyncParameterIds=[],this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0,this._modelOpacity=1}static create(t,e){const i=new jo;return i.parse(t),i._sourceFrameRate=i._motionData.fps,i._loopDurationSeconds=i._motionData.duration,i._onFinishedMotion=e,i}doUpdateParameters(t,e,i,r){this._modelCurveIdEyeBlink==null&&(this._modelCurveIdEyeBlink=iy),this._modelCurveIdLipSync==null&&(this._modelCurveIdLipSync=ry),this._modelCurveIdOpacity==null&&(this._modelCurveIdOpacity=an);let n=e-r.getStartTime();n<0&&(n=0);let a=Number.MAX_VALUE,o=Number.MAX_VALUE;const h=64;let l=0,u=0;this._eyeBlinkParameterIds.length>h&&Rd("too many eye blink targets : {0}",this._eyeBlinkParameterIds.length),this._lipSyncParameterIds.length>h&&Rd("too many lip sync targets : {0}",this._lipSyncParameterIds.length);const c=this._fadeInSeconds<=0?1:mt.getEasingSine((e-r.getFadeInStartTime())/this._fadeInSeconds),d=this._fadeOutSeconds<=0||r.getEndTime()<0?1:mt.getEasingSine((r.getEndTime()-e)/this._fadeOutSeconds);let f,p,g,m=n;if(this._isLoop)for(;m>this._motionData.duration;)m-=this._motionData.duration;const _=this._motionData.curves;for(p=0;p<this._motionData.curveCount&&_[p].type==Fe.CubismMotionCurveTarget_Model;++p)f=$o(this._motionData,p,m),_[p].id==this._modelCurveIdEyeBlink?o=f:_[p].id==this._modelCurveIdLipSync?a=f:_[p].id==this._modelCurveIdOpacity&&(this._modelOpacity=f,t.setModelOapcity(this.getModelOpacityValue()));for(;p<this._motionData.curveCount&&_[p].type==Fe.CubismMotionCurveTarget_Parameter;++p){if(g=t.getParameterIndex(_[p].id),g==-1)continue;const b=t.getParameterValueByIndex(g);if(f=$o(this._motionData,p,m),o!=Number.MAX_VALUE){for(let E=0;E<this._eyeBlinkParameterIds.length&&E<h;++E)if(this._eyeBlinkParameterIds[E]==_[p].id){f*=o,u|=1<<E;break}}if(a!=Number.MAX_VALUE){for(let E=0;E<this._lipSyncParameterIds.length&&E<h;++E)if(this._lipSyncParameterIds[E]==_[p].id){f+=a,l|=1<<E;break}}let y;if(_[p].fadeInTime<0&&_[p].fadeOutTime<0)y=b+(f-b)*i;else{let E,v;_[p].fadeInTime<0?E=c:E=_[p].fadeInTime==0?1:mt.getEasingSine((e-r.getFadeInStartTime())/_[p].fadeInTime),_[p].fadeOutTime<0?v=d:v=_[p].fadeOutTime==0||r.getEndTime()<0?1:mt.getEasingSine((r.getEndTime()-e)/_[p].fadeOutTime);const M=this._weight*E*v;y=b+(f-b)*M}t.setParameterValueByIndex(g,y,1)}{if(o!=Number.MAX_VALUE)for(let b=0;b<this._eyeBlinkParameterIds.length&&b<h;++b){const y=t.getParameterValueById(this._eyeBlinkParameterIds[b]);if(u>>b&1)continue;const E=y+(o-y)*i;t.setParameterValueById(this._eyeBlinkParameterIds[b],E)}if(a!=Number.MAX_VALUE)for(let b=0;b<this._lipSyncParameterIds.length&&b<h;++b){const y=t.getParameterValueById(this._lipSyncParameterIds[b]);if(l>>b&1)continue;const E=y+(a-y)*i;t.setParameterValueById(this._lipSyncParameterIds[b],E)}}for(;p<this._motionData.curveCount&&_[p].type==Fe.CubismMotionCurveTarget_PartOpacity;++p)if(f=$o(this._motionData,p,m),tn.setOpacityFromMotion)t.setPartOpacityById(_[p].id,f);else{if(g=t.getParameterIndex(_[p].id),g==-1)continue;t.setParameterValueByIndex(g,f)}n>=this._motionData.duration&&(this._isLoop?(r.setStartTime(e),this._isLoopFadeIn&&r.setFadeInStartTime(e)):(this._onFinishedMotion&&this._onFinishedMotion(this),r.setIsFinished(!0))),this._lastWeight=i}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 i=this._motionData.curves;for(let r=0;r<this._motionData.curveCount;++r)if(t==i[r].id){i[r].fadeInTime=e;return}}setParameterFadeOutTime(t,e){const i=this._motionData.curves;for(let r=0;r<this._motionData.curveCount;++r)if(t==i[r].id){i[r].fadeOutTime=e;return}}getParameterFadeInTime(t){const e=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==e[i].id)return e[i].fadeInTime;return-1}getParameterFadeOutTime(t){const e=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==e[i].id)return e[i].fadeOutTime;return-1}setEffectIds(t,e){this._eyeBlinkParameterIds=t,this._lipSyncParameterIds=e}release(){this._motionData=void 0}parse(t){this._motionData=new ey;const e=new Ld(t);this._motionData.duration=e.getMotionDuration(),this._motionData.loop=e.isMotionLoop(),this._motionData.curveCount=e.getMotionCurveCount(),this._motionData.fps=e.getMotionFps(),this._motionData.eventCount=e.getEventCount();const i=e.getEvaluationOptionFlag(Od.EvaluationOptionFlag_AreBeziersRistricted),r=e.getMotionFadeInTime(),n=e.getMotionFadeOutTime();r!==void 0?this._fadeInSeconds=r<0?1:r:this._fadeInSeconds=1,n!==void 0?this._fadeOutSeconds=n<0?1:n:this._fadeOutSeconds=1,this._motionData.curves=Array.from({length:this._motionData.curveCount}).map(()=>new Q_),this._motionData.segments=Array.from({length:e.getMotionTotalSegmentCount()}).map(()=>new J_),this._motionData.events=Array.from({length:this._motionData.eventCount}).map(()=>new ty),this._motionData.points=[];let a=0,o=0;for(let h=0;h<this._motionData.curveCount;++h){const l=this._motionData.curves[h];switch(e.getMotionCurveTarget(h)){case sy:l.type=Fe.CubismMotionCurveTarget_Model;break;case ny:l.type=Fe.CubismMotionCurveTarget_Parameter;break;case ay:l.type=Fe.CubismMotionCurveTarget_PartOpacity;break;default:Ci('Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!')}l.id=e.getMotionCurveId(h),l.baseSegmentIndex=o;const u=e.getMotionCurveFadeInTime(h),c=e.getMotionCurveFadeOutTime(h);l.fadeInTime=u!==void 0?u:-1,l.fadeOutTime=c!==void 0?c:-1;for(let d=0;d<e.getMotionCurveSegmentCount(h);){switch(d==0?(this._motionData.segments[o].basePointIndex=a,this._motionData.points[a]=new ai(e.getMotionCurveSegment(h,d),e.getMotionCurveSegment(h,d+1)),a+=1,d+=2):this._motionData.segments[o].basePointIndex=a-1,e.getMotionCurveSegment(h,d)){case Be.CubismMotionSegmentType_Linear:{this._motionData.segments[o].segmentType=Be.CubismMotionSegmentType_Linear,this._motionData.segments[o].evaluate=hy,this._motionData.points[a]=new ai(e.getMotionCurveSegment(h,d+1),e.getMotionCurveSegment(h,d+2)),a+=1,d+=3;break}case Be.CubismMotionSegmentType_Bezier:{this._motionData.segments[o].segmentType=Be.CubismMotionSegmentType_Bezier,i||oy?this._motionData.segments[o].evaluate=ly:this._motionData.segments[o].evaluate=uy,this._motionData.points[a]=new ai(e.getMotionCurveSegment(h,d+1),e.getMotionCurveSegment(h,d+2)),this._motionData.points[a+1]=new ai(e.getMotionCurveSegment(h,d+3),e.getMotionCurveSegment(h,d+4)),this._motionData.points[a+2]=new ai(e.getMotionCurveSegment(h,d+5),e.getMotionCurveSegment(h,d+6)),a+=3,d+=7;break}case Be.CubismMotionSegmentType_Stepped:{this._motionData.segments[o].segmentType=Be.CubismMotionSegmentType_Stepped,this._motionData.segments[o].evaluate=cy,this._motionData.points[a]=new ai(e.getMotionCurveSegment(h,d+1),e.getMotionCurveSegment(h,d+2)),a+=1,d+=3;break}case Be.CubismMotionSegmentType_InverseStepped:{this._motionData.segments[o].segmentType=Be.CubismMotionSegmentType_InverseStepped,this._motionData.segments[o].evaluate=dy,this._motionData.points[a]=new ai(e.getMotionCurveSegment(h,d+1),e.getMotionCurveSegment(h,d+2)),a+=1,d+=3;break}default:{qi(0);break}}++l.segmentCount,++o}this._motionData.curves.push(l)}for(let h=0;h<e.getEventCount();++h)this._motionData.events[h].fireTime=e.getEventTime(h),this._motionData.events[h].value=e.getEventValue(h);e.release()}getFiredEvent(t,e){this._firedEventValues.length=0;for(let i=0;i<this._motionData.eventCount;++i)this._motionData.events[i].fireTime>t&&this._motionData.events[i].fireTime<=e&&this._firedEventValues.push(this._motionData.events[i].value);return this._firedEventValues}isExistModelOpacity(){for(let t=0;t<this._motionData.curveCount;t++){const e=this._motionData.curves[t];if(e.type==Fe.CubismMotionCurveTarget_Model&&e.id===an)return!0}return!1}getModelOpacityIndex(){if(this.isExistModelOpacity())for(let t=0;t<this._motionData.curveCount;t++){const e=this._motionData.curves[t];if(e.type==Fe.CubismMotionCurveTarget_Model&&e.id===an)return t}return-1}getModelOpacityId(t){if(t!=-1){const e=this._motionData.curves[t];if(e.type==Fe.CubismMotionCurveTarget_Model&&e.id===an)return e.id}}getModelOpacityValue(){return this._modelOpacity}}class fy extends zr{constructor(t,e){var i;super(t,e),I(this,"definitions"),I(this,"groups",{idle:"Idle"}),I(this,"motionDataType","json"),I(this,"queueManager",new Bd),I(this,"expressionManager"),I(this,"eyeBlinkIds"),I(this,"lipSyncIds",["ParamMouthOpenY"]),this.definitions=(i=t.motions)!=null?i:{},this.eyeBlinkIds=t.getEyeBlinkParameters()||[];const r=t.getLipSyncParameters();r!=null&&r.length&&(this.lipSyncIds=r),this.init(e)}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new Z_(this.settings,t)),this.queueManager.setEventCallback((e,i,r)=>{this.emit("motion:"+i)})}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,i){const r=jo.create(t),n=new Ld(t),a=(e===this.groups.idle?Xi.idleMotionFadingDuration:Xi.motionFadingDuration)/1e3;return n.getMotionFadeInTime()===void 0&&r.setFadeInTime(i.FadeInTime>0?i.FadeInTime:a),n.getMotionFadeOutTime()===void 0&&r.setFadeOutTime(i.FadeOutTime>0?i.FadeOutTime:a),r.setEffectIds(this.eyeBlinkIds,this.lipSyncIds),r}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 py="ParamAngleX",my="ParamAngleY",gy="ParamAngleZ",_y="ParamEyeBallX",yy="ParamEyeBallY",vy="ParamMouthForm",xy="ParamBodyAngleX",by="ParamBreath";class Yo{constructor(){this._breathParameters=[],this._currentTime=0}static create(){return new Yo}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,e){this._currentTime+=e;const i=this._currentTime*2*3.14159;for(let r=0;r<this._breathParameters.length;++r){const n=this._breathParameters[r];t.addParameterValueById(n.parameterId,n.offset+n.peak*Math.sin(i/n.cycle),n.weight)}}}class qr{constructor(t,e,i,r,n){this.parameterId=t??void 0,this.offset=e??0,this.peak=i??0,this.cycle=r??0,this.weight=n??0}}const kd=class xh{static create(t){return new xh(t)}setBlinkingInterval(t){this._blinkingIntervalSeconds=t}setBlinkingSetting(t,e,i){this._closingSeconds=t,this._closedSeconds=e,this._openingSeconds=i}setParameterIds(t){this._parameterIds=t}getParameterIds(){return this._parameterIds}updateParameters(t,e){this._userTimeSeconds+=e;let i,r=0;switch(this._blinkingState){case 2:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closingSeconds,r>=1&&(r=1,this._blinkingState=3,this._stateStartTimeSeconds=this._userTimeSeconds),i=1-r;break;case 3:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,r>=1&&(this._blinkingState=4,this._stateStartTimeSeconds=this._userTimeSeconds),i=0;break;case 4:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,r>=1&&(r=1,this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming()),i=r;break;case 1:this._nextBlinkingTime<this._userTimeSeconds&&(this._blinkingState=2,this._stateStartTimeSeconds=this._userTimeSeconds),i=1;break;case 0:default:this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming(),i=1;break}xh.CloseIfZero||(i=-i);for(let n=0;n<this._parameterIds.length;++n)t.setParameterValueById(this._parameterIds[n],i)}constructor(t){var e,i;this._blinkingState=0,this._nextBlinkingTime=0,this._stateStartTimeSeconds=0,this._blinkingIntervalSeconds=4,this._closingSeconds=.1,this._closedSeconds=.05,this._openingSeconds=.15,this._userTimeSeconds=0,this._parameterIds=[],t!=null&&(this._parameterIds=(i=(e=t.getEyeBlinkParameters())==null?void 0:e.slice())!=null?i:this._parameterIds)}determinNextBlinkingTiming(){const t=Math.random();return this._userTimeSeconds+t*(2*this._blinkingIntervalSeconds-1)}};kd.CloseIfZero=!0;let Ty=kd;class qo{constructor(t=0,e=0,i=0,r=0){this.x=t,this.y=e,this.width=i,this.height=r}getCenterX(){return this.x+.5*this.width}getCenterY(){return this.y+.5*this.height}getRight(){return this.x+this.width}getBottom(){return this.y+this.height}setRect(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 on=4,Ey=36,wy=32,Cy=10;let Ai,je,hn;class Nd{getChannelFlagAsColor(t){return this._channelColors[t]}getMaskRenderTexture(){if(this._maskTexture&&this._maskTexture.textures!=null)this._maskTexture.frameNo=this._currentFrameNo;else{this._maskRenderTextures=[],this._maskColorBuffers=[];const t=this._clippingMaskBufferSize;for(let e=0;e<this._renderTextureCount;e++)this._maskColorBuffers.push(this.gl.createTexture()),this.gl.bindTexture(this.gl.TEXTURE_2D,this._maskColorBuffers[e]),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,t,t,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,null),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.bindTexture(this.gl.TEXTURE_2D,null),this._maskRenderTextures.push(this.gl.createFramebuffer()),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._maskRenderTextures[e]),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,this._maskColorBuffers[e],0);this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,hn),this._maskTexture=new Ay(this._currentFrameNo,this._maskRenderTextures)}return this._maskTexture.textures}setGL(t){this.gl=t}calcClippedDrawTotalBounds(t,e){let i=Number.MAX_VALUE,r=Number.MAX_VALUE,n=Number.MIN_VALUE,a=Number.MIN_VALUE;const o=e._clippedDrawableIndexList.length;for(let h=0;h<o;h++){const l=e._clippedDrawableIndexList[h],u=t.getDrawableVertexCount(l),c=t.getDrawableVertices(l);let d=Number.MAX_VALUE,f=Number.MAX_VALUE,p=-Number.MAX_VALUE,g=-Number.MAX_VALUE;const m=u*zo.vertexStep;for(let _=zo.vertexOffset;_<m;_+=zo.vertexStep){const b=c[_],y=c[_+1];b<d&&(d=b),b>p&&(p=b),y<f&&(f=y),y>g&&(g=y)}if(d!=Number.MAX_VALUE)if(d<i&&(i=d),f<r&&(r=f),p>n&&(n=p),g>a&&(a=g),i==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 _=n-i,b=a-r;e._allClippedDrawRect.x=i,e._allClippedDrawRect.y=r,e._allClippedDrawRect.width=_,e._allClippedDrawRect.height=b}}}constructor(){this._currentMaskRenderTexture=null,this._currentFrameNo=0,this._renderTextureCount=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=[],this._clippingContextListForDraw=[],this._channelColors=[],this._tmpBoundsOnModel=new qo,this._tmpMatrix=new se,this._tmpMatrixForMask=new se,this._tmpMatrixForDraw=new se;let t=new Yt;t.R=1,t.G=0,t.B=0,t.A=0,this._channelColors.push(t),t=new Yt,t.R=0,t.G=1,t.B=0,t.A=0,this._channelColors.push(t),t=new Yt,t.R=0,t.G=0,t.B=1,t.A=0,this._channelColors.push(t),t=new Yt,t.R=0,t.G=0,t.B=0,t.A=1,this._channelColors.push(t)}release(){var t;const e=this;for(let i=0;i<this._clippingContextListForMask.length;i++)this._clippingContextListForMask[i]&&((t=this._clippingContextListForMask[i])==null||t.release());if(e._clippingContextListForMask=void 0,e._clippingContextListForDraw=void 0,this._maskTexture){for(let i=0;i<this._maskTexture.textures.length;i++)this.gl.deleteFramebuffer(this._maskTexture.textures[i]);this._maskTexture=void 0}if(e._channelColors=void 0,this._maskColorBuffers)for(let i=0;i<this._maskColorBuffers.length;i++)this.gl.deleteTexture(this._maskColorBuffers[i]);this._maskColorBuffers=void 0,this._maskRenderTextures=void 0,this._clearedFrameBufferflags=void 0}initialize(t,e,i,r,n){n%1!=0&&(Ci("The number of render textures must be specified as an integer. The decimal point is rounded down and corrected to an integer."),n=~~n),n<1&&Ci("The number of render textures must be an integer greater than or equal to 1. Set the number of render textures to 1."),this._renderTextureCount=n<1?1:n,this._clearedFrameBufferflags=[];for(let a=0;a<e;a++){if(r[a]<=0){this._clippingContextListForDraw.push(null);continue}let o=this.findSameClip(i[a],r[a]);o==null&&(o=new Sy(this,i[a],r[a]),this._clippingContextListForMask.push(o)),o.addClippedDrawable(a),this._clippingContextListForDraw.push(o)}}setupClippingContext(t,e){this._currentFrameNo++;let i=0;for(let r=0;r<this._clippingContextListForMask.length;r++){const n=this._clippingContextListForMask[r];this.calcClippedDrawTotalBounds(t,n),n._isUsing&&i++}if(i>0){this.setupLayoutBounds(e.isUsingHighPrecisionMask()?0:i),e.isUsingHighPrecisionMask()||(this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),this._currentMaskRenderTexture=this.getMaskRenderTexture()[0],e.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture)),this._clearedFrameBufferflags||(this._clearedFrameBufferflags=[]);for(let r=0;r<this._renderTextureCount;r++)this._clearedFrameBufferflags[r]=!1;for(let r=0;r<this._clippingContextListForMask.length;r++){const n=this._clippingContextListForMask[r],a=n._allClippedDrawRect,o=n._layoutBounds,h=.05;let l=0,u=0;const c=this.getMaskRenderTexture()[n._bufferIndex];if(this._currentMaskRenderTexture!=c&&!e.isUsingHighPrecisionMask()&&(this._currentMaskRenderTexture=c,e.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture)),e.isUsingHighPrecisionMask()){const d=t.getPixelsPerUnit(),f=n.getClippingManager()._clippingMaskBufferSize,p=o.width*f,g=o.height*f;this._tmpBoundsOnModel.setRect(a),this._tmpBoundsOnModel.width*d>p?(this._tmpBoundsOnModel.expand(a.width*h,0),l=o.width/this._tmpBoundsOnModel.width):l=d/p,this._tmpBoundsOnModel.height*d>g?(this._tmpBoundsOnModel.expand(0,a.height*h),u=o.height/this._tmpBoundsOnModel.height):u=d/g}else this._tmpBoundsOnModel.setRect(a),this._tmpBoundsOnModel.expand(a.width*h,a.height*h),l=o.width/this._tmpBoundsOnModel.width,u=o.height/this._tmpBoundsOnModel.height;if(this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(o.x,o.y),this._tmpMatrix.scaleRelative(l,u),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(o.x,o.y),this._tmpMatrix.scaleRelative(l,u),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray()),n._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),n._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray()),!e.isUsingHighPrecisionMask()){const d=n._clippingIdCount;for(let f=0;f<d;f++){const p=n._clippingIdList[f];t.getDrawableDynamicFlagVertexPositionsDidChange(p)&&(e.setIsCulling(t.getDrawableCulling(p)!=!1),this._clearedFrameBufferflags[n._bufferIndex]||(this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this._clearedFrameBufferflags[n._bufferIndex]=!0),e.setClippingContextBufferForMask(n),e.drawMesh(t.getDrawableTextureIndex(p),t.getDrawableVertexIndexCount(p),t.getDrawableVertexCount(p),t.getDrawableVertexIndices(p),t.getDrawableVertices(p),t.getDrawableVertexUvs(p),t.getMultiplyColor(p),t.getScreenColor(p),t.getDrawableOpacity(p),$e.CubismBlendMode_Normal,!1))}}}e.isUsingHighPrecisionMask()||(this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,hn),e.setClippingContextBufferForMask(null),this.gl.viewport(je[0],je[1],je[2],je[3]))}}findSameClip(t,e){for(let i=0;i<this._clippingContextListForMask.length;i++){const r=this._clippingContextListForMask[i],n=r._clippingIdCount;if(n!=e)continue;let a=0;for(let o=0;o<n;o++){const h=r._clippingIdList[o];for(let l=0;l<n;l++)if(t[l]==h){a++;break}}if(a==n)return r}return null}setupLayoutBounds(t){const e=this._renderTextureCount<=1?Ey:wy*this._renderTextureCount;if(t<=0||t>e){t>e&&De(`not supported mask count : {0}
1161
+ [Details] render texture count : {1}, mask count : {2}`,t-e,this._renderTextureCount,t);for(let l=0;l<this._clippingContextListForMask.length;l++){const u=this._clippingContextListForMask[l];u._layoutChannelNo=0,u._layoutBounds.x=0,u._layoutBounds.y=0,u._layoutBounds.width=1,u._layoutBounds.height=1,u._bufferIndex=0}return}const i=this._renderTextureCount<=1?9:8;let r=t/this._renderTextureCount,n=t%this._renderTextureCount;r=~~r,n=~~n;let a=r/on,o=r%on;a=~~a,o=~~o;let h=0;for(let l=0;l<this._renderTextureCount;l++)for(let u=0;u<on;u++){let c=a+(u<o?1:0);const d=o+1>=on?0:o+1;if(c<i&&u==d&&(c+=l<n?1:0),c!=0)if(c==1){const f=this._clippingContextListForMask[h++];f._layoutChannelNo=u,f._layoutBounds.x=0,f._layoutBounds.y=0,f._layoutBounds.width=1,f._layoutBounds.height=1,f._bufferIndex=l}else if(c==2)for(let f=0;f<c;f++){let p=f%2;p=~~p;const g=this._clippingContextListForMask[h++];g._layoutChannelNo=u,g._layoutBounds.x=p*.5,g._layoutBounds.y=0,g._layoutBounds.width=.5,g._layoutBounds.height=1,g._bufferIndex=l}else if(c<=4)for(let f=0;f<c;f++){let p=f%2,g=f/2;p=~~p,g=~~g;const m=this._clippingContextListForMask[h++];m._layoutChannelNo=u,m._layoutBounds.x=p*.5,m._layoutBounds.y=g*.5,m._layoutBounds.width=.5,m._layoutBounds.height=.5,m._bufferIndex=l}else if(c<=i)for(let f=0;f<c;f++){let p=f%3,g=f/3;p=~~p,g=~~g;const m=this._clippingContextListForMask[h++];m._layoutChannelNo=u,m._layoutBounds.x=p/3,m._layoutBounds.y=g/3,m._layoutBounds.width=1/3,m._layoutBounds.height=1/3,m._bufferIndex=l}else if(tn.supportMoreMaskDivisions&&c<=16)for(let f=0;f<c;f++){let p=f%4,g=f/4;p=~~p,g=~~g;const m=this._clippingContextListForMask[h++];m._layoutChannelNo=u,m._layoutBounds.x=p/4,m._layoutBounds.y=g/4,m._layoutBounds.width=1/4,m._layoutBounds.height=1/4,m._bufferIndex=l}else{De(`not supported mask count : {0}
1162
+ [Details] render texture count : {1}, mask count : {2}`,t-e,this._renderTextureCount,t);for(let f=0;f<c;f++){const p=this._clippingContextListForMask[h++];p._layoutChannelNo=0,p._layoutBounds.x=0,p._layoutBounds.y=0,p._layoutBounds.width=1,p._layoutBounds.height=1,p._bufferIndex=0}}}}getColorBuffer(){return this._maskColorBuffers}getClippingContextListForDraw(){return this._clippingContextListForDraw}getClippingMaskCount(){return this._clippingContextListForMask.length}setClippingMaskBufferSize(t){this._clippingMaskBufferSize=t}getClippingMaskBufferSize(){return this._clippingMaskBufferSize}getRenderTextureCount(){return this._renderTextureCount}}class Ay{constructor(t,e){this.frameNo=t,this.textures=e}}class Sy{constructor(t,e,i){this._isUsing=!1,this._owner=t,this._clippingIdList=e,this._clippingIdCount=i,this._allClippedDrawRect=new qo,this._layoutBounds=new qo,this._clippedDrawableIndexList=[],this._matrixForMask=new se,this._matrixForDraw=new se,this._bufferIndex=0}release(){const t=this;t._layoutBounds=void 0,t._allClippedDrawRect=void 0,t._clippedDrawableIndexList=void 0}addClippedDrawable(t){this._clippedDrawableIndexList.push(t)}getClippingManager(){return this._owner}setGl(t){this._owner.setGL(t)}}class Py{setGlEnable(t,e){e?this.gl.enable(t):this.gl.disable(t)}setGlEnableVertexAttribArray(t,e){e?this.gl.enableVertexAttribArray(t):this.gl.disableVertexAttribArray(t)}save(){if(this.gl==null){De(`'gl' is null. WebGLRenderingContext is required.
1163
+ Please call 'CubimRenderer_WebGL.startUp' function.`);return}this._lastArrayBufferBinding=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING),this._lastArrayBufferBinding=this.gl.getParameter(this.gl.ELEMENT_ARRAY_BUFFER_BINDING),this._lastProgram=this.gl.getParameter(this.gl.CURRENT_PROGRAM),this._lastActiveTexture=this.gl.getParameter(this.gl.ACTIVE_TEXTURE),this.gl.activeTexture(this.gl.TEXTURE1),this._lastTexture1Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this.gl.activeTexture(this.gl.TEXTURE0),this._lastTexture0Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this._lastVertexAttribArrayEnabled[0]=this.gl.getVertexAttrib(0,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[1]=this.gl.getVertexAttrib(1,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[2]=this.gl.getVertexAttrib(2,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[3]=this.gl.getVertexAttrib(3,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastScissorTest=this.gl.isEnabled(this.gl.SCISSOR_TEST),this._lastStencilTest=this.gl.isEnabled(this.gl.STENCIL_TEST),this._lastDepthTest=this.gl.isEnabled(this.gl.DEPTH_TEST),this._lastCullFace=this.gl.isEnabled(this.gl.CULL_FACE),this._lastBlend=this.gl.isEnabled(this.gl.BLEND),this._lastFrontFace=this.gl.getParameter(this.gl.FRONT_FACE),this._lastColorMask=this.gl.getParameter(this.gl.COLOR_WRITEMASK),this._lastBlending[0]=this.gl.getParameter(this.gl.BLEND_SRC_RGB),this._lastBlending[1]=this.gl.getParameter(this.gl.BLEND_DST_RGB),this._lastBlending[2]=this.gl.getParameter(this.gl.BLEND_SRC_ALPHA),this._lastBlending[3]=this.gl.getParameter(this.gl.BLEND_DST_ALPHA),this._lastFBO=this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING),this._lastViewport=this.gl.getParameter(this.gl.VIEWPORT)}restore(){if(this.gl==null){De(`'gl' is null. WebGLRenderingContext is required.
1164
+ Please call 'CubimRenderer_WebGL.startUp' function.`);return}this.gl.useProgram(this._lastProgram),this.setGlEnableVertexAttribArray(0,this._lastVertexAttribArrayEnabled[0]),this.setGlEnableVertexAttribArray(1,this._lastVertexAttribArrayEnabled[1]),this.setGlEnableVertexAttribArray(2,this._lastVertexAttribArrayEnabled[2]),this.setGlEnableVertexAttribArray(3,this._lastVertexAttribArrayEnabled[3]),this.setGlEnable(this.gl.SCISSOR_TEST,this._lastScissorTest),this.setGlEnable(this.gl.STENCIL_TEST,this._lastStencilTest),this.setGlEnable(this.gl.DEPTH_TEST,this._lastDepthTest),this.setGlEnable(this.gl.CULL_FACE,this._lastCullFace),this.setGlEnable(this.gl.BLEND,this._lastBlend),this.gl.frontFace(this._lastFrontFace),this.gl.colorMask(this._lastColorMask[0],this._lastColorMask[1],this._lastColorMask[2],this._lastColorMask[3]),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._lastArrayBufferBinding),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._lastElementArrayBufferBinding),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture1Binding2D),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture0Binding2D),this.gl.activeTexture(this._lastActiveTexture),this.gl.blendFuncSeparate(this._lastBlending[0],this._lastBlending[1],this._lastBlending[2],this._lastBlending[3])}setGl(t){this.gl=t}constructor(){this._lastVertexAttribArrayEnabled=new Array(4),this._lastColorMask=new Array(4),this._lastBlending=new Array(4),this._lastViewport=new Array(4)}}class Ki{static getInstance(){return Ai==null&&(Ai=new Ki),Ai}static deleteInstance(){Ai&&(Ai.release(),Ai=void 0)}constructor(){this._shaderSets=[]}release(){this.releaseShaderProgram()}setupShaderProgram(t,e,i,r,n,a,o,h,l,u,c,d,f,p,g){f||De("NoPremultipliedAlpha is not allowed"),this._shaderSets.length==0&&this.generateShaders();let m,_,b,y;const E=t.getClippingContextBufferForMask();if(E!=null){const v=this._shaderSets[0];this.gl.useProgram(v.shaderProgram),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(v.samplerTexture0Location,0),o.vertex==null&&(o.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,o.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,r,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(v.attributePositionLocation),this.gl.vertexAttribPointer(v.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),o.uv==null&&(o.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,o.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,a,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(v.attributeTexCoordLocation),this.gl.vertexAttribPointer(v.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0);const M=E._layoutChannelNo,T=E.getClippingManager().getChannelFlagAsColor(M);this.gl.uniform4f(v.uniformChannelFlagLocation,T.R,T.G,T.B,T.A),this.gl.uniformMatrix4fv(v.uniformClipMatrixLocation,!1,E._matrixForMask.getArray());const P=E._layoutBounds;this.gl.uniform4f(v.uniformBaseColorLocation,P.x*2-1,P.y*2-1,P.getRight()*2-1,P.getBottom()*2-1),this.gl.uniform4f(v.uniformMultiplyColorLocation,c.R,c.G,c.B,c.A),this.gl.uniform4f(v.uniformScreenColorLocation,d.R,d.G,d.B,d.A),m=this.gl.ZERO,_=this.gl.ONE_MINUS_SRC_COLOR,b=this.gl.ZERO,y=this.gl.ONE_MINUS_SRC_ALPHA}else{const v=t.getClippingContextBufferForDraw(),T=v!=null?g?2:1:0;let P;switch(l){case $e.CubismBlendMode_Normal:default:P=this._shaderSets[1+T],m=this.gl.ONE,_=this.gl.ONE_MINUS_SRC_ALPHA,b=this.gl.ONE,y=this.gl.ONE_MINUS_SRC_ALPHA;break;case $e.CubismBlendMode_Additive:P=this._shaderSets[4+T],m=this.gl.ONE,_=this.gl.ONE,b=this.gl.ZERO,y=this.gl.ONE;break;case $e.CubismBlendMode_Multiplicative:P=this._shaderSets[7+T],m=this.gl.DST_COLOR,_=this.gl.ONE_MINUS_SRC_ALPHA,b=this.gl.ZERO,y=this.gl.ONE;break}if(this.gl.useProgram(P.shaderProgram),o.vertex==null&&(o.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,o.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,r,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(P.attributePositionLocation),this.gl.vertexAttribPointer(P.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),o.uv==null&&(o.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,o.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,a,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(P.attributeTexCoordLocation),this.gl.vertexAttribPointer(P.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),v!=null){this.gl.activeTexture(this.gl.TEXTURE1);const N=v.getClippingManager().getColorBuffer()[t.getClippingContextBufferForDraw()._bufferIndex];this.gl.bindTexture(this.gl.TEXTURE_2D,N),this.gl.uniform1i(P.samplerTexture1Location,1),this.gl.uniformMatrix4fv(P.uniformClipMatrixLocation,!1,v._matrixForDraw.getArray());const G=v._layoutChannelNo,z=v.getClippingManager().getChannelFlagAsColor(G);this.gl.uniform4f(P.uniformChannelFlagLocation,z.R,z.G,z.B,z.A)}this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(P.samplerTexture0Location,0),this.gl.uniformMatrix4fv(P.uniformMatrixLocation,!1,p.getArray()),this.gl.uniform4f(P.uniformBaseColorLocation,u.R,u.G,u.B,u.A),this.gl.uniform4f(P.uniformMultiplyColorLocation,c.R,c.G,c.B,c.A),this.gl.uniform4f(P.uniformScreenColorLocation,d.R,d.G,d.B,d.A)}o.index==null&&(o.index=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,o.index),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,n,this.gl.DYNAMIC_DRAW),this.gl.blendFuncSeparate(m,_,b,y)}releaseShaderProgram(){for(let t=0;t<this._shaderSets.length;t++)this.gl.deleteProgram(this._shaderSets[t].shaderProgram),this._shaderSets[t].shaderProgram=0;this._shaderSets=[]}generateShaders(){for(let t=0;t<Cy;t++)this._shaderSets.push({});this._shaderSets[0].shaderProgram=this.loadShaderProgram(My,Iy),this._shaderSets[1].shaderProgram=this.loadShaderProgram(Ry,Dy),this._shaderSets[2].shaderProgram=this.loadShaderProgram(Ud,Fy),this._shaderSets[3].shaderProgram=this.loadShaderProgram(Ud,By),this._shaderSets[4].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[5].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[6].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[7].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[8].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[9].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[0].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_position"),this._shaderSets[0].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_texCoord"),this._shaderSets[0].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"s_texture0"),this._shaderSets[0].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_clipMatrix"),this._shaderSets[0].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_channelFlag"),this._shaderSets[0].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_baseColor"),this._shaderSets[0].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_multiplyColor"),this._shaderSets[0].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_screenColor"),this._shaderSets[1].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_position"),this._shaderSets[1].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_texCoord"),this._shaderSets[1].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"s_texture0"),this._shaderSets[1].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_matrix"),this._shaderSets[1].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_baseColor"),this._shaderSets[1].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_multiplyColor"),this._shaderSets[1].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_screenColor"),this._shaderSets[2].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_position"),this._shaderSets[2].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_texCoord"),this._shaderSets[2].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture0"),this._shaderSets[2].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture1"),this._shaderSets[2].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_matrix"),this._shaderSets[2].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_clipMatrix"),this._shaderSets[2].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_channelFlag"),this._shaderSets[2].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_baseColor"),this._shaderSets[2].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_multiplyColor"),this._shaderSets[2].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_screenColor"),this._shaderSets[3].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_position"),this._shaderSets[3].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_texCoord"),this._shaderSets[3].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture0"),this._shaderSets[3].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture1"),this._shaderSets[3].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_matrix"),this._shaderSets[3].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_clipMatrix"),this._shaderSets[3].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_channelFlag"),this._shaderSets[3].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_baseColor"),this._shaderSets[3].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_multiplyColor"),this._shaderSets[3].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_screenColor"),this._shaderSets[4].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_position"),this._shaderSets[4].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_texCoord"),this._shaderSets[4].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"s_texture0"),this._shaderSets[4].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_matrix"),this._shaderSets[4].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_baseColor"),this._shaderSets[4].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_multiplyColor"),this._shaderSets[4].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_screenColor"),this._shaderSets[5].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_position"),this._shaderSets[5].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_texCoord"),this._shaderSets[5].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture0"),this._shaderSets[5].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture1"),this._shaderSets[5].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_matrix"),this._shaderSets[5].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_clipMatrix"),this._shaderSets[5].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_channelFlag"),this._shaderSets[5].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_baseColor"),this._shaderSets[5].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_multiplyColor"),this._shaderSets[5].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_screenColor"),this._shaderSets[6].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_position"),this._shaderSets[6].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_texCoord"),this._shaderSets[6].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture0"),this._shaderSets[6].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture1"),this._shaderSets[6].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_matrix"),this._shaderSets[6].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_clipMatrix"),this._shaderSets[6].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_channelFlag"),this._shaderSets[6].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_baseColor"),this._shaderSets[6].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_multiplyColor"),this._shaderSets[6].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_screenColor"),this._shaderSets[7].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_position"),this._shaderSets[7].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_texCoord"),this._shaderSets[7].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"s_texture0"),this._shaderSets[7].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_matrix"),this._shaderSets[7].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_baseColor"),this._shaderSets[7].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_multiplyColor"),this._shaderSets[7].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_screenColor"),this._shaderSets[8].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_position"),this._shaderSets[8].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_texCoord"),this._shaderSets[8].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture0"),this._shaderSets[8].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture1"),this._shaderSets[8].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_matrix"),this._shaderSets[8].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_clipMatrix"),this._shaderSets[8].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_channelFlag"),this._shaderSets[8].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_baseColor"),this._shaderSets[8].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_multiplyColor"),this._shaderSets[8].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_screenColor"),this._shaderSets[9].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_position"),this._shaderSets[9].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_texCoord"),this._shaderSets[9].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture0"),this._shaderSets[9].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture1"),this._shaderSets[9].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_matrix"),this._shaderSets[9].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_clipMatrix"),this._shaderSets[9].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_channelFlag"),this._shaderSets[9].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_baseColor"),this._shaderSets[9].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_multiplyColor"),this._shaderSets[9].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_screenColor")}loadShaderProgram(t,e){const i=this.gl.createProgram(),r=this.compileShaderSource(this.gl.VERTEX_SHADER,t);if(!r)return De("Vertex shader compile error!"),0;const n=this.compileShaderSource(this.gl.FRAGMENT_SHADER,e);return n?(this.gl.attachShader(i,r),this.gl.attachShader(i,n),this.gl.linkProgram(i),this.gl.getProgramParameter(i,this.gl.LINK_STATUS)?(this.gl.deleteShader(r),this.gl.deleteShader(n),i):(De("Failed to link program: {0}",i),this.gl.deleteShader(r),this.gl.deleteShader(n),i&&this.gl.deleteProgram(i),0)):(De("Vertex shader compile error!"),0)}compileShaderSource(t,e){const i=e,r=this.gl.createShader(t);if(this.gl.shaderSource(r,i),this.gl.compileShader(r),!r){const a=this.gl.getShaderInfoLog(r);De("Shader compile log: {0} ",a)}return this.gl.getShaderParameter(r,this.gl.COMPILE_STATUS)?r:(this.gl.deleteShader(r),null)}setGl(t){this.gl=t}}const My="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;}",Iy="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;}",Ry="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;}",Ud="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;}",Dy="precision mediump float;varying vec2 v_texCoord;uniform vec4 u_baseColor;uniform sampler2D s_texture0;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 color = texColor * u_baseColor; gl_FragColor = vec4(color.rgb, color.a);}",Fy="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;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * 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;}",By="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;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * 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 Gd extends Xo{initialize(t,e=1){t.isUsingMasking()&&(this._clippingManager=new Nd,this._clippingManager.initialize(t,t.getDrawableCount(),t.getDrawableMasks(),t.getDrawableMaskCounts(),e));for(let i=t.getDrawableCount()-1;i>=0;i--)this._sortedDrawableIndexList[i]=0;super.initialize(t)}bindTexture(t,e){this._textures[t]=e}getBindedTextures(){return this._textures}setClippingMaskBufferSize(t){if(!this._model.isUsingMasking())return;const e=this._clippingManager.getRenderTextureCount();this._clippingManager.release(),this._clippingManager=new Nd,this._clippingManager.setClippingMaskBufferSize(t),this._clippingManager.initialize(this.getModel(),this.getModel().getDrawableCount(),this.getModel().getDrawableMasks(),this.getModel().getDrawableMaskCounts(),e)}getClippingMaskBufferSize(){return this._model.isUsingMasking()?this._clippingManager.getClippingMaskBufferSize():-1}getRenderTextureCount(){return this._model.isUsingMasking()?this._clippingManager.getRenderTextureCount():-1}constructor(){super(),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._rendererProfile=new Py,this.firstDraw=!0,this._textures={},this._sortedDrawableIndexList=[],this._bufferData={vertex:null,uv:null,index:null}}release(){var t,e,i;const r=this;this._clippingManager.release(),r._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,(i=this.gl)==null||i.deleteBuffer(this._bufferData.index),this._bufferData.index=null,r._bufferData=void 0,r._textures=void 0}doDrawModel(){if(this.gl==null){De(`'gl' is null. WebGLRenderingContext is required.
1165
+ Please call 'CubimRenderer_WebGL.startUp' function.`);return}this._clippingManager!=null&&(this.preDraw(),this._clippingManager.setupClippingContext(this.getModel(),this)),this.preDraw();const t=this.getModel().getDrawableCount(),e=this.getModel().getDrawableRenderOrders();for(let i=0;i<t;++i){const r=e[i];this._sortedDrawableIndexList[r]=i}for(let i=0;i<t;++i){const r=this._sortedDrawableIndexList[i];if(!this.getModel().getDrawableDynamicFlagIsVisible(r))continue;const n=this._clippingManager!=null?this._clippingManager.getClippingContextListForDraw()[r]:null;if(n!=null&&this.isUsingHighPrecisionMask()){n._isUsing&&(this.gl.viewport(0,0,this._clippingManager.getClippingMaskBufferSize(),this._clippingManager.getClippingMaskBufferSize()),this.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,n.getClippingManager().getMaskRenderTexture()[n._bufferIndex]),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT));{const a=n._clippingIdCount;for(let o=0;o<a;o++){const h=n._clippingIdList[o];this._model.getDrawableDynamicFlagVertexPositionsDidChange(h)&&(this.setIsCulling(this._model.getDrawableCulling(h)!=!1),this.setClippingContextBufferForMask(n),this.drawMesh(this.getModel().getDrawableTextureIndex(h),this.getModel().getDrawableVertexIndexCount(h),this.getModel().getDrawableVertexCount(h),this.getModel().getDrawableVertexIndices(h),this.getModel().getDrawableVertices(h),this.getModel().getDrawableVertexUvs(h),this.getModel().getMultiplyColor(h),this.getModel().getScreenColor(h),this.getModel().getDrawableOpacity(h),$e.CubismBlendMode_Normal,!1))}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,hn),this.setClippingContextBufferForMask(null),this.gl.viewport(je[0],je[1],je[2],je[3]),this.preDraw()}this.setClippingContextBufferForDraw(n),this.setIsCulling(this.getModel().getDrawableCulling(r)),this.drawMesh(this.getModel().getDrawableTextureIndex(r),this.getModel().getDrawableVertexIndexCount(r),this.getModel().getDrawableVertexCount(r),this.getModel().getDrawableVertexIndices(r),this.getModel().getDrawableVertices(r),this.getModel().getDrawableVertexUvs(r),this.getModel().getMultiplyColor(r),this.getModel().getScreenColor(r),this.getModel().getDrawableOpacity(r),this.getModel().getDrawableBlendMode(r),this.getModel().getDrawableInvertedMaskBit(r))}}drawMesh(t,e,i,r,n,a,o,h,l,u,c){this.isCulling()?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this.gl.frontFace(this.gl.CCW);const d=this.getModelColor();this.getClippingContextBufferForMask()==null&&(d.A*=l,this.isPremultipliedAlpha()&&(d.R*=d.A,d.G*=d.A,d.B*=d.A));let f=null;this._textures[t]!=null&&(f=this._textures[t]),Ki.getInstance().setupShaderProgram(this,f,i,n,r,a,this._bufferData,l,u,d,o,h,this.isPremultipliedAlpha(),this.getMvpMatrix(),c),this.gl.drawElements(this.gl.TRIANGLES,e,this.gl.UNSIGNED_SHORT,0),this.gl.useProgram(null),this.setClippingContextBufferForDraw(null),this.setClippingContextBufferForMask(null)}saveProfile(){this._rendererProfile.save()}restoreProfile(){this._rendererProfile.restore()}static doStaticRelease(){Ki.deleteInstance()}setRenderState(t,e){hn=t,je=e}preDraw(){if(this.firstDraw&&(this.firstDraw=!1),this.gl.disable(this.gl.SCISSOR_TEST),this.gl.disable(this.gl.STENCIL_TEST),this.gl.disable(this.gl.DEPTH_TEST),this.gl.frontFace(this.gl.CW),this.gl.enable(this.gl.BLEND),this.gl.colorMask(!0,!0,!0,!0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null),this.getAnisotropy()>0&&this._extension)for(const t of Object.entries(this._textures))this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.texParameterf(this.gl.TEXTURE_2D,this._extension.TEXTURE_MAX_ANISOTROPY_EXT,this.getAnisotropy())}setClippingContextBufferForMask(t){this._clippingContextBufferForMask=t}getClippingContextBufferForMask(){return this._clippingContextBufferForMask}setClippingContextBufferForDraw(t){this._clippingContextBufferForDraw=t}getClippingContextBufferForDraw(){return this._clippingContextBufferForDraw}startUp(t){this.gl=t,this._clippingManager&&this._clippingManager.setGL(t),Ki.getInstance().setGl(t),this._rendererProfile.setGl(t),this._extension=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")}}Xo.staticRelease=()=>{Gd.doStaticRelease()};const Vd=new se;class Ly extends fd{constructor(t,e,i){super(),I(this,"settings"),I(this,"coreModel"),I(this,"motionManager"),I(this,"lipSync",!0),I(this,"breath",Yo.create()),I(this,"eyeBlink"),I(this,"userData"),I(this,"renderer",new Gd),I(this,"idParamAngleX",py),I(this,"idParamAngleY",my),I(this,"idParamAngleZ",gy),I(this,"idParamEyeBallX",_y),I(this,"idParamEyeBallY",yy),I(this,"idParamBodyAngleX",xy),I(this,"idParamBreath",by),I(this,"idParamMouthForm",vy),I(this,"pixelsPerUnit",1),I(this,"centeringTransform",new vt),this.coreModel=t,this.settings=e,this.motionManager=new fy(e,i),this.init()}init(){var t;super.init(),(t=this.settings.getEyeBlinkParameters())!=null&&t.length&&(this.eyeBlink=Ty.create(this.settings)),this.breath.setParameters([new qr(this.idParamAngleX,0,15,6.5345,.5),new qr(this.idParamAngleY,0,8,3.5345,.5),new qr(this.idParamAngleZ,0,10,5.5345,.5),new qr(this.idParamBodyAngleX,0,4,15.5345,.5),new qr(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,i]of Object.entries(this.settings.layout)){const r=e.charAt(0).toLowerCase()+e.slice(1);t[r]=i}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,Ki.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(i=>({id:i.Id,name:i.Name,index:this.coreModel.getDrawableIndex(i.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 i=0;i<e.length;i+=2)e[i]=e[i]*this.pixelsPerUnit+this.originalWidth/2,e[i+1]=-e[i+1]*this.pixelsPerUnit+this.originalHeight/2;return e}updateTransform(t){this.drawingMatrix.copyFrom(this.centeringTransform).prepend(this.localTransform).prepend(t)}update(t,e){var i,r,n,a;super.update(t,e),t/=1e3,e/=1e3;const o=this.coreModel;this.emit("beforeMotionUpdate");const h=this.motionManager.update(this.coreModel,e);if(this.emit("afterMotionUpdate"),o.saveParameters(),(i=this.motionManager.expressionManager)==null||i.update(o,e),h||(r=this.eyeBlink)==null||r.updateParameters(o,t),this.updateFocus(),this.updateNaturalMovements(t*1e3,e*1e3),this.lipSync&&this.motionManager.currentAudio){let l=this.motionManager.mouthSync(),u=0;const c=1,d=1.2;l>0&&(u=.4),l=zi(l*d,u,c);for(let f=0;f<this.motionManager.lipSyncIds.length;++f)o.addParameterValueById(this.motionManager.lipSyncIds[f],l,.8)}(n=this.physics)==null||n.evaluate(o,t),(a=this.pose)==null||a.updateParameters(o,t),this.emit("beforeModelUpdate"),o.update(),o.loadParameters()}updateFocus(){this.coreModel.addParameterValueById(this.idParamEyeBallX,this.focusController.x),this.coreModel.addParameterValueById(this.idParamEyeBallY,this.focusController.y),this.coreModel.addParameterValueById(this.idParamAngleX,this.focusController.x*30),this.coreModel.addParameterValueById(this.idParamAngleY,this.focusController.y*30),this.coreModel.addParameterValueById(this.idParamAngleZ,this.focusController.x*this.focusController.y*-30),this.coreModel.addParameterValueById(this.idParamBodyAngleX,this.focusController.x*10)}updateFacialEmotion(t){this.coreModel.addParameterValueById(this.idParamMouthForm,t)}updateNaturalMovements(t,e){var i;(i=this.breath)==null||i.updateParameters(this.coreModel,t/1e3)}draw(t){const e=this.drawingMatrix,i=Vd.getArray();i[0]=e.a,i[1]=e.b,i[4]=-e.c,i[5]=-e.d,i[12]=e.tx,i[13]=e.ty,this.renderer.setMvpMatrix(Vd),this.renderer.setRenderState(t.getParameter(t.FRAMEBUFFER_BINDING),this.viewport),this.renderer.drawModel()}destroy(){super.destroy(),this.renderer.release(),this.coreModel.release(),this.renderer=void 0,this.coreModel=void 0}}class Hd{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(i=>i.Name==="EyeBlink"))==null?void 0:e.Ids}getLipSyncParameters(){var t,e;return(e=(t=this.groups)==null?void 0:t.find(i=>i.Name==="LipSync"))==null?void 0:e.Ids}}class Zi extends en{constructor(t){if(super(t),I(this,"moc"),I(this,"textures"),!Zi.isValidJSON(t))throw new TypeError("Invalid JSON.");Object.assign(this,new Hd(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(i=>typeof i=="string")}replaceFiles(t){if(super.replaceFiles(t),this.motions)for(const[e,i]of Object.entries(this.motions))for(let r=0;r<i.length;r++)i[r].File=t(i[r].File,`motions.${e}[${r}].File`),i[r].Sound!==void 0&&(i[r].Sound=t(i[r].Sound,`motions.${e}[${r}].Sound`));if(this.expressions)for(let e=0;e<this.expressions.length;e++)this.expressions[e].File=t(this.expressions[e].File,`expressions[${e}].File`)}}w_(Zi,[Hd]);let ln,Xd=20;function Oy(){return jr.isStarted()?Promise.resolve():(ln??(ln=new Promise((s,t)=>{function e(){try{ky(),s()}catch(i){if(Xd--,Xd<0){const r=new Error("Failed to start up Cubism 4 framework.");r.cause=i,t(r);return}setTimeout(e,10)}}e()})),ln)}function ky(s){s=Object.assign({logFunction:console.log,loggingLevel:Yi.LogLevel_Verbose},s),jr.startUp(s),jr.initialize()}const Ny=.001,zd=.5;class Ko{static create(t){const e=new Ko;typeof t.FadeInTime=="number"&&(e._fadeTimeSeconds=t.FadeInTime,e._fadeTimeSeconds<=0&&(e._fadeTimeSeconds=zd));const i=t.Groups,r=i.length;for(let n=0;n<r;++n){const a=i[n],o=a.length;let h=0;for(let l=0;l<o;++l){const u=a[l],c=new un;c.partId=u.Id;const d=u.Link;if(d){const f=d.length;for(let p=0;p<f;++p){const g=new un;g.partId=d[p],c.link.push(g)}}e._partGroups.push(c),++h}e._partGroupCounts.push(h)}return e}updateParameters(t,e){t!=this._lastModel&&this.reset(t),this._lastModel=t,e<0&&(e=0);let i=0;for(let r=0;r<this._partGroupCounts.length;r++){const n=this._partGroupCounts[r];this.doFade(t,e,i,n),i+=n}this.copyPartOpacities(t)}reset(t){let e=0;for(let i=0;i<this._partGroupCounts.length;++i){const r=this._partGroupCounts[i];for(let n=e;n<e+r;++n){this._partGroups[n].initialize(t);const a=this._partGroups[n].partIndex,o=this._partGroups[n].parameterIndex;if(!(a<0)){t.setPartOpacityByIndex(a,n==e?1:0),t.setParameterValueByIndex(o,n==e?1:0);for(let h=0;h<this._partGroups[n].link.length;++h)this._partGroups[n].link[h].initialize(t)}}e+=r}}copyPartOpacities(t){for(let e=0;e<this._partGroups.length;++e){const i=this._partGroups[e];if(i.link.length==0)continue;const r=this._partGroups[e].partIndex,n=t.getPartOpacityByIndex(r);for(let a=0;a<i.link.length;++a){const h=i.link[a].partIndex;h<0||t.setPartOpacityByIndex(h,n)}}}doFade(t,e,i,r){let n=-1,a=1;const o=.5,h=.15;for(let l=i;l<i+r;++l){const u=this._partGroups[l].partIndex,c=this._partGroups[l].parameterIndex;if(t.getParameterValueByIndex(c)>Ny){if(n>=0)break;n=l,a=t.getPartOpacityByIndex(u),a+=e/this._fadeTimeSeconds,a>1&&(a=1)}}n<0&&(n=0,a=1);for(let l=i;l<i+r;++l){const u=this._partGroups[l].partIndex;if(n==l)t.setPartOpacityByIndex(u,a);else{let c=t.getPartOpacityByIndex(u),d;a<o?d=a*(o-1)/o+1:d=(1-a)*o/(1-o),(1-d)*(1-a)>h&&(d=1-h/(1-a)),c>d&&(c=d),t.setPartOpacityByIndex(u,c)}}}constructor(){this._fadeTimeSeconds=zd,this._lastModel=void 0,this._partGroups=[],this._partGroupCounts=[]}}class un{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 un;return t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=this.link.map(e=>e.clone()),t}}class Wd{constructor(t=!1,e=new Yt){this.isOverwritten=t,this.Color=e}}class $d{constructor(t=!1,e=new Yt){this.isOverwritten=t,this.Color=e}}class Uy{constructor(t=!1,e=!1){this.isOverwritten=t,this.isCulling=e}}class Gy{update(){this._model.update(),this._model.drawables.resetDynamicFlags()}getPixelsPerUnit(){return this._model==null?0:this._model.canvasinfo.PixelsPerUnit}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 i=0;i<t;++i)i<e?this._savedParameters[i]=this._parameterValues[i]:this._savedParameters.push(this._parameterValues[i])}getMultiplyColor(t){return this.getOverwriteFlagForModelMultiplyColors()||this.getOverwriteFlagForDrawableMultiplyColors(t)?this._userMultiplyColors[t].Color:this.getDrawableMultiplyColor(t)}getScreenColor(t){return this.getOverwriteFlagForModelScreenColors()||this.getOverwriteFlagForDrawableScreenColors(t)?this._userScreenColors[t].Color:this.getDrawableScreenColor(t)}setMultiplyColorByTextureColor(t,e){this.setMultiplyColorByRGBA(t,e.R,e.G,e.B,e.A)}setMultiplyColorByRGBA(t,e,i,r,n=1){this._userMultiplyColors[t].Color.R=e,this._userMultiplyColors[t].Color.G=i,this._userMultiplyColors[t].Color.B=r,this._userMultiplyColors[t].Color.A=n}setScreenColorByTextureColor(t,e){this.setScreenColorByRGBA(t,e.R,e.G,e.B,e.A)}setScreenColorByRGBA(t,e,i,r,n=1){this._userScreenColors[t].Color.R=e,this._userScreenColors[t].Color.G=i,this._userScreenColors[t].Color.B=r,this._userScreenColors[t].Color.A=n}getPartMultiplyColor(t){return this._userPartMultiplyColors[t].Color}getPartScreenColor(t){return this._userPartScreenColors[t].Color}setPartColor(t,e,i,r,n,a,o){if(a[t].Color.R=e,a[t].Color.G=i,a[t].Color.B=r,a[t].Color.A=n,a[t].isOverwritten)for(let h=0;h<this._partChildDrawables[t].length;++h){const l=this._partChildDrawables[t][h];o[l].Color.R=e,o[l].Color.G=i,o[l].Color.B=r,o[l].Color.A=n}}setPartMultiplyColorByTextureColor(t,e){this.setPartMultiplyColorByRGBA(t,e.R,e.G,e.B,e.A)}setPartMultiplyColorByRGBA(t,e,i,r,n){this.setPartColor(t,e,i,r,n,this._userPartMultiplyColors,this._userMultiplyColors)}setPartScreenColorByTextureColor(t,e){this.setPartScreenColorByRGBA(t,e.R,e.G,e.B,e.A)}setPartScreenColorByRGBA(t,e,i,r,n){this.setPartColor(t,e,i,r,n,this._userPartScreenColors,this._userScreenColors)}getOverwriteFlagForModelMultiplyColors(){return this._isOverwrittenModelMultiplyColors}getOverwriteFlagForModelScreenColors(){return this._isOverwrittenModelScreenColors}setOverwriteFlagForModelMultiplyColors(t){this._isOverwrittenModelMultiplyColors=t}setOverwriteFlagForModelScreenColors(t){this._isOverwrittenModelScreenColors=t}getOverwriteFlagForDrawableMultiplyColors(t){return this._userMultiplyColors[t].isOverwritten}getOverwriteFlagForDrawableScreenColors(t){return this._userScreenColors[t].isOverwritten}setOverwriteFlagForDrawableMultiplyColors(t,e){this._userMultiplyColors[t].isOverwritten=e}setOverwriteFlagForDrawableScreenColors(t,e){this._userScreenColors[t].isOverwritten=e}getOverwriteColorForPartMultiplyColors(t){return this._userPartMultiplyColors[t].isOverwritten}getOverwriteColorForPartScreenColors(t){return this._userPartScreenColors[t].isOverwritten}setOverwriteColorForPartColors(t,e,i,r){i[t].isOverwritten=e;for(let n=0;n<this._partChildDrawables[t].length;++n){const a=this._partChildDrawables[t][n];r[a].isOverwritten=e,e&&(r[a].Color.R=i[t].Color.R,r[a].Color.G=i[t].Color.G,r[a].Color.B=i[t].Color.B,r[a].Color.A=i[t].Color.A)}}setOverwriteColorForPartMultiplyColors(t,e){this._userPartMultiplyColors[t].isOverwritten=e,this.setOverwriteColorForPartColors(t,e,this._userPartMultiplyColors,this._userMultiplyColors)}setOverwriteColorForPartScreenColors(t,e){this._userPartScreenColors[t].isOverwritten=e,this.setOverwriteColorForPartColors(t,e,this._userPartScreenColors,this._userScreenColors)}getDrawableCulling(t){if(this.getOverwriteFlagForModelCullings()||this.getOverwriteFlagForDrawableCullings(t))return this._userCullings[t].isCulling;const e=this._model.drawables.constantFlags;return!Live2DCubismCore.Utils.hasIsDoubleSidedBit(e[t])}setDrawableCulling(t,e){this._userCullings[t].isCulling=e}getOverwriteFlagForModelCullings(){return this._isOverwrittenCullings}setOverwriteFlagForModelCullings(t){this._isOverwrittenCullings=t}getOverwriteFlagForDrawableCullings(t){return this._userCullings[t].isOverwritten}setOverwriteFlagForDrawableCullings(t,e){this._userCullings[t].isOverwritten=e}getModelOapcity(){return this._modelOpacity}setModelOapcity(t){this._modelOpacity=t}getModel(){return this._model}getPartIndex(t){let e;const i=this._model.parts.count;for(e=0;e<i;++e)if(t==this._partIds[e])return e;return t in this._notExistPartId?this._notExistPartId[t]:(e=i+this._notExistPartId.length,this._notExistPartId[t]=e,this._notExistPartOpacities[e]=0,e)}getPartId(t){return this._model.parts.ids[t]}getPartCount(){return this._model.parts.count}setPartOpacityByIndex(t,e){if(t in this._notExistPartOpacities){this._notExistPartOpacities[t]=e;return}qi(0<=t&&t<this.getPartCount()),this._partOpacities[t]=e}setPartOpacityById(t,e){const i=this.getPartIndex(t);i<0||this.setPartOpacityByIndex(i,e)}getPartOpacityByIndex(t){return t in this._notExistPartOpacities?this._notExistPartOpacities[t]:(qi(0<=t&&t<this.getPartCount()),this._partOpacities[t])}getPartOpacityById(t){const e=this.getPartIndex(t);return e<0?0:this.getPartOpacityByIndex(e)}getParameterIndex(t){let e;const i=this._model.parameters.count;for(e=0;e<i;++e)if(t==this._parameterIds[e])return e;return t in this._notExistParameterId?this._notExistParameterId[t]:(e=this._model.parameters.count+Object.keys(this._notExistParameterId).length,this._notExistParameterId[t]=e,this._notExistParameterValues[e]=0,e)}getParameterCount(){return this._model.parameters.count}getParameterType(t){return this._model.parameters.types[t]}getParameterMaximumValue(t){return this._model.parameters.maximumValues[t]}getParameterMinimumValue(t){return this._model.parameters.minimumValues[t]}getParameterDefaultValue(t){return this._model.parameters.defaultValues[t]}getParameterValueByIndex(t){return t in this._notExistParameterValues?this._notExistParameterValues[t]:(qi(0<=t&&t<this.getParameterCount()),this._parameterValues[t])}getParameterValueById(t){const e=this.getParameterIndex(t);return this.getParameterValueByIndex(e)}setParameterValueByIndex(t,e,i=1){if(t in this._notExistParameterValues){this._notExistParameterValues[t]=i==1?e:this._notExistParameterValues[t]*(1-i)+e*i;return}qi(0<=t&&t<this.getParameterCount()),this._model.parameters.maximumValues[t]<e&&(e=this._model.parameters.maximumValues[t]),this._model.parameters.minimumValues[t]>e&&(e=this._model.parameters.minimumValues[t]),this._parameterValues[t]=i==1?e:this._parameterValues[t]=this._parameterValues[t]*(1-i)+e*i}setParameterValueById(t,e,i=1){const r=this.getParameterIndex(t);this.setParameterValueByIndex(r,e,i)}addParameterValueByIndex(t,e,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)+e*i)}addParameterValueById(t,e,i=1){const r=this.getParameterIndex(t);this.addParameterValueByIndex(r,e,i)}multiplyParameterValueById(t,e,i=1){const r=this.getParameterIndex(t);this.multiplyParameterValueByIndex(r,e,i)}multiplyParameterValueByIndex(t,e,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)*(1+(e-1)*i))}getDrawableIds(){return this._drawableIds.slice()}getDrawableIndex(t){const e=this._model.drawables.count;for(let i=0;i<e;++i)if(this._drawableIds[i]==t)return i;return-1}getDrawableCount(){return this._model.drawables.count}getDrawableId(t){return this._model.drawables.ids[t]}getDrawableRenderOrders(){return this._model.drawables.renderOrders}getDrawableTextureIndices(t){return this.getDrawableTextureIndex(t)}getDrawableTextureIndex(t){return this._model.drawables.textureIndices[t]}getDrawableDynamicFlagVertexPositionsDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVertexPositionsDidChangeBit(e[t])}getDrawableVertexIndexCount(t){return this._model.drawables.indexCounts[t]}getDrawableVertexCount(t){return this._model.drawables.vertexCounts[t]}getDrawableVertices(t){return this.getDrawableVertexPositions(t)}getDrawableVertexIndices(t){return this._model.drawables.indices[t]}getDrawableVertexPositions(t){return this._model.drawables.vertexPositions[t]}getDrawableVertexUvs(t){return this._model.drawables.vertexUvs[t]}getDrawableOpacity(t){return this._model.drawables.opacities[t]}getDrawableMultiplyColor(t){const e=this._model.drawables.multiplyColors,i=t*4,r=new Yt;return r.R=e[i],r.G=e[i+1],r.B=e[i+2],r.A=e[i+3],r}getDrawableScreenColor(t){const e=this._model.drawables.screenColors,i=t*4,r=new Yt;return r.R=e[i],r.G=e[i+1],r.B=e[i+2],r.A=e[i+3],r}getDrawableParentPartIndex(t){return this._model.drawables.parentPartIndices[t]}getDrawableBlendMode(t){const e=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasBlendAdditiveBit(e[t])?$e.CubismBlendMode_Additive:Live2DCubismCore.Utils.hasBlendMultiplicativeBit(e[t])?$e.CubismBlendMode_Multiplicative:$e.CubismBlendMode_Normal}getDrawableInvertedMaskBit(t){const e=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasIsInvertedMaskBit(e[t])}getDrawableMasks(){return this._model.drawables.masks}getDrawableMaskCounts(){return this._model.drawables.maskCounts}isUsingMasking(){for(let t=0;t<this._model.drawables.count;++t)if(!(this._model.drawables.maskCounts[t]<=0))return!0;return!1}getDrawableDynamicFlagIsVisible(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasIsVisibleBit(e[t])}getDrawableDynamicFlagVisibilityDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVisibilityDidChangeBit(e[t])}getDrawableDynamicFlagOpacityDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasOpacityDidChangeBit(e[t])}getDrawableDynamicFlagRenderOrderDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasRenderOrderDidChangeBit(e[t])}getDrawableDynamicFlagBlendColorDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasBlendColorDidChangeBit(e[t])}loadParameters(){let t=this._model.parameters.count;const e=this._savedParameters.length;t>e&&(t=e);for(let i=0;i<t;++i)this._parameterValues[i]=this._savedParameters[i]}initialize(){this._parameterValues=this._model.parameters.values,this._partOpacities=this._model.parts.opacities,this._parameterMaximumValues=this._model.parameters.maximumValues,this._parameterMinimumValues=this._model.parameters.minimumValues;{const e=this._model.parameters.ids,i=this._model.parameters.count;for(let r=0;r<i;++r)this._parameterIds.push(e[r])}const t=this._model.parts.count;{const e=this._model.parts.ids;for(let i=0;i<t;++i)this._partIds.push(e[i])}{const e=this._model.drawables.ids,i=this._model.drawables.count,r=new Uy(!1,!1);for(let n=0;n<t;++n){const a=new Yt(1,1,1,1),o=new Yt(0,0,0,1),h=new $d(!1,a),l=new $d(!1,o);this._userPartMultiplyColors.push(h),this._userPartScreenColors.push(l),this._partChildDrawables.push([])}for(let n=0;n<i;++n){const a=new Yt(1,1,1,1),o=new Yt(0,0,0,1),h=new Wd(!1,a),l=new Wd(!1,o);this._drawableIds.push(e[n]),this._userMultiplyColors.push(h),this._userScreenColors.push(l),this._userCullings.push(r);const u=this.getDrawableParentPartIndex(n);u>=0&&this._partChildDrawables[u].push(n)}}}constructor(t){this._model=t,this._savedParameters=[],this._parameterIds=[],this._drawableIds=[],this._partIds=[],this._isOverwrittenModelMultiplyColors=!1,this._isOverwrittenModelScreenColors=!1,this._isOverwrittenCullings=!1,this._modelOpacity=1,this._userMultiplyColors=[],this._userScreenColors=[],this._userCullings=[],this._userPartMultiplyColors=[],this._userPartScreenColors=[],this._partChildDrawables=[],this._notExistPartId={},this._notExistParameterId={},this._notExistParameterValues={},this._notExistPartOpacities={},this.initialize()}release(){this._model.release(),this._model=void 0}}class Zo{static create(t,e){if(e&&!this.hasMocConsistency(t))throw new Error("Inconsistent MOC3.");const i=Live2DCubismCore.Moc.fromArrayBuffer(t);if(i){const r=new Zo(i);return r._mocVersion=Live2DCubismCore.Version.csmGetMocVersion(i,t),r}throw new Error("Failed to CubismMoc.create().")}createModel(){let t;const e=Live2DCubismCore.Model.fromMoc(this._moc);if(e)return t=new Gy(e),++this._modelCount,t;throw new Error("Unknown error")}deleteModel(t){t!=null&&--this._modelCount}constructor(t){this._moc=t,this._modelCount=0,this._mocVersion=0}release(){this._moc._release(),this._moc=void 0}getLatestMocVersion(){return Live2DCubismCore.Version.csmGetLatestMocVersion()}getMocVersion(){return this._mocVersion}static hasMocConsistency(t){return Live2DCubismCore.Moc.prototype.hasMocConsistency(t)===1}}var Jo=(s=>(s[s.CubismPhysicsTargetType_Parameter=0]="CubismPhysicsTargetType_Parameter",s))(Jo||{}),Si=(s=>(s[s.CubismPhysicsSource_X=0]="CubismPhysicsSource_X",s[s.CubismPhysicsSource_Y=1]="CubismPhysicsSource_Y",s[s.CubismPhysicsSource_Angle=2]="CubismPhysicsSource_Angle",s))(Si||{});class Vy{constructor(){this.initialPosition=new at(0,0),this.position=new at(0,0),this.lastPosition=new at(0,0),this.lastGravity=new at(0,0),this.force=new at(0,0),this.velocity=new at(0,0)}}class Hy{constructor(){this.normalizationPosition={},this.normalizationAngle={}}}class Xy{constructor(){this.source={}}}class zy{constructor(){this.destination={},this.translationScale=new at(0,0)}}class Wy{constructor(){this.settings=[],this.inputs=[],this.outputs=[],this.particles=[],this.gravity=new at(0,0),this.wind=new at(0,0),this.fps=0}}class $y{constructor(t){this._json=t}release(){this._json=void 0}getGravity(){const t=new at(0,0);return t.x=this._json.Meta.EffectiveForces.Gravity.X,t.y=this._json.Meta.EffectiveForces.Gravity.Y,t}getWind(){const t=new at(0,0);return t.x=this._json.Meta.EffectiveForces.Wind.X,t.y=this._json.Meta.EffectiveForces.Wind.Y,t}getFps(){return this._json.Meta.Fps||0}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 i=new at(0,0);return i.x=this._json.PhysicsSettings[t].Vertices[e].Position.X,i.y=this._json.PhysicsSettings[t].Vertices[e].Position.Y,i}}const jd="X",Yd="Y",qd="Angle",jy=5,Qo=100,Kd=.001,Yy=5;class th{static create(t){const e=new th;return e.parse(t),e._physicsRig.gravity.y=0,e}static delete(t){t!=null&&t.release()}parse(t){this._physicsRig=new Wy;const e=new $y(t);this._physicsRig.gravity=e.getGravity(),this._physicsRig.wind=e.getWind(),this._physicsRig.subRigCount=e.getSubRigCount(),this._physicsRig.fps=e.getFps(),this._currentRigOutputs=[],this._previousRigOutputs=[];let i=0,r=0,n=0;for(let a=0;a<this._physicsRig.subRigCount;++a){const o=new Hy;o.normalizationPosition.minimum=e.getNormalizationPositionMinimumValue(a),o.normalizationPosition.maximum=e.getNormalizationPositionMaximumValue(a),o.normalizationPosition.defalut=e.getNormalizationPositionDefaultValue(a),o.normalizationAngle.minimum=e.getNormalizationAngleMinimumValue(a),o.normalizationAngle.maximum=e.getNormalizationAngleMaximumValue(a),o.normalizationAngle.defalut=e.getNormalizationAngleDefaultValue(a),o.inputCount=e.getInputCount(a),o.baseInputIndex=i,i+=o.inputCount;for(let u=0;u<o.inputCount;++u){const c=new Xy;switch(c.sourceParameterIndex=-1,c.weight=e.getInputWeight(a,u),c.reflect=e.getInputReflect(a,u),e.getInputType(a,u)){case jd:c.type=Si.CubismPhysicsSource_X,c.getNormalizedParameterValue=Ky;break;case Yd:c.type=Si.CubismPhysicsSource_Y,c.getNormalizedParameterValue=Zy;break;case qd:c.type=Si.CubismPhysicsSource_Angle,c.getNormalizedParameterValue=Jy;break}c.source.targetType=Jo.CubismPhysicsTargetType_Parameter,c.source.id=e.getInputSourceId(a,u),this._physicsRig.inputs.push(c)}o.outputCount=e.getOutputCount(a),o.baseOutputIndex=r;const h=new Zd,l=new Zd;for(let u=0;u<o.outputCount;++u){h.outputs[u]=0,l.outputs[u]=0;let c=this._physicsRig.outputs[r+u];switch(c||(c=new zy,this._physicsRig.outputs[r+u]=c),c.destinationParameterIndex=-1,c.vertexIndex=e.getOutputVertexIndex(a,u),c.angleScale=e.getOutputAngleScale(a,u),c.weight=e.getOutputWeight(a,u),c.destination.targetType=Jo.CubismPhysicsTargetType_Parameter,c.destination.id=e.getOutputDestinationId(a,u),e.getOutputType(a,u)){case jd:c.type=Si.CubismPhysicsSource_X,c.getValue=Qy,c.getScale=sv;break;case Yd:c.type=Si.CubismPhysicsSource_Y,c.getValue=tv,c.getScale=nv;break;case qd:c.type=Si.CubismPhysicsSource_Angle,c.getValue=ev,c.getScale=av;break}c.reflect=e.getOutputReflect(a,u)}this._currentRigOutputs.push(h),this._previousRigOutputs.push(l),r+=o.outputCount,o.particleCount=e.getParticleCount(a),o.baseParticleIndex=n,n+=o.particleCount;for(let u=0;u<o.particleCount;++u){const c=new Vy;c.mobility=e.getParticleMobility(a,u),c.delay=e.getParticleDelay(a,u),c.acceleration=e.getParticleAcceleration(a,u),c.radius=e.getParticleRadius(a,u),c.position=e.getParticlePosition(a,u),this._physicsRig.particles.push(c)}this._physicsRig.settings.push(o)}this.initialize(),e.release()}stabilization(t){var e,i,r,n;let a,o,h,l;const u=new at;let c,d,f,p,g,m,_,b;g=t.getModel().parameters.values,m=t.getModel().parameters.maximumValues,_=t.getModel().parameters.minimumValues,b=t.getModel().parameters.defaultValues,((i=(e=this._parameterCaches)==null?void 0:e.length)!=null?i:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),((n=(r=this._parameterInputCaches)==null?void 0:r.length)!=null?n:0)<t.getParameterCount()&&(this._parameterInputCaches=new Float32Array(t.getParameterCount()));for(let y=0;y<t.getParameterCount();++y)this._parameterCaches[y]=g[y],this._parameterInputCaches[y]=g[y];for(let y=0;y<this._physicsRig.subRigCount;++y){a={angle:0},u.x=0,u.y=0,c=this._physicsRig.settings[y],d=this._physicsRig.inputs.slice(c.baseInputIndex),f=this._physicsRig.outputs.slice(c.baseOutputIndex),p=this._physicsRig.particles.slice(c.baseParticleIndex);for(let E=0;E<c.inputCount;++E)o=d[E].weight/Qo,d[E].sourceParameterIndex==-1&&(d[E].sourceParameterIndex=t.getParameterIndex(d[E].source.id)),d[E].getNormalizedParameterValue(u,a,g[d[E].sourceParameterIndex],_[d[E].sourceParameterIndex],m[d[E].sourceParameterIndex],b[d[E].sourceParameterIndex],c.normalizationPosition,c.normalizationAngle,d[E].reflect,o),this._parameterCaches[d[E].sourceParameterIndex]=g[d[E].sourceParameterIndex];h=mt.degreesToRadian(-a.angle),u.x=u.x*mt.cos(h)-u.y*mt.sin(h),u.y=u.x*mt.sin(h)+u.y*mt.cos(h),hv(p,c.particleCount,u,a.angle,this._options.wind,Kd*c.normalizationPosition.maximum);for(let E=0;E<c.outputCount;++E){const v=f[E].vertexIndex;if(f[E].destinationParameterIndex==-1&&(f[E].destinationParameterIndex=t.getParameterIndex(f[E].destination.id)),v<1||v>=c.particleCount)continue;let M=new at;M=p[v].position.substract(p[v-1].position),l=f[E].getValue(M,p,v,f[E].reflect,this._options.gravity),this._currentRigOutputs[y].outputs[E]=l,this._previousRigOutputs[y].outputs[E]=l;const T=f[E].destinationParameterIndex,P=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(g.subarray(T))):g.slice(T);eh(P,_[T],m[T],l,f[E]);for(let N=T,G=0;N<this._parameterCaches.length;N++,G++)g[N]=this._parameterCaches[N]=P[G]}}}evaluate(t,e){var i,r,n,a;let o,h,l,u;const c=new at;let d,f,p,g;if(0>=e)return;let m,_,b,y,E;if(this._currentRemainTime+=e,this._currentRemainTime>Yy&&(this._currentRemainTime=0),m=t.getModel().parameters.values,_=t.getModel().parameters.maximumValues,b=t.getModel().parameters.minimumValues,y=t.getModel().parameters.defaultValues,((r=(i=this._parameterCaches)==null?void 0:i.length)!=null?r:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),((a=(n=this._parameterInputCaches)==null?void 0:n.length)!=null?a:0)<t.getParameterCount()){this._parameterInputCaches=new Float32Array(t.getParameterCount());for(let M=0;M<t.getParameterCount();++M)this._parameterInputCaches[M]=m[M]}for(this._physicsRig.fps>0?E=1/this._physicsRig.fps:E=e;this._currentRemainTime>=E;){for(let T=0;T<this._physicsRig.subRigCount;++T){d=this._physicsRig.settings[T],p=this._physicsRig.outputs.slice(d.baseOutputIndex);for(let P=0;P<d.outputCount;++P)this._previousRigOutputs[T].outputs[P]=this._currentRigOutputs[T].outputs[P]}const M=E/this._currentRemainTime;for(let T=0;T<t.getParameterCount();++T)this._parameterCaches[T]=this._parameterInputCaches[T]*(1-M)+m[T]*M,this._parameterInputCaches[T]=this._parameterCaches[T];for(let T=0;T<this._physicsRig.subRigCount;++T){o={angle:0},c.x=0,c.y=0,d=this._physicsRig.settings[T],f=this._physicsRig.inputs.slice(d.baseInputIndex),p=this._physicsRig.outputs.slice(d.baseOutputIndex),g=this._physicsRig.particles.slice(d.baseParticleIndex);for(let P=0;P<d.inputCount;++P)h=f[P].weight/Qo,f[P].sourceParameterIndex==-1&&(f[P].sourceParameterIndex=t.getParameterIndex(f[P].source.id)),f[P].getNormalizedParameterValue(c,o,this._parameterCaches[f[P].sourceParameterIndex],b[f[P].sourceParameterIndex],_[f[P].sourceParameterIndex],y[f[P].sourceParameterIndex],d.normalizationPosition,d.normalizationAngle,f[P].reflect,h);l=mt.degreesToRadian(-o.angle),c.x=c.x*mt.cos(l)-c.y*mt.sin(l),c.y=c.x*mt.sin(l)+c.y*mt.cos(l),ov(g,d.particleCount,c,o.angle,this._options.wind,Kd*d.normalizationPosition.maximum,E,jy);for(let P=0;P<d.outputCount;++P){const N=p[P].vertexIndex;if(p[P].destinationParameterIndex==-1&&(p[P].destinationParameterIndex=t.getParameterIndex(p[P].destination.id)),N<1||N>=d.particleCount)continue;const G=new at;G.x=g[N].position.x-g[N-1].position.x,G.y=g[N].position.y-g[N-1].position.y,u=p[P].getValue(G,g,N,p[P].reflect,this._options.gravity),this._currentRigOutputs[T].outputs[P]=u;const z=p[P].destinationParameterIndex,D=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(this._parameterCaches.subarray(z))):this._parameterCaches.slice(z);eh(D,b[z],_[z],u,p[P]);for(let O=z,V=0;O<this._parameterCaches.length;O++,V++)this._parameterCaches[O]=D[V]}}this._currentRemainTime-=E}const v=this._currentRemainTime/E;this.interpolate(t,v)}interpolate(t,e){let i,r,n,a,o;n=t.getModel().parameters.values,a=t.getModel().parameters.maximumValues,o=t.getModel().parameters.minimumValues;for(let h=0;h<this._physicsRig.subRigCount;++h){r=this._physicsRig.settings[h],i=this._physicsRig.outputs.slice(r.baseOutputIndex);for(let l=0;l<r.outputCount;++l){if(i[l].destinationParameterIndex==-1)continue;const u=i[l].destinationParameterIndex,c=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(n.subarray(u))):n.slice(u);eh(c,o[u],a[u],this._previousRigOutputs[h].outputs[l]*(1-e)+this._currentRigOutputs[h].outputs[l]*e,i[l]);for(let d=u,f=0;d<n.length;d++,f++)n[d]=c[f]}}}setOptions(t){this._options=t}getOption(){return this._options}constructor(){this._options=new qy,this._options.gravity.y=-1,this._options.gravity.x=0,this._options.wind.x=0,this._options.wind.y=0,this._currentRigOutputs=[],this._previousRigOutputs=[],this._currentRemainTime=0}release(){this._physicsRig=void 0}initialize(){let t,e,i;for(let r=0;r<this._physicsRig.subRigCount;++r){e=this._physicsRig.settings[r],t=this._physicsRig.particles.slice(e.baseParticleIndex),t[0].initialPosition=new at(0,0),t[0].lastPosition=new at(t[0].initialPosition.x,t[0].initialPosition.y),t[0].lastGravity=new at(0,-1),t[0].lastGravity.y*=-1,t[0].velocity=new at(0,0),t[0].force=new at(0,0);for(let n=1;n<e.particleCount;++n)i=new at(0,0),i.y=t[n].radius,t[n].initialPosition=new at(t[n-1].initialPosition.x+i.x,t[n-1].initialPosition.y+i.y),t[n].position=new at(t[n].initialPosition.x,t[n].initialPosition.y),t[n].lastPosition=new at(t[n].initialPosition.x,t[n].initialPosition.y),t[n].lastGravity=new at(0,-1),t[n].lastGravity.y*=-1,t[n].velocity=new at(0,0),t[n].force=new at(0,0)}}}class qy{constructor(){this.gravity=new at(0,0),this.wind=new at(0,0)}}class Zd{constructor(){this.outputs=[]}}function Ky(s,t,e,i,r,n,a,o,h,l){s.x+=ih(e,i,r,n,a.minimum,a.maximum,a.defalut,h)*l}function Zy(s,t,e,i,r,n,a,o,h,l){s.y+=ih(e,i,r,n,a.minimum,a.maximum,a.defalut,h)*l}function Jy(s,t,e,i,r,n,a,o,h,l){t.angle+=ih(e,i,r,n,o.minimum,o.maximum,o.defalut,h)*l}function Qy(s,t,e,i,r){let n=s.x;return i&&(n*=-1),n}function tv(s,t,e,i,r){let n=s.y;return i&&(n*=-1),n}function ev(s,t,e,i,r){let n;return e>=2?r=t[e-1].position.substract(t[e-2].position):r=r.multiplyByScaler(-1),n=mt.directionToRadian(r,s),i&&(n*=-1),n}function iv(s,t){return Math.abs(Math.max(s,t)-Math.min(s,t))}function rv(s,t){return Math.min(s,t)+iv(s,t)/2}function sv(s,t){return s.x}function nv(s,t){return s.y}function av(s,t){return t}function ov(s,t,e,i,r,n,a,o){let h,l,u,c,d=new at(0,0),f=new at(0,0),p=new at(0,0),g=new at(0,0);s[0].position=new at(e.x,e.y),h=mt.degreesToRadian(i),c=mt.radianToDirection(h),c.normalize();for(let m=1;m<t;++m)s[m].force=c.multiplyByScaler(s[m].acceleration).add(r),s[m].lastPosition=new at(s[m].position.x,s[m].position.y),l=s[m].delay*a*30,d=s[m].position.substract(s[m-1].position),u=mt.directionToRadian(s[m].lastGravity,c)/o,d.x=mt.cos(u)*d.x-d.y*mt.sin(u),d.y=mt.sin(u)*d.x+d.y*mt.cos(u),s[m].position=s[m-1].position.add(d),f=s[m].velocity.multiplyByScaler(l),p=s[m].force.multiplyByScaler(l).multiplyByScaler(l),s[m].position=s[m].position.add(f).add(p),g=s[m].position.substract(s[m-1].position),g.normalize(),s[m].position=s[m-1].position.add(g.multiplyByScaler(s[m].radius)),mt.abs(s[m].position.x)<n&&(s[m].position.x=0),l!=0&&(s[m].velocity=s[m].position.substract(s[m].lastPosition),s[m].velocity=s[m].velocity.divisionByScalar(l),s[m].velocity=s[m].velocity.multiplyByScaler(s[m].mobility)),s[m].force=new at(0,0),s[m].lastGravity=new at(c.x,c.y)}function hv(s,t,e,i,r,n){let a,o,h=new at(0,0);s[0].position=new at(e.x,e.y),a=mt.degreesToRadian(i),o=mt.radianToDirection(a),o.normalize();for(let l=1;l<t;++l)s[l].force=o.multiplyByScaler(s[l].acceleration).add(r),s[l].lastPosition=new at(s[l].position.x,s[l].position.y),s[l].velocity=new at(0,0),h=s[l].force,h.normalize(),h=h.multiplyByScaler(s[l].radius),s[l].position=s[l-1].position.add(h),mt.abs(s[l].position.x)<n&&(s[l].position.x=0),s[l].force=new at(0,0),s[l].lastGravity=new at(o.x,o.y)}function eh(s,t,e,i,r){let n,a,o;n=r.getScale(r.translationScale,r.angleScale),a=i*n,a<t?(a<r.valueBelowMinimum&&(r.valueBelowMinimum=a),a=t):a>e&&(a>r.valueExceededMaximum&&(r.valueExceededMaximum=a),a=e),o=r.weight/Qo,o>=1||(a=s[0]*(1-o)+a*o),s[0]=a}function ih(s,t,e,i,r,n,a,o){let h=0;const l=mt.max(e,t);l<s&&(s=l);const u=mt.min(e,t);u>s&&(s=u);const c=mt.min(r,n),d=mt.max(r,n),f=a,p=rv(u,l),g=s-p;switch(Math.sign(g)){case 1:{const m=d-f,_=l-p;_!=0&&(h=g*(m/_),h+=f);break}case-1:{const m=c-f,_=u-p;_!=0&&(h=g*(m/_),h+=f);break}case 0:{h=f;break}}return o?h:h*-1}jt.registerRuntime({version:4,ready:Oy,test(s){return s instanceof Zi||Zi.isValidJSON(s)},isValidMoc(s){if(s.byteLength<4)return!1;const t=new Int8Array(s,0,4);return String.fromCharCode(...t)==="MOC3"},createModelSettings(s){return new Zi(s)},createCoreModel(s,t){const e=Zo.create(s,!!(t!=null&&t.checkMocConsistency));try{const i=e.createModel();return i.__moc=e,i}catch(i){try{e.release()}catch{}throw i}},createInternalModel(s,t,e){const i=new Ly(s,t,e),r=s;return r.__moc&&(i.__moc=r.__moc,delete r.__moc,i.once("destroy",lv)),i},createPhysics(s,t){return th.create(t)},createPose(s,t){return Ko.create(t)}});function lv(){var s;(s=this.__moc)==null||s.release()}async function uv(s){const{models:t,element_id:e,auto_fit:i=!0,auto_motion:r=!0,mouse_tracking:n=!0}=s,a=new fo({view:document.getElementById(e),width:300,height:300,backgroundAlpha:0,autoDensity:!0,antialias:!0}),o=await Ho.from(t[0]);if(a.stage.addChild(o),i){const h=Math.min(300/o.width,300/o.height);o.scale.set(h),o.x=(300-o.width*h)/2,o.y=(300-o.height*h)/2}return n&&cv(o,a.view),r&&await dv(o),o}function cv(s,t){document.addEventListener("mousemove",e=>{var h;const i=t.getBoundingClientRect(),r=i.left+i.width/2,n=i.top+i.height/2,a=(e.clientX-r)/i.width,o=(e.clientY-n)/i.height;s.internalModel&&((h=s.internalModel.focusController)==null||h.focus(a,o))})}async function dv(s){var t;try{const e=(t=s.internalModel)==null?void 0:t.motionManager.definitions;if(e)if(e.idle)await s.motion("idle");else if(e.tap_body)await s.motion("tap_body");else{const i=Object.keys(e)[0];i&&await s.motion(i)}}catch(e){console.warn("Failed to start idle animation:",e)}}async function fv(s,t){Ho.registerTicker(Pt),Q.add(As),Q.add(x_)}ae.Live2DModel=Ho,ae.MotionManager=zr,ae.PIXI=m_,ae.SoundManager=Dt,ae.createLive2dModel=uv,ae.initializeLive2D=fv,Object.defineProperty(ae,Symbol.toStringTag,{value:"Module"})});