pastel.codes/obsidian/lib/scripts/pixi.js
2024-04-29 14:52:09 +01:00

1 line
439 KiB
JavaScript

var qd=Object.defineProperty,Kd=Object.defineProperties,Zd=Object.getOwnPropertyDescriptors,ir=Object.getOwnPropertySymbols,$h=Object.prototype.hasOwnProperty,jh=Object.prototype.propertyIsEnumerable,Wh=(t,e,s)=>e in t?qd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,bt=(t,e)=>{for(var s in e||(e={}))$h.call(e,s)&&Wh(t,s,e[s]);if(ir)for(var s of ir(e))jh.call(e,s)&&Wh(t,s,e[s]);return t},Qi=(t,e)=>Kd(t,Zd(e)),zn=(t,e)=>{var s={};for(var i in t)$h.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&ir)for(var i of ir(t))e.indexOf(i)<0&&jh.call(t,i)&&(s[i]=t[i]);return s},PIXI=function(t){var e,s,i=((s=i||{})[s.WEBGL_LEGACY=0]="WEBGL_LEGACY",s[s.WEBGL=1]="WEBGL",s[s.WEBGL2=2]="WEBGL2",s),r=(t=>(t[t.UNKNOWN=0]="UNKNOWN",t[t.WEBGL=1]="WEBGL",t[t.CANVAS=2]="CANVAS",t))(r||{}),n=(t=>(t[t.COLOR=16384]="COLOR",t[t.DEPTH=256]="DEPTH",t[t.STENCIL=1024]="STENCIL",t))(n||{}),a=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ADD=1]="ADD",t[t.MULTIPLY=2]="MULTIPLY",t[t.SCREEN=3]="SCREEN",t[t.OVERLAY=4]="OVERLAY",t[t.DARKEN=5]="DARKEN",t[t.LIGHTEN=6]="LIGHTEN",t[t.COLOR_DODGE=7]="COLOR_DODGE",t[t.COLOR_BURN=8]="COLOR_BURN",t[t.HARD_LIGHT=9]="HARD_LIGHT",t[t.SOFT_LIGHT=10]="SOFT_LIGHT",t[t.DIFFERENCE=11]="DIFFERENCE",t[t.EXCLUSION=12]="EXCLUSION",t[t.HUE=13]="HUE",t[t.SATURATION=14]="SATURATION",t[t.COLOR=15]="COLOR",t[t.LUMINOSITY=16]="LUMINOSITY",t[t.NORMAL_NPM=17]="NORMAL_NPM",t[t.ADD_NPM=18]="ADD_NPM",t[t.SCREEN_NPM=19]="SCREEN_NPM",t[t.NONE=20]="NONE",t[t.SRC_OVER=0]="SRC_OVER",t[t.SRC_IN=21]="SRC_IN",t[t.SRC_OUT=22]="SRC_OUT",t[t.SRC_ATOP=23]="SRC_ATOP",t[t.DST_OVER=24]="DST_OVER",t[t.DST_IN=25]="DST_IN",t[t.DST_OUT=26]="DST_OUT",t[t.DST_ATOP=27]="DST_ATOP",t[t.ERASE=26]="ERASE",t[t.SUBTRACT=28]="SUBTRACT",t[t.XOR=29]="XOR",t))(a||{}),o=(t=>(t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t))(o||{}),h=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(h||{}),l=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(l||{}),u=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(u||{}),d=(t=>(t[t.FLOAT=0]="FLOAT",t[t.INT=1]="INT",t[t.UINT=2]="UINT",t))(d||{}),c=(t=>(t[t.NEAREST=0]="NEAREST",t[t.LINEAR=1]="LINEAR",t))(c||{}),p=(t=>(t[t.CLAMP=33071]="CLAMP",t[t.REPEAT=10497]="REPEAT",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t))(p||{}),f=(t=>(t[t.OFF=0]="OFF",t[t.POW2=1]="POW2",t[t.ON=2]="ON",t[t.ON_MANUAL=3]="ON_MANUAL",t))(f||{}),m=(t=>(t[t.NPM=0]="NPM",t[t.UNPACK=1]="UNPACK",t[t.PMA=2]="PMA",t[t.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",t[t.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",t[t.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",t))(m||{}),_=(t=>(t[t.NO=0]="NO",t[t.YES=1]="YES",t[t.AUTO=2]="AUTO",t[t.BLEND=0]="BLEND",t[t.CLEAR=1]="CLEAR",t[t.BLIT=2]="BLIT",t))(_||{}),g=(t=>(t[t.AUTO=0]="AUTO",t[t.MANUAL=1]="MANUAL",t))(g||{}),x=(t=>(t.LOW="lowp",t.MEDIUM="mediump",t.HIGH="highp",t))(x||{}),v=(t=>(t[t.NONE=0]="NONE",t[t.SCISSOR=1]="SCISSOR",t[t.STENCIL=2]="STENCIL",t[t.SPRITE=3]="SPRITE",t[t.COLOR=4]="COLOR",t))(v||{}),y=(t=>(t[t.RED=1]="RED",t[t.GREEN=2]="GREEN",t[t.BLUE=4]="BLUE",t[t.ALPHA=8]="ALPHA",t))(y||{}),T=(t=>(t[t.NONE=0]="NONE",t[t.LOW=2]="LOW",t[t.MEDIUM=4]="MEDIUM",t[t.HIGH=8]="HIGH",t))(T||{}),b=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(b||{});const E={createCanvas:(t,e)=>{const s=document.createElement("canvas");return s.width=t,s.height=e,s},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>{var t;return null!=(t=document.baseURI)?t:window.location.href},getFontFaceSet:()=>document.fonts,fetch:(t,e)=>fetch(t,e),parseXML:t=>(new DOMParser).parseFromString(t,"text/xml")},A={ADAPTER:E,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var R=/iPhone/i,S=/iPod/i,w=/iPad/i,I=/\biOS-universal(?:.+)Mac\b/i,M=/\bAndroid(?:.+)Mobile\b/i,C=/Android/i,D=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,P=/Silk/i,O=/Windows Phone/i,F=/\bWindows(?:.+)ARM\b/i,B=/BlackBerry/i,N=/BB10/i,L=/Opera Mini/i,G=/\b(CriOS|Chrome)(?:.+)Mobile/i,U=/Mobile(?:.+)Firefox\b/i,k=function(t){return void 0!==t&&"MacIntel"===t.platform&&"number"==typeof t.maxTouchPoints&&t.maxTouchPoints>1&&"undefined"==typeof MSStream};function X(t){var e={userAgent:"",platform:"",maxTouchPoints:0};t||"undefined"==typeof navigator?"string"==typeof t?e.userAgent=t:t&&t.userAgent&&(e={userAgent:t.userAgent,platform:t.platform,maxTouchPoints:t.maxTouchPoints||0}):e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0};var s=e.userAgent,i=s.split("[FBAN");void 0!==i[1]&&(s=i[0]),void 0!==(i=s.split("Twitter"))[1]&&(s=i[0]);var r=function(t){return function(e){return e.test(t)}}(s),n={apple:{phone:r(R)&&!r(O),ipod:r(S),tablet:!r(R)&&(r(w)||k(e))&&!r(O),universal:r(I),device:(r(R)||r(S)||r(w)||r(I)||k(e))&&!r(O)},amazon:{phone:r(D),tablet:!r(D)&&r(P),device:r(D)||r(P)},android:{phone:!r(O)&&r(D)||!r(O)&&r(M),tablet:!r(O)&&!r(D)&&!r(M)&&(r(P)||r(C)),device:!r(O)&&(r(D)||r(P)||r(M)||r(C))||r(/\bokhttp\b/i)},windows:{phone:r(O),tablet:r(F),device:r(O)||r(F)},other:{blackberry:r(B),blackberry10:r(N),opera:r(L),firefox:r(U),chrome:r(G),device:r(B)||r(N)||r(L)||r(U)||r(G)},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 H=(null!=(e=X.default)?e:X)(globalThis.navigator);A.RETINA_PREFIX=/@([0-9\.]+)x/,A.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var V="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function z(t,e,s){return t(s={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&s.path)}},s.exports),s.exports}var W=z((function(t){"use strict";var e=Object.prototype.hasOwnProperty,s="~";function i(){}function r(t,e,s){this.fn=t,this.context=e,this.once=s||!1}function n(t,e,i,n,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new r(i,n||t,a),h=s?s+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],o]:t._events[h].push(o):(t._events[h]=o,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(s=!1)),o.prototype.eventNames=function(){var t,i,r=[];if(0===this._eventsCount)return r;for(i in t=this._events)e.call(t,i)&&r.push(s?i.slice(1):i);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},o.prototype.listeners=function(t){var e=s?s+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,n=i.length,a=new Array(n);r<n;r++)a[r]=i[r].fn;return a},o.prototype.listenerCount=function(t){var e=s?s+t:t,i=this._events[e];return i?i.fn?1:i.length:0},o.prototype.emit=function(t,e,i,r,n,a){var o=s?s+t:t;if(!this._events[o])return!1;var h,l,u=this._events[o],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(t,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,e),!0;case 3:return u.fn.call(u.context,e,i),!0;case 4:return u.fn.call(u.context,e,i,r),!0;case 5:return u.fn.call(u.context,e,i,r,n),!0;case 6:return u.fn.call(u.context,e,i,r,n,a),!0}for(l=1,h=new Array(d-1);l<d;l++)h[l-1]=arguments[l];u.fn.apply(u.context,h)}else{var c,p=u.length;for(l=0;l<p;l++)switch(u[l].once&&this.removeListener(t,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,e);break;case 3:u[l].fn.call(u[l].context,e,i);break;case 4:u[l].fn.call(u[l].context,e,i,r);break;default:if(!h)for(c=1,h=new Array(d-1);c<d;c++)h[c-1]=arguments[c];u[l].fn.apply(u[l].context,h)}}return!0},o.prototype.on=function(t,e,s){return n(this,t,e,s,!1)},o.prototype.once=function(t,e,s){return n(this,t,e,s,!0)},o.prototype.removeListener=function(t,e,i,r){var n=s?s+t:t;if(!this._events[n])return this;if(!e)return a(this,n),this;var o=this._events[n];if(o.fn)o.fn===e&&(!r||o.once)&&(!i||o.context===i)&&a(this,n);else{for(var h=0,l=[],u=o.length;h<u;h++)(o[h].fn!==e||r&&!o[h].once||i&&o[h].context!==i)&&l.push(o[h]);l.length?this._events[n]=1===l.length?l[0]:l:a(this,n)}return this},o.prototype.removeAllListeners=function(t){var e;return t?(e=s?s+t:t,this._events[e]&&a(this,e)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=s,o.EventEmitter=o,t.exports=o})),Y=$,j=$;function $(t,e,s){s=s||2;var i,r,n,a,o,h,l,u=e&&e.length,d=u?e[0]*s:t.length,c=q(t,0,d,s,!0),p=[];if(!c||c.next===c.prev)return p;if(u&&(c=function(t,e,s,i){var r,n,a,o,h,l=[];for(r=0,n=e.length;r<n;r++)a=e[r]*i,o=r<n-1?e[r+1]*i:t.length,(h=q(t,a,o,i,!1))===h.next&&(h.steiner=!0),l.push(at(h));for(l.sort(st),r=0;r<l.length;r++)s=it(l[r],s);return s}(t,e,c,s)),t.length>80*s){i=n=t[0],r=a=t[1];for(var f=s;f<d;f+=s)(o=t[f])<i&&(i=o),(h=t[f+1])<r&&(r=h),o>n&&(n=o),h>a&&(a=h);l=0!==(l=Math.max(n-i,a-r))?32767/l:0}return Z(c,p,s,i,r,l,0),p}function q(t,e,s,i,r){var n,a;if(r===vt(t,e,s,i)>0)for(n=e;n<s;n+=i)a=_t(n,t[n],t[n+1],a);else for(n=s-i;n>=e;n-=i)a=_t(n,t[n],t[n+1],a);return a&&ut(a,a.next)&&(gt(a),a=a.next),a}function K(t,e){if(!t)return t;e||(e=t);var s,i=t;do{if(s=!1,i.steiner||!ut(i,i.next)&&0!==lt(i.prev,i,i.next))i=i.next;else{if(gt(i),(i=e=i.prev)===i.next)break;s=!0}}while(s||i!==e);return e}function Z(t,e,s,i,r,n,a){if(t){!a&&n&&function(t,e,s,i){var r=t;do{0===r.z&&(r.z=nt(r.x,r.y,e,s,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,s,i,r,n,a,o,h,l=1;do{for(s=t,t=null,n=null,a=0;s;){for(a++,i=s,o=0,e=0;e<l&&(o++,i=i.nextZ);e++);for(h=l;o>0||h>0&&i;)0!==o&&(0===h||!i||s.z<=i.z)?(r=s,s=s.nextZ,o--):(r=i,i=i.nextZ,h--),n?n.nextZ=r:t=r,r.prevZ=n,n=r;s=i}n.nextZ=null,l*=2}while(a>1)}(r)}(t,i,r,n);for(var o,h,l=t;t.prev!==t.next;)if(o=t.prev,h=t.next,n?J(t,i,r,n):Q(t))e.push(o.i/s|0),e.push(t.i/s|0),e.push(h.i/s|0),gt(t),t=h.next,l=h.next;else if((t=h)===l){a?1===a?Z(t=tt(K(t),e,s),e,s,i,r,n,2):2===a&&et(t,e,s,i,r,n):Z(K(t),e,s,i,r,n,1);break}}}function Q(t){var e=t.prev,s=t,i=t.next;if(lt(e,s,i)>=0)return!1;for(var r=e.x,n=s.x,a=i.x,o=e.y,h=s.y,l=i.y,u=r<n?r<a?r:a:n<a?n:a,d=o<h?o<l?o:l:h<l?h:l,c=r>n?r>a?r:a:n>a?n:a,p=o>h?o>l?o:l:h>l?h:l,f=i.next;f!==e;){if(f.x>=u&&f.x<=c&&f.y>=d&&f.y<=p&&ot(r,o,n,h,a,l,f.x,f.y)&&lt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function J(t,e,s,i){var r=t.prev,n=t,a=t.next;if(lt(r,n,a)>=0)return!1;for(var o=r.x,h=n.x,l=a.x,u=r.y,d=n.y,c=a.y,p=o<h?o<l?o:l:h<l?h:l,f=u<d?u<c?u:c:d<c?d:c,m=o>h?o>l?o:l:h>l?h:l,_=u>d?u>c?u:c:d>c?d:c,g=nt(p,f,e,s,i),x=nt(m,_,e,s,i),v=t.prevZ,y=t.nextZ;v&&v.z>=g&&y&&y.z<=x;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==r&&v!==a&&ot(o,u,h,d,l,c,v.x,v.y)&&lt(v.prev,v,v.next)>=0||(v=v.prevZ,y.x>=p&&y.x<=m&&y.y>=f&&y.y<=_&&y!==r&&y!==a&&ot(o,u,h,d,l,c,y.x,y.y)&&lt(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==r&&v!==a&&ot(o,u,h,d,l,c,v.x,v.y)&&lt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;y&&y.z<=x;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=_&&y!==r&&y!==a&&ot(o,u,h,d,l,c,y.x,y.y)&&lt(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function tt(t,e,s){var i=t;do{var r=i.prev,n=i.next.next;!ut(r,n)&&dt(r,i,i.next,n)&&ft(r,n)&&ft(n,r)&&(e.push(r.i/s|0),e.push(i.i/s|0),e.push(n.i/s|0),gt(i),gt(i.next),i=t=n),i=i.next}while(i!==t);return K(i)}function et(t,e,s,i,r,n){var a=t;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&ht(a,o)){var h=mt(a,o);return a=K(a,a.next),h=K(h,h.next),Z(a,e,s,i,r,n,0),void Z(h,e,s,i,r,n,0)}o=o.next}a=a.next}while(a!==t)}function st(t,e){return t.x-e.x}function it(t,e){var s=function(t,e){var s,i=e,r=t.x,n=t.y,a=-1/0;do{if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){var o=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(o<=r&&o>a&&(a=o,s=i.x<i.next.x?i:i.next,o===r))return s}i=i.next}while(i!==e);if(!s)return null;var h,l=s,u=s.x,d=s.y,c=1/0;i=s;do{r>=i.x&&i.x>=u&&r!==i.x&&ot(n<d?r:a,n,u,d,n<d?a:r,n,i.x,i.y)&&(h=Math.abs(n-i.y)/(r-i.x),ft(i,t)&&(h<c||h===c&&(i.x>s.x||i.x===s.x&&rt(s,i)))&&(s=i,c=h)),i=i.next}while(i!==l);return s}(t,e);if(!s)return e;var i=mt(s,t);return K(i,i.next),K(s,s.next)}function rt(t,e){return lt(t.prev,t,e.prev)<0&&lt(e.next,t,t.next)<0}function nt(t,e,s,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function at(t){var e=t,s=t;do{(e.x<s.x||e.x===s.x&&e.y<s.y)&&(s=e),e=e.next}while(e!==t);return s}function ot(t,e,s,i,r,n,a,o){return(r-a)*(e-o)>=(t-a)*(n-o)&&(t-a)*(i-o)>=(s-a)*(e-o)&&(s-a)*(n-o)>=(r-a)*(i-o)}function ht(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var s=t;do{if(s.i!==t.i&&s.next.i!==t.i&&s.i!==e.i&&s.next.i!==e.i&&dt(s,s.next,t,e))return!0;s=s.next}while(s!==t);return!1}(t,e)&&(ft(t,e)&&ft(e,t)&&function(t,e){var s=t,i=!1,r=(t.x+e.x)/2,n=(t.y+e.y)/2;do{s.y>n!=s.next.y>n&&s.next.y!==s.y&&r<(s.next.x-s.x)*(n-s.y)/(s.next.y-s.y)+s.x&&(i=!i),s=s.next}while(s!==t);return i}(t,e)&&(lt(t.prev,t,e.prev)||lt(t,e.prev,e))||ut(t,e)&&lt(t.prev,t,t.next)>0&&lt(e.prev,e,e.next)>0)}function lt(t,e,s){return(e.y-t.y)*(s.x-e.x)-(e.x-t.x)*(s.y-e.y)}function ut(t,e){return t.x===e.x&&t.y===e.y}function dt(t,e,s,i){var r=pt(lt(t,e,s)),n=pt(lt(t,e,i)),a=pt(lt(s,i,t)),o=pt(lt(s,i,e));return!!(r!==n&&a!==o||0===r&&ct(t,s,e)||0===n&&ct(t,i,e)||0===a&&ct(s,t,i)||0===o&&ct(s,e,i))}function ct(t,e,s){return e.x<=Math.max(t.x,s.x)&&e.x>=Math.min(t.x,s.x)&&e.y<=Math.max(t.y,s.y)&&e.y>=Math.min(t.y,s.y)}function pt(t){return t>0?1:t<0?-1:0}function ft(t,e){return lt(t.prev,t,t.next)<0?lt(t,e,t.next)>=0&&lt(t,t.prev,e)>=0:lt(t,e,t.prev)<0||lt(t,t.next,e)<0}function mt(t,e){var s=new xt(t.i,t.x,t.y),i=new xt(e.i,e.x,e.y),r=t.next,n=e.prev;return t.next=e,e.prev=t,s.next=r,r.prev=s,i.next=s,s.prev=i,n.next=i,i.prev=n,i}function _t(t,e,s,i){var r=new xt(t,e,s);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function gt(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function xt(t,e,s){this.i=t,this.x=e,this.y=s,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function vt(t,e,s,i){for(var r=0,n=e,a=s-i;n<s;n+=i)r+=(t[a]-t[n])*(t[n+1]+t[a+1]),a=n;return r}$.deviation=function(t,e,s,i){var r=e&&e.length,n=r?e[0]*s:t.length,a=Math.abs(vt(t,0,n,s));if(r)for(var o=0,h=e.length;o<h;o++){var l=e[o]*s,u=o<h-1?e[o+1]*s:t.length;a-=Math.abs(vt(t,l,u,s))}var d=0;for(o=0;o<i.length;o+=3){var c=i[o]*s,p=i[o+1]*s,f=i[o+2]*s;d+=Math.abs((t[c]-t[f])*(t[p+1]-t[c+1])-(t[c]-t[p])*(t[f+1]-t[c+1]))}return 0===a&&0===d?0:Math.abs((d-a)/a)},$.flatten=function(t){for(var e=t[0][0].length,s={vertices:[],holes:[],dimensions:e},i=0,r=0;r<t.length;r++){for(var n=0;n<t[r].length;n++)for(var a=0;a<e;a++)s.vertices.push(t[r][n][a]);r>0&&(i+=t[r-1].length,s.holes.push(i))}return s},Y.default=j;var yt=z((function(t,e){/*! https://mths.be/punycode v1.3.2 by @mathias */!function(s){var i=e&&!e.nodeType&&e,r=t&&!t.nodeType&&t,n="object"==typeof V&&V;(n.global===n||n.window===n||n.self===n)&&(s=n);var a,o,h=2147483647,l=36,u=1,d=26,c=38,p=700,f=72,m=128,_="-",g=/^xn--/,x=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,y={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},T=l-u,b=Math.floor,E=String.fromCharCode;function A(t){throw RangeError(y[t])}function R(t,e){for(var s=t.length,i=[];s--;)i[s]=e(t[s]);return i}function S(t,e){var s=t.split("@"),i="";return s.length>1&&(i=s[0]+"@",t=s[1]),i+R((t=t.replace(v,".")).split("."),e).join(".")}function w(t){for(var e,s,i=[],r=0,n=t.length;r<n;)(e=t.charCodeAt(r++))>=55296&&e<=56319&&r<n?56320==(64512&(s=t.charCodeAt(r++)))?i.push(((1023&e)<<10)+(1023&s)+65536):(i.push(e),r--):i.push(e);return i}function I(t){return R(t,(function(t){var e="";return t>65535&&(e+=E((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=E(t)})).join("")}function M(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:l}function C(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function D(t,e,s){var i=0;for(t=s?b(t/p):t>>1,t+=b(t/e);t>T*d>>1;i+=l)t=b(t/T);return b(i+(T+1)*t/(t+c))}function P(t){var e,s,i,r,n,a,o,c,p,g,x=[],v=t.length,y=0,T=m,E=f;for((s=t.lastIndexOf(_))<0&&(s=0),i=0;i<s;++i)t.charCodeAt(i)>=128&&A("not-basic"),x.push(t.charCodeAt(i));for(r=s>0?s+1:0;r<v;){for(n=y,a=1,o=l;r>=v&&A("invalid-input"),((c=M(t.charCodeAt(r++)))>=l||c>b((h-y)/a))&&A("overflow"),y+=c*a,!(c<(p=o<=E?u:o>=E+d?d:o-E));o+=l)a>b(h/(g=l-p))&&A("overflow"),a*=g;E=D(y-n,e=x.length+1,0==n),b(y/e)>h-T&&A("overflow"),T+=b(y/e),y%=e,x.splice(y++,0,T)}return I(x)}function O(t){var e,s,i,r,n,a,o,c,p,g,x,v,y,T,R,S=[];for(v=(t=w(t)).length,e=m,s=0,n=f,a=0;a<v;++a)(x=t[a])<128&&S.push(E(x));for(i=r=S.length,r&&S.push(_);i<v;){for(o=h,a=0;a<v;++a)(x=t[a])>=e&&x<o&&(o=x);for(o-e>b((h-s)/(y=i+1))&&A("overflow"),s+=(o-e)*y,e=o,a=0;a<v;++a)if((x=t[a])<e&&++s>h&&A("overflow"),x==e){for(c=s,p=l;!(c<(g=p<=n?u:p>=n+d?d:p-n));p+=l)R=c-g,T=l-g,S.push(E(C(g+R%T,0))),c=b(R/T);S.push(E(C(c,0))),n=D(s,y,i==r),s=0,++i}++s,++e}return S.join("")}if(a={version:"1.3.2",ucs2:{decode:w,encode:I},decode:P,encode:O,toASCII:function(t){return S(t,(function(t){return x.test(t)?"xn--"+O(t):t}))},toUnicode:function(t){return S(t,(function(t){return g.test(t)?P(t.slice(4).toLowerCase()):t}))}},i&&r)if(t.exports==i)r.exports=a;else for(o in a)a.hasOwnProperty(o)&&(i[o]=a[o]);else s.punycode=a}(V)})),Tt={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}};function Et(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var At=function(t,e,s,i){e=e||"&",s=s||"=";var r={};if("string"!=typeof t||0===t.length)return r;var n=/\+/g;t=t.split(e);var a=1e3;i&&"number"==typeof i.maxKeys&&(a=i.maxKeys);var o=t.length;a>0&&o>a&&(o=a);for(var h=0;h<o;++h){var l,u,d,c,p=t[h].replace(n,"%20"),f=p.indexOf(s);f>=0?(l=p.substr(0,f),u=p.substr(f+1)):(l=p,u=""),d=decodeURIComponent(l),c=decodeURIComponent(u),Et(r,d)?Array.isArray(r[d])?r[d].push(c):r[d]=[r[d],c]:r[d]=c}return r},Rt=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}},St=function(t,e,s,i){return e=e||"&",s=s||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map((function(i){var r=encodeURIComponent(Rt(i))+s;return Array.isArray(t[i])?t[i].map((function(t){return r+encodeURIComponent(Rt(t))})).join(e):r+encodeURIComponent(Rt(t[i]))})).join(e):i?encodeURIComponent(Rt(i))+s+encodeURIComponent(Rt(t)):""},wt=z((function(t,e){"use strict";e.decode=e.parse=At,e.encode=e.stringify=St})),It=zt,Mt=function(t,e){return zt(t,!1,!0).resolve(e)},Ct=function(t){return Tt.isString(t)&&(t=zt(t)),t instanceof Dt?t.format():Dt.prototype.format.call(t)};function Dt(){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 Pt=/^([a-z0-9.+-]+:)/i,Ot=/:[0-9]*$/,Ft=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Bt=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),Nt=["'"].concat(Bt),Lt=["%","/","?",";","#"].concat(Nt),Gt=["/","?","#"],Ut=/^[+a-z0-9A-Z_-]{0,63}$/,kt=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Xt={javascript:!0,"javascript:":!0},Ht={javascript:!0,"javascript:":!0},Vt={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function zt(t,e,s){if(t&&Tt.isObject(t)&&t instanceof Dt)return t;var i=new Dt;return i.parse(t,e,s),i}Dt.prototype.parse=function(t,e,s){if(!Tt.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var i=t.indexOf("?"),r=-1!==i&&i<t.indexOf("#")?"?":"#",n=t.split(r);n[0]=n[0].replace(/\\/g,"/");var a=t=n.join(r);if(a=a.trim(),!s&&1===t.split("#").length){var o=Ft.exec(a);if(o)return this.path=a,this.href=a,this.pathname=o[1],o[2]?(this.search=o[2],this.query=e?wt.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var h=Pt.exec(a);if(h){var l=(h=h[0]).toLowerCase();this.protocol=l,a=a.substr(h.length)}if(s||h||a.match(/^\/\/[^@\/]+@[^@\/]+/)){var u="//"===a.substr(0,2);u&&(!h||!Ht[h])&&(a=a.substr(2),this.slashes=!0)}if(!Ht[h]&&(u||h&&!Vt[h])){for(var d=-1,c=0;c<Gt.length;c++){-1!==(m=a.indexOf(Gt[c]))&&(-1===d||m<d)&&(d=m)}var p,f;-1!==(f=-1===d?a.lastIndexOf("@"):a.lastIndexOf("@",d))&&(p=a.slice(0,f),a=a.slice(f+1),this.auth=decodeURIComponent(p)),d=-1;for(c=0;c<Lt.length;c++){var m;-1!==(m=a.indexOf(Lt[c]))&&(-1===d||m<d)&&(d=m)}-1===d&&(d=a.length),this.host=a.slice(0,d),a=a.slice(d),this.parseHost(),this.hostname=this.hostname||"";var _="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!_)for(var g=this.hostname.split(/\./),x=(c=0,g.length);c<x;c++){var v=g[c];if(v&&!v.match(Ut)){for(var y="",T=0,b=v.length;T<b;T++)v.charCodeAt(T)>127?y+="x":y+=v[T];if(!y.match(Ut)){var E=g.slice(0,c),A=g.slice(c+1),R=v.match(kt);R&&(E.push(R[1]),A.unshift(R[2])),A.length&&(a="/"+A.join(".")+a),this.hostname=E.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),_||(this.hostname=yt.toASCII(this.hostname));var S=this.port?":"+this.port:"",w=this.hostname||"";this.host=w+S,this.href+=this.host,_&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!Xt[l])for(c=0,x=Nt.length;c<x;c++){var I=Nt[c];if(-1!==a.indexOf(I)){var M=encodeURIComponent(I);M===I&&(M=escape(I)),a=a.split(I).join(M)}}var C=a.indexOf("#");-1!==C&&(this.hash=a.substr(C),a=a.slice(0,C));var D=a.indexOf("?");if(-1!==D?(this.search=a.substr(D),this.query=a.substr(D+1),e&&(this.query=wt.parse(this.query)),a=a.slice(0,D)):e&&(this.search="",this.query={}),a&&(this.pathname=a),Vt[l]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){S=this.pathname||"";var P=this.search||"";this.path=S+P}return this.href=this.format(),this},Dt.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",s=this.pathname||"",i=this.hash||"",r=!1,n="";this.host?r=t+this.host:this.hostname&&(r=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(r+=":"+this.port)),this.query&&Tt.isObject(this.query)&&Object.keys(this.query).length&&(n=wt.stringify(this.query));var a=this.search||n&&"?"+n||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||Vt[e])&&!1!==r?(r="//"+(r||""),s&&"/"!==s.charAt(0)&&(s="/"+s)):r||(r=""),i&&"#"!==i.charAt(0)&&(i="#"+i),a&&"?"!==a.charAt(0)&&(a="?"+a),e+r+(s=s.replace(/[?#]/g,(function(t){return encodeURIComponent(t)})))+(a=a.replace("#","%23"))+i},Dt.prototype.resolve=function(t){return this.resolveObject(zt(t,!1,!0)).format()},Dt.prototype.resolveObject=function(t){if(Tt.isString(t)){var e=new Dt;e.parse(t,!1,!0),t=e}for(var s=new Dt,i=Object.keys(this),r=0;r<i.length;r++){var n=i[r];s[n]=this[n]}if(s.hash=t.hash,""===t.href)return s.href=s.format(),s;if(t.slashes&&!t.protocol){for(var a=Object.keys(t),o=0;o<a.length;o++){var h=a[o];"protocol"!==h&&(s[h]=t[h])}return Vt[s.protocol]&&s.hostname&&!s.pathname&&(s.path=s.pathname="/"),s.href=s.format(),s}if(t.protocol&&t.protocol!==s.protocol){if(!Vt[t.protocol]){for(var l=Object.keys(t),u=0;u<l.length;u++){var d=l[u];s[d]=t[d]}return s.href=s.format(),s}if(s.protocol=t.protocol,t.host||Ht[t.protocol])s.pathname=t.pathname;else{for(var c=(t.pathname||"").split("/");c.length&&!(t.host=c.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==c[0]&&c.unshift(""),c.length<2&&c.unshift(""),s.pathname=c.join("/")}if(s.search=t.search,s.query=t.query,s.host=t.host||"",s.auth=t.auth,s.hostname=t.hostname||t.host,s.port=t.port,s.pathname||s.search){var p=s.pathname||"",f=s.search||"";s.path=p+f}return s.slashes=s.slashes||t.slashes,s.href=s.format(),s}var m=s.pathname&&"/"===s.pathname.charAt(0),_=t.host||t.pathname&&"/"===t.pathname.charAt(0),g=_||m||s.host&&t.pathname,x=g,v=s.pathname&&s.pathname.split("/")||[],y=(c=t.pathname&&t.pathname.split("/")||[],s.protocol&&!Vt[s.protocol]);if(y&&(s.hostname="",s.port=null,s.host&&(""===v[0]?v[0]=s.host:v.unshift(s.host)),s.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===c[0]?c[0]=t.host:c.unshift(t.host)),t.host=null),g=g&&(""===c[0]||""===v[0])),_)s.host=t.host||""===t.host?t.host:s.host,s.hostname=t.hostname||""===t.hostname?t.hostname:s.hostname,s.search=t.search,s.query=t.query,v=c;else if(c.length)v||(v=[]),v.pop(),v=v.concat(c),s.search=t.search,s.query=t.query;else if(!Tt.isNullOrUndefined(t.search)){if(y)s.hostname=s.host=v.shift(),(R=!!(s.host&&s.host.indexOf("@")>0)&&s.host.split("@"))&&(s.auth=R.shift(),s.host=s.hostname=R.shift());return s.search=t.search,s.query=t.query,(!Tt.isNull(s.pathname)||!Tt.isNull(s.search))&&(s.path=(s.pathname?s.pathname:"")+(s.search?s.search:"")),s.href=s.format(),s}if(!v.length)return s.pathname=null,s.search?s.path="/"+s.search:s.path=null,s.href=s.format(),s;for(var T=v.slice(-1)[0],b=(s.host||t.host||v.length>1)&&("."===T||".."===T)||""===T,E=0,A=v.length;A>=0;A--)"."===(T=v[A])?v.splice(A,1):".."===T?(v.splice(A,1),E++):E&&(v.splice(A,1),E--);if(!g&&!x)for(;E--;E)v.unshift("..");g&&""!==v[0]&&(!v[0]||"/"!==v[0].charAt(0))&&v.unshift(""),b&&"/"!==v.join("/").substr(-1)&&v.push("");var R,S=""===v[0]||v[0]&&"/"===v[0].charAt(0);y&&(s.hostname=s.host=S?"":v.length?v.shift():"",(R=!!(s.host&&s.host.indexOf("@")>0)&&s.host.split("@"))&&(s.auth=R.shift(),s.host=s.hostname=R.shift()));return(g=g||s.host&&v.length)&&!S&&v.unshift(""),v.length?s.pathname=v.join("/"):(s.pathname=null,s.path=null),(!Tt.isNull(s.pathname)||!Tt.isNull(s.search))&&(s.path=(s.pathname?s.pathname:"")+(s.search?s.search:"")),s.auth=t.auth||s.auth,s.slashes=s.slashes||t.slashes,s.href=s.format(),s},Dt.prototype.parseHost=function(){var t=this.host,e=Ot.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)};const Wt={parse:It,format:Ct,resolve:Mt};function Yt(t){if("string"!=typeof t)throw new TypeError(`Path must be a string. Received ${JSON.stringify(t)}`)}function jt(t){return t.split("?")[0].split("#")[0]}const $t={toPosix:t=>function(t,e,s){return t.replace(new RegExp(function(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(e),"g"),s)}(t,"\\","/"),isUrl(t){return/^https?:/.test(this.toPosix(t))},isDataUrl:t=>/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(t),hasProtocol(t){return/^[^/:]+:\//.test(this.toPosix(t))},getProtocol(t){Yt(t),t=this.toPosix(t);let e="";const s=/^file:\/\/\//.exec(t),i=/^[^/:]+:\/\//.exec(t),r=/^[^/:]+:\//.exec(t);if(s||i||r){const n=(null==s?void 0:s[0])||(null==i?void 0:i[0])||(null==r?void 0:r[0]);e=n,t=t.slice(n.length)}return e},toAbsolute(t,e,s){if(this.isDataUrl(t))return t;const i=jt(this.toPosix(null!=e?e:A.ADAPTER.getBaseUrl())),r=jt(this.toPosix(null!=s?s:this.rootname(i)));return Yt(t),(t=this.toPosix(t)).startsWith("/")?$t.join(r,t.slice(1)):this.isAbsolute(t)?t:this.join(i,t)},normalize(t){if(Yt(t=this.toPosix(t)),0===t.length)return".";let e="";const s=t.startsWith("/");this.hasProtocol(t)&&(e=this.rootname(t),t=t.slice(e.length));const i=t.endsWith("/");return t=function(t,e){let s="",i=0,r=-1,n=0,a=-1;for(let o=0;o<=t.length;++o){if(o<t.length)a=t.charCodeAt(o);else{if(47===a)break;a=47}if(47===a){if(r!==o-1&&1!==n)if(r!==o-1&&2===n){if(s.length<2||2!==i||46!==s.charCodeAt(s.length-1)||46!==s.charCodeAt(s.length-2))if(s.length>2){const t=s.lastIndexOf("/");if(t!==s.length-1){-1===t?(s="",i=0):(s=s.slice(0,t),i=s.length-1-s.lastIndexOf("/")),r=o,n=0;continue}}else if(2===s.length||1===s.length){s="",i=0,r=o,n=0;continue}e&&(s.length>0?s+="/..":s="..",i=2)}else s.length>0?s+=`/${t.slice(r+1,o)}`:s=t.slice(r+1,o),i=o-r-1;r=o,n=0}else 46===a&&-1!==n?++n:n=-1}return s}(t,!1),t.length>0&&i&&(t+="/"),s?`/${t}`:e+t},isAbsolute(t){return Yt(t),t=this.toPosix(t),!!this.hasProtocol(t)||t.startsWith("/")},join(...t){var e;if(0===t.length)return".";let s;for(let i=0;i<t.length;++i){const r=t[i];if(Yt(r),r.length>0)if(void 0===s)s=r;else{const n=null!=(e=t[i-1])?e:"";this.extname(n)?s+=`/../${r}`:s+=`/${r}`}}return void 0===s?".":this.normalize(s)},dirname(t){if(Yt(t),0===t.length)return".";let e=(t=this.toPosix(t)).charCodeAt(0);const s=47===e;let i=-1,r=!0;const n=this.getProtocol(t),a=t;for(let s=(t=t.slice(n.length)).length-1;s>=1;--s)if(e=t.charCodeAt(s),47===e){if(!r){i=s;break}}else r=!1;return-1===i?s?"/":this.isUrl(a)?n+t:n:s&&1===i?"//":n+t.slice(0,i)},rootname(t){Yt(t);let e="";if(e=(t=this.toPosix(t)).startsWith("/")?"/":this.getProtocol(t),this.isUrl(t)){const s=t.indexOf("/",e.length);e=-1!==s?t.slice(0,s):t,e.endsWith("/")||(e+="/")}return e},basename(t,e){Yt(t),e&&Yt(e),t=jt(this.toPosix(t));let s,i=0,r=-1,n=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";let a=e.length-1,o=-1;for(s=t.length-1;s>=0;--s){const h=t.charCodeAt(s);if(47===h){if(!n){i=s+1;break}}else-1===o&&(n=!1,o=s+1),a>=0&&(h===e.charCodeAt(a)?-1==--a&&(r=s):(a=-1,r=o))}return i===r?r=o:-1===r&&(r=t.length),t.slice(i,r)}for(s=t.length-1;s>=0;--s)if(47===t.charCodeAt(s)){if(!n){i=s+1;break}}else-1===r&&(n=!1,r=s+1);return-1===r?"":t.slice(i,r)},extname(t){Yt(t);let e=-1,s=0,i=-1,r=!0,n=0;for(let a=(t=jt(this.toPosix(t))).length-1;a>=0;--a){const o=t.charCodeAt(a);if(47!==o)-1===i&&(r=!1,i=a+1),46===o?-1===e?e=a:1!==n&&(n=1):-1!==e&&(n=-1);else if(!r){s=a+1;break}}return-1===e||-1===i||0===n||1===n&&e===i-1&&e===s+1?"":t.slice(e,i)},parse(t){Yt(t);const e={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return e;let s=(t=jt(this.toPosix(t))).charCodeAt(0);const i=this.isAbsolute(t);let r;e.root=this.rootname(t),r=i||this.hasProtocol(t)?1:0;let n=-1,a=0,o=-1,h=!0,l=t.length-1,u=0;for(;l>=r;--l)if(s=t.charCodeAt(l),47!==s)-1===o&&(h=!1,o=l+1),46===s?-1===n?n=l:1!==u&&(u=1):-1!==n&&(u=-1);else if(!h){a=l+1;break}return-1===n||-1===o||0===u||1===u&&n===o-1&&n===a+1?-1!==o&&(e.base=e.name=0===a&&i?t.slice(1,o):t.slice(a,o)):(0===a&&i?(e.name=t.slice(1,n),e.base=t.slice(1,o)):(e.name=t.slice(a,n),e.base=t.slice(a,o)),e.ext=t.slice(n,o)),e.dir=this.dirname(t),e},sep:"/",delimiter:":"},qt={};function Kt(t,e,s=3){if(qt[e])return;let i=(new Error).stack;void 0===i?console.warn("PixiJS Deprecation Warning: ",`${e}\nDeprecated since v${t}`):(i=i.split("\n").splice(s).join("\n"),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${e}\nDeprecated since v${t}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${e}\nDeprecated since v${t}`),console.warn(i))),qt[e]=!0}let Zt;function Qt(){return void 0===Zt&&(Zt=function(){var t;const e={stencil:!0,failIfMajorPerformanceCaveat:A.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!A.ADAPTER.getWebGLRenderingContext())return!1;const s=A.ADAPTER.createCanvas();let i=s.getContext("webgl",e)||s.getContext("experimental-webgl",e);const r=!(null==(t=null==i?void 0:i.getContextAttributes())||!t.stencil);if(i){const t=i.getExtension("WEBGL_lose_context");t&&t.loseContext()}return i=null,r}catch(t){return!1}}()),Zt}var Jt={grad:.9,turn:360,rad:360/(2*Math.PI)},te=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},ee=function(t,e,s){return void 0===e&&(e=0),void 0===s&&(s=Math.pow(10,e)),Math.round(s*t)/s+0},se=function(t,e,s){return void 0===e&&(e=0),void 0===s&&(s=1),t>s?s:t>e?t:e},ie=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},re=function(t){return{r:se(t.r,0,255),g:se(t.g,0,255),b:se(t.b,0,255),a:se(t.a)}},ne=function(t){return{r:ee(t.r),g:ee(t.g),b:ee(t.b),a:ee(t.a,3)}},ae=/^#([0-9a-f]{3,8})$/i,oe=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},he=function(t){var e=t.r,s=t.g,i=t.b,r=t.a,n=Math.max(e,s,i),a=n-Math.min(e,s,i),o=a?n===e?(s-i)/a:n===s?2+(i-e)/a:4+(e-s)/a:0;return{h:60*(o<0?o+6:o),s:n?a/n*100:0,v:n/255*100,a:r}},le=function(t){var e=t.h,s=t.s,i=t.v,r=t.a;e=e/360*6,s/=100,i/=100;var n=Math.floor(e),a=i*(1-s),o=i*(1-(e-n)*s),h=i*(1-(1-e+n)*s),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}},ue=function(t){return{h:ie(t.h),s:se(t.s,0,100),l:se(t.l,0,100),a:se(t.a)}},de=function(t){return{h:ee(t.h),s:ee(t.s),l:ee(t.l),a:ee(t.a,3)}},ce=function(t){return le((s=(e=t).s,{h:e.h,s:(s*=((i=e.l)<50?i:100-i)/100)>0?2*s/(i+s)*100:0,v:i+s,a:e.a}));var e,s,i},pe=function(t){return{h:(e=he(t)).h,s:(r=(200-(s=e.s))*(i=e.v)/100)>0&&r<200?s*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:e.a};var e,s,i,r},fe=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,me=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,_e=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ge=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,xe={string:[[function(t){var e=ae.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:4===t.length?ee(parseInt(t[3]+t[3],16)/255,2):1}:6===t.length||8===t.length?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:8===t.length?ee(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=_e.exec(t)||ge.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:re({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:void 0===e[7]?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=fe.exec(t)||me.exec(t);if(!e)return null;var s,i,r=ue({h:(s=e[1],i=e[2],void 0===i&&(i="deg"),Number(s)*(Jt[i]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return ce(r)},"hsl"]],object:[[function(t){var e=t.r,s=t.g,i=t.b,r=t.a,n=void 0===r?1:r;return te(e)&&te(s)&&te(i)?re({r:Number(e),g:Number(s),b:Number(i),a:Number(n)}):null},"rgb"],[function(t){var e=t.h,s=t.s,i=t.l,r=t.a,n=void 0===r?1:r;if(!te(e)||!te(s)||!te(i))return null;var a=ue({h:Number(e),s:Number(s),l:Number(i),a:Number(n)});return ce(a)},"hsl"],[function(t){var e=t.h,s=t.s,i=t.v,r=t.a,n=void 0===r?1:r;if(!te(e)||!te(s)||!te(i))return null;var a,o=(a={h:Number(e),s:Number(s),v:Number(i),a:Number(n)},{h:ie(a.h),s:se(a.s,0,100),v:se(a.v,0,100),a:se(a.a)});return le(o)},"hsv"]]},ve=function(t,e){for(var s=0;s<e.length;s++){var i=e[s][0](t);if(i)return[i,e[s][1]]}return[null,void 0]},ye=function(t){return"string"==typeof t?ve(t.trim(),xe.string):"object"==typeof t&&null!==t?ve(t,xe.object):[null,void 0]},Te=function(t,e){var s=pe(t);return{h:s.h,s:se(s.s+100*e,0,100),l:s.l,a:s.a}},be=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},Ee=function(t,e){var s=pe(t);return{h:s.h,s:s.s,l:se(s.l+100*e,0,100),a:s.a}},Ae=function(){function t(t){this.parsed=ye(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return null!==this.parsed},t.prototype.brightness=function(){return ee(be(this.rgba),2)},t.prototype.isDark=function(){return be(this.rgba)<.5},t.prototype.isLight=function(){return be(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=ne(this.rgba)).r,s=t.g,i=t.b,n=(r=t.a)<1?oe(ee(255*r)):"","#"+oe(e)+oe(s)+oe(i)+n;var t,e,s,i,r,n},t.prototype.toRgb=function(){return ne(this.rgba)},t.prototype.toRgbString=function(){return e=(t=ne(this.rgba)).r,s=t.g,i=t.b,(r=t.a)<1?"rgba("+e+", "+s+", "+i+", "+r+")":"rgb("+e+", "+s+", "+i+")";var t,e,s,i,r},t.prototype.toHsl=function(){return de(pe(this.rgba))},t.prototype.toHslString=function(){return e=(t=de(pe(this.rgba))).h,s=t.s,i=t.l,(r=t.a)<1?"hsla("+e+", "+s+"%, "+i+"%, "+r+")":"hsl("+e+", "+s+"%, "+i+"%)";var t,e,s,i,r},t.prototype.toHsv=function(){return t=he(this.rgba),{h:ee(t.h),s:ee(t.s),v:ee(t.v),a:ee(t.a,3)};var t},t.prototype.invert=function(){return Re({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},t.prototype.saturate=function(t){return void 0===t&&(t=.1),Re(Te(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),Re(Te(this.rgba,-t))},t.prototype.grayscale=function(){return Re(Te(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),Re(Ee(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),Re(Ee(this.rgba,-t))},t.prototype.rotate=function(t){return void 0===t&&(t=15),this.hue(this.hue()+t)},t.prototype.alpha=function(t){return"number"==typeof t?Re({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):ee(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=pe(this.rgba);return"number"==typeof t?Re({h:t,s:e.s,l:e.l,a:e.a}):ee(e.h)},t.prototype.isEqual=function(t){return this.toHex()===Re(t).toHex()},t}(),Re=function(t){return t instanceof Ae?t:new Ae(t)},Se=[];!function(t){t.forEach((function(t){Se.indexOf(t)<0&&(t(Ae,xe),Se.push(t))}))}([function(t,e){var s={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 s)i[s[r]]=r;var n={};t.prototype.toName=function(e){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var r,a,o=i[this.toHex()];if(o)return o;if(null!=e&&e.closest){var h=this.toRgb(),l=1/0,u="black";if(!n.length)for(var d in s)n[d]=new t(s[d]).toRgb();for(var c in s){var p=(r=h,a=n[c],Math.pow(r.r-a.r,2)+Math.pow(r.g-a.g,2)+Math.pow(r.b-a.b,2));p<l&&(l=p,u=c)}return u}},e.string.push([function(e){var i=e.toLowerCase(),r="transparent"===i?"#0000":s[i];return r?new t(r).toRgb():null},"name"])}]);const we=class{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 we)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(null===t)throw new Error("Cannot set PIXI.Color#value to null");(null===this._value||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return"string"==typeof t||"number"==typeof t||t instanceof Number||null===t?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):"object"==typeof t&&null!==t?bt({},t):t}isSourceEqual(t,e){const s=typeof t;if(s!==typeof e)return!1;if("number"===s||"string"===s||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length===e.length&&t.every(((t,s)=>t===e[s]));if(null!==t&&null!==e){const s=Object.keys(t),i=Object.keys(e);return s.length===i.length&&s.every((s=>t[s]===e[s]))}return t===e}toRgba(){const[t,e,s,i]=this._components;return{r:t,g:e,b:s,a:i}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,i]=this._components;return(t=null!=t?t:[])[0]=Math.round(255*e),t[1]=Math.round(255*s),t[2]=Math.round(255*i),t}toRgbArray(t){t=null!=t?t:[];const[e,s,i]=this._components;return t[0]=e,t[1]=s,t[2]=i,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(65280&t)+((255&t)<<16)}multiply(t){const[e,s,i,r]=we.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=i,this._components[3]*=r,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(1===t)return(255<<24)+this._int;if(0===t)return e?0:this._int;let s=this._int>>16&255,i=this._int>>8&255,r=255&this._int;return e&&(s=s*t+.5|0,i=i*t+.5|0,r=r*t+.5|0),(255*t<<24)+(s<<16)+(i<<8)+r}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(255*this._components[3]).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,s,i]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(s*t)/t,this._components[2]=Math.round(i*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=null!=t?t:[];const[e,s,i,r]=this._components;return t[0]=e,t[1]=s,t[2]=i,t[3]=r,t}normalize(t){let e,s,i,r;if(("number"==typeof t||t instanceof Number)&&t>=0&&t<=16777215){e=(t>>16&255)/255,s=(t>>8&255)/255,i=(255&t)/255,r=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,i,r=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,i,r=255]=t,e/=255,s/=255,i/=255,r/=255;else if("string"==typeof t||"object"==typeof t){if("string"==typeof t){const e=we.HEX_PATTERN.exec(t);e&&(t=`#${e[2]}`)}const n=Re(t);n.isValid()&&(({r:e,g:s,b:i,a:r}=n.rgba),e/=255,s/=255,i/=255)}if(void 0===e)throw new Error(`Unable to convert color ${t}`);this._components[0]=e,this._components[1]=s,this._components[2]=i,this._components[3]=r,this.refreshInt()}refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(255*t<<16)+(255*e<<8)+(255*s|0)}_clamp(t,e=0,s=1){return"number"==typeof t?Math.min(Math.max(t,e),s):(t.forEach(((i,r)=>{t[r]=Math.min(Math.max(i,e),s)})),t)}};let Ie=we;function Me(t){return Kt("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),Ie.shared.setValue(t).toHex()}function Ce(t){return Kt("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),Ie.shared.setValue(t).toNumber()}Ie.shared=new we,Ie.temp=new we,Ie.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;const De=function(){const t=[],e=[];for(let s=0;s<32;s++)t[s]=s,e[s]=s;t[a.NORMAL_NPM]=a.NORMAL,t[a.ADD_NPM]=a.ADD,t[a.SCREEN_NPM]=a.SCREEN,e[a.NORMAL]=a.NORMAL_NPM,e[a.ADD]=a.ADD_NPM,e[a.SCREEN]=a.SCREEN_NPM;const s=[];return s.push(e),s.push(t),s}();function Pe(t,e){return De[e?1:0][t]}const Oe=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function Fe(t,e=null){const s=6*t;if((e=e||new Uint16Array(s)).length!==s)throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${s}`);for(let t=0,i=0;t<s;t+=6,i+=4)e[t+0]=i+0,e[t+1]=i+1,e[t+2]=i+2,e[t+3]=i+0,e[t+4]=i+2,e[t+5]=i+3;return e}function Be(t){if(4===t.BYTES_PER_ELEMENT)return t instanceof Float32Array?"Float32Array":t instanceof Uint32Array?"Uint32Array":"Int32Array";if(2===t.BYTES_PER_ELEMENT){if(t instanceof Uint16Array)return"Uint16Array"}else if(1===t.BYTES_PER_ELEMENT&&t instanceof Uint8Array)return"Uint8Array";return null}const Ne={Float32Array:Float32Array,Uint32Array:Uint32Array,Int32Array:Int32Array,Uint8Array:Uint8Array};function Le(t){return t+=0===t?1:0,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1}function Ge(t){return!(t&t-1||!t)}function Ue(t){let e=(t>65535?1:0)<<4,s=((t>>>=e)>255?1:0)<<3;return e|=s,s=((t>>>=s)>15?1:0)<<2,e|=s,s=((t>>>=s)>3?1:0)<<1,e|=s,e|(t>>>=s)>>1}function ke(t,e,s){const i=t.length;let r;if(e>=i||0===s)return;const n=i-(s=e+s>i?i-e:s);for(r=e;r<n;++r)t[r]=t[r+s];t.length=n}function Xe(t){return 0===t?0:t<0?-1:1}let He=0;function Ve(){return++He}const ze=class{constructor(t,e,s,i){this.left=t,this.top=e,this.right=s,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}};let We=ze;We.EMPTY=new ze(0,0,0,0);const Ye={},je=Object.create(null),$e=Object.create(null);class qe{constructor(t,e,s){this._canvas=A.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=s||A.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(null===this._canvas)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function Ke(t,e,s){for(let i=0,r=4*s*e;i<e;++i,r+=4)if(0!==t[r+3])return!1;return!0}function Ze(t,e,s,i,r){const n=4*e;for(let e=i,a=i*n+4*s;e<=r;++e,a+=n)if(0!==t[a+3])return!1;return!0}function Qe(t){const{width:e,height:s}=t,i=t.getContext("2d",{willReadFrequently:!0});if(null===i)throw new TypeError("Failed to get canvas 2D context");const r=i.getImageData(0,0,e,s).data;let n=0,a=0,o=e-1,h=s-1;for(;a<s&&Ke(r,e,a);)++a;if(a===s)return We.EMPTY;for(;Ke(r,e,h);)--h;for(;Ze(r,e,n,a,h);)++n;for(;Ze(r,e,o,a,h);)--o;return++o,++h,new We(n,a,o,h)}function Je(t){const e=Qe(t),{width:s,height:i}=e;let r=null;if(!e.isEmpty()){const n=t.getContext("2d");if(null===n)throw new TypeError("Failed to get canvas 2D context");r=n.getImageData(e.left,e.top,s,i)}return{width:s,height:i,data:r}}let ts;function es(t,e=globalThis.location){if(t.startsWith("data:"))return"";e=e||globalThis.location,ts||(ts=document.createElement("a")),ts.href=t;const s=Wt.parse(ts.href),i=!s.port&&""===e.port||s.port===e.port;return s.hostname===e.hostname&&i&&s.protocol===e.protocol?"":"anonymous"}function ss(t,e=1){var s;const i=null==(s=A.RETINA_PREFIX)?void 0:s.exec(t);return i?parseFloat(i[1]):e}var is={__proto__:null,isMobile:H,EventEmitter:W,earcut:Y,url:Wt,path:$t,sayHello:function(){Kt("7.0.0",'sayHello is deprecated, please use Renderer\'s "hello" option')},skipHello:function(){Kt("7.0.0","skipHello is deprecated, please use settings.RENDER_OPTIONS.hello")},isWebGLSupported:Qt,hex2rgb:function(t,e=[]){return Kt("7.2.0","utils.hex2rgb is deprecated, use Color#toRgbArray instead"),Ie.shared.setValue(t).toRgbArray(e)},hex2string:Me,rgb2hex:Ce,string2hex:function(t){return Kt("7.2.0","utils.string2hex is deprecated, use Color#toNumber instead"),Ie.shared.setValue(t).toNumber()},correctBlendMode:Pe,premultiplyBlendMode:De,premultiplyRgba:function(t,e,s,i=!0){return Kt("7.2.0","utils.premultiplyRgba has moved to Color.premultiply"),Ie.shared.setValue(t).premultiply(e,i).toArray(null!=s?s:new Float32Array(4))},premultiplyTint:function(t,e){return Kt("7.2.0","utils.premultiplyTint has moved to Color.toPremultiplied"),Ie.shared.setValue(t).toPremultiplied(e)},premultiplyTintToRgba:function(t,e,s,i=!0){return Kt("7.2.0","utils.premultiplyTintToRgba has moved to Color.premultiply"),Ie.shared.setValue(t).premultiply(e,i).toArray(null!=s?s:new Float32Array(4))},DATA_URI:Oe,createIndicesForQuads:Fe,getBufferType:Be,interleaveTypedArrays:function(t,e){let s=0,i=0;const r={};for(let r=0;r<t.length;r++)i+=e[r],s+=t[r].length;const n=new ArrayBuffer(4*s);let a=null,o=0;for(let s=0;s<t.length;s++){const h=e[s],l=t[s],u=Be(l);r[u]||(r[u]=new Ne[u](n)),a=r[u];for(let t=0;t<l.length;t++){a[(t/h|0)*i+o+t%h]=l[t]}o+=h}return new Float32Array(n)},isPow2:Ge,log2:Ue,nextPow2:Le,removeItems:ke,sign:Xe,uid:Ve,deprecation:Kt,BoundingBox:We,BaseTextureCache:$e,ProgramCache:Ye,TextureCache:je,clearTextureCache:function(){let t;for(t in je)delete je[t];for(t in $e)delete $e[t]},destroyTextureCache:function(){let t;for(t in je)je[t].destroy();for(t in $e)$e[t].destroy()},CanvasRenderTarget:qe,getCanvasBoundingBox:Qe,trimCanvas:Je,decomposeDataUri:function(t){const e=Oe.exec(t);if(e)return{mediaType:e[1]?e[1].toLowerCase():void 0,subType:e[2]?e[2].toLowerCase():void 0,charset:e[3]?e[3].toLowerCase():void 0,encoding:e[4]?e[4].toLowerCase():void 0,data:e[5]}},determineCrossOrigin:es,getResolutionOfUrl:ss},rs=(t=>(t.Renderer="renderer",t.Application="application",t.RendererSystem="renderer-webgl-system",t.RendererPlugin="renderer-webgl-plugin",t.CanvasRendererSystem="renderer-canvas-system",t.CanvasRendererPlugin="renderer-canvas-plugin",t.Asset="asset",t.LoadParser="load-parser",t.ResolveParser="resolve-parser",t.CacheParser="cache-parser",t.DetectionParser="detection-parser",t))(rs||{});const ns=t=>{if("function"==typeof t||"object"==typeof t&&t.extension){if(!t.extension)throw new Error("Extension class must have an extension object");const e="object"!=typeof t.extension?{type:t.extension}:t.extension;t=Qi(bt({},e),{ref:t})}if("object"!=typeof t)throw new Error("Invalid extension type");return"string"==typeof(t=bt({},t)).type&&(t.type=[t.type]),t},as=(t,e)=>{var s;return null!=(s=ns(t).priority)?s:e},os={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map(ns).forEach((t=>{t.type.forEach((e=>{var s,i;return null==(i=(s=this._removeHandlers)[e])?void 0:i.call(s,t)}))})),this},add(...t){return t.map(ns).forEach((t=>{t.type.forEach((e=>{const s=this._addHandlers,i=this._queue;s[e]?s[e](t):(i[e]=i[e]||[],i[e].push(t))}))})),this},handle(t,e,s){const i=this._addHandlers,r=this._removeHandlers;if(i[t]||r[t])throw new Error(`Extension type ${t} already has a handler`);i[t]=e,r[t]=s;const n=this._queue;return n[t]&&(n[t].forEach((t=>e(t))),delete n[t]),this},handleByMap(t,e){return this.handle(t,(t=>{e[t.name]=t.ref}),(t=>{delete e[t.name]}))},handleByList(t,e,s=-1){return this.handle(t,(t=>{e.includes(t.ref)||(e.push(t.ref),e.sort(((t,e)=>as(e,s)-as(t,s))))}),(t=>{const s=e.indexOf(t.ref);-1!==s&&e.splice(s,1)}))}};class hs{constructor(t){"number"==typeof t?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 ls=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join("\n");function us(t){let e="";for(let s=0;s<t;++s)s>0&&(e+="\nelse "),s<t-1&&(e+=`if(test == ${s}.0){}`);return e}function ds(t,e){if(0===t)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const s=e.createShader(e.FRAGMENT_SHADER);for(;;){const i=ls.replace(/%forloop%/gi,us(t));if(e.shaderSource(s,i),e.compileShader(s),e.getShaderParameter(s,e.COMPILE_STATUS))break;t=t/2|0}return t}class cs{constructor(){this.data=0,this.blendMode=a.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(1&this.data)}set blend(t){!!(1&this.data)!==t&&(this.data^=1)}get offsets(){return!!(2&this.data)}set offsets(t){!!(2&this.data)!==t&&(this.data^=2)}get culling(){return!!(4&this.data)}set culling(t){!!(4&this.data)!==t&&(this.data^=4)}get depthTest(){return!!(8&this.data)}set depthTest(t){!!(8&this.data)!==t&&(this.data^=8)}get depthMask(){return!!(32&this.data)}set depthMask(t){!!(32&this.data)!==t&&(this.data^=32)}get clockwiseFrontFace(){return!!(16&this.data)}set clockwiseFrontFace(t){!!(16&this.data)!==t&&(this.data^=16)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==a.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}toString(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const t=new cs;return t.depthTest=!1,t.blend=!0,t}}const ps=[];function fs(t,e){if(!t)return null;let s="";if("string"==typeof t){const e=/\.(\w{3,4})(?:$|\?|#)/i.exec(t);e&&(s=e[1].toLowerCase())}for(let i=ps.length-1;i>=0;--i){const r=ps[i];if(r.test&&r.test(t,s))return new r(t,e)}throw new Error("Unrecognized source type to auto-detect Resource")}class ms{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,s,i,r,n,a,o){if(arguments.length>8)throw new Error("max arguments reached");const{name:h,items:l}=this;this._aliasCount++;for(let u=0,d=l.length;u<d;u++)l[u][h](t,e,s,i,r,n,a,o);return l===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-1!==e&&(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=null,this._name=null}get empty(){return 0===this.items.length}get name(){return this._name}}Object.defineProperties(ms.prototype,{dispatch:{value:ms.prototype.emit},run:{value:ms.prototype.emit}});class _s{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new ms("setRealSize"),this.onUpdate=new ms("update"),this.onError=new ms("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,s){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 gs extends _s{constructor(t,e){const{width:s,height:i}=e||{};if(!s||!i)throw new Error("BufferResource width or height invalid");super(s,i),this.data=t}upload(t,e,s){const i=t.gl;i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===m.UNPACK);const r=e.realWidth,n=e.realHeight;return s.width===r&&s.height===n?i.texSubImage2D(e.target,0,0,0,r,n,e.format,s.type,this.data):(s.width=r,s.height=n,i.texImage2D(e.target,0,s.internalFormat,r,n,0,e.format,s.type,this.data)),!0}dispose(){this.data=null}static test(t){return t instanceof Float32Array||t instanceof Uint8Array||t instanceof Uint32Array}}const xs={scaleMode:c.NEAREST,format:h.RGBA,alphaMode:m.NPM},vs=class extends W{constructor(t=null,e=null){super(),e=Object.assign({},vs.defaultOptions,e);const{alphaMode:s,mipmap:i,anisotropicLevel:r,scaleMode:n,width:a,height:o,wrapMode:h,format:l,type:u,target:d,resolution:c,resourceOptions:p}=e;t&&!(t instanceof _s)&&((t=fs(t,p)).internal=!0),this.resolution=c||A.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((o||0)*this.resolution)/this.resolution,this._mipmap=i,this.anisotropicLevel=r,this._wrapMode=h,this._scaleMode=n,this.format=l,this.type=u,this.target=d,this.alphaMode=s,this.uid=Ve(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=a>0&&o>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 s;return void 0!==t&&t!==this.scaleMode&&(this.scaleMode=t,s=!0),void 0!==e&&e!==this.mipmap&&(this.mipmap=e,s=!0),s&&this.dirtyStyleId++,this}setSize(t,e,s){return s=s||this.resolution,this.setRealSize(t*s,e*s,s)}setRealSize(t,e,s){return this.resolution=s||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=Ge(this.realWidth)&&Ge(this.realHeight)}setResolution(t){const e=this.resolution;return e===t||(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 $e[this.cacheId],delete je[this.cacheId],this.cacheId=null),this.dispose(),vs.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,e,s=A.STRICT_TEXTURE_CACHE){const i="string"==typeof t;let r=null;if(i)r=t;else{if(!t._pixiId){const s=(null==e?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${s}_${Ve()}`}r=t._pixiId}let n=$e[r];if(i&&s&&!n)throw new Error(`The cacheId "${r}" does not exist in BaseTextureCache.`);return n||(n=new vs(t,e),n.cacheId=r,vs.addToCache(n,r)),n}static fromBuffer(t,e,s,i){t=t||new Float32Array(e*s*4);const r=new gs(t,{width:e,height:s}),n=t instanceof Float32Array?u.FLOAT:u.UNSIGNED_BYTE;return new vs(r,Object.assign({},xs,{type:n},i))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),$e[e]&&$e[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),$e[e]=t)}static removeFromCache(t){if("string"==typeof t){const e=$e[t];if(e){const s=e.textureCacheIds.indexOf(t);return s>-1&&e.textureCacheIds.splice(s,1),delete $e[t],e}}else if(null!=t&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete $e[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};let ys=vs;ys.defaultOptions={mipmap:f.POW2,anisotropicLevel:0,scaleMode:c.LINEAR,wrapMode:p.CLAMP,alphaMode:m.UNPACK,target:l.TEXTURE_2D,format:h.RGBA,type:u.UNSIGNED_BYTE},ys._globalBatch=0;class Ts{constructor(){this.texArray=null,this.blend=0,this.type=o.TRIANGLES,this.start=0,this.size=0,this.data=null}}let bs=0;class Es{constructor(t,e=!0,s=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=s,this.static=e,this.id=bs++,this.disposeRunner=new ms("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?b.ELEMENT_ARRAY_BUFFER:b.ARRAY_BUFFER}get index(){return this.type===b.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Es(t)}}class As{constructor(t,e=0,s=!1,i=u.FLOAT,r,n,a,o=1){this.buffer=t,this.size=e,this.normalized=s,this.type=i,this.stride=r,this.start=n,this.instance=a,this.divisor=o}destroy(){this.buffer=null}static from(t,e,s,i,r){return new As(t,e,s,i,r)}}const Rs={Float32Array:Float32Array,Uint32Array:Uint32Array,Int32Array:Int32Array,Uint8Array:Uint8Array};const Ss={5126:4,5123:2,5121:1};let ws=0;const Is={Float32Array:Float32Array,Uint32Array:Uint32Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array};class Ms{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=ws++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new ms("disposeGeometry"),this.refCount=0}addAttribute(t,e,s=0,i=!1,r,n,a,o=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof Es||(e instanceof Array&&(e=new Float32Array(e)),e=new Es(e));const h=t.split("|");if(h.length>1){for(let t=0;t<h.length;t++)this.addAttribute(h[t],e,s,i,r);return this}let l=this.buffers.indexOf(e);return-1===l&&(this.buffers.push(e),l=this.buffers.length-1),this.attributes[t]=new As(l,s,i,r,n,a,o),this.instanced=this.instanced||o,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof Es||(t instanceof Array&&(t=new Uint16Array(t)),t=new Es(t)),t.type=b.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(1===this.buffers.length||2===this.buffers.length&&this.indexBuffer)return this;const t=[],e=[],s=new Es;let i;for(i in this.attributes){const s=this.attributes[i],r=this.buffers[s.buffer];t.push(r.data),e.push(s.size*Ss[s.type]/4),s.buffer=0}for(s.data=function(t,e){let s=0,i=0;const r={};for(let r=0;r<t.length;r++)i+=e[r],s+=t[r].length;const n=new ArrayBuffer(4*s);let a=null,o=0;for(let s=0;s<t.length;s++){const h=e[s],l=t[s],u=Be(l);r[u]||(r[u]=new Rs[u](n)),a=r[u];for(let t=0;t<l.length;t++)a[(t/h|0)*i+o+t%h]=l[t];o+=h}return new Float32Array(n)}(t,e),i=0;i<this.buffers.length;i++)this.buffers[i]!==this.indexBuffer&&this.buffers[i].destroy();return this.buffers=[s],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 Ms;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new Es(this.buffers[e].data.slice(0));for(const e in this.attributes){const s=this.attributes[e];t.attributes[e]=new As(s.buffer,s.size,s.normalized,s.type,s.stride,s.start,s.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=b.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new Ms,s=[],i=[],r=[];let n;for(let e=0;e<t.length;e++){n=t[e];for(let t=0;t<n.buffers.length;t++)i[t]=i[t]||0,i[t]+=n.buffers[t].data.length,r[t]=0}for(let t=0;t<n.buffers.length;t++)s[t]=new(Is[Be(n.buffers[t].data)])(i[t]),e.buffers[t]=new Es(s[t]);for(let e=0;e<t.length;e++){n=t[e];for(let t=0;t<n.buffers.length;t++)s[t].set(n.buffers[t].data,r[t]),r[t]+=n.buffers[t].data.length}if(e.attributes=n.attributes,n.indexBuffer){e.indexBuffer=e.buffers[n.buffers.indexOf(n.indexBuffer)],e.indexBuffer.type=b.ELEMENT_ARRAY_BUFFER;let s=0,i=0,r=0,a=0;for(let t=0;t<n.buffers.length;t++)if(n.buffers[t]!==n.indexBuffer){a=t;break}for(const t in n.attributes){const e=n.attributes[t];(0|e.buffer)===a&&(i+=e.size*Ss[e.type]/4)}for(let n=0;n<t.length;n++){const o=t[n].indexBuffer.data;for(let t=0;t<o.length;t++)e.indexBuffer.data[t+r]+=s;s+=t[n].buffers[a].data.length/i,r+=o.length}}return e}}class Cs extends Ms{constructor(t=!1){super(),this._buffer=new Es(null,t,!1),this._indexBuffer=new Es(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,u.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,u.FLOAT).addAttribute("aColor",this._buffer,4,!0,u.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,u.FLOAT).addIndex(this._indexBuffer)}}const Ds=2*Math.PI,Ps=180/Math.PI,Os=Math.PI/180;var Fs=(t=>(t[t.POLY=0]="POLY",t[t.RECT=1]="RECT",t[t.CIRC=2]="CIRC",t[t.ELIP=3]="ELIP",t[t.RREC=4]="RREC",t))(Fs||{});class Bs{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new Bs(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}toString(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`}}const Ns=[new Bs,new Bs,new Bs,new Bs];class Ls{constructor(t=0,e=0,s=0,i=0){this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(i),this.type=Fs.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 Ls(0,0,0,0)}clone(){return new Ls(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)&&(t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height)}intersects(t,e){if(!e){const e=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=e)return!1;const s=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>s}const s=this.left,i=this.right,r=this.top,n=this.bottom;if(i<=s||n<=r)return!1;const a=Ns[0].set(t.left,t.top),o=Ns[1].set(t.left,t.bottom),h=Ns[2].set(t.right,t.top),l=Ns[3].set(t.right,t.bottom);if(h.x<=a.x||o.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(0===u||(e.apply(a,a),e.apply(o,o),e.apply(h,h),e.apply(l,l),Math.max(a.x,o.x,h.x,l.x)<=s||Math.min(a.x,o.x,h.x,l.x)>=i||Math.max(a.y,o.y,h.y,l.y)<=r||Math.min(a.y,o.y,h.y,l.y)>=n))return!1;const d=u*(o.y-a.y),c=u*(a.x-o.x),p=d*s+c*r,f=d*i+c*r,m=d*s+c*n,_=d*i+c*n;if(Math.max(p,f,m,_)<=d*a.x+c*a.y||Math.min(p,f,m,_)>=d*l.x+c*l.y)return!1;const g=u*(a.y-h.y),x=u*(h.x-a.x),v=g*s+x*r,y=g*i+x*r,T=g*s+x*n,b=g*i+x*n;return!(Math.max(v,y,T,b)<=g*a.x+x*a.y||Math.min(v,y,T,b)>=g*l.x+x*l.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),i=Math.max(this.y,t.y),r=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=i,this.height=Math.max(r-i,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,i=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=s-this.x,this.height=i-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),i=Math.min(this.y,t.y),r=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=i,this.height=r-i,this}toString(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}class Gs{constructor(t=0,e=0,s=0){this.x=t,this.y=e,this.radius=s,this.type=Fs.CIRC}clone(){return new Gs(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let i=this.x-t,r=this.y-e;return i*=i,r*=r,i+r<=s}getBounds(){return new Ls(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius)}toString(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class Us{constructor(t=0,e=0,s=0,i=0){this.x=t,this.y=e,this.width=s,this.height=i,this.type=Fs.ELIP}clone(){return new Us(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let s=(t-this.x)/this.width,i=(e-this.y)/this.height;return s*=s,i*=i,s+i<=1}getBounds(){return new Ls(this.x-this.width,this.y-this.height,this.width,this.height)}toString(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}class ks{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if("number"!=typeof e[0]){const t=[];for(let s=0,i=e.length;s<i;s++)t.push(e[s].x,e[s].y);e=t}this.points=e,this.type=Fs.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new ks(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let s=!1;const i=this.points.length/2;for(let r=0,n=i-1;r<i;n=r++){const i=this.points[2*r],a=this.points[2*r+1],o=this.points[2*n],h=this.points[2*n+1];a>e!=h>e&&t<(e-a)/(h-a)*(o-i)+i&&(s=!s)}return s}toString(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce(((t,e)=>`${t}, ${e}`),"")}]`}}class Xs{constructor(t=0,e=0,s=0,i=0,r=20){this.x=t,this.y=e,this.width=s,this.height=i,this.radius=r,this.type=Fs.RREC}clone(){return new Xs(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 s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let i=t-(this.x+s),r=e-(this.y+s);const n=s*s;if(i*i+r*r<=n||(i=t-(this.x+this.width-s),i*i+r*r<=n)||(r=e-(this.y+this.height-s),i*i+r*r<=n)||(i=t-(this.x+s),i*i+r*r<=n))return!0}return!1}toString(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}class Hs{constructor(t=1,e=0,s=0,i=1,r=0,n=0){this.array=null,this.a=t,this.b=e,this.c=s,this.d=i,this.tx=r,this.ty=n}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,s,i,r,n){return this.a=t,this.b=e,this.c=s,this.d=i,this.tx=r,this.ty=n,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const s=e||this.array;return t?(s[0]=this.a,s[1]=this.b,s[2]=0,s[3]=this.c,s[4]=this.d,s[5]=0,s[6]=this.tx,s[7]=this.ty,s[8]=1):(s[0]=this.a,s[1]=this.c,s[2]=this.tx,s[3]=this.b,s[4]=this.d,s[5]=this.ty,s[6]=0,s[7]=0,s[8]=1),s}apply(t,e){e=e||new Bs;const s=t.x,i=t.y;return e.x=this.a*s+this.c*i+this.tx,e.y=this.b*s+this.d*i+this.ty,e}applyInverse(t,e){e=e||new Bs;const s=1/(this.a*this.d+this.c*-this.b),i=t.x,r=t.y;return e.x=this.d*s*i+-this.c*s*r+(this.ty*this.c-this.tx*this.d)*s,e.y=this.a*s*r+-this.b*s*i+(-this.ty*this.a+this.tx*this.b)*s,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),s=Math.sin(t),i=this.a,r=this.c,n=this.tx;return this.a=i*e-this.b*s,this.b=i*s+this.b*e,this.c=r*e-this.d*s,this.d=r*s+this.d*e,this.tx=n*e-this.ty*s,this.ty=n*s+this.ty*e,this}append(t){const e=this.a,s=this.b,i=this.c,r=this.d;return this.a=t.a*e+t.b*i,this.b=t.a*s+t.b*r,this.c=t.c*e+t.d*i,this.d=t.c*s+t.d*r,this.tx=t.tx*e+t.ty*i+this.tx,this.ty=t.tx*s+t.ty*r+this.ty,this}setTransform(t,e,s,i,r,n,a,o,h){return this.a=Math.cos(a+h)*r,this.b=Math.sin(a+h)*r,this.c=-Math.sin(a-o)*n,this.d=Math.cos(a-o)*n,this.tx=t-(s*this.a+i*this.c),this.ty=e-(s*this.b+i*this.d),this}prepend(t){const e=this.tx;if(1!==t.a||0!==t.b||0!==t.c||1!==t.d){const e=this.a,s=this.c;this.a=e*t.a+this.b*t.c,this.b=e*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*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,s=this.b,i=this.c,r=this.d,n=t.pivot,a=-Math.atan2(-i,r),o=Math.atan2(s,e),h=Math.abs(a+o);return h<1e-5||Math.abs(Ds-h)<1e-5?(t.rotation=o,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=o),t.scale.x=Math.sqrt(e*e+s*s),t.scale.y=Math.sqrt(i*i+r*r),t.position.x=this.tx+(n.x*e+n.y*i),t.position.y=this.ty+(n.x*s+n.y*r),t}invert(){const t=this.a,e=this.b,s=this.c,i=this.d,r=this.tx,n=t*i-e*s;return this.a=i/n,this.b=-e/n,this.c=-s/n,this.d=t/n,this.tx=(s*this.ty-i*r)/n,this.ty=-(t*this.ty-e*r)/n,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 Hs;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}toString(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return new Hs}static get TEMP_MATRIX(){return new Hs}}const Vs=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],zs=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Ws=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Ys=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],js=[],$s=[],qs=Math.sign;!function(){for(let t=0;t<16;t++){const e=[];js.push(e);for(let s=0;s<16;s++){const i=qs(Vs[t]*Vs[s]+Ws[t]*zs[s]),r=qs(zs[t]*Vs[s]+Ys[t]*zs[s]),n=qs(Vs[t]*Ws[s]+Ws[t]*Ys[s]),a=qs(zs[t]*Ws[s]+Ys[t]*Ys[s]);for(let t=0;t<16;t++)if(Vs[t]===i&&zs[t]===r&&Ws[t]===n&&Ys[t]===a){e.push(t);break}}}for(let t=0;t<16;t++){const e=new Hs;e.set(Vs[t],zs[t],Ws[t],Ys[t],0,0),$s.push(e)}}();const Ks={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:t=>Vs[t],uY:t=>zs[t],vX:t=>Ws[t],vY:t=>Ys[t],inv:t=>8&t?15&t:7&-t,add:(t,e)=>js[t][e],sub:(t,e)=>js[t][Ks.inv(e)],rotate180:t=>4^t,isVertical:t=>2==(3&t),byDirection:(t,e)=>2*Math.abs(t)<=Math.abs(e)?e>=0?Ks.S:Ks.N:2*Math.abs(e)<=Math.abs(t)?t>0?Ks.E:Ks.W:e>0?t>0?Ks.SE:Ks.SW:t>0?Ks.NE:Ks.NW,matrixAppendRotationInv:(t,e,s=0,i=0)=>{const r=$s[Ks.inv(e)];r.tx=s,r.ty=i,t.append(r)}};class Zs{constructor(t,e,s=0,i=0){this._x=s,this._y=i,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new Zs(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}toString(){return`[@pixi/math:ObservablePoint x=0 y=0 scope=${this.scope}]`}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))}}const Qs=class{constructor(){this.worldTransform=new Hs,this.localTransform=new Hs,this.position=new Zs(this.onChange,this,0,0),this.scale=new Zs(this.onChange,this,1,1),this.pivot=new Zs(this.onChange,this,0,0),this.skew=new Zs(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++}toString(){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}) ]`}updateLocalTransform(){const 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)}updateTransform(t){const 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){const s=t.worldTransform,i=this.worldTransform;i.a=e.a*s.a+e.b*s.c,i.b=e.a*s.b+e.b*s.d,i.c=e.c*s.a+e.d*s.c,i.d=e.c*s.b+e.d*s.d,i.tx=e.tx*s.a+e.ty*s.c+s.tx,i.ty=e.tx*s.b+e.ty*s.d+s.ty,this._parentID=t._worldID,this._worldID++}}setFromMatrix(t){t.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this.updateSkew())}};let Js=Qs;Js.IDENTITY=new Qs;function ti(t,e,s){const i=t.createShader(e);return t.shaderSource(i,s),t.compileShader(i),i}function ei(t){const e=new Array(t);for(let t=0;t<e.length;t++)e[t]=!1;return e}function si(t,e){switch(t){case"float":case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return ei(2*e);case"bvec3":return ei(3*e);case"bvec4":return ei(4*e);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 ii=[{test:t=>"float"===t.type&&1===t.size&&!t.isArray,code:t=>`\n if(uv["${t}"] !== ud["${t}"].value)\n {\n ud["${t}"].value = uv["${t}"]\n gl.uniform1f(ud["${t}"].location, uv["${t}"])\n }\n `},{test:(t,e)=>!("sampler2D"!==t.type&&"samplerCube"!==t.type&&"sampler2DArray"!==t.type||1!==t.size||t.isArray||null!=e&&void 0===e.castToBaseTexture),code:t=>`t = syncData.textureCount++;\n\n renderer.texture.bind(uv["${t}"], t);\n\n if(ud["${t}"].value !== t)\n {\n ud["${t}"].value = t;\n gl.uniform1i(ud["${t}"].location, t);\n; // eslint-disable-line max-len\n }`},{test:(t,e)=>"mat3"===t.type&&1===t.size&&!t.isArray&&void 0!==e.a,code:t=>`\n gl.uniformMatrix3fv(ud["${t}"].location, false, uv["${t}"].toArray(true));\n `,codeUbo:t=>`\n var ${t}_matrix = uv.${t}.toArray(true);\n\n data[offset] = ${t}_matrix[0];\n data[offset+1] = ${t}_matrix[1];\n data[offset+2] = ${t}_matrix[2];\n \n data[offset + 4] = ${t}_matrix[3];\n data[offset + 5] = ${t}_matrix[4];\n data[offset + 6] = ${t}_matrix[5];\n \n data[offset + 8] = ${t}_matrix[6];\n data[offset + 9] = ${t}_matrix[7];\n data[offset + 10] = ${t}_matrix[8];\n `},{test:(t,e)=>"vec2"===t.type&&1===t.size&&!t.isArray&&void 0!==e.x,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v.x || cv[1] !== v.y)\n {\n cv[0] = v.x;\n cv[1] = v.y;\n gl.uniform2f(ud["${t}"].location, v.x, v.y);\n }`,codeUbo:t=>`\n v = uv.${t};\n\n data[offset] = v.x;\n data[offset+1] = v.y;\n `},{test:t=>"vec2"===t.type&&1===t.size&&!t.isArray,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2f(ud["${t}"].location, v[0], v[1]);\n }\n `},{test:(t,e)=>"vec4"===t.type&&1===t.size&&!t.isArray&&void 0!==e.width,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height)\n {\n cv[0] = v.x;\n cv[1] = v.y;\n cv[2] = v.width;\n cv[3] = v.height;\n gl.uniform4f(ud["${t}"].location, v.x, v.y, v.width, v.height)\n }`,codeUbo:t=>`\n v = uv.${t};\n\n data[offset] = v.x;\n data[offset+1] = v.y;\n data[offset+2] = v.width;\n data[offset+3] = v.height;\n `},{test:(t,e)=>"vec4"===t.type&&1===t.size&&!t.isArray&&void 0!==e.red,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha)\n {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n cv[3] = v.alpha;\n gl.uniform4f(ud["${t}"].location, v.red, v.green, v.blue, v.alpha)\n }`,codeUbo:t=>`\n v = uv.${t};\n\n data[offset] = v.red;\n data[offset+1] = v.green;\n data[offset+2] = v.blue;\n data[offset+3] = v.alpha;\n `},{test:(t,e)=>"vec3"===t.type&&1===t.size&&!t.isArray&&void 0!==e.red,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a)\n {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n \n gl.uniform3f(ud["${t}"].location, v.red, v.green, v.blue)\n }`,codeUbo:t=>`\n v = uv.${t};\n\n data[offset] = v.red;\n data[offset+1] = v.green;\n data[offset+2] = v.blue;\n `},{test:t=>"vec4"===t.type&&1===t.size&&!t.isArray,code:t=>`\n cv = ud["${t}"].value;\n v = uv["${t}"];\n\n if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4f(ud["${t}"].location, v[0], v[1], v[2], v[3])\n }`}],ri={float:"\n if (cv !== v)\n {\n cu.value = v;\n gl.uniform1f(location, v);\n }",vec2:"\n if (cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2f(location, v[0], v[1])\n }",vec3:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3f(location, v[0], v[1], v[2])\n }",vec4:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4f(location, v[0], v[1], v[2], v[3]);\n }",int:"\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }",ivec2:"\n if (cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2i(location, v[0], v[1]);\n }",ivec3:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3i(location, v[0], v[1], v[2]);\n }",ivec4:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }",uint:"\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1ui(location, v);\n }",uvec2:"\n if (cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2ui(location, v[0], v[1]);\n }",uvec3:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3ui(location, v[0], v[1], v[2]);\n }",uvec4:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4ui(location, v[0], v[1], v[2], v[3]);\n }",bool:"\n if (cv !== v)\n {\n cu.value = v;\n gl.uniform1i(location, v);\n }",bvec2:"\n if (cv[0] != v[0] || cv[1] != v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2i(location, v[0], v[1]);\n }",bvec3:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3i(location, v[0], v[1], v[2]);\n }",bvec4:"\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }",mat2:"gl.uniformMatrix2fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",sampler2D:"\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }",samplerCube:"\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }",sampler2DArray:"\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }"},ni={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)"};const ai={};let oi,hi=ai;function li(){if(hi===ai||(null==hi?void 0:hi.isContextLost())){const t=A.ADAPTER.createCanvas();let e;A.PREFER_ENV>=i.WEBGL2&&(e=t.getContext("webgl2",{})),e||(e=t.getContext("webgl",{})||t.getContext("experimental-webgl",{}),e?e.getExtension("WEBGL_draw_buffers"):e=null),hi=e}return hi}function ui(t,e){const s=t.getShaderSource(e).split("\n").map(((t,e)=>`${e}: ${t}`)),i=t.getShaderInfoLog(e),r=i.split("\n"),n={},a=r.map((t=>parseFloat(t.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1")))).filter((t=>!(!t||n[t])&&(n[t]=!0,!0))),o=[""];a.forEach((t=>{s[t-1]=`%c${s[t-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")}));const h=s.join("\n");o[0]=h,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...o),console.groupEnd()}const di={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 ci(t){return di[t]}let pi=null;const fi={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 mi(t,e){if(!pi){const e=Object.keys(fi);pi={};for(let s=0;s<e.length;++s){const i=e[s];pi[t[i]]=fi[i]}}return pi[e]}function _i(t,e,s){if("precision"!==t.substring(0,9)){let i=e;return e===x.HIGH&&s!==x.HIGH&&(i=x.MEDIUM),`precision ${i} float;\n${t}`}return s!==x.HIGH&&"precision highp"===t.substring(0,15)?t.replace("precision highp","precision mediump"):t}let gi;function xi(){if("boolean"==typeof gi)return gi;try{gi=!0===new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")}catch(t){gi=!1}return gi}let vi=0;const yi={},Ti=class{constructor(t,e,s="pixi-shader",i={}){this.extra={},this.id=vi++,this.vertexSrc=t||Ti.defaultVertexSrc,this.fragmentSrc=e||Ti.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=i,"#version"!==this.vertexSrc.substring(0,8)&&(s=s.replace(/\s+/g,"-"),yi[s]?(yi[s]++,s+=`-${yi[s]}`):yi[s]=1,this.vertexSrc=`#define SHADER_NAME ${s}\n${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${s}\n${this.fragmentSrc}`,this.vertexSrc=_i(this.vertexSrc,Ti.defaultVertexPrecision,x.HIGH),this.fragmentSrc=_i(this.fragmentSrc,Ti.defaultFragmentPrecision,function(){if(!oi){oi=x.MEDIUM;const t=li();t&&t.getShaderPrecisionFormat&&(oi=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision?x.HIGH:x.MEDIUM)}return oi}())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n"}static get defaultFragmentSrc(){return"varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nvoid main(void){\n gl_FragColor *= texture2D(uSampler, vTextureCoord);\n}"}static from(t,e,s){const i=t+e;let r=Ye[i];return r||(Ye[i]=r=new Ti(t,e,s)),r}};let bi=Ti;bi.defaultVertexPrecision=x.HIGH,bi.defaultFragmentPrecision=H.apple.device?x.HIGH:x.MEDIUM;let Ei=0;class Ai{constructor(t,e,s){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=Ei++,this.static=!!e,this.ubo=!!s,t instanceof Es?(this.buffer=t,this.buffer.type=b.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new Es(new Float32Array(1)),this.buffer.type=b.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,s){if(this.ubo)throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them");this.uniforms[t]=new Ai(e,s)}static from(t,e,s){return new Ai(t,e,s)}static uboFrom(t,e){return new Ai(t,null==e||e,!0)}}class Ri{constructor(t,e){this.uniformBindCount=0,this.program=t,this.uniformGroup=e?e instanceof Ai?e:new Ai(e):new Ai({}),this.disposeRunner=new ms("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const s in e.uniforms){const i=e.uniforms[s];if(i.group&&this.checkUniformExists(t,i))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,s){const i=bi.from(t,e);return new Ri(i,s)}}class Si{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 e=new Int32Array(t);for(let s=0;s<t;s++)e[s]=s;this.defaultGroupCache[t]=Ai.from({uSamplers:e},!0);let s=this.fragTemplate;s=s.replace(/%count%/gi,`${t}`),s=s.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new bi(this.vertexSrc,s)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new Hs,default:this.defaultGroupCache[t]};return new Ri(this.programCache[t],e)}generateSampleSrc(t){let e="";e+="\n",e+="\n";for(let s=0;s<t;s++)s>0&&(e+="\nelse "),s<t-1&&(e+=`if(vTextureId < ${s}.5)`),e+="\n{",e+=`\n\tcolor = texture2D(uSamplers[${s}], vTextureCoord);`,e+="\n}";return e+="\n",e+="\n",e}}class wi{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}class Ii{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}const Mi=class extends Ii{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Cs,this.vertexSize=6,this.state=cs.for2d(),this.size=4*Mi.defaultBatchSize,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(){var t;return this._defaultMaxTextures=null!=(t=this._defaultMaxTextures)?t:function(t){let e=!0;const s=A.ADAPTER.getNavigator();if(H.tablet||H.phone){if(H.apple.device){const t=s.userAgent.match(/OS (\d+)_(\d+)?/);t&&parseInt(t[1],10)<11&&(e=!1)}if(H.android.device){const t=s.userAgent.match(/Android\s([0-9.]*)/);t&&parseInt(t[1],10)<7&&(e=!1)}}return e?t:4}(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){var t;return this._canUploadSameBuffer=null!=(t=this._canUploadSameBuffer)?t:!H.apple.device,this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return Kt("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return"precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform vec4 tint;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = aColor * tint;\n}\n"}static get defaultFragmentTemplate(){return"varying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\nuniform sampler2D uSamplers[%count%];\n\nvoid main(void){\n vec4 color;\n %forloop%\n gl_FragColor = color * vColor;\n}\n"}setShaderGenerator({vertex:t=Mi.defaultVertexSrc,fragment:e=Mi.defaultFragmentTemplate}={}){this.shaderGenerator=new Si(t,e)}contextChange(){const t=this.renderer.gl;A.PREFER_ENV===i.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Mi.defaultMaxTextures),this.maxTextures=ds(this.maxTextures,t)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:t,_textureArrayPool:e}=Mi,s=this.size/4,i=Math.floor(s/this.maxTextures)+1;for(;t.length<s;)t.push(new Ts);for(;e.length<i;)e.push(new wi);for(let t=0;t<this.maxTextures;t++)this._tempBoundTextures[t]=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,s=Mi._textureArrayPool,i=this.renderer.batch,r=this._tempBoundTextures,n=this.renderer.textureGC.count;let a=++ys._globalBatch,o=0,h=s[0],l=0;i.copyBoundTextures(r,e);for(let u=0;u<this._bufferSize;++u){const d=t[u];t[u]=null,d._batchEnabled!==a&&(h.count>=e&&(i.boundArray(h,r,a,e),this.buildDrawCalls(h,l,u),l=u,h=s[++o],++a),d._batchEnabled=a,d.touched=n,h.elements[h.count++]=d)}h.count>0&&(i.boundArray(h,r,a,e),this.buildDrawCalls(h,l,this._bufferSize),++o,++a);for(let t=0;t<r.length;t++)r[t]=null;ys._globalBatch=a}buildDrawCalls(t,e,s){const{_bufferedElements:i,_attributeBuffer:r,_indexBuffer:n,vertexSize:a}=this,o=Mi._drawCallPool;let h=this._dcIndex,l=this._aIndex,u=this._iIndex,d=o[h];d.start=this._iIndex,d.texArray=t;for(let c=e;c<s;++c){const s=i[c],p=s._texture.baseTexture,f=De[p.alphaMode?1:0][s.blendMode];i[c]=null,e<c&&d.blend!==f&&(d.size=u-d.start,e=c,d=o[++h],d.texArray=t,d.start=u),this.packInterleavedGeometry(s,r,n,l,u),l+=s.vertexData.length/2*a,u+=s.indices.length,d.blend=f}e<s&&(d.size=u-d.start,++h),this._dcIndex=h,this._aIndex=l,this._iIndex=u}bindAndClearTexArray(t){const e=this.renderer.texture;for(let s=0;s<t.count;s++)e.bind(t.elements[s],t.ids[s]),t.elements[s]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:e,_indexBuffer:s}=this;Mi.canUploadSameBuffer?(t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(s),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(s),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:e,state:s}=this.renderer,i=Mi._drawCallPool;let r=null;for(let n=0;n<t;n++){const{texArray:t,type:a,size:o,start:h,blend:l}=i[n];r!==t&&(r=t,this.bindAndClearTexArray(t)),this.state.blendMode=l,s.set(this.state),e.drawElements(a,o,e.UNSIGNED_SHORT,2*h)}}flush(){0!==this._vertexCount&&(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),Mi.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=Le(Math.ceil(t/8)),s=Ue(e),i=8*e;this._aBuffers.length<=s&&(this._iBuffers.length=s+1);let r=this._aBuffers[i];return r||(this._aBuffers[i]=r=new hs(i*this.vertexSize*4)),r}getIndexBuffer(t){const e=Le(Math.ceil(t/12)),s=Ue(e),i=12*e;this._iBuffers.length<=s&&(this._iBuffers.length=s+1);let r=this._iBuffers[s];return r||(this._iBuffers[s]=r=new Uint16Array(i)),r}packInterleavedGeometry(t,e,s,i,r){const{uint32View:n,float32View:a}=e,o=i/this.vertexSize,h=t.uvs,l=t.indices,u=t.vertexData,d=t._texture.baseTexture._batchLocation,c=Math.min(t.worldAlpha,1),p=Ie.shared.setValue(t._tintRGB).toPremultiplied(c,t._texture.baseTexture.alphaMode>0);for(let t=0;t<u.length;t+=2)a[i++]=u[t],a[i++]=u[t+1],a[i++]=h[t],a[i++]=h[t+1],n[i++]=p,a[i++]=d;for(let t=0;t<l.length;t++)s[r++]=o+l[t]}};let Ci=Mi;Ci.defaultBatchSize=4096,Ci.extension={name:"batch",type:rs.RendererPlugin},Ci._drawCallPool=[],Ci._textureArrayPool=[],os.add(Ci);const Di=class extends Ri{constructor(t,e,s){super(bi.from(t||Di.defaultVertexSrc,e||Di.defaultFragmentSrc),s),this.padding=0,this.resolution=Di.defaultResolution,this.multisample=Di.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new cs}apply(t,e,s,i,r){t.applyFilter(this,e,s,i)}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"attribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n"}static get defaultFragmentSrc(){return"varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nvoid main(void){\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n}\n"}};let Pi=Di;Pi.defaultResolution=1,Pi.defaultMultisample=T.NONE;class Oi{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Ie(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:s,backgroundAlpha:i}=t,r=null!=s?s:e;void 0!==r&&(this.color=r),this.alpha=i}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(){}}Oi.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Oi.extension={type:[rs.RendererSystem,rs.CanvasRendererSystem],name:"background"},os.add(Oi);class Fi{constructor(t){this.renderer=t,this.emptyRenderer=new Ii(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:s}=this.renderer.texture;for(let i=e-1;i>=0;--i)t[i]=s[i]||null,t[i]&&(t[i]._batchLocation=i)}boundArray(t,e,s,i){const{elements:r,ids:n,count:a}=t;let o=0;for(let t=0;t<a;t++){const a=r[t],h=a._batchLocation;if(h>=0&&h<i&&e[h]===a)n[t]=h;else for(;o<i;){const i=e[o];if(!i||i._batchEnabled!==s||i._batchLocation!==o){n[t]=o,a._batchLocation=o,e[o]=a;break}o++}}}destroy(){this.renderer=null}}Fi.extension={type:rs.RendererSystem,name:"batch"},os.add(Fi);let Bi=0;class Ni{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=Bi++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,s=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:s,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=Bi++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;void 0!==e.addEventListener&&(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 s;if(A.PREFER_ENV>=i.WEBGL2&&(s=t.getContext("webgl2",e)),s)this.webGLVersion=2;else if(this.webGLVersion=1,s=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!s)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=s,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")};1===this.webGLVersion?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")}):2===this.webGLVersion&&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,void 0!==t.removeEventListener&&(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(),s="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;s&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const i=s||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=i,i||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}Ni.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},Ni.extension={type:rs.RendererSystem,name:"context"},os.add(Ni);class Li extends gs{upload(t,e,s){const i=t.gl;i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===m.UNPACK);const r=e.realWidth,n=e.realHeight;return s.width===r&&s.height===n?i.texSubImage2D(e.target,0,0,0,r,n,e.format,s.type,this.data):(s.width=r,s.height=n,i.texImage2D(e.target,0,s.internalFormat,r,n,0,e.format,s.type,this.data)),!0}}class Gi{constructor(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 ms("disposeFramebuffer"),this.multisample=T.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new ys(null,{scaleMode:c.NEAREST,resolution:1,mipmap:f.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new ys(new Li(null,{width:this.width,height:this.height}),{scaleMode:c.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:f.OFF,format:h.DEPTH_COMPONENT,type:u.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!==this.width||e!==this.height){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let s=0;s<this.colorTextures.length;s++){const i=this.colorTextures[s],r=i.resolution;i.setSize(t/r,e/r)}if(this.depthTexture){const s=this.depthTexture.resolution;this.depthTexture.setSize(t/s,e/s)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Ui extends ys{constructor(t={}){if("number"==typeof t){t={width:arguments[0],height:arguments[1],scaleMode:arguments[2],resolution:arguments[3]}}t.width=t.width||100,t.height=t.height||100,null!=t.multisample||(t.multisample=T.NONE),super(null,t),this.mipmap=f.OFF,this.valid=!0,this._clear=new Ie([0,0,0,0]),this.framebuffer=new Gi(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}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 ki extends _s{constructor(t){const e=t;super(e.naturalWidth||e.videoWidth||e.width,e.naturalHeight||e.videoHeight||e.height),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,s){void 0!==s||e.startsWith("data:")?!1!==s&&(t.crossOrigin="string"==typeof s?s:"anonymous"):t.crossOrigin=es(e)}upload(t,e,s,i){const r=t.gl,n=e.realWidth,a=e.realHeight;if(i=i||this.source,"undefined"!=typeof HTMLImageElement&&i instanceof HTMLImageElement){if(!i.complete||0===i.naturalWidth)return!1}else if("undefined"!=typeof HTMLVideoElement&&i instanceof HTMLVideoElement&&i.readyState<=1&&0===i.buffered.length)return!1;return r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===m.UNPACK),this.noSubImage||e.target!==r.TEXTURE_2D||s.width!==n||s.height!==a?(s.width=n,s.height=a,r.texImage2D(e.target,0,s.internalFormat,e.format,s.type,i)):r.texSubImage2D(r.TEXTURE_2D,0,0,0,e.format,s.type,i),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,s=t.naturalHeight||t.videoHeight||t.height;this.resize(e,s),super.update()}dispose(){this.source=null}}class Xi extends ki{constructor(t,e){var s;if(e=e||{},"string"==typeof t){const s=new Image;ki.crossOrigin(s,t,e.crossorigin),s.src=t,t=s}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=(null!=(s=e.createBitmap)?s:A.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode="number"==typeof e.alphaMode?e.alphaMode:null,this.bitmap=null,this._load=null,!1!==e.autoLoad&&this.load()}load(t){return this._load||(void 0!==t&&(this.createBitmap=t),this._load=new Promise(((t,e)=>{const s=this.source;this.url=s.src;const i=()=>{this.destroyed||(s.onload=null,s.onerror=null,this.resize(s.width,s.height),this._load=null,this.createBitmap?t(this.process()):t(this))};s.complete&&s.src?i():(s.onload=i,s.onerror=t=>{e(t),this.onError.emit(t)})}))),this._load}process(){const t=this.source;if(null!==this._process)return this._process;if(null!==this.bitmap||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,s=!t.crossOrigin||"anonymous"===t.crossOrigin;return this._process=fetch(t.src,{mode:s?"cors":"no-cors"}).then((t=>t.blob())).then((s=>e(s,0,0,t.width,t.height,{premultiplyAlpha:null===this.alphaMode||this.alphaMode===m.UNPACK?"premultiply":"none"}))).then((t=>this.destroyed?Promise.reject():(this.bitmap=t,this.update(),this._process=null,Promise.resolve(this)))),this._process}upload(t,e,s){if("number"==typeof this.alphaMode&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,s);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,s,this.bitmap),!this.preserveBitmap){let t=!0;const i=e._glTextures;for(const r in i){const n=i[r];if(n!==s&&n.dirtyId!==e.dirtyId){t=!1;break}}t&&(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"undefined"!=typeof HTMLImageElement&&("string"==typeof t||t instanceof HTMLImageElement)}}class Hi{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,s){const i=e.width,r=e.height;if(s){const e=t.width/2/i,n=t.height/2/r,a=t.x/i+e,o=t.y/r+n;s=Ks.add(s,Ks.NW),this.x0=a+e*Ks.uX(s),this.y0=o+n*Ks.uY(s),s=Ks.add(s,2),this.x1=a+e*Ks.uX(s),this.y1=o+n*Ks.uY(s),s=Ks.add(s,2),this.x2=a+e*Ks.uX(s),this.y2=o+n*Ks.uY(s),s=Ks.add(s,2),this.x3=a+e*Ks.uX(s),this.y3=o+n*Ks.uY(s)}else this.x0=t.x/i,this.y0=t.y/r,this.x1=(t.x+t.width)/i,this.y1=t.y/r,this.x2=(t.x+t.width)/i,this.y2=(t.y+t.height)/r,this.x3=t.x/i,this.y3=(t.y+t.height)/r;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}toString(){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 Vi=new Hi;function zi(t){t.destroy=function(){},t.on=function(){},t.once=function(){},t.emit=function(){}}class Wi extends W{constructor(t,e,s,i,r,n,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new Ls(0,0,1,1)),t instanceof Wi&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=i,this.valid=!1,this._uvs=Vi,this.uvMatrix=null,this.orig=s||e,this._rotate=Number(r||0),!0===r)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=n?new Bs(n.x,n.y):new Bs(0,0),this.defaultBorders=a,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:t}=this.baseTexture;(null==t?void 0:t.url)&&je[t.url]&&Wi.removeFromCache(t.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,Wi.removeFromCache(this),this.textureCacheIds=null}clone(){var t;const e=this._frame.clone(),s=this._frame===this.orig?e:this.orig.clone(),i=new Wi(this.baseTexture,!this.noFrame&&e,s,null==(t=this.trim)?void 0:t.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=e),i}updateUvs(){this._uvs===Vi&&(this._uvs=new Hi),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},s=A.STRICT_TEXTURE_CACHE){const i="string"==typeof t;let r=null;if(i)r=t;else if(t instanceof ys){if(!t.cacheId){const s=(null==e?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${s}-${Ve()}`,ys.addToCache(t,t.cacheId)}r=t.cacheId}else{if(!t._pixiId){const s=(null==e?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${s}_${Ve()}`}r=t._pixiId}let n=je[r];if(i&&s&&!n)throw new Error(`The cacheId "${r}" does not exist in TextureCache.`);return n||t instanceof ys?!n&&t instanceof ys&&(n=new Wi(t),Wi.addToCache(n,r)):(e.resolution||(e.resolution=ss(t)),n=new Wi(new ys(t,e)),n.baseTexture.cacheId=r,ys.addToCache(n.baseTexture,r),Wi.addToCache(n,r)),n}static fromURL(t,e){const s=Object.assign({autoLoad:!1},null==e?void 0:e.resourceOptions),i=Wi.from(t,Object.assign({resourceOptions:s},e),!1),r=i.baseTexture.resource;return i.baseTexture.valid?Promise.resolve(i):r.load().then((()=>Promise.resolve(i)))}static fromBuffer(t,e,s,i){return new Wi(ys.fromBuffer(t,e,s,i))}static fromLoader(t,e,s,i){const r=new ys(t,Object.assign({scaleMode:ys.defaultOptions.scaleMode,resolution:ss(e)},i)),{resource:n}=r;n instanceof Xi&&(n.url=e);const a=new Wi(r);return s||(s=e),ys.addToCache(a.baseTexture,s),Wi.addToCache(a,s),s!==e&&(ys.addToCache(a.baseTexture,e),Wi.addToCache(a,e)),a.baseTexture.valid?Promise.resolve(a):new Promise((t=>{a.baseTexture.once("loaded",(()=>t(a)))}))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),je[e]&&je[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),je[e]=t)}static removeFromCache(t){if("string"==typeof t){const e=je[t];if(e){const s=e.textureCacheIds.indexOf(t);return s>-1&&e.textureCacheIds.splice(s,1),delete je[t],e}}else if(null!=t&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)je[t.textureCacheIds[e]]===t&&delete je[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:s,width:i,height:r}=t,n=e+i>this.baseTexture.width,a=s+r>this.baseTexture.height;if(n||a){const t=n&&a?"and":"or",o=`X: ${e} + ${i} = ${e+i} > ${this.baseTexture.width}`,h=`Y: ${s} + ${r} = ${s+r} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${o} ${t} ${h}`)}this.valid=i&&r&&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 Wi._EMPTY||(Wi._EMPTY=new Wi(new ys),zi(Wi._EMPTY),zi(Wi._EMPTY.baseTexture)),Wi._EMPTY}static get WHITE(){if(!Wi._WHITE){const t=A.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),Wi._WHITE=new Wi(ys.from(t)),zi(Wi._WHITE),zi(Wi._WHITE.baseTexture)}return Wi._WHITE}}class Yi extends Wi{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,s=!0){const i=this.baseTexture.resolution,r=Math.round(t*i)/i,n=Math.round(e*i)/i;this.valid=r>0&&n>0,this._frame.width=this.orig.width=r,this._frame.height=this.orig.height=n,s&&this.baseTexture.resize(r,n),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 Yi(new Ui(t))}}class ji{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,s=T.NONE){const i=new Ui(Object.assign({width:t,height:e,resolution:1,multisample:s},this.textureOptions));return new Yi(i)}getOptimalTexture(t,e,s=1,i=T.NONE){let r;t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),this.enableFullScreen&&t===this._pixelsWidth&&e===this._pixelsHeight?r=i>1?-i:-1:(r=((65535&(t=Le(t)))<<16|65535&(e=Le(e)))>>>0,i>1&&(r+=4294967296*i)),this.texturePool[r]||(this.texturePool[r]=[]);let n=this.texturePool[r].pop();return n||(n=this.createTexture(t,e,i)),n.filterPoolKey=r,n.setResolution(s),n}getFilterTexture(t,e,s){const i=this.getOptimalTexture(t.width,t.height,e||t.resolution,s||T.NONE);return i.filterFrame=t.filterFrame,i}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=!1!==t)for(const t in this.texturePool){const e=this.texturePool[t];if(e)for(let t=0;t<e.length;t++)e[t].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 t in this.texturePool){if(!(Number(t)<0))continue;const e=this.texturePool[t];if(e)for(let t=0;t<e.length;t++)e[t].destroy(!0);this.texturePool[t]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}ji.SCREEN_KEY=-1;class $i extends Ms{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class qi extends Ms{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 Es(this.vertices),this.uvBuffer=new Es(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let s=0,i=0;return this.uvs[0]=s,this.uvs[1]=i,this.uvs[2]=s+e.width/t.width,this.uvs[3]=i,this.uvs[4]=s+e.width/t.width,this.uvs[5]=i+e.height/t.height,this.uvs[6]=s,this.uvs[7]=i+e.height/t.height,s=e.x,i=e.y,this.vertices[0]=s,this.vertices[1]=i,this.vertices[2]=s+e.width,this.vertices[3]=i,this.vertices[4]=s+e.width,this.vertices[5]=i+e.height,this.vertices[6]=s,this.vertices[7]=i+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class Ki{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=T.NONE,this.sourceFrame=new Ls,this.destinationFrame=new Ls,this.bindingSourceFrame=new Ls,this.bindingDestinationFrame=new Ls,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const Zi=[new Bs,new Bs,new Bs,new Bs],Ji=new Hs;class tr{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new ji,this.statePool=[],this.quad=new $i,this.quadUv=new qi,this.tempRect=new Ls,this.activeState={},this.globalUniforms=new Ai({outputFrame:new Ls,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){var s,i;const r=this.renderer,n=this.defaultFilterStack,a=this.statePool.pop()||new Ki,o=this.renderer.renderTexture;let h=e[0].resolution,l=e[0].multisample,u=e[0].padding,d=e[0].autoFit,c=null==(s=e[0].legacy)||s;for(let t=1;t<e.length;t++){const s=e[t];h=Math.min(h,s.resolution),l=Math.min(l,s.multisample),u=this.useMaxPadding?Math.max(u,s.padding):u+s.padding,d=d&&s.autoFit,c=c||null==(i=s.legacy)||i}1===n.length&&(this.defaultFilterStack[0].renderTexture=o.current),n.push(a),a.resolution=h,a.multisample=l,a.legacy=c,a.target=t,a.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),a.sourceFrame.pad(u);const p=this.tempRect.copyFrom(o.sourceFrame);r.projection.transform&&this.transformAABB(Ji.copyFrom(r.projection.transform).invert(),p),d?(a.sourceFrame.fit(p),(a.sourceFrame.width<=0||a.sourceFrame.height<=0)&&(a.sourceFrame.width=0,a.sourceFrame.height=0)):a.sourceFrame.intersects(p)||(a.sourceFrame.width=0,a.sourceFrame.height=0),this.roundFrame(a.sourceFrame,o.current?o.current.resolution:r.resolution,o.sourceFrame,o.destinationFrame,r.projection.transform),a.renderTexture=this.getOptimalFilterTexture(a.sourceFrame.width,a.sourceFrame.height,h,l),a.filters=e,a.destinationFrame.width=a.renderTexture.width,a.destinationFrame.height=a.renderTexture.height;const f=this.tempRect;f.x=0,f.y=0,f.width=a.sourceFrame.width,f.height=a.sourceFrame.height,a.renderTexture.filterFrame=a.sourceFrame,a.bindingSourceFrame.copyFrom(o.sourceFrame),a.bindingDestinationFrame.copyFrom(o.destinationFrame),a.transform=r.projection.transform,r.projection.transform=null,o.bind(a.renderTexture,a.sourceFrame,f),r.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),s=e.filters;this.activeState=e;const i=this.globalUniforms.uniforms;i.outputFrame=e.sourceFrame,i.resolution=e.resolution;const r=i.inputSize,n=i.inputPixel,a=i.inputClamp;if(r[0]=e.destinationFrame.width,r[1]=e.destinationFrame.height,r[2]=1/r[0],r[3]=1/r[1],n[0]=Math.round(r[0]*e.resolution),n[1]=Math.round(r[1]*e.resolution),n[2]=1/n[0],n[3]=1/n[1],a[0]=.5*n[2],a[1]=.5*n[3],a[2]=e.sourceFrame.width*r[2]-.5*n[2],a[3]=e.sourceFrame.height*r[3]-.5*n[3],e.legacy){const t=i.filterArea;t[0]=e.destinationFrame.width,t[1]=e.destinationFrame.height,t[2]=e.sourceFrame.x,t[3]=e.sourceFrame.y,i.filterClamp=i.inputClamp}this.globalUniforms.update();const o=t[t.length-1];if(this.renderer.framebuffer.blit(),1===s.length)s[0].apply(this,e.renderTexture,o.renderTexture,_.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let t=e.renderTexture,i=this.getOptimalFilterTexture(t.width,t.height,e.resolution);i.filterFrame=t.filterFrame;let r=0;for(r=0;r<s.length-1;++r){1===r&&e.multisample>1&&(i=this.getOptimalFilterTexture(t.width,t.height,e.resolution),i.filterFrame=t.filterFrame),s[r].apply(this,t,i,_.CLEAR,e);const n=t;t=i,i=n}s[r].apply(this,t,o.renderTexture,_.BLEND,e),r>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(t),this.returnFilterTexture(i)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=_.CLEAR){const{renderTexture:s,state:i}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,null!=t&&t.filterFrame){const e=this.tempRect;e.x=0,e.y=0,e.width=t.filterFrame.width,e.height=t.filterFrame.height,s.bind(t,t.filterFrame,e)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?s.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const r=1&i.stateId||this.forceClear;(e===_.CLEAR||e===_.BLIT&&r)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,s,i){const r=this.renderer;r.state.set(t.state),this.bindAndClear(s,i),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,r.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),r.geometry.bind(this.quadUv),r.geometry.draw(o.TRIANGLES)):(r.geometry.bind(this.quad),r.geometry.draw(o.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:s,destinationFrame:i}=this.activeState,{orig:r}=e._texture,n=t.set(i.width,0,0,i.height,s.x,s.y),a=e.worldTransform.copyTo(Hs.TEMP_MATRIX);return a.invert(),n.prepend(a),n.scale(1/r.width,1/r.height),n.translate(e.anchor.x,e.anchor.y),n}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,s=1,i=T.NONE){return this.texturePool.getOptimalTexture(t,e,s,i)}getFilterTexture(t,e,s){if("number"==typeof t){const s=t;t=e,e=s}t=t||this.activeState.renderTexture;const i=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,s||T.NONE);return i.filterFrame=t.filterFrame,i}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const s=Zi[0],i=Zi[1],r=Zi[2],n=Zi[3];s.set(e.left,e.top),i.set(e.left,e.bottom),r.set(e.right,e.top),n.set(e.right,e.bottom),t.apply(s,s),t.apply(i,i),t.apply(r,r),t.apply(n,n);const a=Math.min(s.x,i.x,r.x,n.x),o=Math.min(s.y,i.y,r.y,n.y),h=Math.max(s.x,i.x,r.x,n.x),l=Math.max(s.y,i.y,r.y,n.y);e.x=a,e.y=o,e.width=h-a,e.height=l-o}roundFrame(t,e,s,i,r){if(!(t.width<=0||t.height<=0||s.width<=0||s.height<=0)){if(r){const{a:t,b:e,c:s,d:i}=r;if((Math.abs(e)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(t)>1e-4||Math.abs(i)>1e-4))return}(r=r?Ji.copyFrom(r):Ji.identity()).translate(-s.x,-s.y).scale(i.width/s.width,i.height/s.height).translate(i.x,i.y),this.transformAABB(r,t),t.ceil(e),this.transformAABB(r.invert(),t)}}}tr.extension={type:rs.RendererSystem,name:"filter"},os.add(tr);class er{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=T.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const sr=new Ls;class ir{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Gi(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 Ls,this.hasMRT=!0,this.writeDepthTexture=!0,1===this.renderer.context.webGLVersion){let e=this.renderer.context.extensions.drawBuffers,s=this.renderer.context.extensions.depthTexture;A.PREFER_ENV===i.WEBGL_LEGACY&&(e=null,s=null),e?t.drawBuffers=t=>e.drawBuffersWEBGL(t):(this.hasMRT=!1,t.drawBuffers=()=>{}),s||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,s=0){const{gl:i}=this;if(t){const r=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,i.bindFramebuffer(i.FRAMEBUFFER,r.framebuffer)),r.mipLevel!==s&&(t.dirtyId++,t.dirtyFormat++,r.mipLevel=s),r.dirtyId!==t.dirtyId&&(r.dirtyId=t.dirtyId,r.dirtyFormat!==t.dirtyFormat?(r.dirtyFormat=t.dirtyFormat,r.dirtySize=t.dirtySize,this.updateFramebuffer(t,s)):r.dirtySize!==t.dirtySize&&(r.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let e=0;e<t.colorTextures.length;e++){const s=t.colorTextures[e];this.renderer.texture.unbind(s.parentTextureArray||s)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const t=e.width>>s,i=e.height>>s,r=t/e.width;this.setViewport(e.x*r,e.y*r,t,i)}else{const e=t.width>>s,i=t.height>>s;this.setViewport(0,0,e,i)}}else this.current&&(this.current=null,i.bindFramebuffer(i.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,s,i){const r=this.viewport;t=Math.round(t),e=Math.round(e),s=Math.round(s),i=Math.round(i),(r.width!==s||r.height!==i||r.x!==t||r.y!==e)&&(r.x=t,r.y=e,r.width=s,r.height=i,this.gl.viewport(t,e,s,i))}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,s,i,r=n.COLOR|n.DEPTH){const{gl:a}=this;a.clearColor(t,e,s,i),a.clear(r)}initFramebuffer(t){const{gl:e}=this,s=new er(e.createFramebuffer());return s.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=s,this.managedFramebuffers.push(t),t.disposeRunner.add(this),s}resizeFramebuffer(t){const{gl:e}=this,s=t.glFramebuffers[this.CONTEXT_UID];s.stencil&&(e.bindRenderbuffer(e.RENDERBUFFER,s.stencil),s.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,s.multisample,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,t.width,t.height));const i=t.colorTextures;let r=i.length;e.drawBuffers||(r=Math.min(r,1));for(let n=0;n<r;n++){const r=i[n],a=r.parentTextureArray||r;this.renderer.texture.bind(a,0),0===n&&s.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,s.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,s.multisample,a._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:s}=this,i=t.glFramebuffers[this.CONTEXT_UID],r=t.colorTextures;let n=r.length;s.drawBuffers||(n=Math.min(n,1)),i.multisample>1&&this.canMultisampleFramebuffer(t)?i.msaaBuffer=i.msaaBuffer||s.createRenderbuffer():i.msaaBuffer&&(s.deleteRenderbuffer(i.msaaBuffer),i.msaaBuffer=null,i.blitFramebuffer&&(i.blitFramebuffer.dispose(),i.blitFramebuffer=null));const a=[];for(let o=0;o<n;o++){const n=r[o],h=n.parentTextureArray||n;this.renderer.texture.bind(h,0),0===o&&i.msaaBuffer?(s.bindRenderbuffer(s.RENDERBUFFER,i.msaaBuffer),s.renderbufferStorageMultisample(s.RENDERBUFFER,i.multisample,h._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,i.msaaBuffer)):(s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+o,n.target,h._glTextures[this.CONTEXT_UID].texture,e),a.push(s.COLOR_ATTACHMENT0+o))}if(a.length>1&&s.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const i=t.depthTexture;this.renderer.texture.bind(i,0),s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,i._glTextures[this.CONTEXT_UID].texture,e)}!t.stencil&&!t.depth||t.depthTexture&&this.writeDepthTexture?i.stencil&&(s.deleteRenderbuffer(i.stencil),i.stencil=null):(i.stencil=i.stencil||s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,i.stencil),i.msaaBuffer?s.renderbufferStorageMultisample(s.RENDERBUFFER,i.multisample,s.DEPTH24_STENCIL8,t.width,t.height):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,t.width,t.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,i.stencil))}canMultisampleFramebuffer(t){return 1!==this.renderer.context.webGLVersion&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let s=T.NONE;if(t<=1||null===e)return s;for(let i=0;i<e.length;i++)if(e[i]<=t){s=e[i];break}return 1===s&&(s=T.NONE),s}blit(t,e,s){const{current:i,renderer:r,gl:n,CONTEXT_UID:a}=this;if(2!==r.context.webGLVersion||!i)return;const o=i.glFramebuffers[a];if(!o)return;if(!t){if(!o.msaaBuffer)return;const e=i.colorTextures[0];if(!e)return;o.blitFramebuffer||(o.blitFramebuffer=new Gi(i.width,i.height),o.blitFramebuffer.addColorTexture(0,e)),(t=o.blitFramebuffer).colorTextures[0]!==e&&(t.colorTextures[0]=e,t.dirtyId++,t.dirtyFormat++),(t.width!==i.width||t.height!==i.height)&&(t.width=i.width,t.height=i.height,t.dirtyId++,t.dirtySize++)}e||((e=sr).width=i.width,e.height=i.height),s||(s=e);const h=e.width===s.width&&e.height===s.height;this.bind(t),n.bindFramebuffer(n.READ_FRAMEBUFFER,o.framebuffer),n.blitFramebuffer(e.left,e.top,e.right,e.bottom,s.left,s.top,s.right,s.bottom,n.COLOR_BUFFER_BIT,h?n.NEAREST:n.LINEAR),n.bindFramebuffer(n.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const s=t.glFramebuffers[this.CONTEXT_UID],i=this.gl;if(!s)return;delete t.glFramebuffers[this.CONTEXT_UID];const r=this.managedFramebuffers.indexOf(t);r>=0&&this.managedFramebuffers.splice(r,1),t.disposeRunner.remove(this),e||(i.deleteFramebuffer(s.framebuffer),s.msaaBuffer&&i.deleteRenderbuffer(s.msaaBuffer),s.stencil&&i.deleteRenderbuffer(s.stencil)),s.blitFramebuffer&&this.disposeFramebuffer(s.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let s=0;s<e.length;s++)this.disposeFramebuffer(e[s],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil)return;t.stencil=!0;const s=t.width,i=t.height,r=this.gl,n=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,n),e.msaaBuffer?r.renderbufferStorageMultisample(r.RENDERBUFFER,e.multisample,r.DEPTH24_STENCIL8,s,i):r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,s,i),e.stencil=n,r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,n)}reset(){this.current=this.unknownFramebuffer,this.viewport=new Ls}destroy(){this.renderer=null}}ir.extension={type:rs.RendererSystem,name:"framebuffer"},os.add(ir);const rr={5126:4,5123:2,5121:1};class nr{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,2!==e.webGLVersion){let e=this.renderer.context.extensions.vertexArrayObject;A.PREFER_ENV===i.WEBGL_LEGACY&&(e=null),e?(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=t=>e.bindVertexArrayOES(t),t.deleteVertexArray=t=>e.deleteVertexArrayOES(t)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(2!==e.webGLVersion){const e=t.getExtension("ANGLE_instanced_arrays");e?(t.vertexAttribDivisor=(t,s)=>e.vertexAttribDivisorANGLE(t,s),t.drawElementsInstanced=(t,s,i,r,n)=>e.drawElementsInstancedANGLE(t,s,i,r,n),t.drawArraysInstanced=(t,s,i,r)=>e.drawArraysInstancedANGLE(t,s,i,r)):this.hasInstance=!1}this.canUseUInt32ElementIndex=2===e.webGLVersion||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:s}=this;let i=t.glVertexArrayObjects[this.CONTEXT_UID],r=!1;i||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=i={},r=!0);const n=i[e.program.id]||this.initGeometryVao(t,e,r);this._activeGeometry=t,this._activeVao!==n&&(this._activeVao=n,this.hasVao?s.bindVertexArray(n):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let s=0;s<t.buffers.length;s++){const i=t.buffers[s];e.update(i)}}checkCompatibility(t,e){const s=t.attributes,i=e.attributeData;for(const t in i)if(!s[t])throw new Error(`shader and geometry incompatible, geometry missing the "${t}" attribute`)}getSignature(t,e){const s=t.attributes,i=e.attributeData,r=["g",t.id];for(const t in s)i[t]&&r.push(t,i[t].location);return r.join("-")}initGeometryVao(t,e,s=!0){const i=this.gl,r=this.CONTEXT_UID,n=this.renderer.buffer,a=e.program;a.glPrograms[r]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,a);const o=this.getSignature(t,a),h=t.glVertexArrayObjects[this.CONTEXT_UID];let l=h[o];if(l)return h[a.id]=l,l;const u=t.buffers,d=t.attributes,c={},p={};for(const t in u)c[t]=0,p[t]=0;for(const t in d)!d[t].size&&a.attributeData[t]?d[t].size=a.attributeData[t].size:d[t].size||console.warn(`PIXI Geometry attribute '${t}' size cannot be determined (likely the bound shader does not have the attribute)`),c[d[t].buffer]+=d[t].size*rr[d[t].type];for(const t in d){const e=d[t],s=e.size;void 0===e.stride&&(c[e.buffer]===s*rr[e.type]?e.stride=0:e.stride=c[e.buffer]),void 0===e.start&&(e.start=p[e.buffer],p[e.buffer]+=s*rr[e.type])}l=i.createVertexArray(),i.bindVertexArray(l);for(let t=0;t<u.length;t++){const e=u[t];n.bind(e),s&&e._glBuffers[r].refCount++}return this.activateVao(t,a),h[a.id]=l,h[o]=l,i.bindVertexArray(null),n.unbind(b.ARRAY_BUFFER),l}disposeGeometry(t,e){var s;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=null==(s=this.renderer)?void 0:s.buffer;if(t.disposeRunner.remove(this),i){if(a)for(let t=0;t<n.length;t++){const s=n[t]._glBuffers[this.CONTEXT_UID];s&&(s.refCount--,0===s.refCount&&!e&&a.dispose(n[t],e))}if(!e)for(const t in i)if("g"===t[0]){const e=i[t];this._activeVao===e&&this.unbind(),r.deleteVertexArray(e)}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let s=0;s<e.length;s++)this.disposeGeometry(this.managedGeometries[e[s]],t)}activateVao(t,e){const s=this.gl,i=this.CONTEXT_UID,r=this.renderer.buffer,n=t.buffers,a=t.attributes;t.indexBuffer&&r.bind(t.indexBuffer);let o=null;for(const t in a){const h=a[t],l=n[h.buffer],u=l._glBuffers[i];if(e.attributeData[t]){o!==u&&(r.bind(l),o=u);const i=e.attributeData[t].location;if(s.enableVertexAttribArray(i),s.vertexAttribPointer(i,h.size,h.type||s.FLOAT,h.normalized,h.stride,h.start),h.instance){if(!this.hasInstance)throw new Error("geometry error, GPU Instancing is not supported on this device");s.vertexAttribDivisor(i,h.divisor)}}}}draw(t,e,s,i){const{gl:r}=this,n=this._activeGeometry;if(n.indexBuffer){const a=n.indexBuffer.data.BYTES_PER_ELEMENT,o=2===a?r.UNSIGNED_SHORT:r.UNSIGNED_INT;2===a||4===a&&this.canUseUInt32ElementIndex?n.instanced?r.drawElementsInstanced(t,e||n.indexBuffer.data.length,o,(s||0)*a,i||1):r.drawElements(t,e||n.indexBuffer.data.length,o,(s||0)*a):console.warn("unsupported index buffer type: uint32")}else n.instanced?r.drawArraysInstanced(t,s,e||n.getSize(),i||1):r.drawArrays(t,s,e||n.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}nr.extension={type:rs.RendererSystem,name:"geometry"},os.add(nr);const ar=new Hs;class or{constructor(t,e){this._texture=t,this.mapCoord=new Hs,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=void 0===e?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){void 0===e&&(e=t);const s=this.mapCoord;for(let i=0;i<t.length;i+=2){const r=t[i],n=t[i+1];e[i]=r*s.a+n*s.c+s.tx,e[i+1]=r*s.b+n*s.d+s.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 s=e._uvs;this.mapCoord.set(s.x1-s.x0,s.y1-s.y0,s.x3-s.x0,s.y3-s.y0,s.x0,s.y0);const i=e.orig,r=e.trim;r&&(ar.set(i.width/r.width,0,0,i.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append(ar));const n=e.baseTexture,a=this.uClampFrame,o=this.clampMargin/n.resolution,h=this.clampOffset;return a[0]=(e._frame.x+o+h)/n.width,a[1]=(e._frame.y+o+h)/n.height,a[2]=(e._frame.x+e._frame.width-o+h)/n.width,a[3]=(e._frame.y+e._frame.height-o+h)/n.height,this.uClampOffset[0]=h/n.realWidth,this.uClampOffset[1]=h/n.realHeight,this.isSimple=e._frame.width===n.width&&e._frame.height===n.height&&0===e.rotate,!0}}class hr extends Pi{constructor(t,e,s){let i=null;"string"!=typeof t&&void 0===e&&void 0===s&&(i=t,t=void 0,e=void 0,s=void 0),super(t||"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;\n}\n",e||"varying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform sampler2D mask;\nuniform float alpha;\nuniform float npmAlpha;\nuniform vec4 maskClamp;\n\nvoid main(void)\n{\n float clip = step(3.5,\n step(maskClamp.x, vMaskCoord.x) +\n step(maskClamp.y, vMaskCoord.y) +\n step(vMaskCoord.x, maskClamp.z) +\n step(vMaskCoord.y, maskClamp.w));\n\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, vMaskCoord);\n float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);\n\n original *= (alphaMul * masky.r * alpha * clip);\n\n gl_FragColor = original;\n}\n",s),this.maskSprite=i,this.maskMatrix=new Hs}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,s,i){const r=this._maskSprite,n=r._texture;!n.valid||(n.uvMatrix||(n.uvMatrix=new or(n,0)),n.uvMatrix.update(),this.uniforms.npmAlpha=n.baseTexture.alphaMode?0:1,this.uniforms.mask=n,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,r).prepend(n.uvMatrix.mapCoord),this.uniforms.alpha=r.worldAlpha,this.uniforms.maskClamp=n.uvMatrix.uClampFrame,t.applyFilter(this,e,s,i))}}class lr{constructor(t=null){this.type=v.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Pi.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=v.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 ur{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 s=e;if(!s.isMaskData){const t=this.maskDataPool.pop()||new lr;t.pooled=!0,t.maskObject=e,s=t}const i=0!==this.maskStack.length?this.maskStack[this.maskStack.length-1]:null;if(s.copyCountersOrReset(i),s._colorMask=i?i._colorMask:15,s.autoDetect&&this.detect(s),s._target=t,s.type!==v.SPRITE&&this.maskStack.push(s),s.enabled)switch(s.type){case v.SCISSOR:this.renderer.scissor.push(s);break;case v.STENCIL:this.renderer.stencil.push(s);break;case v.SPRITE:s.copyCountersOrReset(null),this.pushSpriteMask(s);break;case v.COLOR:this.pushColorMask(s)}s.type===v.SPRITE&&this.maskStack.push(s)}pop(t){const e=this.maskStack.pop();if(e&&e._target===t){if(e.enabled)switch(e.type){case v.SCISSOR:this.renderer.scissor.pop(e);break;case v.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case v.SPRITE:this.popSpriteMask(e);break;case v.COLOR:this.popColorMask(e)}if(e.reset(),e.pooled&&this.maskDataPool.push(e),0!==this.maskStack.length){const t=this.maskStack[this.maskStack.length-1];t.type===v.SPRITE&&t._filters&&(t._filters[0].maskSprite=t.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=v.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=v.SCISSOR:t.type=v.STENCIL:t.type=v.COLOR}pushSpriteMask(t){var e,s;const{maskObject:i}=t,r=t._target;let n=t._filters;n||(n=this.alphaMaskPool[this.alphaMaskIndex],n||(n=this.alphaMaskPool[this.alphaMaskIndex]=[new hr]));const a=this.renderer,o=a.renderTexture;let h,l;if(o.current){const s=o.current;h=t.resolution||s.resolution,l=null!=(e=t.multisample)?e:s.multisample}else h=t.resolution||a.resolution,l=null!=(s=t.multisample)?s:a.multisample;n[0].resolution=h,n[0].multisample=l,n[0].maskSprite=i;const u=r.filterArea;r.filterArea=i.getBounds(!0),a.filter.push(r,n),r.filterArea=u,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,s=t._colorMask=e&t.colorMask;s!==e&&this.renderer.gl.colorMask(0!=(1&s),0!=(2&s),0!=(4&s),0!=(8&s))}popColorMask(t){const e=t._colorMask,s=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;s!==e&&this.renderer.gl.colorMask(0!=(1&s),0!=(2&s),0!=(4&s),0!=(8&s))}destroy(){this.renderer=null}}ur.extension={type:rs.RendererSystem,name:"mask"},os.add(ur);class dr{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,s=this.getStackLength();this.maskStack=t;const i=this.getStackLength();i!==s&&(0===i?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const cr=new Hs,pr=[],fr=class extends dr{constructor(t){super(t),this.glConst=A.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){var e;if(t._scissorRectLocal)return;const s=t._scissorRect,{maskObject:i}=t,{renderer:r}=this,n=r.renderTexture,a=i.getBounds(!0,null!=(e=pr.pop())?e:new Ls);this.roundFrameToPixels(a,n.current?n.current.resolution:r.resolution,n.sourceFrame,n.destinationFrame,r.projection.transform),s&&a.fit(s),t._scissorRectLocal=a}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:s,c:i,d:r}=t;return(Math.abs(s)>1e-4||Math.abs(i)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(r)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||fr.isMatrixRotated(e.worldTransform)||fr.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const s=t._scissorRectLocal;return s.width>0&&s.height>0}roundFrameToPixels(t,e,s,i,r){fr.isMatrixRotated(r)||((r=r?cr.copyFrom(r):cr.identity()).translate(-s.x,-s.y).scale(i.width/s.width,i.height/s.height).translate(i.x,i.y),this.renderer.filter.transformAABB(r,t),t.fit(i),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&&pr.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;e=this.renderer.renderTexture.current?t.y:this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};let mr=fr;mr.extension={type:rs.RendererSystem,name:"scissor"},os.add(mr);class _r extends dr{constructor(t){super(t),this.glConst=A.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:s}=this.renderer,i=t._stencilCounter;0===i&&(this.renderer.framebuffer.forceStencil(),s.clearStencil(0),s.clear(s.STENCIL_BUFFER_BIT),s.enable(s.STENCIL_TEST)),t._stencilCounter++;const r=t._colorMask;0!==r&&(t._colorMask=0,s.colorMask(!1,!1,!1,!1)),s.stencilFunc(s.EQUAL,i,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,0!==r&&(t._colorMask=r,s.colorMask(0!=(1&r),0!=(2&r),0!=(4&r),0!=(8&r))),this._useCurrent()}pop(t){const e=this.renderer.gl;if(0===this.getStackLength())e.disable(e.STENCIL_TEST);else{const s=0!==this.maskStack.length?this.maskStack[this.maskStack.length-1]:null,i=s?s._colorMask:15;0!==i&&(s._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,0!==i&&(s._colorMask=i,e.colorMask(0!=(1&i),0!=(2&i),0!=(4&i),0!=(8&i))),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}_r.extension={type:rs.RendererSystem,name:"stencil"},os.add(_r);class gr{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get:()=>(Kt("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract)},prepare:{enumerable:!1,get:()=>(Kt("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare)},interaction:{enumerable:!1,get:()=>(Kt("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}}gr.extension={type:[rs.RendererSystem,rs.CanvasRendererSystem],name:"_plugin"},os.add(gr);class xr{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new Hs,this.transform=null}update(t,e,s,i){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,s,i),this.transform&&this.projectionMatrix.append(this.transform);const r=this.renderer;r.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,r.globalUniforms.update(),r.shader.shader&&r.shader.syncUniformGroup(r.shader.shader.uniforms.globals)}calculateProjection(t,e,s,i){const r=this.projectionMatrix,n=i?-1:1;r.identity(),r.a=1/e.width*2,r.d=n*(1/e.height*2),r.tx=-1-e.x*r.a,r.ty=-n-e.y*r.d}setTransform(t){}destroy(){this.renderer=null}}xr.extension={type:rs.RendererSystem,name:"projection"},os.add(xr);const vr=new Js;class yr{constructor(t){this.renderer=t,this._tempMatrix=new Hs}generateTexture(t,e){const s=e||{},{region:i}=s,r=zn(s,["region"]),n=i||t.getLocalBounds(null,!0);0===n.width&&(n.width=1),0===n.height&&(n.height=1);const a=Yi.create(bt({width:n.width,height:n.height},r));this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const o=t.transform;return t.transform=vr,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=o,a}destroy(){}}yr.extension={type:[rs.RendererSystem,rs.CanvasRendererSystem],name:"textureGenerator"},os.add(yr);const Tr=new Ls,br=new Ls;class Er{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new Ls,this.destinationFrame=new Ls,this.viewportFrame=new Ls}contextChange(){var t;const e=null==(t=this.renderer)?void 0:t.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(e&&e.alpha&&e.premultipliedAlpha)}bind(t=null,e,s){const i=this.renderer;let r,n,a;this.current=t,t?(r=t.baseTexture,a=r.resolution,e||(Tr.width=t.frame.width,Tr.height=t.frame.height,e=Tr),s||(br.x=t.frame.x,br.y=t.frame.y,br.width=e.width,br.height=e.height,s=br),n=r.framebuffer):(a=i.resolution,e||(Tr.width=i._view.screen.width,Tr.height=i._view.screen.height,e=Tr),s||((s=Tr).width=e.width,s.height=e.height));const o=this.viewportFrame;o.x=s.x*a,o.y=s.y*a,o.width=s.width*a,o.height=s.height*a,t||(o.y=i.view.height-(o.y+o.height)),o.ceil(),this.renderer.framebuffer.bind(n,o),this.renderer.projection.update(s,e,a,!n),t?this.renderer.mask.setMaskStack(r.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(s)}clear(t,e){const s=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,i=Ie.shared.setValue(t||s);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&i.premultiply(i.alpha);const r=this.destinationFrame,n=this.current?this.current.baseTexture:this.renderer._view.screen,a=r.width!==n.width||r.height!==n.height;if(a){let{x:t,y:e,width:s,height:i}=this.viewportFrame;t=Math.round(t),e=Math.round(e),s=Math.round(s),i=Math.round(i),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(t,e,s,i)}this.renderer.framebuffer.clear(i.red,i.green,i.blue,i.alpha,e),a&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}Er.extension={type:rs.RendererSystem,name:"renderTexture"},os.add(Er);class Ar{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 Rr(t,e){var s;const i=ti(t,t.VERTEX_SHADER,e.vertexSrc),r=ti(t,t.FRAGMENT_SHADER,e.fragmentSrc),n=t.createProgram();t.attachShader(n,i),t.attachShader(n,r);const a=null==(s=e.extra)?void 0:s.transformFeedbackVaryings;if(a&&("function"!=typeof t.transformFeedbackVaryings?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):t.transformFeedbackVaryings(n,a.names,"separate"===a.bufferMode?t.SEPARATE_ATTRIBS:t.INTERLEAVED_ATTRIBS)),t.linkProgram(n),t.getProgramParameter(n,t.LINK_STATUS)||function(t,e,s,i){t.getProgramParameter(e,t.LINK_STATUS)||(t.getShaderParameter(s,t.COMPILE_STATUS)||ui(t,s),t.getShaderParameter(i,t.COMPILE_STATUS)||ui(t,i),console.error("PixiJS Error: Could not initialize shader."),""!==t.getProgramInfoLog(e)&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",t.getProgramInfoLog(e)))}(t,n,i,r),e.attributeData=function(t,e){const s={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const i=e.getActiveAttrib(t,r);if(i.name.startsWith("gl_"))continue;const n=mi(e,i.type),a={type:n,name:i.name,size:ci(n),location:e.getAttribLocation(t,i.name)};s[i.name]=a}return s}(n,t),e.uniformData=function(t,e){const s={},i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;r++){const i=e.getActiveUniform(t,r),n=i.name.replace(/\[.*?\]$/,""),a=!!i.name.match(/\[.*?\]$/),o=mi(e,i.type);s[n]={name:n,index:r,type:o,size:i.size,isArray:a,value:si(o,i.size)}}return s}(n,t),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertexSrc)){const s=Object.keys(e.attributeData);s.sort(((t,e)=>t>e?1:-1));for(let i=0;i<s.length;i++)e.attributeData[s[i]].location=i,t.bindAttribLocation(n,i,s[i]);t.linkProgram(n)}t.deleteShader(i),t.deleteShader(r);const o={};for(const s in e.uniformData){const i=e.uniformData[s];o[s]={location:t.getUniformLocation(n,s),value:si(i.type,i.size)}}return new Ar(n,o)}function Sr(t,e,s,i,r){s.buffer.update(r)}const wr={float:"\n data[offset] = v;\n ",vec2:"\n data[offset] = v[0];\n data[offset+1] = v[1];\n ",vec3:"\n data[offset] = v[0];\n data[offset+1] = v[1];\n data[offset+2] = v[2];\n\n ",vec4:"\n data[offset] = v[0];\n data[offset+1] = v[1];\n data[offset+2] = v[2];\n data[offset+3] = v[3];\n ",mat2:"\n data[offset] = v[0];\n data[offset+1] = v[1];\n\n data[offset+4] = v[2];\n data[offset+5] = v[3];\n ",mat3:"\n data[offset] = v[0];\n data[offset+1] = v[1];\n data[offset+2] = v[2];\n\n data[offset + 4] = v[3];\n data[offset + 5] = v[4];\n data[offset + 6] = v[5];\n\n data[offset + 8] = v[6];\n data[offset + 9] = v[7];\n data[offset + 10] = v[8];\n ",mat4:"\n for(var i = 0; i < 16; i++)\n {\n data[offset + i] = v[i];\n }\n "},Ir={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:32,mat3:48,mat4:64};function Mr(t){const e=t.map((t=>({data:t,offset:0,dataLen:0,dirty:0})));let s=0,i=0,r=0;for(let t=0;t<e.length;t++){const n=e[t];if(s=Ir[n.data.type],n.data.size>1&&(s=Math.max(s,16)*n.data.size),n.dataLen=s,i%s!=0&&i<16){const t=i%s%16;i+=t,r+=t}i+s>16?(r=16*Math.ceil(r/16),n.offset=r,r+=s,i=s):(n.offset=r,i+=s,r+=s)}return r=16*Math.ceil(r/16),{uboElements:e,size:r}}function Cr(t,e){const s=[];for(const i in t)e[i]&&s.push(e[i]);return s.sort(((t,e)=>t.index-e.index)),s}function Dr(t,e){if(!t.autoManage)return{size:0,syncFunc:Sr};const s=Cr(t.uniforms,e),{uboElements:i,size:r}=Mr(s),n=["\n var v = null;\n var v2 = null;\n var cv = null;\n var t = 0;\n var gl = renderer.gl\n var index = 0;\n var data = buffer.data;\n "];for(let e=0;e<i.length;e++){const s=i[e],r=t.uniforms[s.data.name],a=s.data.name;let o=!1;for(let t=0;t<ii.length;t++){const e=ii[t];if(e.codeUbo&&e.test(s.data,r)){n.push(`offset = ${s.offset/4};`,ii[t].codeUbo(s.data.name,r)),o=!0;break}}if(!o)if(s.data.size>1){const t=ci(s.data.type),e=Math.max(Ir[s.data.type]/16,1),i=t/e,r=(4-i%4)%4;n.push(`\n cv = ud.${a}.value;\n v = uv.${a};\n offset = ${s.offset/4};\n\n t = 0;\n\n for(var i=0; i < ${s.data.size*e}; i++)\n {\n for(var j = 0; j < ${i}; j++)\n {\n data[offset++] = v[t++];\n }\n offset += ${r};\n }\n\n `)}else{const t=wr[s.data.type];n.push(`\n cv = ud.${a}.value;\n v = uv.${a};\n offset = ${s.offset/4};\n ${t};\n `)}}return n.push("\n renderer.buffer.update(buffer);\n "),{size:r,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join("\n"))}}let Pr=0;const Or={textureCount:0,uboCount:0};class Fr{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=Pr++}systemCheck(){if(!xi())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 s=t.program,i=s.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==s&&(this.program=s,this.gl.useProgram(i.program)),e||(Or.textureCount=0,Or.uboCount=0,this.syncUniformGroup(t.uniformGroup,Or)),i}setUniforms(t){const e=this.shader.program,s=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(s.uniformData,t,this.renderer)}syncUniformGroup(t,e){const s=this.getGlProgram();(!t.static||t.dirtyId!==s.uniformDirtyGroups[t.id])&&(s.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,s,e))}syncUniforms(t,e,s){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,s)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=function(t,e){var s;const i=["\n var v = null;\n var cv = null;\n var cu = null;\n var t = 0;\n var gl = renderer.gl;\n "];for(const r in t.uniforms){const n=e[r];if(!n){null!=(s=t.uniforms[r])&&s.group&&(t.uniforms[r].ubo?i.push(`\n renderer.shader.syncUniformBufferGroup(uv.${r}, '${r}');\n `):i.push(`\n renderer.shader.syncUniformGroup(uv.${r}, syncData);\n `));continue}const a=t.uniforms[r];let o=!1;for(let t=0;t<ii.length;t++)if(ii[t].test(n,a)){i.push(ii[t].code(r,a)),o=!0;break}if(!o){const t=(1!==n.size||n.isArray?ni:ri)[n.type].replace("location",`ud["${r}"].location`);i.push(`\n cu = ud["${r}"];\n cv = cu.value;\n v = uv["${r}"];\n ${t};`)}}return new Function("ud","uv","renderer","syncData",i.join("\n"))}(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const s=this.getGlProgram();if(!t.static||0!==t.dirtyId||!s.uniformGroups[t.id]){t.dirtyId=0;const i=s.uniformGroups[t.id]||this.createSyncBufferGroup(t,s,e);t.buffer.update(),i(s.uniformData,t.uniforms,this.renderer,Or,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,s.uniformBufferBindings[e])}createSyncBufferGroup(t,e,s){const{gl:i}=this.renderer;this.renderer.buffer.bind(t.buffer);const r=this.gl.getUniformBlockIndex(e.program,s);e.uniformBufferBindings[s]=this.shader.uniformBindCount,i.uniformBlockBinding(e.program,r,this.shader.uniformBindCount),this.shader.uniformBindCount++;const n=this.getSignature(t,this.shader.program.uniformData,"ubo");let a=this._uboCache[n];if(a||(a=this._uboCache[n]=Dr(t,this.shader.program.uniformData)),t.autoManage){const e=new Float32Array(a.size/4);t.buffer.update(e)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,s){const i=t.uniforms,r=[`${s}-`];for(const t in i)r.push(t),e[t]&&r.push(e[t].type);return r.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,s=t.program,i=Rr(e,s);return s.glPrograms[this.renderer.CONTEXT_UID]=i,i}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}Fr.extension={type:rs.RendererSystem,name:"shader"},os.add(Fr);class Br{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.2.4 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}Br.defaultOptions={hello:!1},Br.extension={type:[rs.RendererSystem,rs.CanvasRendererSystem],name:"startup"},os.add(Br);const Nr=class{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=a.NONE,this._blendEq=!1,this.map=[],this.map[0]=this.setBlend,this.map[1]=this.setOffset,this.map[2]=this.setCullFace,this.map[3]=this.setDepthTest,this.map[4]=this.setFrontFace,this.map[5]=this.setDepthMask,this.checks=[],this.defaultState=new cs,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=function(t,e=[]){return e[a.NORMAL]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.ADD]=[t.ONE,t.ONE],e[a.MULTIPLY]=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.SCREEN]=[t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.OVERLAY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.DARKEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.LIGHTEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.COLOR_DODGE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.COLOR_BURN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.HARD_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.SOFT_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.DIFFERENCE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.EXCLUSION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.HUE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.SATURATION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.COLOR]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.LUMINOSITY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.NONE]=[0,0],e[a.NORMAL_NPM]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.ADD_NPM]=[t.SRC_ALPHA,t.ONE,t.ONE,t.ONE],e[a.SCREEN_NPM]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e[a.SRC_IN]=[t.DST_ALPHA,t.ZERO],e[a.SRC_OUT]=[t.ONE_MINUS_DST_ALPHA,t.ZERO],e[a.SRC_ATOP]=[t.DST_ALPHA,t.ONE_MINUS_SRC_ALPHA],e[a.DST_OVER]=[t.ONE_MINUS_DST_ALPHA,t.ONE],e[a.DST_IN]=[t.ZERO,t.SRC_ALPHA],e[a.DST_OUT]=[t.ZERO,t.ONE_MINUS_SRC_ALPHA],e[a.DST_ATOP]=[t.ONE_MINUS_DST_ALPHA,t.SRC_ALPHA],e[a.XOR]=[t.ONE_MINUS_DST_ALPHA,t.ONE_MINUS_SRC_ALPHA],e[a.SUBTRACT]=[t.ONE,t.ONE,t.ONE,t.ONE,t.FUNC_REVERSE_SUBTRACT,t.FUNC_ADD],e}(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,s=0;for(;e;)1&e&&this.map[s].call(this,!!(t.data&1<<s)),e>>=1,s++;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(Nr.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Nr.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],s=this.gl;2===e.length?s.blendFunc(e[0],e[1]):s.blendFuncSeparate(e[0],e[1],e[2],e[3]),6===e.length?(this._blendEq=!0,s.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,s.blendEquationSeparate(s.FUNC_ADD,s.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 s=this.checks.indexOf(t);e&&-1===s?this.checks.push(t):!e&&-1!==s&&this.checks.splice(s,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};let Lr=Nr;Lr.extension={type:rs.RendererSystem,name:"state"},os.add(Lr);class Gr extends W{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){var e;this.addRunners(...t.runners);const s=(null!=(e=t.priority)?e:[]).filter((e=>t.systems[e])),i=[...s,...Object.keys(t.systems).filter((t=>!s.includes(t)))];for(const e of i)this.addSystem(t.systems[e],e)}addRunners(...t){t.forEach((t=>{this.runners[t]=new ms(t)}))}addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const t in this.runners)this.runners[t].add(s);return this}emitWithCustomOptions(t,e){const s=Object.keys(this._systemsHash);t.items.forEach((i=>{const r=s.find((t=>this._systemsHash[t]===i));i[t.name](e[r])}))}destroy(){Object.values(this.runners).forEach((t=>{t.destroy()})),this._systemsHash={}}}const Ur=class{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Ur.defaultMaxIdle,this.checkCountMax=Ur.defaultCheckCountMax,this.mode=Ur.defaultMode}postrender(){!this.renderer.objectRenderer.renderingToScreen||(this.count++,this.mode!==g.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let s=!1;for(let i=0;i<e.length;i++){const r=e[i];!r.framebuffer&&this.count-r.touched>this.maxIdle&&(t.destroyTexture(r,!0),e[i]=null,s=!0)}if(s){let t=0;for(let s=0;s<e.length;s++)null!==e[s]&&(e[t++]=e[s]);e.length=t}}unload(t){const e=this.renderer.texture,s=t._texture;s&&!s.framebuffer&&e.destroyTexture(s);for(let e=t.children.length-1;e>=0;e--)this.unload(t.children[e])}destroy(){this.renderer=null}};let kr=Ur;kr.defaultMode=g.AUTO,kr.defaultMaxIdle=3600,kr.defaultCheckCountMax=600,kr.extension={type:rs.RendererSystem,name:"textureGC"},os.add(kr);class Xr{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=u.UNSIGNED_BYTE,this.internalFormat=h.RGBA,this.samplerType=0}}class Hr{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new ys,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=function(t){let e;return e="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext?{[u.UNSIGNED_BYTE]:{[h.RGBA]:t.RGBA8,[h.RGB]:t.RGB8,[h.RG]:t.RG8,[h.RED]:t.R8,[h.RGBA_INTEGER]:t.RGBA8UI,[h.RGB_INTEGER]:t.RGB8UI,[h.RG_INTEGER]:t.RG8UI,[h.RED_INTEGER]:t.R8UI,[h.ALPHA]:t.ALPHA,[h.LUMINANCE]:t.LUMINANCE,[h.LUMINANCE_ALPHA]:t.LUMINANCE_ALPHA},[u.BYTE]:{[h.RGBA]:t.RGBA8_SNORM,[h.RGB]:t.RGB8_SNORM,[h.RG]:t.RG8_SNORM,[h.RED]:t.R8_SNORM,[h.RGBA_INTEGER]:t.RGBA8I,[h.RGB_INTEGER]:t.RGB8I,[h.RG_INTEGER]:t.RG8I,[h.RED_INTEGER]:t.R8I},[u.UNSIGNED_SHORT]:{[h.RGBA_INTEGER]:t.RGBA16UI,[h.RGB_INTEGER]:t.RGB16UI,[h.RG_INTEGER]:t.RG16UI,[h.RED_INTEGER]:t.R16UI,[h.DEPTH_COMPONENT]:t.DEPTH_COMPONENT16},[u.SHORT]:{[h.RGBA_INTEGER]:t.RGBA16I,[h.RGB_INTEGER]:t.RGB16I,[h.RG_INTEGER]:t.RG16I,[h.RED_INTEGER]:t.R16I},[u.UNSIGNED_INT]:{[h.RGBA_INTEGER]:t.RGBA32UI,[h.RGB_INTEGER]:t.RGB32UI,[h.RG_INTEGER]:t.RG32UI,[h.RED_INTEGER]:t.R32UI,[h.DEPTH_COMPONENT]:t.DEPTH_COMPONENT24},[u.INT]:{[h.RGBA_INTEGER]:t.RGBA32I,[h.RGB_INTEGER]:t.RGB32I,[h.RG_INTEGER]:t.RG32I,[h.RED_INTEGER]:t.R32I},[u.FLOAT]:{[h.RGBA]:t.RGBA32F,[h.RGB]:t.RGB32F,[h.RG]:t.RG32F,[h.RED]:t.R32F,[h.DEPTH_COMPONENT]:t.DEPTH_COMPONENT32F},[u.HALF_FLOAT]:{[h.RGBA]:t.RGBA16F,[h.RGB]:t.RGB16F,[h.RG]:t.RG16F,[h.RED]:t.R16F},[u.UNSIGNED_SHORT_5_6_5]:{[h.RGB]:t.RGB565},[u.UNSIGNED_SHORT_4_4_4_4]:{[h.RGBA]:t.RGBA4},[u.UNSIGNED_SHORT_5_5_5_1]:{[h.RGBA]:t.RGB5_A1},[u.UNSIGNED_INT_2_10_10_10_REV]:{[h.RGBA]:t.RGB10_A2,[h.RGBA_INTEGER]:t.RGB10_A2UI},[u.UNSIGNED_INT_10F_11F_11F_REV]:{[h.RGB]:t.R11F_G11F_B10F},[u.UNSIGNED_INT_5_9_9_9_REV]:{[h.RGB]:t.RGB9_E5},[u.UNSIGNED_INT_24_8]:{[h.DEPTH_STENCIL]:t.DEPTH24_STENCIL8},[u.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[h.DEPTH_STENCIL]:t.DEPTH32F_STENCIL8}}:{[u.UNSIGNED_BYTE]:{[h.RGBA]:t.RGBA,[h.RGB]:t.RGB,[h.ALPHA]:t.ALPHA,[h.LUMINANCE]:t.LUMINANCE,[h.LUMINANCE_ALPHA]:t.LUMINANCE_ALPHA},[u.UNSIGNED_SHORT_5_6_5]:{[h.RGB]:t.RGB},[u.UNSIGNED_SHORT_4_4_4_4]:{[h.RGBA]:t.RGBA},[u.UNSIGNED_SHORT_5_5_5_1]:{[h.RGBA]:t.RGBA}},e}(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let t=0;t<e;t++)this.boundTextures[t]=null;this.emptyTextures={};const s=new Xr(t.createTexture());t.bindTexture(t.TEXTURE_2D,s.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]=s,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new Xr(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let e=0;e<6;e++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,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 t=0;t<this.boundTextures.length;t++)this.bind(null,t)}bind(t,e=0){const{gl:s}=this;if((null==(t=null==t?void 0:t.castToBaseTexture())?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const i=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,s.activeTexture(s.TEXTURE0+e)),s.bindTexture(t.target,i.texture)),i.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,s.activeTexture(s.TEXTURE0+e)),this.updateTexture(t)):i.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,s.activeTexture(s.TEXTURE0+e)),s.bindTexture(s.TEXTURE_2D,this.emptyTextures[s.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:s}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let t=0;t<s.length;t++)s[t]===this.unknownTexture&&this.bind(null,t)}for(let i=0;i<s.length;i++)s[i]===t&&(this.currentLocation!==i&&(e.activeTexture(e.TEXTURE0+i),this.currentLocation=i),e.bindTexture(t.target,this.emptyTextures[t.target].texture),s[i]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:s,CONTEXT_UID:i}=this;if(s)for(let s=t-1;s>=0;--s){const t=e[s];t&&t._glTextures[i].samplerType!==d.FLOAT&&this.renderer.texture.unbind(t)}}initTexture(t){const e=new Xr(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 s,i;e.internalFormat=null!=(i=null==(s=this.internalFormats[t.type])?void 0:s[t.format])?i:t.format,2===this.webGLVersion&&t.type===u.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var e;const s=t._glTextures[this.CONTEXT_UID];if(!s)return;const i=this.renderer;if(this.initTextureType(t,s),null!=(e=t.resource)&&e.upload(i,t,s))s.samplerType!==d.FLOAT&&(this.hasIntegerTextures=!0);else{const e=t.realWidth,r=t.realHeight,n=i.gl;(s.width!==e||s.height!==r||s.dirtyId<0)&&(s.width=e,s.height=r,n.texImage2D(t.target,0,s.internalFormat,e,r,0,t.format,s.type,null))}t.dirtyStyleId!==s.dirtyStyleId&&this.updateTextureStyle(t),s.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:s}=this;if((t=t.castToBaseTexture())._glTextures[this.CONTEXT_UID]&&(this.unbind(t),s.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const e=this.managedTextures.indexOf(t);-1!==e&&ke(this.managedTextures,e,1)}}updateTextureStyle(t){var e;const s=t._glTextures[this.CONTEXT_UID];!s||(t.mipmap!==f.POW2&&2===this.webGLVersion||t.isPowerOfTwo?s.mipmap=t.mipmap>=1:s.mipmap=!1,2===this.webGLVersion||t.isPowerOfTwo?s.wrapMode=t.wrapMode:s.wrapMode=p.CLAMP,null!=(e=t.resource)&&e.style(this.renderer,t,s)||this.setStyle(t,s),s.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const s=this.gl;if(e.mipmap&&t.mipmap!==f.ON_MANUAL&&s.generateMipmap(t.target),s.texParameteri(t.target,s.TEXTURE_WRAP_S,e.wrapMode),s.texParameteri(t.target,s.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){s.texParameteri(t.target,s.TEXTURE_MIN_FILTER,t.scaleMode===c.LINEAR?s.LINEAR_MIPMAP_LINEAR:s.NEAREST_MIPMAP_NEAREST);const e=this.renderer.context.extensions.anisotropicFiltering;if(e&&t.anisotropicLevel>0&&t.scaleMode===c.LINEAR){const i=Math.min(t.anisotropicLevel,s.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY_EXT));s.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY_EXT,i)}}else s.texParameteri(t.target,s.TEXTURE_MIN_FILTER,t.scaleMode===c.LINEAR?s.LINEAR:s.NEAREST);s.texParameteri(t.target,s.TEXTURE_MAG_FILTER,t.scaleMode===c.LINEAR?s.LINEAR:s.NEAREST)}destroy(){this.renderer=null}}Hr.extension={type:rs.RendererSystem,name:"texture"},os.add(Hr);class Vr{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:s}=this,i=t._glTransformFeedbacks[s]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,i)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:s,renderer:i}=this;e&&i.shader.bind(e),s.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:s,CONTEXT_UID:i}=this,r=e.createTransformFeedback();t._glTransformFeedbacks[i]=r,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,r);for(let r=0;r<t.buffers.length;r++){const n=t.buffers[r];!n||(s.buffer.update(n),n._glBuffers[i].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,r,n._glBuffers[i].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),r}disposeTransformFeedback(t,e){const s=t._glTransformFeedbacks[this.CONTEXT_UID],i=this.gl;t.disposeRunner.remove(this);const r=this.renderer.buffer;if(r)for(let s=0;s<t.buffers.length;s++){const i=t.buffers[s];if(!i)continue;const n=i._glBuffers[this.CONTEXT_UID];n&&(n.refCount--,0===n.refCount&&!e&&r.dispose(i,e))}!s||(e||i.deleteTransformFeedback(s),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Vr.extension={type:rs.RendererSystem,name:"transformFeedback"},os.add(Vr);class zr{constructor(t){this.renderer=t}init(t){this.screen=new Ls(0,0,t.width,t.height),this.element=t.view||A.ADAPTER.createCanvas(),this.resolution=t.resolution||A.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 s=this.element.width/this.resolution,i=this.element.height/this.resolution;this.screen.width=s,this.screen.height=i,this.autoDensity&&(this.element.style.width=`${s}px`,this.element.style.height=`${i}px`),this.renderer.emit("resize",s,i),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&(null==(e=this.element.parentNode)||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}zr.defaultOptions={width:800,height:600,resolution:A.RESOLUTION,autoDensity:!1},zr.extension={type:[rs.RendererSystem,rs.CanvasRendererSystem],name:"_view"},os.add(zr),A.PREFER_ENV=i.WEBGL2,A.STRICT_TEXTURE_CACHE=!1,A.RENDER_OPTIONS=bt(bt(bt(bt({},Ni.defaultOptions),Oi.defaultOptions),zr.defaultOptions),Br.defaultOptions),Object.defineProperties(A,{WRAP_MODE:{get:()=>ys.defaultOptions.wrapMode,set(t){Kt("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),ys.defaultOptions.wrapMode=t}},SCALE_MODE:{get:()=>ys.defaultOptions.scaleMode,set(t){Kt("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),ys.defaultOptions.scaleMode=t}},MIPMAP_TEXTURES:{get:()=>ys.defaultOptions.mipmap,set(t){Kt("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),ys.defaultOptions.mipmap=t}},ANISOTROPIC_LEVEL:{get:()=>ys.defaultOptions.anisotropicLevel,set(t){Kt("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),ys.defaultOptions.anisotropicLevel=t}},FILTER_RESOLUTION:{get:()=>(Kt("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Pi.defaultResolution),set(t){Pi.defaultResolution=t}},FILTER_MULTISAMPLE:{get:()=>(Kt("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Pi.defaultMultisample),set(t){Pi.defaultMultisample=t}},SPRITE_MAX_TEXTURES:{get:()=>Ci.defaultMaxTextures,set(t){Kt("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Ci.defaultMaxTextures=t}},SPRITE_BATCH_SIZE:{get:()=>Ci.defaultBatchSize,set(t){Kt("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Ci.defaultBatchSize=t}},CAN_UPLOAD_SAME_BUFFER:{get:()=>Ci.canUploadSameBuffer,set(t){Kt("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Ci.canUploadSameBuffer=t}},GC_MODE:{get:()=>kr.defaultMode,set(t){Kt("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),kr.defaultMode=t}},GC_MAX_IDLE:{get:()=>kr.defaultMaxIdle,set(t){Kt("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),kr.defaultMaxIdle=t}},GC_MAX_CHECK_COUNT:{get:()=>kr.defaultCheckCountMax,set(t){Kt("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),kr.defaultCheckCountMax=t}},PRECISION_VERTEX:{get:()=>bi.defaultVertexPrecision,set(t){Kt("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),bi.defaultVertexPrecision=t}},PRECISION_FRAGMENT:{get:()=>bi.defaultFragmentPrecision,set(t){Kt("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),bi.defaultFragmentPrecision=t}}});var Wr=(t=>(t[t.INTERACTION=50]="INTERACTION",t[t.HIGH=25]="HIGH",t[t.NORMAL=0]="NORMAL",t[t.LOW=-25]="LOW",t[t.UTILITY=-50]="UTILITY",t))(Wr||{});class Yr{constructor(t,e=null,s=0,i=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=s,this.once=i}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 jr=class{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 Yr(null,null,1/0),this.deltaMS=1/jr.targetFPMS,this.elapsedMS=1/jr.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&null===this._requestId&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){null===this._requestId&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){null!==this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,s=Wr.NORMAL){return this._addListener(new Yr(t,e,s))}addOnce(t,e,s=Wr.NORMAL){return this._addListener(new Yr(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(e){for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}else t.connect(s);return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s=s.match(t,e)?s.destroy():s.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 e=t-this._lastFrame|0;if(e<this._minElapsedMS)return;this._lastFrame=t-e%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*jr.targetFPMS;const s=this._head;let i=s.next;for(;i;)i=i.emit(this.deltaTime);s.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),s=Math.min(Math.max(0,e)/1e3,jr.targetFPMS);this._maxElapsedMS=1/s}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(0===t)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!jr._shared){const t=jr._shared=new jr;t.autoStart=!0,t._protected=!0}return jr._shared}static get system(){if(!jr._system){const t=jr._system=new jr;t.autoStart=!0,t._protected=!0}return jr._system}};let $r=jr;$r.targetFPMS=.06,Object.defineProperties(A,{TARGET_FPMS:{get:()=>$r.targetFPMS,set(t){Kt("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),$r.targetFPMS=t}}});class qr{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,Wr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?$r.shared:new $r,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}qr.extension=rs.Application,os.add(qr);const Kr=[];function Zr(t){for(const e of Kr)if(e.test(t))return new e(t);throw new Error("Unable to auto-detect a suitable renderer.")}os.handleByList(rs.Renderer,Kr);const Qr="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",Jr="attribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n";class tn{constructor(t){this.renderer=t}contextChange(t){let e;if(1===this.renderer.context.webGLVersion){const s=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,s)}else{const s=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,s)}e>=T.HIGH?this.multisample=T.HIGH:e>=T.MEDIUM?this.multisample=T.MEDIUM:e>=T.LOW?this.multisample=T.LOW:this.multisample=T.NONE}destroy(){}}tn.extension={type:rs.RendererSystem,name:"_multisample"},os.add(tn);class en{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class sn{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:s}=this,i=t._glBuffers[s]||this.createGLBuffer(t);e.bindBuffer(t.type,i.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:s,CONTEXT_UID:i}=this;if(this.boundBufferBases[e]!==t){const r=t._glBuffers[i]||this.createGLBuffer(t);this.boundBufferBases[e]=t,s.bindBufferBase(s.UNIFORM_BUFFER,e,r.buffer)}}bindBufferRange(t,e,s){const{gl:i,CONTEXT_UID:r}=this;s=s||0;const n=t._glBuffers[r]||this.createGLBuffer(t);i.bindBufferRange(i.UNIFORM_BUFFER,e||0,n.buffer,256*s,256)}update(t){const{gl:e,CONTEXT_UID:s}=this,i=t._glBuffers[s]||this.createGLBuffer(t);if(t._updateID!==i.updateID)if(i.updateID=t._updateID,e.bindBuffer(t.type,i.buffer),i.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const s=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;i.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,s)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const s=t._glBuffers[this.CONTEXT_UID],i=this.gl;t.disposeRunner.remove(this),s&&(e||i.deleteBuffer(s.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let s=0;s<e.length;s++)this.dispose(this.managedBuffers[e[s]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:s}=this;return t._glBuffers[e]=new en(s.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}sn.extension={type:rs.RendererSystem,name:"buffer"},os.add(sn);class rn{constructor(t){this.renderer=t}render(t,e){const s=this.renderer;let i,r,n,a;if(e&&(i=e.renderTexture,r=e.clear,n=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!i,s.runners.prerender.emit(),s.emit("prerender"),s.projection.transform=n,!s.context.isLost){if(i||(this.lastObjectRendered=t),!a){const e=t.enableTempParent();t.updateTransform(),t.disableTempParent(e)}s.renderTexture.bind(i),s.batch.currentRenderer.start(),(null!=r?r:s.background.clearBeforeRender)&&s.renderTexture.clear(),t.render(s),s.batch.currentRenderer.flush(),i&&(e.blit&&s.framebuffer.blit(),i.baseTexture.update()),s.runners.postrender.emit(),s.projection.transform=null,s.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}rn.extension={type:rs.RendererSystem,name:"objectRenderer"},os.add(rn);const nn=class extends Gr{constructor(t){super(),this.type=r.WEBGL,t=Object.assign({},A.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new Ai({projectionMatrix:new Hs},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:nn.__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&&(Kt("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&"notMultiplied"!==t.useContextAlpha,t.backgroundAlpha=!1===t.useContextAlpha?1:t.backgroundAlpha),this._plugin.rendererPlugins=nn.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return(null==t||!t.forceCanvas)&&Qt()}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 Kt("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return Kt("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return Kt("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return Kt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){Kt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return Kt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){Kt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return Kt("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)}};let an=nn;an.extension={type:rs.Renderer,priority:1},an.__plugins={},an.__systems={},os.handleByMap(rs.RendererPlugin,an.__plugins),os.handleByMap(rs.RendererSystem,an.__systems),os.add(an);class on extends _s{constructor(t,e){const{width:s,height:i}=e||{};super(s,i),this.items=[],this.itemDirtyIds=[];for(let e=0;e<t;e++){const t=new ys;this.items.push(t),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let s=0;s<this.length;s++)!t[s]||(t[s].castToBaseTexture?this.addBaseTextureAt(t[s].castToBaseTexture(),s):t[s]instanceof _s?this.addResourceAt(t[s],s):this.addResourceAt(fs(t[s],e),s))}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(null!==this.baseTexture)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((t=>t.resource)).filter((t=>t)).map((t=>t.load()));return this._load=Promise.all(t).then((()=>{const{realWidth:t,realHeight:e}=this.items[0];return this.resize(t,e),Promise.resolve(this)})),this._load}}class hn extends on{constructor(t,e){const{width:s,height:i}=e||{};let r,n;Array.isArray(t)?(r=t,n=t.length):n=t,super(n,{width:s,height:i}),r&&this.initFromArray(r,e)}addBaseTextureAt(t,e){if(!t.resource)throw new Error("ArrayResource does not support RenderTexture");return this.addResourceAt(t.resource,e),this}bind(t){super.bind(t),t.target=l.TEXTURE_2D_ARRAY}upload(t,e,s){const{length:i,itemDirtyIds:r,items:n}=this,{gl:a}=t;s.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,s.internalFormat,this._width,this._height,i,0,e.format,s.type,null);for(let t=0;t<i;t++){const i=n[t];r[t]<i.dirtyId&&(r[t]=i.dirtyId,i.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,t,i.resource.width,i.resource.height,1,e.format,s.type,i.resource.source))}return!0}}class ln extends ki{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return!!(e&&t instanceof e)||globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const un=class extends on{constructor(t,e){const{width:s,height:i,autoLoad:r,linkBaseTexture:n}=e||{};if(t&&t.length!==un.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:s,height:i});for(let t=0;t<un.SIDES;t++)this.items[t].target=l.TEXTURE_CUBE_MAP_POSITIVE_X+t;this.linkBaseTexture=!1!==n,t&&this.initFromArray(t,e),!1!==r&&this.load()}bind(t){super.bind(t),t.target=l.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,s){if(void 0===s&&(s=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)throw new Error("CubeResource does not support copying of renderTexture.");this.addResourceAt(t.resource,e)}else t.target=l.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,s){const i=this.itemDirtyIds;for(let r=0;r<un.SIDES;r++){const n=this.items[r];(i[r]<n.dirtyId||s.dirtyId<e.dirtyId)&&(n.valid&&n.resource?(n.resource.upload(t,n,s),i[r]=n.dirtyId):i[r]<-1&&(t.gl.texImage2D(n.target,0,s.internalFormat,e.realWidth,e.realHeight,0,e.format,s.type,null),i[r]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===un.SIDES}};let dn=un;dn.SIDES=6;class cn extends ki{constructor(t,e){var s;let i,r;e=e||{},"string"==typeof t?(i=cn.EMPTY,r=t):(i=t,r=null),super(i),this.url=r,this.crossOrigin=null==(s=e.crossOrigin)||s,this.alphaMode="number"==typeof e.alphaMode?e.alphaMode:null,this._load=null,!1!==e.autoLoad&&this.load()}load(){return this._load||(this._load=new Promise((async(t,e)=>{if(null!==this.url)try{const e=await A.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await e.blob();if(this.destroyed)return;const i=await createImageBitmap(s,{premultiplyAlpha:null===this.alphaMode||this.alphaMode===m.UNPACK?"premultiply":"none"});if(this.destroyed)return;this.source=i,this.update(),t(this)}catch(t){if(this.destroyed)return;e(t),this.onError.emit(t)}else t(this)}))),this._load}upload(t,e,s){return this.source instanceof ImageBitmap?("number"==typeof this.alphaMode&&(e.alphaMode=this.alphaMode),super.upload(t,e,s)):(this.load(),!1)}dispose(){this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&"undefined"!=typeof ImageBitmap&&("string"==typeof t||t instanceof ImageBitmap)}static get EMPTY(){var t;return cn._EMPTY=null!=(t=cn._EMPTY)?t:A.ADAPTER.createCanvas(0,0),cn._EMPTY}}const pn=class extends ki{constructor(t,e){e=e||{},super(A.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,!1!==e.autoLoad&&this.load()}load(){return this._load||(this._load=new Promise((t=>{if(this._resolve=()=>{this.resize(this.source.width,this.source.height),t(this)},pn.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;ki.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,s=t.height;if(!e||!s)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let i=e*this.scale,r=s*this.scale;(this._overrideWidth||this._overrideHeight)&&(i=this._overrideWidth||this._overrideHeight/s*e,r=this._overrideHeight||this._overrideWidth/e*s),i=Math.round(i),r=Math.round(r);const n=this.source;n.width=i,n.height=r,n._pixiId=`canvas_${Ve()}`,n.getContext("2d").drawImage(t,0,0,e,s,0,0,i,r),this._resolve(),this._resolve=null}}static getSize(t){const e=pn.SVG_SIZE.exec(t),s={};return e&&(s[e[1]]=Math.round(parseFloat(e[3])),s[e[5]]=Math.round(parseFloat(e[7]))),s}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return"svg"===e||"string"==typeof t&&t.startsWith("data:image/svg+xml")||"string"==typeof t&&pn.SVG_XML.test(t)}};let fn=pn;fn.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,fn.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;const mn=class extends ki{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const s=document.createElement("video");s.setAttribute("preload","auto"),s.setAttribute("webkit-playsinline",""),s.setAttribute("playsinline",""),"string"==typeof t&&(t=[t]);const i=t[0].src||t[0];ki.crossOrigin(s,i,e.crossorigin);for(let e=0;e<t.length;++e){const i=document.createElement("source");let{src:r,mime:n}=t[e];r=r||t[e];const a=r.split("?").shift().toLowerCase(),o=a.slice(a.lastIndexOf(".")+1);n=n||mn.MIME_TYPES[o]||`video/${o}`,i.src=r,i.type=n,s.appendChild(i)}t=s}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=!1!==e.autoPlay,this._load=null,this._resolve=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),!1!==e.autoLoad&&this.load()}update(t=0){if(!this.destroyed){const t=$r.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t),(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}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.bind(this)),t.addEventListener("pause",this._onPlayStop.bind(this)),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=>{this.valid?e(this):(this._resolve=e,t.load())})),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended&&this._isSourceReady()}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this.autoUpdate&&!this._isConnectedToTicker&&($r.shared.add(this.update,this),this._isConnectedToTicker=!0)}_onPlayStop(){this._isConnectedToTicker&&($r.shared.remove(this.update,this),this._isConnectedToTicker=!1)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this.resize(t.videoWidth,t.videoHeight),!e&&this._resolve&&(this._resolve(this),this._resolve=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._isConnectedToTicker&&($r.shared.remove(this.update,this),this._isConnectedToTicker=!1);const t=this.source;t&&(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._autoUpdate&&this._isConnectedToTicker?($r.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._isSourcePlaying()&&($r.shared.add(this.update,this),this._isConnectedToTicker=!0))}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t)}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||mn.TYPES.includes(e)}};let _n=mn;_n.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],_n.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"},ps.push(cn,Xi,ln,_n,fn,gs,dn,hn);class gn{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?Ls.EMPTY:((t=t||new Ls(0,0,1,1)).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:s,b:i,c:r,d:n,tx:a,ty:o}=t,h=s*e.x+r*e.y+a,l=i*e.x+n*e.y+o;this.minX=Math.min(this.minX,h),this.maxX=Math.max(this.maxX,h),this.minY=Math.min(this.minY,l),this.maxY=Math.max(this.maxY,l)}addQuad(t){let e=this.minX,s=this.minY,i=this.maxX,r=this.maxY,n=t[0],a=t[1];e=n<e?n:e,s=a<s?a:s,i=n>i?n:i,r=a>r?a:r,n=t[2],a=t[3],e=n<e?n:e,s=a<s?a:s,i=n>i?n:i,r=a>r?a:r,n=t[4],a=t[5],e=n<e?n:e,s=a<s?a:s,i=n>i?n:i,r=a>r?a:r,n=t[6],a=t[7],e=n<e?n:e,s=a<s?a:s,i=n>i?n:i,r=a>r?a:r,this.minX=e,this.minY=s,this.maxX=i,this.maxY=r}addFrame(t,e,s,i,r){this.addFrameMatrix(t.worldTransform,e,s,i,r)}addFrameMatrix(t,e,s,i,r){const n=t.a,a=t.b,o=t.c,h=t.d,l=t.tx,u=t.ty;let d=this.minX,c=this.minY,p=this.maxX,f=this.maxY,m=n*e+o*s+l,_=a*e+h*s+u;d=m<d?m:d,c=_<c?_:c,p=m>p?m:p,f=_>f?_:f,m=n*i+o*s+l,_=a*i+h*s+u,d=m<d?m:d,c=_<c?_:c,p=m>p?m:p,f=_>f?_:f,m=n*e+o*r+l,_=a*e+h*r+u,d=m<d?m:d,c=_<c?_:c,p=m>p?m:p,f=_>f?_:f,m=n*i+o*r+l,_=a*i+h*r+u,d=m<d?m:d,c=_<c?_:c,p=m>p?m:p,f=_>f?_:f,this.minX=d,this.minY=c,this.maxX=p,this.maxY=f}addVertexData(t,e,s){let i=this.minX,r=this.minY,n=this.maxX,a=this.maxY;for(let o=e;o<s;o+=2){const e=t[o],s=t[o+1];i=e<i?e:i,r=s<r?s:r,n=e>n?e:n,a=s>a?s:a}this.minX=i,this.minY=r,this.maxX=n,this.maxY=a}addVertices(t,e,s,i){this.addVerticesMatrix(t.worldTransform,e,s,i)}addVerticesMatrix(t,e,s,i,r=0,n=r){const a=t.a,o=t.b,h=t.c,l=t.d,u=t.tx,d=t.ty;let c=this.minX,p=this.minY,f=this.maxX,m=this.maxY;for(let t=s;t<i;t+=2){const s=e[t],i=e[t+1],_=a*s+h*i+u,g=l*i+o*s+d;c=Math.min(c,_-r),f=Math.max(f,_+r),p=Math.min(p,g-n),m=Math.max(m,g+n)}this.minX=c,this.minY=p,this.maxX=f,this.maxY=m}addBounds(t){const e=this.minX,s=this.minY,i=this.maxX,r=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<s?t.minY:s,this.maxX=t.maxX>i?t.maxX:i,this.maxY=t.maxY>r?t.maxY:r}addBoundsMask(t,e){const s=t.minX>e.minX?t.minX:e.minX,i=t.minY>e.minY?t.minY:e.minY,r=t.maxX<e.maxX?t.maxX:e.maxX,n=t.maxY<e.maxY?t.maxY:e.maxY;if(s<=r&&i<=n){const t=this.minX,e=this.minY,a=this.maxX,o=this.maxY;this.minX=s<t?s:t,this.minY=i<e?i:e,this.maxX=r>a?r:a,this.maxY=n>o?n:o}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const s=t.minX>e.x?t.minX:e.x,i=t.minY>e.y?t.minY:e.y,r=t.maxX<e.x+e.width?t.maxX:e.x+e.width,n=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(s<=r&&i<=n){const t=this.minX,e=this.minY,a=this.maxX,o=this.maxY;this.minX=s<t?s:t,this.minY=i<e?i:e,this.maxX=r>a?r:a,this.maxY=n>o?n:o}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,s,i,r,n){t-=r,e-=n,s+=r,i+=n,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>s?this.maxX:s,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>i?this.maxY:i}}class xn extends W{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Js,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 gn,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 s=0;s<e.length;++s){const i=e[s];Object.defineProperty(xn.prototype,i,Object.getOwnPropertyDescriptor(t,i))}}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 Ls),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new Ls),t=this._localBoundsRect),this._localBounds||(this._localBounds=new gn);const e=this.transform,s=this.parent;this.parent=null,this.transform=this._tempDisplayObjectParent.transform;const i=this._bounds,r=this._boundsID;this._bounds=this._localBounds;const n=this.getBounds(!1,t);return this.parent=s,this.transform=e,this._bounds=i,this._bounds.updateID+=this._boundsID-r,n}toGlobal(t,e,s=!1){return s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,s,i){return e&&(t=e.toGlobal(t,s,i)),i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,s)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;null==(t=this.parent)||t.removeChild(this)}setTransform(t=0,e=0,s=1,i=1,r=0,n=0,a=0,o=0,h=0){return this.position.x=t,this.position.y=e,this.scale.x=s||1,this.scale.y=i||1,this.rotation=r,this.skew.x=n,this.skew.y=a,this.pivot.x=o,this.pivot.y=h,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 null===this.tempDisplayObjectParent&&(this.tempDisplayObjectParent=new vn),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*Ps}set angle(t){this.transform.rotation=t*Os}get zIndex(){return this._zIndex}set 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 t=this._mask.isMaskData?this._mask.maskObject:this._mask;t&&(t._maskRefCount--,0===t._maskRefCount&&(t.renderable=!0,t.isMask=!1))}if(this._mask=t,this._mask){const t=this._mask.isMaskData?this._mask.maskObject:this._mask;t&&(0===t._maskRefCount&&(t.renderable=!1,t.isMask=!0),t._maskRefCount++)}}}}class vn extends xn{constructor(){super(...arguments),this.sortDirty=null}}xn.prototype.displayObjectUpdateTransform=xn.prototype.updateTransform;const yn=new Hs;function Tn(t,e){return t.zIndex===e.zIndex?t._lastSortedIndex-e._lastSortedIndex:t.zIndex-e.zIndex}const bn=class extends xn{constructor(){super(),this.children=[],this.sortableChildren=bn.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 s=this.getChildIndex(t),i=this.getChildIndex(e);this.children[s]=e,this.children[i]=t,this.onChildrenChange(s<i?s:i)}getChildIndex(t){const e=this.children.indexOf(t);if(-1===e)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 s=this.getChildIndex(t);ke(this.children,s,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],s=this.children.indexOf(e);if(-1===s)return null;e.parent=null,e.transform._parentID=-1,ke(this.children,s,1),this._boundsID++,this.onChildrenChange(s),e.emit("removed",this),this.emit("childRemoved",e,this,s)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,ke(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 s=t,i=e-s;let r;if(i>0&&i<=e){r=this.children.splice(s,i);for(let t=0;t<r.length;++t)r[t].parent=null,r[t].transform&&(r[t].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let t=0;t<r.length;++t)r[t].emit("removed",this),this.emit("childRemoved",r[t],this,t);return r}if(0===i&&0===this.children.length)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,s=this.children.length;e<s;++e){const s=this.children[e];s._lastSortedIndex=e,!t&&0!==s.zIndex&&(t=!0)}t&&this.children.length>1&&this.children.sort(Tn),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 e=this.children[t];e.visible&&e.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 t=e._mask.isMaskData?e._mask.maskObject:e._mask;t?(t.calculateBounds(),this._bounds.addBoundsMask(e._bounds,t._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 s=super.getLocalBounds(t);if(!e)for(let t=0,e=this.children.length;t<e;++t){const e=this.children[t];e.visible&&e.updateTransform()}return s}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let s,i;this.cullArea?(s=this.cullArea,i=this.worldTransform):this._render!==bn.prototype._render&&(s=this.getBounds(!0));const r=t.projection.transform;if(r&&(i?(i=yn.copyFrom(i),i.prepend(r)):i=r),s&&e.intersects(s,i))this._render(t);else if(this.cullArea)return;for(let e=0,s=this.children.length;e<s;++e){const s=this.children[e],i=s.cullable;s.cullable=i||!this.cullArea,s.render(t),s.cullable=i}}render(t){var e;if(this.visible&&!(this.worldAlpha<=0)&&this.renderable)if(this._mask||(null==(e=this.filters)?void 0:e.length))this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let e=0,s=this.children.length;e<s;++e)this.children[e].render(t)}}renderAdvanced(t){var e,s,i;const r=this.filters,n=this._mask;if(r){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let t=0;t<r.length;t++)r[t].enabled&&this._enabledFilters.push(r[t])}const a=r&&(null==(e=this._enabledFilters)?void 0:e.length)||n&&(!n.isMaskData||n.enabled&&(n.autoDetect||n.type!==v.NONE));if(a&&t.batch.flush(),r&&(null==(s=this._enabledFilters)?void 0:s.length)&&t.filter.push(this,this._enabledFilters),n&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let e=0,s=this.children.length;e<s;++e)this.children[e].render(t)}a&&t.batch.flush(),n&&t.mask.pop(this),r&&(null==(i=this._enabledFilters)?void 0:i.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e="boolean"==typeof t?t:null==t?void 0:t.children,s=this.removeChildren(0,this.children.length);if(e)for(let e=0;e<s.length;++e)s[e].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;this.scale.x=0!==e?t/e:1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;this.scale.y=0!==e?t/e:1,this._height=t}};let En=bn;En.defaultSortableChildren=!1,En.prototype.containerUpdateTransform=En.prototype.updateTransform,Object.defineProperties(A,{SORTABLE_CHILDREN:{get:()=>En.defaultSortableChildren,set(t){Kt("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),En.defaultSortableChildren=t}}});const An=new Bs,Rn=new Uint16Array([0,1,2,0,2,3]);class Sn extends En{constructor(t){super(),this._anchor=new Zs(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 Ie(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=a.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||Wi.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=Rn,this.pluginName="batch",this.isSprite=!0,this._roundPixels=A.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=Xe(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=Xe(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,s=e.a,i=e.b,r=e.c,n=e.d,a=e.tx,o=e.ty,h=this.vertexData,l=t.trim,u=t.orig,d=this._anchor;let c=0,p=0,f=0,m=0;if(l?(p=l.x-d._x*u.width,c=p+l.width,m=l.y-d._y*u.height,f=m+l.height):(p=-d._x*u.width,c=p+u.width,m=-d._y*u.height,f=m+u.height),h[0]=s*p+r*m+a,h[1]=n*m+i*p+o,h[2]=s*c+r*m+a,h[3]=n*m+i*c+o,h[4]=s*c+r*f+a,h[5]=n*f+i*c+o,h[6]=s*p+r*f+a,h[7]=n*f+i*p+o,this._roundPixels){const t=A.RESOLUTION;for(let e=0;e<h.length;++e)h[e]=Math.round(h[e]*t)/t}}calculateTrimmedVertices(){if(this.vertexTrimmedData){if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return}else this.vertexTrimmedData=new Float32Array(8);this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,s=t.orig,i=this._anchor,r=this.transform.worldTransform,n=r.a,a=r.b,o=r.c,h=r.d,l=r.tx,u=r.ty,d=-i._x*s.width,c=d+s.width,p=-i._y*s.height,f=p+s.height;e[0]=n*d+o*p+l,e[1]=h*p+a*d+u,e[2]=n*c+o*p+l,e[3]=h*p+a*c+u,e[4]=n*c+o*f+l,e[5]=h*f+a*c+u,e[6]=n*d+o*f+l,e[7]=h*f+a*d+u}_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 0===this.children.length?(this._localBounds||(this._localBounds=new gn),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 Ls),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,An);const e=this._texture.orig.width,s=this._texture.orig.height,i=-e*this.anchor.x;let r=0;return An.x>=i&&An.x<i+e&&(r=-s*this.anchor.y,An.y>=r&&An.y<r+s)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,"boolean"==typeof t?t:null==t?void 0:t.texture){const e="boolean"==typeof t?t:null==t?void 0:t.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const s=t instanceof Wi?t:Wi.from(t,e);return new Sn(s)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-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=Xe(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=Xe(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||Wi.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const wn=new Hs;xn.prototype._cacheAsBitmap=!1,xn.prototype._cacheData=null,xn.prototype._cacheAsBitmapResolution=null,xn.prototype._cacheAsBitmapMultisample=null;class In{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(xn.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(t){t!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=t,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(t){t!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=t,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(t){if(this._cacheAsBitmap===t)return;let e;this._cacheAsBitmap=t,t?(this._cacheData||(this._cacheData=new In),e=this._cacheData,e.originalRender=this.render,e.originalRenderCanvas=this.renderCanvas,e.originalUpdateTransform=this.updateTransform,e.originalCalculateBounds=this.calculateBounds,e.originalGetLocalBounds=this.getLocalBounds,e.originalDestroy=this.destroy,e.originalContainsPoint=this.containsPoint,e.originalMask=this._mask,e.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(e=this._cacheData,e.sprite&&this._destroyCachedDisplayObject(),this.render=e.originalRender,this.renderCanvas=e.originalRenderCanvas,this.calculateBounds=e.originalCalculateBounds,this.getLocalBounds=e.originalGetLocalBounds,this.destroy=e.originalDestroy,this.updateTransform=e.originalUpdateTransform,this.containsPoint=e.originalContainsPoint,this._mask=e.originalMask,this.filterArea=e.originalFilterArea)}}}),xn.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))},xn.prototype._initCachedDisplayObject=function(t){var e,s,i;if(null!=(e=this._cacheData)&&e.sprite)return;const r=this.alpha;this.alpha=1,t.batch.flush();const n=this.getLocalBounds(null,!0).clone();if(null!=(s=this.filters)&&s.length){const t=this.filters[0].padding;n.pad(t)}n.ceil(A.RESOLUTION);const a=t.renderTexture.current,o=t.renderTexture.sourceFrame.clone(),h=t.renderTexture.destinationFrame.clone(),l=t.projection.transform,u=Yi.create({width:n.width,height:n.height,resolution:this.cacheAsBitmapResolution||t.resolution,multisample:null!=(i=this.cacheAsBitmapMultisample)?i:t.multisample}),d=`cacheAsBitmap_${Ve()}`;this._cacheData.textureCacheId=d,ys.addToCache(u.baseTexture,d),Wi.addToCache(u,d);const c=this.transform.localTransform.copyTo(wn).invert().translate(-n.x,-n.y);this.render=this._cacheData.originalRender,t.render(this,{renderTexture:u,clear:!0,transform:c,skipUpdateTransform:!1}),t.framebuffer.blit(),t.projection.transform=l,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;const p=new Sn(u);p.transform.worldTransform=this.transform.worldTransform,p.anchor.x=-n.x/n.width,p.anchor.y=-n.y/n.height,p.alpha=r,p._bounds=this._bounds,this._cacheData.sprite=p,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=p.containsPoint.bind(p)},xn.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))},xn.prototype._initCachedDisplayObjectCanvas=function(t){var e;if(null!=(e=this._cacheData)&&e.sprite)return;const s=this.getLocalBounds(null,!0),i=this.alpha;this.alpha=1;const r=t.canvasContext.activeContext,n=t._projTransform;s.ceil(A.RESOLUTION);const a=Yi.create({width:s.width,height:s.height}),o=`cacheAsBitmap_${Ve()}`;this._cacheData.textureCacheId=o,ys.addToCache(a.baseTexture,o),Wi.addToCache(a,o);const h=wn;this.transform.localTransform.copyTo(h),h.invert(),h.tx-=s.x,h.ty-=s.y,this.renderCanvas=this._cacheData.originalRenderCanvas,t.render(this,{renderTexture:a,clear:!0,transform:h,skipUpdateTransform:!1}),t.canvasContext.activeContext=r,t._projTransform=n,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=i;const l=new Sn(a);l.transform.worldTransform=this.transform.worldTransform,l.anchor.x=-s.x/s.width,l.anchor.y=-s.y/s.height,l.alpha=i,l._bounds=this._bounds,this._cacheData.sprite=l,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=t._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=l.containsPoint.bind(l)},xn.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},xn.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},xn.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,ys.removeFromCache(this._cacheData.textureCacheId),Wi.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},xn.prototype._cacheAsBitmapDestroy=function(t){this.cacheAsBitmap=!1,this.destroy(t)},xn.prototype.name=null,En.prototype.getChildByName=function(t,e){for(let e=0,s=this.children.length;e<s;e++)if(this.children[e].name===t)return this.children[e];if(e)for(let e=0,s=this.children.length;e<s;e++){const s=this.children[e];if(!s.getChildByName)continue;const i=s.getChildByName(t,!0);if(i)return i}return null},xn.prototype.getGlobalPosition=function(t=new Bs,e=!1){return this.parent?this.parent.toGlobal(this.position,t,e):(t.x=this.position.x,t.y=this.position.y),t};class Mn extends Pi{constructor(t=1){super(Qr,"varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float uAlpha;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;\n}\n",{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const Cn={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]},Dn=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join("\n");class Pn extends Pi{constructor(t,e=8,s=4,i=Pi.defaultResolution,r=5){const n=function(t,e){const s=Math.ceil(t/2);let i,r="\n attribute vec2 aVertexPosition;\n\n uniform mat3 projectionMatrix;\n\n uniform float strength;\n\n varying vec2 vBlurTexCoords[%size%];\n\n uniform vec4 inputSize;\n uniform vec4 outputFrame;\n\n vec4 filterVertexPosition( void )\n {\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n }\n\n vec2 filterTextureCoord( void )\n {\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n }\n\n void main(void)\n {\n gl_Position = filterVertexPosition();\n\n vec2 textureCoord = filterTextureCoord();\n %blur%\n }",n="";i=e?"vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":"vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let e=0;e<t;e++){let t=i.replace("%index%",e.toString());t=t.replace("%sampleIndex%",e-(s-1)+".0"),n+=t,n+="\n"}return r=r.replace("%blur%",n),r=r.replace("%size%",t.toString()),r}(r,t),a=function(t){const e=Cn[t],s=e.length;let i,r=Dn,n="";for(let r=0;r<t;r++){let a="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;".replace("%index%",r.toString());i=r,r>=s&&(i=t-r-1),a=a.replace("%value%",e[i].toString()),n+=a,n+="\n"}return r=r.replace("%blur%",n),r=r.replace("%size%",t.toString()),r}(r);super(n,a),this.horizontal=t,this.resolution=i,this._quality=0,this.quality=s,this.blur=e}apply(t,e,s,i){if(s?this.horizontal?this.uniforms.strength=1/s.width*(s.width/e.width):this.uniforms.strength=1/s.height*(s.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,1===this.passes)t.applyFilter(this,e,s,i);else{const r=t.getFilterTexture(),n=t.renderer;let a=e,o=r;this.state.blend=!1,t.applyFilter(this,a,o,_.CLEAR);for(let e=1;e<this.passes-1;e++){t.bindAndClear(a,_.BLIT),this.uniforms.uSampler=o;const e=o;o=a,a=e,n.shader.bind(this),n.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,o,s,i),t.returnFilterTexture(r)}}get blur(){return this.strength}set blur(t){this.padding=1+2*Math.abs(t),this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class On extends Pi{constructor(t=8,e=4,s=Pi.defaultResolution,i=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new Pn(!0,t,e,s,i),this.blurYFilter=new Pn(!1,t,e,s,i),this.resolution=s,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,s,i){const r=Math.abs(this.blurXFilter.strength),n=Math.abs(this.blurYFilter.strength);if(r&&n){const r=t.getFilterTexture();this.blurXFilter.apply(t,e,r,_.CLEAR),this.blurYFilter.apply(t,r,s,i),t.returnFilterTexture(r)}else n?this.blurYFilter.apply(t,e,s,i):this.blurXFilter.apply(t,e,s,i)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=2*Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))}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()}}class Fn extends Pi{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(Jr,"varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float m[20];\nuniform float uAlpha;\n\nvoid main(void)\n{\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n if (uAlpha == 0.0) {\n gl_FragColor = c;\n return;\n }\n\n // Un-premultiply alpha before applying the color matrix. See issue #3539.\n if (c.a > 0.0) {\n c.rgb /= c.a;\n }\n\n vec4 result;\n\n result.r = (m[0] * c.r);\n result.r += (m[1] * c.g);\n result.r += (m[2] * c.b);\n result.r += (m[3] * c.a);\n result.r += m[4];\n\n result.g = (m[5] * c.r);\n result.g += (m[6] * c.g);\n result.g += (m[7] * c.b);\n result.g += (m[8] * c.a);\n result.g += m[9];\n\n result.b = (m[10] * c.r);\n result.b += (m[11] * c.g);\n result.b += (m[12] * c.b);\n result.b += (m[13] * c.a);\n result.b += m[14];\n\n result.a = (m[15] * c.r);\n result.a += (m[16] * c.g);\n result.a += (m[17] * c.b);\n result.a += (m[18] * c.a);\n result.a += m[19];\n\n vec3 rgb = mix(c.rgb, result.rgb, uAlpha);\n\n // Premultiply alpha again.\n rgb *= result.a;\n\n gl_FragColor = vec4(rgb, result.a);\n}\n",t),this.alpha=1}_loadMatrix(t,e=!1){let s=t;e&&(this._multiply(s,this.uniforms.m,t),s=this._colorMatrix(s)),this.uniforms.m=s}_multiply(t,e,s){return t[0]=e[0]*s[0]+e[1]*s[5]+e[2]*s[10]+e[3]*s[15],t[1]=e[0]*s[1]+e[1]*s[6]+e[2]*s[11]+e[3]*s[16],t[2]=e[0]*s[2]+e[1]*s[7]+e[2]*s[12]+e[3]*s[17],t[3]=e[0]*s[3]+e[1]*s[8]+e[2]*s[13]+e[3]*s[18],t[4]=e[0]*s[4]+e[1]*s[9]+e[2]*s[14]+e[3]*s[19]+e[4],t[5]=e[5]*s[0]+e[6]*s[5]+e[7]*s[10]+e[8]*s[15],t[6]=e[5]*s[1]+e[6]*s[6]+e[7]*s[11]+e[8]*s[16],t[7]=e[5]*s[2]+e[6]*s[7]+e[7]*s[12]+e[8]*s[17],t[8]=e[5]*s[3]+e[6]*s[8]+e[7]*s[13]+e[8]*s[18],t[9]=e[5]*s[4]+e[6]*s[9]+e[7]*s[14]+e[8]*s[19]+e[9],t[10]=e[10]*s[0]+e[11]*s[5]+e[12]*s[10]+e[13]*s[15],t[11]=e[10]*s[1]+e[11]*s[6]+e[12]*s[11]+e[13]*s[16],t[12]=e[10]*s[2]+e[11]*s[7]+e[12]*s[12]+e[13]*s[17],t[13]=e[10]*s[3]+e[11]*s[8]+e[12]*s[13]+e[13]*s[18],t[14]=e[10]*s[4]+e[11]*s[9]+e[12]*s[14]+e[13]*s[19]+e[14],t[15]=e[15]*s[0]+e[16]*s[5]+e[17]*s[10]+e[18]*s[15],t[16]=e[15]*s[1]+e[16]*s[6]+e[17]*s[11]+e[18]*s[16],t[17]=e[15]*s[2]+e[16]*s[7]+e[17]*s[12]+e[18]*s[17],t[18]=e[15]*s[3]+e[16]*s[8]+e[17]*s[13]+e[18]*s[18],t[19]=e[15]*s[4]+e[16]*s[9]+e[17]*s[14]+e[18]*s[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 s=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}tint(t,e){const[s,i,r]=Ie.shared.setValue(t).toArray(),n=[s,0,0,0,0,0,i,0,0,0,0,0,r,0,0,0,0,0,1,0];this._loadMatrix(n,e)}greyscale(t,e){const s=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}blackAndWhite(t){this._loadMatrix([.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0],t)}hue(t,e){t=(t||0)/180*Math.PI;const s=Math.cos(t),i=Math.sin(t),r=1/3,n=(0,Math.sqrt)(r),a=[s+(1-s)*r,r*(1-s)-n*i,r*(1-s)+n*i,0,0,r*(1-s)+n*i,s+r*(1-s),r*(1-s)-n*i,0,0,r*(1-s)-n*i,r*(1-s)+n*i,s+r*(1-s),0,0,0,0,0,1,0];this._loadMatrix(a,e)}contrast(t,e){const s=(t||0)+1,i=-.5*(s-1),r=[s,0,0,0,i,0,s,0,0,i,0,0,s,0,i,0,0,0,1,0];this._loadMatrix(r,e)}saturate(t=0,e){const s=2*t/3+1,i=-.5*(s-1),r=[s,i,i,0,0,i,s,i,0,0,i,i,s,0,0,0,0,0,1,0];this._loadMatrix(r,e)}desaturate(){this.saturate(-1)}negative(t){this._loadMatrix([-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0],t)}sepia(t){this._loadMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0],t)}technicolor(t){this._loadMatrix([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],t)}polaroid(t){this._loadMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],t)}toBGR(t){this._loadMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0],t)}kodachrome(t){this._loadMatrix([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],t)}browni(t){this._loadMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0],t)}vintage(t){this._loadMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0],t)}colorTone(t,e,s,i,r){t=t||.2,e=e||.15,s=s||16770432,i=i||3375104;const n=Ie.shared,[a,o,h]=n.setValue(s).toArray(),[l,u,d]=n.setValue(i).toArray(),c=[.3,.59,.11,0,0,a,o,h,t,0,l,u,d,e,0,a-l,o-u,h-d,0,0];this._loadMatrix(c,r)}night(t,e){const s=[-2*(t=t||.1),-t,0,0,0,-t,0,t,0,0,0,t,2*t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}predator(t,e){const s=[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(s,e)}lsd(t){this._loadMatrix([2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0],t)}reset(){this._loadMatrix([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],!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}}Fn.prototype.grayscale=Fn.prototype.greyscale;class Bn extends Pi{constructor(t,e){const s=new Hs;t.renderable=!1,super("attribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\nuniform mat3 filterMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec2 vFilterCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n}\n\nvoid main(void)\n{\n\tgl_Position = filterVertexPosition();\n\tvTextureCoord = filterTextureCoord();\n\tvFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;\n}\n","varying vec2 vFilterCoord;\nvarying vec2 vTextureCoord;\n\nuniform vec2 scale;\nuniform mat2 rotation;\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nuniform highp vec4 inputSize;\nuniform vec4 inputClamp;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vFilterCoord);\n\n map -= 0.5;\n map.xy = scale * inputSize.zw * (rotation * map.xy);\n\n gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));\n}\n",{mapSampler:t._texture,filterMatrix:s,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=s,null==e&&(e=20),this.scale=new Bs(e,e)}apply(t,e,s,i){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const r=this.maskSprite.worldTransform,n=Math.sqrt(r.a*r.a+r.b*r.b),a=Math.sqrt(r.c*r.c+r.d*r.d);0!==n&&0!==a&&(this.uniforms.rotation[0]=r.a/n,this.uniforms.rotation[1]=r.b/n,this.uniforms.rotation[2]=r.c/a,this.uniforms.rotation[3]=r.d/a),t.applyFilter(this,e,s,i)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}class Nn extends Pi{constructor(){super("\nattribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\nvarying vec2 vFragCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvoid texcoords(vec2 fragCoord, vec2 inverseVP,\n out vec2 v_rgbNW, out vec2 v_rgbNE,\n out vec2 v_rgbSW, out vec2 v_rgbSE,\n out vec2 v_rgbM) {\n v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\n v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\n v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\n v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\n v_rgbM = vec2(fragCoord * inverseVP);\n}\n\nvoid main(void) {\n\n gl_Position = filterVertexPosition();\n\n vFragCoord = aVertexPosition * outputFrame.zw;\n\n texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}\n",'varying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\nvarying vec2 vFragCoord;\nuniform sampler2D uSampler;\nuniform highp vec4 inputSize;\n\n\n/**\n Basic FXAA implementation based on the code on geeks3d.com with the\n modification that the texture2DLod stuff was removed since it\'s\n unsupported by WebGL.\n\n --\n\n From:\n https://github.com/mitsuhiko/webgl-meincraft\n\n Copyright (c) 2011 by Armin Ronacher.\n\n Some rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are\n met:\n\n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n\n * Redistributions in binary form must reproduce the above\n copyright notice, this list of conditions and the following\n disclaimer in the documentation and/or other materials provided\n with the distribution.\n\n * The names of the contributors may not be used to endorse or\n promote products derived from this software without specific\n prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef FXAA_REDUCE_MIN\n#define FXAA_REDUCE_MIN (1.0/ 128.0)\n#endif\n#ifndef FXAA_REDUCE_MUL\n#define FXAA_REDUCE_MUL (1.0 / 8.0)\n#endif\n#ifndef FXAA_SPAN_MAX\n#define FXAA_SPAN_MAX 8.0\n#endif\n\n//optimized version for mobile, where dependent\n//texture reads can be a bottleneck\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP,\n vec2 v_rgbNW, vec2 v_rgbNE,\n vec2 v_rgbSW, vec2 v_rgbSE,\n vec2 v_rgbM) {\n vec4 color;\n vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;\n vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;\n vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;\n vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;\n vec4 texColor = texture2D(tex, v_rgbM);\n vec3 rgbM = texColor.xyz;\n vec3 luma = vec3(0.299, 0.587, 0.114);\n float lumaNW = dot(rgbNW, luma);\n float lumaNE = dot(rgbNE, luma);\n float lumaSW = dot(rgbSW, luma);\n float lumaSE = dot(rgbSE, luma);\n float lumaM = dot(rgbM, luma);\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n mediump vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * inverseVP;\n\n vec3 rgbA = 0.5 * (\n texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\n vec3 rgbB = rgbA * 0.5 + 0.25 * (\n texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\n\n float lumaB = dot(rgbB, luma);\n if ((lumaB < lumaMin) || (lumaB > lumaMax))\n color = vec4(rgbA, texColor.a);\n else\n color = vec4(rgbB, texColor.a);\n return color;\n}\n\nvoid main() {\n\n vec4 color;\n\n color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n\n gl_FragColor = color;\n}\n')}}class Ln extends Pi{constructor(t=.5,e=Math.random()){super(Jr,"precision highp float;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform float uNoise;\nuniform float uSeed;\nuniform sampler2D uSampler;\n\nfloat rand(vec2 co)\n{\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main()\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n float randomValue = rand(gl_FragCoord.xy * uSeed);\n float diff = (randomValue - 0.5) * uNoise;\n\n // Un-premultiply alpha before applying the color matrix. See issue #3539.\n if (color.a > 0.0) {\n color.rgb /= color.a;\n }\n\n color.r += diff;\n color.g += diff;\n color.b += diff;\n\n // Premultiply alpha again.\n color.rgb *= color.a;\n\n gl_FragColor = color;\n}\n",{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 Gn={AlphaFilter:Mn,BlurFilter:On,BlurFilterPass:Pn,ColorMatrixFilter:Fn,DisplacementFilter:Bn,FXAAFilter:Nn,NoiseFilter:Ln};Object.entries(Gn).forEach((([t,e])=>{Object.defineProperty(Gn,t,{get:()=>e})}));const Un=new class{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||($r.system.add(this.tickerUpdate,this,Wr.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){!this.tickerAdded||($r.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove)return void(this._didMove=!1);const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&"touch"===t.pointerType||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())}};class kn{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=kn.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new Bs,this.page=new Bs,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,s){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,s,i,r){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 Xn extends kn{constructor(){super(...arguments),this.client=new Bs,this.movement=new Bs,this.offset=new Bs,this.global=new Bs,this.screen=new Bs}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,s){return t.worldTransform.applyInverse(s||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,s,i,r,n,a,o,h,l,u,d,c,p,f){throw new Error("Method not implemented.")}}class Hn extends Xn{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Vn extends Xn{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Vn.DOM_DELTA_PIXEL=0,Vn.DOM_DELTA_LINE=1,Vn.DOM_DELTA_PAGE=2;const Wn=new Bs,Yn=new Bs;class jn{constructor(t){this.dispatch=new W,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(((t,e)=>t.priority-e.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 s=0,i=e.length;s<i;s++)e[s].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){Un.pauseUpdate=!0;const s=this[this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive"](this.rootTarget,this.rootTarget.eventMode,Wn.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const s=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let i=0,r=s.length-1;i<r;i++)if(t.currentTarget=s[i],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 i=s.length-2;i>=0;i--)if(t.currentTarget=s[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,s=this._allInteractiveElements){if(0===s.length)return;t.eventPhase=t.BUBBLING_PHASE;const i=Array.isArray(e)?e:[e];for(let e=s.length-1;e>=0;e--)i.forEach((i=>{t.currentTarget=s[e],this.notifyTarget(t,i)}))}propagationPath(t){const e=[t];for(let s=0;s<2048&&t!==this.rootTarget;s++){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,s,i,r,n=!1){let a=!1;if(this._interactivePrune(t))return null;if(("dynamic"===t.eventMode||"dynamic"===e)&&(Un.pauseUpdate=!1),t.interactiveChildren&&t.children){const o=t.children;for(let h=o.length-1;h>=0;h--){const l=o[h],u=this.hitTestMoveRecursive(l,this._isInteractive(e)?e:l.eventMode,s,i,r,n||r(t,s));if(u){if(u.length>0&&!u[u.length-1].parent)continue;const e=t.isInteractive();(u.length>0||e)&&(e&&this._allInteractiveElements.push(t),u.push(t)),0===this._hitElements.length&&(this._hitElements=u),a=!0}}}const o=this._isInteractive(e),h=t.isInteractive();return h&&h&&this._allInteractiveElements.push(t),n||this._hitElements.length>0?null:a?this._hitElements:o&&!r(t,s)&&i(t,s)?h?[t]:[]:null}hitTestRecursive(t,e,s,i,r){if(this._interactivePrune(t)||r(t,s))return null;if(("dynamic"===t.eventMode||"dynamic"===e)&&(Un.pauseUpdate=!1),t.interactiveChildren&&t.children){const n=t.children;for(let a=n.length-1;a>=0;a--){const o=n[a],h=this.hitTestRecursive(o,this._isInteractive(e)?e:o.eventMode,s,i,r);if(h){if(h.length>0&&!h[h.length-1].parent)continue;const e=t.isInteractive();return(h.length>0||e)&&h.push(t),h}}}const n=this._isInteractive(e),a=t.isInteractive();return n&&i(t,s)?a?[t]:[]:null}_isInteractive(t){return"static"===t||"dynamic"===t}_interactivePrune(t){return!(t&&!t.isMask&&t.visible&&t.renderable&&"none"!==t.eventMode&&("passive"!==t.eventMode||t.interactiveChildren)&&!t.isMask)}hitPruneFn(t,e){var s;if(t.hitArea&&(t.worldTransform.applyInverse(e,Yn),!t.hitArea.contains(Yn.x,Yn.y)))return!0;if(t._mask){const i=t._mask.isMaskData?t._mask.maskObject:t._mask;if(i&&(null==(s=i.containsPoint)||!s.call(i,e)))return!0}return!1}hitTestFn(t,e){return"passive"!==t.eventMode&&(!!t.hitArea||!!t.containsPoint&&t.containsPoint(e))}notifyTarget(t,e){var s,i;const r=`on${e=null!=e?e:t.type}`;null==(i=(s=t.currentTarget)[r])||i.call(s,t);const n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof Hn))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),"touch"===e.pointerType)this.dispatchEvent(e,"touchstart");else if("mouse"===e.pointerType||"pen"===e.pointerType){const t=2===e.button;this.dispatchEvent(e,t?"rightdown":"mousedown")}this.trackingData(t.pointerId).pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,s,i;if(!(t instanceof Hn))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const r=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const n="mouse"===r.pointerType||"pen"===r.pointerType,a=this.trackingData(t.pointerId),o=this.findMountedTarget(a.overTargets);if((null==(e=a.overTargets)?void 0:e.length)>0&&o!==r.target){const e="mousemove"===t.type?"mouseout":"pointerout",s=this.createPointerEvent(t,e,o);if(this.dispatchEvent(s,"pointerout"),n&&this.dispatchEvent(s,"mouseout"),!r.composedPath().includes(o)){const e=this.createPointerEvent(t,"pointerleave",o);for(e.eventPhase=e.AT_TARGET;e.target&&!r.composedPath().includes(e.target);)e.currentTarget=e.target,this.notifyTarget(e),n&&this.notifyTarget(e,"mouseleave"),e.target=e.target.parent;this.freeEvent(e)}this.freeEvent(s)}if(o!==r.target){const e="mousemove"===t.type?"mouseover":"pointerover",s=this.clonePointerEvent(r,e);this.dispatchEvent(s,"pointerover"),n&&this.dispatchEvent(s,"mouseover");let i=null==o?void 0:o.parent;for(;i&&i!==this.rootTarget.parent&&i!==r.target;)i=i.parent;if(!i||i===this.rootTarget.parent){const t=this.clonePointerEvent(r,"pointerenter");for(t.eventPhase=t.AT_TARGET;t.target&&t.target!==o&&t.target!==this.rootTarget.parent;)t.currentTarget=t.target,this.notifyTarget(t),n&&this.notifyTarget(t,"mouseenter"),t.target=t.target.parent;this.freeEvent(t)}this.freeEvent(s)}const h=[],l=null==(s=this.enableGlobalMoveEvents)||s;this.moveOnAll?h.push("pointermove"):this.dispatchEvent(r,"pointermove"),l&&h.push("globalpointermove"),"touch"===r.pointerType&&(this.moveOnAll?h.splice(1,0,"touchmove"):this.dispatchEvent(r,"touchmove"),l&&h.push("globaltouchmove")),n&&(this.moveOnAll?h.splice(1,0,"mousemove"):this.dispatchEvent(r,"mousemove"),l&&h.push("globalmousemove"),this.cursor=null==(i=r.target)?void 0:i.cursor),h.length>0&&this.all(r,h),this._allInteractiveElements.length=0,this._hitElements.length=0,a.overTargets=r.composedPath(),this.freeEvent(r)}mapPointerOver(t){var e;if(!(t instanceof Hn))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const s=this.trackingData(t.pointerId),i=this.createPointerEvent(t),r="mouse"===i.pointerType||"pen"===i.pointerType;this.dispatchEvent(i,"pointerover"),r&&this.dispatchEvent(i,"mouseover"),"mouse"===i.pointerType&&(this.cursor=null==(e=i.target)?void 0:e.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;s.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof Hn))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId);if(e.overTargets){const s="mouse"===t.pointerType||"pen"===t.pointerType,i=this.findMountedTarget(e.overTargets),r=this.createPointerEvent(t,"pointerout",i);this.dispatchEvent(r),s&&this.dispatchEvent(r,"mouseout");const n=this.createPointerEvent(t,"pointerleave",i);for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseleave"),n.target=n.target.parent;e.overTargets=null,this.freeEvent(r),this.freeEvent(n)}this.cursor=null}mapPointerUp(t){if(!(t instanceof Hn))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=performance.now(),s=this.createPointerEvent(t);if(this.dispatchEvent(s,"pointerup"),"touch"===s.pointerType)this.dispatchEvent(s,"touchend");else if("mouse"===s.pointerType||"pen"===s.pointerType){const t=2===s.button;this.dispatchEvent(s,t?"rightup":"mouseup")}const i=this.trackingData(t.pointerId),r=this.findMountedTarget(i.pressTargetsByButton[t.button]);let n=r;if(r&&!s.composedPath().includes(r)){let e=r;for(;e&&!s.composedPath().includes(e);){if(s.currentTarget=e,this.notifyTarget(s,"pointerupoutside"),"touch"===s.pointerType)this.notifyTarget(s,"touchendoutside");else if("mouse"===s.pointerType||"pen"===s.pointerType){const t=2===s.button;this.notifyTarget(s,t?"rightupoutside":"mouseupoutside")}e=e.parent}delete i.pressTargetsByButton[t.button],n=e}if(n){const r=this.clonePointerEvent(s,"click");r.target=n,r.path=null,i.clicksByButton[t.button]||(i.clicksByButton[t.button]={clickCount:0,target:r.target,timeStamp:e});const a=i.clicksByButton[t.button];if(a.target===r.target&&e-a.timeStamp<200?++a.clickCount:a.clickCount=1,a.target=r.target,a.timeStamp=e,r.detail=a.clickCount,"mouse"===r.pointerType){const t=2===r.button;this.dispatchEvent(r,t?"rightclick":"click")}else"touch"===r.pointerType&&this.dispatchEvent(r,"tap");this.dispatchEvent(r,"pointertap"),this.freeEvent(r)}this.freeEvent(s)}mapPointerUpOutside(t){if(!(t instanceof Hn))return void console.warn("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId),s=this.findMountedTarget(e.pressTargetsByButton[t.button]),i=this.createPointerEvent(t);if(s){let r=s;for(;r;)i.currentTarget=r,this.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType?this.notifyTarget(i,"touchendoutside"):("mouse"===i.pointerType||"pen"===i.pointerType)&&this.notifyTarget(i,2===i.button?"rightupoutside":"mouseupoutside"),r=r.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(i)}mapWheel(t){if(!(t instanceof Vn))return void console.warn("EventBoundary cannot map a non-wheel event as a wheel event");const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let s=1;s<t.length&&t[s].parent===e;s++)e=t[s];return e}createPointerEvent(t,e,s){var i;const r=this.allocateEvent(Hn);return this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=null!=(i=null!=s?s:this.hitTest(r.global.x,r.global.y))?i:this._hitElements[0],"string"==typeof e&&(r.type=e),r}createWheelEvent(t){const e=this.allocateEvent(Vn);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 s=this.allocateEvent(Hn);return s.nativeEvent=t.nativeEvent,s.originalEvent=t.originalEvent,this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.target=t.target,s.path=t.composedPath().slice(),s.type=null!=e?e:s.type,s}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Hn&&e instanceof Hn&&(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 Xn&&e instanceof Xn&&(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 s=t.currentTarget._events[e];if(s&&t.currentTarget.isInteractive())if("fn"in s)s.once&&t.currentTarget.removeListener(e,s.fn,void 0,!0),s.fn.call(s.context,t);else for(let i=0,r=s.length;i<r&&!t.propagationImmediatelyStopped;i++)s[i].once&&t.currentTarget.removeListener(e,s[i].fn,void 0,!0),s[i].fn.call(s[i].context,t)}}const $n={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},qn=class{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new jn(null),Un.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new Hn(null),this.rootWheelEvent=new Vn(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(bt({},qn.defaultEventFeatures),{set:(t,e,s)=>("globalMove"===e&&(this.rootBoundary.enableGlobalMoveEvents=s),t[e]=s,!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){var e,s;const{view:i,resolution:r}=this.renderer;this.setTargetElement(i),this.resolution=r,qn._defaultEventMode=null!=(e=t.eventMode)?e:"auto",Object.assign(this.features,null!=(s=t.eventFeatures)?s:{}),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 s=this.cursorStyles[t];if(s)switch(typeof s){case"string":e&&(this.domElement.style.cursor=s);break;case"function":s(t);break;case"object":e&&Object.assign(this.domElement.style,s)}else e&&"string"==typeof t&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click||(this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.supportsTouchEvents&&"touch"===t.pointerType))return;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let t=0,s=e.length;t<s;t++){const s=e[t],i=this.bootstrapEvent(this.rootPointerEvent,s);this.rootBoundary.mapEvent(i)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move||(this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.supportsTouchEvents&&"touch"===t.pointerType))return;Un.pointerMoved();const e=this.normalizeToPointerData(t);for(let t=0,s=e.length;t<s;t++){const s=this.bootstrapEvent(this.rootPointerEvent,e[t]);this.rootBoundary.mapEvent(s)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click||(this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.supportsTouchEvents&&"touch"===t.pointerType))return;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const s=e!==this.domElement?"outside":"",i=this.normalizeToPointerData(t);for(let t=0,e=i.length;t<e;t++){const e=this.bootstrapEvent(this.rootPointerEvent,i[t]);e.type+=s,this.rootBoundary.mapEvent(e)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click||(this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.supportsTouchEvents&&"touch"===t.pointerType))return;const e=this.normalizeToPointerData(t);for(let t=0,s=e.length;t<s;t++){const s=this.bootstrapEvent(this.rootPointerEvent,e[t]);this.rootBoundary.mapEvent(s)}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,Un.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;Un.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;Un.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,s){let i;i=this.domElement.parentElement?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0};const r=1/this.resolution;t.x=(e-i.left)*(this.domElement.width/i.width)*r,t.y=(s-i.top)*(this.domElement.height/i.height)*r}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let s=0,i=t.changedTouches.length;s<i;s++){const i=t.changedTouches[s];void 0===i.button&&(i.button=0),void 0===i.buttons&&(i.buttons=1),void 0===i.isPrimary&&(i.isPrimary=1===t.touches.length&&"touchstart"===t.type),void 0===i.width&&(i.width=i.radiusX||1),void 0===i.height&&(i.height=i.radiusY||1),void 0===i.tiltX&&(i.tiltX=0),void 0===i.tiltY&&(i.tiltY=0),void 0===i.pointerType&&(i.pointerType="touch"),void 0===i.pointerId&&(i.pointerId=i.identifier||0),void 0===i.pressure&&(i.pressure=i.force||.5),void 0===i.twist&&(i.twist=0),void 0===i.tangentialPressure&&(i.tangentialPressure=0),void 0===i.layerX&&(i.layerX=i.offsetX=i.clientX),void 0===i.layerY&&(i.layerY=i.offsetY=i.clientY),i.isNormalized=!0,i.type=t.type,e.push(i)}else if(globalThis.MouseEvent&&(!(t instanceof MouseEvent)||this.supportsPointerEvents&&t instanceof globalThis.PointerEvent))e.push(t);else{const s=t;void 0===s.isPrimary&&(s.isPrimary=!0),void 0===s.width&&(s.width=1),void 0===s.height&&(s.height=1),void 0===s.tiltX&&(s.tiltX=0),void 0===s.tiltY&&(s.tiltY=0),void 0===s.pointerType&&(s.pointerType="mouse"),void 0===s.pointerId&&(s.pointerId=1),void 0===s.pressure&&(s.pressure=.5),void 0===s.twist&&(s.twist=0),void 0===s.tangentialPressure&&(s.tangentialPressure=0),s.isNormalized=!0,e.push(s)}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,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=$n[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}};let Kn=qn;function Zn(t){return"dynamic"===t||"static"===t}Kn.extension={name:"events",type:[rs.RendererSystem,rs.CanvasRendererSystem]},Kn.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0},os.add(Kn);const Qn={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(){var t;return null!=(t=this._internalInteractive)?t:Zn(Kn.defaultEventMode)},set interactive(t){Kt("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=t,this.eventMode=t?"static":"auto"},_internalEventMode:void 0,get eventMode(){var t;return null!=(t=this._internalEventMode)?t:Kn.defaultEventMode},set eventMode(t){this._internalInteractive=Zn(t),this._internalEventMode=t},isInteractive(){return"static"===this.eventMode||"dynamic"===this.eventMode},interactiveChildren:!0,hitArea:null,addEventListener(t,e,s){const i="function"==typeof e?void 0:e;t="boolean"==typeof s&&s||"object"==typeof s&&s.capture?`${t}capture`:t,e="function"==typeof e?e:e.handleEvent,this.on(t,e,i)},removeEventListener(t,e,s){const i="function"==typeof e?void 0:e;t="boolean"==typeof s&&s||"object"==typeof s&&s.capture?`${t}capture`:t,e="function"==typeof e?e:e.handleEvent,this.off(t,e,i)},dispatchEvent(t){if(!(t instanceof kn))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return t.defaultPrevented=!1,t.path=null,t.target=this,t.manager.dispatchEvent(t),!t.defaultPrevented}};xn.mixin(Qn);const Jn={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};xn.mixin(Jn);class ta{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,(H.tablet||H.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width="100px",e.style.height="100px",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.zIndex=2..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="1px",t.style.height="1px",t.style.position="absolute",t.style.top="-1000px",t.style.left="-1000px",t.style.zIndex=2..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),null==(t=this.renderer.view.parentNode)||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),null==(t=this.div.parentNode)||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 t=0;t<e.length;t++)this.updateAccessibleObjects(e[t])}update(){const t=performance.now();if(H.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:s,width:i,height:r}=this.renderer.view.getBoundingClientRect(),{width:n,height:a,resolution:o}=this.renderer,h=i/n*o,l=r/a*o;let u=this.div;u.style.left=`${e}px`,u.style.top=`${s}px`,u.style.width=`${n}px`,u.style.height=`${a}px`;for(let t=0;t<this.children.length;t++){const e=this.children[t];if(e.renderId!==this.renderId)e._accessibleActive=!1,ke(this.children,t,1),this.div.removeChild(e._accessibleDiv),this.pool.push(e._accessibleDiv),e._accessibleDiv=null,t--;else{u=e._accessibleDiv;let t=e.hitArea;const s=e.worldTransform;e.hitArea?(u.style.left=(s.tx+t.x*s.a)*h+"px",u.style.top=(s.ty+t.y*s.d)*l+"px",u.style.width=t.width*s.a*h+"px",u.style.height=t.height*s.d*l+"px"):(t=e.getBounds(),this.capHitArea(t),u.style.left=t.x*h+"px",u.style.top=t.y*l+"px",u.style.width=t.width*h+"px",u.style.height=t.height*l+"px",u.title!==e.accessibleTitle&&null!==e.accessibleTitle&&(u.title=e.accessibleTitle),u.getAttribute("aria-label")!==e.accessibleHint&&null!==e.accessibleHint&&u.setAttribute("aria-label",e.accessibleHint)),(e.accessibleTitle!==u.title||e.tabIndex!==u.tabIndex)&&(u.title=e.accessibleTitle,u.tabIndex=e.tabIndex,this.debug&&this.updateDebugHTML(u))}}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:s}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>s&&(t.height=s-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width="100px",e.style.height="100px",e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=2..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&&null!==t.accessibleTitle?e.title=t.accessibleTitle:(!t.accessibleHint||null===t.accessibleHint)&&(e.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&null!==t.accessibleHint&&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:s}=t.target,i=this.renderer.events.rootBoundary,r=Object.assign(new kn(i),{target:s});i.rootTarget=this.renderer.lastObjectRendered,e.forEach((t=>i.dispatchEvent(r,t)))}_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){9===t.keyCode&&this.activate()}_onMouseMove(t){0===t.movementX&&0===t.movementY||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}}ta.extension={name:"accessibility",type:[rs.RendererPlugin,rs.CanvasRendererPlugin]},os.add(ta);const ea=class{constructor(t){this.stage=new En,t=Object.assign({forceCanvas:!1},t),this.renderer=Zr(t),ea._plugins.forEach((e=>{e.init.call(this,t)}))}render(){this.renderer.render(this.stage)}get view(){return this.renderer.view}get screen(){return this.renderer.screen}destroy(t,e){const s=ea._plugins.slice(0);s.reverse(),s.forEach((t=>{t.destroy.call(this)})),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};let sa=ea;sa._plugins=[],os.handleByList(rs.Application,sa._plugins);class ia{static init(t){Object.defineProperty(this,"resizeTo",{set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(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;let t,e;if(this.cancelResize(),this._resizeTo===globalThis.window)t=globalThis.innerWidth,e=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:i}=this._resizeTo;t=s,e=i}this.renderer.resize(t,e),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}}ia.extension=rs.Application,os.add(ia);const ra={loader:rs.LoadParser,resolver:rs.ResolveParser,cache:rs.CacheParser,detection:rs.DetectionParser};os.handle(rs.Asset,(t=>{const e=t.ref;Object.entries(ra).filter((([t])=>!!e[t])).forEach((([t,s])=>{var i;return os.add(Object.assign(e[t],{extension:null!=(i=e[t].extension)?i:s}))}))}),(t=>{const e=t.ref;Object.keys(ra).filter((t=>!!e[t])).forEach((t=>os.remove(e[t])))}));class na{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach((t=>{this._assetList.push(t)})),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 s=0;s<e;s++)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 aa(t,e){if(Array.isArray(e)){for(const s of e)if(t.startsWith(`data:${s}`))return!0;return!1}return t.startsWith(`data:${e}`)}function oa(t,e){const s=t.split("?")[0],i=$t.extname(s).toLowerCase();return Array.isArray(e)?e.includes(i):i===e}const ha=(t,e)=>(Array.isArray(t)||(t=[t]),e?t.map((t=>"string"==typeof t?e(t):t)):t),la=(t,e)=>{const s=e.split("?")[1];return s&&(t+=`?${s}`),t};function ua(t,e,s,i,r){const n=e[s];for(let a=0;a<n.length;a++){const o=n[a];s<e.length-1?ua(t.replace(i[s],o),e,s+1,i,r):r.push(t.replace(i[s],o))}}function da(t){const e=t.match(/\{(.*?)\}/g),s=[];if(e){const i=[];e.forEach((t=>{const e=t.substring(1,t.length-1).split(",");i.push(e)})),ua(t,i,0,e,s)}else s.push(t);return s}const ca=t=>!Array.isArray(t);const pa=new class{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 s=ha(t);let i;for(let t=0;t<this.parsers.length;t++){const r=this.parsers[t];if(r.test(e)){i=r.getCacheableAssets(s,e);break}}i||(i={},s.forEach((t=>{i[t]=e})));const r=Object.keys(i),n={cacheKeys:r,keys:s};if(s.forEach((t=>{this._cacheMap.set(t,n)})),r.forEach((t=>{this._cache.has(t)&&this._cache.get(t)!==e&&console.warn("[Cache] already has key:",t),this._cache.set(t,i[t])})),e instanceof Wi){const t=e;s.forEach((e=>{t.baseTexture!==Wi.EMPTY.baseTexture&&ys.addToCache(t.baseTexture,e),Wi.addToCache(t,e)}))}}remove(t){if(this._cacheMap.get(t),!this._cacheMap.has(t))return void console.warn(`[Assets] Asset id ${t} was not found in the Cache`);const e=this._cacheMap.get(t);e.cacheKeys.forEach((t=>{this._cache.delete(t)})),e.keys.forEach((t=>{this._cacheMap.delete(t)}))}get parsers(){return this._parsers}};class fa{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,s)=>(this._parsersValidated=!1,t[e]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{var i,r;let n=null,a=null;if(e.loadParser&&(a=this._parserHash[e.loadParser],a||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!a){for(let s=0;s<this.parsers.length;s++){const r=this.parsers[s];if(r.load&&(null==(i=r.test)?void 0:i.call(r,t,e,this))){a=r;break}}if(!a)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}n=await a.load(t,e,this),s.parser=a;for(let t=0;t<this.parsers.length;t++){const i=this.parsers[t];i.parse&&i.parse&&await(null==(r=i.testParse)?void 0:r.call(i,n,e,this))&&(n=await i.parse(n,e,this)||n,s.parser=i)}return n})(),s}async load(t,e){this._parsersValidated||this._validateParsers();let s=0;const i={},r=ca(t),n=ha(t,(t=>({src:t}))),a=n.length,o=n.map((async t=>{const r=$t.toAbsolute(t.src);if(!i[t.src])try{this.promiseCache[r]||(this.promiseCache[r]=this._getLoadPromiseAndParser(r,t)),i[t.src]=await this.promiseCache[r].promise,e&&e(++s/a)}catch(e){throw delete this.promiseCache[r],delete i[t.src],new Error(`[Loader.load] Failed to load ${r}.\n${e}`)}}));return await Promise.all(o),r?i[n[0].src]:i}async unload(t){const e=ha(t,(t=>({src:t}))).map((async t=>{var e,s;const i=$t.toAbsolute(t.src),r=this.promiseCache[i];if(r){const n=await r.promise;null==(s=null==(e=r.parser)?void 0:e.unload)||s.call(e,n,t,this),delete this.promiseCache[i]}}));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}"`),Qi(bt({},t),{[e.name]:e}))),{})}}var ma=(t=>(t[t.Low=0]="Low",t[t.Normal=1]="Normal",t[t.High=2]="High",t))(ma||{});const _a={extension:{type:rs.LoadParser,priority:ma.Low},name:"loadJson",test:t=>aa(t,"application/json")||oa(t,".json"),load:async t=>await(await A.ADAPTER.fetch(t)).json()};os.add(_a);const ga={name:"loadTxt",extension:{type:rs.LoadParser,priority:ma.Low},test:t=>aa(t,"text/plain")||oa(t,".txt"),load:async t=>await(await A.ADAPTER.fetch(t)).text()};os.add(ga);const xa=["normal","bold","100","200","300","400","500","600","700","800","900"],va=[".ttf",".otf",".woff",".woff2"],ya=["font/ttf","font/otf","font/woff","font/woff2"],Ta=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function ba(t){const e=$t.extname(t),s=$t.basename(t,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map((t=>t.charAt(0).toUpperCase()+t.slice(1)));let i=s.length>0;for(const t of s)if(!t.match(Ta)){i=!1;break}let r=s.join(" ");return i||(r=`"${r.replace(/[\\"]/g,"\\$&")}"`),r}const Ea={extension:{type:rs.LoadParser,priority:ma.Low},name:"loadWebFont",test:t=>aa(t,ya)||oa(t,va),async load(t,e){var s,i,r,n,a,o;const h=A.ADAPTER.getFontFaceSet();if(h){const l=[],u=null!=(i=null==(s=e.data)?void 0:s.family)?i:ba(t),d=null!=(a=null==(n=null==(r=e.data)?void 0:r.weights)?void 0:n.filter((t=>xa.includes(t))))?a:["normal"],c=null!=(o=e.data)?o:{};for(let e=0;e<d.length;e++){const s=d[e],i=new FontFace(u,`url(${encodeURI(t)})`,Qi(bt({},c),{weight:s}));await i.load(),h.add(i),l.push(i)}return 1===l.length?l[0]:l}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(t){(Array.isArray(t)?t:[t]).forEach((t=>A.ADAPTER.getFontFaceSet().delete(t)))}};os.add(Ea);let Aa,Ra=0;const Sa={id:"checkImageBitmap",code:"\n async function checkImageBitmap()\n {\n try\n {\n if (typeof createImageBitmap !== 'function') return false;\n\n const response = await fetch('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=');\n const imageBlob = await response.blob();\n const imageBitmap = await createImageBitmap(imageBlob);\n\n return imageBitmap.width === 1 && imageBitmap.height === 1;\n }\n catch (e)\n {\n return false;\n }\n }\n checkImageBitmap().then((result) => { self.postMessage(result); });\n "},wa={id:"loadImageBitmap",code:"\n async function loadImageBitmap(url)\n {\n const response = await fetch(url);\n\n if (!response.ok)\n {\n throw new Error(`[WorkerManager.loadImageBitmap] Failed to fetch ${url}: `\n + `${response.status} ${response.statusText}`);\n }\n\n const imageBlob = await response.blob();\n const imageBitmap = await createImageBitmap(imageBlob);\n\n return imageBitmap;\n }\n self.onmessage = async (event) =>\n {\n try\n {\n const imageBitmap = await loadImageBitmap(event.data.data[0]);\n\n self.postMessage({\n data: imageBitmap,\n uuid: event.data.uuid,\n id: event.data.id,\n }, [imageBitmap]);\n }\n catch(e)\n {\n self.postMessage({\n error: e,\n uuid: event.data.uuid,\n id: event.data.id,\n });\n }\n };"};let Ia;const Ma=new class{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return void 0!==this._isImageBitmapSupported||(this._isImageBitmapSupported=new Promise((t=>{const e=URL.createObjectURL(new Blob([Sa.code],{type:"application/javascript"})),s=new Worker(e);s.addEventListener("message",(i=>{s.terminate(),URL.revokeObjectURL(e),t(i.data)}))}))),this._isImageBitmapSupported}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){void 0===Aa&&(Aa=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<Aa&&(Ia||(Ia=URL.createObjectURL(new Blob([wa.code],{type:"application/javascript"}))),this._createdWorkers++,t=new Worker(Ia),t.addEventListener("message",(t=>{this.complete(t.data),this.returnWorker(t.target),this.next()}))),t}returnWorker(t){this.workerPool.push(t)}complete(t){void 0!==t.error?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 s=new Promise(((s,i)=>{this.queue.push({id:t,arguments:e,resolve:s,reject:i})}));return this.next(),s}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),s=e.id;this.resolveHash[Ra]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Ra++,id:s})}};function Ca(t,e,s){const i=new Wi(t);return i.baseTexture.on("dispose",(()=>{delete e.promiseCache[s]})),i}const Da=[".jpeg",".jpg",".png",".webp",".avif"],Pa=["image/jpeg","image/png","image/webp","image/avif"];async function Oa(t){const e=await A.ADAPTER.fetch(t);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${t}: ${e.status} ${e.statusText}`);const s=await e.blob();return await createImageBitmap(s)}const Fa={name:"loadTextures",extension:{type:rs.LoadParser,priority:ma.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test:t=>aa(t,Pa)||oa(t,Da),async load(t,e,s){let i=null;i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Ma.isImageBitmapSupported()?await Ma.loadImageBitmap(t):await Oa(t):await new Promise((e=>{i=new Image,i.crossOrigin=this.config.crossOrigin,i.src=t,i.complete?e(i):i.onload=()=>{e(i)}}));const r=new ys(i,bt({resolution:ss(t)},e.data));return r.resource.src=t,Ca(r,s,t)},unload(t){t.destroy(!0)}};os.add(Fa);const Ba={extension:{type:rs.LoadParser,priority:ma.High},name:"loadSVG",test:t=>aa(t,"image/svg+xml")||oa(t,".svg"),testParse:async t=>fn.test(t),async parse(t,e,s){var i;const r=new fn(t,null==(i=null==e?void 0:e.data)?void 0:i.resourceOptions);await r.load();const n=new ys(r,bt({resolution:ss(t)},null==e?void 0:e.data));return n.resource.src=t,Ca(n,s,t)},load:async(t,e)=>(await A.ADAPTER.fetch(t)).text(),unload:Fa.unload};os.add(Ba);class Na{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){var e,s,i;if(this._bundleIdConnector=null!=(e=t.connector)?e:this._bundleIdConnector,this._createBundleAssetId=null!=(s=t.createBundleAssetId)?s:this._createBundleAssetId,this._extractAssetIdFromBundle=null!=(i=t.extractAssetIdFromBundle)?i:this._extractAssetIdFromBundle,"bar"!==this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar")))throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach((t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.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("string"==typeof t)this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&")}}addManifest(t){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach((t=>{this.addBundle(t.name,t.assets)}))}addBundle(t,e){const s=[];Array.isArray(e)?e.forEach((e=>{if("string"==typeof e.name){const i=this._createBundleAssetId(t,e.name);s.push(i),this.add([e.name,i],e.srcs,e.data)}else{const i=e.name.map((e=>this._createBundleAssetId(t,e)));i.forEach((t=>{s.push(t)})),this.add([...e.name,...i],e.srcs)}})):Object.keys(e).forEach((i=>{s.push(this._createBundleAssetId(t,i)),this.add([i,this._createBundleAssetId(t,i)],e[i])})),this._bundles[t]=s}add(t,e,s){const i=ha(t);i.forEach((t=>{this.hasKey(t)&&console.warn(`[Resolver] already has key: ${t} overwriting`)})),Array.isArray(e)||(e="string"==typeof e?da(e):[e]);const r=e.map((t=>{var e;let r=t;if("string"==typeof t){let e=!1;for(let s=0;s<this._parsers.length;s++){const i=this._parsers[s];if(i.test(t)){r=i.parse(t),e=!0;break}}e||(r={src:t})}return r.format||(r.format=r.src.split(".").pop()),r.alias||(r.alias=i),(this._basePath||this._rootPath)&&(r.src=$t.toAbsolute(r.src,this._basePath,this._rootPath)),r.src=this._appendDefaultSearchParams(r.src),r.data=null!=(e=r.data)?e:s,r}));i.forEach((t=>{this._assetMap[t]=r}))}resolveBundle(t){const e=ca(t);t=ha(t);const s={};return t.forEach((t=>{const e=this._bundles[t];if(e){const i=this.resolve(e),r={};for(const e in i){const s=i[e];r[this._extractAssetIdFromBundle(t,e)]=s}s[t]=r}})),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if("string"!=typeof t){const t={};for(const s in e)t[s]=e[s].src;return t}return e.src}resolve(t){const e=ca(t);t=ha(t);const s={};return t.forEach((t=>{var e;if(!this._resolverHash[t])if(this._assetMap[t]){let s=this._assetMap[t];const i=this._getPreferredOrder(s),r=s[0];null==i||i.priority.forEach((t=>{i.params[t].forEach((e=>{const i=s.filter((s=>!!s[t]&&s[t]===e));i.length&&(s=i)}))})),this._resolverHash[t]=null!=(e=s[0])?e:r}else{let e=t;(this._basePath||this._rootPath)&&(e=$t.toAbsolute(e,this._basePath,this._rootPath)),e=this._appendDefaultSearchParams(e),this._resolverHash[t]={src:e}}s[t]=this._resolverHash[t]})),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const e=t[0],s=this._preferredOrder.find((t=>t.params.format.includes(e.format)));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;return`${t}${/\?/.test(t)?"&":"?"}${this._defaultSearchParams}`}}class La{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Na,this.loader=new fa,this.cache=pa,this._backgroundLoader=new na(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var e,s,i,r;if(this._initialized)return void console.warn("[Assets]AssetManager already initialized, did you load before calling this Asset.init()?");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 e=t.manifest;"string"==typeof e&&(e=await this.load(e)),this.resolver.addManifest(e)}const n=null!=(s=null==(e=t.texturePreference)?void 0:e.resolution)?s:1,a="number"==typeof n?[n]:n;let o=[];if(null!=(i=t.texturePreference)&&i.format){const e=null==(r=t.texturePreference)?void 0:r.format;o="string"==typeof e?[e]:e;for(const t of this._detections)await t.test()||(o=await t.remove(o))}else for(const t of this._detections)await t.test()&&(o=await t.add(o));this.resolver.prefer({params:{format:o,resolution:a}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,s){this.resolver.add(t,e,s)}async load(t,e){this._initialized||await this.init();const s=ca(t),i=ha(t).map((t=>"string"!=typeof t?(this.resolver.add(t.src,t),t.src):(this.resolver.hasKey(t)||this.resolver.add(t,t),t))),r=this.resolver.resolve(i),n=await this._mapLoadToResolve(r,e);return s?n[i[0]]:n}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let s=!1;"string"==typeof t&&(s=!0,t=[t]);const i=this.resolver.resolveBundle(t),r={},n=Object.keys(i);let a=0,o=0;const h=()=>{null==e||e(++a/o)},l=n.map((t=>{const e=i[t];return o+=Object.keys(e).length,this._mapLoadToResolve(e,h).then((e=>{r[t]=e}))}));return await Promise.all(l),s?r[t[0]]:r}async backgroundLoad(t){this._initialized||await this.init(),"string"==typeof t&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),"string"==typeof t&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach((t=>{this._backgroundLoader.add(Object.values(t))}))}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if("string"==typeof t)return pa.get(t);const e={};for(let s=0;s<t.length;s++)e[s]=pa.get(t[s]);return e}async _mapLoadToResolve(t,e){const s=Object.values(t),i=Object.keys(t);this._backgroundLoader.active=!1;const r=await this.loader.load(s,e);this._backgroundLoader.active=!0;const n={};return s.forEach(((t,e)=>{const s=r[t.src],a=[t.src];t.alias&&a.push(...t.alias),n[i[e]]=s,pa.set(a,s)})),n}async unload(t){this._initialized||await this.init();const e=ha(t).map((t=>"string"!=typeof t?t.src:t)),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=ha(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map((t=>this._unloadFromResolved(e[t])));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach((t=>{pa.remove(t.src)})),await this.loader.unload(e)}get detections(){return this._detections}get preferWorkers(){return Fa.config.preferWorkers}set preferWorkers(t){Kt("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((e=>e in t)).forEach((s=>{e.config[s]=t[s]}))}))}}const Ga=new La;os.handleByList(rs.LoadParser,Ga.loader.parsers).handleByList(rs.ResolveParser,Ga.resolver.parsers).handleByList(rs.CacheParser,Ga.cache.parsers).handleByList(rs.DetectionParser,Ga.detections);const Ua={extension:rs.CacheParser,test:t=>Array.isArray(t)&&t.every((t=>t instanceof Wi)),getCacheableAssets:(t,e)=>{const s={};return t.forEach((t=>{e.forEach(((e,i)=>{s[t+(0===i?"":i+1)]=e}))})),s}};os.add(Ua);const ka={extension:{type:rs.DetectionParser,priority:1},test:async()=>{if(!globalThis.createImageBitmap)return!1;const t=await A.ADAPTER.fetch("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=").then((t=>t.blob()));return createImageBitmap(t).then((()=>!0),(()=>!1))},add:async t=>[...t,"avif"],remove:async t=>t.filter((t=>"avif"!==t))};os.add(ka);const Xa={extension:{type:rs.DetectionParser,priority:0},test:async()=>{if(!globalThis.createImageBitmap)return!1;const t=await A.ADAPTER.fetch("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=").then((t=>t.blob()));return createImageBitmap(t).then((()=>!0),(()=>!1))},add:async t=>[...t,"webp"],remove:async t=>t.filter((t=>"webp"!==t))};os.add(Xa);const Ha=["png","jpg","jpeg"],Va={extension:{type:rs.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async t=>[...t,...Ha],remove:async t=>t.filter((t=>!Ha.includes(t)))};os.add(Va);const za={extension:rs.ResolveParser,test:Fa.test,parse:t=>{var e,s;return{resolution:parseFloat(null!=(s=null==(e=A.RETINA_PREFIX.exec(t))?void 0:e[1])?s:"1"),format:t.split(".").pop(),src:t}}};os.add(za);var Wa=(t=>(t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t))(Wa||{});const Ya={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,35986:1,34798:1,37808:1};let ja,$a;function qa(){$a={s3tc:ja.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:ja.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:ja.getExtension("WEBGL_compressed_texture_etc"),etc1:ja.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:ja.getExtension("WEBGL_compressed_texture_pvrtc")||ja.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:ja.getExtension("WEBGL_compressed_texture_atc"),astc:ja.getExtension("WEBGL_compressed_texture_astc")}}const Ka={extension:{type:rs.DetectionParser,priority:2},test:async()=>{const t=A.ADAPTER.createCanvas().getContext("webgl");return t?(ja=t,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async t=>{$a||qa();const e=[];for(const t in $a)!$a[t]||e.push(t);return[...e,...t]},remove:async t=>($a||qa(),t.filter((t=>!(t in $a))))};os.add(Ka);class Za extends gs{constructor(t,e={width:1,height:1,autoLoad:!0}){let s,i;"string"==typeof t?(s=t,i=new Uint8Array):(s=null,i=t),super(i,e),this.origin=s,this.buffer=i?new hs(i):null,this._load=null,this.loaded=!1,null!==this.origin&&!1!==e.autoLoad&&this.load(),null===this.origin&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return 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 hs(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)))),this._load}}class Qa extends Za{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=Qa._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||Qa._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,s){const i=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;for(let t=0,e=this.levels;t<e;t++){const{levelID:e,levelWidth:s,levelHeight:r,levelBuffer:n}=this._levelBuffers[t];i.compressedTexImage2D(i.TEXTURE_2D,e,this.format,s,r,0,n)}return!0}onBlobLoaded(){this._levelBuffers=Qa._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>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t>=36196)return"etc1";if(t>=35986&&t<=34798)return"atc";throw new Error("Invalid (compressed) texture format given!")}static _createLevelBuffers(t,e,s,i,r,n,a){const o=new Array(s);let h=t.byteOffset,l=n,u=a,d=l+i-1&~(i-1),c=u+r-1&~(r-1),p=d*c*Ya[e];for(let n=0;n<s;n++)o[n]={levelID:n,levelWidth:s>1?l:d,levelHeight:s>1?u:c,levelBuffer:new Uint8Array(t.buffer,h,p)},h+=p,l=l>>1||1,u=u>>1||1,d=l+i-1&~(i-1),c=u+r-1&~(r-1),p=d*c*Ya[e];return o}}const Ja=124,to=3,eo=4,so=7,io=19,ro=2,no=0,ao=1,oo=2,ho=3;var lo=(t=>(t[t.DXGI_FORMAT_UNKNOWN=0]="DXGI_FORMAT_UNKNOWN",t[t.DXGI_FORMAT_R32G32B32A32_TYPELESS=1]="DXGI_FORMAT_R32G32B32A32_TYPELESS",t[t.DXGI_FORMAT_R32G32B32A32_FLOAT=2]="DXGI_FORMAT_R32G32B32A32_FLOAT",t[t.DXGI_FORMAT_R32G32B32A32_UINT=3]="DXGI_FORMAT_R32G32B32A32_UINT",t[t.DXGI_FORMAT_R32G32B32A32_SINT=4]="DXGI_FORMAT_R32G32B32A32_SINT",t[t.DXGI_FORMAT_R32G32B32_TYPELESS=5]="DXGI_FORMAT_R32G32B32_TYPELESS",t[t.DXGI_FORMAT_R32G32B32_FLOAT=6]="DXGI_FORMAT_R32G32B32_FLOAT",t[t.DXGI_FORMAT_R32G32B32_UINT=7]="DXGI_FORMAT_R32G32B32_UINT",t[t.DXGI_FORMAT_R32G32B32_SINT=8]="DXGI_FORMAT_R32G32B32_SINT",t[t.DXGI_FORMAT_R16G16B16A16_TYPELESS=9]="DXGI_FORMAT_R16G16B16A16_TYPELESS",t[t.DXGI_FORMAT_R16G16B16A16_FLOAT=10]="DXGI_FORMAT_R16G16B16A16_FLOAT",t[t.DXGI_FORMAT_R16G16B16A16_UNORM=11]="DXGI_FORMAT_R16G16B16A16_UNORM",t[t.DXGI_FORMAT_R16G16B16A16_UINT=12]="DXGI_FORMAT_R16G16B16A16_UINT",t[t.DXGI_FORMAT_R16G16B16A16_SNORM=13]="DXGI_FORMAT_R16G16B16A16_SNORM",t[t.DXGI_FORMAT_R16G16B16A16_SINT=14]="DXGI_FORMAT_R16G16B16A16_SINT",t[t.DXGI_FORMAT_R32G32_TYPELESS=15]="DXGI_FORMAT_R32G32_TYPELESS",t[t.DXGI_FORMAT_R32G32_FLOAT=16]="DXGI_FORMAT_R32G32_FLOAT",t[t.DXGI_FORMAT_R32G32_UINT=17]="DXGI_FORMAT_R32G32_UINT",t[t.DXGI_FORMAT_R32G32_SINT=18]="DXGI_FORMAT_R32G32_SINT",t[t.DXGI_FORMAT_R32G8X24_TYPELESS=19]="DXGI_FORMAT_R32G8X24_TYPELESS",t[t.DXGI_FORMAT_D32_FLOAT_S8X24_UINT=20]="DXGI_FORMAT_D32_FLOAT_S8X24_UINT",t[t.DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS=21]="DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS",t[t.DXGI_FORMAT_X32_TYPELESS_G8X24_UINT=22]="DXGI_FORMAT_X32_TYPELESS_G8X24_UINT",t[t.DXGI_FORMAT_R10G10B10A2_TYPELESS=23]="DXGI_FORMAT_R10G10B10A2_TYPELESS",t[t.DXGI_FORMAT_R10G10B10A2_UNORM=24]="DXGI_FORMAT_R10G10B10A2_UNORM",t[t.DXGI_FORMAT_R10G10B10A2_UINT=25]="DXGI_FORMAT_R10G10B10A2_UINT",t[t.DXGI_FORMAT_R11G11B10_FLOAT=26]="DXGI_FORMAT_R11G11B10_FLOAT",t[t.DXGI_FORMAT_R8G8B8A8_TYPELESS=27]="DXGI_FORMAT_R8G8B8A8_TYPELESS",t[t.DXGI_FORMAT_R8G8B8A8_UNORM=28]="DXGI_FORMAT_R8G8B8A8_UNORM",t[t.DXGI_FORMAT_R8G8B8A8_UNORM_SRGB=29]="DXGI_FORMAT_R8G8B8A8_UNORM_SRGB",t[t.DXGI_FORMAT_R8G8B8A8_UINT=30]="DXGI_FORMAT_R8G8B8A8_UINT",t[t.DXGI_FORMAT_R8G8B8A8_SNORM=31]="DXGI_FORMAT_R8G8B8A8_SNORM",t[t.DXGI_FORMAT_R8G8B8A8_SINT=32]="DXGI_FORMAT_R8G8B8A8_SINT",t[t.DXGI_FORMAT_R16G16_TYPELESS=33]="DXGI_FORMAT_R16G16_TYPELESS",t[t.DXGI_FORMAT_R16G16_FLOAT=34]="DXGI_FORMAT_R16G16_FLOAT",t[t.DXGI_FORMAT_R16G16_UNORM=35]="DXGI_FORMAT_R16G16_UNORM",t[t.DXGI_FORMAT_R16G16_UINT=36]="DXGI_FORMAT_R16G16_UINT",t[t.DXGI_FORMAT_R16G16_SNORM=37]="DXGI_FORMAT_R16G16_SNORM",t[t.DXGI_FORMAT_R16G16_SINT=38]="DXGI_FORMAT_R16G16_SINT",t[t.DXGI_FORMAT_R32_TYPELESS=39]="DXGI_FORMAT_R32_TYPELESS",t[t.DXGI_FORMAT_D32_FLOAT=40]="DXGI_FORMAT_D32_FLOAT",t[t.DXGI_FORMAT_R32_FLOAT=41]="DXGI_FORMAT_R32_FLOAT",t[t.DXGI_FORMAT_R32_UINT=42]="DXGI_FORMAT_R32_UINT",t[t.DXGI_FORMAT_R32_SINT=43]="DXGI_FORMAT_R32_SINT",t[t.DXGI_FORMAT_R24G8_TYPELESS=44]="DXGI_FORMAT_R24G8_TYPELESS",t[t.DXGI_FORMAT_D24_UNORM_S8_UINT=45]="DXGI_FORMAT_D24_UNORM_S8_UINT",t[t.DXGI_FORMAT_R24_UNORM_X8_TYPELESS=46]="DXGI_FORMAT_R24_UNORM_X8_TYPELESS",t[t.DXGI_FORMAT_X24_TYPELESS_G8_UINT=47]="DXGI_FORMAT_X24_TYPELESS_G8_UINT",t[t.DXGI_FORMAT_R8G8_TYPELESS=48]="DXGI_FORMAT_R8G8_TYPELESS",t[t.DXGI_FORMAT_R8G8_UNORM=49]="DXGI_FORMAT_R8G8_UNORM",t[t.DXGI_FORMAT_R8G8_UINT=50]="DXGI_FORMAT_R8G8_UINT",t[t.DXGI_FORMAT_R8G8_SNORM=51]="DXGI_FORMAT_R8G8_SNORM",t[t.DXGI_FORMAT_R8G8_SINT=52]="DXGI_FORMAT_R8G8_SINT",t[t.DXGI_FORMAT_R16_TYPELESS=53]="DXGI_FORMAT_R16_TYPELESS",t[t.DXGI_FORMAT_R16_FLOAT=54]="DXGI_FORMAT_R16_FLOAT",t[t.DXGI_FORMAT_D16_UNORM=55]="DXGI_FORMAT_D16_UNORM",t[t.DXGI_FORMAT_R16_UNORM=56]="DXGI_FORMAT_R16_UNORM",t[t.DXGI_FORMAT_R16_UINT=57]="DXGI_FORMAT_R16_UINT",t[t.DXGI_FORMAT_R16_SNORM=58]="DXGI_FORMAT_R16_SNORM",t[t.DXGI_FORMAT_R16_SINT=59]="DXGI_FORMAT_R16_SINT",t[t.DXGI_FORMAT_R8_TYPELESS=60]="DXGI_FORMAT_R8_TYPELESS",t[t.DXGI_FORMAT_R8_UNORM=61]="DXGI_FORMAT_R8_UNORM",t[t.DXGI_FORMAT_R8_UINT=62]="DXGI_FORMAT_R8_UINT",t[t.DXGI_FORMAT_R8_SNORM=63]="DXGI_FORMAT_R8_SNORM",t[t.DXGI_FORMAT_R8_SINT=64]="DXGI_FORMAT_R8_SINT",t[t.DXGI_FORMAT_A8_UNORM=65]="DXGI_FORMAT_A8_UNORM",t[t.DXGI_FORMAT_R1_UNORM=66]="DXGI_FORMAT_R1_UNORM",t[t.DXGI_FORMAT_R9G9B9E5_SHAREDEXP=67]="DXGI_FORMAT_R9G9B9E5_SHAREDEXP",t[t.DXGI_FORMAT_R8G8_B8G8_UNORM=68]="DXGI_FORMAT_R8G8_B8G8_UNORM",t[t.DXGI_FORMAT_G8R8_G8B8_UNORM=69]="DXGI_FORMAT_G8R8_G8B8_UNORM",t[t.DXGI_FORMAT_BC1_TYPELESS=70]="DXGI_FORMAT_BC1_TYPELESS",t[t.DXGI_FORMAT_BC1_UNORM=71]="DXGI_FORMAT_BC1_UNORM",t[t.DXGI_FORMAT_BC1_UNORM_SRGB=72]="DXGI_FORMAT_BC1_UNORM_SRGB",t[t.DXGI_FORMAT_BC2_TYPELESS=73]="DXGI_FORMAT_BC2_TYPELESS",t[t.DXGI_FORMAT_BC2_UNORM=74]="DXGI_FORMAT_BC2_UNORM",t[t.DXGI_FORMAT_BC2_UNORM_SRGB=75]="DXGI_FORMAT_BC2_UNORM_SRGB",t[t.DXGI_FORMAT_BC3_TYPELESS=76]="DXGI_FORMAT_BC3_TYPELESS",t[t.DXGI_FORMAT_BC3_UNORM=77]="DXGI_FORMAT_BC3_UNORM",t[t.DXGI_FORMAT_BC3_UNORM_SRGB=78]="DXGI_FORMAT_BC3_UNORM_SRGB",t[t.DXGI_FORMAT_BC4_TYPELESS=79]="DXGI_FORMAT_BC4_TYPELESS",t[t.DXGI_FORMAT_BC4_UNORM=80]="DXGI_FORMAT_BC4_UNORM",t[t.DXGI_FORMAT_BC4_SNORM=81]="DXGI_FORMAT_BC4_SNORM",t[t.DXGI_FORMAT_BC5_TYPELESS=82]="DXGI_FORMAT_BC5_TYPELESS",t[t.DXGI_FORMAT_BC5_UNORM=83]="DXGI_FORMAT_BC5_UNORM",t[t.DXGI_FORMAT_BC5_SNORM=84]="DXGI_FORMAT_BC5_SNORM",t[t.DXGI_FORMAT_B5G6R5_UNORM=85]="DXGI_FORMAT_B5G6R5_UNORM",t[t.DXGI_FORMAT_B5G5R5A1_UNORM=86]="DXGI_FORMAT_B5G5R5A1_UNORM",t[t.DXGI_FORMAT_B8G8R8A8_UNORM=87]="DXGI_FORMAT_B8G8R8A8_UNORM",t[t.DXGI_FORMAT_B8G8R8X8_UNORM=88]="DXGI_FORMAT_B8G8R8X8_UNORM",t[t.DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM=89]="DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM",t[t.DXGI_FORMAT_B8G8R8A8_TYPELESS=90]="DXGI_FORMAT_B8G8R8A8_TYPELESS",t[t.DXGI_FORMAT_B8G8R8A8_UNORM_SRGB=91]="DXGI_FORMAT_B8G8R8A8_UNORM_SRGB",t[t.DXGI_FORMAT_B8G8R8X8_TYPELESS=92]="DXGI_FORMAT_B8G8R8X8_TYPELESS",t[t.DXGI_FORMAT_B8G8R8X8_UNORM_SRGB=93]="DXGI_FORMAT_B8G8R8X8_UNORM_SRGB",t[t.DXGI_FORMAT_BC6H_TYPELESS=94]="DXGI_FORMAT_BC6H_TYPELESS",t[t.DXGI_FORMAT_BC6H_UF16=95]="DXGI_FORMAT_BC6H_UF16",t[t.DXGI_FORMAT_BC6H_SF16=96]="DXGI_FORMAT_BC6H_SF16",t[t.DXGI_FORMAT_BC7_TYPELESS=97]="DXGI_FORMAT_BC7_TYPELESS",t[t.DXGI_FORMAT_BC7_UNORM=98]="DXGI_FORMAT_BC7_UNORM",t[t.DXGI_FORMAT_BC7_UNORM_SRGB=99]="DXGI_FORMAT_BC7_UNORM_SRGB",t[t.DXGI_FORMAT_AYUV=100]="DXGI_FORMAT_AYUV",t[t.DXGI_FORMAT_Y410=101]="DXGI_FORMAT_Y410",t[t.DXGI_FORMAT_Y416=102]="DXGI_FORMAT_Y416",t[t.DXGI_FORMAT_NV12=103]="DXGI_FORMAT_NV12",t[t.DXGI_FORMAT_P010=104]="DXGI_FORMAT_P010",t[t.DXGI_FORMAT_P016=105]="DXGI_FORMAT_P016",t[t.DXGI_FORMAT_420_OPAQUE=106]="DXGI_FORMAT_420_OPAQUE",t[t.DXGI_FORMAT_YUY2=107]="DXGI_FORMAT_YUY2",t[t.DXGI_FORMAT_Y210=108]="DXGI_FORMAT_Y210",t[t.DXGI_FORMAT_Y216=109]="DXGI_FORMAT_Y216",t[t.DXGI_FORMAT_NV11=110]="DXGI_FORMAT_NV11",t[t.DXGI_FORMAT_AI44=111]="DXGI_FORMAT_AI44",t[t.DXGI_FORMAT_IA44=112]="DXGI_FORMAT_IA44",t[t.DXGI_FORMAT_P8=113]="DXGI_FORMAT_P8",t[t.DXGI_FORMAT_A8P8=114]="DXGI_FORMAT_A8P8",t[t.DXGI_FORMAT_B4G4R4A4_UNORM=115]="DXGI_FORMAT_B4G4R4A4_UNORM",t[t.DXGI_FORMAT_P208=116]="DXGI_FORMAT_P208",t[t.DXGI_FORMAT_V208=117]="DXGI_FORMAT_V208",t[t.DXGI_FORMAT_V408=118]="DXGI_FORMAT_V408",t[t.DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE=119]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE",t[t.DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE=120]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE",t[t.DXGI_FORMAT_FORCE_UINT=121]="DXGI_FORMAT_FORCE_UINT",t))(lo||{}),uo=(t=>(t[t.DDS_DIMENSION_TEXTURE1D=2]="DDS_DIMENSION_TEXTURE1D",t[t.DDS_DIMENSION_TEXTURE2D=3]="DDS_DIMENSION_TEXTURE2D",t[t.DDS_DIMENSION_TEXTURE3D=6]="DDS_DIMENSION_TEXTURE3D",t))(uo||{});const co={827611204:Wa.COMPRESSED_RGBA_S3TC_DXT1_EXT,861165636:Wa.COMPRESSED_RGBA_S3TC_DXT3_EXT,894720068:Wa.COMPRESSED_RGBA_S3TC_DXT5_EXT},po={70:Wa.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Wa.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Wa.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Wa.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Wa.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Wa.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Wa.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Wa.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Wa.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT};function fo(t){const e=new Uint32Array(t);if(542327876!==e[0])throw new Error("Invalid DDS file magic word");const s=new Uint32Array(t,0,Ja/Uint32Array.BYTES_PER_ELEMENT),i=s[to],r=s[eo],n=s[so],a=new Uint32Array(t,io*Uint32Array.BYTES_PER_ELEMENT,32/Uint32Array.BYTES_PER_ELEMENT),o=a[1];if(4&o){const s=a[ro];if(808540228!==s){const e=co[s],a=new Uint8Array(t,128);return[new Qa(a,{format:e,width:r,height:i,levels:n})]}const o=128,h=new Uint32Array(e.buffer,o,20/Uint32Array.BYTES_PER_ELEMENT),l=h[no],u=h[ao],d=h[oo],c=h[ho],p=po[l];if(void 0===p)throw new Error(`DDSParser cannot parse texture data with DXGI format ${l}`);if(4===d)throw new Error("DDSParser does not support cubemap textures");if(6===u)throw new Error("DDSParser does not supported 3D texture data");const f=new Array,m=148;if(1===c)f.push(new Uint8Array(t,m));else{const e=Ya[p];let s=0,a=r,o=i;for(let t=0;t<n;t++){s+=Math.max(1,a+3&-4)*Math.max(1,o+3&-4)*e,a>>>=1,o>>>=1}let h=m;for(let e=0;e<c;e++)f.push(new Uint8Array(t,h,s)),h+=s}return f.map((t=>new Qa(t,{format:p,width:r,height:i,levels:n})))}throw 64&o?new Error("DDSParser does not support uncompressed texture data."):512&o?new Error("DDSParser does not supported YUV uncompressed texture data."):131072&o?new Error("DDSParser does not support single-channel (lumninance) texture data!"):2&o?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 mo=[171,75,84,88,32,49,49,187,13,10,26,10],_o=12,go=16,xo=24,vo=28,yo=36,To=40,bo=44,Eo=48,Ao=52,Ro=56,So=60,wo=64,Io={[u.UNSIGNED_BYTE]:1,[u.UNSIGNED_SHORT]:2,[u.INT]:4,[u.UNSIGNED_INT]:4,[u.FLOAT]:4,[u.HALF_FLOAT]:8},Mo={[h.RGBA]:4,[h.RGB]:3,[h.RG]:2,[h.RED]:1,[h.LUMINANCE]:1,[h.LUMINANCE_ALPHA]:2,[h.ALPHA]:1},Co={[u.UNSIGNED_SHORT_4_4_4_4]:2,[u.UNSIGNED_SHORT_5_5_5_1]:2,[u.UNSIGNED_SHORT_5_6_5]:2};function Do(t,e,s=!1){const i=new DataView(e);if(!function(t,e){for(let s=0;s<mo.length;s++)if(e.getUint8(s)!==mo[s])return console.error(`${t} is not a valid *.ktx file!`),!1;return!0}(t,i))return null;const r=67305985===i.getUint32(_o,!0),n=i.getUint32(go,r),a=i.getUint32(xo,r),o=i.getUint32(vo,r),h=i.getUint32(yo,r),l=i.getUint32(To,r)||1,d=i.getUint32(bo,r)||1,c=i.getUint32(Eo,r)||1,p=i.getUint32(Ao,r),f=i.getUint32(Ro,r),m=i.getUint32(So,r);if(0===l||1!==d)throw new Error("Only 2D textures are supported");if(1!==p)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(1!==c)throw new Error("WebGL does not support array textures");const _=h+3&-4,g=l+3&-4,x=new Array(c);let v,y=h*l;if(0===n&&(y=_*g),v=0!==n?Io[n]?Io[n]*Mo[a]:Co[n]:Ya[o],void 0===v)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const T=s?function(t,e,s){const i=new Map;let r=0;for(;r<e;){const n=t.getUint32(wo+r,s),a=wo+r+4,o=3-(n+3)%4;if(0===n||n>e-r){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let h=0;for(;h<n&&0!==t.getUint8(a+h);h++);if(-1===h){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const l=(new TextDecoder).decode(new Uint8Array(t.buffer,a,h)),u=new DataView(t.buffer,a+h+1,n-h-1);i.set(l,u),r+=4+n+o}return i}(i,m,r):null;let b=y*v,E=h,A=l,R=_,S=g,w=wo+m;for(let t=0;t<f;t++){const s=i.getUint32(w,r);let a=w+4;for(let s=0;s<c;s++){let i=x[s];i||(i=x[s]=new Array(f)),i[t]={levelID:t,levelWidth:f>1||0!==n?E:R,levelHeight:f>1||0!==n?A:S,levelBuffer:new Uint8Array(e,a,b)},a+=b}w+=s+4,w=w%4!=0?w+4-w%4:w,E=E>>1||1,A=A>>1||1,R=E+4-1&-4,S=A+4-1&-4,b=R*S*v}return 0!==n?{uncompressed:x.map((t=>{let e=t[0].levelBuffer,s=!1;return n===u.FLOAT?e=new Float32Array(t[0].levelBuffer.buffer,t[0].levelBuffer.byteOffset,t[0].levelBuffer.byteLength/4):n===u.UNSIGNED_INT?(s=!0,e=new Uint32Array(t[0].levelBuffer.buffer,t[0].levelBuffer.byteOffset,t[0].levelBuffer.byteLength/4)):n===u.INT&&(s=!0,e=new Int32Array(t[0].levelBuffer.buffer,t[0].levelBuffer.byteOffset,t[0].levelBuffer.byteLength/4)),{resource:new gs(e,{width:t[0].levelWidth,height:t[0].levelHeight}),type:n,format:s?Po(a):a}})),kvData:T}:{compressed:x.map((t=>new Qa(null,{format:o,width:h,height:l,levels:f,levelBuffers:t}))),kvData:T}}function Po(t){switch(t){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 t}}const Oo={extension:{type:rs.LoadParser,priority:ma.High},name:"loadDDS",test:t=>oa(t,".dds"),async load(t,e,s){const i=fo(await(await A.ADAPTER.fetch(t)).arrayBuffer()).map((i=>Ca(new ys(i,bt({mipmap:f.OFF,alphaMode:m.NO_PREMULTIPLIED_ALPHA,resolution:ss(t)},e.data)),s,t)));return 1===i.length?i[0]:i},unload(t){Array.isArray(t)?t.forEach((t=>t.destroy(!0))):t.destroy(!0)}};os.add(Oo);const Fo={extension:{type:rs.LoadParser,priority:ma.High},name:"loadKTX",test:t=>oa(t,".ktx"),async load(t,e,s){const i=await(await A.ADAPTER.fetch(t)).arrayBuffer(),{compressed:r,uncompressed:n,kvData:a}=Do(t,i),o=null!=r?r:n,h=bt({mipmap:f.OFF,alphaMode:m.NO_PREMULTIPLIED_ALPHA,resolution:ss(t)},e.data),l=o.map((e=>{o===n&&Object.assign(h,{type:e.type,format:e.format});const i=new ys(e,h);return i.ktxKeyValueData=a,Ca(i,s,t)}));return 1===l.length?l[0]:l},unload(t){Array.isArray(t)?t.forEach((t=>t.destroy(!0))):t.destroy(!0)}};os.add(Fo);const Bo={extension:rs.ResolveParser,test:t=>{const e=t.split("?")[0].split(".").pop();return["basis","ktx","dds"].includes(e)},parse:t=>{var e,s,i,r;if("ktx"===t.split("?")[0].split(".").pop()){const i=[".s3tc.ktx",".s3tc_sRGB.ktx",".etc.ktx",".etc1.ktx",".pvrt.ktx",".atc.ktx",".astc.ktx"];if(i.some((e=>t.endsWith(e))))return{resolution:parseFloat(null!=(s=null==(e=A.RETINA_PREFIX.exec(t))?void 0:e[1])?s:"1"),format:i.find((e=>t.endsWith(e))),src:t}}return{resolution:parseFloat(null!=(r=null==(i=A.RETINA_PREFIX.exec(t))?void 0:i[1])?r:"1"),format:t.split(".").pop(),src:t}}};os.add(Bo);const No=new Ls,Lo=class{constructor(t){this.renderer=t}async image(t,e,s){const i=new Image;return i.src=await this.base64(t,e,s),i}async base64(t,e,s){const i=this.canvas(t);if(void 0!==i.toBlob)return new Promise(((t,r)=>{i.toBlob((e=>{if(!e)return void r(new Error("ICanvas.toBlob failed!"));const s=new FileReader;s.onload=()=>t(s.result),s.onerror=r,s.readAsDataURL(e)}),e,s)}));if(void 0!==i.toDataURL)return i.toDataURL(e,s);if(void 0!==i.convertToBlob){const t=await i.convertToBlob({type:e,quality:s});return new Promise(((e,s)=>{const i=new FileReader;i.onload=()=>e(i.result),i.onerror=s,i.readAsDataURL(t)}))}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const{pixels:s,width:i,height:r,flipY:n}=this._rawPixels(t,e);n&&Lo._flipY(s,i,r),Lo._unpremultiplyAlpha(s);const a=new qe(i,r,1),o=new ImageData(new Uint8ClampedArray(s.buffer),i,r);return a.context.putImageData(o,0,0),a.canvas}pixels(t,e){const{pixels:s,width:i,height:r,flipY:n}=this._rawPixels(t,e);return n&&Lo._flipY(s,i,r),Lo._unpremultiplyAlpha(s),s}_rawPixels(t,e){const s=this.renderer;if(!s)throw new Error("The Extract has already been destroyed");let i,r,n=!1,a=!1;if(t&&(t instanceof Yi?r=t:(r=s.generateTexture(t,{resolution:s.resolution,multisample:s.multisample}),a=!0)),r){if(i=r.baseTexture.resolution,e=null!=e?e:r.frame,n=!1,!a){s.renderTexture.bind(r);const t=r.framebuffer.glFramebuffers[s.CONTEXT_UID];t.blitFramebuffer&&s.framebuffer.bind(t.blitFramebuffer)}}else i=s.resolution,e||((e=No).width=s.width/i,e.height=s.height/i),n=!0,s.renderTexture.bind();const o=Math.round(e.width*i),h=Math.round(e.height*i),l=new Uint8Array(4*o*h),u=s.gl;return u.readPixels(Math.round(e.x*i),Math.round(e.y*i),o,h,u.RGBA,u.UNSIGNED_BYTE,l),a&&(null==r||r.destroy(!0)),{pixels:l,width:o,height:h,flipY:n}}destroy(){this.renderer=null}static _flipY(t,e,s){const i=e<<2,r=s>>1,n=new Uint8Array(i);for(let e=0;e<r;e++){const r=e*i,a=(s-e-1)*i;n.set(t.subarray(r,r+i)),t.copyWithin(r,a,a+i),t.set(n,a)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const e=t.length;for(let s=0;s<e;s+=4){const e=t[s+3];if(0!==e){const i=255.001/e;t[s]=t[s]*i+.5,t[s+1]=t[s+1]*i+.5,t[s+2]=t[s+2]*i+.5}}}};let Go=Lo;Go.extension={name:"extract",type:rs.RendererSystem},os.add(Go);const Uo={build(t){const e=t.points;let s,i,r,n,a,o;if(t.type===Fs.CIRC){const e=t.shape;s=e.x,i=e.y,a=o=e.radius,r=n=0}else if(t.type===Fs.ELIP){const e=t.shape;s=e.x,i=e.y,a=e.width,o=e.height,r=n=0}else{const e=t.shape,h=e.width/2,l=e.height/2;s=e.x+h,i=e.y+l,a=o=Math.max(0,Math.min(e.radius,Math.min(h,l))),r=h-a,n=l-o}if(!(a>=0&&o>=0&&r>=0&&n>=0))return void(e.length=0);const h=Math.ceil(2.3*Math.sqrt(a+o)),l=8*h+(r?4:0)+(n?4:0);if(e.length=l,0===l)return;if(0===h)return e.length=8,e[0]=e[6]=s+r,e[1]=e[3]=i+n,e[2]=e[4]=s-r,void(e[5]=e[7]=i-n);let u=0,d=4*h+(r?2:0)+2,c=d,p=l;{const t=r+a,o=n,h=s+t,l=s-t,f=i+o;if(e[u++]=h,e[u++]=f,e[--d]=f,e[--d]=l,n){const t=i-o;e[c++]=l,e[c++]=t,e[--p]=t,e[--p]=h}}for(let t=1;t<h;t++){const l=Math.PI/2*(t/h),f=r+Math.cos(l)*a,m=n+Math.sin(l)*o,_=s+f,g=s-f,x=i+m,v=i-m;e[u++]=_,e[u++]=x,e[--d]=x,e[--d]=g,e[c++]=g,e[c++]=v,e[--p]=v,e[--p]=_}{const t=n+o,a=s+r,h=s-r,l=i+t,d=i-t;e[u++]=a,e[u++]=l,e[--p]=d,e[--p]=a,r&&(e[u++]=h,e[u++]=l,e[--p]=d,e[--p]=h)}},triangulate(t,e){const s=t.points,i=e.points,r=e.indices;if(0===s.length)return;let n=i.length/2;const a=n;let o,h;if(t.type!==Fs.RREC){const e=t.shape;o=e.x,h=e.y}else{const e=t.shape;o=e.x+e.width/2,h=e.y+e.height/2}const l=t.matrix;i.push(t.matrix?l.a*o+l.c*h+l.tx:o,t.matrix?l.b*o+l.d*h+l.ty:h),n++,i.push(s[0],s[1]);for(let t=2;t<s.length;t+=2)i.push(s[t],s[t+1]),r.push(n++,a,n);r.push(a+1,a,n)}};function ko(t,e=!1){const s=t.length;if(s<6)return;let i=0;for(let e=0,r=t[s-2],n=t[s-1];e<s;e+=2){const s=t[e],a=t[e+1];i+=(s-r)*(a+n),r=s,n=a}if(!e&&i>0||e&&i<=0){const e=s/2;for(let i=e+e%2;i<s;i+=2){const e=s-i-2,r=s-i-1,n=i,a=i+1;[t[e],t[n]]=[t[n],t[e]],[t[r],t[a]]=[t[a],t[r]]}}}const Xo={build(t){t.points=t.shape.points.slice()},triangulate(t,e){let s=t.points;const i=t.holes,r=e.points,n=e.indices;if(s.length>=6){ko(s,!1);const t=[];for(let e=0;e<i.length;e++){const r=i[e];ko(r.points,!0),t.push(s.length/2),s=s.concat(r.points)}const e=Y(s,t,2);if(!e)return;const a=r.length/2;for(let t=0;t<e.length;t+=3)n.push(e[t]+a),n.push(e[t+1]+a),n.push(e[t+2]+a);for(let t=0;t<s.length;t++)r.push(s[t])}}},Ho={build(t){const e=t.shape,s=e.x,i=e.y,r=e.width,n=e.height,a=t.points;a.length=0,r>=0&&n>=0&&a.push(s,i,s+r,i,s+r,i+n,s,i+n)},triangulate(t,e){const s=t.points,i=e.points;if(0===s.length)return;const r=i.length/2;i.push(s[0],s[1],s[2],s[3],s[6],s[7],s[4],s[5]),e.indices.push(r,r+1,r+2,r+1,r+2,r+3)}},Vo={build(t){Uo.build(t)},triangulate(t,e){Uo.triangulate(t,e)}};var zo=(t=>(t.MITER="miter",t.BEVEL="bevel",t.ROUND="round",t))(zo||{}),Wo=(t=>(t.BUTT="butt",t.ROUND="round",t.SQUARE="square",t))(Wo||{});const Yo={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(t,e=20){if(!this.adaptive||!t||isNaN(t))return e;let s=Math.ceil(t/this.maxLength);return s<this.minSegments?s=this.minSegments:s>this.maxSegments&&(s=this.maxSegments),s}},jo=Yo;class $o{static curveTo(t,e,s,i,r,n){const a=n[n.length-2],o=n[n.length-1]-e,h=a-t,l=i-e,u=s-t,d=Math.abs(o*u-h*l);if(d<1e-8||0===r)return(n[n.length-2]!==t||n[n.length-1]!==e)&&n.push(t,e),null;const c=o*o+h*h,p=l*l+u*u,f=o*l+h*u,m=r*Math.sqrt(c)/d,_=r*Math.sqrt(p)/d,g=m*f/c,x=_*f/p,v=m*u+_*h,y=m*l+_*o,T=h*(_+g),b=o*(_+g),E=u*(m+x),A=l*(m+x);return{cx:v+t,cy:y+e,radius:r,startAngle:Math.atan2(b-y,T-v),endAngle:Math.atan2(A-y,E-v),anticlockwise:h*l>u*o}}static arc(t,e,s,i,r,n,a,o,h){const l=a-n,u=Yo._segmentsCount(Math.abs(l)*r,40*Math.ceil(Math.abs(l)/Ds)),d=l/(2*u),c=2*d,p=Math.cos(d),f=Math.sin(d),m=u-1,_=m%1/m;for(let t=0;t<=m;++t){const e=d+n+c*(t+_*t),a=Math.cos(e),o=-Math.sin(e);h.push((p*a+f*o)*r+s,(p*-o+f*a)*r+i)}}}class qo{constructor(){this.reset()}begin(t,e,s){this.reset(),this.style=t,this.start=e,this.attribStart=s}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 Ko{static curveLength(t,e,s,i,r,n,a,o){let h=0,l=0,u=0,d=0,c=0,p=0,f=0,m=0,_=0,g=0,x=0,v=t,y=e;for(let T=1;T<=10;++T)l=T/10,u=l*l,d=u*l,c=1-l,p=c*c,f=p*c,m=f*t+3*p*l*s+3*c*u*r+d*a,_=f*e+3*p*l*i+3*c*u*n+d*o,g=v-m,x=y-_,v=m,y=_,h+=Math.sqrt(g*g+x*x);return h}static curveTo(t,e,s,i,r,n,a){const o=a[a.length-2],h=a[a.length-1];a.length-=2;const l=Yo._segmentsCount(Ko.curveLength(o,h,t,e,s,i,r,n));let u=0,d=0,c=0,p=0,f=0;a.push(o,h);for(let m=1,_=0;m<=l;++m)_=m/l,u=1-_,d=u*u,c=d*u,p=_*_,f=p*_,a.push(c*o+3*d*_*t+3*u*p*s+f*r,c*h+3*d*_*e+3*u*p*i+f*n)}}function Zo(t,e,s,i,r,n,a,o){let h,l;a?(h=i,l=-s):(h=-i,l=s);const u=t-s*r+h,d=e-i*r+l,c=t+s*n+h,p=e+i*n+l;return o.push(u,d,c,p),2}function Qo(t,e,s,i,r,n,a,o){const h=s-t,l=i-e;let u=Math.atan2(h,l),d=Math.atan2(r-t,n-e);o&&u<d?u+=2*Math.PI:!o&&u>d&&(d+=2*Math.PI);let c=u;const p=d-u,f=Math.abs(p),m=Math.sqrt(h*h+l*l),_=1+(15*f*Math.sqrt(m)/Math.PI>>0),g=p/_;if(c+=g,o){a.push(t,e,s,i);for(let s=1,i=c;s<_;s++,i+=g)a.push(t,e,t+Math.sin(i)*m,e+Math.cos(i)*m);a.push(t,e,r,n)}else{a.push(s,i,t,e);for(let s=1,i=c;s<_;s++,i+=g)a.push(t+Math.sin(i)*m,e+Math.cos(i)*m,t,e);a.push(r,n,t,e)}return 2*_}function Jo(t,e){t.lineStyle.native?function(t,e){let s=0;const i=t.shape,r=t.points||i.points,n=i.type!==Fs.POLY||i.closeStroke;if(0===r.length)return;const a=e.points,o=e.indices,h=r.length/2,l=a.length/2;let u=l;for(a.push(r[0],r[1]),s=1;s<h;s++)a.push(r[2*s],r[2*s+1]),o.push(u,u+1),u++;n&&o.push(u,l)}(t,e):function(t,e){const s=t.shape;let i=t.points||s.points.slice();const r=e.closePointEps;if(0===i.length)return;const n=t.lineStyle,a=new Bs(i[0],i[1]),o=new Bs(i[i.length-2],i[i.length-1]),h=s.type!==Fs.POLY||s.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 t=.5*(a.x+o.x),e=.5*(o.y+a.y);i.unshift(t,e),i.push(t,e)}const u=e.points,d=i.length/2;let c=i.length;const p=u.length/2,f=n.width/2,m=f*f,_=n.miterLimit*n.miterLimit;let g=i[0],x=i[1],v=i[2],y=i[3],T=0,b=0,E=-(x-y),A=g-v,R=0,S=0,w=Math.sqrt(E*E+A*A);E/=w,A/=w,E*=f,A*=f;const I=n.alignment,M=2*(1-I),C=2*I;h||(n.cap===Wo.ROUND?c+=Qo(g-E*(M-C)*.5,x-A*(M-C)*.5,g-E*M,x-A*M,g+E*C,x+A*C,u,!0)+2:n.cap===Wo.SQUARE&&(c+=Zo(g,x,E,A,M,C,!0,u))),u.push(g-E*M,x-A*M,g+E*C,x+A*C);for(let t=1;t<d-1;++t){g=i[2*(t-1)],x=i[2*(t-1)+1],v=i[2*t],y=i[2*t+1],T=i[2*(t+1)],b=i[2*(t+1)+1],E=-(x-y),A=g-v,w=Math.sqrt(E*E+A*A),E/=w,A/=w,E*=f,A*=f,R=-(y-b),S=v-T,w=Math.sqrt(R*R+S*S),R/=w,S/=w,R*=f,S*=f;const e=v-g,s=x-y,r=v-T,a=b-y,o=e*r+s*a,h=s*r-a*e,l=h<0;if(Math.abs(h)<.001*Math.abs(o)){u.push(v-E*M,y-A*M,v+E*C,y+A*C),o>=0&&(n.join===zo.ROUND?c+=Qo(v,y,v-E*M,y-A*M,v-R*M,y-S*M,u,!1)+4:c+=2,u.push(v-R*C,y-S*C,v+R*M,y+S*M));continue}const d=(-E+g)*(-A+y)-(-E+v)*(-A+x),p=(-R+T)*(-S+y)-(-R+v)*(-S+b),I=(e*p-r*d)/h,D=(a*d-s*p)/h,P=(I-v)*(I-v)+(D-y)*(D-y),O=v+(I-v)*M,F=y+(D-y)*M,B=v-(I-v)*C,N=y-(D-y)*C,L=l?M:C,G=P<=Math.min(e*e+s*s,r*r+a*a)+L*L*m;let U=n.join;if(U===zo.MITER&&P/m>_&&(U=zo.BEVEL),G)switch(U){case zo.MITER:u.push(O,F,B,N);break;case zo.BEVEL:l?u.push(O,F,v+E*C,y+A*C,O,F,v+R*C,y+S*C):u.push(v-E*M,y-A*M,B,N,v-R*M,y-S*M,B,N),c+=2;break;case zo.ROUND:l?(u.push(O,F,v+E*C,y+A*C),c+=Qo(v,y,v+E*C,y+A*C,v+R*C,y+S*C,u,!0)+4,u.push(O,F,v+R*C,y+S*C)):(u.push(v-E*M,y-A*M,B,N),c+=Qo(v,y,v-E*M,y-A*M,v-R*M,y-S*M,u,!1)+4,u.push(v-R*M,y-S*M,B,N))}else{switch(u.push(v-E*M,y-A*M,v+E*C,y+A*C),U){case zo.MITER:l?u.push(B,N,B,N):u.push(O,F,O,F),c+=2;break;case zo.ROUND:c+=l?Qo(v,y,v+E*C,y+A*C,v+R*C,y+S*C,u,!0)+2:Qo(v,y,v-E*M,y-A*M,v-R*M,y-S*M,u,!1)+2}u.push(v-R*M,y-S*M,v+R*C,y+S*C),c+=2}}g=i[2*(d-2)],x=i[2*(d-2)+1],v=i[2*(d-1)],y=i[2*(d-1)+1],E=-(x-y),A=g-v,w=Math.sqrt(E*E+A*A),E/=w,A/=w,E*=f,A*=f,u.push(v-E*M,y-A*M,v+E*C,y+A*C),h||(n.cap===Wo.ROUND?c+=Qo(v-E*(M-C)*.5,y-A*(M-C)*.5,v-E*M,y-A*M,v+E*C,y+A*C,u,!1)+2:n.cap===Wo.SQUARE&&(c+=Zo(v,y,E,A,M,C,!1,u)));const D=e.indices,P=Yo.epsilon*Yo.epsilon;for(let t=p;t<c+p-2;++t)g=u[2*t],x=u[2*t+1],v=u[2*(t+1)],y=u[2*(t+1)+1],T=u[2*(t+2)],b=u[2*(t+2)+1],!(Math.abs(g*(y-b)+v*(b-x)+T*(x-y))<P)&&D.push(t,t+1,t+2)}(t,e)}class th{static curveLength(t,e,s,i,r,n){const a=t-2*s+r,o=e-2*i+n,h=2*s-2*t,l=2*i-2*e,u=4*(a*a+o*o),d=4*(a*h+o*l),c=h*h+l*l,p=2*Math.sqrt(u+d+c),f=Math.sqrt(u),m=2*u*f,_=2*Math.sqrt(c),g=d/f;return(m*p+f*d*(p-_)+(4*c*u-d*d)*Math.log((2*f+g+p)/(g+_)))/(4*m)}static curveTo(t,e,s,i,r){const n=r[r.length-2],a=r[r.length-1],o=Yo._segmentsCount(th.curveLength(n,a,t,e,s,i));let h=0,l=0;for(let u=1;u<=o;++u){const d=u/o;h=n+(t-n)*d,l=a+(e-a)*d,r.push(h+(t+(s-t)*d-h)*d,l+(e+(i-e)*d-l)*d)}}}const eh={[Fs.POLY]:Xo,[Fs.CIRC]:Uo,[Fs.ELIP]:Uo,[Fs.RECT]:Ho,[Fs.RREC]:Vo},sh=[],ih=[];class rh{constructor(t,e=null,s=null,i=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=s,this.fillStyle=e,this.matrix=i,this.type=t.type}clone(){return new rh(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 nh=new Bs,ah=class extends Cs{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 gn,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(),ih.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),sh.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,s=null,i=null){const r=new rh(t,e,s,i);return this.graphicsData.push(r),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const s=new rh(t,null,null,e),i=this.graphicsData[this.graphicsData.length-1];return s.lineStyle=i.lineStyle,i.holes.push(s),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 s=0;s<e.length;++s){const i=e[s];if(i.fillStyle.visible&&i.shape&&(i.matrix?i.matrix.applyInverse(t,nh):nh.copyFrom(t),i.shape.contains(nh.x,nh.y))){let t=!1;if(i.holes)for(let e=0;e<i.holes.length;e++)if(i.holes[e].shape.contains(nh.x,nh.y)){t=!0;break}if(!t)return!0}}return!1}updateBatches(){if(!this.graphicsData.length)return void(this.batchable=!0);if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let s=null,i=null;this.batches.length>0&&(s=this.batches[this.batches.length-1],i=s.style);for(let r=this.shapeIndex;r<e.length;r++){this.shapeIndex++;const n=e[r],a=n.fillStyle,o=n.lineStyle;eh[n.type].build(n),n.matrix&&this.transformPoints(n.points,n.matrix),(a.visible||o.visible)&&this.processHoles(n.holes);for(let e=0;e<2;e++){const r=0===e?a:o;if(!r.visible)continue;const h=r.texture.baseTexture,l=this.indices.length,u=this.points.length/2;h.wrapMode=p.REPEAT,0===e?this.processFill(n):this.processLine(n);const d=this.points.length/2-u;0!==d&&(s&&!this._compareStyles(i,r)&&(s.end(l,u),s=null),s||(s=sh.pop()||new qo,s.begin(r,l,u),this.batches.push(s),i=r),this.addUvs(this.points,t,r.texture,u,d,r.matrix))}}const r=this.indices.length,n=this.points.length/2;if(s&&s.end(r,n),0===this.batches.length)return void(this.batchable=!0);const a=n>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&a===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=a?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 e=this.graphicsData[t],s=e.fillStyle,i=e.lineStyle;if(s&&!s.texture.baseTexture.valid||i&&!i.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,s=t.length;e<s;e++){const s=t[e];for(let t=0;t<s.size;t++){const e=s.start+t;this.indicesUint16[e]=this.indicesUint16[e]-s.attribStart}}}isBatchable(){if(this.points.length>131070)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<2*ah.BATCHABLE_SIZE}buildDrawCalls(){let t=++ys._globalBatch;for(let t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),ih.push(this.drawCalls[t]);this.drawCalls.length=0;const e=this.colors,s=this.textureIds;let i=ih.pop();i||(i=new Ts,i.texArray=new wi),i.texArray.count=0,i.start=0,i.size=0,i.type=o.TRIANGLES;let r=0,n=null,a=0,h=!1,l=o.TRIANGLES,u=0;this.drawCalls.push(i);for(let d=0;d<this.batches.length;d++){const c=this.batches[d],f=8,m=c.style,_=m.texture.baseTexture;h!==!!m.native&&(h=!!m.native,l=h?o.LINES:o.TRIANGLES,n=null,r=f,t++),n!==_&&(n=_,_._batchEnabled!==t&&(r===f&&(t++,r=0,i.size>0&&(i=ih.pop(),i||(i=new Ts,i.texArray=new wi),this.drawCalls.push(i)),i.start=u,i.size=0,i.texArray.count=0,i.type=l),_.touched=1,_._batchEnabled=t,_._batchLocation=r,_.wrapMode=p.REPEAT,i.texArray.elements[i.texArray.count++]=_,r++)),i.size+=c.size,u+=c.size,a=_._batchLocation,this.addColors(e,m.color,m.alpha,c.attribSize,c.attribStart),this.addTextureIds(s,a,c.attribSize,c.attribStart)}ys._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,s=this.colors,i=this.textureIds,r=new ArrayBuffer(3*t.length*4),n=new Float32Array(r),a=new Uint32Array(r);let o=0;for(let r=0;r<t.length/2;r++)n[o++]=t[2*r],n[o++]=t[2*r+1],n[o++]=e[2*r],n[o++]=e[2*r+1],a[o++]=s[r],n[o++]=i[r];this._buffer.update(r),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?Xo.triangulate(t,this):eh[t.type].triangulate(t,this)}processLine(t){Jo(t,this);for(let e=0;e<t.holes.length;e++)Jo(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const s=t[e];eh[s.type].build(s),s.matrix&&this.transformPoints(s.points,s.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 s=0;s<t.length/2;s++){const i=t[2*s],r=t[2*s+1];t[2*s]=e.a*i+e.c*r+e.tx,t[2*s+1]=e.b*i+e.d*r+e.ty}}addColors(t,e,s,i,r=0){const n=Ie.shared.setValue(e).toLittleEndianNumber(),a=Ie.shared.setValue(n).toPremultiplied(s);t.length=Math.max(t.length,r+i);for(let e=0;e<i;e++)t[r+e]=a}addTextureIds(t,e,s,i=0){t.length=Math.max(t.length,i+s);for(let r=0;r<s;r++)t[i+r]=e}addUvs(t,e,s,i,r,n=null){let a=0;const o=e.length,h=s.frame;for(;a<r;){let s=t[2*(i+a)],r=t[2*(i+a)+1];if(n){const t=n.a*s+n.c*r+n.tx;r=n.b*s+n.d*r+n.ty,s=t}a++,e.push(s/h.width,r/h.height)}const l=s.baseTexture;(h.width<l.width||h.height<l.height)&&this.adjustUvs(e,s,o,r)}adjustUvs(t,e,s,i){const r=e.baseTexture,n=1e-6,a=s+2*i,o=e.frame,h=o.width/r.width,l=o.height/r.height;let u=o.x/o.width,d=o.y/o.height,c=Math.floor(t[s]+n),p=Math.floor(t[s+1]+n);for(let e=s+2;e<a;e+=2)c=Math.min(c,Math.floor(t[e]+n)),p=Math.min(p,Math.floor(t[e+1]+n));u-=c,d-=p;for(let e=s;e<a;e+=2)t[e]=(t[e]+u)*h,t[e+1]=(t[e+1]+d)*l}};let oh=ah;oh.BATCHABLE_SIZE=100;class hh{constructor(){this.color=16777215,this.alpha=1,this.texture=Wi.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new hh;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=Wi.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class lh extends hh{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=Wo.BUTT,this.join=zo.MITER,this.miterLimit=10}clone(){const t=new lh;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}}const uh={},dh=class extends En{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 hh,this._lineStyle=new lh,this._matrix=null,this._holeMode=!1,this.state=cs.for2d(),this._geometry=t||new oh,this._geometry.refCount++,this._transformID=-1,this._tintColor=new Ie(16777215),this.blendMode=a.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new dh(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,s,i=.5,r=!1){return"number"==typeof t&&(t={width:t,color:e,alpha:s,alignment:i,native:r}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:Wi.WHITE,color:null!=t&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:Wo.BUTT,join:zo.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const s=t.width>0&&t.alpha>0;return s?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:s},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 ks,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new ks,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 s=this.currentPath.points,i=s[s.length-2],r=s[s.length-1];return(i!==t||r!==e)&&s.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?0===this.currentPath.points.length&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,s,i){this._initCurve();const r=this.currentPath.points;return 0===r.length&&this.moveTo(0,0),th.curveTo(t,e,s,i,r),this}bezierCurveTo(t,e,s,i,r,n){return this._initCurve(),Ko.curveTo(t,e,s,i,r,n,this.currentPath.points),this}arcTo(t,e,s,i,r){this._initCurve(t,e);const n=this.currentPath.points,a=$o.curveTo(t,e,s,i,r,n);if(a){const{cx:t,cy:e,radius:s,startAngle:i,endAngle:r,anticlockwise:n}=a;this.arc(t,e,s,i,r,n)}return this}arc(t,e,s,i,r,n=!1){if(i===r)return this;if(!n&&r<=i?r+=Ds:n&&i<=r&&(i+=Ds),r-i==0)return this;const a=t+Math.cos(i)*s,o=e+Math.sin(i)*s,h=this._geometry.closePointEps;let l=this.currentPath?this.currentPath.points:null;if(l){const t=Math.abs(l[l.length-2]-a),e=Math.abs(l[l.length-1]-o);t<h&&e<h||l.push(a,o)}else this.moveTo(a,o),l=this.currentPath.points;return $o.arc(a,o,t,e,s,i,r,n,l),this}beginFill(t=0,e){return this.beginTextureFill({texture:Wi.WHITE,color:t,alpha:e})}normalizeColor(t){var e;const s=Ie.shared.setValue(null!=(e=t.color)?e:0);t.color=s.toNumber(),null!=t.alpha||(t.alpha=s.alpha)}beginTextureFill(t){const e={texture:Wi.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const s=t.alpha>0;return s?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:s},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,s,i){return this.drawShape(new Ls(t,e,s,i))}drawRoundedRect(t,e,s,i,r){return this.drawShape(new Xs(t,e,s,i,r))}drawCircle(t,e,s){return this.drawShape(new Gs(t,e,s))}drawEllipse(t,e,s,i){return this.drawShape(new Us(t,e,s,i))}drawPolygon(...t){let e,s=!0;const i=t[0];i.points?(s=i.closeStroke,e=i.points):e=Array.isArray(t[0])?t[0]:t;const r=new ks(e);return r.closeStroke=s,this.drawShape(r),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!(1!==t.length||t[0].shape.type!==Fs.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,s=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=s,this.vertexData=new Float32Array(t.points);for(let i=0;i<s;i++){const s=t.batches[i],r=s.style.color,n=new Float32Array(this.vertexData.buffer,4*s.attribStart*2,2*s.attribSize),a=new Float32Array(t.uvsFloat32.buffer,4*s.attribStart*2,2*s.attribSize),o={vertexData:n,blendMode:e,indices:new Uint16Array(t.indicesUint16.buffer,2*s.start,s.size),uvs:a,_batchRGB:Ie.shared.setValue(r).toRgbArray(),_tintRGB:r,_texture:s.style.texture,alpha:s.style.alpha,worldAlpha:1};this.batches[i]=o}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,s=this.batches.length;e<s;e++){const s=this.batches[e];s.worldAlpha=this.worldAlpha*s.alpha,t.plugins[this.pluginName].render(s)}}}_renderDirect(t){const e=this._resolveDirectShader(t),s=this._geometry,i=this.worldAlpha,r=e.uniforms,n=s.drawCalls;r.translationMatrix=this.transform.worldTransform,Ie.shared.setValue(this._tintColor).premultiply(i).toArray(r.tint),t.shader.bind(e),t.geometry.bind(s,e),t.state.set(this.state);for(let e=0,i=n.length;e<i;e++)this._renderDrawCallDirect(t,s.drawCalls[e])}_renderDrawCallDirect(t,e){const{texArray:s,type:i,size:r,start:n}=e,a=s.count;for(let e=0;e<a;e++)t.texture.bind(s.elements[e],e);t.geometry.draw(i,r,n)}_resolveDirectShader(t){let e=this.shader;const s=this.pluginName;if(!e){if(!uh[s]){const{maxTextures:e}=t.plugins[s],i=new Int32Array(e);for(let t=0;t<e;t++)i[t]=t;const r={tint:new Float32Array([1,1,1,1]),translationMatrix:new Hs,default:Ai.from({uSamplers:i},!0)},n=t.plugins[s]._shader.program;uh[s]=new Ri(n,r)}e=uh[s]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:s,maxX:i,maxY:r}=t.bounds;this._bounds.addFrame(this.transform,e,s,i,r)}containsPoint(t){return this.worldTransform.applyInverse(t,dh._TEMP_POINT),this._geometry.containsPoint(dh._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=Ie.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,s=e.a,i=e.b,r=e.c,n=e.d,a=e.tx,o=e.ty,h=this._geometry.points,l=this.vertexData;let u=0;for(let t=0;t<h.length;t+=2){const e=h[t],d=h[t+1];l[u++]=s*e+r*d+a,l[u++]=n*d+i*e+o}}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--,0===this._geometry.refCount&&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)}};let ch=dh;ch.curves=Yo,ch._TEMP_POINT=new Bs;const ph={buildPoly:Xo,buildCircle:Uo,buildRectangle:Ho,buildRoundedRectangle:Vo,buildLine:Jo,ArcUtils:$o,BezierUtils:Ko,QuadraticUtils:th,BatchPart:qo,FILL_COMMANDS:eh,BATCH_POOL:sh,DRAW_CALL_POOL:ih};class fh{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 mh=new Bs,_h=new ks,gh=class extends En{constructor(t,e,s,i=o.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=s||cs.for2d(),this.drawMode=i,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=A.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,0===this._geometry.refCount&&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===o.TRIANGLES&&e.length<2*gh.BATCHABLE_SIZE?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,s=this.shader;s.uvMatrix&&(s.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=s._tintRGB,this._texture=s.texture;const i=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[i]),t.plugins[i].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,s=t._updateID;if(s===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 i=this.transform.worldTransform,r=i.a,n=i.b,a=i.c,o=i.d,h=i.tx,l=i.ty,u=this.vertexData;for(let t=0;t<u.length/2;t++){const s=e[2*t],i=e[2*t+1];u[2*t]=r*s+a*i+h,u[2*t+1]=n*s+o*i+l}if(this._roundPixels){const t=A.RESOLUTION;for(let e=0;e<u.length;++e)u[e]=Math.round(u[e]*t)/t}this.vertexDirty=s}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new fh(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,mh);const e=this.geometry.getBuffer("aVertexPosition").data,s=_h.points,i=this.geometry.getIndex().data,r=i.length,n=4===this.drawMode?3:1;for(let t=0;t+2<r;t+=n){const r=2*i[t],n=2*i[t+1],a=2*i[t+2];if(s[0]=e[r],s[1]=e[r+1],s[2]=e[n],s[3]=e[n+1],s[4]=e[a],s[5]=e[a+1],_h.contains(mh.x,mh.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}};let xh=gh;xh.BATCHABLE_SIZE=100;class vh extends Ms{constructor(t,e,s){super();const i=new Es(t),r=new Es(e,!0),n=new Es(s,!0,!0);this.addAttribute("aVertexPosition",i,2,!1,u.FLOAT).addAttribute("aTextureCoord",r,2,!1,u.FLOAT).addIndex(n),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}class yh extends Ri{constructor(t,e){const s={uSampler:t,alpha:1,uTextureMatrix:Hs.IDENTITY,uColor:new Float32Array([1,1,1,1])};(e=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},e)).uniforms&&Object.assign(s,e.uniforms),super(e.program||bi.from("attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTextureMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\n}\n","varying vec2 vTextureCoord;\nuniform vec4 uColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;\n}\n"),s),this._colorDirty=!1,this.uvMatrix=new or(t),this.batchable=void 0===e.program,this.pluginName=e.pluginName,this._tintColor=new Ie(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;Ie.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class Th extends vh{constructor(t=100,e=100,s=10,i=10){super(),this.segWidth=s,this.segHeight=i,this.width=t,this.height=e,this.build()}build(){const t=this.segWidth*this.segHeight,e=[],s=[],i=[],r=this.segWidth-1,n=this.segHeight-1,a=this.width/r,o=this.height/n;for(let i=0;i<t;i++){const t=i%this.segWidth,h=i/this.segWidth|0;e.push(t*a,h*o),s.push(t/r,h/n)}const h=r*n;for(let t=0;t<h;t++){const e=t%r,s=t/r|0,n=s*this.segWidth+e,a=s*this.segWidth+e+1,o=(s+1)*this.segWidth+e,h=(s+1)*this.segWidth+e+1;i.push(n,a,o,a,h,o)}this.buffers[0].data=new Float32Array(e),this.buffers[1].data=new Float32Array(s),this.indexBuffer.data=new Uint16Array(i),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}}class bh extends vh{constructor(t=200,e,s=0){super(new Float32Array(4*e.length),new Float32Array(4*e.length),new Uint16Array(6*(e.length-1))),this.points=e,this._width=t,this.textureScale=s,this.build()}get width(){return this._width}build(){const t=this.points;if(!t)return;const e=this.getBuffer("aVertexPosition"),s=this.getBuffer("aTextureCoord"),i=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(4*t.length),s.data=new Float32Array(4*t.length),i.data=new Uint16Array(6*(t.length-1)));const r=s.data,n=i.data;r[0]=0,r[1]=0,r[2]=0,r[3]=1;let a=0,o=t[0];const h=this._width*this.textureScale,l=t.length;for(let e=0;e<l;e++){const s=4*e;if(this.textureScale>0){const s=o.x-t[e].x,i=o.y-t[e].y,r=Math.sqrt(s*s+i*i);o=t[e],a+=r/h}else a=e/(l-1);r[s]=a,r[s+1]=0,r[s+2]=a,r[s+3]=1}let u=0;for(let t=0;t<l-1;t++){const e=2*t;n[u++]=e,n[u++]=e+1,n[u++]=e+2,n[u++]=e+2,n[u++]=e+1,n[u++]=e+3}s.update(),i.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let e,s=t[0],i=0,r=0;const n=this.buffers[0].data,a=t.length,o=this.textureScale>0?this.textureScale*this._width/2:this._width/2;for(let h=0;h<a;h++){const l=t[h],u=4*h;e=h<t.length-1?t[h+1]:l,r=-(e.x-s.x),i=e.y-s.y;let d=10*(1-h/(a-1));d>1&&(d=1);const c=Math.sqrt(i*i+r*r);c<1e-6?(i=0,r=0):(i/=c,r/=c,i*=o,r*=o),n[u]=l.x+i,n[u+1]=l.y+r,n[u+2]=l.x-i,n[u+3]=l.y-r,s=l}this.buffers[0].update()}update(){this.textureScale>0?this.build():this.updateVertices()}}class Eh extends xh{constructor(t,e,s){super(new Th(t.width,t.height,e,s),new yh(Wi.WHITE)),this.texture=t,this.autoResize=!0}textureUpdated(){this._textureID=this.shader.texture._updateID;const t=this.geometry,{width:e,height:s}=this.shader.texture;this.autoResize&&(t.width!==e||t.height!==s)&&(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)}}class Ah{constructor(t,e,s){this.geometry=new Ms,this.indexBuffer=null,this.size=s,this.dynamicProperties=[],this.staticProperties=[];for(let s=0;s<t.length;++s){let i=t[s];i={attributeName:i.attributeName,size:i.size,uploadFunction:i.uploadFunction,type:i.type||u.FLOAT,offset:i.offset},e[s]?this.dynamicProperties.push(i):this.staticProperties.push(i)}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 Es(Fe(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(let t=0;t<this.dynamicProperties.length;++t){const s=this.dynamicProperties[t];s.offset=e,e+=s.size,this.dynamicStride+=s.size}const s=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(s),this.dynamicDataUint32=new Uint32Array(s),this.dynamicBuffer=new Es(this.dynamicData,!1,!1);let i=0;this.staticStride=0;for(let t=0;t<this.staticProperties.length;++t){const e=this.staticProperties[t];e.offset=i,i+=e.size,this.staticStride+=e.size}const r=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(r),this.staticDataUint32=new Uint32Array(r),this.staticBuffer=new Es(this.staticData,!0,!1);for(let e=0;e<this.dynamicProperties.length;++e){const s=this.dynamicProperties[e];t.addAttribute(s.attributeName,this.dynamicBuffer,0,s.type===u.UNSIGNED_BYTE,s.type,4*this.dynamicStride,4*s.offset)}for(let e=0;e<this.staticProperties.length;++e){const s=this.staticProperties[e];t.addAttribute(s.attributeName,this.staticBuffer,0,s.type===u.UNSIGNED_BYTE,s.type,4*this.staticStride,4*s.offset)}}uploadDynamic(t,e,s){for(let i=0;i<this.dynamicProperties.length;i++){const r=this.dynamicProperties[i];r.uploadFunction(t,e,s,r.type===u.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,r.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,s){for(let i=0;i<this.staticProperties.length;i++){const r=this.staticProperties[i];r.uploadFunction(t,e,s,r.type===u.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,r.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()}}class Rh extends Ii{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new Hs,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:u.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=Ri.from("attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nattribute vec2 aPositionCoord;\nattribute float aRotation;\n\nuniform mat3 translationMatrix;\nuniform vec4 uColor;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nvoid main(void){\n float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);\n float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);\n\n vec2 v = vec2(x, y);\n v = v + aPositionCoord;\n\n gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vColor = aColor * uColor;\n}\n","varying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void){\n vec4 color = texture2D(uSampler, vTextureCoord) * vColor;\n gl_FragColor = color;\n}",{}),this.state=cs.for2d()}render(t){const e=t.children,s=t._maxSize,i=t._batchSize,r=this.renderer;let n=e.length;if(0===n)return;n>s&&!t.autoResize&&(n=s);let a=t._buffers;a||(a=t._buffers=this.generateBuffers(t));const o=e[0]._texture.baseTexture,h=o.alphaMode>0;this.state.blendMode=Pe(t.blendMode,h),r.state.set(this.state);const l=r.gl,u=t.worldTransform.copyTo(this.tempMatrix);u.prepend(r.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=u.toArray(!0),this.shader.uniforms.uColor=Ie.shared.setValue(t.tintRgb).premultiply(t.worldAlpha,h).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=o,this.renderer.shader.bind(this.shader);let d=!1;for(let s=0,o=0;s<n;s+=i,o+=1){let h=n-s;h>i&&(h=i),o>=a.length&&a.push(this._generateOneMoreBuffer(t));const u=a[o];u.uploadDynamic(e,s,h);const c=t._bufferUpdateIDs[o]||0;d=d||u._updateID<c,d&&(u._updateID=t._updateID,u.uploadStatic(e,s,h)),r.geometry.bind(u.geometry),l.drawElements(l.TRIANGLES,6*h,l.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],s=t._maxSize,i=t._batchSize,r=t._properties;for(let t=0;t<s;t+=i)e.push(new Ah(this.properties,r,i));return e}_generateOneMoreBuffer(t){const e=t._batchSize,s=t._properties;return new Ah(this.properties,s,e)}uploadVertices(t,e,s,i,r,n){let a=0,o=0,h=0,l=0;for(let u=0;u<s;++u){const s=t[e+u],d=s._texture,c=s.scale.x,p=s.scale.y,f=d.trim,m=d.orig;f?(o=f.x-s.anchor.x*m.width,a=o+f.width,l=f.y-s.anchor.y*m.height,h=l+f.height):(a=m.width*(1-s.anchor.x),o=m.width*-s.anchor.x,h=m.height*(1-s.anchor.y),l=m.height*-s.anchor.y),i[n]=o*c,i[n+1]=l*p,i[n+r]=a*c,i[n+r+1]=l*p,i[n+2*r]=a*c,i[n+2*r+1]=h*p,i[n+3*r]=o*c,i[n+3*r+1]=h*p,n+=4*r}}uploadPosition(t,e,s,i,r,n){for(let a=0;a<s;a++){const s=t[e+a].position;i[n]=s.x,i[n+1]=s.y,i[n+r]=s.x,i[n+r+1]=s.y,i[n+2*r]=s.x,i[n+2*r+1]=s.y,i[n+3*r]=s.x,i[n+3*r+1]=s.y,n+=4*r}}uploadRotation(t,e,s,i,r,n){for(let a=0;a<s;a++){const s=t[e+a].rotation;i[n]=s,i[n+r]=s,i[n+2*r]=s,i[n+3*r]=s,n+=4*r}}uploadUvs(t,e,s,i,r,n){for(let a=0;a<s;++a){const s=t[e+a]._texture._uvs;s?(i[n]=s.x0,i[n+1]=s.y0,i[n+r]=s.x1,i[n+r+1]=s.y1,i[n+2*r]=s.x2,i[n+2*r+1]=s.y2,i[n+3*r]=s.x3,i[n+3*r+1]=s.y3,n+=4*r):(i[n]=0,i[n+1]=0,i[n+r]=0,i[n+r+1]=0,i[n+2*r]=0,i[n+2*r+1]=0,i[n+3*r]=0,i[n+3*r+1]=0,n+=4*r)}}uploadTint(t,e,s,i,r,n){for(let a=0;a<s;++a){const s=t[e+a],o=Ie.shared.setValue(s._tintRGB).toPremultiplied(s.alpha,s.texture.baseTexture.alphaMode>0);i[n]=o,i[n+r]=o,i[n+2*r]=o,i[n+3*r]=o,n+=4*r}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}Rh.extension={name:"particle",type:rs.RendererPlugin},os.add(Rh);var Sh=(t=>(t[t.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",t[t.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",t))(Sh||{});const wh={willReadFrequently:!0},Ih=class{static get experimentalLetterSpacingSupported(){let t=Ih._experimentalLetterSpacingSupported;if(void 0!==t){const e=A.ADAPTER.getCanvasRenderingContext2D().prototype;t=Ih._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,i,r,n,a,o,h){this.text=t,this.style=e,this.width=s,this.height=i,this.lines=r,this.lineWidths=n,this.lineHeight=a,this.maxLineWidth=o,this.fontProperties=h}static measureText(t,e,s,i=Ih._canvas){s=null==s?e.wordWrap:s;const r=e.toFontString(),n=Ih.measureFont(r);0===n.fontSize&&(n.fontSize=e.fontSize,n.ascent=e.fontSize);const a=i.getContext("2d",wh);a.font=r;const o=(s?Ih.wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),h=new Array(o.length);let l=0;for(let t=0;t<o.length;t++){const s=Ih._measureText(o[t],e.letterSpacing,a);h[t]=s,l=Math.max(l,s)}let u=l+e.strokeThickness;e.dropShadow&&(u+=e.dropShadowDistance);const d=e.lineHeight||n.fontSize+e.strokeThickness;let c=Math.max(d,n.fontSize+2*e.strokeThickness)+(o.length-1)*(d+e.leading);return e.dropShadow&&(c+=e.dropShadowDistance),new Ih(t,e,u,c,o,h,d+e.leading,l,n)}static _measureText(t,e,s){let i=!1;Ih.experimentalLetterSpacingSupported&&(Ih.experimentalLetterSpacing?(s.letterSpacing=`${e}px`,s.textLetterSpacing=`${e}px`,i=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));let r=s.measureText(t).width;return r>0&&(i?r-=e:r+=(Ih.graphemeSegmenter(t).length-1)*e),r}static wordWrap(t,e,s=Ih._canvas){const i=s.getContext("2d",wh);let r=0,n="",a="";const o=Object.create(null),{letterSpacing:h,whiteSpace:l}=e,u=Ih.collapseSpaces(l),d=Ih.collapseNewlines(l);let c=!u;const p=e.wordWrapWidth+h,f=Ih.tokenize(t);for(let t=0;t<f.length;t++){let s=f[t];if(Ih.isNewline(s)){if(!d){a+=Ih.addLine(n),c=!u,n="",r=0;continue}s=" "}if(u){const t=Ih.isBreakingSpace(s),e=Ih.isBreakingSpace(n[n.length-1]);if(t&&e)continue}const l=Ih.getFromCache(s,h,o,i);if(l>p)if(""!==n&&(a+=Ih.addLine(n),n="",r=0),Ih.canBreakWords(s,e.breakWords)){const t=Ih.wordWrapSplit(s);for(let l=0;l<t.length;l++){let u=t[l],d=u,f=1;for(;t[l+f];){const i=t[l+f];if(Ih.canBreakChars(d,i,s,l,e.breakWords))break;u+=i,d=i,f++}l+=f-1;const m=Ih.getFromCache(u,h,o,i);m+r>p&&(a+=Ih.addLine(n),c=!1,n="",r=0),n+=u,r+=m}}else{n.length>0&&(a+=Ih.addLine(n),n="",r=0);const e=t===f.length-1;a+=Ih.addLine(s,!e),c=!1,n="",r=0}else l+r>p&&(c=!1,a+=Ih.addLine(n),n="",r=0),(n.length>0||!Ih.isBreakingSpace(s)||c)&&(n+=s,r+=l)}return a+=Ih.addLine(n,!1),a}static addLine(t,e=!0){return t=Ih.trimRight(t),t=e?`${t}\n`:t}static getFromCache(t,e,s,i){let r=s[t];return"number"!=typeof r&&(r=Ih._measureText(t,e,i)+e,s[t]=r),r}static collapseSpaces(t){return"normal"===t||"pre-line"===t}static collapseNewlines(t){return"normal"===t}static trimRight(t){if("string"!=typeof t)return"";for(let e=t.length-1;e>=0;e--){const s=t[e];if(!Ih.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static isNewline(t){return"string"==typeof t&&Ih._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return"string"==typeof t&&Ih._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let s="";if("string"!=typeof t)return e;for(let i=0;i<t.length;i++){const r=t[i],n=t[i+1];Ih.isBreakingSpace(r,n)||Ih.isNewline(r)?(""!==s&&(e.push(s),s=""),e.push(r)):s+=r}return""!==s&&e.push(s),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,s,i,r){return!0}static wordWrapSplit(t){return Ih.graphemeSegmenter(t)}static measureFont(t){if(Ih._fonts[t])return Ih._fonts[t];const e={ascent:0,descent:0,fontSize:0},s=Ih._canvas,i=Ih._context;i.font=t;const r=Ih.METRICS_STRING+Ih.BASELINE_SYMBOL,n=Math.ceil(i.measureText(r).width);let a=Math.ceil(i.measureText(Ih.BASELINE_SYMBOL).width);const o=Math.ceil(Ih.HEIGHT_MULTIPLIER*a);if(a=a*Ih.BASELINE_MULTIPLIER|0,0===n||0===o)return Ih._fonts[t]=e,e;s.width=n,s.height=o,i.fillStyle="#f00",i.fillRect(0,0,n,o),i.font=t,i.textBaseline="alphabetic",i.fillStyle="#000",i.fillText(r,0,a);const h=i.getImageData(0,0,n,o).data,l=h.length,u=4*n;let d=0,c=0,p=!1;for(d=0;d<a;++d){for(let t=0;t<u;t+=4)if(255!==h[c+t]){p=!0;break}if(p)break;c+=u}for(e.ascent=a-d,c=l-u,p=!1,d=o;d>a;--d){for(let t=0;t<u;t+=4)if(255!==h[c+t]){p=!0;break}if(p)break;c-=u}return e.descent=d-a,e.fontSize=e.ascent+e.descent,Ih._fonts[t]=e,e}static clearMetrics(t=""){t?delete Ih._fonts[t]:Ih._fonts={}}static get _canvas(){if(!Ih.__canvas){let t;try{const e=new OffscreenCanvas(0,0),s=e.getContext("2d",wh);if(null!=s&&s.measureText)return Ih.__canvas=e,e;t=A.ADAPTER.createCanvas()}catch(e){t=A.ADAPTER.createCanvas()}t.width=t.height=10,Ih.__canvas=t}return Ih.__canvas}static get _context(){return Ih.__context||(Ih.__context=Ih._canvas.getContext("2d",wh)),Ih.__context}};let Mh=Ih;Mh.METRICS_STRING="|ÉqÅ",Mh.BASELINE_SYMBOL="M",Mh.BASELINE_MULTIPLIER=1.4,Mh.HEIGHT_MULTIPLIER=2,Mh.graphemeSegmenter=(()=>{if("function"==typeof(null==Intl?void 0:Intl.Segmenter)){const t=new Intl.Segmenter;return e=>[...t.segment(e)].map((t=>t.segment))}return t=>[...t]})(),Mh.experimentalLetterSpacing=!1,Mh._fonts={},Mh._newlines=[10,13],Mh._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];const Ch=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Dh=class{constructor(t){this.styleID=0,this.reset(),Fh(this,t,t)}clone(){const t={};return Fh(t,this,Dh.defaultStyle),new Dh(t)}reset(){Fh(this,Dh.defaultStyle,Dh.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=Oh(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=Oh(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){(function(t,e){if(!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length)return!1;for(let s=0;s<t.length;++s)if(t[s]!==e[s])return!1;return!0})(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=Oh(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="number"==typeof this.fontSize?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let t=e.length-1;t>=0;t--){let s=e[t].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!Ch.includes(s)&&(s=`"${s}"`),e[t]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};let Ph=Dh;function Oh(t){const e=Ie.shared;return Array.isArray(t)?t.map((t=>e.setValue(t).toHex())):e.setValue(t).toHex()}function Fh(t,e,s){for(const i in s)Array.isArray(e[i])?t[i]=e[i].slice():t[i]=e[i]}Ph.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:Sh.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};const Bh={texture:!0,children:!1,baseTexture:!0},Nh=class extends Sn{constructor(t,e,s){var i;let r=!1;s||(s=A.ADAPTER.createCanvas(),r=!0),s.width=3,s.height=3;const n=Wi.from(s);n.orig=new Ls,n.trim=new Ls,super(n),this._ownCanvas=r,this.canvas=s,this.context=s.getContext("2d",{willReadFrequently:!0}),this._resolution=null!=(i=Nh.defaultResolution)?i:A.RESOLUTION,this._autoResolution=Nh.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 Mh.experimentalLetterSpacing}static set experimentalLetterSpacing(t){Kt("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Mh.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 s=this.context,i=Mh.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),r=i.width,n=i.height,a=i.lines,o=i.lineHeight,h=i.lineWidths,l=i.maxLineWidth,u=i.fontProperties;let d,c;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,r)+2*e.padding)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,n)+2*e.padding)*this._resolution),s.scale(this._resolution,this._resolution),s.clearRect(0,0,this.canvas.width,this.canvas.height),s.font=this._font,s.lineWidth=e.strokeThickness,s.textBaseline=e.textBaseline,s.lineJoin=e.lineJoin,s.miterLimit=e.miterLimit;const p=e.dropShadow?2:1;for(let t=0;t<p;++t){const r=e.dropShadow&&0===t,p=r?Math.ceil(Math.max(1,n)+2*e.padding):0,f=p*this._resolution;if(r){s.fillStyle="black",s.strokeStyle="black";const t=e.dropShadowColor,i=e.dropShadowBlur*this._resolution,r=e.dropShadowDistance*this._resolution;s.shadowColor=Ie.shared.setValue(t).setAlpha(e.dropShadowAlpha).toRgbaString(),s.shadowBlur=i,s.shadowOffsetX=Math.cos(e.dropShadowAngle)*r,s.shadowOffsetY=Math.sin(e.dropShadowAngle)*r+f}else s.fillStyle=this._generateFillStyle(e,a,i),s.strokeStyle=e.stroke,s.shadowColor="black",s.shadowBlur=0,s.shadowOffsetX=0,s.shadowOffsetY=0;let m=(o-u.fontSize)/2;o-u.fontSize<0&&(m=0);for(let t=0;t<a.length;t++)d=e.strokeThickness/2,c=e.strokeThickness/2+t*o+u.ascent+m,"right"===e.align?d+=l-h[t]:"center"===e.align&&(d+=(l-h[t])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(a[t],d+e.padding,c+e.padding-p,!0),e.fill&&this.drawLetterSpacing(a[t],d+e.padding,c+e.padding-p)}this.updateTexture()}drawLetterSpacing(t,e,s,i=!1){const r=this._style.letterSpacing;let n=!1;if(Mh.experimentalLetterSpacingSupported&&(Mh.experimentalLetterSpacing?(this.context.letterSpacing=`${r}px`,this.context.textLetterSpacing=`${r}px`,n=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),0===r||n)return void(i?this.context.strokeText(t,e,s):this.context.fillText(t,e,s));let a=e;const o=Mh.graphemeSegmenter(t);let h=this.context.measureText(t).width,l=0;for(let t=0;t<o.length;++t){const e=o[t];i?this.context.strokeText(e,a,s):this.context.fillText(e,a,s);let n="";for(let e=t+1;e<o.length;++e)n+=o[e];l=this.context.measureText(n).width,a+=h-l+r,h=l}}updateTexture(){const t=this.canvas;if(this._style.trim){const e=Je(t);e.data&&(t.width=e.width,t.height=e.height,this.context.putImageData(e.data,0,0))}const e=this._texture,s=this._style,i=s.trim?0:s.padding,r=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=-i,e.trim.y=-i,e.orig.width=e._frame.width-2*i,e.orig.height=e._frame.height-2*i,this._onTextureUpdate(),r.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),-1===this._textureID&&(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,s){const i=t.fill;if(!Array.isArray(i))return i;if(1===i.length)return i[0];let r;const n=t.dropShadow?t.dropShadowDistance:0,a=t.padding||0,o=this.canvas.width/this._resolution-n-2*a,h=this.canvas.height/this._resolution-n-2*a,l=i.slice(),u=t.fillGradientStops.slice();if(!u.length){const t=l.length+1;for(let e=1;e<t;++e)u.push(e/t)}if(l.unshift(i[0]),u.unshift(0),l.push(i[i.length-1]),u.push(1),t.fillGradientType===Sh.LINEAR_VERTICAL){r=this.context.createLinearGradient(o/2,a,o/2,h+a);const i=s.fontProperties.fontSize+t.strokeThickness;for(let t=0;t<e.length;t++){const n=s.lineHeight*(t-1)+i,a=s.lineHeight*t;let o=a;t>0&&n>a&&(o=(a+n)/2);const d=a+i,c=s.lineHeight*(t+1);let p=d;t+1<e.length&&c<d&&(p=(d+c)/2);const f=(p-o)/h;for(let t=0;t<l.length;t++){let e=0;e="number"==typeof u[t]?u[t]:t/l.length;let s=Math.min(1,Math.max(0,o/h+e*f));s=Number(s.toFixed(5)),r.addColorStop(s,l[t])}}}else{r=this.context.createLinearGradient(a,h/2,o+a,h/2);const t=l.length+1;let e=1;for(let s=0;s<l.length;s++){let i;i="number"==typeof u[s]?u[s]:e/t,r.addColorStop(i,l[s]),e++}}return r}destroy(t){"boolean"==typeof t&&(t={children:t}),t=Object.assign({},Bh,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=Xe(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=Xe(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||{},this._style=t instanceof Ph?t:new Ph(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(null==t?"":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)}};let Lh=Nh;Lh.defaultAutoResolution=!0;class Gh{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function Uh(t,e){var s;let i=!1;if(null!=(s=null==t?void 0:t._textures)&&s.length)for(let s=0;s<t._textures.length;s++)if(t._textures[s]instanceof Wi){const r=t._textures[s].baseTexture;e.includes(r)||(e.push(r),i=!0)}return i}function kh(t,e){if(t.baseTexture instanceof ys){const s=t.baseTexture;return e.includes(s)||e.push(s),!0}return!1}function Xh(t,e){if(t._texture&&t._texture instanceof Wi){const s=t._texture.baseTexture;return e.includes(s)||e.push(s),!0}return!1}function Hh(t,e){return e instanceof Lh&&(e.updateText(!0),!0)}function Vh(t,e){if(e instanceof Ph){const t=e.toFontString();return Mh.measureFont(t),!0}return!1}function zh(t,e){if(t instanceof Lh){e.includes(t.style)||e.push(t.style),e.includes(t)||e.push(t);const s=t._texture.baseTexture;return e.includes(s)||e.push(s),!0}return!1}function Wh(t,e){return t instanceof Ph&&(e.includes(t)||e.push(t),!0)}const Yh=class{constructor(t){this.limiter=new Gh(Yh.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(zh),this.registerFindHook(Wh),this.registerFindHook(Uh),this.registerFindHook(kh),this.registerFindHook(Xh),this.registerUploadHook(Hh),this.registerUploadHook(Vh)}upload(t){return new Promise((e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,$r.system.addOnce(this.tick,this,Wr.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 s=0,i=this.uploadHooks.length;s<i;s++)if(this.uploadHooks[s](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}e||this.queue.shift()}if(this.queue.length)$r.system.addOnce(this.tick,this,Wr.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,s=t.length;e<s;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,s=this.addHooks.length;e<s&&!this.addHooks[e](t,this.queue);e++);if(t instanceof En)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&$r.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}};let jh=Yh;function $h(t,e){return e instanceof ys&&(e._glTextures[t.CONTEXT_UID]||t.texture.bind(e),!0)}function qh(t,e){if(!(e instanceof ch))return!1;const{geometry:s}=e;e.finishPoly(),s.updateBatches();const{batches:i}=s;for(let e=0;e<i.length;e++){const{texture:s}=i[e].style;s&&$h(t,s.baseTexture)}return s.batchable||t.geometry.bind(s,e._resolveDirectShader(t)),!0}function Kh(t,e){return t instanceof ch&&(e.push(t),!0)}jh.uploadsPerFrame=4,Object.defineProperties(A,{UPLOADS_PER_FRAME:{get:()=>jh.uploadsPerFrame,set(t){Kt("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),jh.uploadsPerFrame=t}}});class Zh extends jh{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(Kh),this.registerUploadHook($h),this.registerUploadHook(qh)}}Zh.extension={name:"prepare",type:rs.RendererSystem},os.add(Zh);class Qh extends Sn{constructor(t,e=!0){super(t[0]instanceof Wi?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&&($r.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&($r.shared.add(this.update,this,Wr.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,s=this.currentFrame;if(null!==this._durations){let s=this._currentTime%1*this._durations[this.currentFrame];for(s+=e/60*1e3;s<0;)this._currentTime--,s+=this._durations[this.currentFrame];const i=Math.sign(this.animationSpeed*t);for(this._currentTime=Math.floor(this._currentTime);s>=this._durations[this.currentFrame];)s-=this._durations[this.currentFrame]*i,this._currentTime+=i;this._currentTime+=s/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()):s!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<s||this.animationSpeed<0&&this.currentFrame>s)&&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 s=0;s<t.length;++s)e.push(Wi.from(t[s]));return new Qh(e)}static fromImages(t){const e=[];for(let s=0;s<t.length;++s)e.push(Wi.from(t[s]));return new Qh(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof Wi)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?($r.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&($r.shared.add(this.update,this),this._isConnectedToTicker=!0))}}const Jh=new Bs;class tl extends Sn{constructor(t,e=100,s=100){super(t),this.tileTransform=new Js,this._width=e,this._height=s,this.uvMatrix=this.texture.uvMatrix||new or(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,s=this._width*(1-this._anchor._x),i=this._height*(1-this._anchor._y);this._bounds.addFrame(this.transform,t,e,s,i)}getLocalBounds(t){return 0===this.children.length?(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 Ls),t=this._localBoundsRect),this._bounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,Jh);const e=this._width,s=this._height,i=-e*this.anchor._x;if(Jh.x>=i&&Jh.x<i+e){const t=-s*this.anchor._y;if(Jh.y>=t&&Jh.y<t+s)return!0}return!1}destroy(t){super.destroy(t),this.tileTransform=null,this.uvMatrix=null}static from(t,e){const s=t instanceof Wi?t:Wi.from(t,e);return new tl(s,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 el="#version 100\n#define SHADER_NAME Tiling-Sprite-100\n\nprecision lowp float;\n\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;\n}\n";const sl=new Hs;class il extends Ii{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new qi,this.state=cs.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=Ri.from(el,"#version 100\n#define SHADER_NAME Tiling-Sprite-Simple-100\n\nprecision lowp float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\n\nvoid main(void)\n{\n vec4 texSample = texture2D(uSampler, vTextureCoord);\n gl_FragColor = texSample * uColor;\n}\n",e),this.shader=t.context.webGLVersion>1?Ri.from("#version 300 es\n#define SHADER_NAME Tiling-Sprite-300\n\nprecision lowp float;\n\nin vec2 aVertexPosition;\nin vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nout vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;\n}\n","#version 300 es\n#define SHADER_NAME Tiling-Sprite-100\n\nprecision lowp float;\n\nin vec2 vTextureCoord;\n\nout vec4 fragmentColor;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\nuniform mat3 uMapCoord;\nuniform vec4 uClampFrame;\nuniform vec2 uClampOffset;\n\nvoid main(void)\n{\n vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n vec2 unclamped = coord;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n\n vec4 texSample = texture(uSampler, coord, unclamped == coord ? 0.0f : -32.0f);// lod-bias very negative to force lod 0\n\n fragmentColor = texSample * uColor;\n}\n",e):Ri.from(el,"#version 100\n#ifdef GL_EXT_shader_texture_lod\n #extension GL_EXT_shader_texture_lod : enable\n#endif\n#define SHADER_NAME Tiling-Sprite-100\n\nprecision lowp float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\nuniform mat3 uMapCoord;\nuniform vec4 uClampFrame;\nuniform vec2 uClampOffset;\n\nvoid main(void)\n{\n vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n vec2 unclamped = coord;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n\n #ifdef GL_EXT_shader_texture_lod\n vec4 texSample = unclamped == coord\n ? texture2D(uSampler, coord) \n : texture2DLodEXT(uSampler, coord, 0);\n #else\n vec4 texSample = texture2D(uSampler, coord);\n #endif\n\n gl_FragColor = texSample * uColor;\n}\n",e)}render(t){const e=this.renderer,s=this.quad;let i=s.vertices;i[0]=i[6]=t._width*-t.anchor.x,i[1]=i[3]=t._height*-t.anchor.y,i[2]=i[4]=t._width*(1-t.anchor.x),i[5]=i[7]=t._height*(1-t.anchor.y);const r=t.uvRespectAnchor?t.anchor.x:0,n=t.uvRespectAnchor?t.anchor.y:0;i=s.uvs,i[0]=i[6]=-r,i[1]=i[3]=-n,i[2]=i[4]=1-r,i[5]=i[7]=1-n,s.invalidate();const a=t._texture,o=a.baseTexture,h=o.alphaMode>0,l=t.tileTransform.localTransform,u=t.uvMatrix;let d=o.isPowerOfTwo&&a.frame.width===o.width&&a.frame.height===o.height;d&&(o._glTextures[e.CONTEXT_UID]?d=o.wrapMode!==p.CLAMP:o.wrapMode===p.CLAMP&&(o.wrapMode=p.REPEAT));const c=d?this.simpleShader:this.shader,f=a.width,m=a.height,_=t._width,g=t._height;sl.set(l.a*f/_,l.b*f/g,l.c*m/_,l.d*m/g,l.tx/_,l.ty/g),sl.invert(),d?sl.prepend(u.mapCoord):(c.uniforms.uMapCoord=u.mapCoord.toArray(!0),c.uniforms.uClampFrame=u.uClampFrame,c.uniforms.uClampOffset=u.uClampOffset),c.uniforms.uTransform=sl.toArray(!0),c.uniforms.uColor=Ie.shared.setValue(t.tint).premultiply(t.worldAlpha,h).toArray(c.uniforms.uColor),c.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),c.uniforms.uSampler=a,e.shader.bind(c),e.geometry.bind(s),this.state.blendMode=Pe(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}il.extension={name:"tilingSprite",type:rs.RendererPlugin},os.add(il);const rl=class{constructor(t,e,s=null){this.linkedSheets=[],this._texture=t instanceof Wi?t:null,this.baseTexture=t instanceof ys?t:this._texture.baseTexture,this.textures={},this.animations={},this.data=e;const i=this.baseTexture.resource;this.resolution=this._updateResolution(s||(i?i.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 s=ss(t,null);return null===s&&(s=parseFloat(null!=e?e:"1")),1!==s&&this.baseTexture.setResolution(s),s}parse(){return new Promise((t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=rl.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()}))}_processFrames(t){let e=t;const s=rl.BATCH_SIZE;for(;e-t<s&&e<this._frameKeys.length;){const t=this._frameKeys[e],s=this._frames[t],i=s.frame;if(i){let e=null,r=null;const n=!1!==s.trimmed&&s.sourceSize?s.sourceSize:s.frame,a=new Ls(0,0,Math.floor(n.w)/this.resolution,Math.floor(n.h)/this.resolution);e=s.rotated?new Ls(Math.floor(i.x)/this.resolution,Math.floor(i.y)/this.resolution,Math.floor(i.h)/this.resolution,Math.floor(i.w)/this.resolution):new Ls(Math.floor(i.x)/this.resolution,Math.floor(i.y)/this.resolution,Math.floor(i.w)/this.resolution,Math.floor(i.h)/this.resolution),!1!==s.trimmed&&s.spriteSourceSize&&(r=new Ls(Math.floor(s.spriteSourceSize.x)/this.resolution,Math.floor(s.spriteSourceSize.y)/this.resolution,Math.floor(i.w)/this.resolution,Math.floor(i.h)/this.resolution)),this.textures[t]=new Wi(this.baseTexture,e,a,r,s.rotated?2:0,s.anchor,s.borders),Wi.addToCache(this.textures[t],t)}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let s=0;s<t[e].length;s++){const i=t[e][s];this.animations[e].push(this.textures[i])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*rl.BATCH_SIZE),this._batchIndex++,setTimeout((()=>{this._batchIndex*rl.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())}),0)}destroy(t=!1){var e;for(const t in this.textures)this.textures[t].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(null==(e=this._texture)||e.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};let nl=rl;nl.BATCH_SIZE=1e3;const al=["jpg","png","jpeg","avif","webp"];function ol(t,e,s){const i={};if(t.forEach((t=>{i[t]=e})),Object.keys(e.textures).forEach((t=>{i[t]=e.textures[t]})),!s){const s=$t.dirname(t[0]);e.linkedSheets.forEach(((t,r)=>{const n=ol([`${s}/${e.data.meta.related_multi_packs[r]}`],t,!0);Object.assign(i,n)}))}return i}const hl={extension:rs.Asset,cache:{test:t=>t instanceof nl,getCacheableAssets:(t,e)=>ol(t,e,!1)},resolver:{test:t=>{const e=t.split("?")[0].split("."),s=e.pop(),i=e.pop();return"json"===s&&al.includes(i)},parse:t=>{var e,s;const i=t.split(".");return{resolution:parseFloat(null!=(s=null==(e=A.RETINA_PREFIX.exec(t))?void 0:e[1])?s:"1"),format:i[i.length-2],src:t}}},loader:{name:"spritesheetLoader",extension:{type:rs.LoadParser,priority:ma.Normal},testParse:async(t,e)=>".json"===$t.extname(e.src).toLowerCase()&&!!t.frames,async parse(t,e,s){var i,r;let n=$t.dirname(e.src);n&&n.lastIndexOf("/")!==n.length-1&&(n+="/");let a=n+t.meta.image;a=la(a,e.src);const o=(await s.load([a]))[a],h=new nl(o.baseTexture,t,e.src);await h.parse();const l=null==(i=null==t?void 0:t.meta)?void 0:i.related_multi_packs;if(Array.isArray(l)){const t=[];for(const i of l){if("string"!=typeof i)continue;let a=n+i;null!=(r=e.data)&&r.ignoreMultiPack||(a=la(a,e.src),t.push(s.load({src:a,data:{ignoreMultiPack:!0}})))}const i=await Promise.all(t);h.linkedSheets=i,i.forEach((t=>{t.linkedSheets=[h].concat(h.linkedSheets.filter((e=>e!==t)))}))}return h},unload(t){t.destroy(!0)}}};os.add(hl);class ll{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class ul{static test(t){return"string"==typeof t&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),s={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const t in e){const i=e[t].match(/^[a-z]+/gm)[0],r=e[t].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),n={};for(const t in r){const e=r[t].split("="),s=e[0],i=e[1].replace(/"/gm,""),a=parseFloat(i),o=isNaN(a)?i:a;n[s]=o}s[i].push(n)}const i=new ll;return s.info.forEach((t=>i.info.push({face:t.face,size:parseInt(t.size,10)}))),s.common.forEach((t=>i.common.push({lineHeight:parseInt(t.lineHeight,10)}))),s.page.forEach((t=>i.page.push({id:parseInt(t.id,10),file:t.file}))),s.char.forEach((t=>i.char.push({id:parseInt(t.id,10),page:parseInt(t.page,10),x:parseInt(t.x,10),y:parseInt(t.y,10),width:parseInt(t.width,10),height:parseInt(t.height,10),xoffset:parseInt(t.xoffset,10),yoffset:parseInt(t.yoffset,10),xadvance:parseInt(t.xadvance,10)}))),s.kerning.forEach((t=>i.kerning.push({first:parseInt(t.first,10),second:parseInt(t.second,10),amount:parseInt(t.amount,10)}))),s.distanceField.forEach((t=>i.distanceField.push({distanceRange:parseInt(t.distanceRange,10),fieldType:t.fieldType}))),i}}class dl{static test(t){const e=t;return"getElementsByTagName"in e&&e.getElementsByTagName("page").length&&null!==e.getElementsByTagName("info")[0].getAttribute("face")}static parse(t){const e=new ll,s=t.getElementsByTagName("info"),i=t.getElementsByTagName("common"),r=t.getElementsByTagName("page"),n=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning"),o=t.getElementsByTagName("distanceField");for(let t=0;t<s.length;t++)e.info.push({face:s[t].getAttribute("face"),size:parseInt(s[t].getAttribute("size"),10)});for(let t=0;t<i.length;t++)e.common.push({lineHeight:parseInt(i[t].getAttribute("lineHeight"),10)});for(let t=0;t<r.length;t++)e.page.push({id:parseInt(r[t].getAttribute("id"),10)||0,file:r[t].getAttribute("file")});for(let t=0;t<n.length;t++){const s=n[t];e.char.push({id:parseInt(s.getAttribute("id"),10),page:parseInt(s.getAttribute("page"),10)||0,x:parseInt(s.getAttribute("x"),10),y:parseInt(s.getAttribute("y"),10),width:parseInt(s.getAttribute("width"),10),height:parseInt(s.getAttribute("height"),10),xoffset:parseInt(s.getAttribute("xoffset"),10),yoffset:parseInt(s.getAttribute("yoffset"),10),xadvance:parseInt(s.getAttribute("xadvance"),10)})}for(let t=0;t<a.length;t++)e.kerning.push({first:parseInt(a[t].getAttribute("first"),10),second:parseInt(a[t].getAttribute("second"),10),amount:parseInt(a[t].getAttribute("amount"),10)});for(let t=0;t<o.length;t++)e.distanceField.push({fieldType:o[t].getAttribute("fieldType"),distanceRange:parseInt(o[t].getAttribute("distanceRange"),10)});return e}}class cl{static test(t){return!("string"!=typeof t||!t.includes("<font>"))&&dl.test(A.ADAPTER.parseXML(t))}static parse(t){return dl.parse(A.ADAPTER.parseXML(t))}}const pl=[ul,dl,cl];function fl(t){for(let e=0;e<pl.length;e++)if(pl[e].test(t))return pl[e];return null}function ml(t,e,s,i,r,n,a){const o=s.text,h=s.fontProperties;e.translate(i,r),e.scale(n,n);const l=a.strokeThickness/2,u=-a.strokeThickness/2;if(e.font=a.toFontString(),e.lineWidth=a.strokeThickness,e.textBaseline=a.textBaseline,e.lineJoin=a.lineJoin,e.miterLimit=a.miterLimit,e.fillStyle=function(t,e,s,i,r,n){const a=s.fill;if(!Array.isArray(a))return a;if(1===a.length)return a[0];let o;const h=s.dropShadow?s.dropShadowDistance:0,l=s.padding||0,u=t.width/i-h-2*l,d=t.height/i-h-2*l,c=a.slice(),p=s.fillGradientStops.slice();if(!p.length){const t=c.length+1;for(let e=1;e<t;++e)p.push(e/t)}if(c.unshift(a[0]),p.unshift(0),c.push(a[a.length-1]),p.push(1),s.fillGradientType===Sh.LINEAR_VERTICAL){o=e.createLinearGradient(u/2,l,u/2,d+l);let t=0;const i=(n.fontProperties.fontSize+s.strokeThickness)/d;for(let e=0;e<r.length;e++){const s=n.lineHeight*e;for(let e=0;e<c.length;e++){let r=0;r="number"==typeof p[e]?p[e]:e/c.length;const n=s/d+r*i;let a=Math.max(t,n);a=Math.min(a,1),o.addColorStop(a,c[e]),t=a}}}else{o=e.createLinearGradient(l,d/2,u+l,d/2);const t=c.length+1;let s=1;for(let e=0;e<c.length;e++){let i;i="number"==typeof p[e]?p[e]:s/t,o.addColorStop(i,c[e]),s++}}return o}(t,e,a,n,[o],s),e.strokeStyle=a.stroke,a.dropShadow){const t=a.dropShadowColor,s=a.dropShadowBlur*n,i=a.dropShadowDistance*n;e.shadowColor=Ie.shared.setValue(t).setAlpha(a.dropShadowAlpha).toRgbaString(),e.shadowBlur=s,e.shadowOffsetX=Math.cos(a.dropShadowAngle)*i,e.shadowOffsetY=Math.sin(a.dropShadowAngle)*i}else e.shadowColor="black",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0;a.stroke&&a.strokeThickness&&e.strokeText(o,l,u+s.lineHeight-h.descent),a.fill&&e.fillText(o,l,u+s.lineHeight-h.descent),e.setTransform(1,0,0,1,0,0),e.fillStyle="rgba(0, 0, 0, 0)"}function _l(t){return t.codePointAt?t.codePointAt(0):t.charCodeAt(0)}function gl(t){return Array.from?Array.from(t):t.split("")}const xl=class{constructor(t,e,s){var i,r;const[n]=t.info,[a]=t.common,[o]=t.page,[h]=t.distanceField,l=ss(o.file),u={};this._ownsTextures=s,this.font=n.face,this.size=n.size,this.lineHeight=a.lineHeight/l,this.chars={},this.pageTextures=u;for(let s=0;s<t.page.length;s++){const{id:i,file:r}=t.page[s];u[i]=e instanceof Array?e[s]:e[r],(null==h?void 0:h.fieldType)&&"none"!==h.fieldType&&(u[i].baseTexture.alphaMode=m.NO_PREMULTIPLIED_ALPHA,u[i].baseTexture.mipmap=f.OFF)}for(let e=0;e<t.char.length;e++){const{id:s,page:i}=t.char[e];let{x:r,y:n,width:a,height:o,xoffset:h,yoffset:d,xadvance:c}=t.char[e];r/=l,n/=l,a/=l,o/=l,h/=l,d/=l,c/=l;const p=new Ls(r+u[i].frame.x/l,n+u[i].frame.y/l,a,o);this.chars[s]={xOffset:h,yOffset:d,xAdvance:c,kerning:{},texture:new Wi(u[i].baseTexture,p),page:i}}for(let e=0;e<t.kerning.length;e++){let{first:s,second:i,amount:r}=t.kerning[e];s/=l,i/=l,r/=l,this.chars[i]&&(this.chars[i].kerning[s]=r)}this.distanceFieldRange=null==h?void 0:h.distanceRange,this.distanceFieldType=null!=(r=null==(i=null==h?void 0:h.fieldType)?void 0:i.toLowerCase())?r:"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,s){let i;if(t instanceof ll)i=t;else{const e=fl(t);if(!e)throw new Error("Unrecognized data format for font.");i=e.parse(t)}e instanceof Wi&&(e=[e]);const r=new xl(i,e,s);return xl.available[r.font]=r,r}static uninstall(t){const e=xl.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete xl.available[t]}static from(t,e,s){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const i=Object.assign({},xl.defaultOptions,s),{chars:r,padding:n,resolution:a,textureWidth:o,textureHeight:h}=i,l=zn(i,["chars","padding","resolution","textureWidth","textureHeight"]),u=function(t){"string"==typeof t&&(t=[t]);const e=[];for(let s=0,i=t.length;s<i;s++){const i=t[s];if(Array.isArray(i)){if(2!==i.length)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${i.length}.`);const t=i[0].charCodeAt(0),s=i[1].charCodeAt(0);if(s<t)throw new Error("[BitmapFont]: Invalid character range.");for(let i=t,r=s;i<=r;i++)e.push(String.fromCharCode(i))}else e.push(...gl(i))}if(0===e.length)throw new Error("[BitmapFont]: Empty set when resolving characters.");return e}(r),d=e instanceof Ph?e:new Ph(e),c=o,p=new ll;p.info[0]={face:d.fontFamily,size:d.fontSize},p.common[0]={lineHeight:d.fontSize};let f,m,_,g=0,x=0,v=0;const y=[],T=[];for(let t=0;t<u.length;t++){f||(f=A.ADAPTER.createCanvas(),f.width=o,f.height=h,m=f.getContext("2d"),_=new ys(f,bt({resolution:a},l)),y.push(_),T.push(new Wi(_)),p.page.push({id:T.length-1,file:""}));const e=u[t],s=Mh.measureText(e,d,!1,f),i=s.width,r=Math.ceil(s.height),b=Math.ceil(("italic"===d.fontStyle?2:1)*i);if(x>=h-r*a){if(0===x)throw new Error(`[BitmapFont] textureHeight ${h}px is too small (fontFamily: '${d.fontFamily}', fontSize: ${d.fontSize}px, char: '${e}')`);--t,f=null,m=null,_=null,x=0,g=0,v=0;continue}if(v=Math.max(r+s.fontProperties.descent,v),b*a+g>=c){if(0===g)throw new Error(`[BitmapFont] textureWidth ${o}px is too small (fontFamily: '${d.fontFamily}', fontSize: ${d.fontSize}px, char: '${e}')`);--t,x+=v*a,x=Math.ceil(x),g=0,v=0;continue}ml(f,m,s,g,x,a,d);const E=_l(s.text);p.char.push({id:E,page:T.length-1,x:g/a,y:x/a,width:b,height:r,xoffset:0,yoffset:0,xadvance:i-(d.dropShadow?d.dropShadowDistance:0)-(d.stroke?d.strokeThickness:0)}),g+=(b+2*n)*a,g=Math.ceil(g)}for(let t=0,e=u.length;t<e;t++){const s=u[t];for(let t=0;t<e;t++){const e=u[t],i=m.measureText(s).width,r=m.measureText(e).width,n=m.measureText(s+e).width-(i+r);n&&p.kerning.push({first:_l(s),second:_l(e),amount:n})}}const b=new xl(p,T,!0);return void 0!==xl.available[t]&&xl.uninstall(t),xl.available[t]=b,b}};let vl=xl;vl.ALPHA=[["a","z"],["A","Z"]," "],vl.NUMERIC=[["0","9"]],vl.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],vl.ASCII=[[" ","~"]],vl.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:xl.ALPHANUMERIC},vl.available={};const yl=[],Tl=[],bl=[],El=class extends En{constructor(t,e={}){super();const{align:s,tint:i,maxWidth:r,letterSpacing:n,fontName:a,fontSize:o}=Object.assign({},El.styleDefaults,e);if(!vl.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=s,this._tintColor=new Ie(i),this._font=void 0,this._fontName=a,this._fontSize=o,this.text=t,this._maxWidth=r,this._maxLineHeight=0,this._letterSpacing=n,this._anchor=new Zs((()=>{this.dirty=!0}),this,0,0),this._roundPixels=A.ROUND_PIXELS,this.dirty=!0,this._resolution=A.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var t;const e=vl.available[this._fontName],s=this.fontSize,i=s/e.size,r=new Bs,n=[],o=[],h=[],l=gl(this._text.replace(/(?:\r\n|\r)/g,"\n")||" "),u=this._maxWidth*e.size/s,d="none"===e.distanceFieldType?yl:Tl;let c=null,p=0,f=0,m=0,_=-1,g=0,x=0,v=0,y=0;for(let t=0;t<l.length;t++){const s=l[t],i=_l(s);if(/(?:\s)/.test(s)&&(_=t,g=p,y++),"\r"===s||"\n"===s){o.push(p),h.push(-1),f=Math.max(f,p),++m,++x,r.x=0,r.y+=e.lineHeight,c=null,y=0;continue}const a=e.chars[i];if(!a)continue;c&&a.kerning[c]&&(r.x+=a.kerning[c]);const d=bl.pop()||{texture:Wi.EMPTY,line:0,charCode:0,prevSpaces:0,position:new Bs};d.texture=a.texture,d.line=m,d.charCode=i,d.position.x=Math.round(r.x+a.xOffset+this._letterSpacing/2),d.position.y=Math.round(r.y+a.yOffset),d.prevSpaces=y,n.push(d),p=d.position.x+Math.max(a.xAdvance-a.xOffset,a.texture.orig.width),r.x+=a.xAdvance+this._letterSpacing,v=Math.max(v,a.yOffset+a.texture.height),c=i,-1!==_&&u>0&&r.x>u&&(++x,ke(n,1+_-x,1+t-_),t=_,_=-1,o.push(g),h.push(n.length>0?n[n.length-1].prevSpaces:0),f=Math.max(f,g),m++,r.x=0,r.y+=e.lineHeight,c=null,y=0)}const T=l[l.length-1];"\r"!==T&&"\n"!==T&&(/(?:\s)/.test(T)&&(p=g),o.push(p),f=Math.max(f,p),h.push(-1));const b=[];for(let t=0;t<=m;t++){let e=0;"right"===this._align?e=f-o[t]:"center"===this._align?e=(f-o[t])/2:"justify"===this._align&&(e=h[t]<0?0:(f-o[t])/h[t]),b.push(e)}const E=n.length,A={},R=[],S=this._activePagesMeshData;d.push(...S);for(let t=0;t<E;t++){const s=n[t].texture,i=s.baseTexture.uid;if(!A[i]){let t=d.pop();if(!t){const s=new vh;let i,r;"none"===e.distanceFieldType?(i=new yh(Wi.EMPTY),r=a.NORMAL):(i=new yh(Wi.EMPTY,{program:bi.from("// Mesh material default fragment\r\nattribute vec2 aVertexPosition;\r\nattribute vec2 aTextureCoord;\r\n\r\nuniform mat3 projectionMatrix;\r\nuniform mat3 translationMatrix;\r\nuniform mat3 uTextureMatrix;\r\n\r\nvarying vec2 vTextureCoord;\r\n\r\nvoid main(void)\r\n{\r\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\r\n\r\n vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r\n}\r\n","// Pixi texture info\r\nvarying vec2 vTextureCoord;\r\nuniform sampler2D uSampler;\r\n\r\n// Tint\r\nuniform vec4 uColor;\r\n\r\n// on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\r\nuniform float uFWidth;\r\n\r\nvoid main(void) {\r\n\r\n // To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\r\n vec4 texColor = texture2D(uSampler, vTextureCoord);\r\n\r\n // MSDF\r\n float median = texColor.r + texColor.g + texColor.b -\r\n min(texColor.r, min(texColor.g, texColor.b)) -\r\n max(texColor.r, max(texColor.g, texColor.b));\r\n // SDF\r\n median = min(median, texColor.a);\r\n\r\n float screenPxDistance = uFWidth * (median - 0.5);\r\n float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\r\n if (median < 0.01) {\r\n alpha = 0.0;\r\n } else if (median > 0.99) {\r\n alpha = 1.0;\r\n }\r\n\r\n // Gamma correction for coverage-like alpha\r\n float luma = dot(uColor.rgb, vec3(0.299, 0.587, 0.114));\r\n float gamma = mix(1.0, 1.0 / 2.2, luma);\r\n float coverage = pow(uColor.a * alpha, gamma); \r\n\r\n // NPM Textures, NPM outputs\r\n gl_FragColor = vec4(uColor.rgb, coverage);\r\n}\r\n"),uniforms:{uFWidth:0}}),r=a.NORMAL_NPM);const n=new xh(s,i);n.blendMode=r,t={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:n,vertices:null,uvs:null,indices:null}}t.index=0,t.indexCount=0,t.vertexCount=0,t.uvsCount=0,t.total=0;const{_textureCache:r}=this;r[i]=r[i]||new Wi(s.baseTexture),t.mesh.texture=r[i],t.mesh.tint=this._tintColor.value,R.push(t),A[i]=t}A[i].total++}for(let t=0;t<S.length;t++)R.includes(S[t])||this.removeChild(S[t].mesh);for(let t=0;t<R.length;t++)R[t].mesh.parent!==this&&this.addChild(R[t].mesh);this._activePagesMeshData=R;for(const e in A){const s=A[e],i=s.total;if(!((null==(t=s.indices)?void 0:t.length)>6*i)||s.vertices.length<2*xh.BATCHABLE_SIZE)s.vertices=new Float32Array(8*i),s.uvs=new Float32Array(8*i),s.indices=new Uint16Array(6*i);else{const t=s.total,e=s.vertices;for(let s=4*t*2;s<e.length;s++)e[s]=0}s.mesh.size=6*i}for(let t=0;t<E;t++){const e=n[t];let s=e.position.x+b[e.line]*("justify"===this._align?e.prevSpaces:1);this._roundPixels&&(s=Math.round(s));const r=s*i,a=e.position.y*i,o=e.texture,h=A[o.baseTexture.uid],l=o.frame,u=o._uvs,d=h.index++;h.indices[6*d+0]=0+4*d,h.indices[6*d+1]=1+4*d,h.indices[6*d+2]=2+4*d,h.indices[6*d+3]=0+4*d,h.indices[6*d+4]=2+4*d,h.indices[6*d+5]=3+4*d,h.vertices[8*d+0]=r,h.vertices[8*d+1]=a,h.vertices[8*d+2]=r+l.width*i,h.vertices[8*d+3]=a,h.vertices[8*d+4]=r+l.width*i,h.vertices[8*d+5]=a+l.height*i,h.vertices[8*d+6]=r,h.vertices[8*d+7]=a+l.height*i,h.uvs[8*d+0]=u.x0,h.uvs[8*d+1]=u.y0,h.uvs[8*d+2]=u.x1,h.uvs[8*d+3]=u.y1,h.uvs[8*d+4]=u.x2,h.uvs[8*d+5]=u.y2,h.uvs[8*d+6]=u.x3,h.uvs[8*d+7]=u.y3}this._textWidth=f*i,this._textHeight=(r.y+e.lineHeight)*i;for(const t in A){const e=A[t];if(0!==this.anchor.x||0!==this.anchor.y){let t=0;const s=this._textWidth*this.anchor.x,i=this._textHeight*this.anchor.y;for(let r=0;r<e.total;r++)e.vertices[t++]-=s,e.vertices[t++]-=i,e.vertices[t++]-=s,e.vertices[t++]-=i,e.vertices[t++]-=s,e.vertices[t++]-=i,e.vertices[t++]-=s,e.vertices[t++]-=i}this._maxLineHeight=v*i;const s=e.mesh.geometry.getBuffer("aVertexPosition"),r=e.mesh.geometry.getBuffer("aTextureCoord"),n=e.mesh.geometry.getIndex();s.data=e.vertices,r.data=e.uvs,n.data=e.indices,s.update(),r.update(),n.update()}for(let t=0;t<n.length;t++)bl.push(n[t]);this._font=e,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:s,size:i}=vl.available[this._fontName];if("none"!==s){const{a:s,b:r,c:n,d:a}=this.worldTransform,o=Math.sqrt(s*s+r*r),h=Math.sqrt(n*n+a*a),l=(Math.abs(o)+Math.abs(h))/2,u=this.fontSize/i,d=t._view.resolution;for(const t of this._activePagesMeshData)t.mesh.shader.uniforms.uFWidth=l*e*u*d}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=vl.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(!vl.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){var t;return null!=(t=this._fontSize)?t:vl.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(null==t?"":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,s="none"===vl.available[this._fontName].distanceFieldType?yl:Tl;s.push(...this._activePagesMeshData);for(const t of this._activePagesMeshData)this.removeChild(t.mesh);this._activePagesMeshData=[],s.filter((t=>e[t.mesh.texture.baseTexture.uid])).forEach((t=>{t.mesh.texture=Wi.EMPTY}));for(const t in e)e[t].destroy(),delete e[t];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};let Al=El;Al.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const Rl=[".xml",".fnt"],Sl={extension:{type:rs.LoadParser,priority:ma.Normal},name:"loadBitmapFont",test:t=>Rl.includes($t.extname(t).toLowerCase()),testParse:async t=>ul.test(t)||cl.test(t),async parse(t,e,s){const i=ul.test(t)?ul.parse(t):cl.parse(t),{src:r}=e,{page:n}=i,a=[];for(let t=0;t<n.length;++t){const e=n[t].file;let s=$t.join($t.dirname(r),e);s=la(s,r),a.push(s)}const o=await s.load(a),h=a.map((t=>o[t]));return vl.install(i,h,!0)},load:async(t,e)=>(await A.ADAPTER.fetch(t)).text(),unload(t){t.destroy()}};os.add(Sl);const wl=class extends Ph{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new wl(Object.keys(wl.defaultOptions).reduce(((e,s)=>Qi(bt({},e),{[s]:t[s]})),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach((t=>{URL.revokeObjectURL(t.src),t.refs--,0===t.refs&&(t.fontFace&&document.fonts.delete(t.fontFace),delete wl.availableFonts[t.originalUrl])})),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:s}=wl;if(s[t]){const e=s[t];return this._fonts.push(e),e.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return A.ADAPTER.fetch(t).then((t=>t.blob())).then((async t=>new Promise(((e,s)=>{const i=URL.createObjectURL(t),r=new FileReader;r.onload=()=>e([i,r.result]),r.onerror=s,r.readAsDataURL(t)})))).then((async([i,r])=>{const n=Object.assign({family:$t.basename(t,$t.extname(t)),weight:"normal",style:"normal",src:i,dataSrc:r,refs:1,originalUrl:t,fontFace:null},e);s[t]=n,this._fonts.push(n),this.styleID++;const a=new FontFace(n.family,`url(${n.src})`,{weight:n.weight,style:n.style});n.fontFace=a,await a.load(),document.fonts.add(a),await document.fonts.ready,this.styleID++,this.fontsDirty=!0}))}addOverride(...t){const e=t.filter((t=>!this._overrides.includes(t)));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter((t=>this._overrides.includes(t)));e.length>0&&(this._overrides=this._overrides.filter((t=>!e.includes(t))),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}\n @font-face {\n font-family: "${e.family}";\n src: url('${e.dataSrc}');\n font-weight: ${e.weight};\n font-style: ${e.style}; \n }`),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=Ce(t)),"number"==typeof t?Me(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,s=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),i=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(255*e|0).toString(16).padStart(2,"0"));const r=`${s}px ${i}px`;return this.dropShadowBlur>0?`text-shadow: ${r} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${r} ${t}`}reset(){Object.assign(this,wl.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise((t=>setTimeout(t,100))):Promise.resolve()}get isSafari(){const{userAgent:t}=A.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}};let Il=wl;Il.availableFonts={},Il.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};const Ml=class extends Sn{constructor(t="",e={}){var s;super(Wi.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this._loading=!1,this.localStyleID=-1,this.dirty=!1,this.ownsStyle=!1;const i=new Image,r=Wi.from(i,{scaleMode:A.SCALE_MODE,resourceOptions:{autoLoad:!1}});r.orig=new Ls,r.trim=new Ls,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=Ml.defaultMaxWidth,this.maxHeight=Ml.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=Ml.defaultAutoResolution,this._resolution=null!=(s=Ml.defaultResolution)?s:A.RESOLUTION,this.text=t,this.style=e}measureText(t){var e,s;const{text:i,style:r,resolution:n}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:i,style:r.toCSS(n)}),this._styleElement.textContent=r.toGlobalCSS(),document.body.appendChild(this._svgRoot);const a=this._domElement.getBoundingClientRect();this._svgRoot.remove();const o=Math.min(this.maxWidth,Math.ceil(a.width)),h=Math.min(this.maxHeight,Math.ceil(a.height));return this._svgRoot.setAttribute("width",o.toString()),this._svgRoot.setAttribute("height",h.toString()),i!==this._text&&(this._domElement.innerHTML=this._text),r!==this._style&&(Object.assign(this._domElement,{style:null==(e=this._style)?void 0:e.toCSS(n)}),this._styleElement.textContent=null==(s=this._style)?void 0:s.toGlobalCSS()),{width:o+2*r.padding,height:h+2*r.padding}}async updateText(t=!0){const{style:e,_image:s,_loadImage:i}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:r,height:n}=this.measureText();s.width=i.width=Math.ceil(Math.max(1,r)),s.height=i.height=Math.ceil(Math.max(1,n)),this._loading||(this._loading=!0,await new Promise((t=>{i.onload=async()=>{await e.onBeforeDraw(),this._loading=!1,s.src=i.src,i.onload=null,i.src="",this.updateTexture(),t()};const r=(new XMLSerializer).serializeToString(this._svgRoot);i.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(r)}`})))}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:s,resolution:i}=this,{padding:r}=t,{baseTexture:n}=e;e.trim.width=e._frame.width=s.width/i,e.trim.height=e._frame.height=s.height/i,e.trim.x=-r,e.trim.y=-r,e.orig.width=e._frame.width-2*r,e.orig.height=e._frame.height-2*r,this._onTextureUpdate(),n.setRealSize(s.width,s.height,i),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 e,s,i,r,n;"boolean"==typeof t&&(t={children:t}),t=Object.assign({},Ml.defaultDestroyOptions,t),super.destroy(t);const a=null;this.ownsStyle&&(null==(e=this._style)||e.cleanFonts()),this._style=a,null==(s=this._svgRoot)||s.remove(),this._svgRoot=a,null==(i=this._domElement)||i.remove(),this._domElement=a,null==(r=this._foreignObject)||r.remove(),this._foreignObject=a,null==(n=this._styleElement)||n.remove(),this._styleElement=a,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=a,this._image.src="",this._image=a}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=Xe(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=Xe(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||{})instanceof Il?(this.ownsStyle=!1,this._style=t):t instanceof Ph?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Il.from(t)):(this.ownsStyle=!0,this._style=new Il(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(""===t||null==t?" ":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;")}};let Cl=Ml;return Cl.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Cl.defaultMaxWidth=2024,Cl.defaultMaxHeight=2024,Cl.defaultAutoResolution=!0,t.ALPHA_MODES=m,t.AbstractMultiResource=on,t.AccessibilityManager=ta,t.AlphaFilter=Mn,t.AnimatedSprite=Qh,t.Application=sa,t.ArrayResource=hn,t.Assets=Ga,t.AssetsClass=La,t.Attribute=As,t.BLEND_MODES=a,t.BUFFER_BITS=n,t.BUFFER_TYPE=b,t.BackgroundSystem=Oi,t.BaseImageResource=ki,t.BasePrepare=jh,t.BaseRenderTexture=Ui,t.BaseTexture=ys,t.BatchDrawCall=Ts,t.BatchGeometry=Cs,t.BatchRenderer=Ci,t.BatchShaderGenerator=Si,t.BatchSystem=Fi,t.BatchTextureArray=wi,t.BitmapFont=vl,t.BitmapFontData=ll,t.BitmapText=Al,t.BlobResource=Za,t.BlurFilter=On,t.BlurFilterPass=Pn,t.Bounds=gn,t.BrowserAdapter=E,t.Buffer=Es,t.BufferResource=gs,t.BufferSystem=sn,t.CLEAR_MODES=_,t.COLOR_MASK_BITS=y,t.Cache=pa,t.CanvasResource=ln,t.Circle=Gs,t.Color=Ie,t.ColorMatrixFilter=Fn,t.CompressedTextureResource=Qa,t.Container=En,t.ContextSystem=Ni,t.CountLimiter=Gh,t.CubeResource=dn,t.DEG_TO_RAD=Os,t.DRAW_MODES=o,t.DisplacementFilter=Bn,t.DisplayObject=xn,t.ENV=i,t.Ellipse=Us,t.EventBoundary=jn,t.EventSystem=Kn,t.ExtensionType=rs,t.Extract=Go,t.FORMATS=h,t.FORMATS_TO_COMPONENTS=Mo,t.FXAAFilter=Nn,t.FederatedDisplayObject=Qn,t.FederatedEvent=kn,t.FederatedMouseEvent=Xn,t.FederatedPointerEvent=Hn,t.FederatedWheelEvent=Vn,t.FillStyle=hh,t.Filter=Pi,t.FilterState=Ki,t.FilterSystem=tr,t.Framebuffer=Gi,t.FramebufferSystem=ir,t.GC_MODES=g,t.GLFramebuffer=er,t.GLProgram=Ar,t.GLTexture=Xr,t.GRAPHICS_CURVES=jo,t.GenerateTextureSystem=yr,t.Geometry=Ms,t.GeometrySystem=nr,t.Graphics=ch,t.GraphicsData=rh,t.GraphicsGeometry=oh,t.HTMLText=Cl,t.HTMLTextStyle=Il,t.IGLUniformData=class{},t.INSTALLED=ps,t.INTERNAL_FORMATS=Wa,t.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL=Ya,t.ImageBitmapResource=cn,t.ImageResource=Xi,t.LINE_CAP=Wo,t.LINE_JOIN=zo,t.LineStyle=lh,t.LoaderParserPriority=ma,t.MASK_TYPES=v,t.MIPMAP_MODES=f,t.MSAA_QUALITY=T,t.MaskData=lr,t.MaskSystem=ur,t.Matrix=Hs,t.Mesh=xh,t.MeshBatchUvs=fh,t.MeshGeometry=vh,t.MeshMaterial=yh,t.MultisampleSystem=tn,t.NineSlicePlane=class extends Eh{constructor(t,e,s,i,r){var n,a,o,h,l,u,d,c;super(Wi.WHITE,4,4),this._origWidth=t.orig.width,this._origHeight=t.orig.height,this._width=this._origWidth,this._height=this._origHeight,this._leftWidth=null!=(a=null!=e?e:null==(n=t.defaultBorders)?void 0:n.left)?a:10,this._rightWidth=null!=(h=null!=i?i:null==(o=t.defaultBorders)?void 0:o.right)?h:10,this._topHeight=null!=(u=null!=s?s:null==(l=t.defaultBorders)?void 0:l.top)?u:10,this._bottomHeight=null!=(c=null!=r?r:null==(d=t.defaultBorders)?void 0:d.bottom)?c:10,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,s=this._topHeight+this._bottomHeight,i=this._height>s?1:this._height/s;return Math.min(e,i)}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 s=1/this._origWidth,i=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]=s*this._leftWidth,e[4]=e[12]=e[20]=e[28]=1-s*this._rightWidth,e[9]=e[11]=e[13]=e[15]=i*this._topHeight,e[17]=e[19]=e[21]=e[23]=1-i*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.geometry.buffers[0].update(),this.geometry.buffers[1].update()}},t.NoiseFilter=Ln,t.ObjectRenderer=Ii,t.ObjectRendererSystem=rn,t.ObservablePoint=Zs,t.PI_2=Ds,t.PRECISION=x,t.ParticleContainer=class extends En{constructor(t=1500,e,s=16384,i=!1){super();s>16384&&(s=16384),this._properties=[!1,!0,!1,!1,!1],this._maxSize=t,this._batchSize=s,this._buffers=null,this._bufferUpdateIDs=[],this._updateID=0,this.interactiveChildren=!1,this.blendMode=a.NORMAL,this.autoResize=i,this.roundPixels=!0,this.baseTexture=null,this.setProperties(e),this._tintColor=new Ie(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}},t.ParticleRenderer=Rh,t.PlaneGeometry=Th,t.PluginSystem=gr,t.Point=Bs,t.Polygon=ks,t.Prepare=Zh,t.Program=bi,t.ProjectionSystem=xr,t.Quad=$i,t.QuadUv=qi,t.RAD_TO_DEG=Ps,t.RENDERER_TYPE=r,t.Rectangle=Ls,t.RenderTexture=Yi,t.RenderTexturePool=ji,t.RenderTextureSystem=Er,t.Renderer=an,t.ResizePlugin=ia,t.Resource=_s,t.RopeGeometry=bh,t.RoundedRectangle=Xs,t.Runner=ms,t.SAMPLER_TYPES=d,t.SCALE_MODES=c,t.SHAPES=Fs,t.SVGResource=fn,t.ScissorSystem=mr,t.Shader=Ri,t.ShaderSystem=Fr,t.SimpleMesh=class extends xh{constructor(t=Wi.EMPTY,e,s,i,r){const n=new vh(e,s,i);n.getBuffer("aVertexPosition").static=!1;super(n,new yh(t),null,r),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)}},t.SimplePlane=Eh,t.SimpleRope=class extends xh{constructor(t,e,s=0){const i=new bh(t.height,e,s),r=new yh(t);s>0&&(t.baseTexture.wrapMode=p.REPEAT),super(i,r),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)}},t.Sprite=Sn,t.SpriteMaskFilter=hr,t.Spritesheet=nl,t.StartupSystem=Br,t.State=cs,t.StateSystem=Lr,t.StencilSystem=_r,t.SystemManager=Gr,t.TARGETS=l,t.TEXT_GRADIENT=Sh,t.TYPES=u,t.TYPES_TO_BYTES_PER_COMPONENT=Io,t.TYPES_TO_BYTES_PER_PIXEL=Co,t.TemporaryDisplayObject=vn,t.Text=Lh,t.TextFormat=ul,t.TextMetrics=Mh,t.TextStyle=Ph,t.Texture=Wi,t.TextureGCSystem=kr,t.TextureMatrix=or,t.TextureSystem=Hr,t.TextureUvs=Hi,t.Ticker=$r,t.TickerPlugin=qr,t.TilingSprite=tl,t.TilingSpriteRenderer=il,t.TimeLimiter=class{constructor(t){this.maxMilliseconds=t,this.frameStart=0}beginFrame(){this.frameStart=Date.now()}allowedToUpload(){return Date.now()-this.frameStart<this.maxMilliseconds}},t.Transform=Js,t.TransformFeedback=class{constructor(){this._glTransformFeedbacks={},this.buffers=[],this.disposeRunner=new ms("disposeTransformFeedback")}bindBuffer(t,e){this.buffers[t]=e}destroy(){this.disposeRunner.emit(this,!1)}},t.TransformFeedbackSystem=Vr,t.UPDATE_PRIORITY=Wr,t.UniformGroup=Ai,t.VERSION="7.2.4",t.VideoResource=_n,t.ViewSystem=zr,t.ViewableBuffer=hs,t.WRAP_MODES=p,t.XMLFormat=dl,t.XMLStringFormat=cl,t.accessibleTarget=Jn,t.autoDetectFormat=fl,t.autoDetectRenderer=Zr,t.autoDetectResource=fs,t.cacheTextureArray=Ua,t.checkDataUrl=aa,t.checkExtension=oa,t.checkMaxIfStatementsInShader=ds,t.convertToList=ha,t.copySearchParams=la,t.createStringVariations=da,t.createTexture=Ca,t.createUBOElements=Mr,t.curves=Yo,t.defaultFilterVertex=Jr,t.defaultVertex=Qr,t.detectAvif=ka,t.detectCompressedTextures=Ka,t.detectDefaults=Va,t.detectWebp=Xa,t.extensions=os,t.filters=Gn,t.generateProgram=Rr,t.generateUniformBufferSync=Dr,t.getFontFamilyName=ba,t.getTestContext=li,t.getUBOData=Cr,t.graphicsUtils=ph,t.groupD8=Ks,t.isMobile=H,t.isSingleItem=ca,t.loadBitmapFont=Sl,t.loadDDS=Oo,t.loadImageBitmap=Oa,t.loadJson=_a,t.loadKTX=Fo,t.loadSVG=Ba,t.loadTextures=Fa,t.loadTxt=ga,t.loadWebFont=Ea,t.parseDDS=fo,t.parseKTX=Do,t.resolveCompressedTextureUrl=Bo,t.resolveTextureUrl=za,t.settings=A,t.spritesheetAsset=hl,t.uniformParsers=ii,t.unsafeEvalSupported=xi,t.utils=is,Object.defineProperty(t,"__esModule",{value:!0}),t}({})