evotars 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CanvasPool-323z5Bgc.js +46 -0
- package/dist/SharedSystems-CpNLwPlr.js +2134 -0
- package/dist/WebGLRenderer-8_UYFwzF.js +2564 -0
- package/dist/WebGPURenderer-D3yK12c3.js +1561 -0
- package/dist/browserAll--tlJ0wmH.js +1968 -0
- package/dist/colorToUniform-ZnVvWd8z.js +1308 -0
- package/dist/evotars.js +9 -26282
- package/dist/evotars.umd.cjs +902 -1069
- package/dist/getBatchSamplersUniformGroup-DIigPB-W.js +16 -0
- package/dist/index-RgERw5ms.js +14288 -0
- package/dist/index.d.ts +236 -5
- package/dist/webworkerAll-DxpydbmF.js +2661 -0
- package/package.json +3 -3
package/dist/evotars.umd.cjs
CHANGED
|
@@ -1,1147 +1,980 @@
|
|
|
1
|
-
(function(Ct,yt){typeof exports=="object"&&typeof module<"u"?yt(exports):typeof define=="function"&&define.amd?define(["exports"],yt):(Ct=typeof globalThis<"u"?globalThis:Ct||self,yt(Ct.evotars={}))})(this,function(Ct){"use strict";var d_=Object.defineProperty;var f_=(Ct,yt,Pe)=>yt in Ct?d_(Ct,yt,{enumerable:!0,configurable:!0,writable:!0,value:Pe}):Ct[yt]=Pe;var B=(Ct,yt,Pe)=>(f_(Ct,typeof yt!="symbol"?yt+"":yt,Pe),Pe);var yt=(i=>(i[i.WEBGL_LEGACY=0]="WEBGL_LEGACY",i[i.WEBGL=1]="WEBGL",i[i.WEBGL2=2]="WEBGL2",i))(yt||{}),Pe=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.WEBGL=1]="WEBGL",i[i.CANVAS=2]="CANVAS",i))(Pe||{}),Us=(i=>(i[i.COLOR=16384]="COLOR",i[i.DEPTH=256]="DEPTH",i[i.STENCIL=1024]="STENCIL",i))(Us||{}),z=(i=>(i[i.NORMAL=0]="NORMAL",i[i.ADD=1]="ADD",i[i.MULTIPLY=2]="MULTIPLY",i[i.SCREEN=3]="SCREEN",i[i.OVERLAY=4]="OVERLAY",i[i.DARKEN=5]="DARKEN",i[i.LIGHTEN=6]="LIGHTEN",i[i.COLOR_DODGE=7]="COLOR_DODGE",i[i.COLOR_BURN=8]="COLOR_BURN",i[i.HARD_LIGHT=9]="HARD_LIGHT",i[i.SOFT_LIGHT=10]="SOFT_LIGHT",i[i.DIFFERENCE=11]="DIFFERENCE",i[i.EXCLUSION=12]="EXCLUSION",i[i.HUE=13]="HUE",i[i.SATURATION=14]="SATURATION",i[i.COLOR=15]="COLOR",i[i.LUMINOSITY=16]="LUMINOSITY",i[i.NORMAL_NPM=17]="NORMAL_NPM",i[i.ADD_NPM=18]="ADD_NPM",i[i.SCREEN_NPM=19]="SCREEN_NPM",i[i.NONE=20]="NONE",i[i.SRC_OVER=0]="SRC_OVER",i[i.SRC_IN=21]="SRC_IN",i[i.SRC_OUT=22]="SRC_OUT",i[i.SRC_ATOP=23]="SRC_ATOP",i[i.DST_OVER=24]="DST_OVER",i[i.DST_IN=25]="DST_IN",i[i.DST_OUT=26]="DST_OUT",i[i.DST_ATOP=27]="DST_ATOP",i[i.ERASE=26]="ERASE",i[i.SUBTRACT=28]="SUBTRACT",i[i.XOR=29]="XOR",i))(z||{}),te=(i=>(i[i.POINTS=0]="POINTS",i[i.LINES=1]="LINES",i[i.LINE_LOOP=2]="LINE_LOOP",i[i.LINE_STRIP=3]="LINE_STRIP",i[i.TRIANGLES=4]="TRIANGLES",i[i.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",i[i.TRIANGLE_FAN=6]="TRIANGLE_FAN",i))(te||{}),A=(i=>(i[i.RGBA=6408]="RGBA",i[i.RGB=6407]="RGB",i[i.RG=33319]="RG",i[i.RED=6403]="RED",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.ALPHA=6406]="ALPHA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL",i))(A||{}),ui=(i=>(i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",i))(ui||{}),H=(i=>(i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.BYTE=5120]="BYTE",i[i.SHORT=5122]="SHORT",i[i.INT=5124]="INT",i[i.FLOAT=5126]="FLOAT",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.HALF_FLOAT=36193]="HALF_FLOAT",i))(H||{}),D=(i=>(i[i.FLOAT=0]="FLOAT",i[i.INT=1]="INT",i[i.UINT=2]="UINT",i))(D||{}),$t=(i=>(i[i.NEAREST=0]="NEAREST",i[i.LINEAR=1]="LINEAR",i))($t||{}),Me=(i=>(i[i.CLAMP=33071]="CLAMP",i[i.REPEAT=10497]="REPEAT",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i))(Me||{}),ee=(i=>(i[i.OFF=0]="OFF",i[i.POW2=1]="POW2",i[i.ON=2]="ON",i[i.ON_MANUAL=3]="ON_MANUAL",i))(ee||{}),Ot=(i=>(i[i.NPM=0]="NPM",i[i.UNPACK=1]="UNPACK",i[i.PMA=2]="PMA",i[i.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",i[i.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",i[i.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",i))(Ot||{}),ie=(i=>(i[i.NO=0]="NO",i[i.YES=1]="YES",i[i.AUTO=2]="AUTO",i[i.BLEND=0]="BLEND",i[i.CLEAR=1]="CLEAR",i[i.BLIT=2]="BLIT",i))(ie||{}),Gs=(i=>(i[i.AUTO=0]="AUTO",i[i.MANUAL=1]="MANUAL",i))(Gs||{}),Ut=(i=>(i.LOW="lowp",i.MEDIUM="mediump",i.HIGH="highp",i))(Ut||{}),_t=(i=>(i[i.NONE=0]="NONE",i[i.SCISSOR=1]="SCISSOR",i[i.STENCIL=2]="STENCIL",i[i.SPRITE=3]="SPRITE",i[i.COLOR=4]="COLOR",i))(_t||{}),pt=(i=>(i[i.NONE=0]="NONE",i[i.LOW=2]="LOW",i[i.MEDIUM=4]="MEDIUM",i[i.HIGH=8]="HIGH",i))(pt||{}),re=(i=>(i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",i))(re||{});const F={ADAPTER:{createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(i,t)=>fetch(i,t),parseXML:i=>new DOMParser().parseFromString(i,"text/xml")},RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Hs=/iPhone/i,za=/iPod/i,Va=/iPad/i,Wa=/\biOS-universal(?:.+)Mac\b/i,$s=/\bAndroid(?:.+)Mobile\b/i,ja=/Android/i,di=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,xr=/Silk/i,_e=/Windows Phone/i,Ya=/\bWindows(?:.+)ARM\b/i,qa=/BlackBerry/i,Ka=/BB10/i,Za=/Opera Mini/i,Ja=/\b(CriOS|Chrome)(?:.+)Mobile/i,Qa=/Mobile(?:.+)Firefox\b/i,to=function(i){return typeof i<"u"&&i.platform==="MacIntel"&&typeof i.maxTouchPoints=="number"&&i.maxTouchPoints>1&&typeof MSStream>"u"};function Oc(i){return function(t){return t.test(i)}}function eo(i){var t={userAgent:"",platform:"",maxTouchPoints:0};!i&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof i=="string"?t.userAgent=i:i&&i.userAgent&&(t={userAgent:i.userAgent,platform:i.platform,maxTouchPoints:i.maxTouchPoints||0});var e=t.userAgent,r=e.split("[FBAN");typeof r[1]<"u"&&(e=r[0]),r=e.split("Twitter"),typeof r[1]<"u"&&(e=r[0]);var s=Oc(e),n={apple:{phone:s(Hs)&&!s(_e),ipod:s(za),tablet:!s(Hs)&&(s(Va)||to(t))&&!s(_e),universal:s(Wa),device:(s(Hs)||s(za)||s(Va)||s(Wa)||to(t))&&!s(_e)},amazon:{phone:s(di),tablet:!s(di)&&s(xr),device:s(di)||s(xr)},android:{phone:!s(_e)&&s(di)||!s(_e)&&s($s),tablet:!s(_e)&&!s(di)&&!s($s)&&(s(xr)||s(ja)),device:!s(_e)&&(s(di)||s(xr)||s($s)||s(ja))||s(/\bokhttp\b/i)},windows:{phone:s(_e),tablet:s(Ya),device:s(_e)||s(Ya)},other:{blackberry:s(qa),blackberry10:s(Ka),opera:s(Za),firefox:s(Qa),chrome:s(Ja),device:s(qa)||s(Ka)||s(Za)||s(Qa)||s(Ja)},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 Lc=eo.default??eo,ve=Lc(globalThis.navigator);F.RETINA_PREFIX=/@([0-9\.]+)x/,F.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var br=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function io(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Nc(i){if(i.__esModule)return i;var t=i.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(i).forEach(function(r){var s=Object.getOwnPropertyDescriptor(i,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:function(){return i[r]}})}),e}var ro={exports:{}};(function(i){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function s(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function n(h,l,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,u||h,d),p=e?e+l:l;return h._events[p]?h._events[p].fn?h._events[p]=[h._events[p],f]:h._events[p].push(f):(h._events[p]=f,h._eventsCount++),h}function a(h,l){--h._eventsCount===0?h._events=new r:delete h._events[l]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],c,u;if(this._eventsCount===0)return l;for(u in c=this._events)t.call(c,u)&&l.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},o.prototype.listeners=function(l){var c=e?e+l:l,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},o.prototype.listenerCount=function(l){var c=e?e+l:l,u=this._events[c];return u?u.fn?1:u.length:0},o.prototype.emit=function(l,c,u,d,f,p){var m=e?e+l:l;if(!this._events[m])return!1;var g=this._events[m],_=arguments.length,x,y;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),_){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,u),!0;case 4:return g.fn.call(g.context,c,u,d),!0;case 5:return g.fn.call(g.context,c,u,d,f),!0;case 6:return g.fn.call(g.context,c,u,d,f,p),!0}for(y=1,x=new Array(_-1);y<_;y++)x[y-1]=arguments[y];g.fn.apply(g.context,x)}else{var v=g.length,T;for(y=0;y<v;y++)switch(g[y].once&&this.removeListener(l,g[y].fn,void 0,!0),_){case 1:g[y].fn.call(g[y].context);break;case 2:g[y].fn.call(g[y].context,c);break;case 3:g[y].fn.call(g[y].context,c,u);break;case 4:g[y].fn.call(g[y].context,c,u,d);break;default:if(!x)for(T=1,x=new Array(_-1);T<_;T++)x[T-1]=arguments[T];g[y].fn.apply(g[y].context,x)}}return!0},o.prototype.on=function(l,c,u){return n(this,l,c,u,!1)},o.prototype.once=function(l,c,u){return n(this,l,c,u,!0)},o.prototype.removeListener=function(l,c,u,d){var f=e?e+l:l;if(!this._events[f])return this;if(!c)return a(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&a(this,f);else{for(var m=0,g=[],_=p.length;m<_;m++)(p[m].fn!==c||d&&!p[m].once||u&&p[m].context!==u)&&g.push(p[m]);g.length?this._events[f]=g.length===1?g[0]:g:a(this,f)}return this},o.prototype.removeAllListeners=function(l){var c;return l?(c=e?e+l:l,this._events[c]&&a(this,c)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,i.exports=o})(ro);var kc=ro.exports;const Xi=io(kc);var Xs={exports:{}};Xs.exports=Tr,Xs.exports.default=Tr;function Tr(i,t,e){e=e||2;var r=t&&t.length,s=r?t[0]*e:i.length,n=so(i,0,s,e,!0),a=[];if(!n||n.next===n.prev)return a;var o,h,l,c,u,d,f;if(r&&(n=Xc(i,t,n,e)),i.length>80*e){o=l=i[0],h=c=i[1];for(var p=e;p<s;p+=e)u=i[p],d=i[p+1],u<o&&(o=u),d<h&&(h=d),u>l&&(l=u),d>c&&(c=d);f=Math.max(l-o,c-h),f=f!==0?32767/f:0}return zi(n,a,e,o,h,f,0),a}function so(i,t,e,r,s){var n,a;if(s===Ws(i,t,e,r)>0)for(n=t;n<e;n+=r)a=oo(n,i[n],i[n+1],a);else for(n=e-r;n>=t;n-=r)a=oo(n,i[n],i[n+1],a);return a&&wr(a,a.next)&&(Wi(a),a=a.next),a}function je(i,t){if(!i)return i;t||(t=i);var e=i,r;do if(r=!1,!e.steiner&&(wr(e,e.next)||ot(e.prev,e,e.next)===0)){if(Wi(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function zi(i,t,e,r,s,n,a){if(i){!a&&n&&Yc(i,r,s,n);for(var o=i,h,l;i.prev!==i.next;){if(h=i.prev,l=i.next,n?Gc(i,r,s,n):Uc(i)){t.push(h.i/e|0),t.push(i.i/e|0),t.push(l.i/e|0),Wi(i),i=l.next,o=l.next;continue}if(i=l,i===o){a?a===1?(i=Hc(je(i),t,e),zi(i,t,e,r,s,n,2)):a===2&&$c(i,t,e,r,s,n):zi(je(i),t,e,r,s,n,1);break}}}}function Uc(i){var t=i.prev,e=i,r=i.next;if(ot(t,e,r)>=0)return!1;for(var s=t.x,n=e.x,a=r.x,o=t.y,h=e.y,l=r.y,c=s<n?s<a?s:a:n<a?n:a,u=o<h?o<l?o:l:h<l?h:l,d=s>n?s>a?s:a:n>a?n:a,f=o>h?o>l?o:l:h>l?h:l,p=r.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&fi(s,o,n,h,a,l,p.x,p.y)&&ot(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Gc(i,t,e,r){var s=i.prev,n=i,a=i.next;if(ot(s,n,a)>=0)return!1;for(var o=s.x,h=n.x,l=a.x,c=s.y,u=n.y,d=a.y,f=o<h?o<l?o:l:h<l?h:l,p=c<u?c<d?c:d:u<d?u:d,m=o>h?o>l?o:l:h>l?h:l,g=c>u?c>d?c:d:u>d?u:d,_=zs(f,p,t,e,r),x=zs(m,g,t,e,r),y=i.prevZ,v=i.nextZ;y&&y.z>=_&&v&&v.z<=x;){if(y.x>=f&&y.x<=m&&y.y>=p&&y.y<=g&&y!==s&&y!==a&&fi(o,c,h,u,l,d,y.x,y.y)&&ot(y.prev,y,y.next)>=0||(y=y.prevZ,v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==s&&v!==a&&fi(o,c,h,u,l,d,v.x,v.y)&&ot(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;y&&y.z>=_;){if(y.x>=f&&y.x<=m&&y.y>=p&&y.y<=g&&y!==s&&y!==a&&fi(o,c,h,u,l,d,y.x,y.y)&&ot(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;v&&v.z<=x;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==s&&v!==a&&fi(o,c,h,u,l,d,v.x,v.y)&&ot(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Hc(i,t,e){var r=i;do{var s=r.prev,n=r.next.next;!wr(s,n)&&no(s,r,r.next,n)&&Vi(s,n)&&Vi(n,s)&&(t.push(s.i/e|0),t.push(r.i/e|0),t.push(n.i/e|0),Wi(r),Wi(r.next),r=i=n),r=r.next}while(r!==i);return je(r)}function $c(i,t,e,r,s,n){var a=i;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&Zc(a,o)){var h=ao(a,o);a=je(a,a.next),h=je(h,h.next),zi(a,t,e,r,s,n,0),zi(h,t,e,r,s,n,0);return}o=o.next}a=a.next}while(a!==i)}function Xc(i,t,e,r){var s=[],n,a,o,h,l;for(n=0,a=t.length;n<a;n++)o=t[n]*r,h=n<a-1?t[n+1]*r:i.length,l=so(i,o,h,r,!1),l===l.next&&(l.steiner=!0),s.push(Kc(l));for(s.sort(zc),n=0;n<s.length;n++)e=Vc(s[n],e);return e}function zc(i,t){return i.x-t.x}function Vc(i,t){var e=Wc(i,t);if(!e)return t;var r=ao(e,i);return je(r,r.next),je(e,e.next)}function Wc(i,t){var e=t,r=i.x,s=i.y,n=-1/0,a;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){var o=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(o<=r&&o>n&&(n=o,a=e.x<e.next.x?e:e.next,o===r))return a}e=e.next}while(e!==t);if(!a)return null;var h=a,l=a.x,c=a.y,u=1/0,d;e=a;do r>=e.x&&e.x>=l&&r!==e.x&&fi(s<c?r:n,s,l,c,s<c?n:r,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(r-e.x),Vi(e,i)&&(d<u||d===u&&(e.x>a.x||e.x===a.x&&jc(a,e)))&&(a=e,u=d)),e=e.next;while(e!==h);return a}function jc(i,t){return ot(i.prev,i,t.prev)<0&&ot(t.next,i,i.next)<0}function Yc(i,t,e,r){var s=i;do s.z===0&&(s.z=zs(s.x,s.y,t,e,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i);s.prevZ.nextZ=null,s.prevZ=null,qc(s)}function qc(i){var t,e,r,s,n,a,o,h,l=1;do{for(e=i,i=null,n=null,a=0;e;){for(a++,r=e,o=0,t=0;t<l&&(o++,r=r.nextZ,!!r);t++);for(h=l;o>0||h>0&&r;)o!==0&&(h===0||!r||e.z<=r.z)?(s=e,e=e.nextZ,o--):(s=r,r=r.nextZ,h--),n?n.nextZ=s:i=s,s.prevZ=n,n=s;e=r}n.nextZ=null,l*=2}while(a>1);return i}function zs(i,t,e,r,s){return i=(i-e)*s|0,t=(t-r)*s|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function Kc(i){var t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function fi(i,t,e,r,s,n,a,o){return(s-a)*(t-o)>=(i-a)*(n-o)&&(i-a)*(r-o)>=(e-a)*(t-o)&&(e-a)*(n-o)>=(s-a)*(r-o)}function Zc(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!Jc(i,t)&&(Vi(i,t)&&Vi(t,i)&&Qc(i,t)&&(ot(i.prev,i,t.prev)||ot(i,t.prev,t))||wr(i,t)&&ot(i.prev,i,i.next)>0&&ot(t.prev,t,t.next)>0)}function ot(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function wr(i,t){return i.x===t.x&&i.y===t.y}function no(i,t,e,r){var s=Ar(ot(i,t,e)),n=Ar(ot(i,t,r)),a=Ar(ot(e,r,i)),o=Ar(ot(e,r,t));return!!(s!==n&&a!==o||s===0&&Er(i,e,t)||n===0&&Er(i,r,t)||a===0&&Er(e,i,r)||o===0&&Er(e,t,r))}function Er(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function Ar(i){return i>0?1:i<0?-1:0}function Jc(i,t){var e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&no(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Vi(i,t){return ot(i.prev,i,i.next)<0?ot(i,t,i.next)>=0&&ot(i,i.prev,t)>=0:ot(i,t,i.prev)<0||ot(i,i.next,t)<0}function Qc(i,t){var e=i,r=!1,s=(i.x+t.x)/2,n=(i.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==i);return r}function ao(i,t){var e=new Vs(i.i,i.x,i.y),r=new Vs(t.i,t.x,t.y),s=i.next,n=t.prev;return i.next=t,t.prev=i,e.next=s,s.prev=e,r.next=e,e.prev=r,n.next=r,r.prev=n,r}function oo(i,t,e,r){var s=new Vs(i,t,e);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function Wi(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Vs(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Tr.deviation=function(i,t,e,r){var s=t&&t.length,n=s?t[0]*e:i.length,a=Math.abs(Ws(i,0,n,e));if(s)for(var o=0,h=t.length;o<h;o++){var l=t[o]*e,c=o<h-1?t[o+1]*e:i.length;a-=Math.abs(Ws(i,l,c,e))}var u=0;for(o=0;o<r.length;o+=3){var d=r[o]*e,f=r[o+1]*e,p=r[o+2]*e;u+=Math.abs((i[d]-i[p])*(i[f+1]-i[d+1])-(i[d]-i[f])*(i[p+1]-i[d+1]))}return a===0&&u===0?0:Math.abs((u-a)/a)};function Ws(i,t,e,r){for(var s=0,n=t,a=e-r;n<e;n+=r)s+=(i[a]-i[n])*(i[n+1]+i[a+1]),a=n;return s}Tr.flatten=function(i){for(var t=i[0][0].length,e={vertices:[],holes:[],dimensions:t},r=0,s=0;s<i.length;s++){for(var n=0;n<i[s].length;n++)for(var a=0;a<t;a++)e.vertices.push(i[s][n][a]);s>0&&(r+=i[s-1].length,e.holes.push(r))}return e};var tu=Xs.exports;const eu=io(tu);var Sr={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */Sr.exports,function(i,t){(function(e){var r=t&&!t.nodeType&&t,s=i&&!i.nodeType&&i,n=typeof br=="object"&&br;(n.global===n||n.window===n||n.self===n)&&(e=n);var a,o=2147483647,h=36,l=1,c=26,u=38,d=700,f=72,p=128,m="-",g=/^xn--/,_=/[^\x20-\x7E]/,x=/[\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"},v=h-l,T=Math.floor,C=String.fromCharCode,E;function w(I){throw new RangeError(y[I])}function R(I,M){for(var Q=I.length,et=[];Q--;)et[Q]=M(I[Q]);return et}function N(I,M){var Q=I.split("@"),et="";Q.length>1&&(et=Q[0]+"@",I=Q[1]),I=I.replace(x,".");var it=I.split("."),At=R(it,M).join(".");return et+At}function q(I){for(var M=[],Q=0,et=I.length,it,At;Q<et;)it=I.charCodeAt(Q++),it>=55296&&it<=56319&&Q<et?(At=I.charCodeAt(Q++),(At&64512)==56320?M.push(((it&1023)<<10)+(At&1023)+65536):(M.push(it),Q--)):M.push(it);return M}function O(I){return R(I,function(M){var Q="";return M>65535&&(M-=65536,Q+=C(M>>>10&1023|55296),M=56320|M&1023),Q+=C(M),Q}).join("")}function b(I){return I-48<10?I-22:I-65<26?I-65:I-97<26?I-97:h}function S(I,M){return I+22+75*(I<26)-((M!=0)<<5)}function G(I,M,Q){var et=0;for(I=Q?T(I/d):I>>1,I+=T(I/M);I>v*c>>1;et+=h)I=T(I/v);return T(et+(v+1)*I/(I+u))}function j(I){var M=[],Q=I.length,et,it=0,At=p,mt=f,St,Ft,Nt,Pt,at,gt,Tt,me,ge;for(St=I.lastIndexOf(m),St<0&&(St=0),Ft=0;Ft<St;++Ft)I.charCodeAt(Ft)>=128&&w("not-basic"),M.push(I.charCodeAt(Ft));for(Nt=St>0?St+1:0;Nt<Q;){for(Pt=it,at=1,gt=h;Nt>=Q&&w("invalid-input"),Tt=b(I.charCodeAt(Nt++)),(Tt>=h||Tt>T((o-it)/at))&&w("overflow"),it+=Tt*at,me=gt<=mt?l:gt>=mt+c?c:gt-mt,!(Tt<me);gt+=h)ge=h-me,at>T(o/ge)&&w("overflow"),at*=ge;et=M.length+1,mt=G(it-Pt,et,Pt==0),T(it/et)>o-At&&w("overflow"),At+=T(it/et),it%=et,M.splice(it++,0,At)}return O(M)}function X(I){var M,Q,et,it,At,mt,St,Ft,Nt,Pt,at,gt=[],Tt,me,ge,pr;for(I=q(I),Tt=I.length,M=p,Q=0,At=f,mt=0;mt<Tt;++mt)at=I[mt],at<128&>.push(C(at));for(et=it=gt.length,it&>.push(m);et<Tt;){for(St=o,mt=0;mt<Tt;++mt)at=I[mt],at>=M&&at<St&&(St=at);for(me=et+1,St-M>T((o-Q)/me)&&w("overflow"),Q+=(St-M)*me,M=St,mt=0;mt<Tt;++mt)if(at=I[mt],at<M&&++Q>o&&w("overflow"),at==M){for(Ft=Q,Nt=h;Pt=Nt<=At?l:Nt>=At+c?c:Nt-At,!(Ft<Pt);Nt+=h)pr=Ft-Pt,ge=h-Pt,gt.push(C(S(Pt+pr%ge,0))),Ft=T(pr/ge);gt.push(C(S(Ft,0))),At=G(Q,me,et==it),Q=0,++et}++Q,++M}return gt.join("")}function V(I){return N(I,function(M){return g.test(M)?j(M.slice(4).toLowerCase()):M})}function nt(I){return N(I,function(M){return _.test(M)?"xn--"+X(M):M})}if(a={version:"1.4.1",ucs2:{decode:q,encode:O},decode:j,encode:X,toASCII:nt,toUnicode:V},r&&s)if(i.exports==r)s.exports=a;else for(E in a)a.hasOwnProperty(E)&&(r[E]=a[E]);else e.punycode=a})(br)}(Sr,Sr.exports);var iu=Sr.exports,ru=Error,su=EvalError,nu=RangeError,au=ReferenceError,ho=SyntaxError,ji=TypeError,ou=URIError,hu=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),r=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var s=42;t[e]=s;for(e in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var n=Object.getOwnPropertySymbols(t);if(n.length!==1||n[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,e);if(a.value!==s||a.enumerable!==!0)return!1}return!0},lo=typeof Symbol<"u"&&Symbol,lu=hu,cu=function(){return typeof lo!="function"||typeof Symbol!="function"||typeof lo("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:lu()},js={__proto__:null,foo:{}},uu=Object,du=function(){return{__proto__:js}.foo===js.foo&&!(js instanceof uu)},fu="Function.prototype.bind called on incompatible ",pu=Object.prototype.toString,mu=Math.max,gu="[object Function]",co=function(t,e){for(var r=[],s=0;s<t.length;s+=1)r[s]=t[s];for(var n=0;n<e.length;n+=1)r[n+t.length]=e[n];return r},yu=function(t,e){for(var r=[],s=e,n=0;s<t.length;s+=1,n+=1)r[n]=t[s];return r},_u=function(i,t){for(var e="",r=0;r<i.length;r+=1)e+=i[r],r+1<i.length&&(e+=t);return e},vu=function(t){var e=this;if(typeof e!="function"||pu.apply(e)!==gu)throw new TypeError(fu+e);for(var r=yu(arguments,1),s,n=function(){if(this instanceof s){var c=e.apply(this,co(r,arguments));return Object(c)===c?c:this}return e.apply(t,co(r,arguments))},a=mu(0,e.length-r.length),o=[],h=0;h<a;h++)o[h]="$"+h;if(s=Function("binder","return function ("+_u(o,",")+"){ return binder.apply(this,arguments); }")(n),e.prototype){var l=function(){};l.prototype=e.prototype,s.prototype=new l,l.prototype=null}return s},xu=vu,Ys=Function.prototype.bind||xu,bu=Function.prototype.call,Tu=Object.prototype.hasOwnProperty,wu=Ys,Eu=wu.call(bu,Tu),Z,Au=ru,Su=su,Cu=nu,Iu=au,pi=ho,mi=ji,Ru=ou,uo=Function,qs=function(i){try{return uo('"use strict"; return ('+i+").constructor;")()}catch{}},Ye=Object.getOwnPropertyDescriptor;if(Ye)try{Ye({},"")}catch{Ye=null}var Ks=function(){throw new mi},Pu=Ye?function(){try{return arguments.callee,Ks}catch{try{return Ye(arguments,"callee").get}catch{return Ks}}}():Ks,gi=cu(),Mu=du(),wt=Object.getPrototypeOf||(Mu?function(i){return i.__proto__}:null),yi={},Fu=typeof Uint8Array>"u"||!wt?Z:wt(Uint8Array),qe={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?Z:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Z:ArrayBuffer,"%ArrayIteratorPrototype%":gi&&wt?wt([][Symbol.iterator]()):Z,"%AsyncFromSyncIteratorPrototype%":Z,"%AsyncFunction%":yi,"%AsyncGenerator%":yi,"%AsyncGeneratorFunction%":yi,"%AsyncIteratorPrototype%":yi,"%Atomics%":typeof Atomics>"u"?Z:Atomics,"%BigInt%":typeof BigInt>"u"?Z:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Z:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Z:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Z:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Au,"%eval%":eval,"%EvalError%":Su,"%Float32Array%":typeof Float32Array>"u"?Z:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Z:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Z:FinalizationRegistry,"%Function%":uo,"%GeneratorFunction%":yi,"%Int8Array%":typeof Int8Array>"u"?Z:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Z:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Z:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":gi&&wt?wt(wt([][Symbol.iterator]())):Z,"%JSON%":typeof JSON=="object"?JSON:Z,"%Map%":typeof Map>"u"?Z:Map,"%MapIteratorPrototype%":typeof Map>"u"||!gi||!wt?Z:wt(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Z:Promise,"%Proxy%":typeof Proxy>"u"?Z:Proxy,"%RangeError%":Cu,"%ReferenceError%":Iu,"%Reflect%":typeof Reflect>"u"?Z:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Z:Set,"%SetIteratorPrototype%":typeof Set>"u"||!gi||!wt?Z:wt(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Z:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":gi&&wt?wt(""[Symbol.iterator]()):Z,"%Symbol%":gi?Symbol:Z,"%SyntaxError%":pi,"%ThrowTypeError%":Pu,"%TypedArray%":Fu,"%TypeError%":mi,"%Uint8Array%":typeof Uint8Array>"u"?Z:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Z:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Z:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Z:Uint32Array,"%URIError%":Ru,"%WeakMap%":typeof WeakMap>"u"?Z:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Z:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Z:WeakSet};if(wt)try{null.error}catch(i){var Bu=wt(wt(i));qe["%Error.prototype%"]=Bu}var Du=function i(t){var e;if(t==="%AsyncFunction%")e=qs("async function () {}");else if(t==="%GeneratorFunction%")e=qs("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=qs("async function* () {}");else if(t==="%AsyncGenerator%"){var r=i("%AsyncGeneratorFunction%");r&&(e=r.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=i("%AsyncGenerator%");s&&wt&&(e=wt(s.prototype))}return qe[t]=e,e},fo={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Yi=Ys,Cr=Eu,Ou=Yi.call(Function.call,Array.prototype.concat),Lu=Yi.call(Function.apply,Array.prototype.splice),po=Yi.call(Function.call,String.prototype.replace),Ir=Yi.call(Function.call,String.prototype.slice),Nu=Yi.call(Function.call,RegExp.prototype.exec),ku=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Uu=/\\(\\)?/g,Gu=function(t){var e=Ir(t,0,1),r=Ir(t,-1);if(e==="%"&&r!=="%")throw new pi("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&e!=="%")throw new pi("invalid intrinsic syntax, expected opening `%`");var s=[];return po(t,ku,function(n,a,o,h){s[s.length]=o?po(h,Uu,"$1"):a||n}),s},Hu=function(t,e){var r=t,s;if(Cr(fo,r)&&(s=fo[r],r="%"+s[0]+"%"),Cr(qe,r)){var n=qe[r];if(n===yi&&(n=Du(r)),typeof n>"u"&&!e)throw new mi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:r,value:n}}throw new pi("intrinsic "+t+" does not exist!")},_i=function(t,e){if(typeof t!="string"||t.length===0)throw new mi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new mi('"allowMissing" argument must be a boolean');if(Nu(/^%?[^%]*%?$/,t)===null)throw new pi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=Gu(t),s=r.length>0?r[0]:"",n=Hu("%"+s+"%",e),a=n.name,o=n.value,h=!1,l=n.alias;l&&(s=l[0],Lu(r,Ou([0,1],l)));for(var c=1,u=!0;c<r.length;c+=1){var d=r[c],f=Ir(d,0,1),p=Ir(d,-1);if((f==='"'||f==="'"||f==="`"||p==='"'||p==="'"||p==="`")&&f!==p)throw new pi("property names with quotes must have matching quotes");if((d==="constructor"||!u)&&(h=!0),s+="."+d,a="%"+s+"%",Cr(qe,a))o=qe[a];else if(o!=null){if(!(d in o)){if(!e)throw new mi("base intrinsic for "+t+" exists, but the property is not available.");return}if(Ye&&c+1>=r.length){var m=Ye(o,d);u=!!m,u&&"get"in m&&!("originalValue"in m.get)?o=m.get:o=o[d]}else u=Cr(o,d),o=o[d];u&&!h&&(qe[a]=o)}}return o},mo={exports:{}},Zs,go;function Js(){if(go)return Zs;go=1;var i=_i,t=i("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return Zs=t,Zs}var $u=_i,Rr=$u("%Object.getOwnPropertyDescriptor%",!0);if(Rr)try{Rr([],"length")}catch{Rr=null}var yo=Rr,_o=Js(),Xu=ho,vi=ji,vo=yo,zu=function(t,e,r){if(!t||typeof t!="object"&&typeof t!="function")throw new vi("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new vi("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new vi("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new vi("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new vi("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new vi("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,n=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,o=arguments.length>6?arguments[6]:!1,h=!!vo&&vo(t,e);if(_o)_o(t,e,{configurable:a===null&&h?h.configurable:!a,enumerable:s===null&&h?h.enumerable:!s,value:r,writable:n===null&&h?h.writable:!n});else if(o||!s&&!n&&!a)t[e]=r;else throw new Xu("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Qs=Js(),xo=function(){return!!Qs};xo.hasArrayLengthDefineBug=function(){if(!Qs)return null;try{return Qs([],"length",{value:1}).length!==1}catch{return!0}};var Vu=xo,Wu=_i,bo=zu,ju=Vu(),To=yo,wo=ji,Yu=Wu("%Math.floor%"),qu=function(t,e){if(typeof t!="function")throw new wo("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||Yu(e)!==e)throw new wo("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],s=!0,n=!0;if("length"in t&&To){var a=To(t,"length");a&&!a.configurable&&(s=!1),a&&!a.writable&&(n=!1)}return(s||n||!r)&&(ju?bo(t,"length",e,!0,!0):bo(t,"length",e)),t};(function(i){var t=Ys,e=_i,r=qu,s=ji,n=e("%Function.prototype.apply%"),a=e("%Function.prototype.call%"),o=e("%Reflect.apply%",!0)||t.call(a,n),h=Js(),l=e("%Math.max%");i.exports=function(d){if(typeof d!="function")throw new s("a function is required");var f=o(t,a,arguments);return r(f,1+l(0,d.length-(arguments.length-1)),!0)};var c=function(){return o(t,n,arguments)};h?h(i.exports,"apply",{value:c}):i.exports.apply=c})(mo);var Ku=mo.exports,Eo=_i,Ao=Ku,Zu=Ao(Eo("String.prototype.indexOf")),Ju=function(t,e){var r=Eo(t,!!e);return typeof r=="function"&&Zu(t,".prototype.")>-1?Ao(r):r};const Qu=Nc(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var tn=typeof Map=="function"&&Map.prototype,en=Object.getOwnPropertyDescriptor&&tn?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Pr=tn&&en&&typeof en.get=="function"?en.get:null,So=tn&&Map.prototype.forEach,rn=typeof Set=="function"&&Set.prototype,sn=Object.getOwnPropertyDescriptor&&rn?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Mr=rn&&sn&&typeof sn.get=="function"?sn.get:null,Co=rn&&Set.prototype.forEach,td=typeof WeakMap=="function"&&WeakMap.prototype,qi=td?WeakMap.prototype.has:null,ed=typeof WeakSet=="function"&&WeakSet.prototype,Ki=ed?WeakSet.prototype.has:null,id=typeof WeakRef=="function"&&WeakRef.prototype,Io=id?WeakRef.prototype.deref:null,rd=Boolean.prototype.valueOf,sd=Object.prototype.toString,nd=Function.prototype.toString,ad=String.prototype.match,nn=String.prototype.slice,Fe=String.prototype.replace,od=String.prototype.toUpperCase,Ro=String.prototype.toLowerCase,Po=RegExp.prototype.test,Mo=Array.prototype.concat,se=Array.prototype.join,hd=Array.prototype.slice,Fo=Math.floor,an=typeof BigInt=="function"?BigInt.prototype.valueOf:null,on=Object.getOwnPropertySymbols,hn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,xi=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Mt=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===xi||!0)?Symbol.toStringTag:null,Bo=Object.prototype.propertyIsEnumerable,Do=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(i){return i.__proto__}:null);function Oo(i,t){if(i===1/0||i===-1/0||i!==i||i&&i>-1e3&&i<1e3||Po.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof i=="number"){var r=i<0?-Fo(-i):Fo(i);if(r!==i){var s=String(r),n=nn.call(t,s.length+1);return Fe.call(s,e,"$&_")+"."+Fe.call(Fe.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Fe.call(t,e,"$&_")}var ln=Qu,Lo=ln.custom,No=Go(Lo)?Lo:null,ld=function i(t,e,r,s){var n=e||{};if(Be(n,"quoteStyle")&&n.quoteStyle!=="single"&&n.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Be(n,"maxStringLength")&&(typeof n.maxStringLength=="number"?n.maxStringLength<0&&n.maxStringLength!==1/0:n.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=Be(n,"customInspect")?n.customInspect:!0;if(typeof a!="boolean"&&a!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Be(n,"indent")&&n.indent!==null&&n.indent!==" "&&!(parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Be(n,"numericSeparator")&&typeof n.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var o=n.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return $o(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var h=String(t);return o?Oo(t,h):h}if(typeof t=="bigint"){var l=String(t)+"n";return o?Oo(t,l):l}var c=typeof n.depth>"u"?5:n.depth;if(typeof r>"u"&&(r=0),r>=c&&c>0&&typeof t=="object")return cn(t)?"[Array]":"[Object]";var u=Cd(n,r);if(typeof s>"u")s=[];else if(Ho(s,t)>=0)return"[Circular]";function d(b,S,G){if(S&&(s=hd.call(s),s.push(S)),G){var j={depth:n.depth};return Be(n,"quoteStyle")&&(j.quoteStyle=n.quoteStyle),i(b,j,r+1,s)}return i(b,n,r+1,s)}if(typeof t=="function"&&!Uo(t)){var f=_d(t),p=Fr(t,d);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(p.length>0?" { "+se.call(p,", ")+" }":"")}if(Go(t)){var m=xi?Fe.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):hn.call(t);return typeof t=="object"&&!xi?Zi(m):m}if(Ed(t)){for(var g="<"+Ro.call(String(t.nodeName)),_=t.attributes||[],x=0;x<_.length;x++)g+=" "+_[x].name+"="+ko(cd(_[x].value),"double",n);return g+=">",t.childNodes&&t.childNodes.length&&(g+="..."),g+="</"+Ro.call(String(t.nodeName))+">",g}if(cn(t)){if(t.length===0)return"[]";var y=Fr(t,d);return u&&!Sd(y)?"["+dn(y,u)+"]":"[ "+se.call(y,", ")+" ]"}if(dd(t)){var v=Fr(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!Bo.call(t,"cause")?"{ ["+String(t)+"] "+se.call(Mo.call("[cause]: "+d(t.cause),v),", ")+" }":v.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+se.call(v,", ")+" }"}if(typeof t=="object"&&a){if(No&&typeof t[No]=="function"&&ln)return ln(t,{depth:c-r});if(a!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(vd(t)){var T=[];return So&&So.call(t,function(b,S){T.push(d(S,t,!0)+" => "+d(b,t))}),Xo("Map",Pr.call(t),T,u)}if(Td(t)){var C=[];return Co&&Co.call(t,function(b){C.push(d(b,t))}),Xo("Set",Mr.call(t),C,u)}if(xd(t))return un("WeakMap");if(wd(t))return un("WeakSet");if(bd(t))return un("WeakRef");if(pd(t))return Zi(d(Number(t)));if(gd(t))return Zi(d(an.call(t)));if(md(t))return Zi(rd.call(t));if(fd(t))return Zi(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(t===br)return"{ [object globalThis] }";if(!ud(t)&&!Uo(t)){var E=Fr(t,d),w=Do?Do(t)===Object.prototype:t instanceof Object||t.constructor===Object,R=t instanceof Object?"":"null prototype",N=!w&&Mt&&Object(t)===t&&Mt in t?nn.call(De(t),8,-1):R?"Object":"",q=w||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",O=q+(N||R?"["+se.call(Mo.call([],N||[],R||[]),": ")+"] ":"");return E.length===0?O+"{}":u?O+"{"+dn(E,u)+"}":O+"{ "+se.call(E,", ")+" }"}return String(t)};function ko(i,t,e){var r=(e.quoteStyle||t)==="double"?'"':"'";return r+i+r}function cd(i){return Fe.call(String(i),/"/g,""")}function cn(i){return De(i)==="[object Array]"&&(!Mt||!(typeof i=="object"&&Mt in i))}function ud(i){return De(i)==="[object Date]"&&(!Mt||!(typeof i=="object"&&Mt in i))}function Uo(i){return De(i)==="[object RegExp]"&&(!Mt||!(typeof i=="object"&&Mt in i))}function dd(i){return De(i)==="[object Error]"&&(!Mt||!(typeof i=="object"&&Mt in i))}function fd(i){return De(i)==="[object String]"&&(!Mt||!(typeof i=="object"&&Mt in i))}function pd(i){return De(i)==="[object Number]"&&(!Mt||!(typeof i=="object"&&Mt in i))}function md(i){return De(i)==="[object Boolean]"&&(!Mt||!(typeof i=="object"&&Mt in i))}function Go(i){if(xi)return i&&typeof i=="object"&&i instanceof Symbol;if(typeof i=="symbol")return!0;if(!i||typeof i!="object"||!hn)return!1;try{return hn.call(i),!0}catch{}return!1}function gd(i){if(!i||typeof i!="object"||!an)return!1;try{return an.call(i),!0}catch{}return!1}var yd=Object.prototype.hasOwnProperty||function(i){return i in this};function Be(i,t){return yd.call(i,t)}function De(i){return sd.call(i)}function _d(i){if(i.name)return i.name;var t=ad.call(nd.call(i),/^function\s*([\w$]+)/);return t?t[1]:null}function Ho(i,t){if(i.indexOf)return i.indexOf(t);for(var e=0,r=i.length;e<r;e++)if(i[e]===t)return e;return-1}function vd(i){if(!Pr||!i||typeof i!="object")return!1;try{Pr.call(i);try{Mr.call(i)}catch{return!0}return i instanceof Map}catch{}return!1}function xd(i){if(!qi||!i||typeof i!="object")return!1;try{qi.call(i,qi);try{Ki.call(i,Ki)}catch{return!0}return i instanceof WeakMap}catch{}return!1}function bd(i){if(!Io||!i||typeof i!="object")return!1;try{return Io.call(i),!0}catch{}return!1}function Td(i){if(!Mr||!i||typeof i!="object")return!1;try{Mr.call(i);try{Pr.call(i)}catch{return!0}return i instanceof Set}catch{}return!1}function wd(i){if(!Ki||!i||typeof i!="object")return!1;try{Ki.call(i,Ki);try{qi.call(i,qi)}catch{return!0}return i instanceof WeakSet}catch{}return!1}function Ed(i){return!i||typeof i!="object"?!1:typeof HTMLElement<"u"&&i instanceof HTMLElement?!0:typeof i.nodeName=="string"&&typeof i.getAttribute=="function"}function $o(i,t){if(i.length>t.maxStringLength){var e=i.length-t.maxStringLength,r="... "+e+" more character"+(e>1?"s":"");return $o(nn.call(i,0,t.maxStringLength),t)+r}var s=Fe.call(Fe.call(i,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,Ad);return ko(s,"single",t)}function Ad(i){var t=i.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+od.call(t.toString(16))}function Zi(i){return"Object("+i+")"}function un(i){return i+" { ? }"}function Xo(i,t,e,r){var s=r?dn(e,r):se.call(e,", ");return i+" ("+t+") {"+s+"}"}function Sd(i){for(var t=0;t<i.length;t++)if(Ho(i[t],`
|
|
2
|
-
|
|
3
|
-
`+t.prev+t.base;return e+se.call(i,","+e)+`
|
|
4
|
-
`+t.prev}function Fr(i,t){var e=cn(i),r=[];if(e){r.length=i.length;for(var s=0;s<i.length;s++)r[s]=Be(i,s)?t(i[s],i):""}var n=typeof on=="function"?on(i):[],a;if(xi){a={};for(var o=0;o<n.length;o++)a["$"+n[o]]=n[o]}for(var h in i)Be(i,h)&&(e&&String(Number(h))===h&&h<i.length||xi&&a["$"+h]instanceof Symbol||(Po.call(/[^\w$]/,h)?r.push(t(h,i)+": "+t(i[h],i)):r.push(h+": "+t(i[h],i))));if(typeof on=="function")for(var l=0;l<n.length;l++)Bo.call(i,n[l])&&r.push("["+t(n[l])+"]: "+t(i[n[l]],i));return r}var zo=_i,bi=Ju,Id=ld,Rd=ji,Br=zo("%WeakMap%",!0),Dr=zo("%Map%",!0),Pd=bi("WeakMap.prototype.get",!0),Md=bi("WeakMap.prototype.set",!0),Fd=bi("WeakMap.prototype.has",!0),Bd=bi("Map.prototype.get",!0),Dd=bi("Map.prototype.set",!0),Od=bi("Map.prototype.has",!0),fn=function(i,t){for(var e=i,r;(r=e.next)!==null;e=r)if(r.key===t)return e.next=r.next,r.next=i.next,i.next=r,r},Ld=function(i,t){var e=fn(i,t);return e&&e.value},Nd=function(i,t,e){var r=fn(i,t);r?r.value=e:i.next={key:t,next:i.next,value:e}},kd=function(i,t){return!!fn(i,t)},Ud=function(){var t,e,r,s={assert:function(n){if(!s.has(n))throw new Rd("Side channel does not contain "+Id(n))},get:function(n){if(Br&&n&&(typeof n=="object"||typeof n=="function")){if(t)return Pd(t,n)}else if(Dr){if(e)return Bd(e,n)}else if(r)return Ld(r,n)},has:function(n){if(Br&&n&&(typeof n=="object"||typeof n=="function")){if(t)return Fd(t,n)}else if(Dr){if(e)return Od(e,n)}else if(r)return kd(r,n);return!1},set:function(n,a){Br&&n&&(typeof n=="object"||typeof n=="function")?(t||(t=new Br),Md(t,n,a)):Dr?(e||(e=new Dr),Dd(e,n,a)):(r||(r={key:{},next:null}),Nd(r,n,a))}};return s},Gd=String.prototype.replace,Hd=/%20/g,pn={RFC1738:"RFC1738",RFC3986:"RFC3986"},mn={default:pn.RFC3986,formatters:{RFC1738:function(i){return Gd.call(i,Hd,"+")},RFC3986:function(i){return String(i)}},RFC1738:pn.RFC1738,RFC3986:pn.RFC3986},$d=mn,gn=Object.prototype.hasOwnProperty,Ke=Array.isArray,ne=function(){for(var i=[],t=0;t<256;++t)i.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return i}(),Xd=function(t){for(;t.length>1;){var e=t.pop(),r=e.obj[e.prop];if(Ke(r)){for(var s=[],n=0;n<r.length;++n)typeof r[n]<"u"&&s.push(r[n]);e.obj[e.prop]=s}}},Vo=function(t,e){for(var r=e&&e.plainObjects?Object.create(null):{},s=0;s<t.length;++s)typeof t[s]<"u"&&(r[s]=t[s]);return r},zd=function i(t,e,r){if(!e)return t;if(typeof e!="object"){if(Ke(t))t.push(e);else if(t&&typeof t=="object")(r&&(r.plainObjects||r.allowPrototypes)||!gn.call(Object.prototype,e))&&(t[e]=!0);else return[t,e];return t}if(!t||typeof t!="object")return[t].concat(e);var s=t;return Ke(t)&&!Ke(e)&&(s=Vo(t,r)),Ke(t)&&Ke(e)?(e.forEach(function(n,a){if(gn.call(t,a)){var o=t[a];o&&typeof o=="object"&&n&&typeof n=="object"?t[a]=i(o,n,r):t.push(n)}else t[a]=n}),t):Object.keys(e).reduce(function(n,a){var o=e[a];return gn.call(n,a)?n[a]=i(n[a],o,r):n[a]=o,n},s)},Vd=function(t,e){return Object.keys(e).reduce(function(r,s){return r[s]=e[s],r},t)},Wd=function(i,t,e){var r=i.replace(/\+/g," ");if(e==="iso-8859-1")return r.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(r)}catch{return r}},yn=1024,jd=function(t,e,r,s,n){if(t.length===0)return t;var a=t;if(typeof t=="symbol"?a=Symbol.prototype.toString.call(t):typeof t!="string"&&(a=String(t)),r==="iso-8859-1")return escape(a).replace(/%u[0-9a-f]{4}/gi,function(f){return"%26%23"+parseInt(f.slice(2),16)+"%3B"});for(var o="",h=0;h<a.length;h+=yn){for(var l=a.length>=yn?a.slice(h,h+yn):a,c=[],u=0;u<l.length;++u){var d=l.charCodeAt(u);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||n===$d.RFC1738&&(d===40||d===41)){c[c.length]=l.charAt(u);continue}if(d<128){c[c.length]=ne[d];continue}if(d<2048){c[c.length]=ne[192|d>>6]+ne[128|d&63];continue}if(d<55296||d>=57344){c[c.length]=ne[224|d>>12]+ne[128|d>>6&63]+ne[128|d&63];continue}u+=1,d=65536+((d&1023)<<10|l.charCodeAt(u)&1023),c[c.length]=ne[240|d>>18]+ne[128|d>>12&63]+ne[128|d>>6&63]+ne[128|d&63]}o+=c.join("")}return o},Yd=function(t){for(var e=[{obj:{o:t},prop:"o"}],r=[],s=0;s<e.length;++s)for(var n=e[s],a=n.obj[n.prop],o=Object.keys(a),h=0;h<o.length;++h){var l=o[h],c=a[l];typeof c=="object"&&c!==null&&r.indexOf(c)===-1&&(e.push({obj:a,prop:l}),r.push(c))}return Xd(e),t},qd=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},Kd=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},Zd=function(t,e){return[].concat(t,e)},Jd=function(t,e){if(Ke(t)){for(var r=[],s=0;s<t.length;s+=1)r.push(e(t[s]));return r}return e(t)},Wo={arrayToObject:Vo,assign:Vd,combine:Zd,compact:Yd,decode:Wd,encode:jd,isBuffer:Kd,isRegExp:qd,maybeMap:Jd,merge:zd},jo=Ud,Or=Wo,Ji=mn,Qd=Object.prototype.hasOwnProperty,Yo={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},ae=Array.isArray,tf=Array.prototype.push,qo=function(i,t){tf.apply(i,ae(t)?t:[t])},ef=Date.prototype.toISOString,Ko=Ji.default,vt={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Or.encode,encodeValuesOnly:!1,format:Ko,formatter:Ji.formatters[Ko],indices:!1,serializeDate:function(t){return ef.call(t)},skipNulls:!1,strictNullHandling:!1},rf=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},_n={},sf=function i(t,e,r,s,n,a,o,h,l,c,u,d,f,p,m,g,_,x){for(var y=t,v=x,T=0,C=!1;(v=v.get(_n))!==void 0&&!C;){var E=v.get(t);if(T+=1,typeof E<"u"){if(E===T)throw new RangeError("Cyclic object value");C=!0}typeof v.get(_n)>"u"&&(T=0)}if(typeof c=="function"?y=c(e,y):y instanceof Date?y=f(y):r==="comma"&&ae(y)&&(y=Or.maybeMap(y,function(I){return I instanceof Date?f(I):I})),y===null){if(a)return l&&!g?l(e,vt.encoder,_,"key",p):e;y=""}if(rf(y)||Or.isBuffer(y)){if(l){var w=g?e:l(e,vt.encoder,_,"key",p);return[m(w)+"="+m(l(y,vt.encoder,_,"value",p))]}return[m(e)+"="+m(String(y))]}var R=[];if(typeof y>"u")return R;var N;if(r==="comma"&&ae(y))g&&l&&(y=Or.maybeMap(y,l)),N=[{value:y.length>0?y.join(",")||null:void 0}];else if(ae(c))N=c;else{var q=Object.keys(y);N=u?q.sort(u):q}var O=h?e.replace(/\./g,"%2E"):e,b=s&&ae(y)&&y.length===1?O+"[]":O;if(n&&ae(y)&&y.length===0)return b+"[]";for(var S=0;S<N.length;++S){var G=N[S],j=typeof G=="object"&&typeof G.value<"u"?G.value:y[G];if(!(o&&j===null)){var X=d&&h?G.replace(/\./g,"%2E"):G,V=ae(y)?typeof r=="function"?r(b,X):b:b+(d?"."+X:"["+X+"]");x.set(t,T);var nt=jo();nt.set(_n,x),qo(R,i(j,V,r,s,n,a,o,h,r==="comma"&&g&&ae(y)?null:l,c,u,d,f,p,m,g,_,nt))}}return R},nf=function(t){if(!t)return vt;if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.encodeDotInKeys<"u"&&typeof t.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(t.encoder!==null&&typeof t.encoder<"u"&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");var e=t.charset||vt.charset;if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=Ji.default;if(typeof t.format<"u"){if(!Qd.call(Ji.formatters,t.format))throw new TypeError("Unknown format option provided.");r=t.format}var s=Ji.formatters[r],n=vt.filter;(typeof t.filter=="function"||ae(t.filter))&&(n=t.filter);var a;if(t.arrayFormat in Yo?a=t.arrayFormat:"indices"in t?a=t.indices?"indices":"repeat":a=vt.arrayFormat,"commaRoundTrip"in t&&typeof t.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var o=typeof t.allowDots>"u"?t.encodeDotInKeys===!0?!0:vt.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:vt.addQueryPrefix,allowDots:o,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:vt.allowEmptyArrays,arrayFormat:a,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:vt.charsetSentinel,commaRoundTrip:t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?vt.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:vt.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:vt.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:vt.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:vt.encodeValuesOnly,filter:n,format:r,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:vt.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:vt.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:vt.strictNullHandling}},af=function(i,t){var e=i,r=nf(t),s,n;typeof r.filter=="function"?(n=r.filter,e=n("",e)):ae(r.filter)&&(n=r.filter,s=n);var a=[];if(typeof e!="object"||e===null)return"";var o=Yo[r.arrayFormat],h=o==="comma"&&r.commaRoundTrip;s||(s=Object.keys(e)),r.sort&&s.sort(r.sort);for(var l=jo(),c=0;c<s.length;++c){var u=s[c];r.skipNulls&&e[u]===null||qo(a,sf(e[u],u,o,h,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,l))}var d=a.join(r.delimiter),f=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),d.length>0?f+d:""},Ti=Wo,vn=Object.prototype.hasOwnProperty,of=Array.isArray,ct={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:Ti.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},hf=function(i){return i.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},Zo=function(i,t){return i&&typeof i=="string"&&t.comma&&i.indexOf(",")>-1?i.split(","):i},lf="utf8=%26%2310003%3B",cf="utf8=%E2%9C%93",uf=function(t,e){var r={__proto__:null},s=e.ignoreQueryPrefix?t.replace(/^\?/,""):t,n=e.parameterLimit===1/0?void 0:e.parameterLimit,a=s.split(e.delimiter,n),o=-1,h,l=e.charset;if(e.charsetSentinel)for(h=0;h<a.length;++h)a[h].indexOf("utf8=")===0&&(a[h]===cf?l="utf-8":a[h]===lf&&(l="iso-8859-1"),o=h,h=a.length);for(h=0;h<a.length;++h)if(h!==o){var c=a[h],u=c.indexOf("]="),d=u===-1?c.indexOf("="):u+1,f,p;d===-1?(f=e.decoder(c,ct.decoder,l,"key"),p=e.strictNullHandling?null:""):(f=e.decoder(c.slice(0,d),ct.decoder,l,"key"),p=Ti.maybeMap(Zo(c.slice(d+1),e),function(g){return e.decoder(g,ct.decoder,l,"value")})),p&&e.interpretNumericEntities&&l==="iso-8859-1"&&(p=hf(p)),c.indexOf("[]=")>-1&&(p=of(p)?[p]:p);var m=vn.call(r,f);m&&e.duplicates==="combine"?r[f]=Ti.combine(r[f],p):(!m||e.duplicates==="last")&&(r[f]=p)}return r},df=function(i,t,e,r){for(var s=r?t:Zo(t,e),n=i.length-1;n>=0;--n){var a,o=i[n];if(o==="[]"&&e.parseArrays)a=e.allowEmptyArrays&&s===""?[]:[].concat(s);else{a=e.plainObjects?Object.create(null):{};var h=o.charAt(0)==="["&&o.charAt(o.length-1)==="]"?o.slice(1,-1):o,l=e.decodeDotInKeys?h.replace(/%2E/g,"."):h,c=parseInt(l,10);!e.parseArrays&&l===""?a={0:s}:!isNaN(c)&&o!==l&&String(c)===l&&c>=0&&e.parseArrays&&c<=e.arrayLimit?(a=[],a[c]=s):l!=="__proto__"&&(a[l]=s)}s=a}return s},ff=function(t,e,r,s){if(t){var n=r.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,a=/(\[[^[\]]*])/,o=/(\[[^[\]]*])/g,h=r.depth>0&&a.exec(n),l=h?n.slice(0,h.index):n,c=[];if(l){if(!r.plainObjects&&vn.call(Object.prototype,l)&&!r.allowPrototypes)return;c.push(l)}for(var u=0;r.depth>0&&(h=o.exec(n))!==null&&u<r.depth;){if(u+=1,!r.plainObjects&&vn.call(Object.prototype,h[1].slice(1,-1))&&!r.allowPrototypes)return;c.push(h[1])}return h&&c.push("["+n.slice(h.index)+"]"),df(c,e,r,s)}},pf=function(t){if(!t)return ct;if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.decodeDotInKeys<"u"&&typeof t.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(t.decoder!==null&&typeof t.decoder<"u"&&typeof t.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var e=typeof t.charset>"u"?ct.charset:t.charset,r=typeof t.duplicates>"u"?ct.duplicates:t.duplicates;if(r!=="combine"&&r!=="first"&&r!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var s=typeof t.allowDots>"u"?t.decodeDotInKeys===!0?!0:ct.allowDots:!!t.allowDots;return{allowDots:s,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:ct.allowEmptyArrays,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:ct.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:ct.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:ct.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:ct.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:ct.comma,decodeDotInKeys:typeof t.decodeDotInKeys=="boolean"?t.decodeDotInKeys:ct.decodeDotInKeys,decoder:typeof t.decoder=="function"?t.decoder:ct.decoder,delimiter:typeof t.delimiter=="string"||Ti.isRegExp(t.delimiter)?t.delimiter:ct.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:ct.depth,duplicates:r,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:ct.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:ct.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:ct.plainObjects,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:ct.strictNullHandling}},mf=function(i,t){var e=pf(t);if(i===""||i===null||typeof i>"u")return e.plainObjects?Object.create(null):{};for(var r=typeof i=="string"?uf(i,e):i,s=e.plainObjects?Object.create(null):{},n=Object.keys(r),a=0;a<n.length;++a){var o=n[a],h=ff(o,r[o],e,typeof i=="string");s=Ti.merge(s,h,e)}return e.allowSparse===!0?s:Ti.compact(s)},gf=af,yf=mf,_f=mn,vf={formats:_f,parse:yf,stringify:gf},xf=iu;function xe(){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 bf=/^([a-z0-9.+-]+:)/i,Tf=/:[0-9]*$/,wf=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,Ef=["<",">",'"',"`"," ","\r",`
|
|
5
|
-
`," "],Af=["{","}","|","\\","^","`"].concat(Ef),xn=["'"].concat(Af),Jo=["%","/","?",";","#"].concat(xn),Qo=["/","?","#"],Sf=255,th=/^[+a-z0-9A-Z_-]{0,63}$/,Cf=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,If={javascript:!0,"javascript:":!0},bn={javascript:!0,"javascript:":!0},wi={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},Tn=vf;function Rf(i,t,e){if(i&&typeof i=="object"&&i instanceof xe)return i;var r=new xe;return r.parse(i,t,e),r}xe.prototype.parse=function(i,t,e){if(typeof i!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof i);var r=i.indexOf("?"),s=r!==-1&&r<i.indexOf("#")?"?":"#",n=i.split(s),a=/\\/g;n[0]=n[0].replace(a,"/"),i=n.join(s);var o=i;if(o=o.trim(),!e&&i.split("#").length===1){var h=wf.exec(o);if(h)return this.path=o,this.href=o,this.pathname=h[1],h[2]?(this.search=h[2],t?this.query=Tn.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var l=bf.exec(o);if(l){l=l[0];var c=l.toLowerCase();this.protocol=c,o=o.substr(l.length)}if(e||l||o.match(/^\/\/[^@/]+@[^@/]+/)){var u=o.substr(0,2)==="//";u&&!(l&&bn[l])&&(o=o.substr(2),this.slashes=!0)}if(!bn[l]&&(u||l&&!wi[l])){for(var d=-1,f=0;f<Qo.length;f++){var p=o.indexOf(Qo[f]);p!==-1&&(d===-1||p<d)&&(d=p)}var m,g;d===-1?g=o.lastIndexOf("@"):g=o.lastIndexOf("@",d),g!==-1&&(m=o.slice(0,g),o=o.slice(g+1),this.auth=decodeURIComponent(m)),d=-1;for(var f=0;f<Jo.length;f++){var p=o.indexOf(Jo[f]);p!==-1&&(d===-1||p<d)&&(d=p)}d===-1&&(d=o.length),this.host=o.slice(0,d),o=o.slice(d),this.parseHost(),this.hostname=this.hostname||"";var _=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!_)for(var x=this.hostname.split(/\./),f=0,y=x.length;f<y;f++){var v=x[f];if(v&&!v.match(th)){for(var T="",C=0,E=v.length;C<E;C++)v.charCodeAt(C)>127?T+="x":T+=v[C];if(!T.match(th)){var w=x.slice(0,f),R=x.slice(f+1),N=v.match(Cf);N&&(w.push(N[1]),R.unshift(N[2])),R.length&&(o="/"+R.join(".")+o),this.hostname=w.join(".");break}}}this.hostname.length>Sf?this.hostname="":this.hostname=this.hostname.toLowerCase(),_||(this.hostname=xf.toASCII(this.hostname));var q=this.port?":"+this.port:"",O=this.hostname||"";this.host=O+q,this.href+=this.host,_&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),o[0]!=="/"&&(o="/"+o))}if(!If[c])for(var f=0,y=xn.length;f<y;f++){var b=xn[f];if(o.indexOf(b)!==-1){var S=encodeURIComponent(b);S===b&&(S=escape(b)),o=o.split(b).join(S)}}var G=o.indexOf("#");G!==-1&&(this.hash=o.substr(G),o=o.slice(0,G));var j=o.indexOf("?");if(j!==-1?(this.search=o.substr(j),this.query=o.substr(j+1),t&&(this.query=Tn.parse(this.query)),o=o.slice(0,j)):t&&(this.search="",this.query={}),o&&(this.pathname=o),wi[c]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var q=this.pathname||"",X=this.search||"";this.path=q+X}return this.href=this.format(),this},xe.prototype.format=function(){var i=this.auth||"";i&&(i=encodeURIComponent(i),i=i.replace(/%3A/i,":"),i+="@");var t=this.protocol||"",e=this.pathname||"",r=this.hash||"",s=!1,n="";this.host?s=i+this.host:this.hostname&&(s=i+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(n=Tn.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var a=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||wi[t])&&s!==!1?(s="//"+(s||""),e&&e.charAt(0)!=="/"&&(e="/"+e)):s||(s=""),r&&r.charAt(0)!=="#"&&(r="#"+r),a&&a.charAt(0)!=="?"&&(a="?"+a),e=e.replace(/[?#]/g,function(o){return encodeURIComponent(o)}),a=a.replace("#","%23"),t+s+e+a+r},xe.prototype.resolve=function(i){return this.resolveObject(Rf(i,!1,!0)).format()},xe.prototype.resolveObject=function(i){if(typeof i=="string"){var t=new xe;t.parse(i,!1,!0),i=t}for(var e=new xe,r=Object.keys(this),s=0;s<r.length;s++){var n=r[s];e[n]=this[n]}if(e.hash=i.hash,i.href==="")return e.href=e.format(),e;if(i.slashes&&!i.protocol){for(var a=Object.keys(i),o=0;o<a.length;o++){var h=a[o];h!=="protocol"&&(e[h]=i[h])}return wi[e.protocol]&&e.hostname&&!e.pathname&&(e.pathname="/",e.path=e.pathname),e.href=e.format(),e}if(i.protocol&&i.protocol!==e.protocol){if(!wi[i.protocol]){for(var l=Object.keys(i),c=0;c<l.length;c++){var u=l[c];e[u]=i[u]}return e.href=e.format(),e}if(e.protocol=i.protocol,!i.host&&!bn[i.protocol]){for(var y=(i.pathname||"").split("/");y.length&&!(i.host=y.shift()););i.host||(i.host=""),i.hostname||(i.hostname=""),y[0]!==""&&y.unshift(""),y.length<2&&y.unshift(""),e.pathname=y.join("/")}else e.pathname=i.pathname;if(e.search=i.search,e.query=i.query,e.host=i.host||"",e.auth=i.auth,e.hostname=i.hostname||i.host,e.port=i.port,e.pathname||e.search){var d=e.pathname||"",f=e.search||"";e.path=d+f}return e.slashes=e.slashes||i.slashes,e.href=e.format(),e}var p=e.pathname&&e.pathname.charAt(0)==="/",m=i.host||i.pathname&&i.pathname.charAt(0)==="/",g=m||p||e.host&&i.pathname,_=g,x=e.pathname&&e.pathname.split("/")||[],y=i.pathname&&i.pathname.split("/")||[],v=e.protocol&&!wi[e.protocol];if(v&&(e.hostname="",e.port=null,e.host&&(x[0]===""?x[0]=e.host:x.unshift(e.host)),e.host="",i.protocol&&(i.hostname=null,i.port=null,i.host&&(y[0]===""?y[0]=i.host:y.unshift(i.host)),i.host=null),g=g&&(y[0]===""||x[0]==="")),m)e.host=i.host||i.host===""?i.host:e.host,e.hostname=i.hostname||i.hostname===""?i.hostname:e.hostname,e.search=i.search,e.query=i.query,x=y;else if(y.length)x||(x=[]),x.pop(),x=x.concat(y),e.search=i.search,e.query=i.query;else if(i.search!=null){if(v){e.host=x.shift(),e.hostname=e.host;var T=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;T&&(e.auth=T.shift(),e.hostname=T.shift(),e.host=e.hostname)}return e.search=i.search,e.query=i.query,(e.pathname!==null||e.search!==null)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=e.format(),e}if(!x.length)return e.pathname=null,e.search?e.path="/"+e.search:e.path=null,e.href=e.format(),e;for(var C=x.slice(-1)[0],E=(e.host||i.host||x.length>1)&&(C==="."||C==="..")||C==="",w=0,R=x.length;R>=0;R--)C=x[R],C==="."?x.splice(R,1):C===".."?(x.splice(R,1),w++):w&&(x.splice(R,1),w--);if(!g&&!_)for(;w--;w)x.unshift("..");g&&x[0]!==""&&(!x[0]||x[0].charAt(0)!=="/")&&x.unshift(""),E&&x.join("/").substr(-1)!=="/"&&x.push("");var N=x[0]===""||x[0]&&x[0].charAt(0)==="/";if(v){e.hostname=N?"":x.length?x.shift():"",e.host=e.hostname;var T=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;T&&(e.auth=T.shift(),e.hostname=T.shift(),e.host=e.hostname)}return g=g||e.host&&x.length,g&&!N&&x.unshift(""),x.length>0?e.pathname=x.join("/"):(e.pathname=null,e.path=null),(e.pathname!==null||e.search!==null)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.auth=i.auth||e.auth,e.slashes=e.slashes||i.slashes,e.href=e.format(),e},xe.prototype.parseHost=function(){var i=this.host,t=Tf.exec(i);t&&(t=t[0],t!==":"&&(this.port=t.substr(1)),i=i.substr(0,i.length-t.length)),i&&(this.hostname=i)};const eh={};function K(i,t,e=3){if(eh[t])return;let r=new Error().stack;typeof r>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
|
|
6
|
-
Deprecated since v${i}`):(r=r.split(`
|
|
1
|
+
(function(nt,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(nt=typeof globalThis<"u"?globalThis:nt||self,b(nt.evotars={}))})(this,function(nt){"use strict";var gx=Object.defineProperty;var _x=(nt,b,Wt)=>b in nt?gx(nt,b,{enumerable:!0,configurable:!0,writable:!0,value:Wt}):nt[b]=Wt;var T=(nt,b,Wt)=>(_x(nt,typeof b!="symbol"?b+"":b,Wt),Wt);var b=(s=>(s.Application="application",s.WebGLPipes="webgl-pipes",s.WebGLPipesAdaptor="webgl-pipes-adaptor",s.WebGLSystem="webgl-system",s.WebGPUPipes="webgpu-pipes",s.WebGPUPipesAdaptor="webgpu-pipes-adaptor",s.WebGPUSystem="webgpu-system",s.CanvasSystem="canvas-system",s.CanvasPipesAdaptor="canvas-pipes-adaptor",s.CanvasPipes="canvas-pipes",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s.MaskEffect="mask-effect",s.BlendMode="blend-mode",s.TextureSource="texture-source",s.Environment="environment",s))(b||{});const Wt=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},Ts=(s,t)=>Wt(s).priority??t,O={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(Wt).forEach(t=>{t.type.forEach(e=>{var i,r;return(r=(i=this._removeHandlers)[e])==null?void 0:r.call(i,t)})}),this},add(...s){return s.map(Wt).forEach(t=>{t.type.forEach(e=>{var n,a;const i=this._addHandlers,r=this._queue;i[e]?(a=i[e])==null||a.call(i,t):(r[e]=r[e]||[],(n=r[e])==null||n.push(t))})}),this},handle(s,t,e){var a;const i=this._addHandlers,r=this._removeHandlers;if(i[s]||r[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,r[s]=e;const n=this._queue;return n[s]&&((a=n[s])==null||a.forEach(o=>t(o)),delete n[s]),this},handleByMap(s,t){return this.handle(s,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(s,t,e=-1){return this.handle(s,i=>{t.findIndex(n=>n.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((n,a)=>Ts(a.value,e)-Ts(n.value,e)))},i=>{const r=t.findIndex(n=>n.name===i.name);r!==-1&&t.splice(r,1)})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((r,n)=>Ts(n,e)-Ts(r,e)))},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1)})}},Ml={extension:{type:b.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(()=>ux)}},Bl={extension:{type:b.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>dx)}};class pt{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new pt(t??this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),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.js/math:ObservablePoint x=0 y=0 scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}function xi(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Tn={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function r(h,c,l){this.fn=h,this.context=c,this.once=l||!1}function n(h,c,l,u,d){if(typeof l!="function")throw new TypeError("The listener must be a function");var f=new r(l,u||h,d),p=e?e+c:c;return h._events[p]?h._events[p].fn?h._events[p]=[h._events[p],f]:h._events[p].push(f):(h._events[p]=f,h._eventsCount++),h}function a(h,c){--h._eventsCount===0?h._events=new i:delete h._events[c]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],l,u;if(this._eventsCount===0)return c;for(u in l=this._events)t.call(l,u)&&c.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(l)):c},o.prototype.listeners=function(c){var l=e?e+c:c,u=this._events[l];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},o.prototype.listenerCount=function(c){var l=e?e+c:c,u=this._events[l];return u?u.fn?1:u.length:0},o.prototype.emit=function(c,l,u,d,f,p){var g=e?e+c:c;if(!this._events[g])return!1;var m=this._events[g],_=arguments.length,x,y;if(m.fn){switch(m.once&&this.removeListener(c,m.fn,void 0,!0),_){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,l),!0;case 3:return m.fn.call(m.context,l,u),!0;case 4:return m.fn.call(m.context,l,u,d),!0;case 5:return m.fn.call(m.context,l,u,d,f),!0;case 6:return m.fn.call(m.context,l,u,d,f,p),!0}for(y=1,x=new Array(_-1);y<_;y++)x[y-1]=arguments[y];m.fn.apply(m.context,x)}else{var v=m.length,w;for(y=0;y<v;y++)switch(m[y].once&&this.removeListener(c,m[y].fn,void 0,!0),_){case 1:m[y].fn.call(m[y].context);break;case 2:m[y].fn.call(m[y].context,l);break;case 3:m[y].fn.call(m[y].context,l,u);break;case 4:m[y].fn.call(m[y].context,l,u,d);break;default:if(!x)for(w=1,x=new Array(_-1);w<_;w++)x[w-1]=arguments[w];m[y].fn.apply(m[y].context,x)}}return!0},o.prototype.on=function(c,l,u){return n(this,c,l,u,!1)},o.prototype.once=function(c,l,u){return n(this,c,l,u,!0)},o.prototype.removeListener=function(c,l,u,d){var f=e?e+c:c;if(!this._events[f])return this;if(!l)return a(this,f),this;var p=this._events[f];if(p.fn)p.fn===l&&(!d||p.once)&&(!u||p.context===u)&&a(this,f);else{for(var g=0,m=[],_=p.length;g<_;g++)(p[g].fn!==l||d&&!p[g].once||u&&p[g].context!==u)&&m.push(p[g]);m.length?this._events[f]=m.length===1?m[0]:m:a(this,f)}return this},o.prototype.removeAllListeners=function(c){var l;return c?(l=e?e+c:c,this._events[l]&&a(this,l)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,s.exports=o})(Tn);var Rl=Tn.exports;const _t=xi(Rl),kl=Math.PI*2,Il=180/Math.PI,Fl=Math.PI/180;class X{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new X(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.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return yi.x=0,yi.y=0,yi}}const yi=new X;class I{constructor(t=1,e=0,i=0,r=1,n=0,a=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=a}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,r,n,a){return this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=a,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new X;const i=t.x,r=t.y;return e.x=this.a*i+this.c*r+this.tx,e.y=this.b*i+this.d*r+this.ty,e}applyInverse(t,e){e=e||new X;const i=this.a,r=this.b,n=this.c,a=this.d,o=this.tx,h=this.ty,c=1/(i*a+n*-r),l=t.x,u=t.y;return e.x=a*c*l+-n*c*u+(h*n-o*a)*c,e.y=i*c*u+-r*c*l+(-h*i+o*r)*c,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),r=this.a,n=this.c,a=this.tx;return this.a=r*e-this.b*i,this.b=r*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=a*e-this.ty*i,this.ty=a*i+this.ty*e,this}append(t){const e=this.a,i=this.b,r=this.c,n=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*r,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}appendFrom(t,e){const i=t.a,r=t.b,n=t.c,a=t.d,o=t.tx,h=t.ty,c=e.a,l=e.b,u=e.c,d=e.d;return this.a=i*c+r*u,this.b=i*l+r*d,this.c=n*c+a*u,this.d=n*l+a*d,this.tx=o*c+h*u+e.tx,this.ty=o*l+h*d+e.ty,this}setTransform(t,e,i,r,n,a,o,h,c){return this.a=Math.cos(o+c)*n,this.b=Math.sin(o+c)*n,this.c=-Math.sin(o-h)*a,this.d=Math.cos(o-h)*a,this.tx=t-(i*this.a+r*this.c),this.ty=e-(i*this.b+r*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,r=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=r*t.a+this.d*t.c,this.d=r*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,r=this.c,n=this.d,a=t.pivot,o=-Math.atan2(-r,n),h=Math.atan2(i,e),c=Math.abs(o+h);return c<1e-5||Math.abs(kl-c)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=h),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(r*r+n*n),t.position.x=this.tx+(a.x*e+a.y*r),t.position.y=this.ty+(a.x*i+a.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,a=t*r-e*i;return this.a=r/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-r*n)/a,this.ty=-(t*this.ty-e*n)/a,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}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 I;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}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}equals(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}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Ul.identity()}static get shared(){return Gl.identity()}}const Gl=new I,Ul=new I,he=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],ce=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],le=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ue=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],bi=[],An=[],As=Math.sign;function Dl(){for(let s=0;s<16;s++){const t=[];bi.push(t);for(let e=0;e<16;e++){const i=As(he[s]*he[e]+le[s]*ce[e]),r=As(ce[s]*he[e]+ue[s]*ce[e]),n=As(he[s]*le[e]+le[s]*ue[e]),a=As(ce[s]*le[e]+ue[s]*ue[e]);for(let o=0;o<16;o++)if(he[o]===i&&ce[o]===r&&le[o]===n&&ue[o]===a){t.push(o);break}}}for(let s=0;s<16;s++){const t=new I;t.set(he[s],ce[s],le[s],ue[s],0,0),An.push(t)}}Dl();const tt={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:s=>he[s],uY:s=>ce[s],vX:s=>le[s],vY:s=>ue[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>bi[s][t],sub:(s,t)=>bi[s][tt.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?tt.S:tt.N:Math.abs(t)*2<=Math.abs(s)?s>0?tt.E:tt.W:t>0?s>0?tt.SE:tt.SW:s>0?tt.NE:tt.NW,matrixAppendRotationInv:(s,t,e=0,i=0)=>{const r=An[tt.inv(t)];r.tx=e,r.ty=i,s.append(r)}},Ps=[new X,new X,new X,new X];class Y{constructor(t=0,e=0,i=0,r=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(r)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new Y(0,0,0,0)}clone(){return new Y(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i){const{width:r,height:n}=this;if(r<=0||n<=0)return!1;const a=this.x,o=this.y,h=a-i/2,c=a+r+i/2,l=o-i/2,u=o+n+i/2,d=a+i/2,f=a+r-i/2,p=o+i/2,g=o+n-i/2;return t>=h&&t<=c&&e>=l&&e<=u&&!(t>d&&t<f&&e>p&&e<g)}intersects(t,e){if(!e){const P=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=P)return!1;const A=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>A}const i=this.left,r=this.right,n=this.top,a=this.bottom;if(r<=i||a<=n)return!1;const o=Ps[0].set(t.left,t.top),h=Ps[1].set(t.left,t.bottom),c=Ps[2].set(t.right,t.top),l=Ps[3].set(t.right,t.bottom);if(c.x<=o.x||h.y<=o.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(o,o),e.apply(h,h),e.apply(c,c),e.apply(l,l),Math.max(o.x,h.x,c.x,l.x)<=i||Math.min(o.x,h.x,c.x,l.x)>=r||Math.max(o.y,h.y,c.y,l.y)<=n||Math.min(o.y,h.y,c.y,l.y)>=a))return!1;const d=u*(h.y-o.y),f=u*(o.x-h.x),p=d*i+f*n,g=d*r+f*n,m=d*i+f*a,_=d*r+f*a;if(Math.max(p,g,m,_)<=d*o.x+f*o.y||Math.min(p,g,m,_)>=d*l.x+f*l.y)return!1;const x=u*(o.y-c.y),y=u*(c.x-o.x),v=x*i+y*n,w=x*r+y*n,E=x*i+y*a,C=x*r+y*a;return!(Math.max(v,w,E,C)<=x*o.x+y*o.y||Math.min(v,w,E,C)>=x*l.x+y*l.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,r=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=r,this.height=n-r,this}getBounds(t){return t=t||new Y,t.copyFrom(this),t}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const vi={default:-1};function et(s="default"){return vi[s]===void 0&&(vi[s]=-1),++vi[s]}const Pn={},W="8.0.0";function N(s,t,e=3){if(Pn[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
|
|
2
|
+
Deprecated since v${s}`):(i=i.split(`
|
|
7
3
|
`).splice(e).join(`
|
|
8
4
|
`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
|
|
9
|
-
Deprecated since v${
|
|
10
|
-
Deprecated since v${i}`),console.warn(r))),eh[t]=!0}function Xt(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function Qi(i){return i.split("?")[0].split("#")[0]}function Pf(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Mf(i,t,e){return i.replace(new RegExp(Pf(t),"g"),e)}function Ff(i,t){let e="",r=0,s=-1,n=0,a=-1;for(let o=0;o<=i.length;++o){if(o<i.length)a=i.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(s===o-1||n===1))if(s!==o-1&&n===2){if(e.length<2||r!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",r=0):(e=e.slice(0,h),r=e.length-1-e.lastIndexOf("/")),s=o,n=0;continue}}else if(e.length===2||e.length===1){e="",r=0,s=o,n=0;continue}}}else e.length>0?e+=`/${i.slice(s+1,o)}`:e=i.slice(s+1,o),r=o-s-1;s=o,n=0}else a===46&&n!==-1?++n:n=-1}return e}const xt={toPosix(i){return Mf(i,"\\","/")},isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl(i){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i)},isBlobUrl(i){return i.startsWith("blob:")},hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){Xt(i),i=this.toPosix(i);const t=/^file:\/\/\//.exec(i);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(i);return e?e[0]:""},toAbsolute(i,t,e){if(Xt(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const r=Qi(this.toPosix(t??F.ADAPTER.getBaseUrl())),s=Qi(this.toPosix(e??this.rootname(r)));return i=this.toPosix(i),i.startsWith("/")?xt.join(s,i.slice(1)):this.isAbsolute(i)?i:this.join(r,i)},normalize(i){if(Xt(i),i.length===0)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;i=this.toPosix(i);let t="";const e=i.startsWith("/");this.hasProtocol(i)&&(t=this.rootname(i),i=i.slice(t.length));const r=i.endsWith("/");return i=Ff(i),i.length>0&&r&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return Xt(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join(...i){if(i.length===0)return".";let t;for(let e=0;e<i.length;++e){const r=i[e];if(Xt(r),r.length>0)if(t===void 0)t=r;else{const s=i[e-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?t+=`/../${r}`:t+=`/${r}`}}return t===void 0?".":this.normalize(t)},dirname(i){if(Xt(i),i.length===0)return".";i=this.toPosix(i);let t=i.charCodeAt(0);const e=t===47;let r=-1,s=!0;const n=this.getProtocol(i),a=i;i=i.slice(n.length);for(let o=i.length-1;o>=1;--o)if(t=i.charCodeAt(o),t===47){if(!s){r=o;break}}else s=!1;return r===-1?e?"/":this.isUrl(a)?n+i:n:e&&r===1?"//":n+i.slice(0,r)},rootname(i){Xt(i),i=this.toPosix(i);let t="";if(i.startsWith("/")?t="/":t=this.getProtocol(i),this.isUrl(i)){const e=i.indexOf("/",t.length);e!==-1?t=i.slice(0,e):t=i,t.endsWith("/")||(t+="/")}return t},basename(i,t){Xt(i),t&&Xt(t),i=Qi(this.toPosix(i));let e=0,r=-1,s=!0,n;if(t!==void 0&&t.length>0&&t.length<=i.length){if(t.length===i.length&&t===i)return"";let a=t.length-1,o=-1;for(n=i.length-1;n>=0;--n){const h=i.charCodeAt(n);if(h===47){if(!s){e=n+1;break}}else o===-1&&(s=!1,o=n+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(r=n):(a=-1,r=o))}return e===r?r=o:r===-1&&(r=i.length),i.slice(e,r)}for(n=i.length-1;n>=0;--n)if(i.charCodeAt(n)===47){if(!s){e=n+1;break}}else r===-1&&(s=!1,r=n+1);return r===-1?"":i.slice(e,r)},extname(i){Xt(i),i=Qi(this.toPosix(i));let t=-1,e=0,r=-1,s=!0,n=0;for(let a=i.length-1;a>=0;--a){const o=i.charCodeAt(a);if(o===47){if(!s){e=a+1;break}continue}r===-1&&(s=!1,r=a+1),o===46?t===-1?t=a:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||r===-1||n===0||n===1&&t===r-1&&t===e+1?"":i.slice(t,r)},parse(i){Xt(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=Qi(this.toPosix(i));let e=i.charCodeAt(0);const r=this.isAbsolute(i);let s;t.root=this.rootname(i),r||this.hasProtocol(i)?s=1:s=0;let n=-1,a=0,o=-1,h=!0,l=i.length-1,c=0;for(;l>=s;--l){if(e=i.charCodeAt(l),e===47){if(!h){a=l+1;break}continue}o===-1&&(h=!1,o=l+1),e===46?n===-1?n=l:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||o===-1||c===0||c===1&&n===o-1&&n===a+1?o!==-1&&(a===0&&r?t.base=t.name=i.slice(1,o):t.base=t.name=i.slice(a,o)):(a===0&&r?(t.name=i.slice(1,n),t.base=i.slice(1,o)):(t.name=i.slice(a,n),t.base=i.slice(a,o)),t.ext=i.slice(n,o)),t.dir=this.dirname(i),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let wn;async function Bf(){return wn??(wn=(async()=>{var n;const i=document.createElement("canvas").getContext("webgl");if(!i)return Ot.UNPACK;const t=await new Promise(a=>{const o=document.createElement("video");o.onloadeddata=()=>a(o),o.onerror=()=>a(null),o.autoplay=!1,o.crossOrigin="anonymous",o.preload="auto",o.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",o.load()});if(!t)return Ot.UNPACK;const e=i.createTexture();i.bindTexture(i.TEXTURE_2D,e);const r=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,r),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return i.readPixels(0,0,1,1,i.RGBA,i.UNSIGNED_BYTE,s),i.deleteFramebuffer(r),i.deleteTexture(e),(n=i.getExtension("WEBGL_lose_context"))==null||n.loseContext(),s[0]<=s[3]?Ot.PMA:Ot.UNPACK})()),wn}let En;function Df(){return typeof En>"u"&&(En=function(){var t;const i={stencil:!0,failIfMajorPerformanceCaveat:F.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!F.ADAPTER.getWebGLRenderingContext())return!1;const e=F.ADAPTER.createCanvas();let r=e.getContext("webgl",i)||e.getContext("experimental-webgl",i);const s=!!((t=r==null?void 0:r.getContextAttributes())!=null&&t.stencil);if(r){const n=r.getExtension("WEBGL_lose_context");n&&n.loseContext()}return r=null,s}catch{return!1}}()),En}var Of={grad:.9,turn:360,rad:360/(2*Math.PI)},be=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},Et=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*i)/e+0},Gt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},ih=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},rh=function(i){return{r:Gt(i.r,0,255),g:Gt(i.g,0,255),b:Gt(i.b,0,255),a:Gt(i.a)}},An=function(i){return{r:Et(i.r),g:Et(i.g),b:Et(i.b),a:Et(i.a,3)}},Lf=/^#([0-9a-f]{3,8})$/i,Lr=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},sh=function(i){var t=i.r,e=i.g,r=i.b,s=i.a,n=Math.max(t,e,r),a=n-Math.min(t,e,r),o=a?n===t?(e-r)/a:n===e?2+(r-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:n?a/n*100:0,v:n/255*100,a:s}},nh=function(i){var t=i.h,e=i.s,r=i.v,s=i.a;t=t/360*6,e/=100,r/=100;var n=Math.floor(t),a=r*(1-e),o=r*(1-(t-n)*e),h=r*(1-(1-t+n)*e),l=n%6;return{r:255*[r,o,a,a,h,r][l],g:255*[h,r,r,o,a,a][l],b:255*[a,a,h,r,r,o][l],a:s}},ah=function(i){return{h:ih(i.h),s:Gt(i.s,0,100),l:Gt(i.l,0,100),a:Gt(i.a)}},oh=function(i){return{h:Et(i.h),s:Et(i.s),l:Et(i.l),a:Et(i.a,3)}},hh=function(i){return nh((e=(t=i).s,{h:t.h,s:(e*=((r=t.l)<50?r:100-r)/100)>0?2*e/(r+e)*100:0,v:r+e,a:t.a}));var t,e,r},tr=function(i){return{h:(t=sh(i)).h,s:(s=(200-(e=t.s))*(r=t.v)/100)>0&&s<200?e*r/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,r,s},Nf=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,kf=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Uf=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Gf=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Sn={string:[[function(i){var t=Lf.exec(i);return t?(i=t[1]).length<=4?{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:i.length===4?Et(parseInt(i[3]+i[3],16)/255,2):1}:i.length===6||i.length===8?{r:parseInt(i.substr(0,2),16),g:parseInt(i.substr(2,2),16),b:parseInt(i.substr(4,2),16),a:i.length===8?Et(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var t=Uf.exec(i)||Gf.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:rh({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(i){var t=Nf.exec(i)||kf.exec(i);if(!t)return null;var e,r,s=ah({h:(e=t[1],r=t[2],r===void 0&&(r="deg"),Number(e)*(Of[r]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return hh(s)},"hsl"]],object:[[function(i){var t=i.r,e=i.g,r=i.b,s=i.a,n=s===void 0?1:s;return be(t)&&be(e)&&be(r)?rh({r:Number(t),g:Number(e),b:Number(r),a:Number(n)}):null},"rgb"],[function(i){var t=i.h,e=i.s,r=i.l,s=i.a,n=s===void 0?1:s;if(!be(t)||!be(e)||!be(r))return null;var a=ah({h:Number(t),s:Number(e),l:Number(r),a:Number(n)});return hh(a)},"hsl"],[function(i){var t=i.h,e=i.s,r=i.v,s=i.a,n=s===void 0?1:s;if(!be(t)||!be(e)||!be(r))return null;var a=function(o){return{h:ih(o.h),s:Gt(o.s,0,100),v:Gt(o.v,0,100),a:Gt(o.a)}}({h:Number(t),s:Number(e),v:Number(r),a:Number(n)});return nh(a)},"hsv"]]},lh=function(i,t){for(var e=0;e<t.length;e++){var r=t[e][0](i);if(r)return[r,t[e][1]]}return[null,void 0]},Hf=function(i){return typeof i=="string"?lh(i.trim(),Sn.string):typeof i=="object"&&i!==null?lh(i,Sn.object):[null,void 0]},Cn=function(i,t){var e=tr(i);return{h:e.h,s:Gt(e.s+100*t,0,100),l:e.l,a:e.a}},In=function(i){return(299*i.r+587*i.g+114*i.b)/1e3/255},ch=function(i,t){var e=tr(i);return{h:e.h,s:e.s,l:Gt(e.l+100*t,0,100),a:e.a}},Rn=function(){function i(t){this.parsed=Hf(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return i.prototype.isValid=function(){return this.parsed!==null},i.prototype.brightness=function(){return Et(In(this.rgba),2)},i.prototype.isDark=function(){return In(this.rgba)<.5},i.prototype.isLight=function(){return In(this.rgba)>=.5},i.prototype.toHex=function(){return t=An(this.rgba),e=t.r,r=t.g,s=t.b,a=(n=t.a)<1?Lr(Et(255*n)):"","#"+Lr(e)+Lr(r)+Lr(s)+a;var t,e,r,s,n,a},i.prototype.toRgb=function(){return An(this.rgba)},i.prototype.toRgbString=function(){return t=An(this.rgba),e=t.r,r=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+r+", "+s+", "+n+")":"rgb("+e+", "+r+", "+s+")";var t,e,r,s,n},i.prototype.toHsl=function(){return oh(tr(this.rgba))},i.prototype.toHslString=function(){return t=oh(tr(this.rgba)),e=t.h,r=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+r+"%, "+s+"%, "+n+")":"hsl("+e+", "+r+"%, "+s+"%)";var t,e,r,s,n},i.prototype.toHsv=function(){return t=sh(this.rgba),{h:Et(t.h),s:Et(t.s),v:Et(t.v),a:Et(t.a,3)};var t},i.prototype.invert=function(){return oe({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},i.prototype.saturate=function(t){return t===void 0&&(t=.1),oe(Cn(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),oe(Cn(this.rgba,-t))},i.prototype.grayscale=function(){return oe(Cn(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),oe(ch(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),oe(ch(this.rgba,-t))},i.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},i.prototype.alpha=function(t){return typeof t=="number"?oe({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Et(this.rgba.a,3);var e},i.prototype.hue=function(t){var e=tr(this.rgba);return typeof t=="number"?oe({h:t,s:e.s,l:e.l,a:e.a}):Et(e.h)},i.prototype.isEqual=function(t){return this.toHex()===oe(t).toHex()},i}(),oe=function(i){return i instanceof Rn?i:new Rn(i)},uh=[],$f=function(i){i.forEach(function(t){uh.indexOf(t)<0&&(t(Rn,Sn),uh.push(t))})};function Xf(i,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var s in e)r[e[s]]=s;var n={};i.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,l=r[this.toHex()];if(l)return l;if(a!=null&&a.closest){var c=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in e)n[f]=new i(e[f]).toRgb();for(var p in e){var m=(o=c,h=n[p],Math.pow(o.r-h.r,2)+Math.pow(o.g-h.g,2)+Math.pow(o.b-h.b,2));m<u&&(u=m,d=p)}return d}},t.string.push([function(a){var o=a.toLowerCase(),h=o==="transparent"?"#0000":e[o];return h?new i(h).toRgb():null},"name"])}$f([Xf]);const Ei=class Ds{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 Ds)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,e){const r=typeof t;if(r!==typeof e)return!1;if(r==="number"||r==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((s,n)=>s===e[n]);if(t!==null&&e!==null){const s=Object.keys(t),n=Object.keys(e);return s.length!==n.length?!1:s.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,r,s]=this._components;return{r:t,g:e,b:r,a:s}}toRgb(){const[t,e,r]=this._components;return{r:t,g:e,b:r}}toRgbaString(){const[t,e,r]=this.toUint8RgbArray();return`rgba(${t},${e},${r},${this.alpha})`}toUint8RgbArray(t){const[e,r,s]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(r*255),t[2]=Math.round(s*255),t}toRgbArray(t){t=t??[];const[e,r,s]=this._components;return t[0]=e,t[1]=r,t[2]=s,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,r,s,n]=Ds.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=r,this._components[2]*=s,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let r=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return e&&(r=r*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(r<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,r,s]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(r*t)/t,this._components[2]=Math.round(s*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,r,s,n]=this._components;return t[0]=e,t[1]=r,t[2]=s,t[3]=n,t}normalize(t){let e,r,s,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,r=(a>>8&255)/255,s=(a&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,r,s,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,r,s,n=255]=t,e/=255,r/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=Ds.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=oe(t);a.isValid()&&({r:e,g:r,b:s,a:n}=a.rgba,e/=255,r/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=r,this._components[2]=s,this._components[3]=n,this.refreshInt();else throw new Error(`Unable to convert color ${t}`)}refreshInt(){this._clamp(this._components);const[t,e,r]=this._components;this._int=(t*255<<16)+(e*255<<8)+(r*255|0)}_clamp(t,e=0,r=1){return typeof t=="number"?Math.min(Math.max(t,e),r):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),r)}),t)}};Ei.shared=new Ei,Ei.temp=new Ei,Ei.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let tt=Ei;function zf(i){return K("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),tt.shared.setValue(i).toHex()}function Vf(i){return K("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),tt.shared.setValue(i).toNumber()}function Wf(){const i=[],t=[];for(let r=0;r<32;r++)i[r]=r,t[r]=r;i[z.NORMAL_NPM]=z.NORMAL,i[z.ADD_NPM]=z.ADD,i[z.SCREEN_NPM]=z.SCREEN,t[z.NORMAL]=z.NORMAL_NPM,t[z.ADD]=z.ADD_NPM,t[z.SCREEN]=z.SCREEN_NPM;const e=[];return e.push(t),e.push(i),e}const dh=Wf();function fh(i,t){return dh[t?1:0][i]}function jf(i,t=null){const e=i*6;if(t=t||new Uint16Array(e),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let r=0,s=0;r<e;r+=6,s+=4)t[r+0]=s+0,t[r+1]=s+1,t[r+2]=s+2,t[r+3]=s+0,t[r+4]=s+2,t[r+5]=s+3;return t}function ph(i){if(i.BYTES_PER_ELEMENT===4)return i instanceof Float32Array?"Float32Array":i instanceof Uint32Array?"Uint32Array":"Int32Array";if(i.BYTES_PER_ELEMENT===2){if(i instanceof Uint16Array)return"Uint16Array"}else if(i.BYTES_PER_ELEMENT===1&&i instanceof Uint8Array)return"Uint8Array";return null}function Nr(i){return i+=i===0?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i+1}function mh(i){return!(i&i-1)&&!!i}function gh(i){let t=(i>65535?1:0)<<4;i>>>=t;let e=(i>255?1:0)<<3;return i>>>=e,t|=e,e=(i>15?1:0)<<2,i>>>=e,t|=e,e=(i>3?1:0)<<1,i>>>=e,t|=e,t|i>>1}function Ai(i,t,e){const r=i.length;let s;if(t>=r||e===0)return;e=t+e>r?r-t:e;const n=r-e;for(s=t;s<n;++s)i[s]=i[s+e];i.length=n}function Oe(i){return i===0?0:i<0?-1:1}let Yf=0;function Ze(){return++Yf}const Pn=class{constructor(i,t,e,r){this.left=i,this.top=t,this.right=e,this.bottom=r}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};Pn.EMPTY=new Pn(0,0,0,0);let yh=Pn;const _h={},he=Object.create(null),Le=Object.create(null);class qf{constructor(t,e,r){this._canvas=F.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=r||F.RESOLUTION,this.resize(t,e)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(e*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function vh(i,t,e){for(let r=0,s=4*e*t;r<t;++r,s+=4)if(i[s+3]!==0)return!1;return!0}function xh(i,t,e,r,s){const n=4*t;for(let a=r,o=r*n+4*e;a<=s;++a,o+=n)if(i[o+3]!==0)return!1;return!0}function Kf(i){const{width:t,height:e}=i,r=i.getContext("2d",{willReadFrequently:!0});if(r===null)throw new TypeError("Failed to get canvas 2D context");const s=r.getImageData(0,0,t,e).data;let n=0,a=0,o=t-1,h=e-1;for(;a<e&&vh(s,t,a);)++a;if(a===e)return yh.EMPTY;for(;vh(s,t,h);)--h;for(;xh(s,t,n,a,h);)++n;for(;xh(s,t,o,a,h);)--o;return++o,++h,new yh(n,a,o,h)}function Zf(i){const t=Kf(i),{width:e,height:r}=t;let s=null;if(!t.isEmpty()){const n=i.getContext("2d");if(n===null)throw new TypeError("Failed to get canvas 2D context");s=n.getImageData(t.left,t.top,e,r)}return{width:e,height:r,data:s}}function Jf(i,t=globalThis.location){if(i.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(i,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function Te(i,t=1){var r;const e=(r=F.RETINA_PREFIX)==null?void 0:r.exec(i);return e?parseFloat(e[1]):t}var P=(i=>(i.Renderer="renderer",i.Application="application",i.RendererSystem="renderer-webgl-system",i.RendererPlugin="renderer-webgl-plugin",i.CanvasRendererSystem="renderer-canvas-system",i.CanvasRendererPlugin="renderer-canvas-plugin",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i))(P||{});const Mn=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");i={...typeof i.extension!="object"?{type:i.extension}:i.extension,ref:i}}if(typeof i=="object")i={...i};else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},bh=(i,t)=>Mn(i).priority??t,k={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(Mn).forEach(t=>{t.type.forEach(e=>{var r,s;return(s=(r=this._removeHandlers)[e])==null?void 0:s.call(r,t)})}),this},add(...i){return i.map(Mn).forEach(t=>{t.type.forEach(e=>{var n,a;const r=this._addHandlers,s=this._queue;r[e]?(n=r[e])==null||n.call(r,t):(s[e]=s[e]||[],(a=s[e])==null||a.push(t))})}),this},handle(i,t,e){var a;const r=this._addHandlers,s=this._removeHandlers;if(r[i]||s[i])throw new Error(`Extension type ${i} already has a handler`);r[i]=t,s[i]=e;const n=this._queue;return n[i]&&((a=n[i])==null||a.forEach(o=>t(o)),delete n[i]),this},handleByMap(i,t){return this.handle(i,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByList(i,t,e=-1){return this.handle(i,r=>{t.includes(r.ref)||(t.push(r.ref),t.sort((s,n)=>bh(n,e)-bh(s,e)))},r=>{const s=t.indexOf(r.ref);s!==-1&&t.splice(s,1)})}};class Fn{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const Qf=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
11
|
-
`);function tp(i){let t="";for(let e=0;e<i;++e)e>0&&(t+=`
|
|
12
|
-
else `),e<i-1&&(t+=`if(test == ${e}.0){}`);return t}function ep(i,t){if(i===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);for(;;){const r=Qf.replace(/%forloop%/gi,tp(i));if(t.shaderSource(e,r),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))i=i/2|0;else break}return i}const Bn=0,Dn=1,On=2,Ln=3,Nn=4,kn=5;class le{constructor(){this.data=0,this.blendMode=z.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Bn)}set blend(t){!!(this.data&1<<Bn)!==t&&(this.data^=1<<Bn)}get offsets(){return!!(this.data&1<<Dn)}set offsets(t){!!(this.data&1<<Dn)!==t&&(this.data^=1<<Dn)}get culling(){return!!(this.data&1<<On)}set culling(t){!!(this.data&1<<On)!==t&&(this.data^=1<<On)}get depthTest(){return!!(this.data&1<<Ln)}set depthTest(t){!!(this.data&1<<Ln)!==t&&(this.data^=1<<Ln)}get depthMask(){return!!(this.data&1<<kn)}set depthMask(t){!!(this.data&1<<kn)!==t&&(this.data^=1<<kn)}get clockwiseFrontFace(){return!!(this.data&1<<Nn)}set clockwiseFrontFace(t){!!(this.data&1<<Nn)!==t&&(this.data^=1<<Nn)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==z.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new le;return t.depthTest=!1,t.blend=!0,t}}le.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const Un=[];function Th(i,t){if(!i)return null;let e="";if(typeof i=="string"){const r=/\.(\w{3,4})(?:$|\?|#)/i.exec(i);r&&(e=r[1].toLowerCase())}for(let r=Un.length-1;r>=0;--r){const s=Un[r];if(s.test&&s.test(i,e))return new s(i,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class zt{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,r,s,n,a,o,h){if(arguments.length>8)throw new Error("max arguments reached");const{name:l,items:c}=this;this._aliasCount++;for(let u=0,d=c.length;u<d;u++)c[u][l](t,e,r,s,n,a,o,h);return c===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(zt.prototype,{dispatch:{value:zt.prototype.emit},run:{value:zt.prototype.emit}});class er{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new zt("setRealSize"),this.onUpdate=new zt("update"),this.onError=new zt("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,r){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 kr extends er{constructor(t,e){const{width:r,height:s}=e||{};if(!r||!s)throw new Error("BufferResource width or height invalid");super(r,s),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,r){const s=t.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Ot.UNPACK);const n=e.realWidth,a=e.realHeight;return r.width===n&&r.height===a?s.texSubImage2D(e.target,0,0,0,n,a,e.format,r.type,this.data):(r.width=n,r.height=a,s.texImage2D(e.target,0,r.internalFormat,n,a,0,e.format,r.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const ip={scaleMode:$t.NEAREST,alphaMode:Ot.NPM},Gn=class Ui extends Xi{constructor(t=null,e=null){super(),e=Object.assign({},Ui.defaultOptions,e);const{alphaMode:r,mipmap:s,anisotropicLevel:n,scaleMode:a,width:o,height:h,wrapMode:l,format:c,type:u,target:d,resolution:f,resourceOptions:p}=e;t&&!(t instanceof er)&&(t=Th(t,p),t.internal=!0),this.resolution=f||F.RESOLUTION,this.width=Math.round((o||0)*this.resolution)/this.resolution,this.height=Math.round((h||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=l,this._scaleMode=a,this.format=c,this.type=u,this.target=d,this.alphaMode=r,this.uid=Ze(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=o>0&&h>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(t)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,e){let r;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,r=!0),e!==void 0&&e!==this.mipmap&&(this.mipmap=e,r=!0),r&&this.dirtyStyleId++,this}setSize(t,e,r){return r=r||this.resolution,this.setRealSize(t*r,e*r,r)}setRealSize(t,e,r){return this.resolution=r||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=mh(this.realWidth)&&mh(this.realHeight)}setResolution(t){const e=this.resolution;return e===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete Le[this.cacheId],delete he[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),Ui.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,e,r=F.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else{if(!t._pixiId){const o=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${o}_${Ze()}`}n=t._pixiId}let a=Le[n];if(s&&r&&!a)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return a||(a=new Ui(t,e),a.cacheId=n,Ui.addToCache(a,n)),a}static fromBuffer(t,e,r,s){t=t||new Float32Array(e*r*4);const n=new kr(t,{width:e,height:r,...s==null?void 0:s.resourceOptions});let a,o;return t instanceof Float32Array?(a=A.RGBA,o=H.FLOAT):t instanceof Int32Array?(a=A.RGBA_INTEGER,o=H.INT):t instanceof Uint32Array?(a=A.RGBA_INTEGER,o=H.UNSIGNED_INT):t instanceof Int16Array?(a=A.RGBA_INTEGER,o=H.SHORT):t instanceof Uint16Array?(a=A.RGBA_INTEGER,o=H.UNSIGNED_SHORT):t instanceof Int8Array?(a=A.RGBA,o=H.BYTE):(a=A.RGBA,o=H.UNSIGNED_BYTE),n.internal=!0,new Ui(n,Object.assign({},ip,{type:o,format:a},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),Le[e]&&Le[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),Le[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=Le[t];if(e){const r=e.textureCacheIds.indexOf(t);return r>-1&&e.textureCacheIds.splice(r,1),delete Le[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete Le[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};Gn.defaultOptions={mipmap:ee.POW2,anisotropicLevel:0,scaleMode:$t.LINEAR,wrapMode:Me.CLAMP,alphaMode:Ot.UNPACK,target:ui.TEXTURE_2D,format:A.RGBA,type:H.UNSIGNED_BYTE},Gn._globalBatch=0;let W=Gn;class Hn{constructor(){this.texArray=null,this.blend=0,this.type=te.TRIANGLES,this.start=0,this.size=0,this.data=null}}let rp=0;class ut{constructor(t,e=!0,r=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=r,this.static=e,this.id=rp++,this.disposeRunner=new zt("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?re.ELEMENT_ARRAY_BUFFER:re.ARRAY_BUFFER}get index(){return this.type===re.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new ut(t)}}class Ur{constructor(t,e=0,r=!1,s=H.FLOAT,n,a,o,h=1){this.buffer=t,this.size=e,this.normalized=r,this.type=s,this.stride=n,this.start=a,this.instance=o,this.divisor=h}destroy(){this.buffer=null}static from(t,e,r,s,n){return new Ur(t,e,r,s,n)}}const sp={Float32Array,Uint32Array,Int32Array,Uint8Array};function np(i,t){let e=0,r=0;const s={};for(let h=0;h<i.length;h++)r+=t[h],e+=i[h].length;const n=new ArrayBuffer(e*4);let a=null,o=0;for(let h=0;h<i.length;h++){const l=t[h],c=i[h],u=ph(c);s[u]||(s[u]=new sp[u](n)),a=s[u];for(let d=0;d<c.length;d++){const f=(d/l|0)*r+o,p=d%l;a[f+p]=c[d]}o+=l}return new Float32Array(n)}const wh={5126:4,5123:2,5121:1};let ap=0;const op={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class Ne{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=ap++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new zt("disposeGeometry"),this.refCount=0}addAttribute(t,e,r=0,s=!1,n,a,o,h=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof ut||(e instanceof Array&&(e=new Float32Array(e)),e=new ut(e));const l=t.split("|");if(l.length>1){for(let u=0;u<l.length;u++)this.addAttribute(l[u],e,r,s,n);return this}let c=this.buffers.indexOf(e);return c===-1&&(this.buffers.push(e),c=this.buffers.length-1),this.attributes[t]=new Ur(c,r,s,n,a,o,h),this.instanced=this.instanced||h,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof ut||(t instanceof Array&&(t=new Uint16Array(t)),t=new ut(t)),t.type=re.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],r=new ut;let s;for(s in this.attributes){const n=this.attributes[s],a=this.buffers[n.buffer];t.push(a.data),e.push(n.size*wh[n.type]/4),n.buffer=0}for(r.data=np(t,e),s=0;s<this.buffers.length;s++)this.buffers[s]!==this.indexBuffer&&this.buffers[s].destroy();return this.buffers=[r],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 Ne;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new ut(this.buffers[e].data.slice(0));for(const e in this.attributes){const r=this.attributes[e];t.attributes[e]=new Ur(r.buffer,r.size,r.normalized,r.type,r.stride,r.start,r.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=re.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new Ne,r=[],s=[],n=[];let a;for(let o=0;o<t.length;o++){a=t[o];for(let h=0;h<a.buffers.length;h++)s[h]=s[h]||0,s[h]+=a.buffers[h].data.length,n[h]=0}for(let o=0;o<a.buffers.length;o++)r[o]=new op[ph(a.buffers[o].data)](s[o]),e.buffers[o]=new ut(r[o]);for(let o=0;o<t.length;o++){a=t[o];for(let h=0;h<a.buffers.length;h++)r[h].set(a.buffers[h].data,n[h]),n[h]+=a.buffers[h].data.length}if(e.attributes=a.attributes,a.indexBuffer){e.indexBuffer=e.buffers[a.buffers.indexOf(a.indexBuffer)],e.indexBuffer.type=re.ELEMENT_ARRAY_BUFFER;let o=0,h=0,l=0,c=0;for(let u=0;u<a.buffers.length;u++)if(a.buffers[u]!==a.indexBuffer){c=u;break}for(const u in a.attributes){const d=a.attributes[u];(d.buffer|0)===c&&(h+=d.size*wh[d.type]/4)}for(let u=0;u<t.length;u++){const d=t[u].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+l]+=o;o+=t[u].buffers[c].data.length/h,l+=d.length}}return e}}class Eh extends Ne{constructor(t=!1){super(),this._buffer=new ut(null,t,!1),this._indexBuffer=new ut(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,H.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,H.FLOAT).addAttribute("aColor",this._buffer,4,!0,H.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,H.FLOAT).addIndex(this._indexBuffer)}}const Gr=Math.PI*2,hp=180/Math.PI,lp=Math.PI/180;var It=(i=>(i[i.POLY=0]="POLY",i[i.RECT=1]="RECT",i[i.CIRC=2]="CIRC",i[i.ELIP=3]="ELIP",i[i.RREC=4]="RREC",i))(It||{});class J{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new J(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}}J.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const Hr=[new J,new J,new J,new J];class Y{constructor(t=0,e=0,r=0,s=0){this.x=Number(t),this.y=Number(e),this.width=Number(r),this.height=Number(s),this.type=It.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 Y(0,0,0,0)}clone(){return new Y(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const w=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=w)return!1;const R=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>R}const r=this.left,s=this.right,n=this.top,a=this.bottom;if(s<=r||a<=n)return!1;const o=Hr[0].set(t.left,t.top),h=Hr[1].set(t.left,t.bottom),l=Hr[2].set(t.right,t.top),c=Hr[3].set(t.right,t.bottom);if(l.x<=o.x||h.y<=o.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(o,o),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(o.x,h.x,l.x,c.x)<=r||Math.min(o.x,h.x,l.x,c.x)>=s||Math.max(o.y,h.y,l.y,c.y)<=n||Math.min(o.y,h.y,l.y,c.y)>=a))return!1;const d=u*(h.y-o.y),f=u*(o.x-h.x),p=d*r+f*n,m=d*s+f*n,g=d*r+f*a,_=d*s+f*a;if(Math.max(p,m,g,_)<=d*o.x+f*o.y||Math.min(p,m,g,_)>=d*c.x+f*c.y)return!1;const x=u*(o.y-l.y),y=u*(l.x-o.x),v=x*r+y*n,T=x*s+y*n,C=x*r+y*a,E=x*s+y*a;return!(Math.max(v,T,C,E)<=x*o.x+y*o.y||Math.min(v,T,C,E)>=x*c.x+y*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),r=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(r-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const r=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=r-this.x,this.height=s-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),r=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=r-e,this.y=s,this.height=n-s,this}}Y.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class $r{constructor(t=0,e=0,r=0){this.x=t,this.y=e,this.radius=r,this.type=It.CIRC}clone(){return new $r(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const r=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=r}getBounds(){return new Y(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}$r.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class Xr{constructor(t=0,e=0,r=0,s=0){this.x=t,this.y=e,this.width=r,this.height=s,this.type=It.ELIP}clone(){return new Xr(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let r=(t-this.x)/this.width,s=(e-this.y)/this.height;return r*=r,s*=s,r+s<=1}getBounds(){return new Y(this.x-this.width,this.y-this.height,this.width,this.height)}}Xr.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Je{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const r=[];for(let s=0,n=e.length;s<n;s++)r.push(e[s].x,e[s].y);e=r}this.points=e,this.type=It.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Je(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let r=!1;const s=this.points.length/2;for(let n=0,a=s-1;n<s;a=n++){const o=this.points[n*2],h=this.points[n*2+1],l=this.points[a*2],c=this.points[a*2+1];h>e!=c>e&&t<(l-o)*((e-h)/(c-h))+o&&(r=!r)}return r}}Je.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((i,t)=>`${i}, ${t}`,"")}]`};class zr{constructor(t=0,e=0,r=0,s=0,n=20){this.x=t,this.y=e,this.width=r,this.height=s,this.radius=n,this.type=It.RREC}clone(){return new zr(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 r=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+r&&e<=this.y+this.height-r||t>=this.x+r&&t<=this.x+this.width-r)return!0;let s=t-(this.x+r),n=e-(this.y+r);const a=r*r;if(s*s+n*n<=a||(s=t-(this.x+this.width-r),s*s+n*n<=a)||(n=e-(this.y+this.height-r),s*s+n*n<=a)||(s=t-(this.x+r),s*s+n*n<=a))return!0}return!1}}zr.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class rt{constructor(t=1,e=0,r=0,s=1,n=0,a=0){this.array=null,this.a=t,this.b=e,this.c=r,this.d=s,this.tx=n,this.ty=a}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,r,s,n,a){return this.a=t,this.b=e,this.c=r,this.d=s,this.tx=n,this.ty=a,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const r=e||this.array;return t?(r[0]=this.a,r[1]=this.b,r[2]=0,r[3]=this.c,r[4]=this.d,r[5]=0,r[6]=this.tx,r[7]=this.ty,r[8]=1):(r[0]=this.a,r[1]=this.c,r[2]=this.tx,r[3]=this.b,r[4]=this.d,r[5]=this.ty,r[6]=0,r[7]=0,r[8]=1),r}apply(t,e){e=e||new J;const r=t.x,s=t.y;return e.x=this.a*r+this.c*s+this.tx,e.y=this.b*r+this.d*s+this.ty,e}applyInverse(t,e){e=e||new J;const r=1/(this.a*this.d+this.c*-this.b),s=t.x,n=t.y;return e.x=this.d*r*s+-this.c*r*n+(this.ty*this.c-this.tx*this.d)*r,e.y=this.a*r*n+-this.b*r*s+(-this.ty*this.a+this.tx*this.b)*r,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),r=Math.sin(t),s=this.a,n=this.c,a=this.tx;return this.a=s*e-this.b*r,this.b=s*r+this.b*e,this.c=n*e-this.d*r,this.d=n*r+this.d*e,this.tx=a*e-this.ty*r,this.ty=a*r+this.ty*e,this}append(t){const e=this.a,r=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*r+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*r+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*r+t.ty*n+this.ty,this}setTransform(t,e,r,s,n,a,o,h,l){return this.a=Math.cos(o+l)*n,this.b=Math.sin(o+l)*n,this.c=-Math.sin(o-h)*a,this.d=Math.cos(o-h)*a,this.tx=t-(r*this.a+s*this.c),this.ty=e-(r*this.b+s*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const r=this.a,s=this.c;this.a=r*t.a+this.b*t.c,this.b=r*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,r=this.b,s=this.c,n=this.d,a=t.pivot,o=-Math.atan2(-s,n),h=Math.atan2(r,e),l=Math.abs(o+h);return l<1e-5||Math.abs(Gr-l)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=h),t.scale.x=Math.sqrt(e*e+r*r),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(a.x*e+a.y*s),t.position.y=this.ty+(a.x*r+a.y*n),t}invert(){const t=this.a,e=this.b,r=this.c,s=this.d,n=this.tx,a=t*s-e*r;return this.a=s/a,this.b=-e/a,this.c=-r/a,this.d=t/a,this.tx=(r*this.ty-s*n)/a,this.ty=-(t*this.ty-e*n)/a,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new rt;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}static get IDENTITY(){return new rt}static get TEMP_MATRIX(){return new rt}}rt.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const Qe=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],ti=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],ei=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ii=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],$n=[],Ah=[],Vr=Math.sign;function cp(){for(let i=0;i<16;i++){const t=[];$n.push(t);for(let e=0;e<16;e++){const r=Vr(Qe[i]*Qe[e]+ei[i]*ti[e]),s=Vr(ti[i]*Qe[e]+ii[i]*ti[e]),n=Vr(Qe[i]*ei[e]+ei[i]*ii[e]),a=Vr(ti[i]*ei[e]+ii[i]*ii[e]);for(let o=0;o<16;o++)if(Qe[o]===r&&ti[o]===s&&ei[o]===n&&ii[o]===a){t.push(o);break}}}for(let i=0;i<16;i++){const t=new rt;t.set(Qe[i],ti[i],ei[i],ii[i],0,0),Ah.push(t)}}cp();const ht={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:i=>Qe[i],uY:i=>ti[i],vX:i=>ei[i],vY:i=>ii[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>$n[i][t],sub:(i,t)=>$n[i][ht.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?ht.S:ht.N:Math.abs(t)*2<=Math.abs(i)?i>0?ht.E:ht.W:t>0?i>0?ht.SE:ht.SW:i>0?ht.NE:ht.NW,matrixAppendRotationInv:(i,t,e=0,r=0)=>{const s=Ah[ht.inv(t)];s.tx=e,s.ty=r,i.append(s)}};class we{constructor(t,e,r=0,s=0){this._x=r,this._y=s,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new we(t,e,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}we.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Xn=class{constructor(){this.worldTransform=new rt,this.localTransform=new rt,this.position=new we(this.onChange,this,0,0),this.scale=new we(this.onChange,this,1,1),this.pivot=new we(this.onChange,this,0,0),this.skew=new we(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const i=this.localTransform;this._localID!==this._currentLocalID&&(i.a=this._cx*this.scale.x,i.b=this._sx*this.scale.x,i.c=this._cy*this.scale.y,i.d=this._sy*this.scale.y,i.tx=this.position.x-(this.pivot.x*i.a+this.pivot.y*i.c),i.ty=this.position.y-(this.pivot.x*i.b+this.pivot.y*i.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(i){const t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==i._worldID){const e=i.worldTransform,r=this.worldTransform;r.a=t.a*e.a+t.b*e.c,r.b=t.a*e.b+t.b*e.d,r.c=t.c*e.a+t.d*e.c,r.d=t.c*e.b+t.d*e.d,r.tx=t.tx*e.a+t.ty*e.c+e.tx,r.ty=t.tx*e.b+t.ty*e.d+e.ty,this._parentID=i._worldID,this._worldID++}}setFromMatrix(i){i.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(i){this._rotation!==i&&(this._rotation=i,this.updateSkew())}};Xn.IDENTITY=new Xn;let zn=Xn;zn.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};var up=`varying vec2 vTextureCoord;
|
|
13
|
-
|
|
14
|
-
uniform sampler2D uSampler;
|
|
15
|
-
|
|
16
|
-
void main(void){
|
|
17
|
-
gl_FragColor *= texture2D(uSampler, vTextureCoord);
|
|
18
|
-
}`,dp=`attribute vec2 aVertexPosition;
|
|
19
|
-
attribute vec2 aTextureCoord;
|
|
20
|
-
|
|
21
|
-
uniform mat3 projectionMatrix;
|
|
22
|
-
|
|
23
|
-
varying vec2 vTextureCoord;
|
|
24
|
-
|
|
25
|
-
void main(void){
|
|
26
|
-
gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
27
|
-
vTextureCoord = aTextureCoord;
|
|
28
|
-
}
|
|
29
|
-
`;function Sh(i,t,e){const r=i.createShader(t);return i.shaderSource(r,e),i.compileShader(r),r}function Vn(i){const t=new Array(i);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Ch(i,t){switch(i){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return Vn(2*t);case"bvec3":return Vn(3*t);case"bvec4":return Vn(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const Si=[{test:i=>i.type==="float"&&i.size===1&&!i.isArray,code:i=>`
|
|
30
|
-
if(uv["${i}"] !== ud["${i}"].value)
|
|
31
|
-
{
|
|
32
|
-
ud["${i}"].value = uv["${i}"]
|
|
33
|
-
gl.uniform1f(ud["${i}"].location, uv["${i}"])
|
|
34
|
-
}
|
|
35
|
-
`},{test:(i,t)=>(i.type==="sampler2D"||i.type==="samplerCube"||i.type==="sampler2DArray")&&i.size===1&&!i.isArray&&(t==null||t.castToBaseTexture!==void 0),code:i=>`t = syncData.textureCount++;
|
|
36
|
-
|
|
37
|
-
renderer.texture.bind(uv["${i}"], t);
|
|
38
|
-
|
|
39
|
-
if(ud["${i}"].value !== t)
|
|
40
|
-
{
|
|
41
|
-
ud["${i}"].value = t;
|
|
42
|
-
gl.uniform1i(ud["${i}"].location, t);
|
|
43
|
-
; // eslint-disable-line max-len
|
|
44
|
-
}`},{test:(i,t)=>i.type==="mat3"&&i.size===1&&!i.isArray&&t.a!==void 0,code:i=>`
|
|
45
|
-
gl.uniformMatrix3fv(ud["${i}"].location, false, uv["${i}"].toArray(true));
|
|
46
|
-
`,codeUbo:i=>`
|
|
47
|
-
var ${i}_matrix = uv.${i}.toArray(true);
|
|
48
|
-
|
|
49
|
-
data[offset] = ${i}_matrix[0];
|
|
50
|
-
data[offset+1] = ${i}_matrix[1];
|
|
51
|
-
data[offset+2] = ${i}_matrix[2];
|
|
5
|
+
Deprecated since v${s}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
|
|
6
|
+
Deprecated since v${s}`),console.warn(i))),Pn[t]=!0}const Cn=()=>{};function Te(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function En(s){return!(s&s-1)&&!!s}function Ol(s){const t={};for(const e in s)s[e]!==void 0&&(t[e]=s[e]);return t}const Mn=Object.create(null);function Ll(s){const t=Mn[s];return t===void 0&&(Mn[s]=et("resource")),t}const Bn=class dl extends _t{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...dl.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){N(W,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=Ll(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Bn.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Hl=Bn;const Rn=class fl extends _t{constructor(t={}){super(),this.options=t,this.uid=et("textureSource"),this._resourceType="textureSource",this._resourceId=et("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...fl.defaultOptions,...t},this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new Hl(Ol(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=et("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i=i||this._resolution,t=t||this.width,e=e||this.height;const r=Math.round(t*i),n=Math.round(e*i);return this.width=r/i,this.height=n/i,this._resolution=i,this.pixelWidth===r&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=n,this.emit("resize",this),this._resourceId=et("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=En(this.pixelWidth)&&En(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Rn.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let ut=Rn;class Si extends ut{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super({...t,resource:e,format:i}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}Si.extension=b.TextureSource;const kn=new I;class In{constructor(t,e){this.mapCoord=new I,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let r=0;r<t.length;r+=2){const n=t[r],a=t[r+1];e[r]=n*i.a+a*i.c+i.tx,e[r+1]=n*i.b+a*i.d+i.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const i=t.orig,r=t.trim;r&&(kn.set(i.width/r.width,0,0,i.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append(kn));const n=t.source,a=this.uClampFrame,o=this.clampMargin/n._resolution,h=this.clampOffset;return a[0]=(t.frame.x+o+h)/n.width,a[1]=(t.frame.y+o+h)/n.height,a[2]=(t.frame.x+t.frame.width-o+h)/n.width,a[3]=(t.frame.y+t.frame.height-o+h)/n.height,this.uClampOffset[0]=h/n.pixelWidth,this.uClampOffset[1]=h/n.pixelHeight,this.isSimple=t.frame.width===n.width&&t.frame.height===n.height&&t.rotate===0,!0}}class M extends _t{constructor({source:t,label:e,frame:i,orig:r,trim:n,defaultAnchor:a,defaultBorders:o,rotate:h,dynamic:c}={}){if(super(),this.uid=et("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Y,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(t==null?void 0:t.source)??new ut,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:l,height:u}=this._source;this.frame.width=l,this.frame.height=u}this.orig=r||this.frame,this.trim=n,this.rotate=h??0,this.defaultAnchor=a,this.defaultBorders=o,this.destroyed=!1,this.dynamic=c||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new In(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:i,height:r}=this._source,n=e.x/i,a=e.y/r,o=e.width/i,h=e.height/r;let c=this.rotate;if(c){const l=o/2,u=h/2,d=n+l,f=a+u;c=tt.add(c,tt.NW),t.x0=d+l*tt.uX(c),t.y0=f+u*tt.uY(c),c=tt.add(c,2),t.x1=d+l*tt.uX(c),t.y1=f+u*tt.uY(c),c=tt.add(c,2),t.x2=d+l*tt.uX(c),t.y2=f+u*tt.uY(c),c=tt.add(c,2),t.x3=d+l*tt.uX(c),t.y3=f+u*tt.uY(c)}else t.x0=n,t.y0=a,t.x1=n+o,t.y1=a,t.x2=n+o,t.y2=a+h,t.x3=n,t.y3=a+h}destroy(t=!1){this._source&&t&&(this._source.destroy(),this._source=null),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return N(W,"Texture.baseTexture is now Texture.source"),this._source}}M.EMPTY=new M({label:"EMPTY",source:new ut({label:"EMPTY"})}),M.EMPTY.destroy=Cn,M.WHITE=new M({source:new Si({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),M.WHITE.destroy=Cn;function Cs(s,t,e,i){const{width:r,height:n}=e.orig,a=e.trim;if(a){const o=a.width,h=a.height;s.minX=a.x-t._x*r-i,s.maxX=s.minX+o,s.minY=a.y-t._y*n-i,s.maxY=s.minY+h}else s.minX=-t._x*r-i,s.maxX=s.minX+r,s.minY=-t._y*n-i,s.maxY=s.minY+n}var Nl={grad:.9,turn:360,rad:360/(2*Math.PI)},Vt=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},at=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},wt=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},Fn=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},Gn=function(s){return{r:wt(s.r,0,255),g:wt(s.g,0,255),b:wt(s.b,0,255),a:wt(s.a)}},wi=function(s){return{r:at(s.r),g:at(s.g),b:at(s.b),a:at(s.a,3)}},zl=/^#([0-9a-f]{3,8})$/i,Es=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},Un=function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=Math.max(t,e,i),a=n-Math.min(t,e,i),o=a?n===t?(e-i)/a:n===e?2+(i-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:n?a/n*100:0,v:n/255*100,a:r}},Dn=function(s){var t=s.h,e=s.s,i=s.v,r=s.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),a=i*(1-e),o=i*(1-(t-n)*e),h=i*(1-(1-t+n)*e),c=n%6;return{r:255*[i,o,a,a,h,i][c],g:255*[h,i,i,o,a,a][c],b:255*[a,a,h,i,i,o][c],a:r}},On=function(s){return{h:Fn(s.h),s:wt(s.s,0,100),l:wt(s.l,0,100),a:wt(s.a)}},Ln=function(s){return{h:at(s.h),s:at(s.s),l:at(s.l),a:at(s.a,3)}},Hn=function(s){return Dn((e=(t=s).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},We=function(s){return{h:(t=Un(s)).h,s:(r=(200-(e=t.s))*(i=t.v)/100)>0&&r<200?e*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,i,r},Wl=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Vl=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,jl=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,$l=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ti={string:[[function(s){var t=zl.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?at(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?at(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=jl.exec(s)||$l.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:Gn({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(s){var t=Wl.exec(s)||Vl.exec(s);if(!t)return null;var e,i,r=On({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(Nl[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Hn(r)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=r===void 0?1:r;return Vt(t)&&Vt(e)&&Vt(i)?Gn({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,r=s.a,n=r===void 0?1:r;if(!Vt(t)||!Vt(e)||!Vt(i))return null;var a=On({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return Hn(a)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,r=s.a,n=r===void 0?1:r;if(!Vt(t)||!Vt(e)||!Vt(i))return null;var a=function(o){return{h:Fn(o.h),s:wt(o.s,0,100),v:wt(o.v,0,100),a:wt(o.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Dn(a)},"hsv"]]},Nn=function(s,t){for(var e=0;e<t.length;e++){var i=t[e][0](s);if(i)return[i,t[e][1]]}return[null,void 0]},Xl=function(s){return typeof s=="string"?Nn(s.trim(),Ti.string):typeof s=="object"&&s!==null?Nn(s,Ti.object):[null,void 0]},Ai=function(s,t){var e=We(s);return{h:e.h,s:wt(e.s+100*t,0,100),l:e.l,a:e.a}},Pi=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},zn=function(s,t){var e=We(s);return{h:e.h,s:e.s,l:wt(e.l+100*t,0,100),a:e.a}},Ci=function(){function s(t){this.parsed=Xl(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return at(Pi(this.rgba),2)},s.prototype.isDark=function(){return Pi(this.rgba)<.5},s.prototype.isLight=function(){return Pi(this.rgba)>=.5},s.prototype.toHex=function(){return t=wi(this.rgba),e=t.r,i=t.g,r=t.b,a=(n=t.a)<1?Es(at(255*n)):"","#"+Es(e)+Es(i)+Es(r)+a;var t,e,i,r,n,a},s.prototype.toRgb=function(){return wi(this.rgba)},s.prototype.toRgbString=function(){return t=wi(this.rgba),e=t.r,i=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+r+", "+n+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,n},s.prototype.toHsl=function(){return Ln(We(this.rgba))},s.prototype.toHslString=function(){return t=Ln(We(this.rgba)),e=t.h,i=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+n+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,n},s.prototype.toHsv=function(){return t=Un(this.rgba),{h:at(t.h),s:at(t.s),v:at(t.v),a:at(t.a,3)};var t},s.prototype.invert=function(){return Ot({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),Ot(Ai(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),Ot(Ai(this.rgba,-t))},s.prototype.grayscale=function(){return Ot(Ai(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),Ot(zn(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),Ot(zn(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?Ot({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):at(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=We(this.rgba);return typeof t=="number"?Ot({h:t,s:e.s,l:e.l,a:e.a}):at(e.h)},s.prototype.isEqual=function(t){return this.toHex()===Ot(t).toHex()},s}(),Ot=function(s){return s instanceof Ci?s:new Ci(s)},Wn=[],Yl=function(s){s.forEach(function(t){Wn.indexOf(t)<0&&(t(Ci,Ti),Wn.push(t))})};function Kl(s,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var r in e)i[e[r]]=r;var n={};s.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,c=i[this.toHex()];if(c)return c;if(a!=null&&a.closest){var l=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in e)n[f]=new s(e[f]).toRgb();for(var p in e){var g=(o=l,h=n[p],Math.pow(o.r-h.r,2)+Math.pow(o.g-h.g,2)+Math.pow(o.b-h.b,2));g<u&&(u=g,d=p)}return d}},t.string.push([function(a){var o=a.toLowerCase(),h=o==="transparent"?"#0000":e[o];return h?new s(h).toRgb():null},"name"])}Yl([Kl]);const Ae=class Ss{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 Ss)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._normalize(t),this._value=this._cloneSource(t))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((n,a)=>n===e[a]);if(t!==null&&e!==null){const n=Object.keys(t),a=Object.keys(e);return n.length!==a.length?!1:n.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(r*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,i,r,n]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,r,n]=Ss._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=r,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(r<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,i,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,i=(a>>8&255)/255,r=(a&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,r,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,r,n=255]=t,e/=255,i/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=Ss.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=Ot(t);a.isValid()&&({r:e,g:i,b:r,a:n}=a.rgba,e/=255,i/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=r,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof Ss||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};Ae.shared=new Ae,Ae._temp=new Ae,Ae.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let j=Ae;const ql={cullArea:null,cullable:!1,cullableChildren:!0};function Vn(s,t,e){const i=s.length;let r;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(r=t;r<n;++r)s[r]=s[r+e];s.length=n}const Zl={allowChildren:!0,removeChildren(s=0,t){const e=t??this.children.length,i=e-s,r=[];if(i>0&&i<=e){for(let a=e-1;a>=s;a--){const o=this.children[a];o&&(r.push(o),o.parent=null)}Vn(this.children,s,e);const n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(r);for(let a=0;a<r.length;++a)this.emit("childRemoved",r[a],this,a),r[a].emit("removed",this);return r}else if(i===0&&this.children.length===0)return r;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(s){const t=this.getChildAt(s);return this.removeChild(t)},getChildAt(s){if(s<0||s>=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,t)},getChildIndex(s){const t=this.children.indexOf(s);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(s,t){this.allowChildren||N(W,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${s}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(s.parent){const r=s.parent.children.indexOf(s);if(s.parent===this&&r===t)return s;r!==-1&&s.parent.children.splice(r,1)}t===e.length?e.push(s):e.splice(t,0,s),s.parent=this,s.didChange=!0,s.didViewUpdate=!1,s._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(s),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",s,this,t),s.emit("added",this),s},swapChildren(s,t){if(s===t)return;const e=this.getChildIndex(s),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=s},removeFromParent(){var s;(s=this.parent)==null||s.removeChild(this)}};class Ms{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}class Ei{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var i;let e;return this._index>0?e=this._pool[--this._index]:e=new this._classType,(i=e.init)==null||i.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}}class Jl{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new Ei(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const $=new Jl;class Ql{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const i=this._tests[e];if(i.test(t))return $.get(i.maskClass,t)}return t}returnMaskEffect(t){$.return(t)}}const Mi=new Ql;O.handleByList(b.MaskEffect,Mi._effectClasses);const tu={_maskEffect:null,_filterEffect:null,effects:[],addEffect(s){if(this.effects.indexOf(s)!==-1)return;this.effects.push(s),this.effects.sort((i,r)=>i.priority-r.priority);const e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0),this._updateIsSimple()},removeEffect(s){const t=this.effects.indexOf(s);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(s){const t=this._maskEffect;(t==null?void 0:t.mask)!==s&&(t&&(this.removeEffect(t),Mi.returnMaskEffect(t),this._maskEffect=null),s!=null&&(this._maskEffect=Mi.getMaskEffect(s),this.addEffect(this._maskEffect)))},get mask(){var s;return(s=this._maskEffect)==null?void 0:s.mask},set filters(s){var n;!Array.isArray(s)&&s&&(s=[s]);const t=this._filterEffect||(this._filterEffect=new Ms);s=s;const e=(s==null?void 0:s.length)>0,i=((n=t.filters)==null?void 0:n.length)>0,r=e!==i;s=Array.isArray(s)?s.slice(0):s,t.filters=Object.freeze(s),r&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=s??null))},get filters(){var s;return(s=this._filterEffect)==null?void 0:s.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new Ms),this._filterEffect.filterArea=s},get filterArea(){var s;return(s=this._filterEffect)==null?void 0:s.filterArea}},eu={label:null,get name(){return N(W,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){N(W,"Container.name property has been removed, use Container.label instead"),this.label=s},getChildByName(s,t=!1){return this.getChildByLabel(s,t)},getChildByLabel(s,t=!1){const e=this.children;for(let i=0;i<e.length;i++){const r=e[i];if(r.label===s||s instanceof RegExp&&s.test(r.label))return r}if(t)for(let i=0;i<e.length;i++){const n=e[i].getChildByLabel(s,!0);if(n)return n}return null},getChildrenByLabel(s,t=!1,e=[]){const i=this.children;for(let r=0;r<i.length;r++){const n=i[r];(n.label===s||s instanceof RegExp&&s.test(n.label))&&e.push(n)}if(t)for(let r=0;r<i.length;r++)i[r].getChildrenByLabel(s,!0,e);return e}},jn=new I;class mt{constructor(t=1/0,e=1/0,i=-1/0,r=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=jn,this.minX=t,this.minY=e,this.maxX=i,this.maxY=r}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new Y);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=jn,this}set(t,e,i,r){this.minX=t,this.minY=e,this.maxX=i,this.maxY=r}addFrame(t,e,i,r,n){n||(n=this.matrix);const a=n.a,o=n.b,h=n.c,c=n.d,l=n.tx,u=n.ty;let d=this.minX,f=this.minY,p=this.maxX,g=this.maxY,m=a*t+h*e+l,_=o*t+c*e+u;m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=a*i+h*e+l,_=o*i+c*e+u,m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=a*t+h*r+l,_=o*t+c*r+u,m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=a*i+h*r+l,_=o*i+c*r+u,m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),this.minX=d,this.minY=f,this.maxX=p,this.maxY=g}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,i=this.minY,r=this.maxX,n=this.maxY,{a,b:o,c:h,d:c,tx:l,ty:u}=t;let d=a*e+h*i+l,f=o*e+c*i+u;this.minX=d,this.minY=f,this.maxX=d,this.maxY=f,d=a*r+h*i+l,f=o*r+c*i+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*e+h*n+l,f=o*e+c*n+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*r+h*n+l,f=o*r+c*n+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,r){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),this.maxY>r&&(this.maxY=r),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new mt(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,r){let n=this.minX,a=this.minY,o=this.maxX,h=this.maxY;r||(r=this.matrix);const c=r.a,l=r.b,u=r.c,d=r.d,f=r.tx,p=r.ty;for(let g=e;g<i;g+=2){const m=t[g],_=t[g+1],x=c*m+u*_+f,y=l*m+d*_+p;n=x<n?x:n,a=y<a?y:a,o=x>o?x:o,h=y>h?y:h}this.minX=n,this.minY=a,this.maxX=o,this.maxY=h}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}}const jt=new Ei(I),$t=new Ei(mt);function Bi(s,t,e){e.clear();let i,r;return s.parent?t?i=s.parent.worldTransform:(r=jt.get().identity(),i=Bs(s,r)):i=I.IDENTITY,$n(s,e,i,t),r&&jt.return(r),e.isValid||e.set(0,0,0,0),e}function $n(s,t,e,i){var o,h;if(!s.visible||!s.measurable)return;let r;i?r=s.worldTransform:(s.updateLocalTransform(),r=jt.get(),r.appendFrom(s.localTransform,e));const n=t,a=!!s.effects.length;if(a&&(t=$t.get().clear()),s.boundsArea)t.addRect(s.boundsArea,r);else{s.addBounds&&(t.matrix=r,s.addBounds(t));for(let c=0;c<s.children.length;c++)$n(s.children[c],t,r,i)}if(a){for(let c=0;c<s.effects.length;c++)(h=(o=s.effects[c]).addBounds)==null||h.call(o,t);n.addBounds(t,I.IDENTITY),$t.return(t)}i||jt.return(r)}function Bs(s,t){const e=s.parent;return e&&(Bs(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}let Ri=0;const Xn=500;function D(...s){Ri!==Xn&&(Ri++,Ri===Xn?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...s))}function ki(s,t,e){return t.clear(),e||(e=I.IDENTITY),Yn(s,t,e,s,!0),t.isValid||t.set(0,0,0,0),t}function Yn(s,t,e,i,r){var h,c;let n;if(r)n=jt.get(),n=e.copyTo(n);else{if(!s.visible||!s.measurable)return;s.updateLocalTransform();const l=s.localTransform;n=jt.get(),n.appendFrom(l,e)}const a=t,o=!!s.effects.length;if(o&&(t=$t.get().clear()),s.boundsArea)t.addRect(s.boundsArea,n);else{s.renderPipeId&&(t.matrix=n,s.addBounds(t));const l=s.children;for(let u=0;u<l.length;u++)Yn(l[u],t,n,i,!1)}if(o){for(let l=0;l<s.effects.length;l++)(c=(h=s.effects[l]).addLocalBounds)==null||c.call(h,t,i);a.addBounds(t,I.IDENTITY),$t.return(t)}jt.return(n)}function Kn(s,t){const e=s.children;for(let i=0;i<e.length;i++){const r=e[i],n=(r.uid&255)<<24|r._didChangeId&16777215;t.data[t.index]!==n&&(t.data[t.index]=n,t.didChange=!0),t.index++,r.children.length&&Kn(r,t)}return t.didChange}const su=new I,iu={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(s,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=s/t*e:this.scale.x=e},_setHeight(s,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=s/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new mt});const s=this._localBoundsCacheData;return s.index=1,s.didChange=!1,s.data[0]!==this._didChangeId>>12&&(s.didChange=!0,s.data[0]=this._didChangeId>>12),Kn(this,s),s.didChange&&ki(this,s.localBounds,su),s.localBounds},getBounds(s,t){return Bi(this,s,t||new mt)}},ru={_onRender:null,set onRender(s){const t=this.renderGroup||this.parentRenderGroup;if(!s){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=s},get onRender(){return this._onRender}},nu={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(s){this._zIndex!==s&&(this._zIndex=s,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(au))}};function au(s,t){return s._zIndex-t._zIndex}const ou={getGlobalPosition(s=new X,t=!1){return this.parent?this.parent.toGlobal(this._position,s,t):(s.x=this._position.x,s.y=this._position.y),s},toGlobal(s,t,e=!1){if(!e){this.updateLocalTransform();const i=Bs(this,new I);return i.append(this.localTransform),i.apply(s,t)}return this.worldTransform.apply(s,t)},toLocal(s,t,e,i){if(t&&(s=t.toGlobal(s,e,i)),!i){this.updateLocalTransform();const r=Bs(this,new I);return r.append(this.localTransform),r.applyInverse(s,e)}return this.worldTransform.applyInverse(s,e)}};class qn{constructor(){this.uid=et("instructionSet"),this.instructions=[],this.instructionSize=0}reset(){this.instructionSize=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}class hu{constructor(t){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new I,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new qn,this._onRenderContainers=[],this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i])}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let i=0;i<e.length;i++)this.removeChild(e[i])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(t.didViewUpdate=!1,this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t))}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;t<this._onRenderContainers.length;t++)this._onRenderContainers[t]._onRender()}getChildren(t=[]){const e=this.root.children;for(let i=0;i<e.length;i++)this._getChildren(e[i],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const i=t.children;for(let r=0;r<i.length;r++)this._getChildren(i[r],e);return e}}function cu(s,t,e={}){for(const i in t)!e[i]&&t[i]!==void 0&&(s[i]=t[i])}const Ii=new pt(null),Fi=new pt(null),Gi=new pt(null,1,1),Ui=1,Zn=2,Rs=4;class z extends _t{constructor(t={}){var e,i;super(),this.uid=et("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.updateTick=-1,this.localTransform=new I,this.relativeGroupTransform=new I,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new pt(this,0,0),this._scale=Gi,this._pivot=Fi,this._skew=Ii,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didChangeId=0,this._didLocalTransformChangeId=-1,cu(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(r=>this.addChild(r)),this.effects=[],(i=t.parent)==null||i.addChild(this)}static mixin(t){Object.defineProperties(z.prototype,Object.getOwnPropertyDescriptors(t))}addChild(...t){if(this.allowChildren||N(W,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let r=0;r<t.length;r++)this.addChild(t[r]);return t[0]}const e=t[0];if(e.parent===this)return this.children.splice(this.children.indexOf(e),1),this.children.push(e),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),e;e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e.didViewUpdate=!1,e._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didChangeId+=4096,e._zIndex!==0&&e.depthOfChildModified(),e}removeChild(...t){if(t.length>1){for(let r=0;r<t.length;r++)this.removeChild(t[r]);return t[0]}const e=t[0],i=this.children.indexOf(e);return i>-1&&(this._didChangeId+=4096,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didChangeId++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){if(this.renderGroup&&t===!1)throw new Error("[Pixi] cannot undo a render group just yet");t&&this.enableRenderGroup()}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t&&t.removeChild(this),this.renderGroup=new hu(this),t&&t.addChild(this),this._updateIsSimple(),this.groupTransform=I.IDENTITY}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new I),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*Il}set angle(t){this.rotation=t*Fl}get pivot(){return this._pivot===Fi&&(this._pivot=new pt(this,0,0)),this._pivot}set pivot(t){this._pivot===Fi&&(this._pivot=new pt(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Ii&&(this._skew=new pt(this,0,0)),this._skew}set skew(t){this._skew===Ii&&(this._skew=new pt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Gi&&(this._scale=new pt(this,1,1)),this._scale}set scale(t){this._scale===Gi&&(this._scale=new pt(this,0,0)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const i=this.getLocalBounds();let r,n;typeof t!="object"?(r=t,n=e??t):(r=t.width,n=t.height??t.width),r!==void 0&&this._setWidth(r,i.width),n!==void 0&&this._setHeight(n,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){if((this._didLocalTransformChangeId&15)===this._didChangeId)return;this._didLocalTransformChangeId=this._didChangeId;const t=this.localTransform,e=this._scale,i=this._pivot,r=this._position,n=e._x,a=e._y,o=i._x,h=i._y;t.a=this._cx*n,t.b=this._sx*n,t.c=this._cy*a,t.d=this._sy*a,t.tx=r._x-(o*t.a+h*t.c),t.ty=r._y-(o*t.b+h*t.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=Ui,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const i=j.shared.setValue(t??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=Ui,this._onUpdate())}get tint(){const t=this.localColor;return((t&255)<<16)+(t&65280)+(t>>16&255)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Zn,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?1:0;(this.localDisplayStatus&2)>>1!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Rs,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?1:0;(this.localDisplayStatus&4)>>2!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Rs,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=Rs,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){if(this.destroyed)return;this.destroyed=!0;const e=this.removeChildren(0,this.children.length);if(this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.children)for(let r=0;r<e.length;++r)e[r].destroy(t)}}z.mixin(Zl),z.mixin(ou),z.mixin(ru),z.mixin(iu),z.mixin(tu),z.mixin(eu),z.mixin(nu),z.mixin(ql);class Tt extends z{constructor(t=M.EMPTY){t instanceof M&&(t={texture:t});const{texture:e=M.EMPTY,anchor:i,roundPixels:r,width:n,height:a,...o}=t;super({label:"Sprite",...o}),this.renderPipeId="sprite",this.batched=!0,this._didSpriteUpdate=!1,this._bounds={minX:0,maxX:1,minY:0,maxY:0},this._sourceBounds={minX:0,maxX:1,minY:0,maxY:0},this._boundsDirty=!0,this._sourceBoundsDirty=!0,this._roundPixels=0,this._anchor=new pt({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=r??!1,n&&(this.width=n),a&&(this.height=a)}static from(t,e=!1){return t instanceof M?new Tt(t):new Tt(M.from(t,e))}set texture(t){t||(t=M.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get sourceBounds(){return this._sourceBoundsDirty&&(this._updateSourceBounds(),this._sourceBoundsDirty=!1),this._sourceBounds}containsPoint(t){const e=this.sourceBounds;return t.x>=e.maxX&&t.x<=e.minX&&t.y>=e.maxY&&t.y<=e.minY}addBounds(t){const e=this._texture.trim?this.sourceBounds:this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}onViewUpdate(){if(this._didChangeId+=4096,this._didSpriteUpdate=!0,this._sourceBoundsDirty=this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_updateBounds(){Cs(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,i=this._sourceBounds,{width:r,height:n}=e.orig;i.maxX=-t._x*r,i.minX=i.maxX+r,i.maxY=-t._y*n,i.minY=i.maxY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}this._texture=null,this._bounds=null,this._sourceBounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width)}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){let i,r;typeof t!="object"?(i=t,r=e??t):(i=t.width,r=t.height??t.width),i!==void 0&&this._setWidth(i,this._texture.orig.width),r!==void 0&&this._setHeight(r,this._texture.orig.height)}}const lu=new mt;function Jn(s,t,e){const i=lu;s.measurable=!0,Bi(s,e,i),t.addBoundsMask(i),s.measurable=!1}function Qn(s,t,e){const i=$t.get();s.measurable=!0;const r=jt.get().identity(),n=ta(s,e,r);ki(s,i,n),s.measurable=!1,t.addBoundsMask(i),jt.return(r),$t.return(i)}function ta(s,t,e){return s?(s!==t&&(ta(s.parent,t,e),s.updateLocalTransform(),e.append(s.localTransform)),e):(D("Mask bounds, renderable is not inside the root container"),e)}class ea{constructor(t){this.priority=0,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Tt),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){Jn(this.mask,t,e)}addLocalBounds(t,e){Qn(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof Tt}}ea.extension=b.MaskEffect;class sa{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}sa.extension=b.MaskEffect;class ia{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(t,e){Jn(this.mask,t,e)}addLocalBounds(t,e){Qn(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof z}}ia.extension=b.MaskEffect;let ra={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")};const L={get(){return ra},set(s){ra=s}};class Pe extends ut{constructor(t){t.resource||(t.resource=L.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity;const e=t.resource;(this.pixelWidth!==e.width||this.pixelWidth!==e.height)&&this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,i=this._resolution){const r=super.resize(t,e,i);return r&&this.resizeCanvas(),r}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}}Pe.extension=b.TextureSource;class Ce extends ut{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=L.get().createCanvas(t.resource.width,t.resource.height);e.getContext("2d").drawImage(t.resource,0,0),t.resource=e,D("ImageSource: Image element passed, converting to canvas. Use CanvasSource instead.")}super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap}}Ce.extension=b.TextureSource;var de=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(de||{});class Di{constructor(t,e=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=r}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const na=class St{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 Di(null,null,1/0),this.deltaMS=1/St.targetFPMS,this.elapsedMS=1/St.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=de.NORMAL){return this._addListener(new Di(t,e,i))}addOnce(t,e,i=de.NORMAL){return this._addListener(new Di(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*St.targetFPMS;const i=this._head;let r=i.next;for(;r;)r=r.emit(this);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,St.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!St._shared){const t=St._shared=new St;t.autoStart=!0,t._protected=!0}return St._shared}static get system(){if(!St._system){const t=St._system=new St;t.autoStart=!0,t._protected=!0}return St._system}};na.targetFPMS=.06;let ot=na,Oi;async function aa(){return Oi??(Oi=(async()=>{var a;const t=document.createElement("canvas").getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const h=document.createElement("video");h.onloadeddata=()=>o(h),h.onerror=()=>o(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(r),t.deleteTexture(i),(a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Oi}const ks=class pl extends ut{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...pl.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=ot.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await aa(),this._load=new Promise((i,r)=>{this.isValid?i(this):(this._resolve=i,this._reject=r,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(ot.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(ot.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ot.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||globalThis.VideoFrame&&t instanceof VideoFrame}};ks.extension=b.TextureSource,ks.defaultOptions={...ut.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1},ks.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Is=ks;const Bt=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s);class uu{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||D(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=Bt(t);let r;for(let h=0;h<this.parsers.length;h++){const c=this.parsers[h];if(c.test(e)){r=c.getCacheableAssets(i,e);break}}const n=new Map(Object.entries(r||{}));r||i.forEach(h=>{n.set(h,e)});const a=[...n.keys()],o={cacheKeys:a,keys:i};i.forEach(h=>{this._cacheMap.set(h,o)}),a.forEach(h=>{const c=r?r[h]:e;this._cache.has(h)&&this._cache.get(h)!==c&&D("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(t){if(!this._cacheMap.has(t)){D(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(r=>{this._cache.delete(r)}),e.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const K=new uu,Li=[];O.handleByList(b.TextureSource,Li);function du(s={}){const t=s&&s.resource,e=t?s.resource:s,i=t?s:{resource:s};for(let r=0;r<Li.length;r++){const n=Li[r];if(n.test(e))return new n(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function fu(s={},t=!1){const e=s&&s.resource,i=e?s.resource:s,r=e?s:{resource:s};if(!t&&K.has(i))return K.get(i);const n=new M({source:du(r)});return n.on("destroy",()=>{K.has(i)&&K.remove(i)}),t||K.set(i,n),n}function pu(s,t=!1){return typeof s=="string"?K.get(s):s instanceof ut?new M({source:s}):fu(s,t)}M.from=pu,O.add(ea,sa,ia,Is,Ce,Pe,Si);var te=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(te||{});function Rt(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function Ve(s){return s.split("?")[0].split("#")[0]}function mu(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function gu(s,t,e){return s.replace(new RegExp(mu(t),"g"),e)}function _u(s,t){let e="",i=0,r=-1,n=0,a=-1;for(let o=0;o<=s.length;++o){if(o<s.length)a=s.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(r===o-1||n===1))if(r!==o-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),r=o,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,r=o,n=0;continue}}}else e.length>0?e+=`/${s.slice(r+1,o)}`:e=s.slice(r+1,o),i=o-r-1;r=o,n=0}else a===46&&n!==-1?++n:n=-1}return e}const gt={toPosix(s){return gu(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){Rt(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(Rt(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=Ve(this.toPosix(t??L.get().getBaseUrl())),r=Ve(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?gt.join(r,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(Rt(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=_u(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return Rt(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e<s.length;++e){const i=s[e];if(Rt(i),i.length>0)if(t===void 0)t=i;else{const r=s[e-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(Rt(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,r=!0;const n=this.getProtocol(s),a=s;s=s.slice(n.length);for(let o=s.length-1;o>=1;--o)if(t=s.charCodeAt(o),t===47){if(!r){i=o;break}}else r=!1;return i===-1?e?"/":this.isUrl(a)?n+s:n:e&&i===1?"//":n+s.slice(0,i)},rootname(s){Rt(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){Rt(s),t&&Rt(t),s=Ve(this.toPosix(s));let e=0,i=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let a=t.length-1,o=-1;for(n=s.length-1;n>=0;--n){const h=s.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else o===-1&&(r=!1,o=n+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(i=n):(a=-1,i=o))}return e===i?i=o:i===-1&&(i=s.length),s.slice(e,i)}for(n=s.length-1;n>=0;--n)if(s.charCodeAt(n)===47){if(!r){e=n+1;break}}else i===-1&&(r=!1,i=n+1);return i===-1?"":s.slice(e,i)},extname(s){Rt(s),s=Ve(this.toPosix(s));let t=-1,e=0,i=-1,r=!0,n=0;for(let a=s.length-1;a>=0;--a){const o=s.charCodeAt(a);if(o===47){if(!r){e=a+1;break}continue}i===-1&&(r=!1,i=a+1),o===46?t===-1?t=a:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":s.slice(t,i)},parse(s){Rt(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=Ve(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let r;t.root=this.rootname(s),i||this.hasProtocol(s)?r=1:r=0;let n=-1,a=0,o=-1,h=!0,c=s.length-1,l=0;for(;c>=r;--c){if(e=s.charCodeAt(c),e===47){if(!h){a=c+1;break}continue}o===-1&&(h=!1,o=c+1),e===46?n===-1?n=c:l!==1&&(l=1):n!==-1&&(l=-1)}return n===-1||o===-1||l===0||l===1&&n===o-1&&n===a+1?o!==-1&&(a===0&&i?t.base=t.name=s.slice(1,o):t.base=t.name=s.slice(a,o)):(a===0&&i?(t.name=s.slice(1,n),t.base=s.slice(1,o)):(t.name=s.slice(a,n),t.base=s.slice(a,o)),t.ext=s.slice(n,o)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function oa(s,t,e,i,r){const n=t[e];for(let a=0;a<n.length;a++){const o=n[a];e<t.length-1?oa(s.replace(i[e],o),t,e+1,i,r):r.push(s.replace(i[e],o))}}function xu(s){const t=/\{(.*?)\}/g,e=s.match(t),i=[];if(e){const r=[];e.forEach(n=>{const a=n.substring(1,n.length-1).split(",");r.push(a)}),oa(s,r,0,e,i)}else i.push(s);return i}const Fs=s=>!Array.isArray(s);class Ee{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return Bt(e||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(a=>(a==null?void 0:a.src)??a):n!=null&&n.src?n.src:n,!0)}addManifest(t){this._manifest&&D("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let r=e;Array.isArray(e)||(r=Object.entries(e).map(([n,a])=>typeof a=="string"||Array.isArray(a)?{alias:n,src:a}:{alias:n,...a})),r.forEach(n=>{const a=n.src,o=n.alias;let h;if(typeof o=="string"){const c=this._createBundleAssetId(t,o);i.push(c),h=[o,c]}else{const c=o.map(l=>this._createBundleAssetId(t,l));i.push(...c),h=[...o,...c]}this.add({...n,alias:h,src:a})}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;i=n=>{this.hasKey(n)&&D(`[Resolver] already has key: ${n} overwriting`)},Bt(e).forEach(n=>{const{src:a}=n;let{data:o,format:h,loadParser:c}=n;const l=Bt(a).map(f=>typeof f=="string"?xu(f):Array.isArray(f)?f:[f]),u=this.getAlias(n);Array.isArray(u)?u.forEach(i):i(u);const d=[];l.forEach(f=>{f.forEach(p=>{let g={};if(typeof p!="object"){g.src=p;for(let m=0;m<this._parsers.length;m++){const _=this._parsers[m];if(_.test(p)){g=_.parse(p);break}}}else o=p.data??o,h=p.format??h,c=p.loadParser??c,g={...g,...p};if(!u)throw new Error(`[Resolver] alias is undefined for this asset: ${g.src}`);g=this._buildResolvedAsset(g,{aliases:u,data:o,format:h,loadParser:c}),d.push(g)})}),u.forEach(f=>{this._assetMap[f]=d})})}resolveBundle(t){const e=Fs(t);t=Bt(t);const i={};return t.forEach(r=>{const n=this._bundles[r];if(n){const a=this.resolve(n),o={};for(const h in a){const c=a[h];o[this._extractAssetIdFromBundle(r,h)]=c}i[r]=o}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const r in e)i[r]=e[r].src;return i}return e.src}resolve(t){const e=Fs(t);t=Bt(t);const i={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const a=this._getPreferredOrder(n);a==null||a.priority.forEach(o=>{a.params[o].forEach(h=>{const c=n.filter(l=>l[o]?l[o]===h:!1);c.length&&(n=c)})}),this._resolverHash[r]=n[0]}else this._resolverHash[r]=this._buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],r=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){const{aliases:i,data:r,loadParser:n,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=gt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...r||{},...t.data},t.loadParser=n??t.loadParser,t.format=a??t.format??yu(t.src),t}}Ee.RETINA_PREFIX=/@([0-9\.]+)x/;function yu(s){return s.split(".").pop().split("?").shift().split("#").shift()}const Hi=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s},ha=class ws{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof M?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e;const i=parseFloat(e.meta.scale);i?(this.resolution=i,t.source.resolution=this.resolution):this.resolution=t.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=ws.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=ws.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const r=this._frameKeys[e],n=this._frames[r],a=n.frame;if(a){let o=null,h=null;const c=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,l=new Y(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);n.rotated?o=new Y(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):o=new Y(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(h=new Y(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[r]=new M({source:this.textureSource,frame:o,orig:l,trim:h,rotate:n.rotated?2:0,defaultAnchor:n.anchor,defaultBorders:n.borders,label:r.toString()})}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const r=t[e][i];this.animations[e].push(this.textures[r])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*ws.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*ws.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};ha.BATCH_SIZE=1e3;let Ni=ha;const bu=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function ca(s,t,e){const i={};if(s.forEach(r=>{i[r]=t}),Object.keys(t.textures).forEach(r=>{i[r]=t.textures[r]}),!e){const r=gt.dirname(s[0]);t.linkedSheets.forEach((n,a)=>{const o=ca([`${r}/${t.data.meta.related_multi_packs[a]}`],n,!0);Object.assign(i,o)})}return i}const vu={extension:b.Asset,cache:{test:s=>s instanceof Ni,getCacheableAssets:(s,t)=>ca(s,t,!1)},resolver:{test:s=>{const e=s.split("?")[0].split("."),i=e.pop(),r=e.pop();return i==="json"&&bu.includes(r)},parse:s=>{var e;const t=s.split(".");return{resolution:parseFloat(((e=Ee.RETINA_PREFIX.exec(s))==null?void 0:e[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",extension:{type:b.LoadParser,priority:te.Normal},async testParse(s,t){return gt.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){var c,l;const{texture:i,imageFilename:r}=(t==null?void 0:t.data)??{};let n=gt.dirname(t.src);n&&n.lastIndexOf("/")!==n.length-1&&(n+="/");let a;if(i instanceof M)a=i;else{const u=Hi(n+(r??s.meta.image),t.src);a=(await e.load([u]))[u]}const o=new Ni(a.source,s);await o.parse();const h=(c=s==null?void 0:s.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(h)){const u=[];for(const f of h){if(typeof f!="string")continue;let p=n+f;(l=t.data)!=null&&l.ignoreMultiPack||(p=Hi(p,t.src),u.push(e.load({src:p,data:{ignoreMultiPack:!0}})))}const d=await Promise.all(u);o.linkedSheets=d,d.forEach(f=>{f.linkedSheets=[o].concat(o.linkedSheets.filter(p=>p!==f))})}return o},async unload(s,t,e){await e.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}};O.add(vu);class je{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=je.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new X,this.page=new X,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,r,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var zi=/iPhone/i,la=/iPod/i,ua=/iPad/i,da=/\biOS-universal(?:.+)Mac\b/i,Wi=/\bAndroid(?:.+)Mobile\b/i,fa=/Android/i,Me=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Gs=/Silk/i,Xt=/Windows Phone/i,pa=/\bWindows(?:.+)ARM\b/i,ma=/BlackBerry/i,ga=/BB10/i,_a=/Opera Mini/i,xa=/\b(CriOS|Chrome)(?:.+)Mobile/i,ya=/Mobile(?:.+)Firefox\b/i,ba=function(s){return typeof s<"u"&&s.platform==="MacIntel"&&typeof s.maxTouchPoints=="number"&&s.maxTouchPoints>1&&typeof MSStream>"u"};function Su(s){return function(t){return t.test(s)}}function va(s){var t={userAgent:"",platform:"",maxTouchPoints:0};!s&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof s=="string"?t.userAgent=s:s&&s.userAgent&&(t={userAgent:s.userAgent,platform:s.platform,maxTouchPoints:s.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var r=Su(e),n={apple:{phone:r(zi)&&!r(Xt),ipod:r(la),tablet:!r(zi)&&(r(ua)||ba(t))&&!r(Xt),universal:r(da),device:(r(zi)||r(la)||r(ua)||r(da)||ba(t))&&!r(Xt)},amazon:{phone:r(Me),tablet:!r(Me)&&r(Gs),device:r(Me)||r(Gs)},android:{phone:!r(Xt)&&r(Me)||!r(Xt)&&r(Wi),tablet:!r(Xt)&&!r(Me)&&!r(Wi)&&(r(Gs)||r(fa)),device:!r(Xt)&&(r(Me)||r(Gs)||r(Wi)||r(fa))||r(/\bokhttp\b/i)},windows:{phone:r(Xt),tablet:r(pa),device:r(Xt)||r(pa)},other:{blackberry:r(ma),blackberry10:r(ga),opera:r(_a),firefox:r(ya),chrome:r(xa),device:r(ma)||r(ga)||r(_a)||r(ya)||r(xa)},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 wu=(va.default??va)(globalThis.navigator),Tu=9,Us=100,Au=0,Pu=0,Sa=2,wa=1,Cu=-1e3,Eu=-1e3,Mu=2;class Ta{constructor(t,e=wu){this._mobileInfo=e,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,(e.tablet||e.phone)&&this._createTouchHook();const i=document.createElement("div");i.style.width=`${Us}px`,i.style.height=`${Us}px`,i.style.position="absolute",i.style.top=`${Au}px`,i.style.left=`${Pu}px`,i.style.zIndex=Sa.toString(),this._div=i,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}get hookDiv(){return this._hookDiv}_createTouchHook(){const t=document.createElement("button");t.style.width=`${wa}px`,t.style.height=`${wa}px`,t.style.position="absolute",t.style.top=`${Cu}px`,t.style.left=`${Eu}px`,t.style.zIndex=Mu.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.runners.postrender.add(this),(t=this._renderer.view.canvas.parentNode)==null||t.appendChild(this._div))}_deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.remove(this),(t=this._div.parentNode)==null||t.removeChild(this._div))}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this._updateAccessibleObjects(e[i])}init(t){this.debug=(t==null?void 0:t.debug)??this.debug,this._renderer.runners.postrender.remove(this)}postrender(){const t=performance.now();if(this._mobileInfo.android.device&&t<this._androidUpdateCount||(this._androidUpdateCount=t+this._androidUpdateFrequency,!this._renderer.renderingToScreen||!this._renderer.view.canvas))return;this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered);const{x:e,y:i,width:r,height:n}=this._renderer.view.canvas.getBoundingClientRect(),{width:a,height:o,resolution:h}=this._renderer,c=r/a*h,l=n/o*h;let u=this._div;u.style.left=`${e}px`,u.style.top=`${i}px`,u.style.width=`${a}px`,u.style.height=`${o}px`;for(let d=0;d<this._children.length;d++){const f=this._children[d];if(f._renderId!==this._renderId)f._accessibleActive=!1,Vn(this._children,d,1),this._div.removeChild(f._accessibleDiv),this._pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{u=f._accessibleDiv;let p=f.hitArea;const g=f.worldTransform;f.hitArea?(u.style.left=`${(g.tx+p.x*g.a)*c}px`,u.style.top=`${(g.ty+p.y*g.d)*l}px`,u.style.width=`${p.width*g.a*c}px`,u.style.height=`${p.height*g.d*l}px`):(p=f.getBounds().rectangle,this._capHitArea(p),u.style.left=`${p.x*c}px`,u.style.top=`${p.y*l}px`,u.style.width=`${p.width*c}px`,u.style.height=`${p.height*l}px`,u.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(u.title=f.accessibleTitle||""),u.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&u.setAttribute("aria-label",f.accessibleHint||"")),(f.accessibleTitle!==u.title||f.tabIndex!==u.tabIndex)&&(u.title=f.accessibleTitle||"",u.tabIndex=f.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:i}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}_addChild(t){let e=this._pool.pop();e||(e=document.createElement("button"),e.style.width=`${Us}px`,e.style.height=`${Us}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Sa.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`container ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{container:i}=t.target,r=this._renderer.events.rootBoundary,n=Object.assign(new je(r),{target:i});r.rootTarget=this._renderer.lastObjectRendered,e.forEach(a=>r.dispatchEvent(n,a))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===Tu&&this._activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this._deactivate()}destroy(){this._destroyTouchHook(),this._div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this._pool=null,this._children=null,this._renderer=null}}Ta.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"accessibility"};const Bu={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,_renderId:-1},Vi=Object.create(null),Aa=Object.create(null);function Ds(s,t){let e=Aa[s];return e===void 0&&(Vi[t]===void 0&&(Vi[t]=1),Aa[s]=e=Vi[t]++),e}let Be;function Pa(){return(!Be||Be!=null&&Be.isContextLost())&&(Be=L.get().createCanvas().getContext("webgl",{})),Be}let Os;function Ru(){if(!Os){Os="mediump";const s=Pa();s&&s.getShaderPrecisionFormat&&(Os=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return Os}function ku(s,t,e){return t?s:e?(s=s.replace("out vec4 finalColor;",""),`
|
|
52
7
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
8
|
+
#ifdef GL_ES // This checks if it is WebGL1
|
|
9
|
+
#define in varying
|
|
10
|
+
#define finalColor gl_FragColor
|
|
11
|
+
#define texture texture2D
|
|
12
|
+
#endif
|
|
13
|
+
${s}
|
|
14
|
+
`):`
|
|
56
15
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
{
|
|
66
|
-
cv[0] = v.x;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
cv = ud["${i}"].value;
|
|
86
|
-
v = uv["${i}"];
|
|
87
|
-
|
|
88
|
-
if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height)
|
|
89
|
-
{
|
|
90
|
-
cv[0] = v.x;
|
|
91
|
-
cv[1] = v.y;
|
|
92
|
-
cv[2] = v.width;
|
|
93
|
-
cv[3] = v.height;
|
|
94
|
-
gl.uniform4f(ud["${i}"].location, v.x, v.y, v.width, v.height)
|
|
95
|
-
}`,codeUbo:i=>`
|
|
96
|
-
v = uv.${i};
|
|
97
|
-
|
|
98
|
-
data[offset] = v.x;
|
|
99
|
-
data[offset+1] = v.y;
|
|
100
|
-
data[offset+2] = v.width;
|
|
101
|
-
data[offset+3] = v.height;
|
|
102
|
-
`},{test:(i,t)=>i.type==="vec4"&&i.size===1&&!i.isArray&&t.red!==void 0,code:i=>`
|
|
103
|
-
cv = ud["${i}"].value;
|
|
104
|
-
v = uv["${i}"];
|
|
105
|
-
|
|
106
|
-
if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha)
|
|
107
|
-
{
|
|
108
|
-
cv[0] = v.red;
|
|
109
|
-
cv[1] = v.green;
|
|
110
|
-
cv[2] = v.blue;
|
|
111
|
-
cv[3] = v.alpha;
|
|
112
|
-
gl.uniform4f(ud["${i}"].location, v.red, v.green, v.blue, v.alpha)
|
|
113
|
-
}`,codeUbo:i=>`
|
|
114
|
-
v = uv.${i};
|
|
115
|
-
|
|
116
|
-
data[offset] = v.red;
|
|
117
|
-
data[offset+1] = v.green;
|
|
118
|
-
data[offset+2] = v.blue;
|
|
119
|
-
data[offset+3] = v.alpha;
|
|
120
|
-
`},{test:(i,t)=>i.type==="vec3"&&i.size===1&&!i.isArray&&t.red!==void 0,code:i=>`
|
|
121
|
-
cv = ud["${i}"].value;
|
|
122
|
-
v = uv["${i}"];
|
|
123
|
-
|
|
124
|
-
if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a)
|
|
125
|
-
{
|
|
126
|
-
cv[0] = v.red;
|
|
127
|
-
cv[1] = v.green;
|
|
128
|
-
cv[2] = v.blue;
|
|
129
|
-
|
|
130
|
-
gl.uniform3f(ud["${i}"].location, v.red, v.green, v.blue)
|
|
131
|
-
}`,codeUbo:i=>`
|
|
132
|
-
v = uv.${i};
|
|
133
|
-
|
|
134
|
-
data[offset] = v.red;
|
|
135
|
-
data[offset+1] = v.green;
|
|
136
|
-
data[offset+2] = v.blue;
|
|
137
|
-
`},{test:i=>i.type==="vec4"&&i.size===1&&!i.isArray,code:i=>`
|
|
138
|
-
cv = ud["${i}"].value;
|
|
139
|
-
v = uv["${i}"];
|
|
140
|
-
|
|
141
|
-
if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
|
|
142
|
-
{
|
|
143
|
-
cv[0] = v[0];
|
|
144
|
-
cv[1] = v[1];
|
|
145
|
-
cv[2] = v[2];
|
|
146
|
-
cv[3] = v[3];
|
|
147
|
-
|
|
148
|
-
gl.uniform4f(ud["${i}"].location, v[0], v[1], v[2], v[3])
|
|
149
|
-
}`}],fp={float:`
|
|
150
|
-
if (cv !== v)
|
|
151
|
-
{
|
|
152
|
-
cu.value = v;
|
|
153
|
-
gl.uniform1f(location, v);
|
|
154
|
-
}`,vec2:`
|
|
155
|
-
if (cv[0] !== v[0] || cv[1] !== v[1])
|
|
156
|
-
{
|
|
157
|
-
cv[0] = v[0];
|
|
158
|
-
cv[1] = v[1];
|
|
159
|
-
|
|
160
|
-
gl.uniform2f(location, v[0], v[1])
|
|
161
|
-
}`,vec3:`
|
|
162
|
-
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
|
|
163
|
-
{
|
|
164
|
-
cv[0] = v[0];
|
|
165
|
-
cv[1] = v[1];
|
|
166
|
-
cv[2] = v[2];
|
|
167
|
-
|
|
168
|
-
gl.uniform3f(location, v[0], v[1], v[2])
|
|
169
|
-
}`,vec4:`
|
|
170
|
-
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
|
|
171
|
-
{
|
|
172
|
-
cv[0] = v[0];
|
|
173
|
-
cv[1] = v[1];
|
|
174
|
-
cv[2] = v[2];
|
|
175
|
-
cv[3] = v[3];
|
|
176
|
-
|
|
177
|
-
gl.uniform4f(location, v[0], v[1], v[2], v[3]);
|
|
178
|
-
}`,int:`
|
|
179
|
-
if (cv !== v)
|
|
180
|
-
{
|
|
181
|
-
cu.value = v;
|
|
182
|
-
|
|
183
|
-
gl.uniform1i(location, v);
|
|
184
|
-
}`,ivec2:`
|
|
185
|
-
if (cv[0] !== v[0] || cv[1] !== v[1])
|
|
186
|
-
{
|
|
187
|
-
cv[0] = v[0];
|
|
188
|
-
cv[1] = v[1];
|
|
189
|
-
|
|
190
|
-
gl.uniform2i(location, v[0], v[1]);
|
|
191
|
-
}`,ivec3:`
|
|
192
|
-
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
|
|
193
|
-
{
|
|
194
|
-
cv[0] = v[0];
|
|
195
|
-
cv[1] = v[1];
|
|
196
|
-
cv[2] = v[2];
|
|
197
|
-
|
|
198
|
-
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
199
|
-
}`,ivec4:`
|
|
200
|
-
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
|
|
201
|
-
{
|
|
202
|
-
cv[0] = v[0];
|
|
203
|
-
cv[1] = v[1];
|
|
204
|
-
cv[2] = v[2];
|
|
205
|
-
cv[3] = v[3];
|
|
206
|
-
|
|
207
|
-
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
208
|
-
}`,uint:`
|
|
209
|
-
if (cv !== v)
|
|
210
|
-
{
|
|
211
|
-
cu.value = v;
|
|
212
|
-
|
|
213
|
-
gl.uniform1ui(location, v);
|
|
214
|
-
}`,uvec2:`
|
|
215
|
-
if (cv[0] !== v[0] || cv[1] !== v[1])
|
|
216
|
-
{
|
|
217
|
-
cv[0] = v[0];
|
|
218
|
-
cv[1] = v[1];
|
|
219
|
-
|
|
220
|
-
gl.uniform2ui(location, v[0], v[1]);
|
|
221
|
-
}`,uvec3:`
|
|
222
|
-
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
|
|
223
|
-
{
|
|
224
|
-
cv[0] = v[0];
|
|
225
|
-
cv[1] = v[1];
|
|
226
|
-
cv[2] = v[2];
|
|
227
|
-
|
|
228
|
-
gl.uniform3ui(location, v[0], v[1], v[2]);
|
|
229
|
-
}`,uvec4:`
|
|
230
|
-
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
|
|
231
|
-
{
|
|
232
|
-
cv[0] = v[0];
|
|
233
|
-
cv[1] = v[1];
|
|
234
|
-
cv[2] = v[2];
|
|
235
|
-
cv[3] = v[3];
|
|
236
|
-
|
|
237
|
-
gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
|
|
238
|
-
}`,bool:`
|
|
239
|
-
if (cv !== v)
|
|
240
|
-
{
|
|
241
|
-
cu.value = v;
|
|
242
|
-
gl.uniform1i(location, v);
|
|
243
|
-
}`,bvec2:`
|
|
244
|
-
if (cv[0] != v[0] || cv[1] != v[1])
|
|
245
|
-
{
|
|
246
|
-
cv[0] = v[0];
|
|
247
|
-
cv[1] = v[1];
|
|
248
|
-
|
|
249
|
-
gl.uniform2i(location, v[0], v[1]);
|
|
250
|
-
}`,bvec3:`
|
|
251
|
-
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
|
|
252
|
-
{
|
|
253
|
-
cv[0] = v[0];
|
|
254
|
-
cv[1] = v[1];
|
|
255
|
-
cv[2] = v[2];
|
|
256
|
-
|
|
257
|
-
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
258
|
-
}`,bvec4:`
|
|
259
|
-
if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
|
|
260
|
-
{
|
|
261
|
-
cv[0] = v[0];
|
|
262
|
-
cv[1] = v[1];
|
|
263
|
-
cv[2] = v[2];
|
|
264
|
-
cv[3] = v[3];
|
|
265
|
-
|
|
266
|
-
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
267
|
-
}`,mat2:"gl.uniformMatrix2fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",sampler2D:`
|
|
268
|
-
if (cv !== v)
|
|
269
|
-
{
|
|
270
|
-
cu.value = v;
|
|
271
|
-
|
|
272
|
-
gl.uniform1i(location, v);
|
|
273
|
-
}`,samplerCube:`
|
|
274
|
-
if (cv !== v)
|
|
275
|
-
{
|
|
276
|
-
cu.value = v;
|
|
277
|
-
|
|
278
|
-
gl.uniform1i(location, v);
|
|
279
|
-
}`,sampler2DArray:`
|
|
280
|
-
if (cv !== v)
|
|
281
|
-
{
|
|
282
|
-
cu.value = v;
|
|
283
|
-
|
|
284
|
-
gl.uniform1i(location, v);
|
|
285
|
-
}`},pp={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};function mp(i,t){var r;const e=[`
|
|
286
|
-
var v = null;
|
|
287
|
-
var cv = null;
|
|
288
|
-
var cu = null;
|
|
289
|
-
var t = 0;
|
|
290
|
-
var gl = renderer.gl;
|
|
291
|
-
`];for(const s in i.uniforms){const n=t[s];if(!n){((r=i.uniforms[s])==null?void 0:r.group)===!0&&(i.uniforms[s].ubo?e.push(`
|
|
292
|
-
renderer.shader.syncUniformBufferGroup(uv.${s}, '${s}');
|
|
293
|
-
`):e.push(`
|
|
294
|
-
renderer.shader.syncUniformGroup(uv.${s}, syncData);
|
|
295
|
-
`));continue}const a=i.uniforms[s];let o=!1;for(let h=0;h<Si.length;h++)if(Si[h].test(n,a)){e.push(Si[h].code(s,a)),o=!0;break}if(!o){const h=(n.size===1&&!n.isArray?fp:pp)[n.type].replace("location",`ud["${s}"].location`);e.push(`
|
|
296
|
-
cu = ud["${s}"];
|
|
297
|
-
cv = cu.value;
|
|
298
|
-
v = uv["${s}"];
|
|
299
|
-
${h};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
|
|
300
|
-
`))}const Ih={};let Ci=Ih;function gp(){if(Ci===Ih||Ci!=null&&Ci.isContextLost()){const i=F.ADAPTER.createCanvas();let t;F.PREFER_ENV>=yt.WEBGL2&&(t=i.getContext("webgl2",{})),t||(t=i.getContext("webgl",{})||i.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),Ci=t}return Ci}let Wr;function yp(){if(!Wr){Wr=Ut.MEDIUM;const i=gp();if(i&&i.getShaderPrecisionFormat){const t=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT);t&&(Wr=t.precision?Ut.HIGH:Ut.MEDIUM)}}return Wr}function Rh(i,t){const e=i.getShaderSource(t).split(`
|
|
301
|
-
`).map((l,c)=>`${c}: ${l}`),r=i.getShaderInfoLog(t),s=r.split(`
|
|
302
|
-
`),n={},a=s.map(l=>parseFloat(l.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(l=>l&&!n[l]?(n[l]=!0,!0):!1),o=[""];a.forEach(l=>{e[l-1]=`%c${e[l-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const h=e.join(`
|
|
303
|
-
`);o[0]=h,console.error(r),console.groupCollapsed("click to view full shader code"),console.warn(...o),console.groupEnd()}function _p(i,t,e,r){i.getProgramParameter(t,i.LINK_STATUS)||(i.getShaderParameter(e,i.COMPILE_STATUS)||Rh(i,e),i.getShaderParameter(r,i.COMPILE_STATUS)||Rh(i,r),console.error("PixiJS Error: Could not initialize shader."),i.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",i.getProgramInfoLog(t)))}const vp={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 Ph(i){return vp[i]}let jr=null;const Mh={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 Fh(i,t){if(!jr){const e=Object.keys(Mh);jr={};for(let r=0;r<e.length;++r){const s=e[r];jr[i[s]]=Mh[s]}}return jr[t]}function Bh(i,t,e){if(i.substring(0,9)!=="precision"){let r=t;return t===Ut.HIGH&&e!==Ut.HIGH&&(r=Ut.MEDIUM),`precision ${r} float;
|
|
304
|
-
${i}`}else if(e!==Ut.HIGH&&i.substring(0,15)==="precision highp")return i.replace("precision highp","precision mediump");return i}let ir;function xp(){if(typeof ir=="boolean")return ir;try{ir=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{ir=!1}return ir}let bp=0;const Yr={},Wn=class Gi{constructor(t,e,r="pixi-shader",s={}){this.extra={},this.id=bp++,this.vertexSrc=t||Gi.defaultVertexSrc,this.fragmentSrc=e||Gi.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=s,this.vertexSrc.substring(0,8)!=="#version"&&(r=r.replace(/\s+/g,"-"),Yr[r]?(Yr[r]++,r+=`-${Yr[r]}`):Yr[r]=1,this.vertexSrc=`#define SHADER_NAME ${r}
|
|
305
|
-
${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${r}
|
|
306
|
-
${this.fragmentSrc}`,this.vertexSrc=Bh(this.vertexSrc,Gi.defaultVertexPrecision,Ut.HIGH),this.fragmentSrc=Bh(this.fragmentSrc,Gi.defaultFragmentPrecision,yp())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return dp}static get defaultFragmentSrc(){return up}static from(t,e,r){const s=t+e;let n=_h[s];return n||(_h[s]=n=new Gi(t,e,r)),n}};Wn.defaultVertexPrecision=Ut.HIGH,Wn.defaultFragmentPrecision=ve.apple.device?Ut.HIGH:Ut.MEDIUM;let Ee=Wn,Tp=0;class Vt{constructor(t,e,r){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=Tp++,this.static=!!e,this.ubo=!!r,t instanceof ut?(this.buffer=t,this.buffer.type=re.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new ut(new Float32Array(1)),this.buffer.type=re.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,r){if(!this.ubo)this.uniforms[t]=new Vt(e,r);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,e,r){return new Vt(t,e,r)}static uboFrom(t,e){return new Vt(t,e??!0,!0)}}class ce{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof Vt?this.uniformGroup=e:this.uniformGroup=new Vt(e):this.uniformGroup=new Vt({}),this.disposeRunner=new zt("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const r in e.uniforms){const s=e.uniforms[r];if(s.group===!0&&this.checkUniformExists(t,s))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,r){const s=Ee.from(t,e);return new ce(s,r)}}class wp{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 r=new Int32Array(t);for(let n=0;n<t;n++)r[n]=n;this.defaultGroupCache[t]=Vt.from({uSamplers:r},!0);let s=this.fragTemplate;s=s.replace(/%count%/gi,`${t}`),s=s.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new Ee(this.vertexSrc,s)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new rt,default:this.defaultGroupCache[t]};return new ce(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=`
|
|
307
|
-
`,e+=`
|
|
308
|
-
`;for(let r=0;r<t;r++)r>0&&(e+=`
|
|
309
|
-
else `),r<t-1&&(e+=`if(vTextureId < ${r}.5)`),e+=`
|
|
310
|
-
{`,e+=`
|
|
311
|
-
color = texture2D(uSamplers[${r}], vTextureCoord);`,e+=`
|
|
312
|
-
}`;return e+=`
|
|
313
|
-
`,e+=`
|
|
314
|
-
`,e}}class jn{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}function Ep(){return!ve.apple.device}function Ap(i){let t=!0;const e=F.ADAPTER.getNavigator();if(ve.tablet||ve.phone){if(ve.apple.device){const r=e.userAgent.match(/OS (\d+)_(\d+)?/);r&&parseInt(r[1],10)<11&&(t=!1)}if(ve.android.device){const r=e.userAgent.match(/Android\s([0-9.]*)/);r&&parseInt(r[1],10)<7&&(t=!1)}}return t?i:4}class qr{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var Sp=`varying vec2 vTextureCoord;
|
|
315
|
-
varying vec4 vColor;
|
|
316
|
-
varying float vTextureId;
|
|
317
|
-
uniform sampler2D uSamplers[%count%];
|
|
318
|
-
|
|
319
|
-
void main(void){
|
|
320
|
-
vec4 color;
|
|
321
|
-
%forloop%
|
|
322
|
-
gl_FragColor = color * vColor;
|
|
323
|
-
}
|
|
324
|
-
`,Cp=`precision highp float;
|
|
325
|
-
attribute vec2 aVertexPosition;
|
|
326
|
-
attribute vec2 aTextureCoord;
|
|
327
|
-
attribute vec4 aColor;
|
|
328
|
-
attribute float aTextureId;
|
|
329
|
-
|
|
330
|
-
uniform mat3 projectionMatrix;
|
|
331
|
-
uniform mat3 translationMatrix;
|
|
332
|
-
uniform vec4 tint;
|
|
333
|
-
|
|
334
|
-
varying vec2 vTextureCoord;
|
|
335
|
-
varying vec4 vColor;
|
|
336
|
-
varying float vTextureId;
|
|
337
|
-
|
|
338
|
-
void main(void){
|
|
339
|
-
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
340
|
-
|
|
341
|
-
vTextureCoord = aTextureCoord;
|
|
342
|
-
vTextureId = aTextureId;
|
|
343
|
-
vColor = aColor * tint;
|
|
344
|
-
}
|
|
345
|
-
`;const rr=class Qt extends qr{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Eh,this.vertexSize=6,this.state=le.for2d(),this.size=Qt.defaultBatchSize*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),t.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??Ap(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??Ep(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return K("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return Cp}static get defaultFragmentTemplate(){return Sp}setShaderGenerator({vertex:t=Qt.defaultVertexSrc,fragment:e=Qt.defaultFragmentTemplate}={}){this.shaderGenerator=new wp(t,e)}contextChange(){const t=this.renderer.gl;F.PREFER_ENV===yt.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Qt.defaultMaxTextures),this.maxTextures=ep(this.maxTextures,t)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let e=0;e<this._packedGeometryPoolSize;e++)this._packedGeometries[e]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:t,_textureArrayPool:e}=Qt,r=this.size/4,s=Math.floor(r/this.maxTextures)+1;for(;t.length<r;)t.push(new Hn);for(;e.length<s;)e.push(new jn);for(let n=0;n<this.maxTextures;n++)this._tempBoundTextures[n]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:e}=this,r=Qt._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,a=this.renderer.textureGC.count;let o=++W._globalBatch,h=0,l=r[0],c=0;s.copyBoundTextures(n,e);for(let u=0;u<this._bufferSize;++u){const d=t[u];t[u]=null,d._batchEnabled!==o&&(l.count>=e&&(s.boundArray(l,n,o,e),this.buildDrawCalls(l,c,u),c=u,l=r[++h],++o),d._batchEnabled=o,d.touched=a,l.elements[l.count++]=d)}l.count>0&&(s.boundArray(l,n,o,e),this.buildDrawCalls(l,c,this._bufferSize),++h,++o);for(let u=0;u<n.length;u++)n[u]=null;W._globalBatch=o}buildDrawCalls(t,e,r){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:a,vertexSize:o}=this,h=Qt._drawCallPool;let l=this._dcIndex,c=this._aIndex,u=this._iIndex,d=h[l];d.start=this._iIndex,d.texArray=t;for(let f=e;f<r;++f){const p=s[f],m=p._texture.baseTexture,g=dh[m.alphaMode?1:0][p.blendMode];s[f]=null,e<f&&d.blend!==g&&(d.size=u-d.start,e=f,d=h[++l],d.texArray=t,d.start=u),this.packInterleavedGeometry(p,n,a,c,u),c+=p.vertexData.length/2*o,u+=p.indices.length,d.blend=g}e<r&&(d.size=u-d.start,++l),this._dcIndex=l,this._aIndex=c,this._iIndex=u}bindAndClearTexArray(t){const e=this.renderer.texture;for(let r=0;r<t.count;r++)e.bind(t.elements[r],t.ids[r]),t.elements[r]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:e,_indexBuffer:r}=this;Qt.canUploadSameBuffer?(t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(r),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(r),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:e,state:r}=this.renderer,s=Qt._drawCallPool;let n=null;for(let a=0;a<t;a++){const{texArray:o,type:h,size:l,start:c,blend:u}=s[a];n!==o&&(n=o,this.bindAndClearTexArray(o)),this.state.blendMode=u,r.set(this.state),e.drawElements(h,l,e.UNSIGNED_SHORT,c*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),Qt.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=Nr(Math.ceil(t/8)),r=gh(e),s=e*8;this._aBuffers.length<=r&&(this._iBuffers.length=r+1);let n=this._aBuffers[s];return n||(this._aBuffers[s]=n=new Fn(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=Nr(Math.ceil(t/12)),r=gh(e),s=e*12;this._iBuffers.length<=r&&(this._iBuffers.length=r+1);let n=this._iBuffers[r];return n||(this._iBuffers[r]=n=new Uint16Array(s)),n}packInterleavedGeometry(t,e,r,s,n){const{uint32View:a,float32View:o}=e,h=s/this.vertexSize,l=t.uvs,c=t.indices,u=t.vertexData,d=t._texture.baseTexture._batchLocation,f=Math.min(t.worldAlpha,1),p=tt.shared.setValue(t._tintRGB).toPremultiplied(f,t._texture.baseTexture.alphaMode>0);for(let m=0;m<u.length;m+=2)o[s++]=u[m],o[s++]=u[m+1],o[s++]=l[m],o[s++]=l[m+1],a[s++]=p,o[s++]=d;for(let m=0;m<c.length;m++)r[n++]=h+c[m]}};rr.defaultBatchSize=4096,rr.extension={name:"batch",type:P.RendererPlugin},rr._drawCallPool=[],rr._textureArrayPool=[];let ri=rr;k.add(ri);var Ip=`varying vec2 vTextureCoord;
|
|
346
|
-
|
|
347
|
-
uniform sampler2D uSampler;
|
|
348
|
-
|
|
349
|
-
void main(void){
|
|
350
|
-
gl_FragColor = texture2D(uSampler, vTextureCoord);
|
|
351
|
-
}
|
|
352
|
-
`,Rp=`attribute vec2 aVertexPosition;
|
|
353
|
-
|
|
354
|
-
uniform mat3 projectionMatrix;
|
|
355
|
-
|
|
356
|
-
varying vec2 vTextureCoord;
|
|
16
|
+
#ifdef GL_ES // This checks if it is WebGL1
|
|
17
|
+
#define in attribute
|
|
18
|
+
#define out varying
|
|
19
|
+
#endif
|
|
20
|
+
${s}
|
|
21
|
+
`}function Iu(s,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let r=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return r==="highp"&&i!=="highp"&&(r="mediump"),`precision ${r} float;
|
|
22
|
+
${s}`}else if(i!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function Fu(s,t){return t?`#version 300 es
|
|
23
|
+
${s}`:s}const Gu={},Uu={};function Du(s,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?Gu:Uu;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${t}`}
|
|
24
|
+
${s}`}function Ou(s,t){return t?s.replace("#version 300 es",""):s}const ji={stripVersion:Ou,ensurePrecision:Iu,addProgramDefines:ku,setProgramName:Du,insertVersion:Fu},$i=Object.create(null),Ca=class xn{constructor(t){t={...xn.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Ru()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let r=t.fragment,n=t.vertex;Object.keys(ji).forEach(a=>{const o=i[a];r=ji[a](r,o,!0),n=ji[a](n,o,!1)}),this.fragment=r,this.vertex=n,this._key=Ds(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return $i[e]||($i[e]=new xn(t)),$i[e]}};Ca.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let $e=Ca;const Ea={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function Xe(s){return Ea[s]??Ea.float32}const Lu={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"};function Hu({source:s,entryPoint:t}){const e={},i=s.indexOf(`fn ${t}`);if(i!==-1){const r=s.indexOf("->",i);if(r!==-1){const n=s.substring(i,r),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;(o=a.exec(n))!==null;){const h=Lu[o[3]]??"float32";e[o[2]]={location:parseInt(o[1],10),format:h,stride:Xe(h).stride,offset:0,instance:!1,start:0}}}}return e}function Xi(s){var u,d;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,n=/:\s*(\w+)/,a=/struct\s+(\w+)\s*{([^}]+)}/g,o=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,c=(u=s.match(t))==null?void 0:u.map(f=>({group:parseInt(f.match(e)[1],10),binding:parseInt(f.match(i)[1],10),name:f.match(r)[2],isUniform:f.match(r)[1]==="<uniform>",type:f.match(n)[1]}));if(!c)return{groups:[],structs:[]};const l=((d=s.match(a))==null?void 0:d.map(f=>{const p=f.match(h)[1],g=f.match(o).reduce((m,_)=>{const[x,y]=_.split(":");return m[x.trim()]=y.trim(),m},{});return g?{name:p,members:g}:null}).filter(({name:f})=>c.some(p=>p.type===f)))??[];return{groups:c,structs:l}}var Ye=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(Ye||{});function Nu({groups:s}){const t=[];for(let e=0;e<s.length;e++){const i=s[e];t[i.group]||(t[i.group]=[]),i.isUniform?t[i.group].push({binding:i.binding,visibility:Ye.VERTEX|Ye.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:Ye.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"&&t[i.group].push({binding:i.binding,visibility:Ye.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return t}function zu({groups:s}){const t=[];for(let e=0;e<s.length;e++){const i=s[e];t[i.group]||(t[i.group]={}),t[i.group][i.name]=i.binding}return t}function Wu(s,t){const e=new Set,i=new Set,r=[...s.structs,...t.structs].filter(a=>e.has(a.name)?!1:(e.add(a.name),!0)),n=[...s.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return i.has(o)?!1:(i.add(o),!0)});return{structs:r,groups:n}}const Yi=Object.create(null);class Re{constructor(t){var o,h;this._layoutKey=0;const{fragment:e,vertex:i,layout:r,gpuLayout:n,name:a}=t;if(this.name=a,this.fragment=e,this.vertex=i,e.source===i.source){const c=Xi(e.source);this.structsAndGroups=c}else{const c=Xi(i.source),l=Xi(e.source);this.structsAndGroups=Wu(c,l)}this.layout=r??zu(this.structsAndGroups),this.gpuLayout=n??Nu(this.structsAndGroups),this.autoAssignGlobalUniforms=((o=this.layout[0])==null?void 0:o.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Ds(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=Hu(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return Yi[e]||(Yi[e]=new Re(t)),Yi[e]}}const Ma=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>"],Vu=Ma.reduce((s,t)=>(s[t]=!0,s),{});function ju(s,t){switch(s){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const Ba=class ml{constructor(t,e){this._touched=0,this.uid=et("uniform"),this._resourceType="uniformGroup",this._resourceId=et("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...ml.defaultOptions,...e},this.uniformStructures=t;const i={};for(const r in t){const n=t[r];if(n.name=r,n.size=n.size??1,!Vu[n.type])throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${Ma.join(", ")}`);n.value??(n.value=ju(n.type,n.size)),i[r]=n.value}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Ds(Object.keys(i).map(r=>`${r}-${t[r].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Ba.defaultOptions={ubo:!1,isStatic:!1};let xt=Ba;class Yt{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const r=t[i];this.setResource(r,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var r,n;const i=this.resources[e];t!==i&&(i&&((r=t.off)==null||r.call(t,"change",this.onResourceChange,this)),(n=t.on)==null||n.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const i in e)e[i]._touched=t}destroy(){var e;const t=this.resources;for(const i in t){const r=t[i];(e=r.off)==null||e.call(r,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}var Lt=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.BOTH=3]="BOTH",s))(Lt||{});class At extends _t{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:i,groups:r,resources:n,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=i,a===void 0&&(a=0,e&&(a|=Lt.WEBGPU),i&&(a|=Lt.WEBGL)),this.compatibleRenderers=a;const h={};if(!n&&!r&&(n={}),n&&r)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&r&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&r&&o)for(const c in o)for(const l in o[c]){const u=o[c][l];h[u]={group:c,binding:l,name:u}}else if(e&&r&&!o){const c=e.structsAndGroups.groups;o={},c.forEach(l=>{o[l.group]=o[l.group]||{},o[l.group][l.binding]=l.name,h[l.name]=l})}else if(n){if(e){const c=e.structsAndGroups.groups;o={},c.forEach(l=>{o[l.group]=o[l.group]||{},o[l.group][l.binding]=l.name,h[l.name]=l})}else{o={},r={99:new Yt},this._ownedBindGroups.push(r[99]);let c=0;for(const l in n)h[l]={group:99,binding:c,name:l},o[99]=o[99]||{},o[99][c]=l,c++}r={};for(const c in n){const l=c;let u=n[c];!u.source&&!u._resourceType&&(u=new xt(u));const d=h[l];d&&(r[d.group]||(r[d.group]=new Yt,this._ownedBindGroups.push(r[d.group])),r[d.group].setResource(u,d.binding))}}this.groups=r,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(r,h)}addResource(t,e,i){var r,n;(r=this._uniformBindMap)[e]||(r[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new Yt,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const r in e){const n=e[r];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(a){t[n.group].setResource(a,n.binding)}})}return i}destroy(t=!1){var e,i;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(r=>{r.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:i,...r}=t;let n,a;return e&&(n=Re.from(e)),i&&(a=$e.from(i)),new At({gpuProgram:n,glProgram:a,...r})}}const $u={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8},Ki=0,qi=1,Zi=2,Ji=3,Qi=4,tr=5,er=class gl{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Ki)}set blend(t){!!(this.data&1<<Ki)!==t&&(this.data^=1<<Ki)}get offsets(){return!!(this.data&1<<qi)}set offsets(t){!!(this.data&1<<qi)!==t&&(this.data^=1<<qi)}set cullMode(t){if(t==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=t==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<Zi)}set culling(t){!!(this.data&1<<Zi)!==t&&(this.data^=1<<Zi)}get depthTest(){return!!(this.data&1<<Ji)}set depthTest(t){!!(this.data&1<<Ji)!==t&&(this.data^=1<<Ji)}get depthMask(){return!!(this.data&1<<tr)}set depthMask(t){!!(this.data&1<<tr)!==t&&(this.data^=1<<tr)}get clockwiseFrontFace(){return!!(this.data&1<<Qi)}set clockwiseFrontFace(t){!!(this.data&1<<Qi)!==t&&(this.data^=1<<Qi)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=$u[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const t=new gl;return t.depthTest=!1,t.blend=!0,t}};er.default2d=er.for2d();let Kt=er;const Ra=class yn extends At{constructor(t){t={...yn.defaultOptions,...t},super(t),this.enabled=!0,this._state=Kt.for2d(),this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.addResource("uTexture",0,1)}apply(t,e,i,r){t.applyFilter(this,e,i,r)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const{gpu:e,gl:i,...r}=t;let n,a;return e&&(n=Re.from(e)),i&&(a=$e.from(i)),new yn({gpuProgram:n,glProgram:a,...r})}};Ra.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1};let Xu=Ra;const sr=[];O.handleByNamedList(b.Environment,sr);async function Yu(s){if(s)for(let t=0;t<sr.length;t++){const e=sr[t];if(e.value.test()){await e.value.load();return}}}let Ke;function ka(){if(typeof Ke=="boolean")return Ke;try{Ke=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Ke=!1}return Ke}var ir={exports:{}};ir.exports=Ls,ir.exports.default=Ls;function Ls(s,t,e){e=e||2;var i=t&&t.length,r=i?t[0]*e:s.length,n=Ia(s,0,r,e,!0),a=[];if(!n||n.next===n.prev)return a;var o,h,c,l,u,d,f;if(i&&(n=Qu(s,t,n,e)),s.length>80*e){o=c=s[0],h=l=s[1];for(var p=e;p<r;p+=e)u=s[p],d=s[p+1],u<o&&(o=u),d<h&&(h=d),u>c&&(c=u),d>l&&(l=d);f=Math.max(c-o,l-h),f=f!==0?32767/f:0}return qe(n,a,e,o,h,f,0),a}function Ia(s,t,e,i,r){var n,a;if(r===ar(s,t,e,i)>0)for(n=t;n<e;n+=i)a=Ua(n,s[n],s[n+1],a);else for(n=e-i;n>=t;n-=i)a=Ua(n,s[n],s[n+1],a);return a&&Hs(a,a.next)&&(Je(a),a=a.next),a}function fe(s,t){if(!s)return s;t||(t=s);var e=s,i;do if(i=!1,!e.steiner&&(Hs(e,e.next)||st(e.prev,e,e.next)===0)){if(Je(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function qe(s,t,e,i,r,n,a){if(s){!a&&n&&rd(s,i,r,n);for(var o=s,h,c;s.prev!==s.next;){if(h=s.prev,c=s.next,n?qu(s,i,r,n):Ku(s)){t.push(h.i/e|0),t.push(s.i/e|0),t.push(c.i/e|0),Je(s),s=c.next,o=c.next;continue}if(s=c,s===o){a?a===1?(s=Zu(fe(s),t,e),qe(s,t,e,i,r,n,2)):a===2&&Ju(s,t,e,i,r,n):qe(fe(s),t,e,i,r,n,1);break}}}}function Ku(s){var t=s.prev,e=s,i=s.next;if(st(t,e,i)>=0)return!1;for(var r=t.x,n=e.x,a=i.x,o=t.y,h=e.y,c=i.y,l=r<n?r<a?r:a:n<a?n:a,u=o<h?o<c?o:c:h<c?h:c,d=r>n?r>a?r:a:n>a?n:a,f=o>h?o>c?o:c:h>c?h:c,p=i.next;p!==t;){if(p.x>=l&&p.x<=d&&p.y>=u&&p.y<=f&&ke(r,o,n,h,a,c,p.x,p.y)&&st(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function qu(s,t,e,i){var r=s.prev,n=s,a=s.next;if(st(r,n,a)>=0)return!1;for(var o=r.x,h=n.x,c=a.x,l=r.y,u=n.y,d=a.y,f=o<h?o<c?o:c:h<c?h:c,p=l<u?l<d?l:d:u<d?u:d,g=o>h?o>c?o:c:h>c?h:c,m=l>u?l>d?l:d:u>d?u:d,_=rr(f,p,t,e,i),x=rr(g,m,t,e,i),y=s.prevZ,v=s.nextZ;y&&y.z>=_&&v&&v.z<=x;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==r&&y!==a&&ke(o,l,h,u,c,d,y.x,y.y)&&st(y.prev,y,y.next)>=0||(y=y.prevZ,v.x>=f&&v.x<=g&&v.y>=p&&v.y<=m&&v!==r&&v!==a&&ke(o,l,h,u,c,d,v.x,v.y)&&st(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;y&&y.z>=_;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==r&&y!==a&&ke(o,l,h,u,c,d,y.x,y.y)&&st(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;v&&v.z<=x;){if(v.x>=f&&v.x<=g&&v.y>=p&&v.y<=m&&v!==r&&v!==a&&ke(o,l,h,u,c,d,v.x,v.y)&&st(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Zu(s,t,e){var i=s;do{var r=i.prev,n=i.next.next;!Hs(r,n)&&Fa(r,i,i.next,n)&&Ze(r,n)&&Ze(n,r)&&(t.push(r.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),Je(i),Je(i.next),i=s=n),i=i.next}while(i!==s);return fe(i)}function Ju(s,t,e,i,r,n){var a=s;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&od(a,o)){var h=Ga(a,o);a=fe(a,a.next),h=fe(h,h.next),qe(a,t,e,i,r,n,0),qe(h,t,e,i,r,n,0);return}o=o.next}a=a.next}while(a!==s)}function Qu(s,t,e,i){var r=[],n,a,o,h,c;for(n=0,a=t.length;n<a;n++)o=t[n]*i,h=n<a-1?t[n+1]*i:s.length,c=Ia(s,o,h,i,!1),c===c.next&&(c.steiner=!0),r.push(ad(c));for(r.sort(td),n=0;n<r.length;n++)e=ed(r[n],e);return e}function td(s,t){return s.x-t.x}function ed(s,t){var e=sd(s,t);if(!e)return t;var i=Ga(e,s);return fe(i,i.next),fe(e,e.next)}function sd(s,t){var e=t,i=s.x,r=s.y,n=-1/0,a;do{if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){var o=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(o<=i&&o>n&&(n=o,a=e.x<e.next.x?e:e.next,o===i))return a}e=e.next}while(e!==t);if(!a)return null;var h=a,c=a.x,l=a.y,u=1/0,d;e=a;do i>=e.x&&e.x>=c&&i!==e.x&&ke(r<l?i:n,r,c,l,r<l?n:i,r,e.x,e.y)&&(d=Math.abs(r-e.y)/(i-e.x),Ze(e,s)&&(d<u||d===u&&(e.x>a.x||e.x===a.x&&id(a,e)))&&(a=e,u=d)),e=e.next;while(e!==h);return a}function id(s,t){return st(s.prev,s,t.prev)<0&&st(t.next,s,s.next)<0}function rd(s,t,e,i){var r=s;do r.z===0&&(r.z=rr(r.x,r.y,t,e,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==s);r.prevZ.nextZ=null,r.prevZ=null,nd(r)}function nd(s){var t,e,i,r,n,a,o,h,c=1;do{for(e=s,s=null,n=null,a=0;e;){for(a++,i=e,o=0,t=0;t<c&&(o++,i=i.nextZ,!!i);t++);for(h=c;o>0||h>0&&i;)o!==0&&(h===0||!i||e.z<=i.z)?(r=e,e=e.nextZ,o--):(r=i,i=i.nextZ,h--),n?n.nextZ=r:s=r,r.prevZ=n,n=r;e=i}n.nextZ=null,c*=2}while(a>1);return s}function rr(s,t,e,i,r){return s=(s-e)*r|0,t=(t-i)*r|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function ad(s){var t=s,e=s;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==s);return e}function ke(s,t,e,i,r,n,a,o){return(r-a)*(t-o)>=(s-a)*(n-o)&&(s-a)*(i-o)>=(e-a)*(t-o)&&(e-a)*(n-o)>=(r-a)*(i-o)}function od(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!hd(s,t)&&(Ze(s,t)&&Ze(t,s)&&cd(s,t)&&(st(s.prev,s,t.prev)||st(s,t.prev,t))||Hs(s,t)&&st(s.prev,s,s.next)>0&&st(t.prev,t,t.next)>0)}function st(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function Hs(s,t){return s.x===t.x&&s.y===t.y}function Fa(s,t,e,i){var r=zs(st(s,t,e)),n=zs(st(s,t,i)),a=zs(st(e,i,s)),o=zs(st(e,i,t));return!!(r!==n&&a!==o||r===0&&Ns(s,e,t)||n===0&&Ns(s,i,t)||a===0&&Ns(e,s,i)||o===0&&Ns(e,t,i))}function Ns(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function zs(s){return s>0?1:s<0?-1:0}function hd(s,t){var e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&Fa(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function Ze(s,t){return st(s.prev,s,s.next)<0?st(s,t,s.next)>=0&&st(s,s.prev,t)>=0:st(s,t,s.prev)<0||st(s,s.next,t)<0}function cd(s,t){var e=s,i=!1,r=(s.x+t.x)/2,n=(s.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&r<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==s);return i}function Ga(s,t){var e=new nr(s.i,s.x,s.y),i=new nr(t.i,t.x,t.y),r=s.next,n=t.prev;return s.next=t,t.prev=s,e.next=r,r.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function Ua(s,t,e,i){var r=new nr(s,t,e);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Je(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function nr(s,t,e){this.i=s,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Ls.deviation=function(s,t,e,i){var r=t&&t.length,n=r?t[0]*e:s.length,a=Math.abs(ar(s,0,n,e));if(r)for(var o=0,h=t.length;o<h;o++){var c=t[o]*e,l=o<h-1?t[o+1]*e:s.length;a-=Math.abs(ar(s,c,l,e))}var u=0;for(o=0;o<i.length;o+=3){var d=i[o]*e,f=i[o+1]*e,p=i[o+2]*e;u+=Math.abs((s[d]-s[p])*(s[f+1]-s[d+1])-(s[d]-s[f])*(s[p+1]-s[d+1]))}return a===0&&u===0?0:Math.abs((u-a)/a)};function ar(s,t,e,i){for(var r=0,n=t,a=e-i;n<e;n+=i)r+=(s[a]-s[n])*(s[n+1]+s[a+1]),a=n;return r}Ls.flatten=function(s){for(var t=s[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,r=0;r<s.length;r++){for(var n=0;n<s[r].length;n++)for(var a=0;a<t;a++)e.vertices.push(s[r][n][a]);r>0&&(i+=s[r-1].length,e.holes.push(i))}return e};var ld=ir.exports;const ud=xi(ld);var yt=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=16384]="COLOR",s[s.STENCIL=1024]="STENCIL",s[s.DEPTH=256]="DEPTH",s[s.COLOR_DEPTH=16640]="COLOR_DEPTH",s[s.COLOR_STENCIL=17408]="COLOR_STENCIL",s[s.DEPTH_STENCIL=1280]="DEPTH_STENCIL",s[s.ALL=17664]="ALL",s))(yt||{});class Da{constructor(t){this.items=[],this._name=t}emit(t,e,i,r,n,a,o,h){const{name:c,items:l}=this;for(let u=0,d=l.length;u<d;u++)l[u][c](t,e,i,r,n,a,o,h);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&this.items.splice(e,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}const dd=["init","destroy","contextChange","resolutionChange","reset","renderEnd","renderStart","render","update","postrender","prerender"],Oa=class _l extends _t{constructor(t){super(),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name;const e=[...dd,...t.runners??[]];this._addRunners(...e),this._addSystems(t.systems),this._addPipes(t.renderPipes,t.renderPipeAdaptors),this._unsafeEvalCheck()}async init(t={}){for(const e in this._systemsHash)t={...this._systemsHash[e].constructor.defaultOptions,...t};t={..._l.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let e=0;e<this.runners.init.items.length;e++)await this.runners.init.items[e].init(t);this._initOptions=t}render(t,e){let i=t;if(i instanceof z&&(i={container:i},e&&(N(W,"passing a second argument is deprecated, please use render options instead"),i.target=e.renderTexture)),i.target||(i.target=this.view.renderTarget),i.target===this.view.renderTarget&&(this._lastObjectRendered=i.container,i.clearColor=this.background.colorRgba),i.clearColor){const r=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=r?i.clearColor:j.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),this.runners.prerender.emit(i),this.runners.renderStart.emit(i),this.runners.render.emit(i),this.runners.renderEnd.emit(i),this.runners.postrender.emit(i)}resize(t,e,i){this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height)}clear(t={}){const e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=yt.ALL);const{clear:i,clearColor:r,target:n}=t;j.shared.setValue(r??this.background.colorRgba),e.renderTarget.clear(n,i,j.shared.toArray())}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(e=>{this.runners[e]=new Da(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const r in this.runners)this.runners[r].add(i);return this}_addPipes(t,e){const i=e.reduce((r,n)=>(r[n.name]=n.value,r),{});t.forEach(r=>{const n=r.value,a=r.name,o=i[a];this.renderPipes[a]=new n(this,o?new o:null)})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!ka())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};Oa.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Ws=Oa,Vs;function fd(s){return Vs!==void 0||(Vs=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:s??Ws.defaultOptions.failIfMajorPerformanceCaveat};try{if(!L.get().getWebGLRenderingContext())return!1;let r=L.get().createCanvas().getContext("webgl",t);const n=!!((e=r==null?void 0:r.getContextAttributes())!=null&&e.stencil);if(r){const a=r.getExtension("WEBGL_lose_context");a&&a.loseContext()}return r=null,n}catch{return!1}})()),Vs}let js;async function pd(s={}){return js!==void 0||(js=await(async()=>{if(!L.get().getNavigator().gpu)return!1;try{return await(await navigator.gpu.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),js}const La=["webgl","webgpu","canvas"];async function md(s){let t=[];s.preference?(t.push(s.preference),La.forEach(n=>{n!==s.preference&&t.push(n)})):t=La.slice();let e;await Yu(s.manageImports??!0);let i={};for(let n=0;n<t.length;n++){const a=t[n];if(a==="webgpu"&&await pd()){const{WebGPURenderer:o}=await Promise.resolve().then(()=>Tg);e=o,i={...s,...s.webgpu};break}else if(a==="webgl"&&fd(s.failIfMajorPerformanceCaveat??Ws.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:o}=await Promise.resolve().then(()=>ng);e=o,i={...s,...s.webgl};break}else if(a==="canvas")throw i={...s},new Error("CanvasRenderer is not yet implemented")}if(delete i.webgpu,delete i.webgl,!e)throw new Error("No available renderer for the current environment");const r=new e;return await r.init(i),r}class Ha{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:r,clientHeight:n}=this._resizeTo;e=r,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Ha.extension=b.Application;class Na{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,de.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?ot.shared:new ot,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Na.extension=b.Application;class gd{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const _d={extension:b.CacheParser,test:s=>Array.isArray(s)&&s.every(t=>t instanceof M),getCacheableAssets:(s,t)=>{const e={};return s.forEach(i=>{t.forEach((r,n)=>{e[i+(n===0?"":n+1)]=r})}),e}};async function za(s){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const xd={extension:{type:b.DetectionParser,priority:1},test:async()=>za("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")},Wa=["png","jpg","jpeg"],yd={extension:{type:b.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...Wa],remove:async s=>s.filter(t=>!Wa.includes(t))},bd="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function or(s){return bd?!1:document.createElement("video").canPlayType(s)!==""}const vd={extension:{type:b.DetectionParser,priority:0},test:async()=>or("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")},Sd={extension:{type:b.DetectionParser,priority:0},test:async()=>or("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")},wd={extension:{type:b.DetectionParser,priority:0},test:async()=>or("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")},Td={extension:{type:b.DetectionParser,priority:0},test:async()=>za("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")};class Ad{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var a,o;let r=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||D(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let h=0;h<this.parsers.length;h++){const c=this.parsers[h];if(c.load&&((a=c.test)!=null&&a.call(c,t,e,this))){n=c;break}}if(!n)return D(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}r=await n.load(t,e,this),i.parser=n;for(let h=0;h<this.parsers.length;h++){const c=this.parsers[h];c.parse&&c.parse&&await((o=c.testParse)==null?void 0:o.call(c,r,e,this))&&(r=await c.parse(r,e,this)||r,i.parser=c)}return r})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const r={},n=Fs(t),a=Bt(t,c=>({alias:[c],src:c})),o=a.length,h=a.map(async c=>{const l=gt.toAbsolute(c.src);if(!r[c.src])try{this.promiseCache[l]||(this.promiseCache[l]=this._getLoadPromiseAndParser(l,c)),r[c.src]=await this.promiseCache[l].promise,e&&e(++i/o)}catch(u){throw delete this.promiseCache[l],delete r[c.src],new Error(`[Loader.load] Failed to load ${l}.
|
|
25
|
+
${u}`)}});return await Promise.all(h),n?r[a[0].src]:r}async unload(t){const i=Bt(t,r=>({alias:[r],src:r})).map(async r=>{var o,h;const n=gt.toAbsolute(r.src),a=this.promiseCache[n];if(a){const c=await a.promise;delete this.promiseCache[n],await((h=(o=a.parser)==null?void 0:o.unload)==null?void 0:h.call(o,c,r,this))}});await Promise.all(i)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name?t[e.name]&&D(`[Assets] loadParser name conflict "${e.name}"`):D("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function Ie(s,t){if(Array.isArray(t)){for(const e of t)if(s.startsWith(`data:${e}`))return!0;return!1}return s.startsWith(`data:${t}`)}function Fe(s,t){const e=s.split("?")[0],i=gt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const Pd=".json",Cd="application/json",Ed={extension:{type:b.LoadParser,priority:te.Low},name:"loadJson",test(s){return Ie(s,Cd)||Fe(s,Pd)},async load(s){return await(await L.get().fetch(s)).json()}},Md=".txt",Bd="text/plain",Rd={name:"loadTxt",extension:{type:b.LoadParser,priority:te.Low},test(s){return Ie(s,Bd)||Fe(s,Md)},async load(s){return await(await L.get().fetch(s)).text()}},kd=["normal","bold","100","200","300","400","500","600","700","800","900"],Id=[".ttf",".otf",".woff",".woff2"],Fd=["font/ttf","font/otf","font/woff","font/woff2"],Gd=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Ud(s){const t=gt.extname(s),r=gt.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1));let n=r.length>0;for(const o of r)if(!o.match(Gd)){n=!1;break}let a=r.join(" ");return n||(a=`"${a.replace(/[\\"]/g,"\\$&")}"`),a}const Dd=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Od(s){return Dd.test(s)?s:encodeURI(s)}const Ld={extension:{type:b.LoadParser,priority:te.Low},name:"loadWebFont",test(s){return Ie(s,Fd)||Fe(s,Id)},async load(s,t){var i,r,n;const e=L.get().getFontFaceSet();if(e){const a=[],o=((i=t.data)==null?void 0:i.family)??Ud(s),h=((n=(r=t.data)==null?void 0:r.weights)==null?void 0:n.filter(l=>kd.includes(l)))??["normal"],c=t.data??{};for(let l=0;l<h.length;l++){const u=h[l],d=new FontFace(o,`url(${Od(s)})`,{...c,weight:u});await d.load(),e.add(d),a.push(d)}return K.set(`${o}-and-url`,{url:s,fontFaces:a}),a.length===1?a[0]:a}return D("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(s){(Array.isArray(s)?s:[s]).forEach(t=>{K.remove(t.family),L.get().getFontFaceSet().delete(t)})}};var Hd=zd,hr={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Nd=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function zd(s){var t=[];return s.replace(Nd,function(e,i,r){var n=i.toLowerCase();for(r=Vd(r),n=="m"&&r.length>2&&(t.push([i].concat(r.splice(0,2))),n="l",i=i=="m"?"l":"L");;){if(r.length==hr[n])return r.unshift(i),t.push(r);if(r.length<hr[n])throw new Error("malformed path data");t.push([i].concat(r.splice(0,hr[n])))}}),t}var Wd=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function Vd(s){var t=s.match(Wd);return t?t.map(Number):[]}const jd=xi(Hd);function $d(s,t){const e=jd(s),i=[];let r=null,n=0,a=0;for(let o=0;o<e.length;o++){const h=e[o],c=h[0],l=h;switch(c){case"M":n=l[1],a=l[2],t.moveTo(n,a);break;case"m":n+=l[1],a+=l[2],t.moveTo(n,a);break;case"H":n=l[1],t.lineTo(n,a);break;case"h":n+=l[1],t.lineTo(n,a);break;case"V":a=l[1],t.lineTo(n,a);break;case"v":a+=l[1],t.lineTo(n,a);break;case"L":n=l[1],a=l[2],t.lineTo(n,a);break;case"l":n+=l[1],a+=l[2],t.lineTo(n,a);break;case"C":n=l[5],a=l[6],t.bezierCurveTo(l[1],l[2],l[3],l[4],n,a);break;case"c":t.bezierCurveTo(n+l[1],a+l[2],n+l[3],a+l[4],n+l[5],a+l[6]),n+=l[5],a+=l[6];break;case"S":n=l[3],a=l[4],t.bezierCurveToShort(l[1],l[2],n,a);break;case"s":t.bezierCurveToShort(n+l[1],a+l[2],n+l[3],a+l[4]),n+=l[3],a+=l[4];break;case"Q":n=l[3],a=l[4],t.quadraticCurveTo(l[1],l[2],n,a);break;case"q":t.quadraticCurveTo(n+l[1],a+l[2],n+l[3],a+l[4]),n+=l[3],a+=l[4];break;case"T":n=l[1],a=l[2],t.quadraticCurveToShort(n,a);break;case"t":n+=l[1],a+=l[2],t.quadraticCurveToShort(n,a);break;case"A":n=l[6],a=l[7],t.arcToSvg(l[1],l[2],l[3],l[4],l[5],n,a);break;case"a":n+=l[6],a+=l[7],t.arcToSvg(l[1],l[2],l[3],l[4],l[5],n,a);break;case"Z":case"z":t.closePath(),i.length>0&&(r=i.pop(),r?(n=r.startX,a=r.startY):(n=0,a=0)),r=null;break;default:D(`Unknown SVG path command: ${c}`)}c!=="Z"&&c!=="z"&&r===null&&(r={startX:n,startY:a},i.push(r))}return t}class cr{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new cr(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=i}strokeContains(t,e,i){if(this.radius===0)return!1;const r=this.x-t,n=this.y-e,a=this.radius,o=i/2,h=Math.sqrt(r*r+n*n);return h<a+o&&h>a-o}getBounds(t){return t=t||new Y,t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class lr{constructor(t=0,e=0,i=0,r=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=r}clone(){return new lr(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,r=(e-this.y)/this.halfHeight;return i*=i,r*=r,i+r<=1}strokeContains(t,e,i){const{halfWidth:r,halfHeight:n}=this;if(r<=0||n<=0)return!1;const a=i/2,o=r-a,h=n-a,c=r+a,l=n+a,u=t-this.x,d=e-this.y,f=u*u/(o*o)+d*d/(h*h),p=u*u/(c*c)+d*d/(l*l);return f>1&&p<=1}getBounds(){return new Y(this.x-this.halfWidth,this.y-this.halfHeight,this.halfWidth*2,this.halfHeight*2)}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function Xd(s,t,e,i,r,n){const a=s-e,o=t-i,h=r-e,c=n-i,l=a*h+o*c,u=h*h+c*c;let d=-1;u!==0&&(d=l/u);let f,p;d<0?(f=e,p=i):d>1?(f=r,p=n):(f=e+d*h,p=i+d*c);const g=s-f,m=t-p;return g*g+m*m}class Qe{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let r=0,n=e.length;r<n;r++)i.push(e[r].x,e[r].y);e=i}this.points=e,this.closePath=!0}clone(){const t=this.points.slice(),e=new Qe(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const r=this.points.length/2;for(let n=0,a=r-1;n<r;a=n++){const o=this.points[n*2],h=this.points[n*2+1],c=this.points[a*2],l=this.points[a*2+1];h>e!=l>e&&t<(c-o)*((e-h)/(l-h))+o&&(i=!i)}return i}strokeContains(t,e,i){const r=i/2,n=r*r,{points:a}=this,o=a.length-(this.closePath?0:2);for(let h=0;h<o;h+=2){const c=a[h],l=a[h+1],u=a[(h+2)%a.length],d=a[(h+3)%a.length];if(Xd(t,e,c,l,u,d)<=n)return!0}return!1}getBounds(t){t=t||new Y;const e=this.points;let i=1/0,r=-1/0,n=1/0,a=-1/0;for(let o=0,h=e.length;o<h;o+=2){const c=e[o],l=e[o+1];i=c<i?c:i,r=c>r?c:r,n=l<n?l:n,a=l>a?l:a}return t.x=i,t.width=r-i,t.y=n,t.height=a-n,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}}const $s=(s,t,e,i,r,n)=>{const a=s-e,o=t-i,h=Math.sqrt(a*a+o*o);return h>=r-n&&h<=r+n};class ur{constructor(t=0,e=0,i=0,r=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=r,this.radius=n}getBounds(t){return t=t||new Y,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new ur(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),n=e-(this.y+i);const a=i*i;if(r*r+n*n<=a||(r=t-(this.x+this.width-i),r*r+n*n<=a)||(n=e-(this.y+this.height-i),r*r+n*n<=a)||(r=t-(this.x+i),r*r+n*n<=a))return!0}return!1}strokeContains(t,e,i){const{x:r,y:n,width:a,height:o,radius:h}=this,c=i/2,l=r+h,u=n+h,d=a-h*2,f=o-h*2,p=r+a,g=n+o;return(t>=r-c&&t<=r+c||t>=p-c&&t<=p+c)&&e>=u&&e<=u+f||(e>=n-c&&e<=n+c||e>=g-c&&e<=g+c)&&t>=l&&t<=l+d?!0:t<l&&e<u&&$s(t,e,l,u,h,c)||t>p-h&&e<u&&$s(t,e,p-h,u,h,c)||t>p-h&&e>g-h&&$s(t,e,p-h,g-h,h,c)||t<l&&e>g-h&&$s(t,e,l,g-h,h,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}var V=(s=>(s[s.MAP_READ=1]="MAP_READ",s[s.MAP_WRITE=2]="MAP_WRITE",s[s.COPY_SRC=4]="COPY_SRC",s[s.COPY_DST=8]="COPY_DST",s[s.INDEX=16]="INDEX",s[s.VERTEX=32]="VERTEX",s[s.UNIFORM=64]="UNIFORM",s[s.STORAGE=128]="STORAGE",s[s.INDIRECT=256]="INDIRECT",s[s.QUERY_RESOLVE=512]="QUERY_RESOLVE",s[s.STATIC=1024]="STATIC",s))(V||{});class kt extends _t{constructor(t){let{data:e,size:i}=t;const{usage:r,label:n,shrinkToFit:a}=t;super(),this.uid=et("buffer"),this._resourceType="buffer",this._resourceId=et("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i=i??(e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:i,usage:r,mappedAtCreation:o,label:n},this.shrinkToFit=a??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get static(){return!!(this.descriptor.usage&V.STATIC)}set static(t){t?this.descriptor.usage|=V.STATIC:this.descriptor.usage&=~V.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const r=this._data;if(this._data=t,r.length!==t.length){!this.shrinkToFit&&t.byteLength<r.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=et("resource"),this.emit("change",this));return}i&&this.emit("update",this)}update(t){this._updateSize=t??this._updateSize,this._updateID++,this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function Va(s,t){if(!(s instanceof kt)){let e=t?V.INDEX:V.VERTEX;s instanceof Array&&(t?(s=new Uint32Array(s),e=V.INDEX|V.COPY_DST):(s=new Float32Array(s),e=V.VERTEX|V.COPY_DST)),s=new kt({data:s,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return s}function Yd(s,t,e){const i=s.getAttribute(t);if(!i)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const r=i.buffer.data;let n=1/0,a=1/0,o=-1/0,h=-1/0;const c=r.BYTES_PER_ELEMENT,l=(i.offset||0)/c,u=(i.stride||2*4)/c;for(let d=l;d<r.length;d+=u){const f=r[d],p=r[d+1];f>o&&(o=f),p>h&&(h=p),f<n&&(n=f),p<a&&(a=p)}return e.minX=n,e.minY=a,e.maxX=o,e.maxY=h,e}function Kd(s){return(s instanceof kt||Array.isArray(s)||s.BYTES_PER_ELEMENT)&&(s={buffer:s}),s.buffer=Va(s.buffer,!1),s}class Xs extends _t{constructor(t){const{attributes:e,indexBuffer:i,topology:r}=t;super(),this.uid=et("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new mt,this._boundsDirty=!0,this.attributes=e,this.buffers=[],this.instanceCount=t.instanceCount||1;for(const n in e){const a=e[n]=Kd(e[n]);this.buffers.indexOf(a.buffer)===-1&&(this.buffers.push(a.buffer),a.buffer.on("update",this.onBufferUpdate,this),a.buffer.on("change",this.onBufferUpdate,this))}i&&(this.indexBuffer=Va(i,!0),this.buffers.push(this.indexBuffer)),this.topology=r||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Yd(this,"aPosition",this._bounds)):this._bounds}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(e=>e.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const qd=new Float32Array(1),Zd=new Uint32Array(1);class ja extends Xs{constructor(){const e=new kt({data:qd,label:"attribute-batch-buffer",usage:V.VERTEX|V.COPY_DST,shrinkToFit:!1}),i=new kt({data:Zd,label:"index-batch-buffer",usage:V.INDEX|V.COPY_DST,shrinkToFit:!1}),r=6*4;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:r,offset:0,location:1},aUV:{buffer:e,format:"float32x2",stride:r,offset:2*4,location:3},aColor:{buffer:e,format:"unorm8x4",stride:r,offset:4*4,location:0},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:r,offset:5*4,location:2}},indexBuffer:i})}}let Ys=null;function Ht(){if(Ys)return Ys;const s=Pa();return Ys=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),Ys}const $a={};function dr(s,t){let e=0;for(let i=0;i<t;i++)e=e*31+s[i].uid>>>0;return $a[e]||Jd(s,e)}let fr=0;function Jd(s,t){const e={};let i=0;fr||(fr=Ht());for(let n=0;n<fr;n++){const a=n<s.length?s[n]:M.EMPTY.source;e[i++]=a.source,e[i++]=a.style}const r=new Yt(e);return $a[t]=r,r}class Xa{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}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 int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}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`)}}}function pr(s,t){const e=s.byteLength/8|0,i=new Float64Array(s,0,e);new Float64Array(t,0,e).set(i);const n=s.byteLength-e*8;if(n>0){const a=new Uint8Array(s,e*8,n);new Uint8Array(t,e*8,n).set(a)}}const Qd={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var ht=(s=>(s[s.DISABLED=0]="DISABLED",s[s.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",s[s.MASK_ACTIVE=2]="MASK_ACTIVE",s[s.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",s[s.NONE=4]="NONE",s))(ht||{});function Ya(s,t){return t.alphaMode==="no-premultiply-alpha"&&Qd[s]||s}class Ka{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}class qa{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.blendMode="normal",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}let ts=0;const Za=class xl{constructor(t={}){this.uid=et("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._vertexSize=6,this._elements=[],this._batchPool=[],this._batchPoolIndex=0,this._textureBatchPool=[],this._textureBatchPoolIndex=0,t={...xl.defaultOptions,...t};const{vertexSize:e,indexSize:i}=t;this.attributeBuffer=new Xa(e*this._vertexSize*4),this.indexBuffer=new Uint16Array(i),this._maxTextures=Ht()}begin(){this.batchIndex=0,this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0,this._batchPoolIndex=0,this._textureBatchPoolIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t.indexStart=this.indexSize,t.location=this.attributeSize,t.batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.vertexSize*this._vertexSize}checkAndUpdateTexture(t,e){const i=t.batch.textures.ids[e._source.uid];return!i&&i!==0?!1:(t.textureId=i,t.texture=e,!0)}updateElement(t){this.dirty=!0,t.packAttributes(this.attributeBuffer.float32View,this.attributeBuffer.uint32View,t.location,t.textureId)}break(t){const e=this._elements;let i=this._textureBatchPool[this._textureBatchPoolIndex++]||new Ka;if(i.clear(),!e[this.elementStart])return;const r=e[this.elementStart];let n=Ya(r.blendMode,r.texture._source);this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const a=this.attributeBuffer.float32View,o=this.attributeBuffer.uint32View,h=this.indexBuffer;let c=this._batchIndexSize,l=this._batchIndexStart,u="startBatch",d=this._batchPool[this._batchPoolIndex++]||new qa;const f=this._maxTextures;for(let p=this.elementStart;p<this.elementSize;++p){const g=e[p];e[p]=null;const _=g.texture._source,x=Ya(g.blendMode,_),y=n!==x;if(_._batchTick===ts&&!y){g.textureId=_._textureBindLocation,c+=g.indexSize,g.packAttributes(a,o,g.location,g.textureId),g.packIndex(h,g.indexStart,g.location/this._vertexSize),g.batch=d;continue}_._batchTick=ts,(i.count>=f||y)&&(this._finishBatch(d,l,c-l,i,n,t,u),u="renderBatch",l=c,n=x,i=this._textureBatchPool[this._textureBatchPoolIndex++]||new Ka,i.clear(),d=this._batchPool[this._batchPoolIndex++]||new qa,++ts),g.textureId=_._textureBindLocation=i.count,i.ids[_.uid]=i.count,i.textures[i.count++]=_,g.batch=d,c+=g.indexSize,g.packAttributes(a,o,g.location,g.textureId),g.packIndex(h,g.indexStart,g.location/this._vertexSize)}i.count>0&&(this._finishBatch(d,l,c-l,i,n,t,u),l=c,++ts),this.elementStart=this.elementSize,this._batchIndexStart=l,this._batchIndexSize=c}_finishBatch(t,e,i,r,n,a,o){t.gpuBindGroup=null,t.action=o,t.batcher=this,t.textures=r,t.blendMode=n,t.start=e,t.size=i,++ts,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),i=new Xa(e);pr(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const r=i>65535?new Uint32Array(i):new Uint16Array(i);if(r.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n<e.length;n++)r[n]=e[n];else pr(e.buffer,r.buffer);this.indexBuffer=r}destroy(){for(let t=0;t<this.batches.length;t++)this.batches[t].destroy();this.batches=null;for(let t=0;t<this._elements.length;t++)this._elements[t].batch=null;this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}};Za.defaultOptions={vertexSize:4,indexSize:6};let Ja=Za;function tf(s,t,e,i,r,n,a,o=null){let h=0;e*=t,r*=n;const c=o.a,l=o.b,u=o.c,d=o.d,f=o.tx,p=o.ty;for(;h<a;){const g=s[e],m=s[e+1];i[r]=c*g+u*m+f,i[r+1]=l*g+d*m+p,r+=n,e+=t,h++}}function ef(s,t,e,i){let r=0;for(t*=e;r<i;)s[t]=0,s[t+1]=0,t+=e,r++}function Qa(s,t,e,i,r){const n=t.a,a=t.b,o=t.c,h=t.d,c=t.tx,l=t.ty;e=e||0,i=i||2,r=r||s.length/i-e;let u=e*i;for(let d=0;d<r;d++){const f=s[u],p=s[u+1];s[u]=n*f+o*p+c,s[u+1]=a*f+h*p+l,u+=i}}function sf(s,t){if(s===16777215||!t)return t;if(t===16777215||!s)return s;const e=s>>16&255,i=s>>8&255,r=s&255,n=t>>16&255,a=t>>8&255,o=t&255,h=e*n/255,c=i*a/255,l=r*o/255;return(h<<16)+(c<<8)+l}class mr{constructor(){this.batcher=null,this.batch=null,this.applyTransform=!0,this.roundPixels=0}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:"normal"}packIndex(t,e,i){const r=this.geometryData.indices;for(let n=0;n<this.indexSize;n++)t[e++]=r[n+this.indexOffset]+i-this.vertexOffset}packAttributes(t,e,i,r){const n=this.geometryData,a=this.renderable,o=n.vertices,h=n.uvs,c=this.vertexOffset*2,l=(this.vertexOffset+this.vertexSize)*2,u=this.color,d=u>>16|u&65280|(u&255)<<16;if(this.applyTransform){const f=sf(d,a.groupColor)+(this.alpha*a.groupAlpha*255<<24),p=a.groupTransform,g=r<<16|this.roundPixels&65535,m=p.a,_=p.b,x=p.c,y=p.d,v=p.tx,w=p.ty;for(let E=c;E<l;E+=2){const C=o[E],P=o[E+1];t[i]=m*C+x*P+v,t[i+1]=_*C+y*P+w,t[i+2]=h[E],t[i+3]=h[E+1],e[i+4]=f,e[i+5]=g,i+=6}}else{const f=d+(this.alpha*255<<24);for(let p=c;p<l;p+=2)t[i]=o[p],t[i+1]=o[p+1],t[i+2]=h[p],t[i+3]=h[p+1],e[i+4]=f,e[i+5]=r<<16,i+=6}}get vertSize(){return this.vertexSize}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.vertexOffset=this.vertexOffset,t.vertexSize=this.vertexSize,t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData}reset(){this.applyTransform=!0}}const gr={build(s,t){let e,i,r,n,a,o;if(s.type==="circle"){const v=s;e=v.x,i=v.y,a=o=v.radius,r=n=0}else if(s.type==="ellipse"){const v=s;e=v.x,i=v.y,a=v.halfWidth,o=v.halfHeight,r=n=0}else{const v=s,w=v.width/2,E=v.height/2;e=v.x+w,i=v.y+E,a=o=Math.max(0,Math.min(v.radius,Math.min(w,E))),r=w-a,n=E-o}if(!(a>=0&&o>=0&&r>=0&&n>=0))return t;const h=Math.ceil(2.3*Math.sqrt(a+o)),c=h*8+(r?4:0)+(n?4:0);if(c===0)return t;if(h===0)return t[0]=t[6]=e+r,t[1]=t[3]=i+n,t[2]=t[4]=e-r,t[5]=t[7]=i-n,t;let l=0,u=h*4+(r?2:0)+2,d=u,f=c,p=r+a,g=n,m=e+p,_=e-p,x=i+g;if(t[l++]=m,t[l++]=x,t[--u]=x,t[--u]=_,n){const v=i-g;t[d++]=_,t[d++]=v,t[--f]=v,t[--f]=m}for(let v=1;v<h;v++){const w=Math.PI/2*(v/h),E=r+Math.cos(w)*a,C=n+Math.sin(w)*o,P=e+E,S=e-E,A=i+C,Q=i-C;t[l++]=P,t[l++]=A,t[--u]=A,t[--u]=S,t[d++]=S,t[d++]=Q,t[--f]=Q,t[--f]=P}p=r,g=n+o,m=e+p,_=e-p,x=i+g;const y=i-g;return t[l++]=m,t[l++]=x,t[--f]=y,t[--f]=m,r&&(t[l++]=_,t[l++]=x,t[--f]=y,t[--f]=_),t},triangulate(s,t,e,i,r,n){if(s.length===0)return;let a=0,o=0;for(let l=0;l<s.length;l+=2)a+=s[l],o+=s[l+1];a/=s.length/2,o/=s.length/2;let h=i;t[h*e]=a,t[h*e+1]=o;const c=h++;for(let l=0;l<s.length;l+=2)t[h*e]=s[l],t[h*e+1]=s[l+1],l>0&&(r[n++]=h,r[n++]=c,r[n++]=h-1),h++;r[n++]=c+1,r[n++]=c,r[n++]=h-1}},rf=1e-4,to=1e-4;function nf(s){const t=s.length;if(t<6)return 1;let e=0;for(let i=0,r=s[t-2],n=s[t-1];i<t;i+=2){const a=s[i],o=s[i+1];e+=(a-r)*(o+n),r=a,n=o}return e<0?-1:1}function eo(s,t,e,i,r,n,a,o){const h=s-e*r,c=t-i*r,l=s+e*n,u=t+i*n;let d,f;a?(d=i,f=-e):(d=-i,f=e);const p=h+d,g=c+f,m=l+d,_=u+f;return o.push(p,g),o.push(m,_),2}function pe(s,t,e,i,r,n,a,o){const h=e-s,c=i-t;let l=Math.atan2(h,c),u=Math.atan2(r-s,n-t);o&&l<u?l+=Math.PI*2:!o&&l>u&&(u+=Math.PI*2);let d=l;const f=u-l,p=Math.abs(f),g=Math.sqrt(h*h+c*c),m=(15*p*Math.sqrt(g)/Math.PI>>0)+1,_=f/m;if(d+=_,o){a.push(s,t),a.push(e,i);for(let x=1,y=d;x<m;x++,y+=_)a.push(s,t),a.push(s+Math.sin(y)*g,t+Math.cos(y)*g);a.push(s,t),a.push(r,n)}else{a.push(e,i),a.push(s,t);for(let x=1,y=d;x<m;x++,y+=_)a.push(s+Math.sin(y)*g,t+Math.cos(y)*g),a.push(s,t);a.push(r,n),a.push(s,t)}return m*2}function af(s,t,e,i,r,n,a,o,h){const c=rf;if(s.length===0)return;const l=t;let u=l.alignment;if(t.alignment!==.5){let Z=nf(s);u=(u-.5)*Z+.5}const d=new X(s[0],s[1]),f=new X(s[s.length-2],s[s.length-1]),p=i,g=Math.abs(d.x-f.x)<c&&Math.abs(d.y-f.y)<c;if(p){s=s.slice(),g&&(s.pop(),s.pop(),f.set(s[s.length-2],s[s.length-1]));const Z=(d.x+f.x)*.5,oe=(f.y+d.y)*.5;s.unshift(Z,oe),s.push(Z,oe)}const m=r,_=s.length/2;let x=s.length;const y=m.length/2,v=l.width/2,w=v*v,E=l.miterLimit*l.miterLimit;let C=s[0],P=s[1],S=s[2],A=s[3],Q=0,Mt=0,F=-(P-A),B=C-S,q=0,it=0,vt=Math.sqrt(F*F+B*B);F/=vt,B/=vt,F*=v,B*=v;const _s=u,G=(1-_s)*2,U=_s*2;p||(l.cap==="round"?x+=pe(C-F*(G-U)*.5,P-B*(G-U)*.5,C-F*G,P-B*G,C+F*U,P+B*U,m,!0)+2:l.cap==="square"&&(x+=eo(C,P,F,B,G,U,!0,m))),m.push(C-F*G,P-B*G),m.push(C+F*U,P+B*U);for(let Z=1;Z<_-1;++Z){C=s[(Z-1)*2],P=s[(Z-1)*2+1],S=s[Z*2],A=s[Z*2+1],Q=s[(Z+1)*2],Mt=s[(Z+1)*2+1],F=-(P-A),B=C-S,vt=Math.sqrt(F*F+B*B),F/=vt,B/=vt,F*=v,B*=v,q=-(A-Mt),it=S-Q,vt=Math.sqrt(q*q+it*it),q/=vt,it/=vt,q*=v,it*=v;const oe=S-C,xs=P-A,ys=S-Q,bs=Mt-A,hl=oe*ys+xs*bs,mi=xs*ys-bs*oe,vs=mi<0;if(Math.abs(mi)<.001*Math.abs(hl)){m.push(S-F*G,A-B*G),m.push(S+F*U,A+B*U),hl>=0&&(l.join==="round"?x+=pe(S,A,S-F*G,A-B*G,S-q*G,A-it*G,m,!1)+4:x+=2,m.push(S-q*U,A-it*U),m.push(S+q*G,A+it*G));continue}const cl=(-F+C)*(-B+A)-(-F+S)*(-B+P),ll=(-q+Q)*(-it+A)-(-q+S)*(-it+Mt),gi=(oe*ll-ys*cl)/mi,_i=(bs*cl-xs*ll)/mi,_n=(gi-S)*(gi-S)+(_i-A)*(_i-A),be=S+(gi-S)*G,ve=A+(_i-A)*G,Se=S-(gi-S)*U,we=A-(_i-A)*U,px=Math.min(oe*oe+xs*xs,ys*ys+bs*bs),ul=vs?G:U,mx=px+ul*ul*w;_n<=mx?l.join==="bevel"||_n/w>E?(vs?(m.push(be,ve),m.push(S+F*U,A+B*U),m.push(be,ve),m.push(S+q*U,A+it*U)):(m.push(S-F*G,A-B*G),m.push(Se,we),m.push(S-q*G,A-it*G),m.push(Se,we)),x+=2):l.join==="round"?vs?(m.push(be,ve),m.push(S+F*U,A+B*U),x+=pe(S,A,S+F*U,A+B*U,S+q*U,A+it*U,m,!0)+4,m.push(be,ve),m.push(S+q*U,A+it*U)):(m.push(S-F*G,A-B*G),m.push(Se,we),x+=pe(S,A,S-F*G,A-B*G,S-q*G,A-it*G,m,!1)+4,m.push(S-q*G,A-it*G),m.push(Se,we)):(m.push(be,ve),m.push(Se,we)):(m.push(S-F*G,A-B*G),m.push(S+F*U,A+B*U),l.join==="round"?vs?x+=pe(S,A,S+F*U,A+B*U,S+q*U,A+it*U,m,!0)+2:x+=pe(S,A,S-F*G,A-B*G,S-q*G,A-it*G,m,!1)+2:l.join==="miter"&&_n/w<=E&&(vs?(m.push(Se,we),m.push(Se,we)):(m.push(be,ve),m.push(be,ve)),x+=2),m.push(S-q*G,A-it*G),m.push(S+q*U,A+it*U),x+=2)}C=s[(_-2)*2],P=s[(_-2)*2+1],S=s[(_-1)*2],A=s[(_-1)*2+1],F=-(P-A),B=C-S,vt=Math.sqrt(F*F+B*B),F/=vt,B/=vt,F*=v,B*=v,m.push(S-F*G,A-B*G),m.push(S+F*U,A+B*U),p||(l.cap==="round"?x+=pe(S-F*(G-U)*.5,A-B*(G-U)*.5,S-F*G,A-B*G,S+F*U,A+B*U,m,!1)+2:l.cap==="square"&&(x+=eo(S,A,F,B,G,U,!1,m)));const fx=to*to;for(let Z=y;Z<x+y-2;++Z)C=m[Z*2],P=m[Z*2+1],S=m[(Z+1)*2],A=m[(Z+1)*2+1],Q=m[(Z+2)*2],Mt=m[(Z+2)*2+1],!(Math.abs(C*(A-Mt)+S*(Mt-P)+Q*(P-A))<fx)&&o.push(Z,Z+1,Z+2)}function so(s,t,e,i,r,n,a){const o=ud(s,t,2);if(!o)return;for(let c=0;c<o.length;c+=3)n[a++]=o[c]+r,n[a++]=o[c+1]+r,n[a++]=o[c+2]+r;let h=r*i;for(let c=0;c<s.length;c+=2)e[h]=s[c],e[h+1]=s[c+1],h+=i}const of=[],_r={rectangle:{build(s,t){const e=s,i=e.x,r=e.y,n=e.width,a=e.height;return n>=0&&a>=0&&(t[0]=i,t[1]=r,t[2]=i+n,t[3]=r,t[4]=i+n,t[5]=r+a,t[6]=i,t[7]=r+a),t},triangulate(s,t,e,i,r,n){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[6],t[i+a+1]=s[7],a+=e,t[i+a]=s[4],t[i+a+1]=s[5],a+=e;const o=i/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2,r[n++]=o+1,r[n++]=o+3,r[n++]=o+2}},polygon:{build(s,t){for(let e=0;e<s.points.length;e++)t[e]=s.points[e];return t},triangulate(s,t,e,i,r,n){so(s,of,t,e,i,r,n)}},triangle:{build(s,t){return t[0]=s.x,t[1]=s.y,t[2]=s.x2,t[3]=s.y2,t[4]=s.x3,t[5]=s.y3,t},triangulate(s,t,e,i,r,n){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[4],t[i+a+1]=s[5];const o=i/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2}},circle:gr,ellipse:gr,roundedRectangle:gr},hf=new Y;function cf(s,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let r=0;r<s.instructions.length;r++){const n=s.instructions[r];if(n.action==="texture")lf(n.data,i,e);else if(n.action==="fill"||n.action==="stroke"){const a=n.action==="stroke",o=n.data.path.shapePath,h=n.data.style,c=n.data.hole;a&&c&&io(c.shapePath,h,null,!0,i,e),io(o,h,c,a,i,e)}}}function lf(s,t,e){const{vertices:i,uvs:r,indices:n}=e,a=n.length,o=i.length/2,h=[],c=_r.rectangle,l=hf,u=s.image;l.x=s.dx,l.y=s.dy,l.width=s.dw,l.height=s.dh;const d=s.transform;c.build(l,h),d&&Qa(h,d),c.triangulate(h,i,2,o,n,a);const f=u.uvs;r.push(f.x0,f.y0,f.x1,f.y1,f.x3,f.y3,f.x2,f.y2);const p=$.get(mr);p.indexOffset=a,p.indexSize=n.length-a,p.vertexOffset=o,p.vertexSize=i.length/2-o,p.color=s.style,p.alpha=s.alpha,p.texture=u,p.geometryData=e,t.push(p)}function io(s,t,e,i,r,n){const{vertices:a,uvs:o,indices:h}=n,c=s.shapePrimitives.length-1;s.shapePrimitives.forEach(({shape:l,transform:u},d)=>{const f=h.length,p=a.length/2,g=[],m=_r[l.type];if(m.build(l,g),u&&Qa(g,u),i){const v=l.closePath??!0;af(g,t,!1,v,a,2,p,h)}else if(e&&c===d){c!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const v=[],w=g.slice();uf(e.shapePath).forEach(C=>{v.push(w.length/2),w.push(...C)}),so(w,v,a,2,p,h,f)}else m.triangulate(g,a,2,p,h,f);const _=o.length/2,x=t.texture;if(x!==M.WHITE){const v=t.matrix;u&&v.append(u.clone().invert()),tf(a,2,p,o,_,2,a.length/2-p,v)}else ef(o,_,2,a.length/2-p);const y=$.get(mr);y.indexOffset=f,y.indexSize=h.length-f,y.vertexOffset=p,y.vertexSize=a.length/2-p,y.color=t.color,y.alpha=t.alpha,y.texture=x,y.geometryData=n,r.push(y)})}function uf(s){if(!s)return[];const t=s.shapePrimitives,e=[];for(let i=0;i<t.length;i++){const r=t[i].shape,n=[];_r[r.type].build(r,n),e.push(n)}return e}class df{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class ff{constructor(){this.geometry=new ja,this.instructions=new qn}init(){this.instructions.reset()}}const xr=class bn{constructor(){this._activeBatchers=[],this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null)}init(t){bn.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??bn.defaultOptions.bezierSmoothness}prerender(){this._returnActiveBatchers()}getContextRenderData(t){return this._graphicsDataContextHash[t.uid]||this._initContextRenderData(t)}updateGpuContext(t){let e=this._gpuContextHash[t.uid]||this._initContext(t);if(t.dirty){e?this._cleanGraphicsContextData(t):e=this._initContext(t),cf(t,e);const i=t.batchMode;t.customShader||i==="no-batch"?e.isBatchable=!1:i==="auto"&&(e.isBatchable=e.geometryData.vertices.length<400),t.dirty=!1}return e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_returnActiveBatchers(){for(let t=0;t<this._activeBatchers.length;t++)$.return(this._activeBatchers[t]);this._activeBatchers.length=0}_initContextRenderData(t){const e=$.get(ff),{batches:i,geometryData:r}=this._gpuContextHash[t.uid],n=r.vertices.length,a=r.indices.length;for(let l=0;l<i.length;l++)i[l].applyTransform=!1;const o=$.get(Ja);this._activeBatchers.push(o),o.ensureAttributeBuffer(n),o.ensureIndexBuffer(a),o.begin();for(let l=0;l<i.length;l++){const u=i[l];o.add(u)}o.finish(e.instructions);const h=e.geometry;h.indexBuffer.setDataWithSize(o.indexBuffer,o.indexSize,!0),h.buffers[0].setDataWithSize(o.attributeBuffer.float32View,o.attributeSize,!0);const c=o.batches;for(let l=0;l<c.length;l++){const u=c[l];u.bindGroup=dr(u.textures.textures,u.textures.count)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new df;return e.context=t,this._gpuContextHash[t.uid]=e,t.on("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]}onGraphicsContextDestroy(t){this._cleanGraphicsContextData(t),t.off("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]=null}_cleanGraphicsContextData(t){const e=this._gpuContextHash[t.uid];e.isBatchable||this._graphicsDataContextHash[t.uid]&&($.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(i=>{$.return(i)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};xr.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"graphicsContext"},xr.defaultOptions={bezierSmoothness:.5};let yr=xr;const pf=8,Ks=11920929e-14,mf=1;function ro(s,t,e,i,r,n,a,o,h,c){const u=Math.min(.99,Math.max(0,c??yr.defaultOptions.bezierSmoothness));let d=(mf-u)/1;return d*=d,gf(t,e,i,r,n,a,o,h,s,d),s}function gf(s,t,e,i,r,n,a,o,h,c){br(s,t,e,i,r,n,a,o,h,c,0),h.push(a,o)}function br(s,t,e,i,r,n,a,o,h,c,l){if(l>pf)return;const u=(s+e)/2,d=(t+i)/2,f=(e+r)/2,p=(i+n)/2,g=(r+a)/2,m=(n+o)/2,_=(u+f)/2,x=(d+p)/2,y=(f+g)/2,v=(p+m)/2,w=(_+y)/2,E=(x+v)/2;if(l>0){let C=a-s,P=o-t;const S=Math.abs((e-a)*P-(i-o)*C),A=Math.abs((r-a)*P-(n-o)*C);if(S>Ks&&A>Ks){if((S+A)*(S+A)<=c*(C*C+P*P)){h.push(w,E);return}}else if(S>Ks){if(S*S<=c*(C*C+P*P)){h.push(w,E);return}}else if(A>Ks){if(A*A<=c*(C*C+P*P)){h.push(w,E);return}}else if(C=w-(s+a)/2,P=E-(t+o)/2,C*C+P*P<=c){h.push(w,E);return}}br(s,t,u,d,_,x,w,E,h,c,l+1),br(w,E,y,v,g,m,a,o,h,c,l+1)}const _f=8,xf=11920929e-14,yf=1;function bf(s,t,e,i,r,n,a,o){const c=Math.min(.99,Math.max(0,o??yr.defaultOptions.bezierSmoothness));let l=(yf-c)/1;return l*=l,vf(t,e,i,r,n,a,s,l),s}function vf(s,t,e,i,r,n,a,o){vr(a,s,t,e,i,r,n,o,0),a.push(r,n)}function vr(s,t,e,i,r,n,a,o,h){if(h>_f)return;const c=(t+i)/2,l=(e+r)/2,u=(i+n)/2,d=(r+a)/2,f=(c+u)/2,p=(l+d)/2;let g=n-t,m=a-e;const _=Math.abs((i-n)*m-(r-a)*g);if(_>xf){if(_*_<=o*(g*g+m*m)){s.push(f,p);return}}else if(g=f-(t+n)/2,m=p-(e+a)/2,g*g+m*m<=o){s.push(f,p);return}vr(s,t,e,c,l,f,p,o,h+1),vr(s,f,p,u,d,n,a,o,h+1)}function no(s,t,e,i,r,n,a,o){let h=Math.abs(r-n);(!a&&r>n||a&&n>r)&&(h=2*Math.PI-h),o=o||Math.max(6,Math.floor(6*Math.pow(i,1/3)*(h/Math.PI))),o=Math.max(o,3);let c=h/o,l=r;c*=a?-1:1;for(let u=0;u<o+1;u++){const d=Math.cos(l),f=Math.sin(l),p=t+d*i,g=e+f*i;s.push(p,g),l+=c}}function Sf(s,t,e,i,r,n){const a=s[s.length-2],h=s[s.length-1]-e,c=a-t,l=r-e,u=i-t,d=Math.abs(h*u-c*l);if(d<1e-8||n===0){(s[s.length-2]!==t||s[s.length-1]!==e)&&s.push(t,e);return}const f=h*h+c*c,p=l*l+u*u,g=h*l+c*u,m=n*Math.sqrt(f)/d,_=n*Math.sqrt(p)/d,x=m*g/f,y=_*g/p,v=m*u+_*c,w=m*l+_*h,E=c*(_+x),C=h*(_+x),P=u*(m+y),S=l*(m+y),A=Math.atan2(C-w,E-v),Q=Math.atan2(S-w,P-v);no(s,v+t,w+e,n,A,Q,c*l>u*h)}const es=Math.PI*2,Sr={centerX:0,centerY:0,ang1:0,ang2:0},wr=({x:s,y:t},e,i,r,n,a,o,h)=>{s*=e,t*=i;const c=r*s-n*t,l=n*s+r*t;return h.x=c+a,h.y=l+o,h};function wf(s,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,r=Math.cos(s),n=Math.sin(s),a=Math.cos(s+t),o=Math.sin(s+t);return[{x:r-n*i,y:n+r*i},{x:a+o*i,y:o-a*i},{x:a,y:o}]}const ao=(s,t,e,i)=>{const r=s*i-t*e<0?-1:1;let n=s*e+t*i;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},Tf=(s,t,e,i,r,n,a,o,h,c,l,u,d)=>{const f=Math.pow(r,2),p=Math.pow(n,2),g=Math.pow(l,2),m=Math.pow(u,2);let _=f*p-f*m-p*g;_<0&&(_=0),_/=f*m+p*g,_=Math.sqrt(_)*(a===o?-1:1);const x=_*r/n*u,y=_*-n/r*l,v=c*x-h*y+(s+e)/2,w=h*x+c*y+(t+i)/2,E=(l-x)/r,C=(u-y)/n,P=(-l-x)/r,S=(-u-y)/n,A=ao(1,0,E,C);let Q=ao(E,C,P,S);o===0&&Q>0&&(Q-=es),o===1&&Q<0&&(Q+=es),d.centerX=v,d.centerY=w,d.ang1=A,d.ang2=Q};function Af(s,t,e,i,r,n,a,o=0,h=0,c=0){if(n===0||a===0)return;const l=Math.sin(o*es/360),u=Math.cos(o*es/360),d=u*(t-i)/2+l*(e-r)/2,f=-l*(t-i)/2+u*(e-r)/2;if(d===0&&f===0)return;n=Math.abs(n),a=Math.abs(a);const p=Math.pow(d,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(a,2);p>1&&(n*=Math.sqrt(p),a*=Math.sqrt(p)),Tf(t,e,i,r,n,a,h,c,l,u,d,f,Sr);let{ang1:g,ang2:m}=Sr;const{centerX:_,centerY:x}=Sr;let y=Math.abs(m)/(es/4);Math.abs(1-y)<1e-7&&(y=1);const v=Math.max(Math.ceil(y),1);m/=v;let w=s[s.length-2],E=s[s.length-1];const C={x:0,y:0};for(let P=0;P<v;P++){const S=wf(g,m),{x:A,y:Q}=wr(S[0],n,a,u,l,_,x,C),{x:Mt,y:F}=wr(S[1],n,a,u,l,_,x,C),{x:B,y:q}=wr(S[2],n,a,u,l,_,x,C);ro(s,w,E,A,Q,Mt,F,B,q),w=B,E=q,g+=m}}function Pf(s,t,e){const i=(a,o)=>{const h=o.x-a.x,c=o.y-a.y,l=Math.sqrt(h*h+c*c),u=h/l,d=c/l;return{len:l,nx:u,ny:d}},r=(a,o)=>{a===0?s.moveTo(o.x,o.y):s.lineTo(o.x,o.y)};let n=t[t.length-1];for(let a=0;a<t.length;a++){const o=t[a%t.length],h=o.radius??e;if(h<=0){r(a,o),n=o;continue}const c=t[(a+1)%t.length],l=i(o,n),u=i(o,c);if(l.len<1e-4||u.len<1e-4){r(a,o),n=o;continue}let d=Math.asin(l.nx*u.ny-l.ny*u.nx),f=1,p=!1;l.nx*u.nx-l.ny*-u.ny<0?d<0?d=Math.PI+d:(d=Math.PI-d,f=-1,p=!0):d>0&&(f=-1,p=!0);const g=d/2;let m,_=Math.abs(Math.cos(g)*h/Math.sin(g));_>Math.min(l.len/2,u.len/2)?(_=Math.min(l.len/2,u.len/2),m=Math.abs(_*Math.sin(g)/Math.cos(g))):m=h;const x=o.x+u.nx*_+-u.ny*m*f,y=o.y+u.ny*_+u.nx*m*f,v=Math.atan2(l.ny,l.nx)+Math.PI/2*f,w=Math.atan2(u.ny,u.nx)-Math.PI/2*f;a===0&&s.moveTo(x+Math.cos(v)*m,y+Math.sin(v)*m),s.arc(x,y,m,v,w,p),n=o}}function Cf(s,t,e,i){const r=(o,h)=>Math.sqrt((o.x-h.x)**2+(o.y-h.y)**2),n=(o,h,c)=>({x:o.x+(h.x-o.x)*c,y:o.y+(h.y-o.y)*c}),a=t.length;for(let o=0;o<a;o++){const h=t[(o+1)%a],c=h.radius??e;if(c<=0){o===0?s.moveTo(h.x,h.y):s.lineTo(h.x,h.y);continue}const l=t[o],u=t[(o+2)%a],d=r(l,h);let f;if(d<1e-4)f=h;else{const m=Math.min(d/2,c);f=n(h,l,m/d)}const p=r(u,h);let g;if(p<1e-4)g=h;else{const m=Math.min(p/2,c);g=n(h,u,m/p)}o===0?s.moveTo(f.x,f.y):s.lineTo(f.x,f.y),s.quadraticCurveTo(h.x,h.y,g.x,g.y,i)}}const Ef=new Y;class Mf{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new mt,this._graphicsPath2D=t}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const i=this._currentPoly.points,r=i[i.length-2],n=i[i.length-1];return(r!==t||n!==e)&&i.push(t,e),this}arc(t,e,i,r,n,a){this._ensurePoly(!1);const o=this._currentPoly.points;return no(o,t,e,i,r,n,a),this}arcTo(t,e,i,r,n){this._ensurePoly();const a=this._currentPoly.points;return Sf(a,t,e,i,r,n),this}arcToSvg(t,e,i,r,n,a,o){const h=this._currentPoly.points;return Af(h,this._currentPoly.lastX,this._currentPoly.lastY,a,o,t,e,i,r,n),this}bezierCurveTo(t,e,i,r,n,a,o){this._ensurePoly();const h=this._currentPoly;return ro(this._currentPoly.points,h.lastX,h.lastY,t,e,i,r,n,a,o),this}quadraticCurveTo(t,e,i,r,n){this._ensurePoly();const a=this._currentPoly;return bf(this._currentPoly.points,a.lastX,a.lastY,t,e,i,r,n),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));for(let i=0;i<t.instructions.length;i++){const r=t.instructions[i];this[r.action](...r.data)}return this}finish(t=!1){this.endPoly(t)}rect(t,e,i,r,n){return this.drawShape(new Y(t,e,i,r),n),this}circle(t,e,i,r){return this.drawShape(new cr(t,e,i),r),this}poly(t,e,i){const r=new Qe(t);return r.closePath=e,this.drawShape(r,i),this}regularPoly(t,e,i,r,n=0,a){r=Math.max(r|0,3);const o=-1*Math.PI/2+n,h=Math.PI*2/r,c=[];for(let l=0;l<r;l++){const u=l*h+o;c.push(t+i*Math.cos(u),e+i*Math.sin(u))}return this.poly(c,!0,a),this}roundPoly(t,e,i,r,n,a=0,o){if(r=Math.max(r|0,3),n<=0)return this.regularPoly(t,e,i,r,a);const h=i*Math.sin(Math.PI/r)-.001;n=Math.min(n,h);const c=-1*Math.PI/2+a,l=Math.PI*2/r,u=(r-2)*Math.PI/r/2;for(let d=0;d<r;d++){const f=d*l+c,p=t+i*Math.cos(f),g=e+i*Math.sin(f),m=f+Math.PI+u,_=f-Math.PI-u,x=p+n*Math.cos(m),y=g+n*Math.sin(m),v=p+n*Math.cos(_),w=g+n*Math.sin(_);d===0?this.moveTo(x,y):this.lineTo(x,y),this.quadraticCurveTo(p,g,v,w,o)}return this.closePath()}roundShape(t,e,i=!1,r){return t.length<3?this:(i?Cf(this,t,e,r):Pf(this,t,e),this.closePath())}filletRect(t,e,i,r,n){if(n===0)return this.rect(t,e,i,r);const a=Math.min(i,r)/2,o=Math.min(a,Math.max(-a,n)),h=t+i,c=e+r,l=o<0?-o:0,u=Math.abs(o);return this.moveTo(t,e+u).arcTo(t+l,e+l,t+u,e,u).lineTo(h-u,e).arcTo(h-l,e+l,h,e+u,u).lineTo(h,c-u).arcTo(h-l,c-l,t+i-u,c,u).lineTo(t+u,c).arcTo(t+l,c-l,t,c-u,u).closePath()}chamferRect(t,e,i,r,n,a){if(n<=0)return this.rect(t,e,i,r);const o=Math.min(n,Math.min(i,r)/2),h=t+i,c=e+r,l=[t+o,e,h-o,e,h,e+o,h,c-o,h-o,c,t+o,c,t,c-o,t,e+o];for(let u=l.length-1;u>=2;u-=2)l[u]===l[u-2]&&l[u-1]===l[u-3]&&l.splice(u-1,2);return this.poly(l,!0,a)}ellipse(t,e,i,r,n){return this.drawShape(new lr(t,e,i,r),n),this}roundRect(t,e,i,r,n,a){return this.drawShape(new ur(t,e,i,r,n),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new Qe,i.points.push(t,e),this._currentPoly=i,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new Qe,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,r=e.shape.y;if(!e.transform.isIdentity()){const n=e.transform,a=i;i=n.a*i+n.c*r+n.tx,r=n.b*a+n.d*r+n.ty}this._currentPoly.points.push(i,r)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const i=t.instructions[e];this[i.action](...i.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let i=0;i<e.length;i++){const r=e[i],n=r.shape.getBounds(Ef);r.transform?t.addRect(n,r.transform):t.addRect(n)}return t}}class Ge{constructor(t){this.instructions=[],this.uid=et("graphicsPath"),this._dirty=!0,typeof t=="string"?$d(t,this):this.instructions=(t==null?void 0:t.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new Mf(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,i,r,n){const a=this.instructions[this.instructions.length-1],o=this.getLastPoint(X.shared);let h=0,c=0;if(!a||a.action!=="bezierCurveTo")h=o.x,c=o.y;else{h=a.data[2],c=a.data[3];const l=o.x,u=o.y;h=l+(l-h),c=u+(u-c)}return this.instructions.push({action:"bezierCurveTo",data:[h,c,t,e,i,r,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,i){const r=this.instructions[this.instructions.length-1],n=this.getLastPoint(X.shared);let a=0,o=0;if(!r||r.action!=="quadraticCurveTo")a=n.x,o=n.y;else{a=r.data[0],o=r.data[1];const h=n.x,c=n.y;a=h+(h-a),o=c+(c-o)}return this.instructions.push({action:"quadraticCurveTo",data:[a,o,t,e,i]}),this._dirty=!0,this}rect(t,e,i,r,n){return this.instructions.push({action:"rect",data:[t,e,i,r,n]}),this._dirty=!0,this}circle(t,e,i,r){return this.instructions.push({action:"circle",data:[t,e,i,r]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,i,r,n,a,o){n=n||r/2;const h=-1*Math.PI/2+a,c=i*2,l=Math.PI*2/c,u=[];for(let d=0;d<c;d++){const f=d%2?n:r,p=d*l+h;u.push(t+f*Math.cos(p),e+f*Math.sin(p))}return this.poly(u,!0,o),this}clone(t=!1){const e=new Ge;if(!t)e.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const r=this.instructions[i];e.instructions.push({action:r.action,data:r.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,i=t.b,r=t.c,n=t.d,a=t.tx,o=t.ty;let h=0,c=0,l=0,u=0,d=0,f=0,p=0,g=0;for(let m=0;m<this.instructions.length;m++){const _=this.instructions[m],x=_.data;switch(_.action){case"moveTo":case"lineTo":h=x[0],c=x[1],x[0]=e*h+r*c+a,x[1]=i*h+n*c+o;break;case"bezierCurveTo":l=x[0],u=x[1],d=x[2],f=x[3],h=x[4],c=x[5],x[0]=e*l+r*u+a,x[1]=i*l+n*u+o,x[2]=e*d+r*f+a,x[3]=i*d+n*f+o,x[4]=e*h+r*c+a,x[5]=i*h+n*c+o;break;case"quadraticCurveTo":l=x[0],u=x[1],h=x[2],c=x[3],x[0]=e*l+r*u+a,x[1]=i*l+n*u+o,x[2]=e*h+r*c+a,x[3]=i*h+n*c+o;break;case"arcToSvg":h=x[5],c=x[6],p=x[0],g=x[1],x[0]=e*p+r*g,x[1]=i*p+n*g,x[5]=e*h+r*c+a,x[6]=i*h+n*c+o;break;case"circle":x[4]=ss(x[3],t);break;case"rect":x[4]=ss(x[4],t);break;case"ellipse":x[8]=ss(x[8],t);break;case"roundRect":x[5]=ss(x[5],t);break;case"addPath":x[0].transform(t);break;case"poly":x[2]=ss(x[2],t);break;default:D("unknown transform action",_.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,i=this.instructions[e];if(!i)return t.x=0,t.y=0,t;for(;i.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;i=this.instructions[e]}switch(i.action){case"moveTo":case"lineTo":t.x=i.data[0],t.y=i.data[1];break;case"quadraticCurveTo":t.x=i.data[2],t.y=i.data[3];break;case"bezierCurveTo":t.x=i.data[4],t.y=i.data[5];break;case"arc":case"arcToSvg":t.x=i.data[5],t.y=i.data[6];break;case"addPath":i.data[0].getLastPoint(t);break}return t}}function ss(s,t){return s?s.prepend(t):t.clone()}function Bf(s,t){if(typeof s=="string"){const i=document.createElement("div");i.innerHTML=s.trim(),s=i.querySelector("svg")}const e={context:t,path:new Ge};return oo(s,e,null,null),t}function oo(s,t,e,i){const r=s.children,{fillStyle:n,strokeStyle:a}=Rf(s);n&&e?e={...e,...n}:n&&(e=n),a&&i?i={...i,...a}:a&&(i=a),t.context.fillStyle=e,t.context.strokeStyle=i;let o,h,c,l,u,d,f,p,g,m,_,x,y,v,w,E,C;switch(s.nodeName.toLowerCase()){case"path":v=s.getAttribute("d"),w=new Ge(v),t.context.path(w),e&&t.context.fill(),i&&t.context.stroke();break;case"circle":f=ct(s,"cx",0),p=ct(s,"cy",0),g=ct(s,"r",0),t.context.ellipse(f,p,g,g),e&&t.context.fill(),i&&t.context.stroke();break;case"rect":o=ct(s,"x",0),h=ct(s,"y",0),E=ct(s,"width",0),C=ct(s,"height",0),m=ct(s,"rx",0),_=ct(s,"ry",0),m||_?t.context.roundRect(o,h,E,C,m||_):t.context.rect(o,h,E,C),e&&t.context.fill(),i&&t.context.stroke();break;case"ellipse":f=ct(s,"cx",0),p=ct(s,"cy",0),m=ct(s,"rx",0),_=ct(s,"ry",0),t.context.beginPath(),t.context.ellipse(f,p,m,_),e&&t.context.fill(),i&&t.context.stroke();break;case"line":c=ct(s,"x1",0),l=ct(s,"y1",0),u=ct(s,"x2",0),d=ct(s,"y2",0),t.context.beginPath(),t.context.moveTo(c,l),t.context.lineTo(u,d),i&&t.context.stroke();break;case"polygon":y=s.getAttribute("points"),x=y.match(/\d+/g).map(P=>parseInt(P,10)),t.context.poly(x,!0),e&&t.context.fill(),i&&t.context.stroke();break;case"polyline":y=s.getAttribute("points"),x=y.match(/\d+/g).map(P=>parseInt(P,10)),t.context.poly(x,!1),i&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}for(let P=0;P<r.length;P++)oo(r[P],t,e,i)}function ct(s,t,e){const i=s.getAttribute(t);return i?Number(i):e}function Rf(s){const t=s.getAttribute("style"),e={},i={};let r=!1,n=!1;if(t){const a=t.split(";");for(let o=0;o<a.length;o++){const h=a[o],[c,l]=h.split(":");switch(c){case"stroke":l!=="none"&&(e.color=j.shared.setValue(l).toNumber(),n=!0);break;case"stroke-width":e.width=Number(l);break;case"fill":l!=="none"&&(r=!0,i.color=j.shared.setValue(l).toNumber());break;case"fill-opacity":i.alpha=Number(l);break;case"stroke-opacity":e.alpha=Number(l);break;case"opacity":i.alpha=Number(l),e.alpha=Number(l);break}}}else{const a=s.getAttribute("stroke");a&&a!=="none"&&(n=!0,e.color=j.shared.setValue(a).toNumber(),e.width=ct(s,"stroke-width",1));const o=s.getAttribute("fill");o&&o!=="none"&&(r=!0,i.color=j.shared.setValue(o).toNumber())}return{strokeStyle:n?e:null,fillStyle:r?i:null}}const ho=class vn{constructor(t,e,i,r){this.uid=et("fillGradient"),this.type="linear",this.gradientStops=[],this.x0=t,this.y0=e,this.x1=i,this.y1=r}addColorStop(t,e){return this.gradientStops.push({offset:t,color:j.shared.setValue(e).toHex()}),this}buildLinearGradient(){const t=vn.defaultTextureSize,{gradientStops:e}=this,i=L.get().createCanvas();i.width=t,i.height=t;const r=i.getContext("2d"),n=r.createLinearGradient(0,0,vn.defaultTextureSize,1);for(let g=0;g<e.length;g++){const m=e[g];n.addColorStop(m.offset,m.color)}r.fillStyle=n,r.fillRect(0,0,t,t),this.texture=new M({source:new Ce({resource:i,addressModeU:"clamp-to-edge",addressModeV:"repeat"})});const{x0:a,y0:o,x1:h,y1:c}=this,l=new I,u=h-a,d=c-o,f=Math.sqrt(u*u+d*d),p=Math.atan2(d,u);l.translate(-a,-o),l.scale(1/t,1/t),l.rotate(-p),l.scale(256/f,1),this.transform=l}};ho.defaultTextureSize=256;let Tr=ho;const co={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class lo{constructor(t,e){this.uid=et("fillPattern"),this.transform=new I,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=co[e].addressModeU,t.source.style.addressModeV=co[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height)}}function ee(s,t){var a;if(s==null)return null;let e,i;if(s!=null&&s.fill?(i=s.fill,e={...t,...s}):(i=s,e=t),j.isColorLike(i)){const o=j.shared.setValue(i??0);return{...e,color:o.toNumber(),alpha:o.alpha===1?e.alpha:o.alpha,texture:M.WHITE}}else if(i instanceof lo){const o=i;return{...e,color:16777215,texture:o.texture,matrix:o.transform,fill:e.fill??null}}else if(i instanceof Tr){const o=i;return o.buildLinearGradient(),{...e,color:16777215,texture:o.texture,matrix:o.transform}}const r={...t,...s};if(r.texture){if(r.texture!==M.WHITE){const h=((a=r.matrix)==null?void 0:a.invert())||new I;h.scale(1/r.texture.frame.width,1/r.texture.frame.height),r.matrix=h}const o=r.texture.source.style;o.addressMode==="clamp-to-edge"&&(o.addressMode="repeat")}const n=j.shared.setValue(r.color);return r.alpha*=n.alpha,r.color=n.toNumber(),r.matrix=r.matrix?r.matrix.clone():null,r}const kf=new X,uo=new I,Ar=class zt extends _t{constructor(){super(...arguments),this.uid=et("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new Ge,this._transform=new I,this._fillStyle={...zt.defaultFillStyle},this._strokeStyle={...zt.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new mt,this._boundsDirty=!0}clone(){const t=new zt;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...this._strokeStyle},t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=ee(t,zt.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=ee(t,zt.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=ee(t,zt.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=ee(t,zt.defaultStrokeStyle),this}texture(t,e,i,r,n,a){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:r||0,dw:n||t.frame.width,dh:a||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?j.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Ge,this}fill(t,e){let i;const r=this.instructions[this.instructions.length-1];return this._tick===0&&r&&r.action==="stroke"?i=r.data.path:i=this._activePath.clone(),i?(t!=null&&(e!==void 0&&typeof t=="number"&&(N(W,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=ee(t,zt.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(X.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const i=this.instructions[this.instructions.length-1];return this._tick===0&&i&&i.action==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=ee(t,zt.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(i);else{e.data.hole=i;break}}return this._initNextPathLocation(),this}arc(t,e,i,r,n,a){this._tick++;const o=this._transform;return this._activePath.arc(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,i,r,n,a),this}arcTo(t,e,i,r,n){this._tick++;const a=this._transform;return this._activePath.arcTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*i+a.c*r+a.tx,a.b*i+a.d*r+a.ty,n),this}arcToSvg(t,e,i,r,n,a,o){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,i,r,n,h.a*a+h.c*o+h.tx,h.b*a+h.d*o+h.ty),this}bezierCurveTo(t,e,i,r,n,a,o){this._tick++;const h=this._transform;return this._activePath.bezierCurveTo(h.a*t+h.c*e+h.tx,h.b*t+h.d*e+h.ty,h.a*i+h.c*r+h.tx,h.b*i+h.d*r+h.ty,h.a*n+h.c*a+h.tx,h.b*n+h.d*a+h.ty,o),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,i,r){return this._tick++,this._activePath.ellipse(t,e,i,r,this._transform.clone()),this}circle(t,e,i){return this._tick++,this._activePath.circle(t,e,i,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*t+i.c*e+i.tx,i.b*t+i.d*e+i.ty),this}moveTo(t,e){this._tick++;const i=this._transform,r=this._activePath.instructions,n=i.a*t+i.c*e+i.tx,a=i.b*t+i.d*e+i.ty;return r.length===1&&r[0].action==="moveTo"?(r[0].data[0]=n,r[0].data[1]=a,this):(this._activePath.moveTo(n,a),this)}quadraticCurveTo(t,e,i,r,n){this._tick++;const a=this._transform;return this._activePath.quadraticCurveTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*i+a.c*r+a.tx,a.b*i+a.d*r+a.ty,n),this}rect(t,e,i,r){return this._tick++,this._activePath.rect(t,e,i,r,this._transform.clone()),this}roundRect(t,e,i,r,n){return this._tick++,this._activePath.roundRect(t,e,i,r,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,r,n=0,a){return this._tick++,this._activePath.regularPoly(t,e,i,r,n,a),this}roundPoly(t,e,i,r,n,a){return this._tick++,this._activePath.roundPoly(t,e,i,r,n,a),this}roundShape(t,e,i,r){return this._tick++,this._activePath.roundShape(t,e,i,r),this}filletRect(t,e,i,r,n){return this._tick++,this._activePath.filletRect(t,e,i,r,n),this}chamferRect(t,e,i,r,n,a){return this._tick++,this._activePath.chamferRect(t,e,i,r,n,a),this}star(t,e,i,r,n=0,a=0){return this._tick++,this._activePath.star(t,e,i,r,n,a,this._transform.clone()),this}svg(t){return this._tick++,Bf(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,i,r,n,a){return t instanceof I?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,r,n,a),this)}transform(t,e,i,r,n,a){return t instanceof I?(this._transform.append(t),this):(uo.set(t,e,i,r,n,a),this._transform.append(uo),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const i=this.instructions[e],r=i.action;if(r==="fill"){const n=i.data;t.addBounds(n.path.bounds)}else if(r==="texture"){const n=i.data;t.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(r==="stroke"){const n=i.data,a=n.style.width/2,o=n.path.bounds;t.addFrame(o.minX-a,o.minY-a,o.maxX+a,o.maxY+a)}}return t}containsPoint(t){var r;if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let i=!1;for(let n=0;n<e.length;n++){const a=e[n],o=a.data,h=o.path;if(!a.action||!h)continue;const c=o.style,l=h.shapePath.shapePrimitives;for(let u=0;u<l.length;u++){const d=l[u].shape;if(!c||!d)continue;const f=l[u].transform,p=f?f.applyInverse(t,kf):t;a.action==="fill"?i=d.contains(p.x,p.y):i=d.strokeContains(p.x,p.y,c.width);const g=o.hole;if(g){const m=(r=g.shapePath)==null?void 0:r.shapePrimitives;if(m)for(let _=0;_<m.length;_++)m[_].shape.contains(p.x,p.y)&&(i=!1)}if(i)return!0}}return i}destroy(t=!1){if(this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._fillStyle.texture&&this._fillStyle.texture.destroy(i),this._strokeStyle.texture&&this._strokeStyle.texture.destroy(i)}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Ar.defaultFillStyle={color:16777215,alpha:1,texture:M.WHITE,matrix:null,fill:null},Ar.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:M.WHITE,matrix:null,fill:null};let se=Ar;function Pr(s,t=1){var i;const e=(i=Ee.RETINA_PREFIX)==null?void 0:i.exec(s);return e?parseFloat(e[1]):t}function Cr(s,t,e){s.label=e,s._sourceOrigin=e;const i=new M({source:s,label:e}),r=()=>{delete t.promiseCache[e],K.has(e)&&K.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&(D("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),r())}),i.once("destroy",()=>{s.destroyed||(D("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),i}const If=".svg",Ff="image/svg+xml",Gf={extension:{type:b.LoadParser,priority:te.Low},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(s){return Ie(s,Ff)||Fe(s,If)},async load(s,t,e){return t.data.parseAsGraphicsContext??this.config.parseAsGraphicsContext?Df(s):Uf(s,t,e,this.config.crossOrigin)},unload(s){s.destroy(!0)}};async function Uf(s,t,e,i){var m,_,x;const n=await(await L.get().fetch(s)).blob(),a=URL.createObjectURL(n),o=new Image;o.src=a,o.crossOrigin=i,await o.decode(),URL.revokeObjectURL(a);const h=document.createElement("canvas"),c=h.getContext("2d"),l=((m=t.data)==null?void 0:m.resolution)||Pr(s),u=((_=t.data)==null?void 0:_.width)??o.width,d=((x=t.data)==null?void 0:x.height)??o.height;h.width=u*l,h.height=d*l,c.drawImage(o,0,0,u*l,d*l);const{parseAsGraphicsContext:f,...p}=t.data,g=new Ce({resource:h,alphaMode:"premultiply-alpha-on-upload",resolution:l,...p});return Cr(g,e,s)}async function Df(s){const e=await(await L.get().fetch(s)).text(),i=new se;return i.svg(e),i}const Of=`(function () {
|
|
26
|
+
'use strict';
|
|
27
|
+
|
|
28
|
+
const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
|
|
29
|
+
async function checkImageBitmap() {
|
|
30
|
+
try {
|
|
31
|
+
if (typeof createImageBitmap !== "function")
|
|
32
|
+
return false;
|
|
33
|
+
const response = await fetch(WHITE_PNG);
|
|
34
|
+
const imageBlob = await response.blob();
|
|
35
|
+
const imageBitmap = await createImageBitmap(imageBlob);
|
|
36
|
+
return imageBitmap.width === 1 && imageBitmap.height === 1;
|
|
37
|
+
} catch (e) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
void checkImageBitmap().then((result) => {
|
|
42
|
+
self.postMessage(result);
|
|
43
|
+
});
|
|
357
44
|
|
|
358
|
-
|
|
359
|
-
|
|
45
|
+
})();
|
|
46
|
+
`;let Ue=null,Er=class{constructor(){Ue||(Ue=URL.createObjectURL(new Blob([Of],{type:"application/javascript"}))),this.worker=new Worker(Ue)}};Er.revokeObjectURL=function(){Ue&&(URL.revokeObjectURL(Ue),Ue=null)};const Lf=`(function () {
|
|
47
|
+
'use strict';
|
|
48
|
+
|
|
49
|
+
async function loadImageBitmap(url) {
|
|
50
|
+
const response = await fetch(url);
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`);
|
|
53
|
+
}
|
|
54
|
+
const imageBlob = await response.blob();
|
|
55
|
+
const imageBitmap = await createImageBitmap(imageBlob);
|
|
56
|
+
return imageBitmap;
|
|
57
|
+
}
|
|
58
|
+
self.onmessage = async (event) => {
|
|
59
|
+
try {
|
|
60
|
+
const imageBitmap = await loadImageBitmap(event.data.data[0]);
|
|
61
|
+
self.postMessage({
|
|
62
|
+
data: imageBitmap,
|
|
63
|
+
uuid: event.data.uuid,
|
|
64
|
+
id: event.data.id
|
|
65
|
+
}, [imageBitmap]);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
self.postMessage({
|
|
68
|
+
error: e,
|
|
69
|
+
uuid: event.data.uuid,
|
|
70
|
+
id: event.data.id
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
360
74
|
|
|
361
|
-
|
|
362
|
-
{
|
|
363
|
-
|
|
75
|
+
})();
|
|
76
|
+
`;let De=null;class fo{constructor(){De||(De=URL.createObjectURL(new Blob([Lf],{type:"application/javascript"}))),this.worker=new Worker(De)}}fo.revokeObjectURL=function(){De&&(URL.revokeObjectURL(De),De=null)};let po=0,Mr;class Hf{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new Er;e.addEventListener("message",i=>{e.terminate(),Er.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Mr===void 0&&(Mr=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<Mr&&(this._createdWorkers++,t=new fo().worker,t.addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((r,n)=>{this._queue.push({id:t,arguments:e,resolve:r,reject:n})});return this._next(),i}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),i=e.id;this._resolveHash[po]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:po++,id:i})}}const mo=new Hf,Nf=[".jpeg",".jpg",".png",".webp",".avif"],zf=["image/jpeg","image/png","image/webp","image/avif"];async function Wf(s){const t=await L.get().fetch(s);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const go={name:"loadTextures",extension:{type:b.LoadParser,priority:te.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return Ie(s,zf)||Fe(s,Nf)},async load(s,t,e){var n;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await mo.isImageBitmapSupported()?i=await mo.loadImageBitmap(s):i=await Wf(s):i=await new Promise(a=>{i=new Image,i.crossOrigin=this.config.crossOrigin,i.src=s,i.complete?a(i):i.onload=()=>{a(i)}});const r=new Ce({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((n=t.data)==null?void 0:n.resolution)||Pr(s),...t.data});return Cr(r,e,s)},unload(s){s.destroy(!0)}},_o=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],Vf=_o.map(s=>`video/${s.substring(1)}`);function jf(s,t,e){e===void 0&&!t.startsWith("data:")?s.crossOrigin=Xf(t):e!==!1&&(s.crossOrigin=typeof e=="string"?e:"anonymous")}function $f(s){return new Promise((t,e)=>{s.addEventListener("canplaythrough",i),s.addEventListener("error",r),s.load();function i(){n(),t()}function r(a){n(),e(a)}function n(){s.removeEventListener("canplaythrough",i),s.removeEventListener("error",r)}})}function Xf(s,t=globalThis.location){if(s.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(s,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const Yf={name:"loadVideo",extension:{type:b.LoadParser},config:null,test(s){const t=Ie(s,Vf),e=Fe(s,_o);return t||e},async load(s,t,e){var h,c;const i={...Is.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||Pr(s),alphaMode:((c=t.data)==null?void 0:c.alphaMode)||await aa(),...t.data},r=document.createElement("video"),n={preload:i.autoLoad!==!1?"auto":void 0,"webkit-playsinline":i.playsinline!==!1?"":void 0,playsinline:i.playsinline!==!1?"":void 0,muted:i.muted===!0?"":void 0,loop:i.loop===!0?"":void 0,autoplay:i.autoPlay!==!1?"":void 0};Object.keys(n).forEach(l=>{const u=n[l];u!==void 0&&r.setAttribute(l,u)}),i.muted===!0&&(r.muted=!0),jf(r,s,i.crossorigin);const a=document.createElement("source");let o;if(s.startsWith("data:"))o=s.slice(5,s.indexOf(";"));else if(!s.startsWith("blob:")){const l=s.split("?")[0].slice(s.lastIndexOf(".")+1).toLowerCase();o=Is.MIME_TYPES[l]||`video/${l}`}return a.src=s,o&&(a.type=o),new Promise(l=>{const u=async()=>{const d=new Is({...i,resource:r});r.removeEventListener("canplay",u),t.data.preload&&await $f(r),l(Cr(d,e,s))};r.addEventListener("canplay",u),r.appendChild(a)})},unload(s){s.destroy(!0)}},xo={extension:b.ResolveParser,test:go.test,parse:s=>{var t;return{resolution:parseFloat(((t=Ee.RETINA_PREFIX.exec(s))==null?void 0:t[1])??"1"),format:s.split(".").pop(),src:s}}},Kf={extension:b.ResolveParser,test:s=>Ee.RETINA_PREFIX.test(s)&&s.endsWith(".json"),parse:xo.parse};class qf{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Ee,this.loader=new Ad,this.cache=K,this._backgroundLoader=new gd(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,a;if(this._initialized){D("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let o=t.manifest;typeof o=="string"&&(o=await this.load(o)),this.resolver.addManifest(o)}const e=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,r=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:r,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=Fs(t),r=Bt(t).map(o=>{if(typeof o!="string"){const h=this.resolver.getAlias(o);return h.some(c=>!this.resolver.hasKey(c))&&this.add(o),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),n=this.resolver.resolve(r),a=await this._mapLoadToResolve(n,e);return i?a[r[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const r=this.resolver.resolveBundle(t),n={},a=Object.keys(r);let o=0,h=0;const c=()=>{e==null||e(++o/h)},l=a.map(u=>{const d=r[u];return h+=Object.keys(d).length,this._mapLoadToResolve(d,c).then(f=>{n[u]=f})});return await Promise.all(l),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return K.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=K.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const r=await this.loader.load(i,e);this._backgroundLoader.active=!0;const n={};return i.forEach(a=>{const o=r[a.src],h=[a.src];a.alias&&h.push(...a.alias),h.forEach(c=>{n[c]=o}),K.set(h,o)}),n}async unload(t){this._initialized||await this.init();const e=Bt(t).map(r=>typeof r!="string"?r.src:r),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=Bt(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{K.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,r)=>e.indexOf(i)===r),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const ft=new qf;O.handleByList(b.LoadParser,ft.loader.parsers).handleByList(b.ResolveParser,ft.resolver.parsers).handleByList(b.CacheParser,ft.cache.parsers).handleByList(b.DetectionParser,ft.detections),O.add(_d,yd,xd,Td,vd,Sd,wd,Ed,Rd,Ld,Gf,go,Yf,xo,Kf);const yo={loader:b.LoadParser,resolver:b.ResolveParser,cache:b.CacheParser,detection:b.DetectionParser};O.handle(b.Asset,s=>{const t=s.ref;Object.entries(yo).filter(([e])=>!!t[e]).forEach(([e,i])=>O.add(Object.assign(t[e],{extension:t[e].extension??i})))},s=>{const t=s.ref;Object.keys(yo).filter(e=>!!t[e]).forEach(e=>O.remove(t[e]))});class Zf{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||(ot.system.add(this._tickerUpdate,this,de.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(ot.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this._update())}}const ie=new Zf;class qs extends je{constructor(){super(...arguments),this.client=new X,this.movement=new X,this.offset=new X,this.global=new X,this.screen=new X}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,r,n,a,o,h,c,l,u,d,f,p,g){throw new Error("Method not implemented.")}}class It extends qs{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Oe extends qs{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Oe.DOM_DELTA_PIXEL=0,Oe.DOM_DELTA_LINE=1,Oe.DOM_DELTA_PAGE=2;const Jf=2048,Qf=new X,is=new X;class tp{constructor(t){this.dispatch=new _t,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,r)=>i.priority-r.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,r=e.length;i<r;i++)e[i].fn(t);else D(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){ie.pauseUpdate=!0;const r=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[r](this.rootTarget,this.rootTarget.eventMode,Qf.set(t,e),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let r=0,n=i.length-1;r<n;r++)if(t.currentTarget=i[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let r=i.length-2;r>=0;r--)if(t.currentTarget=i[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const r=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)r.forEach(a=>{t.currentTarget=i[n],this.notifyTarget(t,a)})}propagationPath(t){const e=[t];for(let i=0;i<Jf&&t!==this.rootTarget&&t.parent;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,r,n,a=!1){let o=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(ie.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children;for(let u=l.length-1;u>=0;u--){const d=l[u],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,r,n,a||n(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=t.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),o=!0}}}const h=this._isInteractive(e),c=t.isInteractive();return c&&c&&this._allInteractiveElements.push(t),a||this._hitElements.length>0?null:o?this._hitElements:h&&!n(t,i)&&r(t,i)?c?[t]:[]:null}hitTestRecursive(t,e,i,r,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(ie.pauseUpdate=!1),t.interactiveChildren&&t.children){const h=t.children,c=i;for(let l=h.length-1;l>=0;l--){const u=h[l],d=this.hitTestRecursive(u,this._isInteractive(e)?e:u.eventMode,c,r,n);if(d){if(d.length>0&&!d[d.length-1].parent)continue;const f=t.isInteractive();return(d.length>0||f)&&d.push(t),d}}}const a=this._isInteractive(e),o=t.isInteractive();return a&&r(t,i)?o?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!t||!t.visible||!t.renderable||!t.includeInBuild||!t.measurable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,is),!t.hitArea.contains(is.x,is.y)))return!0;if(t.effects&&t.effects.length)for(let i=0;i<t.effects.length;i++){const r=t.effects[i];if(r.containsPoint&&!r.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return t.hitArea?!0:t!=null&&t.containsPoint?(t.worldTransform.applyInverse(e,is),t.containsPoint(is)):!1}notifyTarget(t,e){var n,a;e=e??t.type;const i=`on${e}`;(a=(n=t.currentTarget)[i])==null||a.call(n,t);const r=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,r),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof It)){D("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const r=e.button===2;this.dispatchEvent(e,r?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var h,c;if(!(t instanceof It)){D("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=e.pointerType==="mouse"||e.pointerType==="pen",r=this.trackingData(t.pointerId),n=this.findMountedTarget(r.overTargets);if(((h=r.overTargets)==null?void 0:h.length)>0&&n!==e.target){const l=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,l,n);if(this.dispatchEvent(u,"pointerout"),i&&this.dispatchEvent(u,"mouseout"),!e.composedPath().includes(n)){const d=this.createPointerEvent(t,"pointerleave",n);for(d.eventPhase=d.AT_TARGET;d.target&&!e.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),i&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(u)}if(n!==e.target){const l=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(e,l);this.dispatchEvent(u,"pointerover"),i&&this.dispatchEvent(u,"mouseover");let d=n==null?void 0:n.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const p=this.clonePointerEvent(e,"pointerenter");for(p.eventPhase=p.AT_TARGET;p.target&&p.target!==n&&p.target!==this.rootTarget.parent;)p.currentTarget=p.target,this.notifyTarget(p),i&&this.notifyTarget(p,"mouseenter"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(u)}const a=[],o=this.enableGlobalMoveEvents??!0;this.moveOnAll?a.push("pointermove"):this.dispatchEvent(e,"pointermove"),o&&a.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?a.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),o&&a.push("globaltouchmove")),i&&(this.moveOnAll?a.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),o&&a.push("globalmousemove"),this.cursor=(c=e.target)==null?void 0:c.cursor),a.length>0&&this.all(e,a),this._allInteractiveElements.length=0,this._hitElements.length=0,r.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var a;if(!(t instanceof It)){D("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),r=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),r&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(a=i.target)==null?void 0:a.cursor);const n=this.clonePointerEvent(i,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),r&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof It)){D("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",r=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",r);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const a=this.createPointerEvent(t,"pointerleave",r);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),i&&this.notifyTarget(a,"mouseleave"),a.target=a.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(a)}this.cursor=null}mapPointerUp(t){if(!(t instanceof It)){D("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const o=i.button===2;this.dispatchEvent(i,o?"rightup":"mouseup")}const r=this.trackingData(t.pointerId),n=this.findMountedTarget(r.pressTargetsByButton[t.button]);let a=n;if(n&&!i.composedPath().includes(n)){let o=n;for(;o&&!i.composedPath().includes(o);){if(i.currentTarget=o,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const h=i.button===2;this.notifyTarget(i,h?"rightupoutside":"mouseupoutside")}o=o.parent}delete r.pressTargetsByButton[t.button],a=o}if(a){const o=this.clonePointerEvent(i,"click");o.target=a,o.path=null,r.clicksByButton[t.button]||(r.clicksByButton[t.button]={clickCount:0,target:o.target,timeStamp:e});const h=r.clicksByButton[t.button];if(h.target===o.target&&e-h.timeStamp<200?++h.clickCount:h.clickCount=1,h.target=o.target,h.timeStamp=e,o.detail=h.clickCount,o.pointerType==="mouse"){const c=o.button===2;this.dispatchEvent(o,c?"rightclick":"click")}else o.pointerType==="touch"&&this.dispatchEvent(o,"tap");this.dispatchEvent(o,"pointertap"),this.freeEvent(o)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof It)){D("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),r=this.createPointerEvent(t);if(i){let n=i;for(;n;)r.currentTarget=n,this.notifyTarget(r,"pointerupoutside"),r.pointerType==="touch"?this.notifyTarget(r,"touchendoutside"):(r.pointerType==="mouse"||r.pointerType==="pen")&&this.notifyTarget(r,r.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(r)}mapWheel(t){if(!(t instanceof Oe)){D("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const r=this.allocateEvent(It);return this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=i??this.hitTest(r.global.x,r.global.y)??this._hitElements[0],typeof e=="string"&&(r.type=e),r}createWheelEvent(t){const e=this.allocateEvent(Oe);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(It);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof It&&e instanceof It&&(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 qs&&e instanceof qs&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}_notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let r=0,n=i.length;r<n&&!t.propagationImmediatelyStopped;r++)i[r].once&&t.currentTarget.removeListener(e,i[r].fn,void 0,!0),i[r].fn.call(i[r].context,t)}}const ep=1,sp={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Br=class Sn{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new tp(null),ie.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new It(null),this._rootWheelEvent=new Oe(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Sn.defaultEventFeatures},{set:(e,i,r)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=r),e[i]=r,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{canvas:e,resolution:i}=this.renderer;this.setTargetElement(e),this.resolution=i,Sn._defaultEventMode=t.eventMode??"passive",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this._currentCursor===t)return;this._currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,r=e.length;i<r;i++){const n=e[i],a=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,ie.pointerMoved();const e=this._normalizeToPointerData(t);for(let i=0,r=e.length;i<r;i++){const n=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",r=this._normalizeToPointerData(t);for(let n=0,a=r.length;n<a;n++){const o=this._bootstrapEvent(this._rootPointerEvent,r[n]);o.type+=i,this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);for(let i=0,r=e.length;i<r;i++){const n=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this._removeEvents(),this.domElement=t,ie.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;ie.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;ie.removeTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(t,e,i){const r=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-r.left)*(this.domElement.width/r.width)*n,t.y=(i-r.top)*(this.domElement.height/r.height)*n}_normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,r=t.changedTouches.length;i<r;i++){const n=t.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=ep),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}else e.push(t);return e}normalizeWheelEvent(t){const e=this._rootWheelEvent;return this._transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}_bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this._transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=sp[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}};Br.extension={name:"events",type:[b.WebGLSystem,b.CanvasSystem,b.WebGPUSystem],priority:-1},Br.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let bo=Br;const ip={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,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(s){this.eventMode=s?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??bo.defaultEventMode},set eventMode(s){this._internalEventMode=s},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(s,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,r=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,a=typeof t=="function"?void 0:t;s=i?`${s}capture`:s;const o=typeof t=="function"?t:t.handleEvent,h=this;r&&r.addEventListener("abort",()=>{h.off(s,o,a)}),n?h.once(s,o,a):h.on(s,o,a)},removeEventListener(s,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,r=typeof t=="function"?void 0:t;s=i?`${s}capture`:s,t=typeof t=="function"?t:t.handleEvent,this.off(s,t,r)},dispatchEvent(s){if(!(s instanceof je))throw new Error("Container cannot propagate events outside of the Federated Events API");return s.defaultPrevented=!1,s.path=null,s.target=this,s.manager.dispatchEvent(s),!s.defaultPrevented}};let rp=0;class np{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1}createTexture(t,e,i){const r=new ut({...this.textureOptions,width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!0});return new M({source:r,label:`texturePool_${rp++}`})}getOptimalTexture(t,e,i=1,r){let n=Math.ceil(t*i-1e-6),a=Math.ceil(e*i-1e-6);n=Te(n),a=Te(a);const o=(n<<17)+(a<<1)+(r?1:0);this._texturePool[o]||(this._texturePool[o]=[]);let h=this._texturePool[o].pop();return h||(h=this.createTexture(n,a,r)),h.source._resolution=i,h.source.width=n/i,h.source.height=a/i,h.source.pixelWidth=n,h.source.pixelHeight=a,h.frame.x=0,h.frame.y=0,h.frame.width=t,h.frame.height=e,h.updateUvs(),this._poolKeyHash[h.uid]=o,h}getSameSizeTexture(t,e=!1){const i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t){const e=this._poolKeyHash[t.uid];this._texturePool[e].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const i=this._texturePool[e];if(i)for(let r=0;r<i.length;r++)i[r].destroy(!0)}this._texturePool={}}}const Pt=new np;class vo{constructor(t){this._renderer=t}push(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){t.action==="pushFilter"?this._renderer.filter.push(t):t.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}vo.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"filter"};const ap=new I;function op(s,t){return t.clear(),So(s,t),t.isValid||t.set(0,0,0,0),s.renderGroup?t.applyMatrix(s.renderGroup.localTransform):t.applyMatrix(s.parentRenderGroup.worldTransform),t}function So(s,t){if(s.localDisplayStatus!==7||!s.measurable)return;const e=!!s.effects.length;let i=t;if((s.renderGroup||e)&&(i=$t.get().clear()),s.boundsArea)t.addRect(s.boundsArea,s.worldTransform);else{if(s.renderPipeId){const n=s.bounds;i.addFrame(n.minX,n.minY,n.maxX,n.maxY,s.groupTransform)}const r=s.children;for(let n=0;n<r.length;n++)So(r[n],i)}if(e){let r=!1;for(let n=0;n<s.effects.length;n++)s.effects[n].addBounds&&(r||(r=!0,i.applyMatrix(s.parentRenderGroup.worldTransform)),s.effects[n].addBounds(i,!0));r&&(i.applyMatrix(s.parentRenderGroup.worldTransform.copyTo(ap).invert()),t.addBounds(i,s.relativeGroupTransform)),t.addBounds(i),$t.return(i)}else s.renderGroup&&(t.addBounds(i,s.relativeGroupTransform),$t.return(i))}function hp(s,t){t.clear();const e=t.matrix;for(let i=0;i<s.length;i++){const r=s[i];r.globalDisplayStatus<7||(t.matrix=r.worldTransform,r.addBounds(t))}return t.matrix=e,t}const cp=new Xs({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),location:0,format:"float32x2",stride:2*4,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class wo{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new xt({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new Yt({}),this.renderer=t}get activeBackTexture(){var t;return(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){var f;const e=this.renderer,i=t.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());const r=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,i.length===0){r.skip=!0;return}const n=r.bounds;t.renderables?hp(t.renderables,n):t.filterEffect.filterArea?(n.clear(),n.addRect(t.filterEffect.filterArea),n.applyMatrix(t.container.worldTransform)):op(t.container,n);const a=e.renderTarget.rootRenderTarget.colorTexture.source;let o=a._resolution,h=0,c=a.antialias,l=!1,u=!1;for(let p=0;p<i.length;p++){const g=i[p];if(o=Math.min(o,g.resolution),h+=g.padding,g.antialias!=="inherit"&&(g.antialias==="on"?c=!0:c=!1),!!!(g.compatibleRenderers&e.type)){u=!1;break}if(g.blendRequired&&!(((f=e.backBuffer)==null?void 0:f.useBackBuffer)??!0)){D("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),u=!1;break}u=g.enabled||u,l=l||g.blendRequired}if(!u){r.skip=!0;return}const d=e.renderTarget.rootViewPort;if(n.scale(o).fitBounds(0,d.width,0,d.height).scale(1/o).pad(h).ceil(),!n.isPositive){r.skip=!0;return}r.skip=!1,r.bounds=n,r.blendRequired=l,r.container=t.container,r.filterEffect=t.filterEffect,r.previousRenderSurface=e.renderTarget.renderSurface,r.inputTexture=Pt.getOptimalTexture(n.width,n.height,o,c),e.renderTarget.bind(r.inputTexture,!0),e.globalUniforms.push({offset:n})}pop(){const t=this.renderer;this._filterStackIndex--;const e=this._filterStack[this._filterStackIndex];if(e.skip)return;this._activeFilterData=e;const i=e.inputTexture,r=e.bounds;let n=M.EMPTY;if(t.renderTarget.finishRenderPass(),e.blendRequired){const o=this._filterStackIndex>0?this._filterStack[this._filterStackIndex-1].bounds:null,h=t.renderTarget.getRenderTarget(e.previousRenderSurface);n=this.getBackTexture(h,r,o)}e.backTexture=n;const a=e.filterEffect.filters;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(n.source,3),t.globalUniforms.pop(),a.length===1)a[0].apply(this,i,e.previousRenderSurface,!1),Pt.returnTexture(i);else{let o=e.inputTexture,h=Pt.getOptimalTexture(r.width,r.height,o.source._resolution,!1),c=0;for(c=0;c<a.length-1;++c){a[c].apply(this,o,h,!0);const u=o;o=h,h=u}a[c].apply(this,o,e.previousRenderSurface,!1),Pt.returnTexture(o),Pt.returnTexture(h)}e.blendRequired&&Pt.returnTexture(n)}getBackTexture(t,e,i){const r=t.colorTexture.source._resolution,n=Pt.getOptimalTexture(e.width,e.height,r,!1);let a=e.minX,o=e.minY;i&&(a-=i.minX,o-=i.minY),a=Math.floor(a*r),o=Math.floor(o*r);const h=Math.ceil(e.width*r),c=Math.ceil(e.height*r);return this.renderer.renderTarget.copyToTexture(t,n,{x:a,y:o},{width:h,height:c},{x:0,y:0}),n}applyFilter(t,e,i,r){const n=this.renderer,a=this._filterStack[this._filterStackIndex],o=a.bounds,h=X.shared,l=a.previousRenderSurface===i;let u=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,d=this._filterStackIndex-1;for(;d>0&&this._filterStack[d].skip;)--d;d>0&&(u=this._filterStack[d].inputTexture.source._resolution);const f=this._filterGlobalUniforms,p=f.uniforms,g=p.uOutputFrame,m=p.uInputSize,_=p.uInputPixel,x=p.uInputClamp,y=p.uGlobalFrame,v=p.uOutputTexture;if(l){let C=this._filterStackIndex;for(;C>0;){C--;const P=this._filterStack[this._filterStackIndex-1];if(!P.skip){h.x=P.bounds.minX,h.y=P.bounds.minY;break}}g[0]=o.minX-h.x,g[1]=o.minY-h.y}else g[0]=0,g[1]=0;g[2]=e.frame.width,g[3]=e.frame.height,m[0]=e.source.width,m[1]=e.source.height,m[2]=1/m[0],m[3]=1/m[1],_[0]=e.source.pixelWidth,_[1]=e.source.pixelHeight,_[2]=1/_[0],_[3]=1/_[1],x[0]=.5*_[2],x[1]=.5*_[3],x[2]=e.frame.width*m[2]-.5*_[2],x[3]=e.frame.height*m[3]-.5*_[3];const w=this.renderer.renderTarget.rootRenderTarget.colorTexture;y[0]=h.x*u,y[1]=h.y*u,y[2]=w.source.width*u,y[3]=w.source.height*u;const E=this.renderer.renderTarget.getRenderTarget(i);if(n.renderTarget.bind(i,!!r),i instanceof M?(v[0]=i.frame.width,v[1]=i.frame.height):(v[0]=E.width,v[1]=E.height),v[2]=E.isRoot?-1:1,f.update(),n.renderPipes.uniformBatch){const C=n.renderPipes.uniformBatch.getUboResource(f);this._globalFilterBindGroup.setResource(C,0)}else this._globalFilterBindGroup.setResource(f,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:cp,shader:t,state:t._state,topology:"triangle-list"}),n.type===Lt.WEBGL&&n.renderTarget.finishRenderPass()}_getFilterData(){return{skip:!1,inputTexture:null,bounds:new mt,container:null,filterEffect:null,blendRequired:!1,previousRenderSurface:null}}calculateSpriteMatrix(t,e){const i=this._activeFilterData,r=t.set(i.inputTexture._source.width,0,0,i.inputTexture._source.height,i.bounds.minX,i.bounds.minY),n=e.worldTransform.copyTo(I.shared);return n.invert(),r.prepend(n),r.scale(1/e.texture.frame.width,1/e.texture.frame.height),r.translate(e.anchor.x,e.anchor.y),r}}wo.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"filter"};var lp=`in vec2 vMaskCoord;
|
|
77
|
+
in vec2 vTextureCoord;
|
|
364
78
|
|
|
365
|
-
|
|
366
|
-
|
|
79
|
+
uniform sampler2D uTexture;
|
|
80
|
+
uniform sampler2D uMaskTexture;
|
|
367
81
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
return aVertexPosition * (outputFrame.zw * inputSize.zw);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
void main(void)
|
|
374
|
-
{
|
|
375
|
-
gl_Position = filterVertexPosition();
|
|
376
|
-
vTextureCoord = filterTextureCoord();
|
|
377
|
-
}
|
|
378
|
-
`;const Yn=class mr extends ce{constructor(t,e,r){const s=Ee.from(t||mr.defaultVertexSrc,e||mr.defaultFragmentSrc);super(s,r),this.padding=0,this.resolution=mr.defaultResolution,this.multisample=mr.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new le}apply(t,e,r,s,n){t.applyFilter(this,e,r,s)}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 Rp}static get defaultFragmentSrc(){return Ip}};Yn.defaultResolution=1,Yn.defaultMultisample=pt.NONE;let Bt=Yn;class Kr{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new tt(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:r,backgroundAlpha:s}=t,n=r??e;n!==void 0&&(this.color=n),this.alpha=s}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(){}}Kr.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Kr.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"background"},k.add(Kr);class Dh{constructor(t){this.renderer=t,this.emptyRenderer=new qr(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:r}=this.renderer.texture;for(let s=e-1;s>=0;--s)t[s]=r[s]||null,t[s]&&(t[s]._batchLocation=s)}boundArray(t,e,r,s){const{elements:n,ids:a,count:o}=t;let h=0;for(let l=0;l<o;l++){const c=n[l],u=c._batchLocation;if(u>=0&&u<s&&e[u]===c){a[l]=u;continue}for(;h<s;){const d=e[h];if(d&&d._batchEnabled===r&&d._batchLocation===h){h++;continue}a[l]=h,c._batchLocation=h,e[h]=c;break}}}destroy(){this.renderer=null}}Dh.extension={type:P.RendererSystem,name:"batch"},k.add(Dh);let Oh=0;class Zr{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=Oh++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,r=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:r,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=Oh++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;e.addEventListener!==void 0&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let r;if(F.PREFER_ENV>=yt.WEBGL2&&(r=t.getContext("webgl2",e)),r)this.webGLVersion=2;else if(this.webGLVersion=1,r=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!r)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=r,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),r="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;r&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=r||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=s,s||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}Zr.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},Zr.extension={type:P.RendererSystem,name:"context"},k.add(Zr);class qn{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new zt("disposeFramebuffer"),this.multisample=pt.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new W(null,{scaleMode:$t.NEAREST,resolution:1,mipmap:ee.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new W(null,{scaleMode:$t.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:ee.OFF,format:A.DEPTH_COMPONENT,type:H.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,e){if(t=Math.round(t),e=Math.round(e),!t||!e)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let r=0;r<this.colorTextures.length;r++){const s=this.colorTextures[r],n=s.resolution;s.setSize(t/n,e/n)}if(this.depthTexture){const r=this.depthTexture.resolution;this.depthTexture.setSize(t/r,e/r)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Lh extends W{constructor(t={}){if(typeof t=="number"){const e=arguments[0],r=arguments[1],s=arguments[2],n=arguments[3];t={width:e,height:r,scaleMode:s,resolution:n}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=pt.NONE),super(null,t),this.mipmap=ee.OFF,this.valid=!0,this._clear=new tt([0,0,0,0]),this.framebuffer=new qn(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e){this.framebuffer.resize(t*this.resolution,e*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class Ae extends er{constructor(t){const e=t,r=e.naturalWidth||e.videoWidth||e.displayWidth||e.width,s=e.naturalHeight||e.videoHeight||e.displayHeight||e.height;super(r,s),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,r){r===void 0&&!e.startsWith("data:")?t.crossOrigin=Jf(e):r!==!1&&(t.crossOrigin=typeof r=="string"?r:"anonymous")}upload(t,e,r,s){const n=t.gl,a=e.realWidth,o=e.realHeight;if(s=s||this.source,typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement){if(!s.complete||s.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement&&s.readyState<=1)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Ot.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&r.width===a&&r.height===o?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,r.type,s):(r.width=a,r.height=o,n.texImage2D(e.target,0,r.internalFormat,e.format,r.type,s)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,r=t.naturalHeight||t.videoHeight||t.height;this.resize(e,r),super.update()}dispose(){this.source=null}}class Nh extends Ae{constructor(t,e){if(e=e||{},typeof t=="string"){const r=new Image;Ae.crossOrigin(r,t,e.crossorigin),r.src=t,t=r}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(e.createBitmap??F.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.bitmap=null,this._load=null,e.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((e,r)=>{const s=this.source;this.url=s.src;const n=()=>{this.destroyed||(s.onload=null,s.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};s.complete&&s.src?n():(s.onload=n,s.onerror=a=>{r(a),this.onError.emit(a)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,r=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:r?"cors":"no-cors"}).then(s=>s.blob()).then(s=>e(s,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Ot.UNPACK?"premultiply":"none"})).then(s=>this.destroyed?Promise.reject():(this.bitmap=s,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,r){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,r);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,r,this.bitmap),!this.preserveBitmap){let s=!0;const n=e._glTextures;for(const a in n){const o=n[a];if(o!==r&&o.dirtyId!==e.dirtyId){s=!1;break}}s&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class Kn{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,r){const s=e.width,n=e.height;if(r){const a=t.width/2/s,o=t.height/2/n,h=t.x/s+a,l=t.y/n+o;r=ht.add(r,ht.NW),this.x0=h+a*ht.uX(r),this.y0=l+o*ht.uY(r),r=ht.add(r,2),this.x1=h+a*ht.uX(r),this.y1=l+o*ht.uY(r),r=ht.add(r,2),this.x2=h+a*ht.uX(r),this.y2=l+o*ht.uY(r),r=ht.add(r,2),this.x3=h+a*ht.uX(r),this.y3=l+o*ht.uY(r)}else this.x0=t.x/s,this.y0=t.y/n,this.x1=(t.x+t.width)/s,this.y1=t.y/n,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/n,this.x3=t.x/s,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}Kn.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const kh=new Kn;function Jr(i){i.destroy=function(){},i.on=function(){},i.once=function(){},i.emit=function(){}}class L extends Xi{constructor(t,e,r,s,n,a,o){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new Y(0,0,1,1)),t instanceof L&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=kh,this.uvMatrix=null,this.orig=r||e,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=a?new J(a.x,a.y):new J(0,0),this.defaultBorders=o,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:e}=this.baseTexture;e!=null&&e.url&&he[e.url]&&L.removeFromCache(e.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,L.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var s;const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),r=new L(this.baseTexture,!this.noFrame&&t,e,(s=this.trim)==null?void 0:s.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(r._frame=t),r}updateUvs(){this._uvs===kh&&(this._uvs=new Kn),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},r=F.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof W){if(!t.cacheId){const o=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${o}-${Ze()}`,W.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const o=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${o}_${Ze()}`}n=t._pixiId}let a=he[n];if(s&&r&&!a)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!a&&!(t instanceof W)?(e.resolution||(e.resolution=Te(t)),a=new L(new W(t,e)),a.baseTexture.cacheId=n,W.addToCache(a.baseTexture,n),L.addToCache(a,n)):!a&&t instanceof W&&(a=new L(t),L.addToCache(a,n)),a}static fromURL(t,e){const r=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),s=L.from(t,Object.assign({resourceOptions:r},e),!1),n=s.baseTexture.resource;return s.baseTexture.valid?Promise.resolve(s):n.load().then(()=>Promise.resolve(s))}static fromBuffer(t,e,r,s){return new L(W.fromBuffer(t,e,r,s))}static fromLoader(t,e,r,s){const n=new W(t,Object.assign({scaleMode:W.defaultOptions.scaleMode,resolution:Te(e)},s)),{resource:a}=n;a instanceof Nh&&(a.url=e);const o=new L(n);return r||(r=e),W.addToCache(o.baseTexture,r),L.addToCache(o,r),r!==e&&(W.addToCache(o.baseTexture,e),L.addToCache(o,e)),o.baseTexture.valid?Promise.resolve(o):new Promise(h=>{o.baseTexture.once("loaded",()=>h(o))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),he[e]&&he[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),he[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=he[t];if(e){const r=e.textureCacheIds.indexOf(t);return r>-1&&e.textureCacheIds.splice(r,1),delete he[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)he[t.textureCacheIds[e]]===t&&delete he[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:r,width:s,height:n}=t,a=e+s>this.baseTexture.width,o=r+n>this.baseTexture.height;if(a||o){const h=a&&o?"and":"or",l=`X: ${e} + ${s} = ${e+s} > ${this.baseTexture.width}`,c=`Y: ${r} + ${n} = ${r+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${l} ${h} ${c}`)}this.valid=s&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return L._EMPTY||(L._EMPTY=new L(new W),Jr(L._EMPTY),Jr(L._EMPTY.baseTexture)),L._EMPTY}static get WHITE(){if(!L._WHITE){const t=F.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),L._WHITE=new L(W.from(t)),Jr(L._WHITE),Jr(L._WHITE.baseTexture)}return L._WHITE}}class si extends L{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,r=!0){const s=this.baseTexture.resolution,n=Math.round(t*s)/s,a=Math.round(e*s)/s;this.valid=n>0&&a>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=a,r&&this.baseTexture.resize(n,a),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new si(new Lh(t))}}class Uh{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,r=pt.NONE){const s=new Lh(Object.assign({width:t,height:e,resolution:1,multisample:r},this.textureOptions));return new si(s)}getOptimalTexture(t,e,r=1,s=pt.NONE){let n;t=Math.max(Math.ceil(t*r-1e-6),1),e=Math.max(Math.ceil(e*r-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=Nr(t),e=Nr(e),n=((t&65535)<<16|e&65535)>>>0,s>1&&(n+=s*4294967296)):n=s>1?-s:-1,this.texturePool[n]||(this.texturePool[n]=[]);let a=this.texturePool[n].pop();return a||(a=this.createTexture(t,e,s)),a.filterPoolKey=n,a.setResolution(r),a}getFilterTexture(t,e,r){const s=this.getOptimalTexture(t.width,t.height,e||t.resolution,r||pt.NONE);return s.filterFrame=t.filterFrame,s}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const e in this.texturePool){const r=this.texturePool[e];if(r)for(let s=0;s<r.length;s++)r[s].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const r=this.texturePool[e];if(r)for(let s=0;s<r.length;s++)r[s].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}Uh.SCREEN_KEY=-1;class Pp extends Ne{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class Gh extends Ne{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 ut(this.vertices),this.uvBuffer=new ut(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let r=0,s=0;return this.uvs[0]=r,this.uvs[1]=s,this.uvs[2]=r+e.width/t.width,this.uvs[3]=s,this.uvs[4]=r+e.width/t.width,this.uvs[5]=s+e.height/t.height,this.uvs[6]=r,this.uvs[7]=s+e.height/t.height,r=e.x,s=e.y,this.vertices[0]=r,this.vertices[1]=s,this.vertices[2]=r+e.width,this.vertices[3]=s,this.vertices[4]=r+e.width,this.vertices[5]=s+e.height,this.vertices[6]=r,this.vertices[7]=s+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class Mp{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=pt.NONE,this.sourceFrame=new Y,this.destinationFrame=new Y,this.bindingSourceFrame=new Y,this.bindingDestinationFrame=new Y,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const Qr=[new J,new J,new J,new J],Zn=new rt;class Hh{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Uh,this.statePool=[],this.quad=new Pp,this.quadUv=new Gh,this.tempRect=new Y,this.activeState={},this.globalUniforms=new Vt({outputFrame:new Y,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const r=this.renderer,s=this.defaultFilterStack,n=this.statePool.pop()||new Mp,a=r.renderTexture;let o,h;if(a.current){const g=a.current;o=g.resolution,h=g.multisample}else o=r.resolution,h=r.multisample;let l=e[0].resolution||o,c=e[0].multisample??h,u=e[0].padding,d=e[0].autoFit,f=e[0].legacy??!0;for(let g=1;g<e.length;g++){const _=e[g];l=Math.min(l,_.resolution||o),c=Math.min(c,_.multisample??h),u=this.useMaxPadding?Math.max(u,_.padding):u+_.padding,d=d&&_.autoFit,f=f||(_.legacy??!0)}s.length===1&&(this.defaultFilterStack[0].renderTexture=a.current),s.push(n),n.resolution=l,n.multisample=c,n.legacy=f,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(u);const p=this.tempRect.copyFrom(a.sourceFrame);r.projection.transform&&this.transformAABB(Zn.copyFrom(r.projection.transform).invert(),p),d?(n.sourceFrame.fit(p),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(p)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,a.current?a.current.resolution:r.resolution,a.sourceFrame,a.destinationFrame,r.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,l,c),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const m=this.tempRect;m.x=0,m.y=0,m.width=n.sourceFrame.width,m.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(a.sourceFrame),n.bindingDestinationFrame.copyFrom(a.destinationFrame),n.transform=r.projection.transform,r.projection.transform=null,a.bind(n.renderTexture,n.sourceFrame,m),r.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),r=e.filters;this.activeState=e;const s=this.globalUniforms.uniforms;s.outputFrame=e.sourceFrame,s.resolution=e.resolution;const n=s.inputSize,a=s.inputPixel,o=s.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],a[0]=Math.round(n[0]*e.resolution),a[1]=Math.round(n[1]*e.resolution),a[2]=1/a[0],a[3]=1/a[1],o[0]=.5*a[2],o[1]=.5*a[3],o[2]=e.sourceFrame.width*n[2]-.5*a[2],o[3]=e.sourceFrame.height*n[3]-.5*a[3],e.legacy){const l=s.filterArea;l[0]=e.destinationFrame.width,l[1]=e.destinationFrame.height,l[2]=e.sourceFrame.x,l[3]=e.sourceFrame.y,s.filterClamp=s.inputClamp}this.globalUniforms.update();const h=t[t.length-1];if(this.renderer.framebuffer.blit(),r.length===1)r[0].apply(this,e.renderTexture,h.renderTexture,ie.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let l=e.renderTexture,c=this.getOptimalFilterTexture(l.width,l.height,e.resolution);c.filterFrame=l.filterFrame;let u=0;for(u=0;u<r.length-1;++u){u===1&&e.multisample>1&&(c=this.getOptimalFilterTexture(l.width,l.height,e.resolution),c.filterFrame=l.filterFrame),r[u].apply(this,l,c,ie.CLEAR,e);const d=l;l=c,c=d}r[u].apply(this,l,h.renderTexture,ie.BLEND,e),u>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(l),this.returnFilterTexture(c)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=ie.CLEAR){const{renderTexture:r,state:s}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t==null?void 0:t.filterFrame){const a=this.tempRect;a.x=0,a.y=0,a.width=t.filterFrame.width,a.height=t.filterFrame.height,r.bind(t,t.filterFrame,a)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?r.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=s.stateId&1||this.forceClear;(e===ie.CLEAR||e===ie.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,r,s){const n=this.renderer;n.state.set(t.state),this.bindAndClear(r,s),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(te.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(te.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:r,destinationFrame:s}=this.activeState,{orig:n}=e._texture,a=t.set(s.width,0,0,s.height,r.x,r.y),o=e.worldTransform.copyTo(rt.TEMP_MATRIX);return o.invert(),a.prepend(o),a.scale(1/n.width,1/n.height),a.translate(e.anchor.x,e.anchor.y),a}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,r=1,s=pt.NONE){return this.texturePool.getOptimalTexture(t,e,r,s)}getFilterTexture(t,e,r){if(typeof t=="number"){const n=t;t=e,e=n}t=t||this.activeState.renderTexture;const s=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,r||pt.NONE);return s.filterFrame=t.filterFrame,s}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const r=Qr[0],s=Qr[1],n=Qr[2],a=Qr[3];r.set(e.left,e.top),s.set(e.left,e.bottom),n.set(e.right,e.top),a.set(e.right,e.bottom),t.apply(r,r),t.apply(s,s),t.apply(n,n),t.apply(a,a);const o=Math.min(r.x,s.x,n.x,a.x),h=Math.min(r.y,s.y,n.y,a.y),l=Math.max(r.x,s.x,n.x,a.x),c=Math.max(r.y,s.y,n.y,a.y);e.x=o,e.y=h,e.width=l-o,e.height=c-h}roundFrame(t,e,r,s,n){if(!(t.width<=0||t.height<=0||r.width<=0||r.height<=0)){if(n){const{a,b:o,c:h,d:l}=n;if((Math.abs(o)>1e-4||Math.abs(h)>1e-4)&&(Math.abs(a)>1e-4||Math.abs(l)>1e-4))return}n=n?Zn.copyFrom(n):Zn.identity(),n.translate(-r.x,-r.y).scale(s.width/r.width,s.height/r.height).translate(s.x,s.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}Hh.extension={type:P.RendererSystem,name:"filter"},k.add(Hh);class Fp{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=pt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const Bp=new Y;class $h{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new qn(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 Y,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,r=this.renderer.context.extensions.depthTexture;F.PREFER_ENV===yt.WEBGL_LEGACY&&(e=null,r=null),e?t.drawBuffers=s=>e.drawBuffersWEBGL(s):(this.hasMRT=!1,t.drawBuffers=()=>{}),r||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,r=0){const{gl:s}=this;if(t){const n=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==r&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=r),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,r)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let a=0;a<t.colorTextures.length;a++){const o=t.colorTextures[a];this.renderer.texture.unbind(o.parentTextureArray||o)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const a=e.width>>r,o=e.height>>r,h=a/e.width;this.setViewport(e.x*h,e.y*h,a,o)}else{const a=t.width>>r,o=t.height>>r;this.setViewport(0,0,a,o)}}else this.current&&(this.current=null,s.bindFramebuffer(s.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,r,s){const n=this.viewport;t=Math.round(t),e=Math.round(e),r=Math.round(r),s=Math.round(s),(n.width!==r||n.height!==s||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=r,n.height=s,this.gl.viewport(t,e,r,s))}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,r,s,n=Us.COLOR|Us.DEPTH){const{gl:a}=this;a.clearColor(t,e,r,s),a.clear(n)}initFramebuffer(t){const{gl:e}=this,r=new Fp(e.createFramebuffer());return r.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=r,this.managedFramebuffers.push(t),t.disposeRunner.add(this),r}resizeFramebuffer(t){const{gl:e}=this,r=t.glFramebuffers[this.CONTEXT_UID];if(r.stencil){e.bindRenderbuffer(e.RENDERBUFFER,r.stencil);let a;this.renderer.context.webGLVersion===1?a=e.DEPTH_STENCIL:t.depth&&t.stencil?a=e.DEPTH24_STENCIL8:t.depth?a=e.DEPTH_COMPONENT24:a=e.STENCIL_INDEX8,r.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,r.multisample,a,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,a,t.width,t.height)}const s=t.colorTextures;let n=s.length;e.drawBuffers||(n=Math.min(n,1));for(let a=0;a<n;a++){const o=s[a],h=o.parentTextureArray||o;this.renderer.texture.bind(h,0),a===0&&r.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,r.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,r.multisample,h._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:r}=this,s=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let a=n.length;r.drawBuffers||(a=Math.min(a,1)),s.multisample>1&&this.canMultisampleFramebuffer(t)?s.msaaBuffer=s.msaaBuffer||r.createRenderbuffer():s.msaaBuffer&&(r.deleteRenderbuffer(s.msaaBuffer),s.msaaBuffer=null,s.blitFramebuffer&&(s.blitFramebuffer.dispose(),s.blitFramebuffer=null));const o=[];for(let h=0;h<a;h++){const l=n[h],c=l.parentTextureArray||l;this.renderer.texture.bind(c,0),h===0&&s.msaaBuffer?(r.bindRenderbuffer(r.RENDERBUFFER,s.msaaBuffer),r.renderbufferStorageMultisample(r.RENDERBUFFER,s.multisample,c._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,s.msaaBuffer)):(r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+h,l.target,c._glTextures[this.CONTEXT_UID].texture,e),o.push(r.COLOR_ATTACHMENT0+h))}if(o.length>1&&r.drawBuffers(o),t.depthTexture&&this.writeDepthTexture){const h=t.depthTexture;this.renderer.texture.bind(h,0),r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,h._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||r.createRenderbuffer();let h,l;this.renderer.context.webGLVersion===1?(h=r.DEPTH_STENCIL_ATTACHMENT,l=r.DEPTH_STENCIL):t.depth&&t.stencil?(h=r.DEPTH_STENCIL_ATTACHMENT,l=r.DEPTH24_STENCIL8):t.depth?(h=r.DEPTH_ATTACHMENT,l=r.DEPTH_COMPONENT24):(h=r.STENCIL_ATTACHMENT,l=r.STENCIL_INDEX8),r.bindRenderbuffer(r.RENDERBUFFER,s.stencil),s.msaaBuffer?r.renderbufferStorageMultisample(r.RENDERBUFFER,s.multisample,l,t.width,t.height):r.renderbufferStorage(r.RENDERBUFFER,l,t.width,t.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,h,r.RENDERBUFFER,s.stencil)}else s.stencil&&(r.deleteRenderbuffer(s.stencil),s.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let r=pt.NONE;if(t<=1||e===null)return r;for(let s=0;s<e.length;s++)if(e[s]<=t){r=e[s];break}return r===1&&(r=pt.NONE),r}blit(t,e,r){const{current:s,renderer:n,gl:a,CONTEXT_UID:o}=this;if(n.context.webGLVersion!==2||!s)return;const h=s.glFramebuffers[o];if(!h)return;if(!t){if(!h.msaaBuffer)return;const c=s.colorTextures[0];if(!c)return;h.blitFramebuffer||(h.blitFramebuffer=new qn(s.width,s.height),h.blitFramebuffer.addColorTexture(0,c)),t=h.blitFramebuffer,t.colorTextures[0]!==c&&(t.colorTextures[0]=c,t.dirtyId++,t.dirtyFormat++),(t.width!==s.width||t.height!==s.height)&&(t.width=s.width,t.height=s.height,t.dirtyId++,t.dirtySize++)}e||(e=Bp,e.width=s.width,e.height=s.height),r||(r=e);const l=e.width===r.width&&e.height===r.height;this.bind(t),a.bindFramebuffer(a.READ_FRAMEBUFFER,h.framebuffer),a.blitFramebuffer(e.left,e.top,e.right,e.bottom,r.left,r.top,r.right,r.bottom,a.COLOR_BUFFER_BIT,l?a.NEAREST:a.LINEAR),a.bindFramebuffer(a.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const r=t.glFramebuffers[this.CONTEXT_UID],s=this.gl;if(!r)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(s.deleteFramebuffer(r.framebuffer),r.msaaBuffer&&s.deleteRenderbuffer(r.msaaBuffer),r.stencil&&s.deleteRenderbuffer(r.stencil)),r.blitFramebuffer&&this.disposeFramebuffer(r.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let r=0;r<e.length;r++)this.disposeFramebuffer(e[r],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const r=t.width,s=t.height,n=this.gl,a=e.stencil=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,a);let o,h;this.renderer.context.webGLVersion===1?(o=n.DEPTH_STENCIL_ATTACHMENT,h=n.DEPTH_STENCIL):t.depth?(o=n.DEPTH_STENCIL_ATTACHMENT,h=n.DEPTH24_STENCIL8):(o=n.STENCIL_ATTACHMENT,h=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,h,r,s):n.renderbufferStorage(n.RENDERBUFFER,h,r,s),n.framebufferRenderbuffer(n.FRAMEBUFFER,o,n.RENDERBUFFER,a)}reset(){this.current=this.unknownFramebuffer,this.viewport=new Y}destroy(){this.renderer=null}}$h.extension={type:P.RendererSystem,name:"framebuffer"},k.add($h);const Jn={5126:4,5123:2,5121:1};class Xh{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,e.webGLVersion!==2){let r=this.renderer.context.extensions.vertexArrayObject;F.PREFER_ENV===yt.WEBGL_LEGACY&&(r=null),r?(t.createVertexArray=()=>r.createVertexArrayOES(),t.bindVertexArray=s=>r.bindVertexArrayOES(s),t.deleteVertexArray=s=>r.deleteVertexArrayOES(s)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const r=t.getExtension("ANGLE_instanced_arrays");r?(t.vertexAttribDivisor=(s,n)=>r.vertexAttribDivisorANGLE(s,n),t.drawElementsInstanced=(s,n,a,o,h)=>r.drawElementsInstancedANGLE(s,n,a,o,h),t.drawArraysInstanced=(s,n,a,o)=>r.drawArraysInstancedANGLE(s,n,a,o)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:r}=this;let s=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;s||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=s={},n=!0);const a=s[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==a&&(this._activeVao=a,this.hasVao?r.bindVertexArray(a):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let r=0;r<t.buffers.length;r++){const s=t.buffers[r];e.update(s)}}checkCompatibility(t,e){const r=t.attributes,s=e.attributeData;for(const n in s)if(!r[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const r=t.attributes,s=e.attributeData,n=["g",t.id];for(const a in r)s[a]&&n.push(a,s[a].location);return n.join("-")}initGeometryVao(t,e,r=!0){const s=this.gl,n=this.CONTEXT_UID,a=this.renderer.buffer,o=e.program;o.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,o);const h=this.getSignature(t,o),l=t.glVertexArrayObjects[this.CONTEXT_UID];let c=l[h];if(c)return l[o.id]=c,c;const u=t.buffers,d=t.attributes,f={},p={};for(const m in u)f[m]=0,p[m]=0;for(const m in d)!d[m].size&&o.attributeData[m]?d[m].size=o.attributeData[m].size:d[m].size||console.warn(`PIXI Geometry attribute '${m}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[m].buffer]+=d[m].size*Jn[d[m].type];for(const m in d){const g=d[m],_=g.size;g.stride===void 0&&(f[g.buffer]===_*Jn[g.type]?g.stride=0:g.stride=f[g.buffer]),g.start===void 0&&(g.start=p[g.buffer],p[g.buffer]+=_*Jn[g.type])}c=s.createVertexArray(),s.bindVertexArray(c);for(let m=0;m<u.length;m++){const g=u[m];a.bind(g),r&&g._glBuffers[n].refCount++}return this.activateVao(t,o),l[o.id]=c,l[h]=c,s.bindVertexArray(null),a.unbind(re.ARRAY_BUFFER),c}disposeGeometry(t,e){var o;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const r=t.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,n=t.buffers,a=(o=this.renderer)==null?void 0:o.buffer;if(t.disposeRunner.remove(this),!!r){if(a)for(let h=0;h<n.length;h++){const l=n[h]._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&a.dispose(n[h],e))}if(!e){for(const h in r)if(h[0]==="g"){const l=r[h];this._activeVao===l&&this.unbind(),s.deleteVertexArray(l)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let r=0;r<e.length;r++)this.disposeGeometry(this.managedGeometries[e[r]],t)}activateVao(t,e){const r=this.gl,s=this.CONTEXT_UID,n=this.renderer.buffer,a=t.buffers,o=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let h=null;for(const l in o){const c=o[l],u=a[c.buffer],d=u._glBuffers[s];if(e.attributeData[l]){h!==d&&(n.bind(u),h=d);const f=e.attributeData[l].location;if(r.enableVertexAttribArray(f),r.vertexAttribPointer(f,c.size,c.type||r.FLOAT,c.normalized,c.stride,c.start),c.instance)if(this.hasInstance)r.vertexAttribDivisor(f,c.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,r,s){const{gl:n}=this,a=this._activeGeometry;if(a.indexBuffer){const o=a.indexBuffer.data.BYTES_PER_ELEMENT,h=o===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;o===2||o===4&&this.canUseUInt32ElementIndex?a.instanced?n.drawElementsInstanced(t,e||a.indexBuffer.data.length,h,(r||0)*o,s||1):n.drawElements(t,e||a.indexBuffer.data.length,h,(r||0)*o):console.warn("unsupported index buffer type: uint32")}else a.instanced?n.drawArraysInstanced(t,r,e||a.getSize(),s||1):n.drawArrays(t,r,e||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}Xh.extension={type:P.RendererSystem,name:"geometry"},k.add(Xh);const zh=new rt;class Vh{constructor(t,e){this._texture=t,this.mapCoord=new rt,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){e===void 0&&(e=t);const r=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],a=t[s+1];e[s]=n*r.a+a*r.c+r.tx,e[s+1]=n*r.b+a*r.d+r.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 r=e._uvs;this.mapCoord.set(r.x1-r.x0,r.y1-r.y0,r.x3-r.x0,r.y3-r.y0,r.x0,r.y0);const s=e.orig,n=e.trim;n&&(zh.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(zh));const a=e.baseTexture,o=this.uClampFrame,h=this.clampMargin/a.resolution,l=this.clampOffset;return o[0]=(e._frame.x+h+l)/a.width,o[1]=(e._frame.y+h+l)/a.height,o[2]=(e._frame.x+e._frame.width-h+l)/a.width,o[3]=(e._frame.y+e._frame.height-h+l)/a.height,this.uClampOffset[0]=l/a.realWidth,this.uClampOffset[1]=l/a.realHeight,this.isSimple=e._frame.width===a.width&&e._frame.height===a.height&&e.rotate===0,!0}}var Dp=`varying vec2 vMaskCoord;
|
|
379
|
-
varying vec2 vTextureCoord;
|
|
82
|
+
uniform float uAlpha;
|
|
83
|
+
uniform vec4 uMaskClamp;
|
|
380
84
|
|
|
381
|
-
|
|
382
|
-
uniform sampler2D mask;
|
|
383
|
-
uniform float alpha;
|
|
384
|
-
uniform float npmAlpha;
|
|
385
|
-
uniform vec4 maskClamp;
|
|
85
|
+
out vec4 finalColor;
|
|
386
86
|
|
|
387
87
|
void main(void)
|
|
388
88
|
{
|
|
389
89
|
float clip = step(3.5,
|
|
390
|
-
step(
|
|
391
|
-
step(
|
|
392
|
-
step(vMaskCoord.x,
|
|
393
|
-
step(vMaskCoord.y,
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
90
|
+
step(uMaskClamp.x, vMaskCoord.x) +
|
|
91
|
+
step(uMaskClamp.y, vMaskCoord.y) +
|
|
92
|
+
step(vMaskCoord.x, uMaskClamp.z) +
|
|
93
|
+
step(vMaskCoord.y, uMaskClamp.w));
|
|
94
|
+
|
|
95
|
+
// TODO look into why this is needed
|
|
96
|
+
float npmAlpha = uAlpha;
|
|
97
|
+
vec4 original = texture(uTexture, vTextureCoord);
|
|
98
|
+
vec4 masky = texture(uMaskTexture, vMaskCoord);
|
|
397
99
|
float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
|
|
398
100
|
|
|
399
|
-
original *= (alphaMul * masky.r *
|
|
400
|
-
|
|
401
|
-
gl_FragColor = original;
|
|
402
|
-
}
|
|
403
|
-
`,Op=`attribute vec2 aVertexPosition;
|
|
404
|
-
attribute vec2 aTextureCoord;
|
|
405
|
-
|
|
406
|
-
uniform mat3 projectionMatrix;
|
|
407
|
-
uniform mat3 otherMatrix;
|
|
408
|
-
|
|
409
|
-
varying vec2 vMaskCoord;
|
|
410
|
-
varying vec2 vTextureCoord;
|
|
411
|
-
|
|
412
|
-
void main(void)
|
|
413
|
-
{
|
|
414
|
-
gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
101
|
+
original *= (alphaMul * masky.r * uAlpha * clip);
|
|
415
102
|
|
|
416
|
-
|
|
417
|
-
vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;
|
|
103
|
+
finalColor = original;
|
|
418
104
|
}
|
|
419
|
-
`;class Lp extends Bt{constructor(t,e,r){let s=null;typeof t!="string"&&e===void 0&&r===void 0&&(s=t,t=void 0,e=void 0,r=void 0),super(t||Op,e||Dp,r),this.maskSprite=s,this.maskMatrix=new rt}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,r,s){const n=this._maskSprite,a=n._texture;a.valid&&(a.uvMatrix||(a.uvMatrix=new Vh(a,0)),a.uvMatrix.update(),this.uniforms.npmAlpha=a.baseTexture.alphaMode?0:1,this.uniforms.mask=a,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,n).prepend(a.uvMatrix.mapCoord),this.uniforms.alpha=n.worldAlpha,this.uniforms.maskClamp=a.uvMatrix.uClampFrame,t.applyFilter(this,e,r,s))}}class Np{constructor(t=null){this.type=_t.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Bt.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=_t.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 Wh{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 r=e;if(!r.isMaskData){const n=this.maskDataPool.pop()||new Np;n.pooled=!0,n.maskObject=e,r=n}const s=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(r.copyCountersOrReset(s),r._colorMask=s?s._colorMask:15,r.autoDetect&&this.detect(r),r._target=t,r.type!==_t.SPRITE&&this.maskStack.push(r),r.enabled)switch(r.type){case _t.SCISSOR:this.renderer.scissor.push(r);break;case _t.STENCIL:this.renderer.stencil.push(r);break;case _t.SPRITE:r.copyCountersOrReset(null),this.pushSpriteMask(r);break;case _t.COLOR:this.pushColorMask(r);break}r.type===_t.SPRITE&&this.maskStack.push(r)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case _t.SCISSOR:this.renderer.scissor.pop(e);break;case _t.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case _t.SPRITE:this.popSpriteMask(e);break;case _t.COLOR:this.popColorMask(e);break}if(e.reset(),e.pooled&&this.maskDataPool.push(e),this.maskStack.length!==0){const r=this.maskStack[this.maskStack.length-1];r.type===_t.SPRITE&&r._filters&&(r._filters[0].maskSprite=r.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=_t.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=_t.SCISSOR:t.type=_t.STENCIL:t.type=_t.COLOR}pushSpriteMask(t){const{maskObject:e}=t,r=t._target;let s=t._filters;s||(s=this.alphaMaskPool[this.alphaMaskIndex],s||(s=this.alphaMaskPool[this.alphaMaskIndex]=[new Lp])),s[0].resolution=t.resolution,s[0].multisample=t.multisample,s[0].maskSprite=e;const n=r.filterArea;r.filterArea=e.getBounds(!0),this.renderer.filter.push(r,s),r.filterArea=n,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,r=t._colorMask=e&t.colorMask;r!==e&&this.renderer.gl.colorMask((r&1)!==0,(r&2)!==0,(r&4)!==0,(r&8)!==0)}popColorMask(t){const e=t._colorMask,r=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;r!==e&&this.renderer.gl.colorMask((r&1)!==0,(r&2)!==0,(r&4)!==0,(r&8)!==0)}destroy(){this.renderer=null}}Wh.extension={type:P.RendererSystem,name:"mask"},k.add(Wh);class jh{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,r=this.getStackLength();this.maskStack=t;const s=this.getStackLength();s!==r&&(s===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const Yh=new rt,qh=[],Kh=class Os extends jh{constructor(t){super(t),this.glConst=F.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:r}=t,{renderer:s}=this,n=s.renderTexture,a=r.getBounds(!0,qh.pop()??new Y);this.roundFrameToPixels(a,n.current?n.current.resolution:s.resolution,n.sourceFrame,n.destinationFrame,s.projection.transform),e&&a.fit(e),t._scissorRectLocal=a}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:r,c:s,d:n}=t;return(Math.abs(r)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(n)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||Os.isMatrixRotated(e.worldTransform)||Os.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const r=t._scissorRectLocal;return r.width>0&&r.height>0}roundFrameToPixels(t,e,r,s,n){Os.isMatrixRotated(n)||(n=n?Yh.copyFrom(n):Yh.identity(),n.translate(-r.x,-r.y).scale(s.width/r.width,s.height/r.height).translate(s.x,s.y),this.renderer.filter.transformAABB(n,t),t.fit(s),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&&qh.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():e.disable(e.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let e;this.renderer.renderTexture.current?e=t.y:e=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};Kh.extension={type:P.RendererSystem,name:"scissor"};let kp=Kh;k.add(kp);class Zh extends jh{constructor(t){super(t),this.glConst=F.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:r}=this.renderer,s=t._stencilCounter;s===0&&(this.renderer.framebuffer.forceStencil(),r.clearStencil(0),r.clear(r.STENCIL_BUFFER_BIT),r.enable(r.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,r.colorMask(!1,!1,!1,!1)),r.stencilFunc(r.EQUAL,s,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,r.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}pop(t){const e=this.renderer.gl;if(this.getStackLength()===0)e.disable(e.STENCIL_TEST);else{const r=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,s=r?r._colorMask:15;s!==0&&(r._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,s!==0&&(r._colorMask=s,e.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}Zh.extension={type:P.RendererSystem,name:"stencil"},k.add(Zh);class Jh{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return K("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return K("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return K("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}}Jh.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"_plugin"},k.add(Jh);class Qh{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new rt,this.transform=null}update(t,e,r,s){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,r,s),this.transform&&this.projectionMatrix.append(this.transform);const n=this.renderer;n.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,n.globalUniforms.update(),n.shader.shader&&n.shader.syncUniformGroup(n.shader.shader.uniforms.globals)}calculateProjection(t,e,r,s){const n=this.projectionMatrix,a=s?-1:1;n.identity(),n.a=1/e.width*2,n.d=a*(1/e.height*2),n.tx=-1-e.x*n.a,n.ty=-a-e.y*n.d}setTransform(t){}destroy(){this.renderer=null}}Qh.extension={type:P.RendererSystem,name:"projection"},k.add(Qh);const Up=new zn,tl=new Y;class el{constructor(t){this.renderer=t,this._tempMatrix=new rt}generateTexture(t,e){const{region:r,...s}=e||{},n=(r==null?void 0:r.copyTo(tl))||t.getLocalBounds(tl,!0),a=s.resolution||this.renderer.resolution;n.width=Math.max(n.width,1/a),n.height=Math.max(n.height,1/a),s.width=n.width,s.height=n.height,s.resolution=a,s.multisample??(s.multisample=this.renderer.multisample);const o=si.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const h=t.transform;return t.transform=Up,this.renderer.render(t,{renderTexture:o,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=h,o}destroy(){}}el.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"textureGenerator"},k.add(el);const ni=new Y,sr=new Y;class il{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new Y,this.destinationFrame=new Y,this.viewportFrame=new Y}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,r){const s=this.renderer;this.current=t;let n,a,o;t?(n=t.baseTexture,o=n.resolution,e||(ni.width=t.frame.width,ni.height=t.frame.height,e=ni),r||(sr.x=t.frame.x,sr.y=t.frame.y,sr.width=e.width,sr.height=e.height,r=sr),a=n.framebuffer):(o=s.resolution,e||(ni.width=s._view.screen.width,ni.height=s._view.screen.height,e=ni),r||(r=ni,r.width=e.width,r.height=e.height));const h=this.viewportFrame;h.x=r.x*o,h.y=r.y*o,h.width=r.width*o,h.height=r.height*o,t||(h.y=s.view.height-(h.y+h.height)),h.ceil(),this.renderer.framebuffer.bind(a,h),this.renderer.projection.update(r,e,o,!a),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(r)}clear(t,e){const r=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,s=tt.shared.setValue(t||r);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&s.premultiply(s.alpha);const n=this.destinationFrame,a=this.current?this.current.baseTexture:this.renderer._view.screen,o=n.width!==a.width||n.height!==a.height;if(o){let{x:h,y:l,width:c,height:u}=this.viewportFrame;h=Math.round(h),l=Math.round(l),c=Math.round(c),u=Math.round(u),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(h,l,c,u)}this.renderer.framebuffer.clear(s.red,s.green,s.blue,s.alpha,e),o&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}il.extension={type:P.RendererSystem,name:"renderTexture"},k.add(il);class Gp{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 Hp(i,t){const e={},r=t.getProgramParameter(i,t.ACTIVE_ATTRIBUTES);for(let s=0;s<r;s++){const n=t.getActiveAttrib(i,s);if(n.name.startsWith("gl_"))continue;const a=Fh(t,n.type),o={type:a,name:n.name,size:Ph(a),location:t.getAttribLocation(i,n.name)};e[n.name]=o}return e}function $p(i,t){const e={},r=t.getProgramParameter(i,t.ACTIVE_UNIFORMS);for(let s=0;s<r;s++){const n=t.getActiveUniform(i,s),a=n.name.replace(/\[.*?\]$/,""),o=!!n.name.match(/\[.*?\]$/),h=Fh(t,n.type);e[a]={name:a,index:s,type:h,size:n.size,isArray:o,value:Ch(h,n.size)}}return e}function Xp(i,t){var o;const e=Sh(i,i.VERTEX_SHADER,t.vertexSrc),r=Sh(i,i.FRAGMENT_SHADER,t.fragmentSrc),s=i.createProgram();i.attachShader(s,e),i.attachShader(s,r);const n=(o=t.extra)==null?void 0:o.transformFeedbackVaryings;if(n&&(typeof i.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):i.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?i.SEPARATE_ATTRIBS:i.INTERLEAVED_ATTRIBS)),i.linkProgram(s),i.getProgramParameter(s,i.LINK_STATUS)||_p(i,s,e,r),t.attributeData=Hp(s,i),t.uniformData=$p(s,i),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const h=Object.keys(t.attributeData);h.sort((l,c)=>l>c?1:-1);for(let l=0;l<h.length;l++)t.attributeData[h[l]].location=l,i.bindAttribLocation(s,l,h[l]);i.linkProgram(s)}i.deleteShader(e),i.deleteShader(r);const a={};for(const h in t.uniformData){const l=t.uniformData[h];a[h]={location:i.getUniformLocation(s,h),value:Ch(l.type,l.size)}}return new Gp(s,a)}function zp(i,t,e,r,s){e.buffer.update(s)}const Vp={float:`
|
|
420
|
-
data[offset] = v;
|
|
421
|
-
`,vec2:`
|
|
422
|
-
data[offset] = v[0];
|
|
423
|
-
data[offset+1] = v[1];
|
|
424
|
-
`,vec3:`
|
|
425
|
-
data[offset] = v[0];
|
|
426
|
-
data[offset+1] = v[1];
|
|
427
|
-
data[offset+2] = v[2];
|
|
428
|
-
|
|
429
|
-
`,vec4:`
|
|
430
|
-
data[offset] = v[0];
|
|
431
|
-
data[offset+1] = v[1];
|
|
432
|
-
data[offset+2] = v[2];
|
|
433
|
-
data[offset+3] = v[3];
|
|
434
|
-
`,mat2:`
|
|
435
|
-
data[offset] = v[0];
|
|
436
|
-
data[offset+1] = v[1];
|
|
437
|
-
|
|
438
|
-
data[offset+4] = v[2];
|
|
439
|
-
data[offset+5] = v[3];
|
|
440
|
-
`,mat3:`
|
|
441
|
-
data[offset] = v[0];
|
|
442
|
-
data[offset+1] = v[1];
|
|
443
|
-
data[offset+2] = v[2];
|
|
444
|
-
|
|
445
|
-
data[offset + 4] = v[3];
|
|
446
|
-
data[offset + 5] = v[4];
|
|
447
|
-
data[offset + 6] = v[5];
|
|
448
|
-
|
|
449
|
-
data[offset + 8] = v[6];
|
|
450
|
-
data[offset + 9] = v[7];
|
|
451
|
-
data[offset + 10] = v[8];
|
|
452
|
-
`,mat4:`
|
|
453
|
-
for(var i = 0; i < 16; i++)
|
|
454
|
-
{
|
|
455
|
-
data[offset + i] = v[i];
|
|
456
|
-
}
|
|
457
|
-
`},rl={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:16*2,mat3:16*3,mat4:16*4};function Wp(i){const t=i.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,r=0,s=0;for(let n=0;n<t.length;n++){const a=t[n];if(e=rl[a.data.type],a.data.size>1&&(e=Math.max(e,16)*a.data.size),a.dataLen=e,r%e!==0&&r<16){const o=r%e%16;r+=o,s+=o}r+e>16?(s=Math.ceil(s/16)*16,a.offset=s,s+=e,r=e):(a.offset=s,r+=e,s+=e)}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}function jp(i,t){const e=[];for(const r in i)t[r]&&e.push(t[r]);return e.sort((r,s)=>r.index-s.index),e}function Yp(i,t){if(!i.autoManage)return{size:0,syncFunc:zp};const e=jp(i.uniforms,t),{uboElements:r,size:s}=Wp(e),n=[`
|
|
458
|
-
var v = null;
|
|
459
|
-
var v2 = null;
|
|
460
|
-
var cv = null;
|
|
461
|
-
var t = 0;
|
|
462
|
-
var gl = renderer.gl
|
|
463
|
-
var index = 0;
|
|
464
|
-
var data = buffer.data;
|
|
465
|
-
`];for(let a=0;a<r.length;a++){const o=r[a],h=i.uniforms[o.data.name],l=o.data.name;let c=!1;for(let u=0;u<Si.length;u++){const d=Si[u];if(d.codeUbo&&d.test(o.data,h)){n.push(`offset = ${o.offset/4};`,Si[u].codeUbo(o.data.name,h)),c=!0;break}}if(!c)if(o.data.size>1){const u=Ph(o.data.type),d=Math.max(rl[o.data.type]/16,1),f=u/d,p=(4-f%4)%4;n.push(`
|
|
466
|
-
cv = ud.${l}.value;
|
|
467
|
-
v = uv.${l};
|
|
468
|
-
offset = ${o.offset/4};
|
|
469
|
-
|
|
470
|
-
t = 0;
|
|
471
|
-
|
|
472
|
-
for(var i=0; i < ${o.data.size*d}; i++)
|
|
473
|
-
{
|
|
474
|
-
for(var j = 0; j < ${f}; j++)
|
|
475
|
-
{
|
|
476
|
-
data[offset++] = v[t++];
|
|
477
|
-
}
|
|
478
|
-
offset += ${p};
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
`)}else{const u=Vp[o.data.type];n.push(`
|
|
482
|
-
cv = ud.${l}.value;
|
|
483
|
-
v = uv.${l};
|
|
484
|
-
offset = ${o.offset/4};
|
|
485
|
-
${u};
|
|
486
|
-
`)}}return n.push(`
|
|
487
|
-
renderer.buffer.update(buffer);
|
|
488
|
-
`),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(`
|
|
489
|
-
`))}}let qp=0;const ts={textureCount:0,uboCount:0};class sl{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=qp++}systemCheck(){if(!xp())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 r=t.program,s=r.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==r&&(this.program=r,this.gl.useProgram(s.program)),e||(ts.textureCount=0,ts.uboCount=0,this.syncUniformGroup(t.uniformGroup,ts)),s}setUniforms(t){const e=this.shader.program,r=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(r.uniformData,t,this.renderer)}syncUniformGroup(t,e){const r=this.getGlProgram();(!t.static||t.dirtyId!==r.uniformDirtyGroups[t.id])&&(r.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,r,e))}syncUniforms(t,e,r){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,r)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=mp(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const r=this.getGlProgram();if(!t.static||t.dirtyId!==0||!r.uniformGroups[t.id]){t.dirtyId=0;const s=r.uniformGroups[t.id]||this.createSyncBufferGroup(t,r,e);t.buffer.update(),s(r.uniformData,t.uniforms,this.renderer,ts,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,r.uniformBufferBindings[e])}createSyncBufferGroup(t,e,r){const{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,r);e.uniformBufferBindings[r]=this.shader.uniformBindCount,s.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const a=this.getSignature(t,this.shader.program.uniformData,"ubo");let o=this._uboCache[a];if(o||(o=this._uboCache[a]=Yp(t,this.shader.program.uniformData)),t.autoManage){const h=new Float32Array(o.size/4);t.buffer.update(h)}return e.uniformGroups[t.id]=o.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,r){const s=t.uniforms,n=[`${r}-`];for(const a in s)n.push(a),e[a]&&n.push(e[a].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,r=t.program,s=Xp(e,r);return r.glPrograms[this.renderer.CONTEXT_UID]=s,s}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}sl.extension={type:P.RendererSystem,name:"shader"},k.add(sl);class es{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.2 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}es.defaultOptions={hello:!1},es.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"startup"},k.add(es);function Kp(i,t=[]){return t[z.NORMAL]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.ADD]=[i.ONE,i.ONE],t[z.MULTIPLY]=[i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.SCREEN]=[i.ONE,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.OVERLAY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.DARKEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.LIGHTEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.COLOR_DODGE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.COLOR_BURN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.HARD_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.SOFT_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.DIFFERENCE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.EXCLUSION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.HUE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.SATURATION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.COLOR]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.LUMINOSITY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.NONE]=[0,0],t[z.NORMAL_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.ADD_NPM]=[i.SRC_ALPHA,i.ONE,i.ONE,i.ONE],t[z.SCREEN_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[z.SRC_IN]=[i.DST_ALPHA,i.ZERO],t[z.SRC_OUT]=[i.ONE_MINUS_DST_ALPHA,i.ZERO],t[z.SRC_ATOP]=[i.DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[z.DST_OVER]=[i.ONE_MINUS_DST_ALPHA,i.ONE],t[z.DST_IN]=[i.ZERO,i.SRC_ALPHA],t[z.DST_OUT]=[i.ZERO,i.ONE_MINUS_SRC_ALPHA],t[z.DST_ATOP]=[i.ONE_MINUS_DST_ALPHA,i.SRC_ALPHA],t[z.XOR]=[i.ONE_MINUS_DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[z.SUBTRACT]=[i.ONE,i.ONE,i.ONE,i.ONE,i.FUNC_REVERSE_SUBTRACT,i.FUNC_ADD],t}const Zp=0,Jp=1,Qp=2,tm=3,em=4,im=5,nl=class Na{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=z.NONE,this._blendEq=!1,this.map=[],this.map[Zp]=this.setBlend,this.map[Jp]=this.setOffset,this.map[Qp]=this.setCullFace,this.map[tm]=this.setDepthTest,this.map[em]=this.setFrontFace,this.map[im]=this.setDepthMask,this.checks=[],this.defaultState=new le,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=Kp(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,r=0;for(;e;)e&1&&this.map[r].call(this,!!(t.data&1<<r)),e=e>>1,r++;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(Na.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Na.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],r=this.gl;e.length===2?r.blendFunc(e[0],e[1]):r.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,r.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,r.blendEquationSeparate(r.FUNC_ADD,r.FUNC_ADD))}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 r=this.checks.indexOf(t);e&&r===-1?this.checks.push(t):!e&&r!==-1&&this.checks.splice(r,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};nl.extension={type:P.RendererSystem,name:"state"};let rm=nl;k.add(rm);class sm extends Xi{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(s=>t.systems[s]),r=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(const s of r)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new zt(e)})}addSystem(t,e){const r=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=r,this._systemsHash[e]=r;for(const s in this.runners)this.runners[s].add(r);return this}emitWithCustomOptions(t,e){const r=Object.keys(this._systemsHash);t.items.forEach(s=>{const n=r.find(a=>this._systemsHash[a]===s);s[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const nr=class Ls{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Ls.defaultMaxIdle,this.checkCountMax=Ls.defaultCheckCountMax,this.mode=Ls.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Gs.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let r=!1;for(let s=0;s<e.length;s++){const n=e[s];n.resource&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[s]=null,r=!0)}if(r){let s=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[s++]=e[n]);e.length=s}}unload(t){const e=this.renderer.texture,r=t._texture;r&&!r.framebuffer&&e.destroyTexture(r);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};nr.defaultMode=Gs.AUTO,nr.defaultMaxIdle=60*60,nr.defaultCheckCountMax=60*10,nr.extension={type:P.RendererSystem,name:"textureGC"};let ai=nr;k.add(ai);class Qn{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=H.UNSIGNED_BYTE,this.internalFormat=A.RGBA,this.samplerType=0}}function nm(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[i.RGB]:D.FLOAT,[i.RGBA]:D.FLOAT,[i.ALPHA]:D.FLOAT,[i.LUMINANCE]:D.FLOAT,[i.LUMINANCE_ALPHA]:D.FLOAT,[i.R8]:D.FLOAT,[i.R8_SNORM]:D.FLOAT,[i.RG8]:D.FLOAT,[i.RG8_SNORM]:D.FLOAT,[i.RGB8]:D.FLOAT,[i.RGB8_SNORM]:D.FLOAT,[i.RGB565]:D.FLOAT,[i.RGBA4]:D.FLOAT,[i.RGB5_A1]:D.FLOAT,[i.RGBA8]:D.FLOAT,[i.RGBA8_SNORM]:D.FLOAT,[i.RGB10_A2]:D.FLOAT,[i.RGB10_A2UI]:D.FLOAT,[i.SRGB8]:D.FLOAT,[i.SRGB8_ALPHA8]:D.FLOAT,[i.R16F]:D.FLOAT,[i.RG16F]:D.FLOAT,[i.RGB16F]:D.FLOAT,[i.RGBA16F]:D.FLOAT,[i.R32F]:D.FLOAT,[i.RG32F]:D.FLOAT,[i.RGB32F]:D.FLOAT,[i.RGBA32F]:D.FLOAT,[i.R11F_G11F_B10F]:D.FLOAT,[i.RGB9_E5]:D.FLOAT,[i.R8I]:D.INT,[i.R8UI]:D.UINT,[i.R16I]:D.INT,[i.R16UI]:D.UINT,[i.R32I]:D.INT,[i.R32UI]:D.UINT,[i.RG8I]:D.INT,[i.RG8UI]:D.UINT,[i.RG16I]:D.INT,[i.RG16UI]:D.UINT,[i.RG32I]:D.INT,[i.RG32UI]:D.UINT,[i.RGB8I]:D.INT,[i.RGB8UI]:D.UINT,[i.RGB16I]:D.INT,[i.RGB16UI]:D.UINT,[i.RGB32I]:D.INT,[i.RGB32UI]:D.UINT,[i.RGBA8I]:D.INT,[i.RGBA8UI]:D.UINT,[i.RGBA16I]:D.INT,[i.RGBA16UI]:D.UINT,[i.RGBA32I]:D.INT,[i.RGBA32UI]:D.UINT,[i.DEPTH_COMPONENT16]:D.FLOAT,[i.DEPTH_COMPONENT24]:D.FLOAT,[i.DEPTH_COMPONENT32F]:D.FLOAT,[i.DEPTH_STENCIL]:D.FLOAT,[i.DEPTH24_STENCIL8]:D.FLOAT,[i.DEPTH32F_STENCIL8]:D.FLOAT}:t={[i.RGB]:D.FLOAT,[i.RGBA]:D.FLOAT,[i.ALPHA]:D.FLOAT,[i.LUMINANCE]:D.FLOAT,[i.LUMINANCE_ALPHA]:D.FLOAT,[i.DEPTH_STENCIL]:D.FLOAT},t}function am(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[H.UNSIGNED_BYTE]:{[A.RGBA]:i.RGBA8,[A.RGB]:i.RGB8,[A.RG]:i.RG8,[A.RED]:i.R8,[A.RGBA_INTEGER]:i.RGBA8UI,[A.RGB_INTEGER]:i.RGB8UI,[A.RG_INTEGER]:i.RG8UI,[A.RED_INTEGER]:i.R8UI,[A.ALPHA]:i.ALPHA,[A.LUMINANCE]:i.LUMINANCE,[A.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[H.BYTE]:{[A.RGBA]:i.RGBA8_SNORM,[A.RGB]:i.RGB8_SNORM,[A.RG]:i.RG8_SNORM,[A.RED]:i.R8_SNORM,[A.RGBA_INTEGER]:i.RGBA8I,[A.RGB_INTEGER]:i.RGB8I,[A.RG_INTEGER]:i.RG8I,[A.RED_INTEGER]:i.R8I},[H.UNSIGNED_SHORT]:{[A.RGBA_INTEGER]:i.RGBA16UI,[A.RGB_INTEGER]:i.RGB16UI,[A.RG_INTEGER]:i.RG16UI,[A.RED_INTEGER]:i.R16UI,[A.DEPTH_COMPONENT]:i.DEPTH_COMPONENT16},[H.SHORT]:{[A.RGBA_INTEGER]:i.RGBA16I,[A.RGB_INTEGER]:i.RGB16I,[A.RG_INTEGER]:i.RG16I,[A.RED_INTEGER]:i.R16I},[H.UNSIGNED_INT]:{[A.RGBA_INTEGER]:i.RGBA32UI,[A.RGB_INTEGER]:i.RGB32UI,[A.RG_INTEGER]:i.RG32UI,[A.RED_INTEGER]:i.R32UI,[A.DEPTH_COMPONENT]:i.DEPTH_COMPONENT24},[H.INT]:{[A.RGBA_INTEGER]:i.RGBA32I,[A.RGB_INTEGER]:i.RGB32I,[A.RG_INTEGER]:i.RG32I,[A.RED_INTEGER]:i.R32I},[H.FLOAT]:{[A.RGBA]:i.RGBA32F,[A.RGB]:i.RGB32F,[A.RG]:i.RG32F,[A.RED]:i.R32F,[A.DEPTH_COMPONENT]:i.DEPTH_COMPONENT32F},[H.HALF_FLOAT]:{[A.RGBA]:i.RGBA16F,[A.RGB]:i.RGB16F,[A.RG]:i.RG16F,[A.RED]:i.R16F},[H.UNSIGNED_SHORT_5_6_5]:{[A.RGB]:i.RGB565},[H.UNSIGNED_SHORT_4_4_4_4]:{[A.RGBA]:i.RGBA4},[H.UNSIGNED_SHORT_5_5_5_1]:{[A.RGBA]:i.RGB5_A1},[H.UNSIGNED_INT_2_10_10_10_REV]:{[A.RGBA]:i.RGB10_A2,[A.RGBA_INTEGER]:i.RGB10_A2UI},[H.UNSIGNED_INT_10F_11F_11F_REV]:{[A.RGB]:i.R11F_G11F_B10F},[H.UNSIGNED_INT_5_9_9_9_REV]:{[A.RGB]:i.RGB9_E5},[H.UNSIGNED_INT_24_8]:{[A.DEPTH_STENCIL]:i.DEPTH24_STENCIL8},[H.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[A.DEPTH_STENCIL]:i.DEPTH32F_STENCIL8}}:t={[H.UNSIGNED_BYTE]:{[A.RGBA]:i.RGBA,[A.RGB]:i.RGB,[A.ALPHA]:i.ALPHA,[A.LUMINANCE]:i.LUMINANCE,[A.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[H.UNSIGNED_SHORT_5_6_5]:{[A.RGB]:i.RGB},[H.UNSIGNED_SHORT_4_4_4_4]:{[A.RGBA]:i.RGBA},[H.UNSIGNED_SHORT_5_5_5_1]:{[A.RGBA]:i.RGBA}},t}class al{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new W,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=am(t),this.samplerTypes=nm(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s<e;s++)this.boundTextures[s]=null;this.emptyTextures={};const r=new Qn(t.createTexture());t.bindTexture(t.TEXTURE_2D,r.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]=r,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new Qn(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,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 s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){const{gl:r}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,r.activeTexture(r.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(r.TEXTURE_2D,this.emptyTextures[r.TEXTURE_2D].texture),this.boundTextures[e]=null}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:r}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<r.length;s++)r[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<r.length;s++)r[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),r[s]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:r,CONTEXT_UID:s}=this;if(r)for(let n=t-1;n>=0;--n){const a=e[n];a&&a._glTextures[s].samplerType!==D.FLOAT&&this.renderer.texture.unbind(a)}}initTexture(t){const e=new Qn(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 r;e.internalFormat=((r=this.internalFormats[t.type])==null?void 0:r[t.format])??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??D.FLOAT,this.webGLVersion===2&&t.type===H.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var s;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const r=this.renderer;if(this.initTextureType(t,e),(s=t.resource)==null?void 0:s.upload(r,t,e))e.samplerType!==D.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,a=t.realHeight,o=r.gl;(e.width!==n||e.height!==a||e.dirtyId<0)&&(e.width=n,e.height=a,o.texImage2D(t.target,0,e.internalFormat,n,a,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:r}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),r.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const s=this.managedTextures.indexOf(t);s!==-1&&Ai(this.managedTextures,s,1)}}updateTextureStyle(t){var r;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===ee.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Me.CLAMP:e.wrapMode=t.wrapMode,(r=t.resource)!=null&&r.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const r=this.gl;if(e.mipmap&&t.mipmap!==ee.ON_MANUAL&&r.generateMipmap(t.target),r.texParameteri(t.target,r.TEXTURE_WRAP_S,e.wrapMode),r.texParameteri(t.target,r.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){r.texParameteri(t.target,r.TEXTURE_MIN_FILTER,t.scaleMode===$t.LINEAR?r.LINEAR_MIPMAP_LINEAR:r.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===$t.LINEAR){const n=Math.min(t.anisotropicLevel,r.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));r.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else r.texParameteri(t.target,r.TEXTURE_MIN_FILTER,t.scaleMode===$t.LINEAR?r.LINEAR:r.NEAREST);r.texParameteri(t.target,r.TEXTURE_MAG_FILTER,t.scaleMode===$t.LINEAR?r.LINEAR:r.NEAREST)}destroy(){this.renderer=null}}al.extension={type:P.RendererSystem,name:"texture"},k.add(al);class ol{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:r}=this,s=t._glTransformFeedbacks[r]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:r,renderer:s}=this;e&&s.shader.bind(e),r.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:r,CONTEXT_UID:s}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[s]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let a=0;a<t.buffers.length;a++){const o=t.buffers[a];o&&(r.buffer.update(o),o._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,a,o._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const r=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let a=0;a<t.buffers.length;a++){const o=t.buffers[a];if(!o)continue;const h=o._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&n.dispose(o,e))}r&&(e||s.deleteTransformFeedback(r),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}ol.extension={type:P.RendererSystem,name:"transformFeedback"},k.add(ol);class is{constructor(t){this.renderer=t}init(t){this.screen=new Y(0,0,t.width,t.height),this.element=t.view||F.ADAPTER.createCanvas(),this.resolution=t.resolution||F.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 r=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=r,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${r}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",r,s),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&((e=this.element.parentNode)==null||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}is.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},is.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"_view"},k.add(is),F.PREFER_ENV=yt.WEBGL2,F.STRICT_TEXTURE_CACHE=!1,F.RENDER_OPTIONS={...Zr.defaultOptions,...Kr.defaultOptions,...is.defaultOptions,...es.defaultOptions},Object.defineProperties(F,{WRAP_MODE:{get(){return W.defaultOptions.wrapMode},set(i){K("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),W.defaultOptions.wrapMode=i}},SCALE_MODE:{get(){return W.defaultOptions.scaleMode},set(i){K("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),W.defaultOptions.scaleMode=i}},MIPMAP_TEXTURES:{get(){return W.defaultOptions.mipmap},set(i){K("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),W.defaultOptions.mipmap=i}},ANISOTROPIC_LEVEL:{get(){return W.defaultOptions.anisotropicLevel},set(i){K("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),W.defaultOptions.anisotropicLevel=i}},FILTER_RESOLUTION:{get(){return K("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Bt.defaultResolution},set(i){Bt.defaultResolution=i}},FILTER_MULTISAMPLE:{get(){return K("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Bt.defaultMultisample},set(i){Bt.defaultMultisample=i}},SPRITE_MAX_TEXTURES:{get(){return ri.defaultMaxTextures},set(i){K("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),ri.defaultMaxTextures=i}},SPRITE_BATCH_SIZE:{get(){return ri.defaultBatchSize},set(i){K("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),ri.defaultBatchSize=i}},CAN_UPLOAD_SAME_BUFFER:{get(){return ri.canUploadSameBuffer},set(i){K("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),ri.canUploadSameBuffer=i}},GC_MODE:{get(){return ai.defaultMode},set(i){K("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),ai.defaultMode=i}},GC_MAX_IDLE:{get(){return ai.defaultMaxIdle},set(i){K("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),ai.defaultMaxIdle=i}},GC_MAX_CHECK_COUNT:{get(){return ai.defaultCheckCountMax},set(i){K("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),ai.defaultCheckCountMax=i}},PRECISION_VERTEX:{get(){return Ee.defaultVertexPrecision},set(i){K("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Ee.defaultVertexPrecision=i}},PRECISION_FRAGMENT:{get(){return Ee.defaultFragmentPrecision},set(i){K("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Ee.defaultFragmentPrecision=i}}});var Se=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(Se||{});class ta{constructor(t,e=null,r=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=r,this.once=s}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 hl=class kt{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new ta(null,null,1/0),this.deltaMS=1/kt.targetFPMS,this.elapsedMS=1/kt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,r=Se.NORMAL){return this._addListener(new ta(t,e,r))}addOnce(t,e,r=Se.NORMAL){return this._addListener(new ta(t,e,r,!0))}_addListener(t){let e=this._head.next,r=this._head;if(!e)t.connect(r);else{for(;e;){if(t.priority>e.priority){t.connect(r);break}r=e,e=e.next}t.previous||t.connect(r)}return this._startIfPossible(),this}remove(t,e){let r=this._head.next;for(;r;)r.match(t,e)?r=r.destroy():r=r.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*kt.targetFPMS;const r=this._head;let s=r.next;for(;s;)s=s.emit(this.deltaTime);r.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),r=Math.min(Math.max(0,e)/1e3,kt.targetFPMS);this._maxElapsedMS=1/r}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!kt._shared){const t=kt._shared=new kt;t.autoStart=!0,t._protected=!0}return kt._shared}static get system(){if(!kt._system){const t=kt._system=new kt;t.autoStart=!0,t._protected=!0}return kt._system}};hl.targetFPMS=.06;let dt=hl;Object.defineProperties(F,{TARGET_FPMS:{get(){return dt.targetFPMS},set(i){K("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),dt.targetFPMS=i}}});class ll{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Se.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?dt.shared:new dt,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}ll.extension=P.Application,k.add(ll);const cl=[];k.handleByList(P.Renderer,cl);function om(i){for(const t of cl)if(t.test(i))return new t(i);throw new Error("Unable to auto-detect a suitable renderer.")}var hm=`attribute vec2 aVertexPosition;
|
|
490
|
-
attribute vec2 aTextureCoord;
|
|
491
|
-
|
|
492
|
-
uniform mat3 projectionMatrix;
|
|
105
|
+
`,up=`in vec2 aPosition;
|
|
493
106
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
void main(void)
|
|
497
|
-
{
|
|
498
|
-
gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
499
|
-
vTextureCoord = aTextureCoord;
|
|
500
|
-
}`,lm=`attribute vec2 aVertexPosition;
|
|
501
|
-
|
|
502
|
-
uniform mat3 projectionMatrix;
|
|
107
|
+
out vec2 vTextureCoord;
|
|
108
|
+
out vec2 vMaskCoord;
|
|
503
109
|
|
|
504
|
-
varying vec2 vTextureCoord;
|
|
505
110
|
|
|
506
|
-
uniform vec4
|
|
507
|
-
uniform vec4
|
|
111
|
+
uniform vec4 uInputSize;
|
|
112
|
+
uniform vec4 uOutputFrame;
|
|
113
|
+
uniform vec4 uOutputTexture;
|
|
114
|
+
uniform mat3 uFilterMatrix;
|
|
508
115
|
|
|
509
|
-
vec4 filterVertexPosition(
|
|
116
|
+
vec4 filterVertexPosition( vec2 aPosition )
|
|
510
117
|
{
|
|
511
|
-
vec2 position =
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
118
|
+
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
119
|
+
|
|
120
|
+
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
121
|
+
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
515
122
|
|
|
516
|
-
|
|
517
|
-
{
|
|
518
|
-
return aVertexPosition * (outputFrame.zw * inputSize.zw);
|
|
123
|
+
return vec4(position, 0.0, 1.0);
|
|
519
124
|
}
|
|
520
125
|
|
|
521
|
-
|
|
126
|
+
vec2 filterTextureCoord( vec2 aPosition )
|
|
522
127
|
{
|
|
523
|
-
|
|
524
|
-
vTextureCoord = filterTextureCoord();
|
|
128
|
+
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
525
129
|
}
|
|
526
|
-
`;const cm=hm,ul=lm;class dl{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const r=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,r)}else{const r=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,r)}e>=pt.HIGH?this.multisample=pt.HIGH:e>=pt.MEDIUM?this.multisample=pt.MEDIUM:e>=pt.LOW?this.multisample=pt.LOW:this.multisample=pt.NONE}destroy(){}}dl.extension={type:P.RendererSystem,name:"_multisample"},k.add(dl);class um{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class fl{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:r}=this,s=t._glBuffers[r]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:r,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,r.bindBufferBase(r.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,r){const{gl:s,CONTEXT_UID:n}=this;r=r||0;const a=t._glBuffers[n]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,a.buffer,r*256,256)}update(t){const{gl:e,CONTEXT_UID:r}=this,s=t._glBuffers[r]||this.createGLBuffer(t);if(t._updateID!==s.updateID)if(s.updateID=t._updateID,e.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const r=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),r&&(e||s.deleteBuffer(r.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let r=0;r<e.length;r++)this.dispose(this.managedBuffers[e[r]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:r}=this;return t._glBuffers[e]=new um(r.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}fl.extension={type:P.RendererSystem,name:"buffer"},k.add(fl);class pl{constructor(t){this.renderer=t}render(t,e){const r=this.renderer;let s,n,a,o;if(e&&(s=e.renderTexture,n=e.clear,a=e.transform,o=e.skipUpdateTransform),this.renderingToScreen=!s,r.runners.prerender.emit(),r.emit("prerender"),r.projection.transform=a,!r.context.isLost){if(s||(this.lastObjectRendered=t),!o){const h=t.enableTempParent();t.updateTransform(),t.disableTempParent(h)}r.renderTexture.bind(s),r.batch.currentRenderer.start(),(n??r.background.clearBeforeRender)&&r.renderTexture.clear(),t.render(r),r.batch.currentRenderer.flush(),s&&(e.blit&&r.framebuffer.blit(),s.baseTexture.update()),r.runners.postrender.emit(),r.projection.transform=null,r.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}pl.extension={type:P.RendererSystem,name:"objectRenderer"},k.add(pl);const rs=class ka extends sm{constructor(t){super(),this.type=Pe.WEBGL,t=Object.assign({},F.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new Vt({projectionMatrix:new rt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:ka.__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&&(K("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=ka.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:Df()}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 K("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return K("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return K("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return K("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){K("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return K("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){K("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return K("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)}};rs.extension={type:P.Renderer,priority:1},rs.__plugins={},rs.__systems={};let ss=rs;k.handleByMap(P.RendererPlugin,ss.__plugins),k.handleByMap(P.RendererSystem,ss.__systems),k.add(ss);class ml extends er{constructor(t,e){const{width:r,height:s}=e||{};super(r,s),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const a=new W;this.items.push(a),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let r=0;r<this.length;r++)t[r]&&(t[r].castToBaseTexture?this.addBaseTextureAt(t[r].castToBaseTexture(),r):t[r]instanceof er?this.addResourceAt(t[r],r):this.addResourceAt(Th(t[r],e),r))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{const{realWidth:e,realHeight:r}=this.items[0];return this.resize(e,r),this.update(),Promise.resolve(this)}),this._load}}class dm extends ml{constructor(t,e){const{width:r,height:s}=e||{};let n,a;Array.isArray(t)?(n=t,a=t.length):a=t,super(a,{width:r,height:s}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=ui.TEXTURE_2D_ARRAY}upload(t,e,r){const{length:s,itemDirtyIds:n,items:a}=this,{gl:o}=t;r.dirtyId<0&&o.texImage3D(o.TEXTURE_2D_ARRAY,0,r.internalFormat,this._width,this._height,s,0,e.format,r.type,null);for(let h=0;h<s;h++){const l=a[h];n[h]<l.dirtyId&&(n[h]=l.dirtyId,l.valid&&o.texSubImage3D(o.TEXTURE_2D_ARRAY,0,0,0,h,l.resource.width,l.resource.height,1,e.format,r.type,l.resource.source))}return!0}}class fm extends Ae{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const gl=class gr extends ml{constructor(t,e){const{width:r,height:s,autoLoad:n,linkBaseTexture:a}=e||{};if(t&&t.length!==gr.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:r,height:s});for(let o=0;o<gr.SIDES;o++)this.items[o].target=ui.TEXTURE_CUBE_MAP_POSITIVE_X+o;this.linkBaseTexture=a!==!1,t&&this.initFromArray(t,e),n!==!1&&this.load()}bind(t){super.bind(t),t.target=ui.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,r){if(r===void 0&&(r=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=ui.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,r){const s=this.itemDirtyIds;for(let n=0;n<gr.SIDES;n++){const a=this.items[n];(s[n]<a.dirtyId||r.dirtyId<e.dirtyId)&&(a.valid&&a.resource?(a.resource.upload(t,a,r),s[n]=a.dirtyId):s[n]<-1&&(t.gl.texImage2D(a.target,0,r.internalFormat,e.realWidth,e.realHeight,0,e.format,r.type,null),s[n]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===gr.SIDES}};gl.SIDES=6;let pm=gl;class Ii extends Ae{constructor(t,e){e=e||{};let r,s,n;typeof t=="string"?(r=Ii.EMPTY,s=t,n=!0):(r=t,s=null,n=!1),super(r),this.url=s,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??n,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{const r=await F.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await r.blob();if(this.destroyed)return;const n=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Ot.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(r){if(this.destroyed)return;e(r),this.onError.emit(r)}}),this._load)}upload(t,e,r){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,r)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return Ii._EMPTY=Ii._EMPTY??F.ADAPTER.createCanvas(0,0),Ii._EMPTY}}const ea=class Ns extends Ae{constructor(t,e){e=e||{},super(F.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},Ns.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;Ae.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,r=t.height;if(!e||!r)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,n=r*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/r*e,n=this._overrideHeight||this._overrideWidth/e*r),s=Math.round(s),n=Math.round(n);const a=this.source;a.width=s,a.height=n,a._pixiId=`canvas_${Ze()}`,a.getContext("2d").drawImage(t,0,0,e,r,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(t){const e=Ns.SVG_SIZE.exec(t),r={};return e&&(r[e[1]]=Math.round(parseFloat(e[3])),r[e[5]]=Math.round(parseFloat(e[7]))),r}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&Ns.SVG_XML.test(t)}};ea.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,ea.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let ia=ea;class mm extends Ae{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const ra=class Ua extends Ae{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const r=document.createElement("video");e.autoLoad!==!1&&r.setAttribute("preload","auto"),e.playsinline!==!1&&(r.setAttribute("webkit-playsinline",""),r.setAttribute("playsinline","")),e.muted===!0&&(r.setAttribute("muted",""),r.muted=!0),e.loop===!0&&r.setAttribute("loop",""),e.autoPlay!==!1&&r.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const s=t[0].src||t[0];Ae.crossOrigin(r,s,e.crossorigin);for(let n=0;n<t.length;++n){const a=document.createElement("source");let{src:o,mime:h}=t[n];if(o=o||t[n],o.startsWith("data:"))h=o.slice(5,o.indexOf(";"));else if(!o.startsWith("blob:")){const l=o.split("?").shift().toLowerCase(),c=l.slice(l.lastIndexOf(".")+1);h=h||Ua.MIME_TYPES[c]||`video/${c}`}a.src=o,h&&(a.type=h),r.appendChild(a)}t=r}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const e=dt.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const t=this.source;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,r)=>{this.valid?e(this):(this._resolve=e,this._reject=r,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(dt.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(dt.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(dt.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||Ua.TYPES.includes(e)}};ra.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],ra.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let yl=ra;Un.push(Ii,Nh,fm,yl,mm,ia,kr,pm,dm);class ns{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?Y.EMPTY:(t=t||new Y(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:r,b:s,c:n,d:a,tx:o,ty:h}=t,l=r*e.x+n*e.y+o,c=s*e.x+a*e.y+h;this.minX=Math.min(this.minX,l),this.maxX=Math.max(this.maxX,l),this.minY=Math.min(this.minY,c),this.maxY=Math.max(this.maxY,c)}addQuad(t){let e=this.minX,r=this.minY,s=this.maxX,n=this.maxY,a=t[0],o=t[1];e=a<e?a:e,r=o<r?o:r,s=a>s?a:s,n=o>n?o:n,a=t[2],o=t[3],e=a<e?a:e,r=o<r?o:r,s=a>s?a:s,n=o>n?o:n,a=t[4],o=t[5],e=a<e?a:e,r=o<r?o:r,s=a>s?a:s,n=o>n?o:n,a=t[6],o=t[7],e=a<e?a:e,r=o<r?o:r,s=a>s?a:s,n=o>n?o:n,this.minX=e,this.minY=r,this.maxX=s,this.maxY=n}addFrame(t,e,r,s,n){this.addFrameMatrix(t.worldTransform,e,r,s,n)}addFrameMatrix(t,e,r,s,n){const a=t.a,o=t.b,h=t.c,l=t.d,c=t.tx,u=t.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,g=a*e+h*r+c,_=o*e+l*r+u;d=g<d?g:d,f=_<f?_:f,p=g>p?g:p,m=_>m?_:m,g=a*s+h*r+c,_=o*s+l*r+u,d=g<d?g:d,f=_<f?_:f,p=g>p?g:p,m=_>m?_:m,g=a*e+h*n+c,_=o*e+l*n+u,d=g<d?g:d,f=_<f?_:f,p=g>p?g:p,m=_>m?_:m,g=a*s+h*n+c,_=o*s+l*n+u,d=g<d?g:d,f=_<f?_:f,p=g>p?g:p,m=_>m?_:m,this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}addVertexData(t,e,r){let s=this.minX,n=this.minY,a=this.maxX,o=this.maxY;for(let h=e;h<r;h+=2){const l=t[h],c=t[h+1];s=l<s?l:s,n=c<n?c:n,a=l>a?l:a,o=c>o?c:o}this.minX=s,this.minY=n,this.maxX=a,this.maxY=o}addVertices(t,e,r,s){this.addVerticesMatrix(t.worldTransform,e,r,s)}addVerticesMatrix(t,e,r,s,n=0,a=n){const o=t.a,h=t.b,l=t.c,c=t.d,u=t.tx,d=t.ty;let f=this.minX,p=this.minY,m=this.maxX,g=this.maxY;for(let _=r;_<s;_+=2){const x=e[_],y=e[_+1],v=o*x+l*y+u,T=c*y+h*x+d;f=Math.min(f,v-n),m=Math.max(m,v+n),p=Math.min(p,T-a),g=Math.max(g,T+a)}this.minX=f,this.minY=p,this.maxX=m,this.maxY=g}addBounds(t){const e=this.minX,r=this.minY,s=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<r?t.minY:r,this.maxX=t.maxX>s?t.maxX:s,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const r=t.minX>e.minX?t.minX:e.minX,s=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,a=t.maxY<e.maxY?t.maxY:e.maxY;if(r<=n&&s<=a){const o=this.minX,h=this.minY,l=this.maxX,c=this.maxY;this.minX=r<o?r:o,this.minY=s<h?s:h,this.maxX=n>l?n:l,this.maxY=a>c?a:c}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const r=t.minX>e.x?t.minX:e.x,s=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,a=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(r<=n&&s<=a){const o=this.minX,h=this.minY,l=this.maxX,c=this.maxY;this.minX=r<o?r:o,this.minY=s<h?s:h,this.maxX=n>l?n:l,this.maxY=a>c?a:c}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,r,s,n,a){t-=n,e-=a,r+=n,s+=a,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>r?this.maxX:r,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>s?this.maxY:s}}class lt extends Xi{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new zn,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 ns,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 r=0;r<e.length;++r){const s=e[r];Object.defineProperty(lt.prototype,s,Object.getOwnPropertyDescriptor(t,s))}}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 Y),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new Y),t=this._localBoundsRect),this._localBounds||(this._localBounds=new ns);const e=this.transform,r=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(r==null?void 0:r.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const s=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const a=this.getBounds(!1,t);return this.parent=r,this.transform=e,this._bounds=s,this._bounds.updateID+=this._boundsID-n,a}toGlobal(t,e,r=!1){return r||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,r,s){return e&&(t=e.toGlobal(t,r,s)),s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,r)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,e=0,r=1,s=1,n=0,a=0,o=0,h=0,l=0){return this.position.x=t,this.position.y=e,this.scale.x=r||1,this.scale.y=s||1,this.rotation=n,this.skew.x=a,this.skew.y=o,this.pivot.x=h,this.pivot.y=l,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new gm),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*hp}set angle(t){this.transform.rotation=t*lp}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount--,e._maskRefCount===0&&(e.renderable=!0,e.isMask=!1))}if(this._mask=t,this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount===0&&(e.renderable=!1,e.isMask=!0),e._maskRefCount++)}}}}class gm extends lt{constructor(){super(...arguments),this.sortDirty=null}}lt.prototype.displayObjectUpdateTransform=lt.prototype.updateTransform;const ym=new rt;function _m(i,t){return i.zIndex===t.zIndex?i._lastSortedIndex-t._lastSortedIndex:i.zIndex-t.zIndex}const _l=class Ga extends lt{constructor(){super(),this.children=[],this.sortableChildren=Ga.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 r=this.getChildIndex(t),s=this.getChildIndex(e);this.children[r]=e,this.children[s]=t,this.onChildrenChange(r<s?r:s)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const r=this.getChildIndex(t);Ai(this.children,r,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],r=this.children.indexOf(e);if(r===-1)return null;e.parent=null,e.transform._parentID=-1,Ai(this.children,r,1),this._boundsID++,this.onChildrenChange(r),e.emit("removed",this),this.emit("childRemoved",e,this,r)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,Ai(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 r=t,s=e,n=s-r;let a;if(n>0&&n<=s){a=this.children.splice(r,n);for(let o=0;o<a.length;++o)a[o].parent=null,a[o].transform&&(a[o].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let o=0;o<a.length;++o)a[o].emit("removed",this),this.emit("childRemoved",a[o],this,o);return a}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,r=this.children.length;e<r;++e){const s=this.children[e];s._lastSortedIndex=e,!t&&s.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(_m),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 r=this.children[t];r.visible&&r.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 r=e._mask.isMaskData?e._mask.maskObject:e._mask;r?(r.calculateBounds(),this._bounds.addBoundsMask(e._bounds,r._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 r=super.getLocalBounds(t);if(!e)for(let s=0,n=this.children.length;s<n;++s){const a=this.children[s];a.visible&&a.updateTransform()}return r}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let r,s;this.cullArea?(r=this.cullArea,s=this.worldTransform):this._render!==Ga.prototype._render&&(r=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=ym.copyFrom(s),s.prepend(n)):s=n),r&&e.intersects(r,s))this._render(t);else if(this.cullArea)return;for(let a=0,o=this.children.length;a<o;++a){const h=this.children[a],l=h.cullable;h.cullable=l||!this.cullArea,h.render(t),h.cullable=l}}render(t){var e;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(e=this.filters)!=null&&e.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let r=0,s=this.children.length;r<s;++r)this.children[r].render(t)}}renderAdvanced(t){var n,a,o;const e=this.filters,r=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let h=0;h<e.length;h++)e[h].enabled&&this._enabledFilters.push(e[h])}const s=e&&((n=this._enabledFilters)==null?void 0:n.length)||r&&(!r.isMaskData||r.enabled&&(r.autoDetect||r.type!==_t.NONE));if(s&&t.batch.flush(),e&&((a=this._enabledFilters)!=null&&a.length)&&t.filter.push(this,this._enabledFilters),r&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let h=0,l=this.children.length;h<l;++h)this.children[h].render(t)}s&&t.batch.flush(),r&&t.mask.pop(this),e&&((o=this._enabledFilters)!=null&&o.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t==null?void 0:t.children,r=this.removeChildren(0,this.children.length);if(e)for(let s=0;s<r.length;++s)r[s].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}};_l.defaultSortableChildren=!1;let bt=_l;bt.prototype.containerUpdateTransform=bt.prototype.updateTransform,Object.defineProperties(F,{SORTABLE_CHILDREN:{get(){return bt.defaultSortableChildren},set(i){K("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),bt.defaultSortableChildren=i}}});const ar=new J,vm=new Uint16Array([0,1,2,0,2,3]);class ue extends bt{constructor(t){super(),this._anchor=new we(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 tt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=z.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||L.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=vm,this.pluginName="batch",this.isSprite=!0,this._roundPixels=F.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=Oe(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=Oe(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,r=e.a,s=e.b,n=e.c,a=e.d,o=e.tx,h=e.ty,l=this.vertexData,c=t.trim,u=t.orig,d=this._anchor;let f=0,p=0,m=0,g=0;if(c?(p=c.x-d._x*u.width,f=p+c.width,g=c.y-d._y*u.height,m=g+c.height):(p=-d._x*u.width,f=p+u.width,g=-d._y*u.height,m=g+u.height),l[0]=r*p+n*g+o,l[1]=a*g+s*p+h,l[2]=r*f+n*g+o,l[3]=a*g+s*f+h,l[4]=r*f+n*m+o,l[5]=a*m+s*f+h,l[6]=r*p+n*m+o,l[7]=a*m+s*p+h,this._roundPixels){const _=F.RESOLUTION;for(let x=0;x<l.length;++x)l[x]=Math.round(l[x]*_)/_}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,r=t.orig,s=this._anchor,n=this.transform.worldTransform,a=n.a,o=n.b,h=n.c,l=n.d,c=n.tx,u=n.ty,d=-s._x*r.width,f=d+r.width,p=-s._y*r.height,m=p+r.height;if(e[0]=a*d+h*p+c,e[1]=l*p+o*d+u,e[2]=a*f+h*p+c,e[3]=l*p+o*f+u,e[4]=a*f+h*m+c,e[5]=l*m+o*f+u,e[6]=a*d+h*m+c,e[7]=l*m+o*d+u,this._roundPixels){const g=F.RESOLUTION;for(let _=0;_<e.length;++_)e[_]=Math.round(e[_]*g)/g}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new ns),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 Y),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,ar);const e=this._texture.orig.width,r=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return ar.x>=s&&ar.x<s+e&&(n=-r*this.anchor.y,ar.y>=n&&ar.y<n+r)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const r=t instanceof L?t:L.from(t,e);return new ue(r)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=Oe(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=Oe(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||L.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const vl=new rt;lt.prototype._cacheAsBitmap=!1,lt.prototype._cacheData=null,lt.prototype._cacheAsBitmapResolution=null,lt.prototype._cacheAsBitmapMultisample=null;class xm{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(lt.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(i){i!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=i,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(i){i!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=i,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(i){if(this._cacheAsBitmap===i)return;this._cacheAsBitmap=i;let t;i?(this._cacheData||(this._cacheData=new xm),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}}),lt.prototype._renderCached=function(i){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(i),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(i))},lt.prototype._initCachedDisplayObject=function(i){var d,f;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,i.batch.flush();const e=this.getLocalBounds(new Y,!0);if((f=this.filters)!=null&&f.length){const p=this.filters[0].padding;e.pad(p)}const r=this.cacheAsBitmapResolution||i.resolution;e.ceil(r),e.width=Math.max(e.width,1/r),e.height=Math.max(e.height,1/r);const s=i.renderTexture.current,n=i.renderTexture.sourceFrame.clone(),a=i.renderTexture.destinationFrame.clone(),o=i.projection.transform,h=si.create({width:e.width,height:e.height,resolution:r,multisample:this.cacheAsBitmapMultisample??i.multisample}),l=`cacheAsBitmap_${Ze()}`;this._cacheData.textureCacheId=l,W.addToCache(h.baseTexture,l),L.addToCache(h,l);const c=this.transform.localTransform.copyTo(vl).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,i.render(this,{renderTexture:h,clear:!0,transform:c,skipUpdateTransform:!1}),i.framebuffer.blit(),i.projection.transform=o,i.renderTexture.bind(s,n,a),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const u=new ue(h);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(e.x/e.width),u.anchor.y=-(e.y/e.height),u.alpha=t,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=u.containsPoint.bind(u)},lt.prototype._renderCachedCanvas=function(i){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(i),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(i))},lt.prototype._initCachedDisplayObjectCanvas=function(i){var c;if((c=this._cacheData)!=null&&c.sprite)return;const t=this.getLocalBounds(new Y,!0),e=this.alpha;this.alpha=1;const r=i.canvasContext.activeContext,s=i._projTransform,n=this.cacheAsBitmapResolution||i.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const a=si.create({width:t.width,height:t.height,resolution:n}),o=`cacheAsBitmap_${Ze()}`;this._cacheData.textureCacheId=o,W.addToCache(a.baseTexture,o),L.addToCache(a,o);const h=vl;this.transform.localTransform.copyTo(h),h.invert(),h.tx-=t.x,h.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,i.render(this,{renderTexture:a,clear:!0,transform:h,skipUpdateTransform:!1}),i.canvasContext.activeContext=r,i._projTransform=s,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=e;const l=new ue(a);l.transform.worldTransform=this.transform.worldTransform,l.anchor.x=-(t.x/t.width),l.anchor.y=-(t.y/t.height),l.alpha=e,l._bounds=this._bounds,this._cacheData.sprite=l,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=i._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=l.containsPoint.bind(l)},lt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},lt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},lt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,W.removeFromCache(this._cacheData.textureCacheId),L.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},lt.prototype._cacheAsBitmapDestroy=function(i){this.cacheAsBitmap=!1,this.destroy(i)},lt.prototype.name=null,bt.prototype.getChildByName=function(i,t){for(let e=0,r=this.children.length;e<r;e++)if(this.children[e].name===i)return this.children[e];if(t)for(let e=0,r=this.children.length;e<r;e++){const s=this.children[e];if(!s.getChildByName)continue;const n=s.getChildByName(i,!0);if(n)return n}return null},lt.prototype.getGlobalPosition=function(i=new J,t=!1){return this.parent?this.parent.toGlobal(this.position,i,t):(i.x=this.position.x,i.y=this.position.y),i};var bm=`varying vec2 vTextureCoord;
|
|
527
|
-
|
|
528
|
-
uniform sampler2D uSampler;
|
|
529
|
-
uniform float uAlpha;
|
|
530
130
|
|
|
531
|
-
|
|
131
|
+
vec2 getFilterCoord( vec2 aPosition )
|
|
532
132
|
{
|
|
533
|
-
|
|
534
|
-
}
|
|
535
|
-
`;class Tm extends Bt{constructor(t=1){super(cm,bm,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const wm={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]},Em=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
|
|
536
|
-
`);function Am(i){const t=wm[i],e=t.length;let r=Em,s="";const n="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let a;for(let o=0;o<i;o++){let h=n.replace("%index%",o.toString());a=o,o>=e&&(a=i-o-1),h=h.replace("%value%",t[a].toString()),s+=h,s+=`
|
|
537
|
-
`}return r=r.replace("%blur%",s),r=r.replace("%size%",i.toString()),r}const Sm=`
|
|
538
|
-
attribute vec2 aVertexPosition;
|
|
539
|
-
|
|
540
|
-
uniform mat3 projectionMatrix;
|
|
541
|
-
|
|
542
|
-
uniform float strength;
|
|
543
|
-
|
|
544
|
-
varying vec2 vBlurTexCoords[%size%];
|
|
545
|
-
|
|
546
|
-
uniform vec4 inputSize;
|
|
547
|
-
uniform vec4 outputFrame;
|
|
548
|
-
|
|
549
|
-
vec4 filterVertexPosition( void )
|
|
550
|
-
{
|
|
551
|
-
vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
|
|
552
|
-
|
|
553
|
-
return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
vec2 filterTextureCoord( void )
|
|
557
|
-
{
|
|
558
|
-
return aVertexPosition * (outputFrame.zw * inputSize.zw);
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
void main(void)
|
|
562
|
-
{
|
|
563
|
-
gl_Position = filterVertexPosition();
|
|
564
|
-
|
|
565
|
-
vec2 textureCoord = filterTextureCoord();
|
|
566
|
-
%blur%
|
|
567
|
-
}`;function Cm(i,t){const e=Math.ceil(i/2);let r=Sm,s="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let a=0;a<i;a++){let o=n.replace("%index%",a.toString());o=o.replace("%sampleIndex%",`${a-(e-1)}.0`),s+=o,s+=`
|
|
568
|
-
`}return r=r.replace("%blur%",s),r=r.replace("%size%",i.toString()),r}class sa extends Bt{constructor(t,e=8,r=4,s=Bt.defaultResolution,n=5){const a=Cm(n,t),o=Am(n);super(a,o),this.horizontal=t,this.resolution=s,this._quality=0,this.quality=r,this.blur=e}apply(t,e,r,s){if(r?this.horizontal?this.uniforms.strength=1/r.width*(r.width/e.width):this.uniforms.strength=1/r.height*(r.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,e,r,s);else{const n=t.getFilterTexture(),a=t.renderer;let o=e,h=n;this.state.blend=!1,t.applyFilter(this,o,h,ie.CLEAR);for(let l=1;l<this.passes-1;l++){t.bindAndClear(o,ie.BLIT),this.uniforms.uSampler=h;const c=h;h=o,o=c,a.shader.bind(this),a.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,h,r,s),t.returnFilterTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class Im extends Bt{constructor(t=8,e=4,r=Bt.defaultResolution,s=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new sa(!0,t,e,r,s),this.blurYFilter=new sa(!1,t,e,r,s),this.resolution=r,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,r,s){const n=Math.abs(this.blurXFilter.strength),a=Math.abs(this.blurYFilter.strength);if(n&&a){const o=t.getFilterTexture();this.blurXFilter.apply(t,e,o,ie.CLEAR),this.blurYFilter.apply(t,o,r,s),t.returnFilterTexture(o)}else a?this.blurYFilter.apply(t,e,r,s):this.blurXFilter.apply(t,e,r,s)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var Rm=`varying vec2 vTextureCoord;
|
|
569
|
-
uniform sampler2D uSampler;
|
|
570
|
-
uniform float m[20];
|
|
571
|
-
uniform float uAlpha;
|
|
133
|
+
return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
|
134
|
+
}
|
|
572
135
|
|
|
573
136
|
void main(void)
|
|
574
137
|
{
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
result.a = (m[15] * c.r);
|
|
608
|
-
result.a += (m[16] * c.g);
|
|
609
|
-
result.a += (m[17] * c.b);
|
|
610
|
-
result.a += (m[18] * c.a);
|
|
611
|
-
result.a += m[19];
|
|
612
|
-
|
|
613
|
-
vec3 rgb = mix(c.rgb, result.rgb, uAlpha);
|
|
614
|
-
|
|
615
|
-
// Premultiply alpha again.
|
|
616
|
-
rgb *= result.a;
|
|
617
|
-
|
|
618
|
-
gl_FragColor = vec4(rgb, result.a);
|
|
619
|
-
}
|
|
620
|
-
`;class na extends Bt{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(ul,Rm,t),this.alpha=1}_loadMatrix(t,e=!1){let r=t;e&&(this._multiply(r,this.uniforms.m,t),r=this._colorMatrix(r)),this.uniforms.m=r}_multiply(t,e,r){return t[0]=e[0]*r[0]+e[1]*r[5]+e[2]*r[10]+e[3]*r[15],t[1]=e[0]*r[1]+e[1]*r[6]+e[2]*r[11]+e[3]*r[16],t[2]=e[0]*r[2]+e[1]*r[7]+e[2]*r[12]+e[3]*r[17],t[3]=e[0]*r[3]+e[1]*r[8]+e[2]*r[13]+e[3]*r[18],t[4]=e[0]*r[4]+e[1]*r[9]+e[2]*r[14]+e[3]*r[19]+e[4],t[5]=e[5]*r[0]+e[6]*r[5]+e[7]*r[10]+e[8]*r[15],t[6]=e[5]*r[1]+e[6]*r[6]+e[7]*r[11]+e[8]*r[16],t[7]=e[5]*r[2]+e[6]*r[7]+e[7]*r[12]+e[8]*r[17],t[8]=e[5]*r[3]+e[6]*r[8]+e[7]*r[13]+e[8]*r[18],t[9]=e[5]*r[4]+e[6]*r[9]+e[7]*r[14]+e[8]*r[19]+e[9],t[10]=e[10]*r[0]+e[11]*r[5]+e[12]*r[10]+e[13]*r[15],t[11]=e[10]*r[1]+e[11]*r[6]+e[12]*r[11]+e[13]*r[16],t[12]=e[10]*r[2]+e[11]*r[7]+e[12]*r[12]+e[13]*r[17],t[13]=e[10]*r[3]+e[11]*r[8]+e[12]*r[13]+e[13]*r[18],t[14]=e[10]*r[4]+e[11]*r[9]+e[12]*r[14]+e[13]*r[19]+e[14],t[15]=e[15]*r[0]+e[16]*r[5]+e[17]*r[10]+e[18]*r[15],t[16]=e[15]*r[1]+e[16]*r[6]+e[17]*r[11]+e[18]*r[16],t[17]=e[15]*r[2]+e[16]*r[7]+e[17]*r[12]+e[18]*r[17],t[18]=e[15]*r[3]+e[16]*r[8]+e[17]*r[13]+e[18]*r[18],t[19]=e[15]*r[4]+e[16]*r[9]+e[17]*r[14]+e[18]*r[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 r=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(r,e)}tint(t,e){const[r,s,n]=tt.shared.setValue(t).toArray(),a=[r,0,0,0,0,0,s,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(a,e)}greyscale(t,e){const r=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(r,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const r=Math.cos(t),s=Math.sin(t),n=Math.sqrt,a=1/3,o=n(a),h=r+(1-r)*a,l=a*(1-r)-o*s,c=a*(1-r)+o*s,u=a*(1-r)+o*s,d=r+a*(1-r),f=a*(1-r)-o*s,p=a*(1-r)-o*s,m=a*(1-r)+o*s,g=r+a*(1-r),_=[h,l,c,0,0,u,d,f,0,0,p,m,g,0,0,0,0,0,1,0];this._loadMatrix(_,e)}contrast(t,e){const r=(t||0)+1,s=-.5*(r-1),n=[r,0,0,0,s,0,r,0,0,s,0,0,r,0,s,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const r=t*2/3+1,s=(r-1)*-.5,n=[r,s,s,0,0,s,r,s,0,0,s,s,r,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,r,s,n){t=t||.2,e=e||.15,r=r||16770432,s=s||3375104;const a=tt.shared,[o,h,l]=a.setValue(r).toArray(),[c,u,d]=a.setValue(s).toArray(),f=[.3,.59,.11,0,0,o,h,l,t,0,c,u,d,e,0,o-c,h-u,l-d,0,0];this._loadMatrix(f,n)}night(t,e){t=t||.1;const r=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(r,e)}predator(t,e){const r=[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(r,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}na.prototype.grayscale=na.prototype.greyscale;var Pm=`varying vec2 vFilterCoord;
|
|
621
|
-
varying vec2 vTextureCoord;
|
|
622
|
-
|
|
623
|
-
uniform vec2 scale;
|
|
624
|
-
uniform mat2 rotation;
|
|
625
|
-
uniform sampler2D uSampler;
|
|
626
|
-
uniform sampler2D mapSampler;
|
|
627
|
-
|
|
628
|
-
uniform highp vec4 inputSize;
|
|
629
|
-
uniform vec4 inputClamp;
|
|
138
|
+
gl_Position = filterVertexPosition(aPosition);
|
|
139
|
+
vTextureCoord = filterTextureCoord(aPosition);
|
|
140
|
+
vMaskCoord = getFilterCoord(aPosition);
|
|
141
|
+
}
|
|
142
|
+
`,To=`struct GlobalFilterUniforms {
|
|
143
|
+
uInputSize:vec4<f32>,
|
|
144
|
+
uInputPixel:vec4<f32>,
|
|
145
|
+
uInputClamp:vec4<f32>,
|
|
146
|
+
uOutputFrame:vec4<f32>,
|
|
147
|
+
uGlobalFrame:vec4<f32>,
|
|
148
|
+
uOutputTexture:vec4<f32>,
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
struct MaskUniforms {
|
|
152
|
+
uFilterMatrix:mat3x3<f32>,
|
|
153
|
+
uMaskClamp:vec4<f32>,
|
|
154
|
+
uAlpha:f32,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
159
|
+
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
160
|
+
@group(0) @binding(2) var uSampler : sampler;
|
|
161
|
+
|
|
162
|
+
@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
|
|
163
|
+
@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
|
|
164
|
+
|
|
165
|
+
struct VSOutput {
|
|
166
|
+
@builtin(position) position: vec4<f32>,
|
|
167
|
+
@location(0) uv : vec2<f32>,
|
|
168
|
+
@location(1) filterUv : vec2<f32>,
|
|
169
|
+
};
|
|
630
170
|
|
|
631
|
-
|
|
171
|
+
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
632
172
|
{
|
|
633
|
-
|
|
173
|
+
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
634
174
|
|
|
635
|
-
|
|
636
|
-
|
|
175
|
+
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
176
|
+
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
637
177
|
|
|
638
|
-
|
|
178
|
+
return vec4(position, 0.0, 1.0);
|
|
639
179
|
}
|
|
640
|
-
`,Mm=`attribute vec2 aVertexPosition;
|
|
641
180
|
|
|
642
|
-
|
|
643
|
-
uniform mat3 filterMatrix;
|
|
644
|
-
|
|
645
|
-
varying vec2 vTextureCoord;
|
|
646
|
-
varying vec2 vFilterCoord;
|
|
647
|
-
|
|
648
|
-
uniform vec4 inputSize;
|
|
649
|
-
uniform vec4 outputFrame;
|
|
650
|
-
|
|
651
|
-
vec4 filterVertexPosition( void )
|
|
181
|
+
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
652
182
|
{
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
|
183
|
+
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
656
184
|
}
|
|
657
185
|
|
|
658
|
-
|
|
186
|
+
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
659
187
|
{
|
|
660
|
-
|
|
188
|
+
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
|
661
189
|
}
|
|
662
190
|
|
|
663
|
-
|
|
191
|
+
fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
|
|
664
192
|
{
|
|
665
|
-
|
|
666
|
-
vTextureCoord = filterTextureCoord();
|
|
667
|
-
vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;
|
|
193
|
+
return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
|
668
194
|
}
|
|
669
|
-
`;class Fm extends Bt{constructor(t,e){const r=new rt;t.renderable=!1,super(Mm,Pm,{mapSampler:t._texture,filterMatrix:r,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=r,e==null&&(e=20),this.scale=new J(e,e)}apply(t,e,r,s){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const n=this.maskSprite.worldTransform,a=Math.sqrt(n.a*n.a+n.b*n.b),o=Math.sqrt(n.c*n.c+n.d*n.d);a!==0&&o!==0&&(this.uniforms.rotation[0]=n.a/a,this.uniforms.rotation[1]=n.b/a,this.uniforms.rotation[2]=n.c/o,this.uniforms.rotation[3]=n.d/o),t.applyFilter(this,e,r,s)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var Bm=`varying vec2 v_rgbNW;
|
|
670
|
-
varying vec2 v_rgbNE;
|
|
671
|
-
varying vec2 v_rgbSW;
|
|
672
|
-
varying vec2 v_rgbSE;
|
|
673
|
-
varying vec2 v_rgbM;
|
|
674
|
-
|
|
675
|
-
varying vec2 vFragCoord;
|
|
676
|
-
uniform sampler2D uSampler;
|
|
677
|
-
uniform highp vec4 inputSize;
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
/**
|
|
681
|
-
Basic FXAA implementation based on the code on geeks3d.com with the
|
|
682
|
-
modification that the texture2DLod stuff was removed since it's
|
|
683
|
-
unsupported by WebGL.
|
|
684
|
-
|
|
685
|
-
--
|
|
686
|
-
|
|
687
|
-
From:
|
|
688
|
-
https://github.com/mitsuhiko/webgl-meincraft
|
|
689
|
-
|
|
690
|
-
Copyright (c) 2011 by Armin Ronacher.
|
|
691
|
-
|
|
692
|
-
Some rights reserved.
|
|
693
|
-
|
|
694
|
-
Redistribution and use in source and binary forms, with or without
|
|
695
|
-
modification, are permitted provided that the following conditions are
|
|
696
|
-
met:
|
|
697
|
-
|
|
698
|
-
* Redistributions of source code must retain the above copyright
|
|
699
|
-
notice, this list of conditions and the following disclaimer.
|
|
700
|
-
|
|
701
|
-
* Redistributions in binary form must reproduce the above
|
|
702
|
-
copyright notice, this list of conditions and the following
|
|
703
|
-
disclaimer in the documentation and/or other materials provided
|
|
704
|
-
with the distribution.
|
|
705
|
-
|
|
706
|
-
* The names of the contributors may not be used to endorse or
|
|
707
|
-
promote products derived from this software without specific
|
|
708
|
-
prior written permission.
|
|
709
|
-
|
|
710
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
711
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
712
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
713
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
714
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
715
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
716
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
717
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
718
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
719
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
720
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
721
|
-
*/
|
|
722
|
-
|
|
723
|
-
#ifndef FXAA_REDUCE_MIN
|
|
724
|
-
#define FXAA_REDUCE_MIN (1.0/ 128.0)
|
|
725
|
-
#endif
|
|
726
|
-
#ifndef FXAA_REDUCE_MUL
|
|
727
|
-
#define FXAA_REDUCE_MUL (1.0 / 8.0)
|
|
728
|
-
#endif
|
|
729
|
-
#ifndef FXAA_SPAN_MAX
|
|
730
|
-
#define FXAA_SPAN_MAX 8.0
|
|
731
|
-
#endif
|
|
732
|
-
|
|
733
|
-
//optimized version for mobile, where dependent
|
|
734
|
-
//texture reads can be a bottleneck
|
|
735
|
-
vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP,
|
|
736
|
-
vec2 v_rgbNW, vec2 v_rgbNE,
|
|
737
|
-
vec2 v_rgbSW, vec2 v_rgbSE,
|
|
738
|
-
vec2 v_rgbM) {
|
|
739
|
-
vec4 color;
|
|
740
|
-
vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;
|
|
741
|
-
vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;
|
|
742
|
-
vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;
|
|
743
|
-
vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;
|
|
744
|
-
vec4 texColor = texture2D(tex, v_rgbM);
|
|
745
|
-
vec3 rgbM = texColor.xyz;
|
|
746
|
-
vec3 luma = vec3(0.299, 0.587, 0.114);
|
|
747
|
-
float lumaNW = dot(rgbNW, luma);
|
|
748
|
-
float lumaNE = dot(rgbNE, luma);
|
|
749
|
-
float lumaSW = dot(rgbSW, luma);
|
|
750
|
-
float lumaSE = dot(rgbSE, luma);
|
|
751
|
-
float lumaM = dot(rgbM, luma);
|
|
752
|
-
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
|
|
753
|
-
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
|
|
754
|
-
|
|
755
|
-
mediump vec2 dir;
|
|
756
|
-
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
|
|
757
|
-
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
|
|
758
|
-
|
|
759
|
-
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *
|
|
760
|
-
(0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
|
|
761
|
-
|
|
762
|
-
float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
|
|
763
|
-
dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
|
|
764
|
-
max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
|
|
765
|
-
dir * rcpDirMin)) * inverseVP;
|
|
766
|
-
|
|
767
|
-
vec3 rgbA = 0.5 * (
|
|
768
|
-
texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +
|
|
769
|
-
texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);
|
|
770
|
-
vec3 rgbB = rgbA * 0.5 + 0.25 * (
|
|
771
|
-
texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +
|
|
772
|
-
texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);
|
|
773
|
-
|
|
774
|
-
float lumaB = dot(rgbB, luma);
|
|
775
|
-
if ((lumaB < lumaMin) || (lumaB > lumaMax))
|
|
776
|
-
color = vec4(rgbA, texColor.a);
|
|
777
|
-
else
|
|
778
|
-
color = vec4(rgbB, texColor.a);
|
|
779
|
-
return color;
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
void main() {
|
|
783
|
-
|
|
784
|
-
vec4 color;
|
|
785
|
-
|
|
786
|
-
color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
|
|
787
195
|
|
|
788
|
-
|
|
789
|
-
}
|
|
790
|
-
`,Dm=`
|
|
791
|
-
attribute vec2 aVertexPosition;
|
|
792
|
-
|
|
793
|
-
uniform mat3 projectionMatrix;
|
|
794
|
-
|
|
795
|
-
varying vec2 v_rgbNW;
|
|
796
|
-
varying vec2 v_rgbNE;
|
|
797
|
-
varying vec2 v_rgbSW;
|
|
798
|
-
varying vec2 v_rgbSE;
|
|
799
|
-
varying vec2 v_rgbM;
|
|
800
|
-
|
|
801
|
-
varying vec2 vFragCoord;
|
|
802
|
-
|
|
803
|
-
uniform vec4 inputSize;
|
|
804
|
-
uniform vec4 outputFrame;
|
|
805
|
-
|
|
806
|
-
vec4 filterVertexPosition( void )
|
|
196
|
+
fn getSize() -> vec2<f32>
|
|
807
197
|
{
|
|
808
|
-
vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
|
|
809
|
-
|
|
810
|
-
return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
|
811
|
-
}
|
|
812
198
|
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
199
|
+
|
|
200
|
+
return gfu.uGlobalFrame.zw;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@vertex
|
|
204
|
+
fn mainVertex(
|
|
205
|
+
@location(0) aPosition : vec2<f32>,
|
|
206
|
+
) -> VSOutput {
|
|
207
|
+
return VSOutput(
|
|
208
|
+
filterVertexPosition(aPosition),
|
|
209
|
+
filterTextureCoord(aPosition),
|
|
210
|
+
getFilterCoord(aPosition)
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
@fragment
|
|
215
|
+
fn mainFragment(
|
|
216
|
+
@location(0) uv: vec2<f32>,
|
|
217
|
+
@location(1) filterUv: vec2<f32>,
|
|
218
|
+
@builtin(position) position: vec4<f32>
|
|
219
|
+
) -> @location(0) vec4<f32> {
|
|
220
|
+
|
|
221
|
+
var maskClamp = filterUniforms.uMaskClamp;
|
|
222
|
+
|
|
223
|
+
var clip = step(3.5,
|
|
224
|
+
step(maskClamp.x, filterUv.x) +
|
|
225
|
+
step(maskClamp.y, filterUv.y) +
|
|
226
|
+
step(filterUv.x, maskClamp.z) +
|
|
227
|
+
step(filterUv.y, maskClamp.w));
|
|
228
|
+
|
|
229
|
+
var mask = textureSample(uMaskTexture, uSampler, filterUv);
|
|
230
|
+
var source = textureSample(uTexture, uSampler, uv);
|
|
231
|
+
|
|
232
|
+
var npmAlpha = 0.0;
|
|
233
|
+
|
|
234
|
+
var alphaMul = 1.0 - npmAlpha * (1.0 - mask.a);
|
|
235
|
+
|
|
236
|
+
var a = (alphaMul * mask.r) * clip;
|
|
237
|
+
|
|
238
|
+
return vec4(source.rgb, source.a) * a;
|
|
239
|
+
}`;class dp extends Xu{constructor(t){const{sprite:e,...i}=t,r=new In(e.texture),n=new xt({uFilterMatrix:{value:new I,type:"mat3x3<f32>"},uMaskClamp:{value:r.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"}}),a=Re.from({vertex:{source:To,entryPoint:"mainVertex"},fragment:{source:To,entryPoint:"mainFragment"}}),o=$e.from({vertex:up,fragment:lp,name:"mask-filter"});super({...i,gpuProgram:a,glProgram:o,resources:{filterUniforms:n,uMaskTexture:e.texture.source}}),this.sprite=e,this._textureMatrix=r}apply(t,e,i,r){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,i,r)}}class rs extends z{constructor(t){t instanceof se&&(t={context:t});const{context:e,roundPixels:i,...r}=t||{};super({label:"Graphics",...r}),this.canBundle=!0,this.renderPipeId="graphics",this._roundPixels=0,e?this._context=e:this._context=this._ownedContext=new se,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=i??!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(t){t.addBounds(this._context.bounds)}containsPoint(t){return this._context.containsPoint(t)}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}onViewUpdate(){if(this._didChangeId+=4096,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new rs(this._context.clone()):(this._ownedContext=null,new rs(this._context))}lineStyle(t,e,i){N(W,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const r={};return t&&(r.width=t),e&&(r.color=e),i&&(r.alpha=i),this.context.strokeStyle=r,this}beginFill(t,e){N(W,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return t&&(i.color=t),e&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){N(W,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return(t.width!==se.defaultStrokeStyle.width||t.color!==se.defaultStrokeStyle.color||t.alpha!==se.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return N(W,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return N(W,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return N(W,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return N(W,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return N(W,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return N(W,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const Ao=class yl extends Xs{constructor(...t){let e=t[0]??{};e instanceof Float32Array&&(N(W,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...yl.defaultOptions,...e};const i=e.positions||new Float32Array([0,0,1,0,1,1,0,1]),r=e.uvs||new Float32Array([0,0,1,0,1,1,0,1]),n=e.indices||new Uint32Array([0,1,2,0,2,3]),a=e.shrinkBuffersToFit,o=new kt({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:V.VERTEX|V.COPY_DST}),h=new kt({data:r,label:"attribute-mesh-uvs",shrinkToFit:a,usage:V.VERTEX|V.COPY_DST}),c=new kt({data:n,label:"index-mesh-buffer",shrinkToFit:a,usage:V.INDEX|V.COPY_DST});super({attributes:{aPosition:{buffer:o,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:h,format:"float32x2",stride:2*4,offset:0}},indexBuffer:c,topology:e.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};Ao.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let Rr=Ao;class ns extends Tt{constructor(t,e=!0){super(t[0]instanceof M?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&&(ot.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(ot.shared.add(this.update,this,de.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=t.deltaTime,i=this.animationSpeed*e,r=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=i/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];const a=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*a,this._currentTime+=a;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=i;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()):r!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<r||this.animationSpeed<0&&this.currentFrame>r)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(){this.stop(),super.destroy(),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let i=0;i<t.length;++i)e.push(M.from(t[i]));return new ns(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(M.from(t[i]));return new ns(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof M)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?(ot.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(ot.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class fp extends z{constructor(t,e){const{text:i,resolution:r,style:n,anchor:a,width:o,height:h,roundPixels:c,...l}=t;super({...l}),this.batched=!0,this.resolution=null,this._didTextUpdate=!0,this._roundPixels=0,this._bounds=new mt,this._boundsDirty=!0,this._styleClass=e,this.text=i??"",this.style=n,this.resolution=r??null,this.allowChildren=!1,this._anchor=new pt({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=c??!1,o&&(this.width=o),h&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}get style(){return this._style}set style(t){var e;t=t||{},(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){let i,r;typeof t!="object"?(i=t,r=e??t):(i=t.width,r=t.height??t.width),i!==void 0&&this._setWidth(i,this.bounds.width),r!==void 0&&this._setHeight(r,this.bounds.height)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds.maxX,i=this.bounds.maxY,r=-e*this.anchor.x;let n=0;return t.x>=r&&t.x<=r+e&&(n=-i*this.anchor.y,t.y>=n&&t.y<=n+i)}onViewUpdate(){if(this._didChangeId+=4096,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0,this._didTextUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_getKey(){return`${this.text}:${this._style.styleKey}`}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}}function pp(s,t){let e=s[0]??{};return(typeof e=="string"||s[1])&&(N(W,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:s[1]}),e}const mp=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Zs(s){const t=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize;let e=s.fontFamily;Array.isArray(s.fontFamily)||(e=s.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let r=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!mp.includes(r)&&(r=`"${r}"`),e[i]=r}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`}const kr={willReadFrequently:!0},Ft=class R{static get experimentalLetterSpacingSupported(){let t=R._experimentalLetterSpacingSupported;if(t!==void 0){const e=L.get().getCanvasRenderingContext2D().prototype;t=R._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,r,n,a,o,h,c){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=n,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=c}static measureText(t=" ",e,i=R._canvas,r=e.wordWrap){var x;const n=`${t}:${e.styleKey}`;if(R._measurementCache[n])return R._measurementCache[n];const a=Zs(e),o=R.measureFont(a);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const h=R.__context;h.font=a;const l=(r?R._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),u=new Array(l.length);let d=0;for(let y=0;y<l.length;y++){const v=R._measureText(l[y],e.letterSpacing,h);u[y]=v,d=Math.max(d,v)}const f=((x=e._stroke)==null?void 0:x.width)||0;let p=d+f;e.dropShadow&&(p+=e.dropShadow.distance);const g=e.lineHeight||o.fontSize+f;let m=Math.max(g,o.fontSize+f*2)+(l.length-1)*(g+e.leading);return e.dropShadow&&(m+=e.dropShadow.distance),new R(t,e,p,m,l,u,g+e.leading,d,o)}static _measureText(t,e,i){let r=!1;R.experimentalLetterSpacingSupported&&(R.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,r=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let n=i.measureText(t).width;return n>0&&(r?n-=e:n+=(R.graphemeSegmenter(t).length-1)*e),n}static _wordWrap(t,e,i=R._canvas){const r=i.getContext("2d",kr);let n=0,a="",o="";const h=Object.create(null),{letterSpacing:c,whiteSpace:l}=e,u=R._collapseSpaces(l),d=R._collapseNewlines(l);let f=!u;const p=e.wordWrapWidth+c,g=R._tokenize(t);for(let m=0;m<g.length;m++){let _=g[m];if(R._isNewline(_)){if(!d){o+=R._addLine(a),f=!u,a="",n=0;continue}_=" "}if(u){const y=R.isBreakingSpace(_),v=R.isBreakingSpace(a[a.length-1]);if(y&&v)continue}const x=R._getFromCache(_,c,h,r);if(x>p)if(a!==""&&(o+=R._addLine(a),a="",n=0),R.canBreakWords(_,e.breakWords)){const y=R.wordWrapSplit(_);for(let v=0;v<y.length;v++){let w=y[v],E=w,C=1;for(;y[v+C];){const S=y[v+C];if(!R.canBreakChars(E,S,_,v,e.breakWords))w+=S;else break;E=S,C++}v+=C-1;const P=R._getFromCache(w,c,h,r);P+n>p&&(o+=R._addLine(a),f=!1,a="",n=0),a+=w,n+=P}}else{a.length>0&&(o+=R._addLine(a),a="",n=0);const y=m===g.length-1;o+=R._addLine(_,!y),f=!1,a="",n=0}else x+n>p&&(f=!1,o+=R._addLine(a),a="",n=0),(a.length>0||!R.isBreakingSpace(_)||f)&&(a+=_,n+=x)}return o+=R._addLine(a,!1),o}static _addLine(t,e=!0){return t=R._trimRight(t),t=e?`${t}
|
|
240
|
+
`:t,t}static _getFromCache(t,e,i,r){let n=i[t];return typeof n!="number"&&(n=R._measureText(t,e,r)+e,i[t]=n),n}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!R.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:R._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:R._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let r=0;r<t.length;r++){const n=t[r],a=t[r+1];if(R.isBreakingSpace(n,a)||R._isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,r,n){return!0}static wordWrapSplit(t){return R.graphemeSegmenter(t)}static measureFont(t){if(R._fonts[t])return R._fonts[t];const e=R._context;e.font=t;const i=e.measureText(R.METRICS_STRING+R.BASELINE_SYMBOL),r={ascent:i.actualBoundingBoxAscent,descent:i.actualBoundingBoxDescent,fontSize:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent};return R._fonts[t]=r,r}static clearMetrics(t=""){t?delete R._fonts[t]:R._fonts={}}static get _canvas(){if(!R.__canvas){let t;try{const e=new OffscreenCanvas(0,0),i=e.getContext("2d",kr);if(i!=null&&i.measureText)return R.__canvas=e,e;t=L.get().createCanvas()}catch{t=L.get().createCanvas()}t.width=t.height=10,R.__canvas=t}return R.__canvas}static get _context(){return R.__context||(R.__context=R._canvas.getContext("2d",kr)),R.__context}};Ft.METRICS_STRING="|ÉqÅ",Ft.BASELINE_SYMBOL="M",Ft.BASELINE_MULTIPLIER=1.4,Ft.HEIGHT_MULTIPLIER=2,Ft.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>[...s.segment(t)].map(e=>e.segment)}return s=>[...s]})(),Ft.experimentalLetterSpacing=!1,Ft._fonts={},Ft._newlines=[10,13],Ft._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Ft._measurementCache={};let Gt=Ft;const Po=["_fontFamily","_fontStyle","_fontSize","_fontVariant","_fontWeight","_breakWords","_align","_leading","_letterSpacing","_lineHeight","_textBaseline","_whiteSpace","_wordWrap","_wordWrapWidth","_padding","_cssOverrides","_trim"];function Co(s){const t=[];let e=0;for(let i=0;i<Po.length;i++){const r=Po[i];t[e++]=s[r]}return e=Eo(s._fill,t,e),e=gp(s._stroke,t,e),t.join("-")}function Eo(s,t,e){var i;return s&&(t[e++]=s.color,t[e++]=s.alpha,t[e++]=(i=s.fill)==null?void 0:i.uid),e}function gp(s,t,e){return s&&(e=Eo(s,t,e),t[e++]=s.width,t[e++]=s.alignment,t[e++]=s.cap,t[e++]=s.join,t[e++]=s.miterLimit),e}const Ir=class ze extends _t{constructor(t={}){super(),_p(t);const e={...ze.defaultTextStyle,...t};for(const i in e){const r=i;this[r]=e[i]}this.update()}get align(){return this._align}set align(t){this._align=t,this.update()}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords=t,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(t){t!==null&&typeof t=="object"?this._dropShadow={...ze.defaultDropShadow,...t}:this._dropShadow=t?{...ze.defaultDropShadow}:null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily=t,this.update()}get fontSize(){return this._fontSize}set fontSize(t){typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle=t,this.update()}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant=t,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight=t,this.update()}get leading(){return this._leading}set leading(t){this._leading=t,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing=t,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight=t,this.update()}get padding(){return this._padding}set padding(t){this._padding=t,this.update()}get trim(){return this._trim}set trim(t){this._trim=t,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace=t,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap=t,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth=t,this.update()}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._fill=ee(t===0?"black":t,se.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._stroke=ee(t,se.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=Co(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=ze.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new ze({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(t=!1){var i,r,n,a;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(i=this._fill)!=null&&i.texture&&this._fill.texture.destroy(o),(r=this._originalFill)!=null&&r.texture&&this._originalFill.texture.destroy(o),(n=this._stroke)!=null&&n.texture&&this._stroke.texture.destroy(o),(a=this._originalStroke)!=null&&a.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}};Ir.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},Ir.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let me=Ir;function _p(s){const t=s;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=me.defaultDropShadow;s.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){N(W,"strokeThickness is now a part of stroke");const e=t.stroke;s.stroke={color:e,width:t.strokeThickness}}if(Array.isArray(t.fill)){N(W,"gradient fill is now a fill pattern: `new FillGradient(...)`");const e=new Tr(0,0,0,s.fontSize*1.7),i=t.fill.map(r=>j.shared.setValue(r).toNumber());i.forEach((r,n)=>{const a=t.fillGradientStops[n]??n/i.length;e.addColorStop(a,r)}),s.fill={fill:e}}}class Js extends fp{constructor(...t){const e=pp(t,"Text");super(e,me),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._style.padding,i=this._anchor,r=Gt.measureText(this._text,this._style),{width:n,height:a}=r;t.minX=-i._x*n-e,t.maxX=t.minX+n+e*2,t.minY=-i._y*a-e,t.maxY=t.minY+a+e*2}}class xp{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=L.get().createCanvas();i.width=t,i.height=e;const r=i.getContext("2d");return{canvas:i,context:r}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=Te(t),e=Te(e);const r=(t<<17)+(e<<1);this._canvasPool[r]||(this._canvasPool[r]=[]);let n=this._canvasPool[r].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const{width:e,height:i}=t.canvas,r=(e<<17)+(i<<1);this._canvasPool[r].push(t)}clear(){this._canvasPool={}}}const qt=new xp;function Qs(s,t){if(s.texture===M.WHITE&&!s.fill)return j.shared.setValue(s.color).toHex();if(s.fill){if(s.fill instanceof lo){const e=s.fill,i=t.createPattern(e.texture.source.resource,"repeat"),r=e.transform.copyTo(I.shared);return r.scale(e.texture.frame.width,e.texture.frame.height),i.setTransform(r),i}else if(s.fill instanceof Tr){const e=s.fill;if(e.type==="linear"){const i=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(r=>{i.addColorStop(r.offset,j.shared.setValue(r.color).toHex())}),i}}}else{const e=t.createPattern(s.texture.source.resource,"repeat"),i=s.matrix.copyTo(I.shared);return i.scale(s.texture.frame.width,s.texture.frame.height),e.setTransform(i),e}return D("FillStyle not recognised",s),"red"}class Mo extends _t{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return N(W,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return N(W,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return N(W,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return N(W,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return N(W,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners();for(const e in this.chars)this.chars[e].texture.destroy();this.chars=null,t&&(this.pages.forEach(e=>e.texture.destroy(!0)),this.pages=null)}}function Bo(s){if(s==="")return[];typeof s=="string"&&(s=[s]);const t=[];for(let e=0,i=s.length;e<i;e++){const r=s[e];if(Array.isArray(r)){if(r.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${r.length}.`);if(r[0].length===0||r[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");const n=r[0].charCodeAt(0),a=r[1].charCodeAt(0);if(a<n)throw new Error("[BitmapFont]: Invalid character range.");for(let o=n,h=a;o<=h;o++)t.push(String.fromCharCode(o))}else t.push(...Array.from(r))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}class Ro extends Mo{constructor(t){super(),this.resolution=1,this.pages=[],this._padding=4,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentPageIndex=-1,this._skipKerning=!1;const e=t,i=e.style.clone();e.overrideFill&&(i._fill.color=16777215,i._fill.alpha=1,i._fill.texture=M.WHITE,i._fill.fill=null);const r=i.fontSize;i.fontSize=this.baseMeasurementFontSize;const n=Zs(i);e.overrideSize?i._stroke&&(i._stroke.width*=this.baseRenderedFontSize/r):i.fontSize=this.baseRenderedFontSize=r,this._style=i,this._skipKerning=e.skipKerning??!1,this.resolution=e.resolution??1,this._padding=e.padding??4,this.fontMetrics=Gt.measureFont(n),this.lineHeight=i.lineHeight||this.fontMetrics.fontSize||i.fontSize}ensureCharacters(t){var g,m;const e=Bo(t).filter(_=>!this._currentChars.includes(_)).filter((_,x,y)=>y.indexOf(_)===x);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let i;this._currentPageIndex===-1?i=this._nextPage():i=this.pages[this._currentPageIndex];let{canvas:r,context:n}=i.canvasAndContext,a=i.texture.source;const o=this._style;let h=this._currentX,c=this._currentY;const l=this.baseRenderedFontSize/this.baseMeasurementFontSize,u=this._padding*l,d=o.fontStyle==="italic"?2:1;let f=0,p=!1;for(let _=0;_<e.length;_++){const x=e[_],y=Gt.measureText(x,o,r,!1);y.lineHeight=y.height;const v=d*y.width*l,w=y.height*l,E=v+u*2,C=w+u*2;if(p=!1,x!==`
|
|
241
|
+
`&&x!=="\r"&&x!==" "&&x!==" "&&(p=!0,f=Math.ceil(Math.max(C,f))),h+E>512&&(c+=f,f=C,h=0,c+f>512)){a.update();const S=this._nextPage();r=S.canvasAndContext.canvas,n=S.canvasAndContext.context,a=S.texture.source,c=0}const P=v/l-(((g=o.dropShadow)==null?void 0:g.distance)??0)-(((m=o._stroke)==null?void 0:m.width)??0);if(this.chars[x]={id:x.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:P,kerning:{}},p){this._drawGlyph(n,y,h+u,c+u,l,o);const S=a.width*l,A=a.height*l,Q=new Y(h/S*a.width,c/A*a.height,E/S*a.width,C/A*a.height);this.chars[x].texture=new M({source:a,frame:Q}),h+=Math.ceil(E)}}a.update(),this._currentX=h,this._currentY=c,this._skipKerning&&this._applyKerning(e,n)}get pageTextures(){return N(W,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const i=this._measureCache;for(let r=0;r<t.length;r++){const n=t[r];for(let a=0;a<this._currentChars.length;a++){const o=this._currentChars[a];let h=i[n];h||(h=i[n]=e.measureText(n).width);let c=i[o];c||(c=i[o]=e.measureText(o).width);let l=e.measureText(n+o).width,u=l-(h+c);u&&(this.chars[n].kerning[o]=u),l=e.measureText(n+o).width,u=l-(h+c),u&&(this.chars[o].kerning[n]=u)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=qt.getOptimalCanvasAndContext(512,512,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),r=new M({source:new Ce({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload"})}),n={canvasAndContext:e,texture:r};return this.pages[this._currentPageIndex]=n,n}_setupContext(t,e,i){e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=Zs(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const r=e._stroke,n=(r==null?void 0:r.width)??0;if(r&&(t.lineWidth=n,t.lineJoin=r.join,t.miterLimit=r.miterLimit,t.strokeStyle=Qs(r,t)),e._fill&&(t.fillStyle=Qs(e._fill,t)),e.dropShadow){const a=e.dropShadow,o=j.shared.setValue(a.color).toArray(),h=a.blur*i,c=a.distance*i;t.shadowColor=`rgba(${o[0]*255},${o[1]*255},${o[2]*255},${a.alpha})`,t.shadowBlur=h,t.shadowOffsetX=Math.cos(a.angle)*c,t.shadowOffsetY=Math.sin(a.angle)*c}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,i,r,n,a){const o=e.text,h=e.fontProperties,c=a._stroke,l=((c==null?void 0:c.width)??0)*n,u=i+l/2,d=r-l/2,f=h.descent*n,p=e.lineHeight*n;a.stroke&&l&&t.strokeText(o,u,d+p-f),a._fill&&t.fillText(o,u,d+p-f)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];qt.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}}function ko(s,t,e){const i={width:0,height:0,offsetY:0,scale:t.fontSize/e.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};i.offsetY=e.baseLineOffset;let r=i.lines[0],n=null,a=!0;const o={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},h=f=>{const p=r.width;for(let g=0;g<o.index;g++){const m=f.positions[g];r.chars.push(f.chars[g]),r.charPositions.push(m+p)}r.width+=f.width,a=!1,o.width=0,o.index=0,o.chars.length=0},c=()=>{let f=r.chars.length-1,p=r.chars[f];for(;p===" ";)r.width-=e.chars[p].xAdvance,p=r.chars[--f];i.width=Math.max(i.width,r.width),r={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,i.lines.push(r),i.height+=e.lineHeight},l=e.baseMeasurementFontSize/t.fontSize,u=t.letterSpacing*l,d=t.wordWrapWidth*l;for(let f=0;f<s.length+1;f++){let p;const g=f===s.length;g||(p=s[f]);const m=e.chars[p]||e.chars[" "];if(/(?:\s)/.test(p)||p==="\r"||p===`
|
|
242
|
+
`||g){if(!a&&t.wordWrap&&r.width+o.width-u>d?(c(),h(o),g||r.charPositions.push(0)):(o.start=r.width,h(o),g||r.charPositions.push(0)),p==="\r"||p===`
|
|
243
|
+
`)r.width!==0&&c();else if(!g){const v=m.xAdvance+(m.kerning[n]||0)+u;r.width+=v,r.spaceWidth=v,r.spacesIndex.push(r.charPositions.length),r.chars.push(p)}}else{const y=m.kerning[n]||0,v=m.xAdvance+y+u;o.positions[o.index++]=o.width+y,o.chars.push(p),o.width+=v}n=p}return c(),t.align==="center"?yp(i):t.align==="right"?bp(i):t.align==="justify"&&vp(i),i}function yp(s){for(let t=0;t<s.lines.length;t++){const e=s.lines[t],i=s.width/2-e.width/2;for(let r=0;r<e.charPositions.length;r++)e.charPositions[r]+=i}}function bp(s){for(let t=0;t<s.lines.length;t++){const e=s.lines[t],i=s.width-e.width;for(let r=0;r<e.charPositions.length;r++)e.charPositions[r]+=i}}function vp(s){const t=s.width;for(let e=0;e<s.lines.length;e++){const i=s.lines[e];let r=0,n=i.spacesIndex[r++],a=0;const o=i.spacesIndex.length,c=(t-i.width)/o;for(let l=0;l<i.charPositions.length;l++)l===n&&(n=i.spacesIndex[r++],a+=c),i.charPositions[l]+=a}}class Sp{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1}}getFont(t,e){var a;let i=`${e.fontFamily}-bitmap`,r=!0;if(e._fill.fill&&(i+=e._fill.fill.uid,r=!1),!K.has(i)){const o=new Ro({style:e,overrideFill:r,overrideSize:!0,...this.defaultOptions});o.once("destroy",()=>K.remove(i)),K.set(i,o)}const n=K.get(i);return(a=n.ensureCharacters)==null||a.call(n,t),n}getLayout(t,e){const i=this.getFont(t,e);return ko([...t],e,i)}measureText(t,e){return this.getLayout(t,e)}install(...t){var c,l,u,d;let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:(c=t[2])==null?void 0:c.chars,resolution:(l=t[2])==null?void 0:l.resolution,padding:(u=t[2])==null?void 0:u.padding,skipKerning:(d=t[2])==null?void 0:d.skipKerning},N(W,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const i=e==null?void 0:e.name;if(!i)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const r=e.style,n=r instanceof me?r:new me(r),a=n._fill.fill!==null&&n._fill.fill!==void 0,o=new Ro({style:n,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=Bo(e.chars);return o.ensureCharacters(h.join("")),K.set(`${i}-bitmap`,o),o.once("destroy",()=>K.remove(`${i}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,i=K.get(e);i&&(K.remove(e),i.destroy())}}const Fr=new Sp;function wp(s){const t=s._stroke,e=s._fill,r=[`div { ${[`color: ${j.shared.setValue(e.color).toHex()}`,`font-size: ${s.fontSize}px`,`font-family: ${s.fontFamily}`,`font-weight: ${s.fontWeight}`,`font-style: ${s.fontStyle}`,`font-variant: ${s.fontVariant}`,`letter-spacing: ${s.letterSpacing}px`,`text-align: ${s.align}`,`padding: ${s.padding}px`,`white-space: ${s.whiteSpace==="pre"&&s.wordWrap?"pre-wrap":s.whiteSpace}`,...s.lineHeight?[`line-height: ${s.lineHeight}px`]:[],...s.wordWrap?[`word-wrap: ${s.breakWords?"break-all":"break-word"}`,`max-width: ${s.wordWrapWidth}px`]:[],...t?[Fo(t)]:[],...s.dropShadow?[Io(s.dropShadow)]:[],...s.cssOverrides].join(";")} }`];return Tp(s.tagStyles,r),r.join(" ")}function Io(s){const t=j.shared.setValue(s.color).setAlpha(s.alpha).toHexa(),e=Math.round(Math.cos(s.angle)*s.distance),i=Math.round(Math.sin(s.angle)*s.distance),r=`${e}px ${i}px`;return s.blur>0?`text-shadow: ${r} ${s.blur}px ${t}`:`text-shadow: ${r} ${t}`}function Fo(s){return[`-webkit-text-stroke-width: ${s.width}px`,`-webkit-text-stroke-color: ${j.shared.setValue(s.color).toHex()}`,`text-stroke-width: ${s.width}px`,`text-stroke-color: ${j.shared.setValue(s.color).toHex()}`,"paint-order: stroke"].join(";")}const Go={fontSize:"font-size: {{VALUE}}px",fontFamily:"font-family: {{VALUE}}",fontWeight:"font-weight: {{VALUE}}",fontStyle:"font-style: {{VALUE}}",fontVariant:"font-variant: {{VALUE}}",letterSpacing:"letter-spacing: {{VALUE}}px",align:"text-align: {{VALUE}}",padding:"padding: {{VALUE}}px",whiteSpace:"white-space: {{VALUE}}",lineHeight:"line-height: {{VALUE}}px",wordWrapWidth:"max-width: {{VALUE}}px"},Uo={fill:s=>`color: ${j.shared.setValue(s).toHex()}`,breakWords:s=>`word-wrap: ${s?"break-all":"break-word"}`,stroke:Fo,dropShadow:Io};function Tp(s,t){for(const e in s){const i=s[e],r=[];for(const n in i)Uo[n]?r.push(Uo[n](i[n])):Go[n]&&r.push(Go[n].replace("{{VALUE}}",i[n]));t.push(`${e} { ${r.join(";")} }`)}}class Gr extends me{constructor(t={}){super(t),this._cssOverrides=[],this.cssOverrides??(this.cssOverrides=t.cssOverrides),this.tagStyles=t.tagStyles??{}}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}_generateKey(){return this._styleKey=Co(this)+this._cssOverrides.join("-"),this._styleKey}update(){this._cssStyle=null,super.update()}clone(){return new Gr({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides})}get cssStyle(){return this._cssStyle||(this._cssStyle=wp(this)),this._cssStyle}addOverride(...t){const e=t.filter(i=>!this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides.push(...e),this.update())}removeOverride(...t){const e=t.filter(i=>this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides=this.cssOverrides.filter(i=>!e.includes(i)),this.update())}set fill(t){typeof t!="string"&&typeof t!="number"&&D("[HTMLTextStyle] only color fill is not supported by HTMLText"),super.fill=t}set stroke(t){t&&typeof t!="string"&&typeof t!="number"&&D("[HTMLTextStyle] only color stroke is not supported by HTMLText"),super.stroke=t}}const Do="http://www.w3.org/2000/svg",Oo="http://www.w3.org/1999/xhtml";class Lo{constructor(){this.svgRoot=document.createElementNS(Do,"svg"),this.foreignObject=document.createElementNS(Do,"foreignObject"),this.domElement=document.createElementNS(Oo,"div"),this.styleElement=document.createElementNS(Oo,"style"),this.image=new Image;const{foreignObject:t,svgRoot:e,styleElement:i,domElement:r}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(i),t.appendChild(r)}}let Ho;function Ap(s,t,e,i){i=i||Ho||(Ho=new Lo);const{domElement:r,styleElement:n,svgRoot:a}=i;r.innerHTML=`<style>${t.cssStyle}</style><div>${s}</div>`,r.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(n.textContent=e),document.body.appendChild(a);const o=r.getBoundingClientRect();a.remove();const h=Gt.measureFont(t.fontStyle).descent;return{width:o.width,height:o.height+h}}function No(s,t,e){if(s)for(const i in s){const r=i.toLocaleLowerCase(),n=t[r];if(n){let a=s[i];i==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(a)}else D(`${i} placement hook does not exist in shader`)}}const Pp=/\{\{(.*?)\}\}/g;function zo(s){var i;const t={};return(((i=s.match(Pp))==null?void 0:i.map(r=>r.replace(/[{()}]/g,"")))??[]).forEach(r=>{t[r]=[]}),t}function Wo(s,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function Vo(s,t,e=!1){const i=[];Wo(t,i),s.forEach(o=>{o.header&&Wo(o.header,i)});const r=i;e&&r.sort();const n=r.map((o,h)=>` @location(${h}) ${o},`).join(`
|
|
244
|
+
`);let a=t.replace(/@in\s+[^;]+;\s*/g,"");return a=a.replace("{{in}}",`
|
|
245
|
+
${n}
|
|
246
|
+
`),a}function jo(s,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function Cp(s){const e=/\b(\w+)\s*:/g.exec(s);return e?e[1]:""}function Ep(s){const t=/@.*?\s+/g;return s.replace(t,"")}function Mp(s,t){const e=[];jo(t,e),s.forEach(h=>{h.header&&jo(h.header,e)});let i=0;const r=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${i++}) ${h}`).join(`,
|
|
247
|
+
`),n=e.sort().map(h=>` var ${Ep(h)};`).join(`
|
|
248
|
+
`),a=`return VSOutput(
|
|
249
|
+
${e.sort().map(h=>` ${Cp(h)}`).join(`,
|
|
250
|
+
`)});`;let o=t.replace(/@out\s+[^;]+;\s*/g,"");return o=o.replace("{{struct}}",`
|
|
251
|
+
${r}
|
|
252
|
+
`),o=o.replace("{{start}}",`
|
|
253
|
+
${n}
|
|
254
|
+
`),o=o.replace("{{return}}",`
|
|
255
|
+
${a}
|
|
256
|
+
`),o}function $o(s,t){let e=s;for(const i in t){const r=t[i];r.join(`
|
|
257
|
+
`).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----//
|
|
258
|
+
${r.join(`
|
|
259
|
+
`)}
|
|
260
|
+
//----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const re=Object.create(null),Ur=new Map;let Bp=0;function Rp({template:s,bits:t}){const e=Xo(s,t);if(re[e])return re[e];const{vertex:i,fragment:r}=Ip(s,t);return re[e]=Yo(i,r,t),re[e]}function kp({template:s,bits:t}){const e=Xo(s,t);return re[e]||(re[e]=Yo(s.vertex,s.fragment,t)),re[e]}function Ip(s,t){const e=t.map(a=>a.vertex).filter(a=>!!a),i=t.map(a=>a.fragment).filter(a=>!!a);let r=Vo(e,s.vertex,!0);r=Mp(e,r);const n=Vo(i,s.fragment,!0);return{vertex:r,fragment:n}}function Xo(s,t){return t.map(e=>(Ur.has(e)||Ur.set(e,Bp++),Ur.get(e))).sort((e,i)=>e-i).join("-")+s.vertex+s.fragment}function Yo(s,t,e){const i=zo(s),r=zo(t);return e.forEach(n=>{No(n.vertex,i,n.name),No(n.fragment,r,n.name)}),{vertex:$o(s,i),fragment:$o(t,r)}}const Fp=`
|
|
261
|
+
@in aPosition: vec2<f32>;
|
|
262
|
+
@in aUV: vec2<f32>;
|
|
263
|
+
|
|
264
|
+
@out @builtin(position) vPosition: vec4<f32>;
|
|
265
|
+
@out vUV : vec2<f32>;
|
|
266
|
+
@out vColor : vec4<f32>;
|
|
267
|
+
|
|
268
|
+
{{header}}
|
|
269
|
+
|
|
270
|
+
struct VSOutput {
|
|
271
|
+
{{struct}}
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
@vertex
|
|
275
|
+
fn main( {{in}} ) -> VSOutput {
|
|
276
|
+
|
|
277
|
+
var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
|
|
278
|
+
var modelMatrix = mat3x3<f32>(
|
|
279
|
+
1.0, 0.0, 0.0,
|
|
280
|
+
0.0, 1.0, 0.0,
|
|
281
|
+
0.0, 0.0, 1.0
|
|
282
|
+
);
|
|
283
|
+
var position = aPosition;
|
|
284
|
+
var uv = aUV;
|
|
285
|
+
|
|
286
|
+
{{start}}
|
|
287
|
+
|
|
288
|
+
vColor = vec4<f32>(1., 1., 1., 1.);
|
|
823
289
|
|
|
824
|
-
|
|
290
|
+
{{main}}
|
|
825
291
|
|
|
826
|
-
|
|
292
|
+
vUV = uv;
|
|
827
293
|
|
|
828
|
-
|
|
294
|
+
var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
|
|
829
295
|
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
296
|
+
vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
|
|
297
|
+
|
|
298
|
+
vColor *= globalUniforms.uWorldColorAlpha;
|
|
833
299
|
|
|
834
|
-
|
|
835
|
-
varying vec4 vColor;
|
|
300
|
+
{{end}}
|
|
836
301
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
302
|
+
{{return}}
|
|
303
|
+
};
|
|
304
|
+
`,Gp=`
|
|
305
|
+
@in vUV : vec2<f32>;
|
|
306
|
+
@in vColor : vec4<f32>;
|
|
307
|
+
|
|
308
|
+
{{header}}
|
|
840
309
|
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
{
|
|
848
|
-
vec4 color = texture2D(uSampler, vTextureCoord);
|
|
849
|
-
float randomValue = rand(gl_FragCoord.xy * uSeed);
|
|
850
|
-
float diff = (randomValue - 0.5) * uNoise;
|
|
310
|
+
@fragment
|
|
311
|
+
fn main(
|
|
312
|
+
{{in}}
|
|
313
|
+
) -> @location(0) vec4<f32> {
|
|
314
|
+
|
|
315
|
+
{{start}}
|
|
851
316
|
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
317
|
+
var outColor:vec4<f32>;
|
|
318
|
+
|
|
319
|
+
{{main}}
|
|
320
|
+
|
|
321
|
+
return outColor * vColor;
|
|
322
|
+
};
|
|
323
|
+
`,Up=`
|
|
324
|
+
in vec2 aPosition;
|
|
325
|
+
in vec2 aUV;
|
|
326
|
+
|
|
327
|
+
out vec4 vColor;
|
|
328
|
+
out vec2 vUV;
|
|
329
|
+
|
|
330
|
+
{{header}}
|
|
331
|
+
|
|
332
|
+
void main(void){
|
|
333
|
+
|
|
334
|
+
mat3 worldTransformMatrix = uWorldTransformMatrix;
|
|
335
|
+
mat3 modelMatrix = mat3(
|
|
336
|
+
1.0, 0.0, 0.0,
|
|
337
|
+
0.0, 1.0, 0.0,
|
|
338
|
+
0.0, 0.0, 1.0
|
|
339
|
+
);
|
|
340
|
+
vec2 position = aPosition;
|
|
341
|
+
vec2 uv = aUV;
|
|
342
|
+
|
|
343
|
+
{{start}}
|
|
344
|
+
|
|
345
|
+
vColor = vec4(1.);
|
|
346
|
+
|
|
347
|
+
{{main}}
|
|
348
|
+
|
|
349
|
+
vUV = uv;
|
|
350
|
+
|
|
351
|
+
mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
|
|
856
352
|
|
|
857
|
-
|
|
858
|
-
color.g += diff;
|
|
859
|
-
color.b += diff;
|
|
353
|
+
gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
|
860
354
|
|
|
861
|
-
|
|
862
|
-
color.rgb *= color.a;
|
|
355
|
+
vColor *= uWorldColorAlpha;
|
|
863
356
|
|
|
864
|
-
|
|
865
|
-
}
|
|
866
|
-
`;class Nm extends Bt{constructor(t=.5,e=Math.random()){super(ul,Lm,{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 xl={AlphaFilter:Tm,BlurFilter:Im,BlurFilterPass:sa,ColorMatrixFilter:na,DisplacementFilter:Fm,FXAAFilter:Om,NoiseFilter:Nm};Object.entries(xl).forEach(([i,t])=>{Object.defineProperty(xl,i,{get(){return K("7.1.0",`filters.${i} has moved to ${i}`),t}})});class km{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||(dt.system.add(this.tickerUpdate,this,Se.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(dt.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const ke=new km;class or{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=or.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new J,this.page=new J,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,r){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,r,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class as extends or{constructor(){super(...arguments),this.client=new J,this.movement=new J,this.offset=new J,this.global=new J,this.screen=new J}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,r){return t.worldTransform.applyInverse(r||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,r,s,n,a,o,h,l,c,u,d,f,p,m){throw new Error("Method not implemented.")}}class Wt extends as{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Ri extends as{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Ri.DOM_DELTA_PIXEL=0,Ri.DOM_DELTA_LINE=1,Ri.DOM_DELTA_PAGE=2;const Um=2048,Gm=new J,aa=new J;class Hm{constructor(t){this.dispatch=new Xi,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((r,s)=>r.priority-s.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 r=0,s=e.length;r<s;r++)e[r].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){ke.pauseUpdate=!0;const r=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[r](this.rootTarget,this.rootTarget.eventMode,Gm.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const r=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=r.length-1;s<n;s++)if(t.currentTarget=r[s],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 s=r.length-2;s>=0;s--)if(t.currentTarget=r[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,r=this._allInteractiveElements){if(r.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=r.length-1;n>=0;n--)s.forEach(a=>{t.currentTarget=r[n],this.notifyTarget(t,a)})}propagationPath(t){const e=[t];for(let r=0;r<Um&&t!==this.rootTarget;r++){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,r,s,n,a=!1){let o=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(ke.pauseUpdate=!1),t.interactiveChildren&&t.children){const c=t.children;for(let u=c.length-1;u>=0;u--){const d=c[u],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,r,s,n,a||n(t,r));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=t.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),o=!0}}}const h=this._isInteractive(e),l=t.isInteractive();return h&&l&&this._allInteractiveElements.push(t),a||this._hitElements.length>0?null:o?this._hitElements:h&&!n(t,r)&&s(t,r)?l?[t]:[]:null}hitTestRecursive(t,e,r,s,n){if(this._interactivePrune(t)||n(t,r))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(ke.pauseUpdate=!1),t.interactiveChildren&&t.children){const h=t.children;for(let l=h.length-1;l>=0;l--){const c=h[l],u=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,r,s,n);if(u){if(u.length>0&&!u[u.length-1].parent)continue;const d=t.isInteractive();return(u.length>0||d)&&u.push(t),u}}}const a=this._isInteractive(e),o=t.isInteractive();return a&&s(t,r)?o?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,e){var r;if(t.hitArea&&(t.worldTransform.applyInverse(e,aa),!t.hitArea.contains(aa.x,aa.y)))return!0;if(t._mask){const s=t._mask.isMaskData?t._mask.maskObject:t._mask;if(s&&!((r=s.containsPoint)!=null&&r.call(s,e)))return!0}return!1}hitTestFn(t,e){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){var n,a;e=e??t.type;const r=`on${e}`;(a=(n=t.currentTarget)[r])==null||a.call(n,t);const s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,s),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof Wt)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const s=e.button===2;this.dispatchEvent(e,s?"rightdown":"mousedown")}const r=this.trackingData(t.pointerId);r.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var h,l;if(!(t instanceof Wt)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const r=e.pointerType==="mouse"||e.pointerType==="pen",s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.overTargets);if(((h=s.overTargets)==null?void 0:h.length)>0&&n!==e.target){const c=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,c,n);if(this.dispatchEvent(u,"pointerout"),r&&this.dispatchEvent(u,"mouseout"),!e.composedPath().includes(n)){const d=this.createPointerEvent(t,"pointerleave",n);for(d.eventPhase=d.AT_TARGET;d.target&&!e.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),r&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(u)}if(n!==e.target){const c=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(e,c);this.dispatchEvent(u,"pointerover"),r&&this.dispatchEvent(u,"mouseover");let d=n==null?void 0:n.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(e,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==n&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),r&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(u)}const a=[],o=this.enableGlobalMoveEvents??!0;this.moveOnAll?a.push("pointermove"):this.dispatchEvent(e,"pointermove"),o&&a.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?a.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),o&&a.push("globaltouchmove")),r&&(this.moveOnAll?a.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),o&&a.push("globalmousemove"),this.cursor=(l=e.target)==null?void 0:l.cursor),a.length>0&&this.all(e,a),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var a;if(!(t instanceof Wt)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),r=this.createPointerEvent(t),s=r.pointerType==="mouse"||r.pointerType==="pen";this.dispatchEvent(r,"pointerover"),s&&this.dispatchEvent(r,"mouseover"),r.pointerType==="mouse"&&(this.cursor=(a=r.target)==null?void 0:a.cursor);const n=this.clonePointerEvent(r,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=r.composedPath(),this.freeEvent(r),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof Wt)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const r=t.pointerType==="mouse"||t.pointerType==="pen",s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),r&&this.dispatchEvent(n,"mouseout");const a=this.createPointerEvent(t,"pointerleave",s);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),r&&this.notifyTarget(a,"mouseleave"),a.target=a.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(a)}this.cursor=null}mapPointerUp(t){if(!(t instanceof Wt)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),r=this.createPointerEvent(t);if(this.dispatchEvent(r,"pointerup"),r.pointerType==="touch")this.dispatchEvent(r,"touchend");else if(r.pointerType==="mouse"||r.pointerType==="pen"){const o=r.button===2;this.dispatchEvent(r,o?"rightup":"mouseup")}const s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let a=n;if(n&&!r.composedPath().includes(n)){let o=n;for(;o&&!r.composedPath().includes(o);){if(r.currentTarget=o,this.notifyTarget(r,"pointerupoutside"),r.pointerType==="touch")this.notifyTarget(r,"touchendoutside");else if(r.pointerType==="mouse"||r.pointerType==="pen"){const h=r.button===2;this.notifyTarget(r,h?"rightupoutside":"mouseupoutside")}o=o.parent}delete s.pressTargetsByButton[t.button],a=o}if(a){const o=this.clonePointerEvent(r,"click");o.target=a,o.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:o.target,timeStamp:e});const h=s.clicksByButton[t.button];if(h.target===o.target&&e-h.timeStamp<200?++h.clickCount:h.clickCount=1,h.target=o.target,h.timeStamp=e,o.detail=h.clickCount,o.pointerType==="mouse"){const l=o.button===2;this.dispatchEvent(o,l?"rightclick":"click")}else o.pointerType==="touch"&&this.dispatchEvent(o,"tap");this.dispatchEvent(o,"pointertap"),this.freeEvent(o)}this.freeEvent(r)}mapPointerUpOutside(t){if(!(t instanceof Wt)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),r=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(r){let n=r;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof Ri)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let r=1;r<t.length&&t[r].parent===e;r++)e=t[r];return e}createPointerEvent(t,e,r){const s=this.allocateEvent(Wt);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=r??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(Ri);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 r=this.allocateEvent(Wt);return r.nativeEvent=t.nativeEvent,r.originalEvent=t.originalEvent,this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.target=t.target,r.path=t.composedPath().slice(),r.type=e??r.type,r}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Wt&&e instanceof Wt&&(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 as&&e instanceof as&&(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 r=t.currentTarget._events[e];if(r&&t.currentTarget.isInteractive())if("fn"in r)r.once&&t.currentTarget.removeListener(e,r.fn,void 0,!0),r.fn.call(r.context,t);else for(let s=0,n=r.length;s<n&&!t.propagationImmediatelyStopped;s++)r[s].once&&t.currentTarget.removeListener(e,r[s].fn,void 0,!0),r[s].fn.call(r[s].context,t)}}const $m=1,Xm={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},oa=class Ha{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Hm(null),ke.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new Wt(null),this.rootWheelEvent=new Ri(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Ha.defaultEventFeatures},{set:(e,r,s)=>(r==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),e[r]=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){const{view:e,resolution:r}=this.renderer;this.setTargetElement(e),this.resolution=r,Ha._defaultEventMode=t.eventMode??"auto",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const r=this.cursorStyles[t];if(r)switch(typeof r){case"string":e&&(this.domElement.style.cursor=r);break;case"function":r(t);break;case"object":e&&Object.assign(this.domElement.style,r);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let r=0,s=e.length;r<s;r++){const n=e[r],a=this.bootstrapEvent(this.rootPointerEvent,n);this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,ke.pointerMoved();const e=this.normalizeToPointerData(t);for(let r=0,s=e.length;r<s;r++){const n=this.bootstrapEvent(this.rootPointerEvent,e[r]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const r=e!==this.domElement?"outside":"",s=this.normalizeToPointerData(t);for(let n=0,a=s.length;n<a;n++){const o=this.bootstrapEvent(this.rootPointerEvent,s[n]);o.type+=r,this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let r=0,s=e.length;r<s;r++){const n=this.bootstrapEvent(this.rootPointerEvent,e[r]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,ke.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;ke.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;ke.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,r){const s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*n,t.y=(r-s.top)*(this.domElement.height/s.height)*n}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let r=0,s=t.changedTouches.length;r<s;r++){const n=t.changedTouches[r];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const r=t;typeof r.isPrimary>"u"&&(r.isPrimary=!0),typeof r.width>"u"&&(r.width=1),typeof r.height>"u"&&(r.height=1),typeof r.tiltX>"u"&&(r.tiltX=0),typeof r.tiltY>"u"&&(r.tiltY=0),typeof r.pointerType>"u"&&(r.pointerType="mouse"),typeof r.pointerId>"u"&&(r.pointerId=$m),typeof r.pressure>"u"&&(r.pressure=.5),typeof r.twist>"u"&&(r.twist=0),typeof r.tangentialPressure>"u"&&(r.tangentialPressure=0),r.isNormalized=!0,e.push(r)}else e.push(t);return e}normalizeWheelEvent(t){const e=this.rootWheelEvent;return this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=Xm[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}};oa.extension={name:"events",type:[P.RendererSystem,P.CanvasRendererSystem]},oa.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let ha=oa;k.add(ha);function bl(i){return i==="dynamic"||i==="static"}const zm={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??bl(ha.defaultEventMode)},set interactive(i){K("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=i,this.eventMode=i?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??ha.defaultEventMode},set eventMode(i){this._internalInteractive=bl(i),this._internalEventMode=i},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(i,t,e){const r=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,a=typeof t=="function"?void 0:t;i=r?`${i}capture`:i;const o=typeof t=="function"?t:t.handleEvent,h=this;s&&s.addEventListener("abort",()=>{h.off(i,o,a)}),n?h.once(i,o,a):h.on(i,o,a)},removeEventListener(i,t,e){const r=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;i=r?`${i}capture`:i,t=typeof t=="function"?t:t.handleEvent,this.off(i,t,s)},dispatchEvent(i){if(!(i instanceof or))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return i.defaultPrevented=!1,i.path=null,i.target=this,i.manager.dispatchEvent(i),!i.defaultPrevented}};lt.mixin(zm);const Vm={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};lt.mixin(Vm);const Wm=9,os=100,jm=0,Ym=0,Tl=2,wl=1,qm=-1e3,Km=-1e3,Zm=2;class El{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,(ve.tablet||ve.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${os}px`,e.style.height=`${os}px`,e.style.position="absolute",e.style.top=`${jm}px`,e.style.left=`${Ym}px`,e.style.zIndex=Tl.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=`${wl}px`,t.style.height=`${wl}px`,t.style.position="absolute",t.style.top=`${qm}px`,t.style.left=`${Km}px`,t.style.zIndex=Zm.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),(t=this.renderer.view.parentNode)==null||t.appendChild(this.div))}deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),(t=this.div.parentNode)==null||t.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const e=t.children;if(e)for(let r=0;r<e.length;r++)this.updateAccessibleObjects(e[r])}update(){const t=performance.now();if(ve.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:r,width:s,height:n}=this.renderer.view.getBoundingClientRect(),{width:a,height:o,resolution:h}=this.renderer,l=s/a*h,c=n/o*h;let u=this.div;u.style.left=`${e}px`,u.style.top=`${r}px`,u.style.width=`${a}px`,u.style.height=`${o}px`;for(let d=0;d<this.children.length;d++){const f=this.children[d];if(f.renderId!==this.renderId)f._accessibleActive=!1,Ai(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{u=f._accessibleDiv;let p=f.hitArea;const m=f.worldTransform;f.hitArea?(u.style.left=`${(m.tx+p.x*m.a)*l}px`,u.style.top=`${(m.ty+p.y*m.d)*c}px`,u.style.width=`${p.width*m.a*l}px`,u.style.height=`${p.height*m.d*c}px`):(p=f.getBounds(),this.capHitArea(p),u.style.left=`${p.x*l}px`,u.style.top=`${p.y*c}px`,u.style.width=`${p.width*l}px`,u.style.height=`${p.height*c}px`,u.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(u.title=f.accessibleTitle),u.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&u.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==u.title||f.tabIndex!==u.tabIndex)&&(u.title=f.accessibleTitle,u.tabIndex=f.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:r}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>r&&(t.height=r-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=`${os}px`,e.style.height=`${os}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Tl.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{displayObject:r}=t.target,s=this.renderer.events.rootBoundary,n=Object.assign(new or(s),{target:r});s.rootTarget=this.renderer.lastObjectRendered,e.forEach(a=>s.dispatchEvent(n,a))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===Wm&&this.activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this.deactivate()}destroy(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null}}El.extension={name:"accessibility",type:[P.RendererPlugin,P.CanvasRendererPlugin]},k.add(El);const Al=class $a{constructor(t){this.stage=new bt,t=Object.assign({forceCanvas:!1},t),this.renderer=om(t),$a._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render(this.stage)}get view(){var t;return(t=this.renderer)==null?void 0:t.view}get screen(){var t;return(t=this.renderer)==null?void 0:t.screen}destroy(t,e){const r=$a._plugins.slice(0);r.reverse(),r.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Al._plugins=[];let Jm=Al;k.handleByList(P.Application,Jm._plugins);class Sl{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let e,r;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,r=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,r=n}this.renderer.resize(e,r),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}}Sl.extension=P.Application,k.add(Sl);const Cl={loader:P.LoadParser,resolver:P.ResolveParser,cache:P.CacheParser,detection:P.DetectionParser};k.handle(P.Asset,i=>{const t=i.ref;Object.entries(Cl).filter(([e])=>!!t[e]).forEach(([e,r])=>k.add(Object.assign(t[e],{extension:t[e].extension??r})))},i=>{const t=i.ref;Object.keys(Cl).filter(e=>!!t[e]).forEach(e=>k.remove(t[e]))});class Qm{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let r=0;r<e;r++)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 Pi(i,t){if(Array.isArray(t)){for(const e of t)if(i.startsWith(`data:${e}`))return!0;return!1}return i.startsWith(`data:${t}`)}function Ue(i,t){const e=i.split("?")[0],r=xt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(r):r===t}const jt=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(r=>typeof r=="string"||e?t(r):r):i),la=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i};function Il(i,t,e,r,s){const n=t[e];for(let a=0;a<n.length;a++){const o=n[a];e<t.length-1?Il(i.replace(r[e],o),t,e+1,r,s):s.push(i.replace(r[e],o))}}function tg(i){const t=/\{(.*?)\}/g,e=i.match(t),r=[];if(e){const s=[];e.forEach(n=>{const a=n.substring(1,n.length-1).split(",");s.push(a)}),Il(i,s,0,e,r)}else r.push(i);return r}const hs=i=>!Array.isArray(i);class eg{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 r=jt(t);let s;for(let o=0;o<this.parsers.length;o++){const h=this.parsers[o];if(h.test(e)){s=h.getCacheableAssets(r,e);break}}s||(s={},r.forEach(o=>{s[o]=e}));const n=Object.keys(s),a={cacheKeys:n,keys:r};if(r.forEach(o=>{this._cacheMap.set(o,a)}),n.forEach(o=>{this._cache.has(o)&&this._cache.get(o)!==e&&console.warn("[Cache] already has key:",o),this._cache.set(o,s[o])}),e instanceof L){const o=e;r.forEach(h=>{o.baseTexture!==L.EMPTY.baseTexture&&W.addToCache(o.baseTexture,h),L.addToCache(o,h)})}}remove(t){if(!this._cacheMap.has(t)){console.warn(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(r=>{this._cache.delete(r)}),e.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const oi=new eg;class ig{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,r)=>(this._parsersValidated=!1,t[e]=r,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const r={promise:null,parser:null};return r.promise=(async()=>{var a,o;let s=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.load&&((a=l.test)!=null&&a.call(l,t,e,this))){n=l;break}}if(!n)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await n.load(t,e,this),r.parser=n;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];l.parse&&l.parse&&await((o=l.testParse)==null?void 0:o.call(l,s,e,this))&&(s=await l.parse(s,e,this)||s,r.parser=l)}return s})(),r}async load(t,e){this._parsersValidated||this._validateParsers();let r=0;const s={},n=hs(t),a=jt(t,l=>({alias:[l],src:l})),o=a.length,h=a.map(async l=>{const c=xt.toAbsolute(l.src);if(!s[l.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,l)),s[l.src]=await this.promiseCache[c].promise,e&&e(++r/o)}catch(u){throw delete this.promiseCache[c],delete s[l.src],new Error(`[Loader.load] Failed to load ${c}.
|
|
867
|
-
${u}`)}});return await Promise.all(h),n?s[a[0].src]:s}async unload(t){const e=jt(t,r=>({alias:[r],src:r})).map(async r=>{var a,o;const s=xt.toAbsolute(r.src),n=this.promiseCache[s];if(n){const h=await n.promise;delete this.promiseCache[s],(o=(a=n.parser)==null?void 0:a.unload)==null||o.call(a,h,r,this)}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(t[e.name]&&console.warn(`[Assets] loadParser name conflict "${e.name}"`),{...t,[e.name]:e}),{})}}var Yt=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Yt||{});const rg=".json",sg="application/json",ng={extension:{type:P.LoadParser,priority:Yt.Low},name:"loadJson",test(i){return Pi(i,sg)||Ue(i,rg)},async load(i){return await(await F.ADAPTER.fetch(i)).json()}};k.add(ng);const ag=".txt",og="text/plain",hg={name:"loadTxt",extension:{type:P.LoadParser,priority:Yt.Low},test(i){return Pi(i,og)||Ue(i,ag)},async load(i){return await(await F.ADAPTER.fetch(i)).text()}};k.add(hg);const lg=["normal","bold","100","200","300","400","500","600","700","800","900"],cg=[".ttf",".otf",".woff",".woff2"],ug=["font/ttf","font/otf","font/woff","font/woff2"],dg=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function fg(i){const t=xt.extname(i),e=xt.basename(i,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let r=e.length>0;for(const n of e)if(!n.match(dg)){r=!1;break}let s=e.join(" ");return r||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const pg=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function mg(i){return pg.test(i)?i:encodeURI(i)}const gg={extension:{type:P.LoadParser,priority:Yt.Low},name:"loadWebFont",test(i){return Pi(i,ug)||Ue(i,cg)},async load(i,t){var r,s,n;const e=F.ADAPTER.getFontFaceSet();if(e){const a=[],o=((r=t.data)==null?void 0:r.family)??fg(i),h=((n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(c=>lg.includes(c)))??["normal"],l=t.data??{};for(let c=0;c<h.length;c++){const u=h[c],d=new FontFace(o,`url(${mg(i)})`,{...l,weight:u});await d.load(),e.add(d),a.push(d)}return a.length===1?a[0]:a}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(i){(Array.isArray(i)?i:[i]).forEach(t=>F.ADAPTER.getFontFaceSet().delete(t))}};k.add(gg);const yg=`(function() {
|
|
868
|
-
"use strict";
|
|
869
|
-
const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
|
|
870
|
-
async function checkImageBitmap() {
|
|
871
|
-
try {
|
|
872
|
-
if (typeof createImageBitmap != "function")
|
|
873
|
-
return !1;
|
|
874
|
-
const imageBlob = await (await fetch(WHITE_PNG)).blob(), imageBitmap = await createImageBitmap(imageBlob);
|
|
875
|
-
return imageBitmap.width === 1 && imageBitmap.height === 1;
|
|
876
|
-
} catch {
|
|
877
|
-
return !1;
|
|
357
|
+
{{end}}
|
|
878
358
|
}
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
})();
|
|
884
|
-
`;let Mi=null,ca=class{constructor(){Mi||(Mi=URL.createObjectURL(new Blob([yg],{type:"application/javascript"}))),this.worker=new Worker(Mi)}};ca.revokeObjectURL=function(){Mi&&(URL.revokeObjectURL(Mi),Mi=null)};const _g=`(function() {
|
|
885
|
-
"use strict";
|
|
886
|
-
async function loadImageBitmap(url) {
|
|
887
|
-
const response = await fetch(url);
|
|
888
|
-
if (!response.ok)
|
|
889
|
-
throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`);
|
|
890
|
-
const imageBlob = await response.blob();
|
|
891
|
-
return await createImageBitmap(imageBlob);
|
|
892
|
-
}
|
|
893
|
-
self.onmessage = async (event) => {
|
|
894
|
-
try {
|
|
895
|
-
const imageBitmap = await loadImageBitmap(event.data.data[0]);
|
|
896
|
-
self.postMessage({
|
|
897
|
-
data: imageBitmap,
|
|
898
|
-
uuid: event.data.uuid,
|
|
899
|
-
id: event.data.id
|
|
900
|
-
}, [imageBitmap]);
|
|
901
|
-
} catch (e) {
|
|
902
|
-
self.postMessage({
|
|
903
|
-
error: e,
|
|
904
|
-
uuid: event.data.uuid,
|
|
905
|
-
id: event.data.id
|
|
906
|
-
});
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
})();
|
|
910
|
-
`;let Fi=null;class Rl{constructor(){Fi||(Fi=URL.createObjectURL(new Blob([_g],{type:"application/javascript"}))),this.worker=new Worker(Fi)}}Rl.revokeObjectURL=function(){Fi&&(URL.revokeObjectURL(Fi),Fi=null)};let Pl=0,ua;class vg{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new ca;e.addEventListener("message",r=>{e.terminate(),ca.revokeObjectURL(),t(r.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){ua===void 0&&(ua=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<ua&&(this._createdWorkers++,t=new Rl().worker,t.addEventListener("message",e=>{this.complete(e.data),this.returnWorker(e.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const r=new Promise((s,n)=>{this.queue.push({id:t,arguments:e,resolve:s,reject:n})});return this.next(),r}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),r=e.id;this.resolveHash[Pl]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Pl++,id:r})}}const Ml=new vg;function hr(i,t,e){i.resource.internal=!0;const r=new L(i),s=()=>{delete t.promiseCache[e],oi.has(e)&&oi.remove(e)};return r.baseTexture.once("destroyed",()=>{e in t.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),s())}),r.once("destroyed",()=>{i.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),s())}),r}const xg=[".jpeg",".jpg",".png",".webp",".avif"],bg=["image/jpeg","image/png","image/webp","image/avif"];async function Tg(i){const t=await F.ADAPTER.fetch(i);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const ls={name:"loadTextures",extension:{type:P.LoadParser,priority:Yt.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(i){return Pi(i,bg)||Ue(i,xg)},async load(i,t,e){var o;const r=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;r?this.config.preferWorkers&&await Ml.isImageBitmapSupported()?s=await Ml.loadImageBitmap(i):s=await Tg(i):s=await new Promise((h,l)=>{const c=new Image;c.crossOrigin=this.config.crossOrigin,c.src=i,c.complete?h(c):(c.onload=()=>h(c),c.onerror=u=>l(u))});const n={...t.data};n.resolution??(n.resolution=Te(i)),r&&((o=n.resourceOptions)==null?void 0:o.ownsImageBitmap)===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const a=new W(s,n);return a.resource.src=i,hr(a,e,i)},unload(i){i.destroy(!0)}};k.add(ls);const wg=".svg",Eg="image/svg+xml",Ag={extension:{type:P.LoadParser,priority:Yt.High},name:"loadSVG",test(i){return Pi(i,Eg)||Ue(i,wg)},async testParse(i){return ia.test(i)},async parse(i,t,e){var n;const r=new ia(i,(n=t==null?void 0:t.data)==null?void 0:n.resourceOptions);await r.load();const s=new W(r,{resolution:Te(i),...t==null?void 0:t.data});return s.resource.src=t.src,hr(s,e,t.src)},async load(i,t){return(await F.ADAPTER.fetch(i)).text()},unload:ls.unload};k.add(Ag);const Sg=[".mp4",".m4v",".webm",".ogv"],Cg=["video/mp4","video/webm","video/ogg"],Ig={name:"loadVideo",extension:{type:P.LoadParser,priority:Yt.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(i){return Pi(i,Cg)||Ue(i,Sg)},async load(i,t,e){var a;let r;const s=await(await F.ADAPTER.fetch(i)).blob(),n=URL.createObjectURL(s);try{const o={autoPlay:this.config.defaultAutoPlay,updateFPS:this.config.defaultUpdateFPS,loop:this.config.defaultLoop,muted:this.config.defaultMuted,playsinline:this.config.defaultPlaysinline,...(a=t==null?void 0:t.data)==null?void 0:a.resourceOptions,autoLoad:!0},h=new yl(n,o);await h.load();const l=new W(h,{alphaMode:await Bf(),resolution:Te(i),...t==null?void 0:t.data});l.resource.src=i,r=hr(l,e,i),r.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(o){throw URL.revokeObjectURL(n),o}return r},unload(i){i.destroy(!0)}};k.add(Ig);class Rg{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(r=>`${encodeURIComponent(r)}=${encodeURIComponent(e[r])}`).join("&")}}getAlias(t){const{alias:e,name:r,src:s,srcs:n}=t;return jt(e||r||s||n,a=>typeof a=="string"?a:Array.isArray(a)?a.map(o=>(o==null?void 0:o.src)??(o==null?void 0:o.srcs)??o):a!=null&&a.src||a!=null&&a.srcs?a.src??a.srcs:a,!0)}addManifest(t){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const r=[];Array.isArray(e)?e.forEach(s=>{const n=s.src??s.srcs,a=s.alias??s.name;let o;if(typeof a=="string"){const h=this._createBundleAssetId(t,a);r.push(h),o=[a,h]}else{const h=a.map(l=>this._createBundleAssetId(t,l));r.push(...h),o=[...a,...h]}this.add({...s,alias:o,src:n})}):Object.keys(e).forEach(s=>{const n=[s,this._createBundleAssetId(t,s)];if(typeof e[s]=="string")this.add({alias:n,src:e[s]});else if(Array.isArray(e[s]))this.add({alias:n,src:e[s]});else{const a=e[s],o=a.src??a.srcs;this.add({...a,alias:n,src:Array.isArray(o)?o:[o]})}r.push(...n)}),this._bundles[t]=r}add(t,e,r,s,n){const a=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(K("7.2.0",`Assets.add now uses an object instead of individual parameters.
|
|
911
|
-
Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),a.push({alias:t,src:e,data:r,format:s,loadParser:n})):Array.isArray(t)?a.push(...t):a.push(t);let o;o=h=>{this.hasKey(h)&&console.warn(`[Resolver] already has key: ${h} overwriting`)},jt(a).forEach(h=>{const{src:l,srcs:c}=h;let{data:u,format:d,loadParser:f}=h;const p=jt(l||c).map(_=>typeof _=="string"?tg(_):Array.isArray(_)?_:[_]),m=this.getAlias(h);Array.isArray(m)?m.forEach(o):o(m);const g=[];p.forEach(_=>{_.forEach(x=>{let y={};if(typeof x!="object"){y.src=x;for(let v=0;v<this._parsers.length;v++){const T=this._parsers[v];if(T.test(x)){y=T.parse(x);break}}}else u=x.data??u,d=x.format??d,f=x.loadParser??f,y={...y,...x};if(!m)throw new Error(`[Resolver] alias is undefined for this asset: ${y.src}`);y=this.buildResolvedAsset(y,{aliases:m,data:u,format:d,loadParser:f}),g.push(y)})}),m.forEach(_=>{this._assetMap[_]=g})})}resolveBundle(t){const e=hs(t);t=jt(t);const r={};return t.forEach(s=>{const n=this._bundles[s];if(n){const a=this.resolve(n),o={};for(const h in a){const l=a[h];o[this._extractAssetIdFromBundle(s,h)]=l}r[s]=o}}),e?r[t[0]]:r}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const r={};for(const s in e)r[s]=e[s].src;return r}return e.src}resolve(t){const e=hs(t);t=jt(t);const r={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const a=n[0],o=this._getPreferredOrder(n);o==null||o.priority.forEach(h=>{o.params[h].forEach(l=>{const c=n.filter(u=>u[h]?u[h]===l:!1);c.length&&(n=c)})}),this._resolverHash[s]=n[0]??a}else this._resolverHash[s]=this.buildResolvedAsset({alias:[s],src:s},{});r[s]=this._resolverHash[s]}),e?r[t[0]]:r}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const r=t[0],s=this._preferredOrder.find(n=>n.params.format.includes(r.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}buildResolvedAsset(t,e){const{aliases:r,data:s,loadParser:n,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=xt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=r??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=n??t.loadParser,t.format=a??t.format??xt.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class Pg{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Rg,this.loader=new ig,this.cache=oi,this._backgroundLoader=new Qm(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,a;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let o=t.manifest;typeof o=="string"&&(o=await this.load(o)),this.resolver.addManifest(o)}const e=((n=t.texturePreference)==null?void 0:n.resolution)??1,r=typeof e=="number"?[e]:e,s=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:r}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,r,s,n){this.resolver.add(t,e,r,s,n)}async load(t,e){this._initialized||await this.init();const r=hs(t),s=jt(t).map(o=>{if(typeof o!="string"){const h=this.resolver.getAlias(o);return h.some(l=>!this.resolver.hasKey(l))&&this.add(o),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),n=this.resolver.resolve(s),a=await this._mapLoadToResolve(n,e);return r?a[s[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let r=!1;typeof t=="string"&&(r=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},a=Object.keys(s);let o=0,h=0;const l=()=>{e==null||e(++o/h)},c=a.map(u=>{const d=s[u];return h+=Object.keys(d).length,this._mapLoadToResolve(d,l).then(f=>{n[u]=f})});return await Promise.all(c),r?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(r=>{this._backgroundLoader.add(Object.values(r))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return oi.get(t);const e={};for(let r=0;r<t.length;r++)e[r]=oi.get(t[r]);return e}async _mapLoadToResolve(t,e){const r=Object.values(t),s=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(r,e);this._backgroundLoader.active=!0;const a={};return r.forEach((o,h)=>{const l=n[o.src],c=[o.src];o.alias&&c.push(...o.alias),a[s[h]]=l,oi.set(c,l)}),a}async unload(t){this._initialized||await this.init();const e=jt(t).map(s=>typeof s!="string"?s.src:s),r=this.resolver.resolve(e);await this._unloadFromResolved(r)}async unloadBundle(t){this._initialized||await this.init(),t=jt(t);const e=this.resolver.resolveBundle(t),r=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(r)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(r=>{oi.remove(r.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const r of t.detections)t.skipDetections||await r.test()?e=await r.add(e):t.skipDetections||(e=await r.remove(e));return e=e.filter((r,s)=>e.indexOf(r)===s),e}get detections(){return this._detections}get preferWorkers(){return ls.config.preferWorkers}set preferWorkers(t){K("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(r=>r in t).forEach(r=>{e.config[r]=t[r]})})}}const Bi=new Pg;k.handleByList(P.LoadParser,Bi.loader.parsers).handleByList(P.ResolveParser,Bi.resolver.parsers).handleByList(P.CacheParser,Bi.cache.parsers).handleByList(P.DetectionParser,Bi.detections);const Mg={extension:P.CacheParser,test:i=>Array.isArray(i)&&i.every(t=>t instanceof L),getCacheableAssets:(i,t)=>{const e={};return i.forEach(r=>{t.forEach((s,n)=>{e[r+(n===0?"":n+1)]=s})}),e}};k.add(Mg);async function Fl(i){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=i});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(i)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const Fg={extension:{type:P.DetectionParser,priority:1},test:async()=>Fl("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async i=>[...i,"avif"],remove:async i=>i.filter(t=>t!=="avif")};k.add(Fg);const Bg={extension:{type:P.DetectionParser,priority:0},test:async()=>Fl("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async i=>[...i,"webp"],remove:async i=>i.filter(t=>t!=="webp")};k.add(Bg);const Bl=["png","jpg","jpeg"],Dg={extension:{type:P.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...Bl],remove:async i=>i.filter(t=>!Bl.includes(t))};k.add(Dg);const Og="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function da(i){return Og?!1:document.createElement("video").canPlayType(i)!==""}const Lg={extension:{type:P.DetectionParser,priority:0},test:async()=>da("video/webm"),add:async i=>[...i,"webm"],remove:async i=>i.filter(t=>t!=="webm")};k.add(Lg);const Ng={extension:{type:P.DetectionParser,priority:0},test:async()=>da("video/mp4"),add:async i=>[...i,"mp4","m4v"],remove:async i=>i.filter(t=>t!=="mp4"&&t!=="m4v")};k.add(Ng);const kg={extension:{type:P.DetectionParser,priority:0},test:async()=>da("video/ogg"),add:async i=>[...i,"ogv"],remove:async i=>i.filter(t=>t!=="ogv")};k.add(kg);const Ug={extension:P.ResolveParser,test:ls.test,parse:i=>{var t;return{resolution:parseFloat(((t=F.RETINA_PREFIX.exec(i))==null?void 0:t[1])??"1"),format:xt.extname(i).slice(1),src:i}}};k.add(Ug);var Rt=(i=>(i[i.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",i[i.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",i[i.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",i[i.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",i[i.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",i[i.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",i[i.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",i[i.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",i[i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",i[i.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",i[i.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",i[i.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35987]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",i[i.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",i[i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",i[i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",i[i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",i))(Rt||{});const cs={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35987:1,34798:1,37808:1,36492:1,36493:1,36494:1,36495:1};let de,Di;function Dl(){Di={bptc:de.getExtension("EXT_texture_compression_bptc"),astc:de.getExtension("WEBGL_compressed_texture_astc"),etc:de.getExtension("WEBGL_compressed_texture_etc"),s3tc:de.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:de.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:de.getExtension("WEBGL_compressed_texture_pvrtc")||de.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:de.getExtension("WEBGL_compressed_texture_etc1"),atc:de.getExtension("WEBGL_compressed_texture_atc")}}const Gg={extension:{type:P.DetectionParser,priority:2},test:async()=>{const i=F.ADAPTER.createCanvas().getContext("webgl");return i?(de=i,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async i=>{Di||Dl();const t=[];for(const e in Di)Di[e]&&t.push(e);return[...t,...i]},remove:async i=>(Di||Dl(),i.filter(t=>!(t in Di)))};k.add(Gg);class Hg extends kr{constructor(t,e={width:1,height:1,autoLoad:!0}){let r,s;typeof t=="string"?(r=t,s=new Uint8Array):(r=null,s=t),super(s,e),this.origin=r,this.buffer=s?new Fn(s):null,this._load=null,this.loaded=!1,this.origin!==null&&e.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(t=>t.blob()).then(t=>t.arrayBuffer()).then(t=>(this.data=new Uint32Array(t),this.buffer=new Fn(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class hi extends Hg{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=hi._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||hi._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,r){const s=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;s.pixelStorei(s.UNPACK_ALIGNMENT,4);for(let n=0,a=this.levels;n<a;n++){const{levelID:o,levelWidth:h,levelHeight:l,levelBuffer:c}=this._levelBuffers[n];s.compressedTexImage2D(s.TEXTURE_2D,o,this.format,h,l,0,c)}return!0}onBlobLoaded(){this._levelBuffers=hi._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,e,r,s,n,a,o){const h=new Array(r);let l=t.byteOffset,c=a,u=o,d=c+s-1&~(s-1),f=u+n-1&~(n-1),p=d*f*cs[e];for(let m=0;m<r;m++)h[m]={levelID:m,levelWidth:r>1?c:d,levelHeight:r>1?u:f,levelBuffer:new Uint8Array(t.buffer,l,p)},l+=p,c=c>>1||1,u=u>>1||1,d=c+s-1&~(s-1),f=u+n-1&~(n-1),p=d*f*cs[e];return h}}const fa=4,us=124,$g=32,Ol=20,Xg=542327876,ds={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},zg={SIZE:0,FLAGS:1,FOURCC:2,RGB_BITCOUNT:3,R_BIT_MASK:4,G_BIT_MASK:5,B_BIT_MASK:6,A_BIT_MASK:7},fs={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},Vg=1,Wg=2,jg=4,Yg=64,qg=512,Kg=131072,Zg=827611204,Jg=861165636,Qg=894720068,t0=808540228,e0=4,i0={[Zg]:Rt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Jg]:Rt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Qg]:Rt.COMPRESSED_RGBA_S3TC_DXT5_EXT},r0={70:Rt.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Rt.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Rt.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Rt.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Rt.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Rt.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Rt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Rt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Rt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:Rt.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:Rt.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:Rt.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:Rt.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function s0(i){const t=new Uint32Array(i);if(t[0]!==Xg)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(i,0,us/Uint32Array.BYTES_PER_ELEMENT),r=e[ds.HEIGHT],s=e[ds.WIDTH],n=e[ds.MIPMAP_COUNT],a=new Uint32Array(i,ds.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,$g/Uint32Array.BYTES_PER_ELEMENT),o=a[Vg];if(o&jg){const h=a[zg.FOURCC];if(h!==t0){const x=i0[h],y=fa+us,v=new Uint8Array(i,y);return[new hi(v,{format:x,width:s,height:r,levels:n})]}const l=fa+us,c=new Uint32Array(t.buffer,l,Ol/Uint32Array.BYTES_PER_ELEMENT),u=c[fs.DXGI_FORMAT],d=c[fs.RESOURCE_DIMENSION],f=c[fs.MISC_FLAG],p=c[fs.ARRAY_SIZE],m=r0[u];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${u}`);if(f===e0)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const g=new Array,_=fa+us+Ol;if(p===1)g.push(new Uint8Array(i,_));else{const x=cs[m];let y=0,v=s,T=r;for(let E=0;E<n;E++){const w=Math.max(1,v+3&-4),R=Math.max(1,T+3&-4),N=w*R*x;y+=N,v=v>>>1,T=T>>>1}let C=_;for(let E=0;E<p;E++)g.push(new Uint8Array(i,C,y)),C+=y}return g.map(x=>new hi(x,{format:m,width:s,height:r,levels:n}))}throw o&Yg?new Error("DDSParser does not support uncompressed texture data."):o&qg?new Error("DDSParser does not supported YUV uncompressed texture data."):o&Kg?new Error("DDSParser does not support single-channel (lumninance) texture data!"):o&Wg?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 Ll=[171,75,84,88,32,49,49,187,13,10,26,10],n0=67305985,qt={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},pa=64,Nl={[H.UNSIGNED_BYTE]:1,[H.UNSIGNED_SHORT]:2,[H.INT]:4,[H.UNSIGNED_INT]:4,[H.FLOAT]:4,[H.HALF_FLOAT]:8},a0={[A.RGBA]:4,[A.RGB]:3,[A.RG]:2,[A.RED]:1,[A.LUMINANCE]:1,[A.LUMINANCE_ALPHA]:2,[A.ALPHA]:1},o0={[H.UNSIGNED_SHORT_4_4_4_4]:2,[H.UNSIGNED_SHORT_5_5_5_1]:2,[H.UNSIGNED_SHORT_5_6_5]:2};function h0(i,t,e=!1){const r=new DataView(t);if(!l0(i,r))return null;const s=r.getUint32(qt.ENDIANNESS,!0)===n0,n=r.getUint32(qt.GL_TYPE,s),a=r.getUint32(qt.GL_FORMAT,s),o=r.getUint32(qt.GL_INTERNAL_FORMAT,s),h=r.getUint32(qt.PIXEL_WIDTH,s),l=r.getUint32(qt.PIXEL_HEIGHT,s)||1,c=r.getUint32(qt.PIXEL_DEPTH,s)||1,u=r.getUint32(qt.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=r.getUint32(qt.NUMBER_OF_FACES,s),f=r.getUint32(qt.NUMBER_OF_MIPMAP_LEVELS,s),p=r.getUint32(qt.BYTES_OF_KEY_VALUE_DATA,s);if(l===0||c!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(u!==1)throw new Error("WebGL does not support array textures");const m=4,g=4,_=h+3&-4,x=l+3&-4,y=new Array(u);let v=h*l;n===0&&(v=_*x);let T;if(n!==0?Nl[n]?T=Nl[n]*a0[a]:T=o0[n]:T=cs[o],T===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const C=e?u0(r,p,s):null;let E=v*T,w=h,R=l,N=_,q=x,O=pa+p;for(let b=0;b<f;b++){const S=r.getUint32(O,s);let G=O+4;for(let j=0;j<u;j++){let X=y[j];X||(X=y[j]=new Array(f)),X[b]={levelID:b,levelWidth:f>1||n!==0?w:N,levelHeight:f>1||n!==0?R:q,levelBuffer:new Uint8Array(t,G,E)},G+=E}O+=S+4,O=O%4!==0?O+4-O%4:O,w=w>>1||1,R=R>>1||1,N=w+m-1&~(m-1),q=R+g-1&~(g-1),E=N*q*T}return n!==0?{uncompressed:y.map(b=>{let S=b[0].levelBuffer,G=!1;return n===H.FLOAT?S=new Float32Array(b[0].levelBuffer.buffer,b[0].levelBuffer.byteOffset,b[0].levelBuffer.byteLength/4):n===H.UNSIGNED_INT?(G=!0,S=new Uint32Array(b[0].levelBuffer.buffer,b[0].levelBuffer.byteOffset,b[0].levelBuffer.byteLength/4)):n===H.INT&&(G=!0,S=new Int32Array(b[0].levelBuffer.buffer,b[0].levelBuffer.byteOffset,b[0].levelBuffer.byteLength/4)),{resource:new kr(S,{width:b[0].levelWidth,height:b[0].levelHeight}),type:n,format:G?c0(a):a}}),kvData:C}:{compressed:y.map(b=>new hi(null,{format:o,width:h,height:l,levels:f,levelBuffers:b})),kvData:C}}function l0(i,t){for(let e=0;e<Ll.length;e++)if(t.getUint8(e)!==Ll[e])return console.error(`${i} is not a valid *.ktx file!`),!1;return!0}function c0(i){switch(i){case A.RGBA:return A.RGBA_INTEGER;case A.RGB:return A.RGB_INTEGER;case A.RG:return A.RG_INTEGER;case A.RED:return A.RED_INTEGER;default:return i}}function u0(i,t,e){const r=new Map;let s=0;for(;s<t;){const n=i.getUint32(pa+s,e),a=pa+s+4,o=3-(n+3)%4;if(n===0||n>t-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let h=0;for(;h<n&&i.getUint8(a+h)!==0;h++);if(h===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const l=new TextDecoder().decode(new Uint8Array(i.buffer,a,h)),c=new DataView(i.buffer,a+h+1,n-h-1);r.set(l,c),s+=4+n+o}return r}const d0={extension:{type:P.LoadParser,priority:Yt.High},name:"loadDDS",test(i){return Ue(i,".dds")},async load(i,t,e){const r=await(await F.ADAPTER.fetch(i)).arrayBuffer(),s=s0(r).map(n=>{const a=new W(n,{mipmap:ee.OFF,alphaMode:Ot.NO_PREMULTIPLIED_ALPHA,resolution:Te(i),...t.data});return hr(a,e,i)});return s.length===1?s[0]:s},unload(i){Array.isArray(i)?i.forEach(t=>t.destroy(!0)):i.destroy(!0)}};k.add(d0);const f0={extension:{type:P.LoadParser,priority:Yt.High},name:"loadKTX",test(i){return Ue(i,".ktx")},async load(i,t,e){const r=await(await F.ADAPTER.fetch(i)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:a}=h0(i,r),o=s??n,h={mipmap:ee.OFF,alphaMode:Ot.NO_PREMULTIPLIED_ALPHA,resolution:Te(i),...t.data},l=o.map(c=>{o===n&&Object.assign(h,{type:c.type,format:c.format});const u=c.resource??c,d=new W(u,h);return d.ktxKeyValueData=a,hr(d,e,i)});return l.length===1?l[0]:l},unload(i){Array.isArray(i)?i.forEach(t=>t.destroy(!0)):i.destroy(!0)}};k.add(f0);const p0=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],m0={extension:P.ResolveParser,test:i=>{const t=xt.extname(i).slice(1);return["basis","ktx","dds"].includes(t)},parse:i=>{var r,s;const t=i.split("."),e=t.pop();if(["ktx","dds"].includes(e)){const n=t.pop();if(p0.includes(n))return{resolution:parseFloat(((r=F.RETINA_PREFIX.exec(i))==null?void 0:r[1])??"1"),format:n,src:i}}return{resolution:parseFloat(((s=F.RETINA_PREFIX.exec(i))==null?void 0:s[1])??"1"),format:e,src:i}}};k.add(m0);const ps=new Y,g0=4,kl=class yr{constructor(t){this.renderer=t,this._rendererPremultipliedAlpha=!1}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(t,e,r,s){const n=new Image;return n.src=await this.base64(t,e,r,s),n}async base64(t,e,r,s){const n=this.canvas(t,s);if(n.toBlob!==void 0)return new Promise((a,o)=>{n.toBlob(h=>{if(!h){o(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>a(l.result),l.onerror=o,l.readAsDataURL(h)},e,r)});if(n.toDataURL!==void 0)return n.toDataURL(e,r);if(n.convertToBlob!==void 0){const a=await n.convertToBlob({type:e,quality:r});return new Promise((o,h)=>{const l=new FileReader;l.onload=()=>o(l.result),l.onerror=h,l.readAsDataURL(a)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const{pixels:r,width:s,height:n,flipY:a,premultipliedAlpha:o}=this._rawPixels(t,e);a&&yr._flipY(r,s,n),o&&yr._unpremultiplyAlpha(r);const h=new qf(s,n,1),l=new ImageData(new Uint8ClampedArray(r.buffer),s,n);return h.context.putImageData(l,0,0),h.canvas}pixels(t,e){const{pixels:r,width:s,height:n,flipY:a,premultipliedAlpha:o}=this._rawPixels(t,e);return a&&yr._flipY(r,s,n),o&&yr._unpremultiplyAlpha(r),r}_rawPixels(t,e){const r=this.renderer;if(!r)throw new Error("The Extract has already been destroyed");let s,n=!1,a=!1,o,h=!1;t&&(t instanceof si?o=t:(o=r.generateTexture(t,{region:e,resolution:r.resolution,multisample:r.multisample}),h=!0,e&&(ps.width=e.width,ps.height=e.height,e=ps)));const l=r.gl;if(o){if(s=o.baseTexture.resolution,e=e??o.frame,n=!1,a=o.baseTexture.alphaMode>0&&o.baseTexture.format===A.RGBA,!h){r.renderTexture.bind(o);const f=o.framebuffer.glFramebuffers[r.CONTEXT_UID];f.blitFramebuffer&&r.framebuffer.bind(f.blitFramebuffer)}}else s=r.resolution,e||(e=ps,e.width=r.width/s,e.height=r.height/s),n=!0,a=this._rendererPremultipliedAlpha,r.renderTexture.bind();const c=Math.max(Math.round(e.width*s),1),u=Math.max(Math.round(e.height*s),1),d=new Uint8Array(g0*c*u);return l.readPixels(Math.round(e.x*s),Math.round(e.y*s),c,u,l.RGBA,l.UNSIGNED_BYTE,d),h&&(o==null||o.destroy(!0)),{pixels:d,width:c,height:u,flipY:n,premultipliedAlpha:a}}destroy(){this.renderer=null}static _flipY(t,e,r){const s=e<<2,n=r>>1,a=new Uint8Array(s);for(let o=0;o<n;o++){const h=o*s,l=(r-o-1)*s;a.set(t.subarray(h,h+s)),t.copyWithin(h,l,l+s),t.set(a,l)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const e=t.length;for(let r=0;r<e;r+=4){const s=t[r+3];if(s!==0){const n=255.001/s;t[r]=t[r]*n+.5,t[r+1]=t[r+1]*n+.5,t[r+2]=t[r+2]*n+.5}}}};kl.extension={name:"extract",type:P.RendererSystem};let y0=kl;k.add(y0);const ms={build(i){const t=i.points;let e,r,s,n,a,o;if(i.type===It.CIRC){const p=i.shape;e=p.x,r=p.y,a=o=p.radius,s=n=0}else if(i.type===It.ELIP){const p=i.shape;e=p.x,r=p.y,a=p.width,o=p.height,s=n=0}else{const p=i.shape,m=p.width/2,g=p.height/2;e=p.x+m,r=p.y+g,a=o=Math.max(0,Math.min(p.radius,Math.min(m,g))),s=m-a,n=g-o}if(!(a>=0&&o>=0&&s>=0&&n>=0)){t.length=0;return}const h=Math.ceil(2.3*Math.sqrt(a+o)),l=h*8+(s?4:0)+(n?4:0);if(t.length=l,l===0)return;if(h===0){t.length=8,t[0]=t[6]=e+s,t[1]=t[3]=r+n,t[2]=t[4]=e-s,t[5]=t[7]=r-n;return}let c=0,u=h*4+(s?2:0)+2,d=u,f=l;{const p=s+a,m=n,g=e+p,_=e-p,x=r+m;if(t[c++]=g,t[c++]=x,t[--u]=x,t[--u]=_,n){const y=r-m;t[d++]=_,t[d++]=y,t[--f]=y,t[--f]=g}}for(let p=1;p<h;p++){const m=Math.PI/2*(p/h),g=s+Math.cos(m)*a,_=n+Math.sin(m)*o,x=e+g,y=e-g,v=r+_,T=r-_;t[c++]=x,t[c++]=v,t[--u]=v,t[--u]=y,t[d++]=y,t[d++]=T,t[--f]=T,t[--f]=x}{const p=s,m=n+o,g=e+p,_=e-p,x=r+m,y=r-m;t[c++]=g,t[c++]=x,t[--f]=y,t[--f]=g,s&&(t[c++]=_,t[c++]=x,t[--f]=y,t[--f]=_)}},triangulate(i,t){const e=i.points,r=t.points,s=t.indices;if(e.length===0)return;let n=r.length/2;const a=n;let o,h;if(i.type!==It.RREC){const c=i.shape;o=c.x,h=c.y}else{const c=i.shape;o=c.x+c.width/2,h=c.y+c.height/2}const l=i.matrix;r.push(i.matrix?l.a*o+l.c*h+l.tx:o,i.matrix?l.b*o+l.d*h+l.ty:h),n++,r.push(e[0],e[1]);for(let c=2;c<e.length;c+=2)r.push(e[c],e[c+1]),s.push(n++,a,n);s.push(a+1,a,n)}};function Ul(i,t=!1){const e=i.length;if(e<6)return;let r=0;for(let s=0,n=i[e-2],a=i[e-1];s<e;s+=2){const o=i[s],h=i[s+1];r+=(o-n)*(h+a),n=o,a=h}if(!t&&r>0||t&&r<=0){const s=e/2;for(let n=s+s%2;n<e;n+=2){const a=e-n-2,o=e-n-1,h=n,l=n+1;[i[a],i[h]]=[i[h],i[a]],[i[o],i[l]]=[i[l],i[o]]}}}const Gl={build(i){i.points=i.shape.points.slice()},triangulate(i,t){let e=i.points;const r=i.holes,s=t.points,n=t.indices;if(e.length>=6){Ul(e,!1);const a=[];for(let l=0;l<r.length;l++){const c=r[l];Ul(c.points,!0),a.push(e.length/2),e=e.concat(c.points)}const o=eu(e,a,2);if(!o)return;const h=s.length/2;for(let l=0;l<o.length;l+=3)n.push(o[l]+h),n.push(o[l+1]+h),n.push(o[l+2]+h);for(let l=0;l<e.length;l++)s.push(e[l])}}},_0={build(i){const t=i.shape,e=t.x,r=t.y,s=t.width,n=t.height,a=i.points;a.length=0,s>=0&&n>=0&&a.push(e,r,e+s,r,e+s,r+n,e,r+n)},triangulate(i,t){const e=i.points,r=t.points;if(e.length===0)return;const s=r.length/2;r.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},v0={build(i){ms.build(i)},triangulate(i,t){ms.triangulate(i,t)}};var Ht=(i=>(i.MITER="miter",i.BEVEL="bevel",i.ROUND="round",i))(Ht||{}),Ge=(i=>(i.BUTT="butt",i.ROUND="round",i.SQUARE="square",i))(Ge||{});const Oi={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(i,t=20){if(!this.adaptive||!i||isNaN(i))return t;let e=Math.ceil(i/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class Hl{static curveTo(t,e,r,s,n,a){const o=a[a.length-2],h=a[a.length-1]-e,l=o-t,c=s-e,u=r-t,d=Math.abs(h*u-l*c);if(d<1e-8||n===0)return(a[a.length-2]!==t||a[a.length-1]!==e)&&a.push(t,e),null;const f=h*h+l*l,p=c*c+u*u,m=h*c+l*u,g=n*Math.sqrt(f)/d,_=n*Math.sqrt(p)/d,x=g*m/f,y=_*m/p,v=g*u+_*l,T=g*c+_*h,C=l*(_+x),E=h*(_+x),w=u*(g+y),R=c*(g+y),N=Math.atan2(E-T,C-v),q=Math.atan2(R-T,w-v);return{cx:v+t,cy:T+e,radius:n,startAngle:N,endAngle:q,anticlockwise:l*c>u*h}}static arc(t,e,r,s,n,a,o,h,l){const c=o-a,u=Oi._segmentsCount(Math.abs(c)*n,Math.ceil(Math.abs(c)/Gr)*40),d=c/(u*2),f=d*2,p=Math.cos(d),m=Math.sin(d),g=u-1,_=g%1/g;for(let x=0;x<=g;++x){const y=x+_*x,v=d+a+f*y,T=Math.cos(v),C=-Math.sin(v);l.push((p*T+m*C)*n+r,(p*-C+m*T)*n+s)}}}class x0{constructor(){this.reset()}begin(t,e,r){this.reset(),this.style=t,this.start=e,this.attribStart=r}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 ma{static curveLength(t,e,r,s,n,a,o,h){let l=0,c=0,u=0,d=0,f=0,p=0,m=0,g=0,_=0,x=0,y=0,v=t,T=e;for(let C=1;C<=10;++C)c=C/10,u=c*c,d=u*c,f=1-c,p=f*f,m=p*f,g=m*t+3*p*c*r+3*f*u*n+d*o,_=m*e+3*p*c*s+3*f*u*a+d*h,x=v-g,y=T-_,v=g,T=_,l+=Math.sqrt(x*x+y*y);return l}static curveTo(t,e,r,s,n,a,o){const h=o[o.length-2],l=o[o.length-1];o.length-=2;const c=Oi._segmentsCount(ma.curveLength(h,l,t,e,r,s,n,a));let u=0,d=0,f=0,p=0,m=0;o.push(h,l);for(let g=1,_=0;g<=c;++g)_=g/c,u=1-_,d=u*u,f=d*u,p=_*_,m=p*_,o.push(f*h+3*d*_*t+3*u*p*r+m*n,f*l+3*d*_*e+3*u*p*s+m*a)}}function $l(i,t,e,r,s,n,a,o){const h=i-e*s,l=t-r*s,c=i+e*n,u=t+r*n;let d,f;a?(d=r,f=-e):(d=-r,f=e);const p=h+d,m=l+f,g=c+d,_=u+f;return o.push(p,m,g,_),2}function li(i,t,e,r,s,n,a,o){const h=e-i,l=r-t;let c=Math.atan2(h,l),u=Math.atan2(s-i,n-t);o&&c<u?c+=Math.PI*2:!o&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,p=Math.abs(f),m=Math.sqrt(h*h+l*l),g=(15*p*Math.sqrt(m)/Math.PI>>0)+1,_=f/g;if(d+=_,o){a.push(i,t,e,r);for(let x=1,y=d;x<g;x++,y+=_)a.push(i,t,i+Math.sin(y)*m,t+Math.cos(y)*m);a.push(i,t,s,n)}else{a.push(e,r,i,t);for(let x=1,y=d;x<g;x++,y+=_)a.push(i+Math.sin(y)*m,t+Math.cos(y)*m,i,t);a.push(s,n,i,t)}return g*2}function b0(i,t){const e=i.shape;let r=i.points||e.points.slice();const s=t.closePointEps;if(r.length===0)return;const n=i.lineStyle,a=new J(r[0],r[1]),o=new J(r[r.length-2],r[r.length-1]),h=e.type!==It.POLY||e.closeStroke,l=Math.abs(a.x-o.x)<s&&Math.abs(a.y-o.y)<s;if(h){r=r.slice(),l&&(r.pop(),r.pop(),o.set(r[r.length-2],r[r.length-1]));const X=(a.x+o.x)*.5,V=(o.y+a.y)*.5;r.unshift(X,V),r.push(X,V)}const c=t.points,u=r.length/2;let d=r.length;const f=c.length/2,p=n.width/2,m=p*p,g=n.miterLimit*n.miterLimit;let _=r[0],x=r[1],y=r[2],v=r[3],T=0,C=0,E=-(x-v),w=_-y,R=0,N=0,q=Math.sqrt(E*E+w*w);E/=q,w/=q,E*=p,w*=p;const O=n.alignment,b=(1-O)*2,S=O*2;h||(n.cap===Ge.ROUND?d+=li(_-E*(b-S)*.5,x-w*(b-S)*.5,_-E*b,x-w*b,_+E*S,x+w*S,c,!0)+2:n.cap===Ge.SQUARE&&(d+=$l(_,x,E,w,b,S,!0,c))),c.push(_-E*b,x-w*b,_+E*S,x+w*S);for(let X=1;X<u-1;++X){_=r[(X-1)*2],x=r[(X-1)*2+1],y=r[X*2],v=r[X*2+1],T=r[(X+1)*2],C=r[(X+1)*2+1],E=-(x-v),w=_-y,q=Math.sqrt(E*E+w*w),E/=q,w/=q,E*=p,w*=p,R=-(v-C),N=y-T,q=Math.sqrt(R*R+N*N),R/=q,N/=q,R*=p,N*=p;const V=y-_,nt=x-v,I=y-T,M=C-v,Q=V*I+nt*M,et=nt*I-M*V,it=et<0;if(Math.abs(et)<.001*Math.abs(Q)){c.push(y-E*b,v-w*b,y+E*S,v+w*S),Q>=0&&(n.join===Ht.ROUND?d+=li(y,v,y-E*b,v-w*b,y-R*b,v-N*b,c,!1)+4:d+=2,c.push(y-R*S,v-N*S,y+R*b,v+N*b));continue}const At=(-E+_)*(-w+v)-(-E+y)*(-w+x),mt=(-R+T)*(-N+v)-(-R+y)*(-N+C),St=(V*mt-I*At)/et,Ft=(M*At-nt*mt)/et,Nt=(St-y)*(St-y)+(Ft-v)*(Ft-v),Pt=y+(St-y)*b,at=v+(Ft-v)*b,gt=y-(St-y)*S,Tt=v-(Ft-v)*S,me=Math.min(V*V+nt*nt,I*I+M*M),ge=it?b:S,pr=me+ge*ge*m,u_=Nt<=pr;let Bs=n.join;if(Bs===Ht.MITER&&Nt/m>g&&(Bs=Ht.BEVEL),u_)switch(Bs){case Ht.MITER:{c.push(Pt,at,gt,Tt);break}case Ht.BEVEL:{it?c.push(Pt,at,y+E*S,v+w*S,Pt,at,y+R*S,v+N*S):c.push(y-E*b,v-w*b,gt,Tt,y-R*b,v-N*b,gt,Tt),d+=2;break}case Ht.ROUND:{it?(c.push(Pt,at,y+E*S,v+w*S),d+=li(y,v,y+E*S,v+w*S,y+R*S,v+N*S,c,!0)+4,c.push(Pt,at,y+R*S,v+N*S)):(c.push(y-E*b,v-w*b,gt,Tt),d+=li(y,v,y-E*b,v-w*b,y-R*b,v-N*b,c,!1)+4,c.push(y-R*b,v-N*b,gt,Tt));break}}else{switch(c.push(y-E*b,v-w*b,y+E*S,v+w*S),Bs){case Ht.MITER:{it?c.push(gt,Tt,gt,Tt):c.push(Pt,at,Pt,at),d+=2;break}case Ht.ROUND:{it?d+=li(y,v,y+E*S,v+w*S,y+R*S,v+N*S,c,!0)+2:d+=li(y,v,y-E*b,v-w*b,y-R*b,v-N*b,c,!1)+2;break}}c.push(y-R*b,v-N*b,y+R*S,v+N*S),d+=2}}_=r[(u-2)*2],x=r[(u-2)*2+1],y=r[(u-1)*2],v=r[(u-1)*2+1],E=-(x-v),w=_-y,q=Math.sqrt(E*E+w*w),E/=q,w/=q,E*=p,w*=p,c.push(y-E*b,v-w*b,y+E*S,v+w*S),h||(n.cap===Ge.ROUND?d+=li(y-E*(b-S)*.5,v-w*(b-S)*.5,y-E*b,v-w*b,y+E*S,v+w*S,c,!1)+2:n.cap===Ge.SQUARE&&(d+=$l(y,v,E,w,b,S,!1,c)));const G=t.indices,j=Oi.epsilon*Oi.epsilon;for(let X=f;X<d+f-2;++X)_=c[X*2],x=c[X*2+1],y=c[(X+1)*2],v=c[(X+1)*2+1],T=c[(X+2)*2],C=c[(X+2)*2+1],!(Math.abs(_*(v-C)+y*(C-x)+T*(x-v))<j)&&G.push(X,X+1,X+2)}function T0(i,t){let e=0;const r=i.shape,s=i.points||r.points,n=r.type!==It.POLY||r.closeStroke;if(s.length===0)return;const a=t.points,o=t.indices,h=s.length/2,l=a.length/2;let c=l;for(a.push(s[0],s[1]),e=1;e<h;e++)a.push(s[e*2],s[e*2+1]),o.push(c,c+1),c++;n&&o.push(c,l)}function Xl(i,t){i.lineStyle.native?T0(i,t):b0(i,t)}class ga{static curveLength(t,e,r,s,n,a){const o=t-2*r+n,h=e-2*s+a,l=2*r-2*t,c=2*s-2*e,u=4*(o*o+h*h),d=4*(o*l+h*c),f=l*l+c*c,p=2*Math.sqrt(u+d+f),m=Math.sqrt(u),g=2*u*m,_=2*Math.sqrt(f),x=d/m;return(g*p+m*d*(p-_)+(4*f*u-d*d)*Math.log((2*m+x+p)/(x+_)))/(4*g)}static curveTo(t,e,r,s,n){const a=n[n.length-2],o=n[n.length-1],h=Oi._segmentsCount(ga.curveLength(a,o,t,e,r,s));let l=0,c=0;for(let u=1;u<=h;++u){const d=u/h;l=a+(t-a)*d,c=o+(e-o)*d,n.push(l+(t+(r-t)*d-l)*d,c+(e+(s-e)*d-c)*d)}}}const ya={[It.POLY]:Gl,[It.CIRC]:ms,[It.ELIP]:ms,[It.RECT]:_0,[It.RREC]:v0},zl=[],gs=[];class ys{constructor(t,e=null,r=null,s=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=r,this.fillStyle=e,this.matrix=s,this.type=t.type}clone(){return new ys(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 Li=new J,Vl=class Mc extends Eh{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 ns,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(),gs.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),zl.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,r=null,s=null){const n=new ys(t,e,r,s);return this.graphicsData.push(n),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const r=new ys(t,null,null,e),s=this.graphicsData[this.graphicsData.length-1];return r.lineStyle=s.lineStyle,s.holes.push(r),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 r=0;r<e.length;++r){const s=e[r];if(s.fillStyle.visible&&s.shape&&(s.matrix?s.matrix.applyInverse(t,Li):Li.copyFrom(t),s.shape.contains(Li.x,Li.y))){let n=!1;if(s.holes){for(let a=0;a<s.holes.length;a++)if(s.holes[a].shape.contains(Li.x,Li.y)){n=!0;break}}if(!n)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let r=null,s=null;this.batches.length>0&&(r=this.batches[this.batches.length-1],s=r.style);for(let h=this.shapeIndex;h<e.length;h++){this.shapeIndex++;const l=e[h],c=l.fillStyle,u=l.lineStyle;ya[l.type].build(l),l.matrix&&this.transformPoints(l.points,l.matrix),(c.visible||u.visible)&&this.processHoles(l.holes);for(let d=0;d<2;d++){const f=d===0?c:u;if(!f.visible)continue;const p=f.texture.baseTexture,m=this.indices.length,g=this.points.length/2;p.wrapMode=Me.REPEAT,d===0?this.processFill(l):this.processLine(l);const _=this.points.length/2-g;_!==0&&(r&&!this._compareStyles(s,f)&&(r.end(m,g),r=null),r||(r=zl.pop()||new x0,r.begin(f,m,g),this.batches.push(r),s=f),this.addUvs(this.points,t,f.texture,g,_,f.matrix))}}const n=this.indices.length,a=this.points.length/2;if(r&&r.end(n,a),this.batches.length===0){this.batchable=!0;return}const o=a>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&o===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=o?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const r=this.graphicsData[t],s=r.fillStyle,n=r.lineStyle;if(s&&!s.texture.baseTexture.valid||n&&!n.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,r=t.length;e<r;e++){const s=t[e];for(let n=0;n<s.size;n++){const a=s.start+n;this.indicesUint16[a]=this.indicesUint16[a]-s.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let e=0;e<t.length;e++)if(t[e].style.native)return!1;return this.points.length<Mc.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++W._globalBatch;for(let u=0;u<this.drawCalls.length;u++)this.drawCalls[u].texArray.clear(),gs.push(this.drawCalls[u]);this.drawCalls.length=0;const e=this.colors,r=this.textureIds;let s=gs.pop();s||(s=new Hn,s.texArray=new jn),s.texArray.count=0,s.start=0,s.size=0,s.type=te.TRIANGLES;let n=0,a=null,o=0,h=!1,l=te.TRIANGLES,c=0;this.drawCalls.push(s);for(let u=0;u<this.batches.length;u++){const d=this.batches[u],f=8,p=d.style,m=p.texture.baseTexture;h!==!!p.native&&(h=!!p.native,l=h?te.LINES:te.TRIANGLES,a=null,n=f,t++),a!==m&&(a=m,m._batchEnabled!==t&&(n===f&&(t++,n=0,s.size>0&&(s=gs.pop(),s||(s=new Hn,s.texArray=new jn),this.drawCalls.push(s)),s.start=c,s.size=0,s.texArray.count=0,s.type=l),m.touched=1,m._batchEnabled=t,m._batchLocation=n,m.wrapMode=Me.REPEAT,s.texArray.elements[s.texArray.count++]=m,n++)),s.size+=d.size,c+=d.size,o=m._batchLocation,this.addColors(e,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(r,o,d.attribSize,d.attribStart)}W._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,r=this.colors,s=this.textureIds,n=new ArrayBuffer(t.length*3*4),a=new Float32Array(n),o=new Uint32Array(n);let h=0;for(let l=0;l<t.length/2;l++)a[h++]=t[l*2],a[h++]=t[l*2+1],a[h++]=e[l*2],a[h++]=e[l*2+1],o[h++]=r[l],a[h++]=s[l];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?Gl.triangulate(t,this):ya[t.type].triangulate(t,this)}processLine(t){Xl(t,this);for(let e=0;e<t.holes.length;e++)Xl(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const r=t[e];ya[r.type].build(r),r.matrix&&this.transformPoints(r.points,r.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 r=0;r<t.length/2;r++){const s=t[r*2],n=t[r*2+1];t[r*2]=e.a*s+e.c*n+e.tx,t[r*2+1]=e.b*s+e.d*n+e.ty}}addColors(t,e,r,s,n=0){const a=tt.shared.setValue(e).toLittleEndianNumber(),o=tt.shared.setValue(a).toPremultiplied(r);t.length=Math.max(t.length,n+s);for(let h=0;h<s;h++)t[n+h]=o}addTextureIds(t,e,r,s=0){t.length=Math.max(t.length,s+r);for(let n=0;n<r;n++)t[s+n]=e}addUvs(t,e,r,s,n,a=null){let o=0;const h=e.length,l=r.frame;for(;o<n;){let u=t[(s+o)*2],d=t[(s+o)*2+1];if(a){const f=a.a*u+a.c*d+a.tx;d=a.b*u+a.d*d+a.ty,u=f}o++,e.push(u/l.width,d/l.height)}const c=r.baseTexture;(l.width<c.width||l.height<c.height)&&this.adjustUvs(e,r,h,n)}adjustUvs(t,e,r,s){const n=e.baseTexture,a=1e-6,o=r+s*2,h=e.frame,l=h.width/n.width,c=h.height/n.height;let u=h.x/h.width,d=h.y/h.height,f=Math.floor(t[r]+a),p=Math.floor(t[r+1]+a);for(let m=r+2;m<o;m+=2)f=Math.min(f,Math.floor(t[m]+a)),p=Math.min(p,Math.floor(t[m+1]+a));u-=f,d-=p;for(let m=r;m<o;m+=2)t[m]=(t[m]+u)*l,t[m+1]=(t[m+1]+d)*c}};Vl.BATCHABLE_SIZE=100;let w0=Vl;class _s{constructor(){this.color=16777215,this.alpha=1,this.texture=L.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new _s;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=L.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class _a extends _s{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=Ge.BUTT,this.join=Ht.MITER,this.miterLimit=10}clone(){const t=new _a;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=Ge.BUTT,this.join=Ht.MITER,this.miterLimit=10}}const va={},xa=class ks extends bt{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 _s,this._lineStyle=new _a,this._matrix=null,this._holeMode=!1,this.state=le.for2d(),this._geometry=t||new w0,this._geometry.refCount++,this._transformID=-1,this._tintColor=new tt(16777215),this.blendMode=z.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new ks(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,r,s=.5,n=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:r,alignment:s,native:n}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:L.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:Ge.BUTT,join:Ht.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const r=t.width>0&&t.alpha>0;return r?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:r},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 Je,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Je,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 r=this.currentPath.points,s=r[r.length-2],n=r[r.length-1];return(s!==t||n!==e)&&r.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,r,s){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),ga.curveTo(t,e,r,s,n),this}bezierCurveTo(t,e,r,s,n,a){return this._initCurve(),ma.curveTo(t,e,r,s,n,a,this.currentPath.points),this}arcTo(t,e,r,s,n){this._initCurve(t,e);const a=this.currentPath.points,o=Hl.curveTo(t,e,r,s,n,a);if(o){const{cx:h,cy:l,radius:c,startAngle:u,endAngle:d,anticlockwise:f}=o;this.arc(h,l,c,u,d,f)}return this}arc(t,e,r,s,n,a=!1){if(s===n)return this;if(!a&&n<=s?n+=Gr:a&&s<=n&&(s+=Gr),n-s===0)return this;const o=t+Math.cos(s)*r,h=e+Math.sin(s)*r,l=this._geometry.closePointEps;let c=this.currentPath?this.currentPath.points:null;if(c){const u=Math.abs(c[c.length-2]-o),d=Math.abs(c[c.length-1]-h);u<l&&d<l||c.push(o,h)}else this.moveTo(o,h),c=this.currentPath.points;return Hl.arc(o,h,t,e,r,s,n,a,c),this}beginFill(t=0,e){return this.beginTextureFill({texture:L.WHITE,color:t,alpha:e})}normalizeColor(t){const e=tt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:L.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const r=t.alpha>0;return r?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:r},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,r,s){return this.drawShape(new Y(t,e,r,s))}drawRoundedRect(t,e,r,s,n){return this.drawShape(new zr(t,e,r,s,n))}drawCircle(t,e,r){return this.drawShape(new $r(t,e,r))}drawEllipse(t,e,r,s){return this.drawShape(new Xr(t,e,r,s))}drawPolygon(...t){let e,r=!0;const s=t[0];s.points?(r=s.closeStroke,e=s.points):Array.isArray(t[0])?e=t[0]:e=t;const n=new Je(e);return n.closeStroke=r,this.drawShape(n),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===It.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,r=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=r,this.vertexData=new Float32Array(t.points);for(let s=0;s<r;s++){const n=t.batches[s],a=n.style.color,o=new Float32Array(this.vertexData.buffer,n.attribStart*4*2,n.attribSize*2),h=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),l=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),c={vertexData:o,blendMode:e,indices:l,uvs:h,_batchRGB:tt.shared.setValue(a).toRgbArray(),_tintRGB:a,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[s]=c}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,r=this.batches.length;e<r;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),r=this._geometry,s=this.worldAlpha,n=e.uniforms,a=r.drawCalls;n.translationMatrix=this.transform.worldTransform,tt.shared.setValue(this._tintColor).premultiply(s).toArray(n.tint),t.shader.bind(e),t.geometry.bind(r,e),t.state.set(this.state);for(let o=0,h=a.length;o<h;o++)this._renderDrawCallDirect(t,r.drawCalls[o])}_renderDrawCallDirect(t,e){const{texArray:r,type:s,size:n,start:a}=e,o=r.count;for(let h=0;h<o;h++)t.texture.bind(r.elements[h],h);t.geometry.draw(s,n,a)}_resolveDirectShader(t){let e=this.shader;const r=this.pluginName;if(!e){if(!va[r]){const{maxTextures:s}=t.plugins[r],n=new Int32Array(s);for(let h=0;h<s;h++)n[h]=h;const a={tint:new Float32Array([1,1,1,1]),translationMatrix:new rt,default:Vt.from({uSamplers:n},!0)},o=t.plugins[r]._shader.program;va[r]=new ce(o,a)}e=va[r]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:r,maxX:s,maxY:n}=t.bounds;this._bounds.addFrame(this.transform,e,r,s,n)}containsPoint(t){return this.worldTransform.applyInverse(t,ks._TEMP_POINT),this._geometry.containsPoint(ks._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=tt.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,r=e.a,s=e.b,n=e.c,a=e.d,o=e.tx,h=e.ty,l=this._geometry.points,c=this.vertexData;let u=0;for(let d=0;d<l.length;d+=2){const f=l[d],p=l[d+1];c[u++]=r*f+n*p+o,c[u++]=a*p+s*f+h}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(t)}};xa.curves=Oi,xa._TEMP_POINT=new J;let ba=xa;class E0{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 Ta=new J,Wl=new Je,jl=class Fc extends bt{constructor(t,e,r,s=te.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=r||le.for2d(),this.drawMode=s,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=F.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const e=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===te.TRIANGLES&&e.length<Fc.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const e=this.shader;e.alpha=this.worldAlpha,e.update&&e.update(),t.batch.flush(),e.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(e),t.state.set(this.state),t.geometry.bind(this.geometry,e),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const e=this.geometry,r=this.shader;r.uvMatrix&&(r.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=r._tintRGB,this._texture=r.texture;const s=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[s]),t.plugins[s].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,r=t._updateID;if(r===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 s=this.transform.worldTransform,n=s.a,a=s.b,o=s.c,h=s.d,l=s.tx,c=s.ty,u=this.vertexData;for(let d=0;d<u.length/2;d++){const f=e[d*2],p=e[d*2+1];u[d*2]=n*f+o*p+l,u[d*2+1]=a*f+h*p+c}if(this._roundPixels){const d=F.RESOLUTION;for(let f=0;f<u.length;++f)u[f]=Math.round(u[f]*d)/d}this.vertexDirty=r}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new E0(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,Ta);const e=this.geometry.getBuffer("aVertexPosition").data,r=Wl.points,s=this.geometry.getIndex().data,n=s.length,a=this.drawMode===4?3:1;for(let o=0;o+2<n;o+=a){const h=s[o]*2,l=s[o+1]*2,c=s[o+2]*2;if(r[0]=e[h],r[1]=e[h+1],r[2]=e[l],r[3]=e[l+1],r[4]=e[c],r[5]=e[c+1],Wl.contains(Ta.x,Ta.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}};jl.BATCHABLE_SIZE=100;let Yl=jl;class A0 extends Ne{constructor(t,e,r){super();const s=new ut(t),n=new ut(e,!0),a=new ut(r,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,H.FLOAT).addAttribute("aTextureCoord",n,2,!1,H.FLOAT).addIndex(a),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var S0=`varying vec2 vTextureCoord;
|
|
912
|
-
uniform vec4 uColor;
|
|
913
|
-
|
|
914
|
-
uniform sampler2D uSampler;
|
|
915
|
-
|
|
916
|
-
void main(void)
|
|
917
|
-
{
|
|
918
|
-
gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
|
|
919
|
-
}
|
|
920
|
-
`,C0=`attribute vec2 aVertexPosition;
|
|
921
|
-
attribute vec2 aTextureCoord;
|
|
922
|
-
|
|
923
|
-
uniform mat3 projectionMatrix;
|
|
924
|
-
uniform mat3 translationMatrix;
|
|
925
|
-
uniform mat3 uTextureMatrix;
|
|
926
|
-
|
|
927
|
-
varying vec2 vTextureCoord;
|
|
928
|
-
|
|
929
|
-
void main(void)
|
|
930
|
-
{
|
|
931
|
-
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
932
|
-
|
|
933
|
-
vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
|
|
934
|
-
}
|
|
935
|
-
`;class ql extends ce{constructor(t,e){const r={uSampler:t,alpha:1,uTextureMatrix:rt.IDENTITY,uColor:new Float32Array([1,1,1,1])};e=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},e),e.uniforms&&Object.assign(r,e.uniforms),super(e.program||Ee.from(C0,S0),r),this._colorDirty=!1,this.uvMatrix=new Vh(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new tt(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;tt.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class Kl{constructor(t,e,r){this.geometry=new Ne,this.indexBuffer=null,this.size=r,this.dynamicProperties=[],this.staticProperties=[];for(let s=0;s<t.length;++s){let n=t[s];n={attributeName:n.attributeName,size:n.size,uploadFunction:n.uploadFunction,type:n.type||H.FLOAT,offset:n.offset},e[s]?this.dynamicProperties.push(n):this.staticProperties.push(n)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const t=this.geometry;let e=0;this.indexBuffer=new ut(jf(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(let a=0;a<this.dynamicProperties.length;++a){const o=this.dynamicProperties[a];o.offset=e,e+=o.size,this.dynamicStride+=o.size}const r=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(r),this.dynamicDataUint32=new Uint32Array(r),this.dynamicBuffer=new ut(this.dynamicData,!1,!1);let s=0;this.staticStride=0;for(let a=0;a<this.staticProperties.length;++a){const o=this.staticProperties[a];o.offset=s,s+=o.size,this.staticStride+=o.size}const n=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(n),this.staticDataUint32=new Uint32Array(n),this.staticBuffer=new ut(this.staticData,!0,!1);for(let a=0;a<this.dynamicProperties.length;++a){const o=this.dynamicProperties[a];t.addAttribute(o.attributeName,this.dynamicBuffer,0,o.type===H.UNSIGNED_BYTE,o.type,this.dynamicStride*4,o.offset*4)}for(let a=0;a<this.staticProperties.length;++a){const o=this.staticProperties[a];t.addAttribute(o.attributeName,this.staticBuffer,0,o.type===H.UNSIGNED_BYTE,o.type,this.staticStride*4,o.offset*4)}}uploadDynamic(t,e,r){for(let s=0;s<this.dynamicProperties.length;s++){const n=this.dynamicProperties[s];n.uploadFunction(t,e,r,n.type===H.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,n.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,r){for(let s=0;s<this.staticProperties.length;s++){const n=this.staticProperties[s];n.uploadFunction(t,e,r,n.type===H.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,n.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var I0=`varying vec2 vTextureCoord;
|
|
936
|
-
varying vec4 vColor;
|
|
937
|
-
|
|
938
|
-
uniform sampler2D uSampler;
|
|
359
|
+
`,Dp=`
|
|
360
|
+
|
|
361
|
+
in vec4 vColor;
|
|
362
|
+
in vec2 vUV;
|
|
939
363
|
|
|
940
|
-
|
|
941
|
-
vec4 color = texture2D(uSampler, vTextureCoord) * vColor;
|
|
942
|
-
gl_FragColor = color;
|
|
943
|
-
}`,R0=`attribute vec2 aVertexPosition;
|
|
944
|
-
attribute vec2 aTextureCoord;
|
|
945
|
-
attribute vec4 aColor;
|
|
364
|
+
out vec4 finalColor;
|
|
946
365
|
|
|
947
|
-
|
|
948
|
-
attribute float aRotation;
|
|
366
|
+
{{header}}
|
|
949
367
|
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
varying vec2 vTextureCoord;
|
|
954
|
-
varying vec4 vColor;
|
|
955
|
-
|
|
956
|
-
void main(void){
|
|
957
|
-
float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);
|
|
958
|
-
float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);
|
|
959
|
-
|
|
960
|
-
vec2 v = vec2(x, y);
|
|
961
|
-
v = v + aPositionCoord;
|
|
962
|
-
|
|
963
|
-
gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
|
|
964
|
-
|
|
965
|
-
vTextureCoord = aTextureCoord;
|
|
966
|
-
vColor = aColor * uColor;
|
|
967
|
-
}
|
|
968
|
-
`;class Zl extends qr{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new rt,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:H.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=ce.from(R0,I0,{}),this.state=le.for2d()}render(t){const e=t.children,r=t._maxSize,s=t._batchSize,n=this.renderer;let a=e.length;if(a===0)return;a>r&&!t.autoResize&&(a=r);let o=t._buffers;o||(o=t._buffers=this.generateBuffers(t));const h=e[0]._texture.baseTexture,l=h.alphaMode>0;this.state.blendMode=fh(t.blendMode,l),n.state.set(this.state);const c=n.gl,u=t.worldTransform.copyTo(this.tempMatrix);u.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=u.toArray(!0),this.shader.uniforms.uColor=tt.shared.setValue(t.tintRgb).premultiply(t.worldAlpha,l).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=h,this.renderer.shader.bind(this.shader);let d=!1;for(let f=0,p=0;f<a;f+=s,p+=1){let m=a-f;m>s&&(m=s),p>=o.length&&o.push(this._generateOneMoreBuffer(t));const g=o[p];g.uploadDynamic(e,f,m);const _=t._bufferUpdateIDs[p]||0;d=d||g._updateID<_,d&&(g._updateID=t._updateID,g.uploadStatic(e,f,m)),n.geometry.bind(g.geometry),c.drawElements(c.TRIANGLES,m*6,c.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],r=t._maxSize,s=t._batchSize,n=t._properties;for(let a=0;a<r;a+=s)e.push(new Kl(this.properties,n,s));return e}_generateOneMoreBuffer(t){const e=t._batchSize,r=t._properties;return new Kl(this.properties,r,e)}uploadVertices(t,e,r,s,n,a){let o=0,h=0,l=0,c=0;for(let u=0;u<r;++u){const d=t[e+u],f=d._texture,p=d.scale.x,m=d.scale.y,g=f.trim,_=f.orig;g?(h=g.x-d.anchor.x*_.width,o=h+g.width,c=g.y-d.anchor.y*_.height,l=c+g.height):(o=_.width*(1-d.anchor.x),h=_.width*-d.anchor.x,l=_.height*(1-d.anchor.y),c=_.height*-d.anchor.y),s[a]=h*p,s[a+1]=c*m,s[a+n]=o*p,s[a+n+1]=c*m,s[a+n*2]=o*p,s[a+n*2+1]=l*m,s[a+n*3]=h*p,s[a+n*3+1]=l*m,a+=n*4}}uploadPosition(t,e,r,s,n,a){for(let o=0;o<r;o++){const h=t[e+o].position;s[a]=h.x,s[a+1]=h.y,s[a+n]=h.x,s[a+n+1]=h.y,s[a+n*2]=h.x,s[a+n*2+1]=h.y,s[a+n*3]=h.x,s[a+n*3+1]=h.y,a+=n*4}}uploadRotation(t,e,r,s,n,a){for(let o=0;o<r;o++){const h=t[e+o].rotation;s[a]=h,s[a+n]=h,s[a+n*2]=h,s[a+n*3]=h,a+=n*4}}uploadUvs(t,e,r,s,n,a){for(let o=0;o<r;++o){const h=t[e+o]._texture._uvs;h?(s[a]=h.x0,s[a+1]=h.y0,s[a+n]=h.x1,s[a+n+1]=h.y1,s[a+n*2]=h.x2,s[a+n*2+1]=h.y2,s[a+n*3]=h.x3,s[a+n*3+1]=h.y3,a+=n*4):(s[a]=0,s[a+1]=0,s[a+n]=0,s[a+n+1]=0,s[a+n*2]=0,s[a+n*2+1]=0,s[a+n*3]=0,s[a+n*3+1]=0,a+=n*4)}}uploadTint(t,e,r,s,n,a){for(let o=0;o<r;++o){const h=t[e+o],l=tt.shared.setValue(h._tintRGB).toPremultiplied(h.alpha,h.texture.baseTexture.alphaMode>0);s[a]=l,s[a+n]=l,s[a+n*2]=l,s[a+n*3]=l,a+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}Zl.extension={name:"particle",type:P.RendererPlugin},k.add(Zl);var vs=(i=>(i[i.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",i[i.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",i))(vs||{});const xs={willReadFrequently:!0},fe=class U{static get experimentalLetterSpacingSupported(){let t=U._experimentalLetterSpacingSupported;if(t!==void 0){const e=F.ADAPTER.getCanvasRenderingContext2D().prototype;t=U._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,r,s,n,a,o,h,l){this.text=t,this.style=e,this.width=r,this.height=s,this.lines=n,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=l}static measureText(t,e,r,s=U._canvas){r=r??e.wordWrap;const n=e.toFontString(),a=U.measureFont(n);a.fontSize===0&&(a.fontSize=e.fontSize,a.ascent=e.fontSize);const o=s.getContext("2d",xs);o.font=n;const h=(r?U.wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),l=new Array(h.length);let c=0;for(let p=0;p<h.length;p++){const m=U._measureText(h[p],e.letterSpacing,o);l[p]=m,c=Math.max(c,m)}let u=c+e.strokeThickness;e.dropShadow&&(u+=e.dropShadowDistance);const d=e.lineHeight||a.fontSize+e.strokeThickness;let f=Math.max(d,a.fontSize+e.strokeThickness*2)+e.leading+(h.length-1)*(d+e.leading);return e.dropShadow&&(f+=e.dropShadowDistance),new U(t,e,u,f,h,l,d+e.leading,c,a)}static _measureText(t,e,r){let s=!1;U.experimentalLetterSpacingSupported&&(U.experimentalLetterSpacing?(r.letterSpacing=`${e}px`,r.textLetterSpacing=`${e}px`,s=!0):(r.letterSpacing="0px",r.textLetterSpacing="0px"));let n=r.measureText(t).width;return n>0&&(s?n-=e:n+=(U.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,r=U._canvas){const s=r.getContext("2d",xs);let n=0,a="",o="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=e,u=U.collapseSpaces(c),d=U.collapseNewlines(c);let f=!u;const p=e.wordWrapWidth+l,m=U.tokenize(t);for(let g=0;g<m.length;g++){let _=m[g];if(U.isNewline(_)){if(!d){o+=U.addLine(a),f=!u,a="",n=0;continue}_=" "}if(u){const y=U.isBreakingSpace(_),v=U.isBreakingSpace(a[a.length-1]);if(y&&v)continue}const x=U.getFromCache(_,l,h,s);if(x>p)if(a!==""&&(o+=U.addLine(a),a="",n=0),U.canBreakWords(_,e.breakWords)){const y=U.wordWrapSplit(_);for(let v=0;v<y.length;v++){let T=y[v],C=T,E=1;for(;y[v+E];){const R=y[v+E];if(!U.canBreakChars(C,R,_,v,e.breakWords))T+=R;else break;C=R,E++}v+=E-1;const w=U.getFromCache(T,l,h,s);w+n>p&&(o+=U.addLine(a),f=!1,a="",n=0),a+=T,n+=w}}else{a.length>0&&(o+=U.addLine(a),a="",n=0);const y=g===m.length-1;o+=U.addLine(_,!y),f=!1,a="",n=0}else x+n>p&&(f=!1,o+=U.addLine(a),a="",n=0),(a.length>0||!U.isBreakingSpace(_)||f)&&(a+=_,n+=x)}return o+=U.addLine(a,!1),o}static addLine(t,e=!0){return t=U.trimRight(t),t=e?`${t}
|
|
969
|
-
`:t,t}static getFromCache(t,e,r,s){let n=r[t];return typeof n!="number"&&(n=U._measureText(t,e,s)+e,r[t]=n),n}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const r=t[e];if(!U.isBreakingSpace(r))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:U._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:U._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let r="";if(typeof t!="string")return e;for(let s=0;s<t.length;s++){const n=t[s],a=t[s+1];if(U.isBreakingSpace(n,a)||U.isNewline(n)){r!==""&&(e.push(r),r=""),e.push(n);continue}r+=n}return r!==""&&e.push(r),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,r,s,n){return!0}static wordWrapSplit(t){return U.graphemeSegmenter(t)}static measureFont(t){if(U._fonts[t])return U._fonts[t];const e={ascent:0,descent:0,fontSize:0},r=U._canvas,s=U._context;s.font=t;const n=U.METRICS_STRING+U.BASELINE_SYMBOL,a=Math.ceil(s.measureText(n).width);let o=Math.ceil(s.measureText(U.BASELINE_SYMBOL).width);const h=Math.ceil(U.HEIGHT_MULTIPLIER*o);if(o=o*U.BASELINE_MULTIPLIER|0,a===0||h===0)return U._fonts[t]=e,e;r.width=a,r.height=h,s.fillStyle="#f00",s.fillRect(0,0,a,h),s.font=t,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(n,0,o);const l=s.getImageData(0,0,a,h).data,c=l.length,u=a*4;let d=0,f=0,p=!1;for(d=0;d<o;++d){for(let m=0;m<u;m+=4)if(l[f+m]!==255){p=!0;break}if(!p)f+=u;else break}for(e.ascent=o-d,f=c-u,p=!1,d=h;d>o;--d){for(let m=0;m<u;m+=4)if(l[f+m]!==255){p=!0;break}if(!p)f-=u;else break}return e.descent=d-o,e.fontSize=e.ascent+e.descent,U._fonts[t]=e,e}static clearMetrics(t=""){t?delete U._fonts[t]:U._fonts={}}static get _canvas(){var t;if(!U.__canvas){let e;try{const r=new OffscreenCanvas(0,0);if((t=r.getContext("2d",xs))!=null&&t.measureText)return U.__canvas=r,r;e=F.ADAPTER.createCanvas()}catch{e=F.ADAPTER.createCanvas()}e.width=e.height=10,U.__canvas=e}return U.__canvas}static get _context(){return U.__context||(U.__context=U._canvas.getContext("2d",xs)),U.__context}};fe.METRICS_STRING="|ÉqÅ",fe.BASELINE_SYMBOL="M",fe.BASELINE_MULTIPLIER=1.4,fe.HEIGHT_MULTIPLIER=2,fe.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const i=new Intl.Segmenter;return t=>[...i.segment(t)].map(e=>e.segment)}return i=>[...i]})(),fe.experimentalLetterSpacing=!1,fe._fonts={},fe._newlines=[10,13],fe._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Ce=fe;const P0=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Jl=class _r{constructor(t){this.styleID=0,this.reset(),Ea(this,t,t)}clone(){const t={};return Ea(t,this,_r.defaultStyle),new _r(t)}reset(){Ea(this,_r.defaultStyle,_r.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=wa(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=wa(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){M0(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=wa(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let r=e.length-1;r>=0;r--){let s=e[r].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!P0.includes(s)&&(s=`"${s}"`),e[r]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};Jl.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:vs.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let He=Jl;function wa(i){const t=tt.shared,e=r=>{const s=t.setValue(r);return s.alpha===1?s.toHex():s.toRgbaString()};return Array.isArray(i)?i.map(e):e(i)}function M0(i,t){if(!Array.isArray(i)||!Array.isArray(t)||i.length!==t.length)return!1;for(let e=0;e<i.length;++e)if(i[e]!==t[e])return!1;return!0}function Ea(i,t,e){for(const r in e)Array.isArray(t[r])?i[r]=t[r].slice():i[r]=t[r]}const F0={texture:!0,children:!1,baseTexture:!0},Ql=class Xa extends ue{constructor(t,e,r){let s=!1;r||(r=F.ADAPTER.createCanvas(),s=!0),r.width=3,r.height=3;const n=L.from(r);n.orig=new Y,n.trim=new Y,super(n),this._ownCanvas=s,this.canvas=r,this.context=r.getContext("2d",{willReadFrequently:!0}),this._resolution=Xa.defaultResolution??F.RESOLUTION,this._autoResolution=Xa.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 Ce.experimentalLetterSpacing}static set experimentalLetterSpacing(t){K("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Ce.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 r=this.context,s=Ce.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=s.width,a=s.height,o=s.lines,h=s.lineHeight,l=s.lineWidths,c=s.maxLineWidth,u=s.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,n)+e.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,a)+e.padding*2)*this._resolution),r.scale(this._resolution,this._resolution),r.clearRect(0,0,this.canvas.width,this.canvas.height),r.font=this._font,r.lineWidth=e.strokeThickness,r.textBaseline=e.textBaseline,r.lineJoin=e.lineJoin,r.miterLimit=e.miterLimit;let d,f;const p=e.dropShadow?2:1;for(let m=0;m<p;++m){const g=e.dropShadow&&m===0,_=g?Math.ceil(Math.max(1,a)+e.padding*2):0,x=_*this._resolution;if(g){r.fillStyle="black",r.strokeStyle="black";const v=e.dropShadowColor,T=e.dropShadowBlur*this._resolution,C=e.dropShadowDistance*this._resolution;r.shadowColor=tt.shared.setValue(v).setAlpha(e.dropShadowAlpha).toRgbaString(),r.shadowBlur=T,r.shadowOffsetX=Math.cos(e.dropShadowAngle)*C,r.shadowOffsetY=Math.sin(e.dropShadowAngle)*C+x}else r.fillStyle=this._generateFillStyle(e,o,s),r.strokeStyle=e.stroke,r.shadowColor="black",r.shadowBlur=0,r.shadowOffsetX=0,r.shadowOffsetY=0;let y=(h-u.fontSize)/2;h-u.fontSize<0&&(y=0);for(let v=0;v<o.length;v++)d=e.strokeThickness/2,f=e.strokeThickness/2+v*h+u.ascent+y,e.align==="right"?d+=c-l[v]:e.align==="center"&&(d+=(c-l[v])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(o[v],d+e.padding,f+e.padding-_,!0),e.fill&&this.drawLetterSpacing(o[v],d+e.padding,f+e.padding-_)}this.updateTexture()}drawLetterSpacing(t,e,r,s=!1){const n=this._style.letterSpacing;let a=!1;if(Ce.experimentalLetterSpacingSupported&&(Ce.experimentalLetterSpacing?(this.context.letterSpacing=`${n}px`,this.context.textLetterSpacing=`${n}px`,a=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),n===0||a){s?this.context.strokeText(t,e,r):this.context.fillText(t,e,r);return}let o=e;const h=Ce.graphemeSegmenter(t);let l=this.context.measureText(t).width,c=0;for(let u=0;u<h.length;++u){const d=h[u];s?this.context.strokeText(d,o,r):this.context.fillText(d,o,r);let f="";for(let p=u+1;p<h.length;++p)f+=h[p];c=this.context.measureText(f).width,o+=l-c+n,l=c}}updateTexture(){const t=this.canvas;if(this._style.trim){const a=Zf(t);a.data&&(t.width=a.width,t.height=a.height,this.context.putImageData(a.data,0,0))}const e=this._texture,r=this._style,s=r.trim?0:r.padding,n=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-s,e.trim.y=-s,e.orig.width=e._frame.width-s*2,e.orig.height=e._frame.height-s*2,this._onTextureUpdate(),n.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,r){const s=t.fill;if(Array.isArray(s)){if(s.length===1)return s[0]}else return s;let n;const a=t.dropShadow?t.dropShadowDistance:0,o=t.padding||0,h=this.canvas.width/this._resolution-a-o*2,l=this.canvas.height/this._resolution-a-o*2,c=s.slice(),u=t.fillGradientStops.slice();if(!u.length){const d=c.length+1;for(let f=1;f<d;++f)u.push(f/d)}if(c.unshift(s[0]),u.unshift(0),c.push(s[s.length-1]),u.push(1),t.fillGradientType===vs.LINEAR_VERTICAL){n=this.context.createLinearGradient(h/2,o,h/2,l+o);const d=r.fontProperties.fontSize+t.strokeThickness;for(let f=0;f<e.length;f++){const p=r.lineHeight*(f-1)+d,m=r.lineHeight*f;let g=m;f>0&&p>m&&(g=(m+p)/2);const _=m+d,x=r.lineHeight*(f+1);let y=_;f+1<e.length&&x<_&&(y=(_+x)/2);const v=(y-g)/l;for(let T=0;T<c.length;T++){let C=0;typeof u[T]=="number"?C=u[T]:C=T/c.length;let E=Math.min(1,Math.max(0,g/l+C*v));E=Number(E.toFixed(5)),n.addColorStop(E,c[T])}}}else{n=this.context.createLinearGradient(o,l/2,h+o,l/2);const d=c.length+1;let f=1;for(let p=0;p<c.length;p++){let m;typeof u[p]=="number"?m=u[p]:m=f/d,n.addColorStop(m,c[p]),f++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},F0,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=Oe(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=Oe(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},t instanceof He?this._style=t:this._style=new He(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}};Ql.defaultAutoResolution=!0;let bs=Ql;class B0{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function D0(i,t){var r;let e=!1;if((r=i==null?void 0:i._textures)!=null&&r.length){for(let s=0;s<i._textures.length;s++)if(i._textures[s]instanceof L){const n=i._textures[s].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function O0(i,t){if(i.baseTexture instanceof W){const e=i.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function L0(i,t){if(i._texture&&i._texture instanceof L){const e=i._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function N0(i,t){return t instanceof bs?(t.updateText(!0),!0):!1}function k0(i,t){if(t instanceof He){const e=t.toFontString();return Ce.measureFont(e),!0}return!1}function U0(i,t){if(i instanceof bs){t.includes(i.style)||t.push(i.style),t.includes(i)||t.push(i);const e=i._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function G0(i,t){return i instanceof He?(t.includes(i)||t.push(i),!0):!1}const tc=class Bc{constructor(t){this.limiter=new B0(Bc.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(U0),this.registerFindHook(G0),this.registerFindHook(D0),this.registerFindHook(O0),this.registerFindHook(L0),this.registerUploadHook(N0),this.registerUploadHook(k0)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,dt.system.addOnce(this.tick,this,Se.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 r=0,s=this.uploadHooks.length;r<s;r++)if(this.uploadHooks[r](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)dt.system.addOnce(this.tick,this,Se.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,r=t.length;e<r;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,r=this.addHooks.length;e<r&&!this.addHooks[e](t,this.queue);e++);if(t instanceof bt)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&dt.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}};tc.uploadsPerFrame=4;let Aa=tc;Object.defineProperties(F,{UPLOADS_PER_FRAME:{get(){return Aa.uploadsPerFrame},set(i){K("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),Aa.uploadsPerFrame=i}}});function ec(i,t){return t instanceof W?(t._glTextures[i.CONTEXT_UID]||i.texture.bind(t),!0):!1}function H0(i,t){if(!(t instanceof ba))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:r}=e;for(let s=0;s<r.length;s++){const{texture:n}=r[s].style;n&&ec(i,n.baseTexture)}return e.batchable||i.geometry.bind(e,t._resolveDirectShader(i)),!0}function $0(i,t){return i instanceof ba?(t.push(i),!0):!1}class ic extends Aa{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook($0),this.registerUploadHook(ec),this.registerUploadHook(H0)}}ic.extension={name:"prepare",type:P.RendererSystem},k.add(ic);class Ts extends ue{constructor(t,e=!0){super(t[0]instanceof L?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&&(dt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(dt.shared.add(this.update,this,Se.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,r=this.currentFrame;if(this._durations!==null){let s=this._currentTime%1*this._durations[this.currentFrame];for(s+=e/60*1e3;s<0;)this._currentTime--,s+=this._durations[this.currentFrame];const n=Math.sign(this.animationSpeed*t);for(this._currentTime=Math.floor(this._currentTime);s>=this._durations[this.currentFrame];)s-=this._durations[this.currentFrame]*n,this._currentTime+=n;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()):r!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<r||this.animationSpeed<0&&this.currentFrame>r)&&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 r=0;r<t.length;++r)e.push(L.from(t[r]));return new Ts(e)}static fromImages(t){const e=[];for(let r=0;r<t.length;++r)e.push(L.from(t[r]));return new Ts(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof L)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?(dt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(dt.shared.add(this.update,this),this._isConnectedToTicker=!0))}}var X0=`#version 300 es
|
|
970
|
-
#define SHADER_NAME Tiling-Sprite-100
|
|
971
|
-
|
|
972
|
-
precision lowp float;
|
|
973
|
-
|
|
974
|
-
in vec2 vTextureCoord;
|
|
975
|
-
|
|
976
|
-
out vec4 fragmentColor;
|
|
977
|
-
|
|
978
|
-
uniform sampler2D uSampler;
|
|
979
|
-
uniform vec4 uColor;
|
|
980
|
-
uniform mat3 uMapCoord;
|
|
981
|
-
uniform vec4 uClampFrame;
|
|
982
|
-
uniform vec2 uClampOffset;
|
|
983
|
-
|
|
984
|
-
void main(void)
|
|
985
|
-
{
|
|
986
|
-
vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
|
|
987
|
-
coord = (uMapCoord * vec3(coord, 1.0)).xy;
|
|
988
|
-
vec2 unclamped = coord;
|
|
989
|
-
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
|
|
990
|
-
|
|
991
|
-
vec4 texSample = texture(uSampler, coord, unclamped == coord ? 0.0f : -32.0f);// lod-bias very negative to force lod 0
|
|
992
|
-
|
|
993
|
-
fragmentColor = texSample * uColor;
|
|
994
|
-
}
|
|
995
|
-
`,z0=`#version 300 es
|
|
996
|
-
#define SHADER_NAME Tiling-Sprite-300
|
|
997
|
-
|
|
998
|
-
precision lowp float;
|
|
999
|
-
|
|
1000
|
-
in vec2 aVertexPosition;
|
|
1001
|
-
in vec2 aTextureCoord;
|
|
1002
|
-
|
|
1003
|
-
uniform mat3 projectionMatrix;
|
|
1004
|
-
uniform mat3 translationMatrix;
|
|
1005
|
-
uniform mat3 uTransform;
|
|
1006
|
-
|
|
1007
|
-
out vec2 vTextureCoord;
|
|
1008
|
-
|
|
1009
|
-
void main(void)
|
|
1010
|
-
{
|
|
1011
|
-
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
1012
|
-
|
|
1013
|
-
vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
|
|
1014
|
-
}
|
|
1015
|
-
`,V0=`#version 100
|
|
1016
|
-
#ifdef GL_EXT_shader_texture_lod
|
|
1017
|
-
#extension GL_EXT_shader_texture_lod : enable
|
|
1018
|
-
#endif
|
|
1019
|
-
#define SHADER_NAME Tiling-Sprite-100
|
|
368
|
+
void main(void) {
|
|
369
|
+
|
|
370
|
+
{{start}}
|
|
1020
371
|
|
|
1021
|
-
|
|
372
|
+
vec4 outColor;
|
|
373
|
+
|
|
374
|
+
{{main}}
|
|
375
|
+
|
|
376
|
+
finalColor = outColor * vColor;
|
|
377
|
+
}
|
|
378
|
+
`,Op={name:"global-uniforms-bit",vertex:{header:`
|
|
379
|
+
struct GlobalUniforms {
|
|
380
|
+
uProjectionMatrix:mat3x3<f32>,
|
|
381
|
+
uWorldTransformMatrix:mat3x3<f32>,
|
|
382
|
+
uWorldColorAlpha: vec4<f32>,
|
|
383
|
+
uResolution: vec2<f32>,
|
|
384
|
+
}
|
|
1022
385
|
|
|
1023
|
-
|
|
386
|
+
@group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
|
|
387
|
+
`}},Lp={name:"global-uniforms-bit",vertex:{header:`
|
|
388
|
+
uniform mat3 uProjectionMatrix;
|
|
389
|
+
uniform mat3 uWorldTransformMatrix;
|
|
390
|
+
uniform vec4 uWorldColorAlpha;
|
|
391
|
+
uniform vec2 uResolution;
|
|
392
|
+
`}};function as({bits:s,name:t}){const e=Rp({template:{fragment:Gp,vertex:Fp},bits:[Op,...s]});return Re.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function os({bits:s,name:t}){return new $e({name:t,...kp({template:{vertex:Up,fragment:Dp},bits:[Lp,...s]})})}const Dr={name:"color-bit",vertex:{header:`
|
|
393
|
+
@in aColor: vec4<f32>;
|
|
394
|
+
`,main:`
|
|
395
|
+
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
|
|
396
|
+
`}},Or={name:"color-bit",vertex:{header:`
|
|
397
|
+
in vec4 aColor;
|
|
398
|
+
`,main:`
|
|
399
|
+
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
|
|
400
|
+
`}},Lr={};function Hp(s){const t=[];if(s===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let i=0;i<s;i++)t.push(`@group(1) @binding(${e++}) var textureSource${i+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(`
|
|
401
|
+
`)}function Np(s){const t=[];if(s===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<s;e++)e===s-1?t.push(" default:{"):t.push(` case ${e}:{`),t.push(` outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),t.push(" break;}");t.push("}")}return t.join(`
|
|
402
|
+
`)}function Hr(s){return Lr[s]||(Lr[s]={name:"texture-batch-bit",vertex:{header:`
|
|
403
|
+
@in aTextureIdAndRound: vec2<u32>;
|
|
404
|
+
@out @interpolate(flat) vTextureId : u32;
|
|
405
|
+
`,main:`
|
|
406
|
+
vTextureId = aTextureIdAndRound.y;
|
|
407
|
+
`,end:`
|
|
408
|
+
if(aTextureIdAndRound.x == 1)
|
|
409
|
+
{
|
|
410
|
+
vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
411
|
+
}
|
|
412
|
+
`},fragment:{header:`
|
|
413
|
+
@in @interpolate(flat) vTextureId: u32;
|
|
414
|
+
|
|
415
|
+
${Hp(Ht())}
|
|
416
|
+
`,main:`
|
|
417
|
+
var uvDx = dpdx(vUV);
|
|
418
|
+
var uvDy = dpdy(vUV);
|
|
419
|
+
|
|
420
|
+
${Np(Ht())}
|
|
421
|
+
`}}),Lr[s]}const Nr={};function zp(s){const t=[];for(let e=0;e<s;e++)e>0&&t.push("else"),e<s-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
|
|
422
|
+
`)}function zr(s){return Nr[s]||(Nr[s]={name:"texture-batch-bit",vertex:{header:`
|
|
423
|
+
in vec2 aTextureIdAndRound;
|
|
424
|
+
out float vTextureId;
|
|
425
|
+
|
|
426
|
+
`,main:`
|
|
427
|
+
vTextureId = aTextureIdAndRound.y;
|
|
428
|
+
`,end:`
|
|
429
|
+
if(aTextureIdAndRound.x == 1.)
|
|
430
|
+
{
|
|
431
|
+
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
432
|
+
}
|
|
433
|
+
`},fragment:{header:`
|
|
434
|
+
in float vTextureId;
|
|
435
|
+
|
|
436
|
+
uniform sampler2D uTextures[${s}];
|
|
437
|
+
|
|
438
|
+
`,main:`
|
|
439
|
+
|
|
440
|
+
${zp(Ht())}
|
|
441
|
+
`}}),Nr[s]}const hs={name:"round-pixels-bit",vertex:{header:`
|
|
442
|
+
fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
|
|
443
|
+
{
|
|
444
|
+
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
445
|
+
}
|
|
446
|
+
`}},cs={name:"round-pixels-bit",vertex:{header:`
|
|
447
|
+
vec2 roundPixels(vec2 position, vec2 targetSize)
|
|
448
|
+
{
|
|
449
|
+
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
450
|
+
}
|
|
451
|
+
`}},Ko={};function Wr(s){let t=Ko[s];if(t)return t;const e=new Int32Array(s);for(let i=0;i<s;i++)e[i]=i;return t=Ko[s]=new xt({uTextures:{value:e,type:"i32",size:s}},{isStatic:!0}),t}class qo{constructor(){this._didUpload=!1,this._tempState=Kt.for2d()}init(t){const e=Ht(),i=os({name:"batch",bits:[Or,zr(e),cs]});this._shader=new At({glProgram:i,resources:{batchSamplers:Wr(e)}}),t.renderer.runners.contextChange.add(this)}contextChange(){this._didUpload=!1}start(t,e){const i=t.renderer;i.shader.bind(this._shader,this._didUpload),i.shader.updateUniformGroup(i.globalUniforms.uniformGroup),i.geometry.bind(e,this._shader.glProgram)}execute(t,e){const i=t.renderer;this._didUpload=!0,this._tempState.blendMode=e.blendMode,i.state.set(this._tempState);const r=e.textures.textures;for(let n=0;n<r.length;n++)i.texture.bind(r[n],n);i.geometry.draw("triangle-list",e.size,e.start)}destroy(){this._shader.destroy(!0),this._shader=null}}qo.extension={type:[b.WebGLPipesAdaptor],name:"batch"};const ti=Kt.for2d();class Zo{init(){const t=as({name:"batch",bits:[Dr,Hr(Ht()),hs]});this._shader=new At({gpuProgram:t,groups:{}})}start(t,e){const i=t.renderer,r=i.encoder,n=this._shader.gpuProgram;this._geometry=e,r.setGeometry(e),ti.blendMode="normal",i.pipeline.getPipeline(e,n,ti);const a=i.globalUniforms.bindGroup;r.resetBindGroup(1),r.setBindGroup(0,a,n)}execute(t,e){const i=this._shader.gpuProgram,r=t.renderer,n=r.encoder;if(!e.bindGroup){const h=e.textures;e.bindGroup=dr(h.textures,h.count)}ti.blendMode=e.blendMode;const a=r.bindGroup.getBindGroup(e.bindGroup,i,1),o=r.pipeline.getPipeline(this._geometry,i,ti);e.bindGroup._touch(r.textureGC.count),n.setPipeline(o),n.renderPassEncoder.setBindGroup(1,a),n.renderPassEncoder.drawIndexed(e.size,1,e.start)}destroy(){this._shader.destroy(!0),this._shader=null}}Zo.extension={type:[b.WebGPUPipesAdaptor],name:"batch"};class Jo{constructor(t,e){this.state=Kt.for2d(),this._batches=Object.create(null),this._geometries=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init(this)}buildStart(t){if(!this._batches[t.uid]){const e=new Ja;this._batches[t.uid]=e,this._geometries[e.uid]=new ja}this._activeBatch=this._batches[t.uid],this._activeGeometry=this._geometries[this._activeBatch.uid],this._activeBatch.begin()}addToBatch(t){this._activeBatch.add(t)}break(t){this._activeBatch.break(t)}buildEnd(t){const e=this._activeBatch,i=this._activeGeometry;e.finish(t),i.indexBuffer.setDataWithSize(e.indexBuffer,e.indexSize,!0),i.buffers[0].setDataWithSize(e.attributeBuffer.float32View,e.attributeSize,!1)}upload(t){const e=this._batches[t.uid],i=this._geometries[e.uid];e.dirty&&(e.dirty=!1,i.buffers[0].update(e.attributeSize*4))}execute(t){if(t.action==="startBatch"){const e=t.batcher,i=this._geometries[e.uid];this._adaptor.start(this,i)}this._adaptor.execute(this,t)}destroy(){this.state=null,this.renderer=null,this._adaptor.destroy(),this._adaptor=null;for(const t in this._batches)this._batches[t].destroy();this._batches=null;for(const t in this._geometries)this._geometries[t].destroy();this._geometries=null}}Jo.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"batch"};const ls={name:"local-uniform-bit",vertex:{header:`
|
|
1024
452
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
453
|
+
struct LocalUniforms {
|
|
454
|
+
uTransformMatrix:mat3x3<f32>,
|
|
455
|
+
uColor:vec4<f32>,
|
|
456
|
+
uRound:f32,
|
|
457
|
+
}
|
|
1030
458
|
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
`,
|
|
1049
|
-
|
|
459
|
+
@group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
460
|
+
`,main:`
|
|
461
|
+
vColor *= localUniforms.uColor;
|
|
462
|
+
modelMatrix *= localUniforms.uTransformMatrix;
|
|
463
|
+
`,end:`
|
|
464
|
+
if(localUniforms.uRound == 1)
|
|
465
|
+
{
|
|
466
|
+
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
467
|
+
}
|
|
468
|
+
`}},Wp={...ls,vertex:{...ls.vertex,header:ls.vertex.header.replace("group(1)","group(2)")}},Vr={name:"local-uniform-bit",vertex:{header:`
|
|
469
|
+
|
|
470
|
+
uniform mat3 uTransformMatrix;
|
|
471
|
+
uniform vec4 uColor;
|
|
472
|
+
uniform float uRound;
|
|
473
|
+
`,main:`
|
|
474
|
+
vColor *= uColor;
|
|
475
|
+
modelMatrix = uTransformMatrix;
|
|
476
|
+
`,end:`
|
|
477
|
+
if(uRound == 1.)
|
|
478
|
+
{
|
|
479
|
+
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
480
|
+
}
|
|
481
|
+
`}},Vp={name:"texture-bit",vertex:{header:`
|
|
1050
482
|
|
|
1051
|
-
|
|
483
|
+
struct TextureUniforms {
|
|
484
|
+
uTextureMatrix:mat3x3<f32>,
|
|
485
|
+
}
|
|
1052
486
|
|
|
1053
|
-
|
|
1054
|
-
|
|
487
|
+
@group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
|
|
488
|
+
`,main:`
|
|
489
|
+
uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
|
|
490
|
+
`},fragment:{header:`
|
|
491
|
+
@group(2) @binding(0) var uTexture: texture_2d<f32>;
|
|
492
|
+
@group(2) @binding(1) var uSampler: sampler;
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
`,main:`
|
|
496
|
+
outColor = textureSample(uTexture, uSampler, vUV);
|
|
497
|
+
`}},jp={name:"texture-bit",vertex:{header:`
|
|
498
|
+
uniform mat3 uTextureMatrix;
|
|
499
|
+
`,main:`
|
|
500
|
+
uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
|
|
501
|
+
`},fragment:{header:`
|
|
502
|
+
uniform sampler2D uTexture;
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
`,main:`
|
|
506
|
+
outColor = texture(uTexture, vUV);
|
|
507
|
+
`}};function $p(s,t){const e=s.root,i=s.instructionSet;i.reset(),t.batch.buildStart(i),t.blendMode.buildStart(),t.colorMask.buildStart(),e.sortableChildren&&e.sortChildren(),Qo(e,i,t,!0),t.batch.buildEnd(i),t.blendMode.buildEnd(i)}function ei(s,t,e){s.globalDisplayStatus<7||!s.includeInBuild||(s.sortableChildren&&s.sortChildren(),s.isSimple?Xp(s,t,e):Qo(s,t,e,!1))}function Xp(s,t,e){if(s.renderPipeId&&(e.blendMode.setBlendMode(s,s.groupBlendMode,t),s.didViewUpdate=!1,e[s.renderPipeId].addRenderable(s,t)),!s.renderGroup){const i=s.children,r=i.length;for(let n=0;n<r;n++)ei(i[n],t,e)}}function Qo(s,t,e,i){if(!i&&s.renderGroup)e.renderGroup.addRenderGroup(s.renderGroup,t);else{for(let a=0;a<s.effects.length;a++){const o=s.effects[a];e[o.pipe].push(o,s,t)}const r=s.renderPipeId;r&&(e.blendMode.setBlendMode(s,s.groupBlendMode,t),s.didViewUpdate=!1,e[r].addRenderable(s,t));const n=s.children;if(n.length)for(let a=0;a<n.length;a++)ei(n[a],t,e);for(let a=s.effects.length-1;a>=0;a--){const o=s.effects[a];e[o.pipe].pop(o,s,t)}}}const Yp=new mt;class Kp extends Ms{constructor(){super(),this.filters=[new dp({sprite:new Tt(M.EMPTY)})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}}class th{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,i){const r=this._renderer;if(r.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,canBundle:!1,maskedContainer:e}),t.renderMaskToTexture){const n=t.mask;n.includeInBuild=!0,ei(n,i,r.renderPipes),n.includeInBuild=!1}r.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,canBundle:!1})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,canBundle:!1})}execute(t){const e=this._renderer,i=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){const r=$.get(Kp);if(i){t.mask.mask.measurable=!0;const n=Bi(t.mask.mask,!0,Yp);t.mask.mask.measurable=!1,n.ceil();const a=Pt.getOptimalTexture(n.width,n.height,1,!1);e.renderTarget.push(a,!0),e.globalUniforms.push({offset:n,worldColor:4294967295});const o=r.sprite;o.texture=a,o.worldTransform.tx=n.minX,o.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:r,maskedContainer:t.maskedContainer,filterTexture:a})}else r.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:r,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){const r=this._activeMaskStage[this._activeMaskStage.length-1];i&&(e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:r.maskedContainer,filterEffect:r.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();const r=this._activeMaskStage.pop();i&&Pt.returnTexture(r.filterTexture),$.return(r.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}th.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"alphaMask"};class eh{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&t.mask;const a=this._colorStack[this._colorStackIndex];a!==this._currentColor&&(this._currentColor=a,i.add({renderPipeId:"colorMask",colorMask:a,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;this._colorStackIndex--;const a=n[this._colorStackIndex-1];a!==this._currentColor&&(this._currentColor=a,i.add({renderPipeId:"colorMask",colorMask:a,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._colorStack=null}}eh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"colorMask"};class sh{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,i){var r;const n=t,a=this._renderer;a.renderPipes.batch.break(i),a.renderPipes.blendMode.setBlendMode(n.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,canBundle:!1});const o=n.mask;o.includeInBuild=!0,this._maskHash.has(n)||this._maskHash.set(n,{instructionsStart:0,instructionsLength:0});const h=this._maskHash.get(n);h.instructionsStart=i.instructionSize,ei(o,i,a.renderPipes),o.includeInBuild=!1,a.renderPipes.batch.break(i),i.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,canBundle:!1});const c=i.instructionSize-h.instructionsStart-1;h.instructionsLength=c;const l=a.renderTarget.renderTarget.uid;(r=this._maskStackHash)[l]??(r[l]=0)}pop(t,e,i){const r=t,n=this._renderer;n.renderPipes.batch.break(i),n.renderPipes.blendMode.setBlendMode(r.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"popMaskBegin",canBundle:!1});const a=this._maskHash.get(t);for(let o=0;o<a.instructionsLength;o++)i.instructions[i.instructionSize++]=i.instructions[a.instructionsStart++];i.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e;const i=this._renderer,r=i.renderTarget.renderTarget.uid;let n=(e=this._maskStackHash)[r]??(e[r]=0);t.action==="pushMaskBegin"?(i.renderTarget.ensureDepthStencil(),i.stencil.setStencilMode(ht.RENDERING_MASK_ADD,n),n++,i.colorMask.setMask(0)):t.action==="pushMaskEnd"?(i.stencil.setStencilMode(ht.MASK_ACTIVE,n),i.colorMask.setMask(15)):t.action==="popMaskBegin"?(i.colorMask.setMask(0),n!==0?i.stencil.setStencilMode(ht.RENDERING_MASK_REMOVE,n):(i.renderTarget.clear(null,yt.STENCIL),i.stencil.setStencilMode(ht.DISABLED,n)),n--):t.action==="popMaskEnd"&&(i.stencil.setStencilMode(ht.MASK_ACTIVE,n),i.colorMask.setMask(15)),this._maskStackHash[r]=n}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}sh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"stencilMask"};var si=(s=>(s[s.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",s[s.ARRAY_BUFFER=34962]="ARRAY_BUFFER",s[s.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",s))(si||{});class qp{constructor(t,e){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class ih{constructor(t){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._renderer=t}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gpuBuffers=Object.create(null),this._gl=this._renderer.gl}getGlBuffer(t){return this._gpuBuffers[t.uid]||this.createGLBuffer(t)}bind(t){const{_gl:e}=this,i=this.getGlBuffer(t);e.bindBuffer(i.type,i.buffer)}bindBufferBase(t,e){const{_gl:i}=this;if(this._boundBufferBases[e]!==t){const r=this.getGlBuffer(t);this._boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,r.buffer)}}bindBufferRange(t,e,i){const{_gl:r}=this;i=i||0;const n=this.getGlBuffer(t);r.bindBufferRange(r.UNIFORM_BUFFER,e||0,n.buffer,i*256,256)}updateBuffer(t){const{_gl:e}=this,i=this.getGlBuffer(t);if(t._updateID===i.updateID)return i;i.updateID=t._updateID,e.bindBuffer(i.type,i.buffer);const r=t.data;if(i.byteLength>=t.data.byteLength)e.bufferSubData(i.type,0,r,0,t._updateSize/r.BYTES_PER_ELEMENT);else{const n=t.descriptor.usage&V.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;i.byteLength=r.byteLength,e.bufferData(i.type,r,n)}return i}destroyAll(){const t=this._gl;for(const e in this._gpuBuffers)t.deleteBuffer(this._gpuBuffers[e].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(t,e){const i=this._gpuBuffers[t.uid],r=this._gl;e||r.deleteBuffer(i.buffer),this._gpuBuffers[t.uid]=null}createGLBuffer(t){const{_gl:e}=this;let i=si.ARRAY_BUFFER;t.descriptor.usage&V.INDEX?i=si.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&V.UNIFORM&&(i=si.UNIFORM_BUFFER);const r=new qp(e.createBuffer(),i);return this._gpuBuffers[t.uid]=r,t.on("destroy",this.onBufferDestroy,this),r}}ih.extension={type:[b.WebGLSystem],name:"buffer"};const jr=class bl{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),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}init(t){if(t={...bl.defaultOptions,...t},t.context)this.initFromContext(t.context);else{const e=this._renderer.background.alpha<1,i=t.premultipliedAlpha??!0,r=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:e,premultipliedAlpha:i,antialias:r,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference??"default"})}}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof L.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);const e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let i;const r=this._renderer.view.canvas;if(t===2&&(i=r.getContext("webgl2",e)),!i&&(i=r.getContext("webgl",e),!i))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=i,this.initFromContext(this.gl)}getExtensions(){const{gl:t}=this,e={anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc"),rgtc:t.getExtension("EXT_texture_compression_rgtc"),loseContext:t.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)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"),vertexAttribDivisorANGLE:t.getExtension("ANGLE_instanced_arrays"),srgb:t.getExtension("EXT_sRGB")};else{this.extensions={...e,colorBufferFloat:t.getExtension("EXT_color_buffer_float")};const i=t.getExtension("WEBGL_provoking_vertex");i&&i.provokingVertexWEBGL(i.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(t){t.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var e;this.gl.isContextLost()&&((e=this.extensions.loseContext)==null||e.restoreContext())},0))}handleContextRestored(){this._renderer.runners.contextChange.emit(this.gl)}destroy(){var e;const t=this._renderer.view.canvas;this._renderer=null,t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(e=this.extensions.loseContext)==null||e.loseContext()}forceContextLoss(){var t;(t=this.extensions.loseContext)==null||t.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&!e.stencil&&D("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const i=this.supports,r=this.webGLVersion===2,n=this.extensions;i.uint32Indices=r||!!n.uint32ElementIndex,i.uniformBufferObject=r,i.vertexArrayObject=r||!!n.vertexArrayObject,i.srgbTextures=r||!!n.srgb,i.nonPowOf2wrapping=r,i.nonPowOf2mipmaps=r,i.msaa=r,i.uint32Indices||D("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};jr.extension={type:[b.WebGLSystem],name:"context"},jr.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2};let Zp=jr;function rh(s,t){for(const e in s.attributes){const i=s.attributes[e],r=t[e];r?(i.location??(i.location=r.location),i.format??(i.format=r.format),i.offset??(i.offset=r.offset),i.instance??(i.instance=r.instance)):D(`Attribute ${e} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}Jp(s)}function Jp(s){const{buffers:t,attributes:e}=s,i={},r={};for(const n in t){const a=t[n];i[a.uid]=0,r[a.uid]=0}for(const n in e){const a=e[n];i[a.buffer.uid]+=Xe(a.format).stride}for(const n in e){const a=e[n];a.stride??(a.stride=i[a.buffer.uid]),a.start??(a.start=r[a.buffer.uid]),r[a.buffer.uid]+=Xe(a.format).stride}}var $r=(s=>(s[s.RGBA=6408]="RGBA",s[s.RGB=6407]="RGB",s[s.RG=33319]="RG",s[s.RED=6403]="RED",s[s.RGBA_INTEGER=36249]="RGBA_INTEGER",s[s.RGB_INTEGER=36248]="RGB_INTEGER",s[s.RG_INTEGER=33320]="RG_INTEGER",s[s.RED_INTEGER=36244]="RED_INTEGER",s[s.ALPHA=6406]="ALPHA",s[s.LUMINANCE=6409]="LUMINANCE",s[s.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",s[s.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",s[s.DEPTH_STENCIL=34041]="DEPTH_STENCIL",s))($r||{}),nh=(s=>(s[s.TEXTURE_2D=3553]="TEXTURE_2D",s[s.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",s[s.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",s[s.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",s[s.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",s[s.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",s[s.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",s))(nh||{}),H=(s=>(s[s.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",s[s.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",s[s.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",s[s.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",s[s.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",s[s.UNSIGNED_INT=5125]="UNSIGNED_INT",s[s.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",s[s.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",s[s.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",s[s.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",s[s.BYTE=5120]="BYTE",s[s.SHORT=5122]="SHORT",s[s.INT=5124]="INT",s[s.FLOAT=5126]="FLOAT",s[s.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",s[s.HALF_FLOAT=36193]="HALF_FLOAT",s))(H||{});const ah={uint8x2:H.UNSIGNED_BYTE,uint8x4:H.UNSIGNED_BYTE,sint8x2:H.BYTE,sint8x4:H.BYTE,unorm8x2:H.UNSIGNED_BYTE,unorm8x4:H.UNSIGNED_BYTE,snorm8x2:H.BYTE,snorm8x4:H.BYTE,uint16x2:H.UNSIGNED_SHORT,uint16x4:H.UNSIGNED_SHORT,sint16x2:H.SHORT,sint16x4:H.SHORT,unorm16x2:H.UNSIGNED_SHORT,unorm16x4:H.UNSIGNED_SHORT,snorm16x2:H.SHORT,snorm16x4:H.SHORT,float16x2:H.HALF_FLOAT,float16x4:H.HALF_FLOAT,float32:H.FLOAT,float32x2:H.FLOAT,float32x3:H.FLOAT,float32x4:H.FLOAT,uint32:H.UNSIGNED_INT,uint32x2:H.UNSIGNED_INT,uint32x3:H.UNSIGNED_INT,uint32x4:H.UNSIGNED_INT,sint32:H.INT,sint32x2:H.INT,sint32x3:H.INT,sint32x4:H.INT};function Qp(s){return ah[s]??ah.float32}const tm={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class oh{constructor(t){this._geometryVaoHash=Object.create(null),this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0}contextChange(){const t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=r=>e.bindVertexArrayOES(r),t.deleteVertexArray=r=>e.deleteVertexArrayOES(r));const i=this._renderer.context.extensions.vertexAttribDivisorANGLE;i&&(t.drawArraysInstanced=(r,n,a,o)=>{i.drawArraysInstancedANGLE(r,n,a,o)},t.drawElementsInstanced=(r,n,a,o,h)=>{i.drawElementsInstancedANGLE(r,n,a,o,h)},t.vertexAttribDivisor=(r,n)=>i.vertexAttribDivisorANGLE(r,n)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(t,e){const i=this.gl;this._activeGeometry=t;const r=this.getVao(t,e);this._activeVao!==r&&(this._activeVao=r,i.bindVertexArray(r)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let i=0;i<t.buffers.length;i++){const r=t.buffers[i];e.updateBuffer(r)}}checkCompatibility(t,e){const i=t.attributes,r=e._attributeData;for(const n in r)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,r=e._attributeData,n=["g",t.uid];for(const a in i)r[a]&&n.push(a,r[a].location);return n.join("-")}getVao(t,e){var i;return((i=this._geometryVaoHash[t.uid])==null?void 0:i[e._key])||this.initGeometryVao(t,e)}initGeometryVao(t,e,i=!0){const r=this._renderer.gl,n=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const a=this.getSignature(t,e);this._geometryVaoHash[t.uid]||(this._geometryVaoHash[t.uid]=Object.create(null),t.on("destroy",this.onGeometryDestroy,this));const o=this._geometryVaoHash[t.uid];let h=o[a];if(h)return o[e._key]=h,h;rh(t,e._attributeData);const c=t.buffers;h=r.createVertexArray(),r.bindVertexArray(h);for(let l=0;l<c.length;l++){const u=c[l];n.bind(u)}return this.activateVao(t,e),o[e._key]=h,o[a]=h,r.bindVertexArray(null),h}onGeometryDestroy(t,e){const i=this._geometryVaoHash[t.uid],r=this.gl;if(i){if(e)for(const n in i)this._activeVao!==i[n]&&this.unbind(),r.deleteVertexArray(i[n]);this._geometryVaoHash[t.uid]=null}}destroyAll(t=!1){const e=this.gl;for(const i in this._geometryVaoHash){if(t)for(const r in this._geometryVaoHash[i]){const n=this._geometryVaoHash[i];this._activeVao!==n&&this.unbind(),e.deleteVertexArray(n[r])}this._geometryVaoHash[i]=null}}activateVao(t,e){var o;const i=this._renderer.gl,r=this._renderer.buffer,n=t.attributes;t.indexBuffer&&r.bind(t.indexBuffer);let a=null;for(const h in n){const c=n[h],l=c.buffer,u=r.getGlBuffer(l),d=e._attributeData[h];if(d){a!==u&&(r.bind(l),a=u);const f=c.location;i.enableVertexAttribArray(f);const p=Xe(c.format),g=Qp(c.format);if(((o=d.format)==null?void 0:o.substring(1,4))==="int"?i.vertexAttribIPointer(f,p.size,g,c.stride,c.offset):i.vertexAttribPointer(f,p.size,g,p.normalised,c.stride,c.offset),c.instance)if(this.hasInstance)i.vertexAttribDivisor(f,1);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,r){const{gl:n}=this._renderer,a=this._activeGeometry,o=tm[a.topology||t];if(r||(r=a.instanceCount),a.indexBuffer){const h=a.indexBuffer.data.BYTES_PER_ELEMENT,c=h===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;r>1?n.drawElementsInstanced(o,e||a.indexBuffer.data.length,c,(i||0)*h,r):n.drawElements(o,e||a.indexBuffer.data.length,c,(i||0)*h)}else r>1?n.drawArraysInstanced(o,i||0,e||a.getSize(),r):n.drawArrays(o,i||0,e||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}oh.extension={type:[b.WebGLSystem],name:"geometry"};const em=new Xs({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),Xr=class vl{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:i}={...vl.defaultOptions,...t};this.useBackBuffer=e,this._antialias=i,this._renderer.context.supports.msaa||(D("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=Kt.for2d();const r=new $e({vertex:`
|
|
508
|
+
attribute vec2 aPosition;
|
|
509
|
+
out vec2 vUv;
|
|
510
|
+
|
|
511
|
+
void main() {
|
|
512
|
+
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
513
|
+
|
|
514
|
+
vUv = (aPosition + 1.0) / 2.0;
|
|
515
|
+
|
|
516
|
+
// flip dem UVs
|
|
517
|
+
vUv.y = 1.0 - vUv.y;
|
|
518
|
+
}`,fragment:`
|
|
519
|
+
in vec2 vUv;
|
|
520
|
+
out vec4 finalColor;
|
|
521
|
+
|
|
522
|
+
uniform sampler2D uTexture;
|
|
523
|
+
|
|
524
|
+
void main() {
|
|
525
|
+
finalColor = texture(uTexture, vUv);
|
|
526
|
+
}`,name:"big-triangle"});this._bigTriangleShader=new At({glProgram:r,resources:{uTexture:M.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const i=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=i.colorTexture,t.target=this._getBackBufferTexture(i.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:em,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new M({source:new ut({width:t.width,height:t.height,resolution:t._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(t.width,t.height,t._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};Xr.extension={type:[b.WebGLSystem],name:"backBuffer",priority:1},Xr.defaultOptions={useBackBuffer:!1};let sm=Xr;class hh{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(t&8),!!(t&4),!!(t&2),!!(t&1)))}}hh.extension={type:[b.WebGLSystem],name:"colorMask"};class ch{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){const e=this._renderer,{geometry:i,shader:r,state:n,skipSync:a,topology:o,size:h,start:c,instanceCount:l}=t;e.shader.bind(r,a),e.geometry.bind(i,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(o,h,c,l??i.instanceCount)}destroy(){this._renderer=null}}ch.extension={type:[b.WebGLSystem],name:"encoder"};class im{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const ge=[];ge[ht.NONE]=void 0,ge[ht.DISABLED]={stencilWriteMask:0,stencilReadMask:0},ge[ht.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},ge[ht.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},ge[ht.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};class lh{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:ht.NONE},this._renderTargetStencilState=Object.create(null),t.renderTarget.onRenderTargetChange.add(this)}contextChange(t){this._gl=t,this._comparisonFuncMapping={always:t.ALWAYS,never:t.NEVER,equal:t.EQUAL,"not-equal":t.NOTEQUAL,less:t.LESS,"less-equal":t.LEQUAL,greater:t.GREATER,"greater-equal":t.GEQUAL},this._stencilOpsMapping={keep:t.KEEP,zero:t.ZERO,replace:t.REPLACE,invert:t.INVERT,"increment-clamp":t.INCR,"decrement-clamp":t.DECR,"increment-wrap":t.INCR_WRAP,"decrement-wrap":t.DECR_WRAP},this._stencilCache.enabled=!1,this._stencilCache.stencilMode=ht.NONE,this._stencilCache.stencilReference=0}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:ht.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid],r=this._gl,n=ge[t],a=this._stencilCache;if(i.stencilMode=t,i.stencilReference=e,t===ht.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,r.disable(r.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,r.enable(r.STENCIL_TEST)),(t!==a.stencilMode||a.stencilReference!==e)&&(a.stencilMode=t,a.stencilReference=e,r.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),r.stencilOp(r.KEEP,r.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}}lh.extension={type:[b.WebGLSystem],name:"stencil"};class uh{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!ka())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const e=this.getUniformGroupData(t);t.buffer||(t.buffer=new kt({data:new Float32Array(e.layout.size/4),usage:V.UNIFORM|V.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const e=t._signature;let i=this._syncFunctionHash[e];if(!i){const r=Object.keys(t.uniformStructures).map(o=>t.uniformStructures[o]),n=this._adaptor.createUboElements(r),a=this._generateUboSync(n.uboElements);i=this._syncFunctionHash[e]={layout:n,syncFunction:a}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,i){const r=this.getUniformGroupData(t);return t.buffer||(t.buffer=new kt({data:new Float32Array(r.layout.size/4),usage:V.UNIFORM|V.COPY_DST})),e||(e=t.buffer.data),i||(i=0),r.syncFunction(t.uniforms,e,i),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;const e=this.syncUniformGroup(t);return t.buffer.update(),e}destroy(){this._syncFunctionHash=null}}const dh={f32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"mat2x2<f32>":16*2,"mat3x3<f32>":16*3,"mat4x4<f32>":16*4};function rm(s){const t=s.map(n=>({data:n,offset:0,size:0}));let e=0,i=0,r=0;for(let n=0;n<t.length;n++){const a=t[n];if(e=dh[a.data.type],!e)throw new Error(`Unknown type ${a.data.type}`);if(a.data.size>1&&(e=Math.max(e,16)*a.data.size),a.size=e,i%e!==0&&i<16){const o=i%e%16;i+=o,r+=o}i+e>16?(r=Math.ceil(r/16)*16,a.offset=r,r+=e,i=e):(a.offset=r,i+=e,r+=e)}return r=Math.ceil(r/16)*16,{uboElements:t,size:r}}const _e=[{type:"mat3x3<f32>",test:s=>s.value.a!==void 0,ubo:`
|
|
527
|
+
var matrix = uv[name].toArray(true);
|
|
528
|
+
data[offset] = matrix[0];
|
|
529
|
+
data[offset + 1] = matrix[1];
|
|
530
|
+
data[offset + 2] = matrix[2];
|
|
531
|
+
data[offset + 4] = matrix[3];
|
|
532
|
+
data[offset + 5] = matrix[4];
|
|
533
|
+
data[offset + 6] = matrix[5];
|
|
534
|
+
data[offset + 8] = matrix[6];
|
|
535
|
+
data[offset + 9] = matrix[7];
|
|
536
|
+
data[offset + 10] = matrix[8];
|
|
537
|
+
`,uniform:`
|
|
538
|
+
gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
|
|
539
|
+
`},{type:"vec4<f32>",test:s=>s.type==="vec4<f32>"&&s.size===1&&s.value.width!==void 0,ubo:`
|
|
540
|
+
v = uv[name];
|
|
541
|
+
data[offset] = v.x;
|
|
542
|
+
data[offset + 1] = v.y;
|
|
543
|
+
data[offset + 2] = v.width;
|
|
544
|
+
data[offset + 3] = v.height;
|
|
545
|
+
`,uniform:`
|
|
546
|
+
cv = ud[name].value;
|
|
547
|
+
v = uv[name];
|
|
548
|
+
if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
|
|
549
|
+
cv[0] = v.x;
|
|
550
|
+
cv[1] = v.y;
|
|
551
|
+
cv[2] = v.width;
|
|
552
|
+
cv[3] = v.height;
|
|
553
|
+
gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
|
|
554
|
+
}
|
|
555
|
+
`},{type:"vec2<f32>",test:s=>s.type==="vec2<f32>"&&s.size===1&&s.value.x!==void 0,ubo:`
|
|
556
|
+
v = uv[name];
|
|
557
|
+
data[offset] = v.x;
|
|
558
|
+
data[offset + 1] = v.y;
|
|
559
|
+
`,uniform:`
|
|
560
|
+
cv = ud[name].value;
|
|
561
|
+
v = uv[name];
|
|
562
|
+
if (cv[0] !== v.x || cv[1] !== v.y) {
|
|
563
|
+
cv[0] = v.x;
|
|
564
|
+
cv[1] = v.y;
|
|
565
|
+
gl.uniform2f(ud[name].location, v.x, v.y);
|
|
566
|
+
}
|
|
567
|
+
`},{type:"vec4<f32>",test:s=>s.type==="vec4<f32>"&&s.size===1&&s.value.red!==void 0,ubo:`
|
|
568
|
+
v = uv[name];
|
|
569
|
+
data[offset] = v.red;
|
|
570
|
+
data[offset + 1] = v.green;
|
|
571
|
+
data[offset + 2] = v.blue;
|
|
572
|
+
data[offset + 3] = v.alpha;
|
|
573
|
+
`,uniform:`
|
|
574
|
+
cv = ud[name].value;
|
|
575
|
+
v = uv[name];
|
|
576
|
+
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
|
|
577
|
+
cv[0] = v.red;
|
|
578
|
+
cv[1] = v.green;
|
|
579
|
+
cv[2] = v.blue;
|
|
580
|
+
cv[3] = v.alpha;
|
|
581
|
+
gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
|
|
582
|
+
}
|
|
583
|
+
`},{type:"vec3<f32>",test:s=>s.type==="vec3<f32>"&&s.size===1&&s.value.red!==void 0,ubo:`
|
|
584
|
+
v = uv[name];
|
|
585
|
+
data[offset] = v.red;
|
|
586
|
+
data[offset + 1] = v.green;
|
|
587
|
+
data[offset + 2] = v.blue;
|
|
588
|
+
`,uniform:`
|
|
589
|
+
cv = ud[name].value;
|
|
590
|
+
v = uv[name];
|
|
591
|
+
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
|
|
592
|
+
cv[0] = v.red;
|
|
593
|
+
cv[1] = v.green;
|
|
594
|
+
cv[2] = v.blue;
|
|
595
|
+
gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
|
|
596
|
+
}
|
|
597
|
+
`}];function fh(s,t,e,i){const r=[`
|
|
598
|
+
var v = null;
|
|
599
|
+
var v2 = null;
|
|
600
|
+
var t = 0;
|
|
601
|
+
var index = 0;
|
|
602
|
+
var name = null;
|
|
603
|
+
var arrayOffset = null;
|
|
604
|
+
`];let n=0;for(let o=0;o<s.length;o++){const h=s[o],c=h.data.name;let l=!1,u=0;for(let d=0;d<_e.length;d++)if(_e[d].test(h.data)){u=h.offset/4,r.push(`name = "${c}";`,`offset += ${u-n};`,_e[d][t]||_e[d].ubo),l=!0;break}if(!l)if(h.data.size>1)u=h.offset/4,r.push(e(h,u-n));else{const d=i[h.data.type];u=h.offset/4,r.push(`
|
|
605
|
+
v = uv.${c};
|
|
606
|
+
offset += ${u-n};
|
|
607
|
+
${d};
|
|
608
|
+
`)}n=u}const a=r.join(`
|
|
609
|
+
`);return new Function("uv","data","offset",a)}function Le(s,t){return`
|
|
610
|
+
for (let i = 0; i < ${s*t}; i++) {
|
|
611
|
+
data[offset + (((i / ${s})|0) * 4) + (i % ${s})] = v[i];
|
|
612
|
+
}
|
|
613
|
+
`}const ph={f32:`
|
|
614
|
+
data[offset] = v;`,i32:`
|
|
615
|
+
data[offset] = v;`,"vec2<f32>":`
|
|
616
|
+
data[offset] = v[0];
|
|
617
|
+
data[offset + 1] = v[1];`,"vec3<f32>":`
|
|
618
|
+
data[offset] = v[0];
|
|
619
|
+
data[offset + 1] = v[1];
|
|
620
|
+
data[offset + 2] = v[2];`,"vec4<f32>":`
|
|
621
|
+
data[offset] = v[0];
|
|
622
|
+
data[offset + 1] = v[1];
|
|
623
|
+
data[offset + 2] = v[2];
|
|
624
|
+
data[offset + 3] = v[3];`,"mat2x2<f32>":`
|
|
625
|
+
data[offset] = v[0];
|
|
626
|
+
data[offset + 1] = v[1];
|
|
627
|
+
data[offset + 4] = v[2];
|
|
628
|
+
data[offset + 5] = v[3];`,"mat3x3<f32>":`
|
|
629
|
+
data[offset] = v[0];
|
|
630
|
+
data[offset + 1] = v[1];
|
|
631
|
+
data[offset + 2] = v[2];
|
|
632
|
+
data[offset + 4] = v[3];
|
|
633
|
+
data[offset + 5] = v[4];
|
|
634
|
+
data[offset + 6] = v[5];
|
|
635
|
+
data[offset + 8] = v[6];
|
|
636
|
+
data[offset + 9] = v[7];
|
|
637
|
+
data[offset + 10] = v[8];`,"mat4x4<f32>":`
|
|
638
|
+
for (let i = 0; i < 16; i++) {
|
|
639
|
+
data[offset + i] = v[i];
|
|
640
|
+
}`,"mat3x2<f32>":Le(3,2),"mat4x2<f32>":Le(4,2),"mat2x3<f32>":Le(2,3),"mat4x3<f32>":Le(4,3),"mat2x4<f32>":Le(2,4),"mat3x4<f32>":Le(3,4)},nm={...ph,"mat2x2<f32>":`
|
|
641
|
+
data[offset] = v[0];
|
|
642
|
+
data[offset + 1] = v[1];
|
|
643
|
+
data[offset + 2] = v[2];
|
|
644
|
+
data[offset + 3] = v[3];
|
|
645
|
+
`};function am(s,t){const e=Math.max(dh[s.data.type]/16,1),i=s.data.value.length/s.data.size,r=(4-i%4)%4;return`
|
|
646
|
+
v = uv.${s.data.name};
|
|
647
|
+
offset += ${t};
|
|
1055
648
|
|
|
1056
|
-
|
|
1057
|
-
uniform mat3 translationMatrix;
|
|
1058
|
-
uniform mat3 uTransform;
|
|
649
|
+
arrayOffset = offset;
|
|
1059
650
|
|
|
1060
|
-
|
|
651
|
+
t = 0;
|
|
1061
652
|
|
|
1062
|
-
|
|
1063
|
-
{
|
|
1064
|
-
|
|
653
|
+
for(var i=0; i < ${s.data.size*e}; i++)
|
|
654
|
+
{
|
|
655
|
+
for(var j = 0; j < ${i}; j++)
|
|
656
|
+
{
|
|
657
|
+
data[arrayOffset++] = v[t++];
|
|
658
|
+
}
|
|
659
|
+
${r!==0?`arrayOffset += ${r};`:""}
|
|
660
|
+
}
|
|
661
|
+
`}function om(s){return fh(s,"uboStd40",am,ph)}class mh extends uh{constructor(){super({createUboElements:rm,generateUboSync:om})}}mh.extension={type:[b.WebGLSystem],name:"ubo"};class hm{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Y}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Y}copyToTexture(t,e,i,r,n){const a=this._renderTargetSystem,o=this._renderer,h=a.getGpuRenderTarget(t),c=o.gl;return this.finishRenderPass(t),c.bindFramebuffer(c.FRAMEBUFFER,h.resolveTargetFramebuffer),o.texture.bind(e,0),c.copyTexSubImage2D(c.TEXTURE_2D,0,n.x,n.y,i.x,i.y,r.width,r.height),e}startRenderPass(t,e=!0,i,r){const n=this._renderTargetSystem,a=t.colorTexture,o=n.getGpuRenderTarget(t);let h=r.y;t.isRoot&&(h=a.pixelHeight-r.height),t.colorTextures.forEach(u=>{this._renderer.texture.unbind(u)});const c=this._renderer.gl;c.bindFramebuffer(c.FRAMEBUFFER,o.framebuffer);const l=this._viewPortCache;(l.x!==r.x||l.y!==h||l.width!==r.width||l.height!==r.height)&&(l.x=r.x,l.y=h,l.width=r.width,l.height=r.height,c.viewport(r.x,h,r.width,r.height)),!o.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(o),this.clear(t,e,i)}finishRenderPass(t){const i=this._renderTargetSystem.getGpuRenderTarget(t);if(!i.msaa)return;const r=this._renderer.gl;r.bindFramebuffer(r.FRAMEBUFFER,i.resolveTargetFramebuffer),r.bindFramebuffer(r.READ_FRAMEBUFFER,i.framebuffer),r.blitFramebuffer(0,0,i.width,i.height,0,0,i.width,i.height,r.COLOR_BUFFER_BIT,r.NEAREST),r.bindFramebuffer(r.FRAMEBUFFER,i.framebuffer)}initGpuRenderTarget(t){const e=this._renderer,i=e.gl,r=new im;return t.colorTexture.resource===e.gl.canvas?(r.framebuffer=null,r):(this._initColor(t,r),i.bindFramebuffer(i.FRAMEBUFFER,null),r)}destroyGpuRenderTarget(t){const e=this._renderer.gl;t.framebuffer&&(e.deleteFramebuffer(t.framebuffer),t.framebuffer=null),t.resolveTargetFramebuffer&&(e.deleteFramebuffer(t.resolveTargetFramebuffer),t.resolveTargetFramebuffer=null),t.depthStencilRenderBuffer&&(e.deleteRenderbuffer(t.depthStencilRenderBuffer),t.depthStencilRenderBuffer=null),t.msaaRenderBuffer.forEach(i=>{e.deleteRenderbuffer(i)}),t.msaaRenderBuffer=null}clear(t,e,i){if(!e)return;const r=this._renderTargetSystem;typeof e=="boolean"&&(e=e?yt.ALL:yt.NONE);const n=this._renderer.gl;if(e&yt.COLOR){i??(i=r.defaultClearColor);const a=this._clearColorCache,o=i;(a[0]!==o[0]||a[1]!==o[1]||a[2]!==o[2]||a[3]!==o[3])&&(a[0]=o[0],a[1]=o[1],a[2]=o[2],a[3]=o[3],n.clearColor(o[0],o[1],o[2],o[3]))}n.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const i=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,i),t.stencil&&this._resizeStencil(i)}_initColor(t,e){const i=this._renderer,r=i.gl,n=r.createFramebuffer();if(e.resolveTargetFramebuffer=n,r.bindFramebuffer(r.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((a,o)=>{const h=a.source;h.antialias&&(i.context.supports.msaa?e.msaa=!0:D("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),i.texture.bindSource(h,0);const l=i.texture.getGlSource(h).texture;r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+o,3553,l,0)}),e.msaa){const a=r.createFramebuffer();e.framebuffer=a,r.bindFramebuffer(r.FRAMEBUFFER,a),t.colorTextures.forEach((o,h)=>{const c=r.createRenderbuffer();e.msaaRenderBuffer[h]=c})}else e.framebuffer=n;this._resizeColor(t,e)}_resizeColor(t,e){const i=t.colorTexture.source;if(e.width=i.pixelWidth,e.height=i.pixelHeight,t.colorTextures.forEach((r,n)=>{n!==0&&r.source.resize(i.width,i.height,i._resolution)}),e.msaa){const r=this._renderer,n=r.gl,a=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,a),t.colorTextures.forEach((o,h)=>{const c=o.source;r.texture.bindSource(c,0);const u=r.texture.getGlSource(c).internalFormat,d=e.msaaRenderBuffer[h];n.bindRenderbuffer(n.RENDERBUFFER,d),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,u,c.pixelWidth,c.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+h,n.RENDERBUFFER,d)})}}_initStencil(t){if(t.framebuffer===null)return;const e=this._renderer.gl,i=e.createRenderbuffer();t.depthStencilRenderBuffer=i,e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,i),this._resizeStencil(t)}_resizeStencil(t){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,this._renderer.context.webGLVersion===2?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}}function cm(s,t,e,i,r,n){const a=n?1:-1;return s.identity(),s.a=1/i*2,s.d=a*(1/r*2),s.tx=-1-t*s.a,s.ty=-a-e*s.d,s}const us=new Map;function gh(s,t){if(!us.has(s)){const e=new M({source:new Pe({resource:s,...t})}),i=()=>{us.get(s)===e&&us.delete(s)};e.once("destroy",i),e.source.once("destroy",i),us.set(s,e)}return us.get(s)}function lm(s){const t=s.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}const _h=class Sl{constructor(t={}){if(this.uid=et("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t={...Sl.defaultOptions,...t},this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,typeof t.colorTextures=="number"){this._managedColorTextures=!0;for(let e=0;e<t.colorTextures;e++)this.colorTextures.push(new ut({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}))}else{this.colorTextures=[...t.colorTextures.map(i=>i.source)];const e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof M||t.depthStencilTexture instanceof ut?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new ut({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,i=this.resolution,r=!1){this.dirtyId++,this.colorTextures.forEach((n,a)=>{r&&a===0||n.source.resize(t,e,i)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,i)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(t=>{t.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};_h.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Yr=_h;class xh{constructor(t){this.rootViewPort=new Y,this.viewport=new Y,this.onRenderTargetChange=new Da("onRenderTargetChange"),this.projectionMatrix=new I,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:i,frame:r}){this._renderTargetStack.length=0,this.push(t,e,i,r),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=lm(this.rootRenderTarget)}bind(t,e=!0,i,r){const n=this.getRenderTarget(t),a=this.renderTarget!==n;this.renderTarget=n,this.renderSurface=t;const o=this.getGpuRenderTarget(n);(n.pixelWidth!==o.width||n.pixelHeight!==o.height)&&(this.adaptor.resizeGpuRenderTarget(n),o.width=n.pixelWidth,o.height=n.pixelHeight);const h=n.colorTexture,c=this.viewport,l=h.pixelWidth,u=h.pixelHeight;if(!r&&t instanceof M&&(r=t.frame),r){const d=h._resolution;c.x=r.x*d+.5|0,c.y=r.y*d+.5|0,c.width=r.width*d+.5|0,c.height=r.height*d+.5|0}else c.x=0,c.y=0,c.width=l,c.height=u;return cm(this.projectionMatrix,0,0,c.width/h.resolution,c.height/h.resolution,!n.isRoot),this.adaptor.startRenderPass(n,e,i,c),a&&this.onRenderTargetChange.emit(n),n}clear(t,e=yt.ALL,i){e&&(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,i,this.viewport))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=yt.ALL,i,r){const n=this.bind(t,e,i,r);return this._renderTargetStack.push({renderTarget:n,frame:r}),n}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame)}getRenderTarget(t){return t.isTexture&&(t=t.source),this._renderSurfaceToRenderTargetHash.get(t)??this._initRenderTarget(t)}copyToTexture(t,e,i,r,n){i.x<0&&(r.width+=i.x,n.x-=i.x,i.x=0),i.y<0&&(r.height+=i.y,n.y-=i.y,i.y=0);const{pixelWidth:a,pixelHeight:o}=t;return r.width=Math.min(r.width,a-i.x),r.height=Math.min(r.height,o-i.y),this.adaptor.copyToTexture(t,e,i,r,n)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((t,e)=>{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return Pe.test(t)&&(t=gh(t).source),t instanceof Yr?e=t:t instanceof ut&&(e=new Yr({colorTextures:[t]}),Pe.test(t.source.resource)&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy();const i=this._gpuRenderTargetHash[e.uid];i&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(i))})),this._renderSurfaceToRenderTargetHash.set(t,e),e}getGpuRenderTarget(t){return this._gpuRenderTargetHash[t.uid]||(this._gpuRenderTargetHash[t.uid]=this.adaptor.initGpuRenderTarget(t))}}class yh extends xh{constructor(t){super(t),this.adaptor=new hm,this.adaptor.init(t,this)}}yh.extension={type:[b.WebGLSystem],name:"renderTarget"};class Kr extends _t{constructor({buffer:t,offset:e,size:i}){super(),this.uid=et("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=et("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=i,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=et("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}function um(s,t){const e=[],i=[`
|
|
662
|
+
var g = s.groups;
|
|
663
|
+
var sS = r.shader;
|
|
664
|
+
var p = s.glProgram;
|
|
665
|
+
var ugS = r.uniformGroup;
|
|
666
|
+
var resources;
|
|
667
|
+
`];let r=!1,n=0,a=0;const o=t._getProgramData(s.glProgram);for(const c in s.groups){const l=s.groups[c];e.push(`
|
|
668
|
+
resources = g[${c}].resources;
|
|
669
|
+
`);for(const u in l.resources){const d=l.resources[u];if(d instanceof xt)d.ubo?e.push(`
|
|
670
|
+
sS.bindUniformBlock(
|
|
671
|
+
resources[${u}],
|
|
672
|
+
sS._uniformBindMap[${c}[${u}],
|
|
673
|
+
${n++}
|
|
674
|
+
);
|
|
675
|
+
`):e.push(`
|
|
676
|
+
ugS.updateUniformGroup(resources[${u}], p, sD);
|
|
677
|
+
`);else if(d instanceof Kr)e.push(`
|
|
678
|
+
sS.bindUniformBlock(
|
|
679
|
+
resources[${u}],
|
|
680
|
+
sS._uniformBindMap[${c}[${u}],
|
|
681
|
+
${n++}
|
|
682
|
+
);
|
|
683
|
+
`);else if(d instanceof ut){const f=s._uniformBindMap[c][u],p=o.uniformData[f];p&&(r||(r=!0,i.push(`
|
|
684
|
+
var tS = r.texture;
|
|
685
|
+
`)),t._gl.uniform1i(p.location,a),e.push(`
|
|
686
|
+
tS.bind(resources[${u}], ${a});
|
|
687
|
+
`),a++)}}}const h=[...i,...e].join(`
|
|
688
|
+
`);return new Function("r","s","sD",h)}class dm{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}function bh(s,t,e){const i=s.createShader(t);return s.shaderSource(i,e),s.compileShader(i),i}function qr(s){const t=new Array(s);for(let e=0;e<t.length;e++)t[e]=!1;return t}function vh(s,t){switch(s){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return qr(2*t);case"bvec3":return qr(3*t);case"bvec4":return qr(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}let ii=null;const Sh={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"},fm={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"};function wh(s,t){if(!ii){const e=Object.keys(Sh);ii={};for(let i=0;i<e.length;++i){const r=e[i];ii[s[r]]=Sh[r]}}return ii[t]}function pm(s,t){const e=wh(s,t);return fm[e]||"float32"}function mm(s,t,e=!1){const i={},r=t.getProgramParameter(s,t.ACTIVE_ATTRIBUTES);for(let a=0;a<r;a++){const o=t.getActiveAttrib(s,a);if(o.name.startsWith("gl_"))continue;const h=pm(t,o.type);i[o.name]={location:0,format:h,stride:Xe(h).stride,offset:0,instance:!1,start:0}}const n=Object.keys(i);if(e){n.sort((a,o)=>a>o?1:-1);for(let a=0;a<n.length;a++)i[n[a]].location=a,t.bindAttribLocation(s,a,n[a]);t.linkProgram(s)}else for(let a=0;a<n.length;a++)i[n[a]].location=t.getAttribLocation(s,n[a]);return i}function gm(s,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};const e={},i=t.getProgramParameter(s,t.ACTIVE_UNIFORM_BLOCKS);for(let r=0;r<i;r++){const n=t.getActiveUniformBlockName(s,r),a=t.getUniformBlockIndex(s,n),o=t.getActiveUniformBlockParameter(s,r,t.UNIFORM_BLOCK_DATA_SIZE);e[n]={name:n,index:a,size:o}}return e}function _m(s,t){const e={},i=t.getProgramParameter(s,t.ACTIVE_UNIFORMS);for(let r=0;r<i;r++){const n=t.getActiveUniform(s,r),a=n.name.replace(/\[.*?\]$/,""),o=!!n.name.match(/\[.*?\]$/),h=wh(t,n.type);e[a]={name:a,index:r,type:h,size:n.size,isArray:o,value:vh(h,n.size)}}return e}function Th(s,t){const e=s.getShaderSource(t).split(`
|
|
689
|
+
`).map((c,l)=>`${l}: ${c}`),i=s.getShaderInfoLog(t),r=i.split(`
|
|
690
|
+
`),n={},a=r.map(c=>parseFloat(c.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(c=>c&&!n[c]?(n[c]=!0,!0):!1),o=[""];a.forEach(c=>{e[c-1]=`%c${e[c-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const h=e.join(`
|
|
691
|
+
`);o[0]=h,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...o),console.groupEnd()}function xm(s,t,e,i){s.getProgramParameter(t,s.LINK_STATUS)||(s.getShaderParameter(e,s.COMPILE_STATUS)||Th(s,e),s.getShaderParameter(i,s.COMPILE_STATUS)||Th(s,i),console.error("PixiJS Error: Could not initialize shader."),s.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",s.getProgramInfoLog(t)))}function ym(s,t){const e=bh(s,s.VERTEX_SHADER,t.vertex),i=bh(s,s.FRAGMENT_SHADER,t.fragment),r=s.createProgram();s.attachShader(r,e),s.attachShader(r,i);const n=t.transformFeedbackVaryings;n&&(typeof s.transformFeedbackVaryings!="function"?D("TransformFeedback is not supported but TransformFeedbackVaryings are given."):s.transformFeedbackVaryings(r,n.names,n.bufferMode==="separate"?s.SEPARATE_ATTRIBS:s.INTERLEAVED_ATTRIBS)),s.linkProgram(r),s.getProgramParameter(r,s.LINK_STATUS)||xm(s,r,e,i),t._attributeData=mm(r,s,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=_m(r,s),t._uniformBlockData=gm(r,s),s.deleteShader(e),s.deleteShader(i);const a={};for(const h in t._uniformData){const c=t._uniformData[h];a[h]={location:s.getUniformLocation(r,h),value:vh(c.type,c.size)}}return new dm(r,a)}const ri={textureCount:0,blockIndex:0};class Ah{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._nextIndex=0,this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t}contextChange(t){this._gl=t,this._maxBindings=t.MAX_UNIFORM_BUFFER_BINDINGS?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0,this._programDataHash=Object.create(null),this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;ri.textureCount=0,ri.blockIndex=0;let i=this._shaderSyncFunctions[t.glProgram._key];i||(i=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),i(this._renderer,t,ri)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,ri)}bindUniformBlock(t,e,i=0){const r=this._renderer.buffer,n=this._getProgramData(this._activeProgram),a=t._bufferResource;a&&this._renderer.ubo.updateUniformGroup(t),r.updateBuffer(t.buffer);let o=this._boundUniformsIdsToIndexHash[t.uid];if(o===void 0){const l=this._nextIndex++%this._maxBindings,u=this._boundIndexToUniformsHash[l];u&&(this._boundUniformsIdsToIndexHash[u.uid]=void 0),o=this._boundUniformsIdsToIndexHash[t.uid]=l,this._boundIndexToUniformsHash[l]=t,a?r.bindBufferRange(t.buffer,l,t.offset):r.bindBufferBase(t.buffer,l)}const h=this._gl,c=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[i]!==o&&(n.uniformBlockBindings[i]=o,h.uniformBlockBinding(n.program,c,o))}_setProgram(t){if(this._activeProgram===t)return;this._activeProgram=t;const e=this._getProgramData(t);this._gl.useProgram(e.program)}_getProgramData(t){return this._programDataHash[t._key]||this._createProgramData(t)}_createProgramData(t){const e=t._key;return this._programDataHash[e]=ym(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash))this._programDataHash[t].destroy(),this._programDataHash[t]=null;this._programDataHash=null,this._boundUniformsIdsToIndexHash=null}_generateShaderSync(t,e){return um(t,e)}}Ah.extension={type:[b.WebGLSystem],name:"shader"};const bm={f32:`if (cv !== v) {
|
|
692
|
+
cu.value = v;
|
|
693
|
+
gl.uniform1f(location, v);
|
|
694
|
+
}`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
695
|
+
cv[0] = v[0];
|
|
696
|
+
cv[1] = v[1];
|
|
697
|
+
gl.uniform2f(location, v[0], v[1]);
|
|
698
|
+
}`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
699
|
+
cv[0] = v[0];
|
|
700
|
+
cv[1] = v[1];
|
|
701
|
+
cv[2] = v[2];
|
|
702
|
+
gl.uniform3f(location, v[0], v[1], v[2]);
|
|
703
|
+
}`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
704
|
+
cv[0] = v[0];
|
|
705
|
+
cv[1] = v[1];
|
|
706
|
+
cv[2] = v[2];
|
|
707
|
+
cv[3] = v[3];
|
|
708
|
+
gl.uniform4f(location, v[0], v[1], v[2], v[3]);
|
|
709
|
+
}`,i32:`if (cv !== v) {
|
|
710
|
+
cu.value = v;
|
|
711
|
+
gl.uniform1i(location, v);
|
|
712
|
+
}`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
713
|
+
cv[0] = v[0];
|
|
714
|
+
cv[1] = v[1];
|
|
715
|
+
gl.uniform2i(location, v[0], v[1]);
|
|
716
|
+
}`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
717
|
+
cv[0] = v[0];
|
|
718
|
+
cv[1] = v[1];
|
|
719
|
+
cv[2] = v[2];
|
|
720
|
+
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
721
|
+
}`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
722
|
+
cv[0] = v[0];
|
|
723
|
+
cv[1] = v[1];
|
|
724
|
+
cv[2] = v[2];
|
|
725
|
+
cv[3] = v[3];
|
|
726
|
+
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
727
|
+
}`,u32:`if (cv !== v) {
|
|
728
|
+
cu.value = v;
|
|
729
|
+
gl.uniform1ui(location, v);
|
|
730
|
+
}`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
731
|
+
cv[0] = v[0];
|
|
732
|
+
cv[1] = v[1];
|
|
733
|
+
gl.uniform2ui(location, v[0], v[1]);
|
|
734
|
+
}`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
735
|
+
cv[0] = v[0];
|
|
736
|
+
cv[1] = v[1];
|
|
737
|
+
cv[2] = v[2];
|
|
738
|
+
gl.uniform3ui(location, v[0], v[1], v[2]);
|
|
739
|
+
}`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
740
|
+
cv[0] = v[0];
|
|
741
|
+
cv[1] = v[1];
|
|
742
|
+
cv[2] = v[2];
|
|
743
|
+
cv[3] = v[3];
|
|
744
|
+
gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
|
|
745
|
+
}`,bool:`if (cv !== v) {
|
|
746
|
+
cu.value = v;
|
|
747
|
+
gl.uniform1i(location, v);
|
|
748
|
+
}`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
749
|
+
cv[0] = v[0];
|
|
750
|
+
cv[1] = v[1];
|
|
751
|
+
gl.uniform2i(location, v[0], v[1]);
|
|
752
|
+
}`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
753
|
+
cv[0] = v[0];
|
|
754
|
+
cv[1] = v[1];
|
|
755
|
+
cv[2] = v[2];
|
|
756
|
+
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
757
|
+
}`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
758
|
+
cv[0] = v[0];
|
|
759
|
+
cv[1] = v[1];
|
|
760
|
+
cv[2] = v[2];
|
|
761
|
+
cv[3] = v[3];
|
|
762
|
+
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
763
|
+
}`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},vm={f32:"gl.uniform1fv(location, v);","vec2<f32>":"gl.uniform2fv(location, v);","vec3<f32>":"gl.uniform3fv(location, v);","vec4<f32>":"gl.uniform4fv(location, v);","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2<i32>":"gl.uniform2iv(location, v);","vec3<i32>":"gl.uniform3iv(location, v);","vec4<i32>":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2<u32>":"gl.uniform2iv(location, v);","vec3<u32>":"gl.uniform3iv(location, v);","vec4<u32>":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2<bool>":"gl.uniform2iv(location, v);","vec3<bool>":"gl.uniform3iv(location, v);","vec4<bool>":"gl.uniform4iv(location, v);"};function Sm(s,t){const e=[`
|
|
764
|
+
var v = null;
|
|
765
|
+
var cv = null;
|
|
766
|
+
var cu = null;
|
|
767
|
+
var t = 0;
|
|
768
|
+
var gl = renderer.gl;
|
|
769
|
+
var name = null;
|
|
770
|
+
`];for(const i in s.uniforms){if(!t[i]){s.uniforms[i]instanceof xt?s.uniforms[i].ubo?e.push(`
|
|
771
|
+
renderer.shader.bindUniformBlock(uv.${i}, "${i}");
|
|
772
|
+
`):e.push(`
|
|
773
|
+
renderer.shader.updateUniformGroup(uv.${i});
|
|
774
|
+
`):s.uniforms[i]instanceof Kr&&e.push(`
|
|
775
|
+
renderer.shader.bindBufferResource(uv.${i}, "${i}");
|
|
776
|
+
`);continue}const r=s.uniformStructures[i];let n=!1;for(let a=0;a<_e.length;a++){const o=_e[a];if(r.type===o.type&&o.test(r)){e.push(`name = "${i}";`,_e[a].uniform),n=!0;break}}if(!n){const o=(r.size===1?bm:vm)[r.type].replace("location",`ud["${i}"].location`);e.push(`
|
|
777
|
+
cu = ud["${i}"];
|
|
778
|
+
cv = cu.value;
|
|
779
|
+
v = uv["${i}"];
|
|
780
|
+
${o};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
|
|
781
|
+
`))}class Ph{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,i){const r=this._renderer.shader._getProgramData(e);(!t.isStatic||t._dirtyId!==r.uniformDirtyGroups[t.uid])&&(r.uniformDirtyGroups[t.uid]=t._dirtyId,this._getUniformSyncFunction(t,e)(r.uniformData,t.uniforms,this._renderer,i))}_getUniformSyncFunction(t,e){var i;return((i=this._uniformGroupSyncHash[t._signature])==null?void 0:i[e._key])||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){const i=this._uniformGroupSyncHash[t._signature]||(this._uniformGroupSyncHash[t._signature]={}),r=this._getSignature(t,e._uniformData,"u");return this._cache[r]||(this._cache[r]=this._generateUniformsSync(t,e._uniformData)),i[e._key]=this._cache[r],i[e._key]}_generateUniformsSync(t,e){return Sm(t,e)}_getSignature(t,e,i){const r=t.uniforms,n=[`${i}-`];for(const a in r)n.push(a),e[a]&&n.push(e[a].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}}Ph.extension={type:[b.WebGLSystem],name:"uniformGroup"};function wm(s){const t={};return t.normal=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t.add=[s.ONE,s.ONE],t.multiply=[s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t.screen=[s.ONE,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t["normal-npm"]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t["add-npm"]=[s.SRC_ALPHA,s.ONE,s.ONE,s.ONE],t["screen-npm"]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t.erase=[s.ZERO,s.ONE_MINUS_SRC_ALPHA],t}const Tm=0,Am=1,Pm=2,Cm=3,Em=4,Mm=5,Ch=class wn{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[Tm]=this.setBlend,this.map[Am]=this.setOffset,this.map[Pm]=this.setCullFace,this.map[Cm]=this.setDepthTest,this.map[Em]=this.setFrontFace,this.map[Mm]=this.setDepthMask,this.checks=[],this.defaultState=Kt.for2d()}contextChange(t){this.gl=t,this.blendModesMap=wm(t),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this._updateCheck(wn._checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this._updateCheck(wn._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(this.blendModesMap[t]||(t="normal"),t===this.blendMode)return;this.blendMode=t;const e=this.blendModesMap[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode="",this.setBlendMode("normal")}_updateCheck(t,e){const i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static _checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static _checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null,this.checks.length=0}};Ch.extension={type:[b.WebGLSystem],name:"state"};let Bm=Ch;class Rm{constructor(t){this.target=nh.TEXTURE_2D,this.texture=t,this.width=-1,this.height=-1,this.type=H.UNSIGNED_BYTE,this.internalFormat=$r.RGBA,this.format=$r.RGBA,this.samplerType=0}}const km={id:"buffer",upload(s,t,e){t.width===s.width||t.height===s.height?e.texSubImage2D(e.TEXTURE_2D,0,0,0,s.width,s.height,t.format,t.type,s.resource):e.texImage2D(t.target,0,t.internalFormat,s.width,s.height,0,t.format,t.type,s.resource),t.width=s.width,t.height=s.height}},Im={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},Fm={id:"compressed",upload(s,t,e){e.pixelStorei(e.UNPACK_ALIGNMENT,4);let i=s.pixelWidth,r=s.pixelHeight;const n=!!Im[s.format];for(let a=0;a<s.resource.length;a++){const o=s.resource[a];n?e.compressedTexImage2D(e.TEXTURE_2D,a,t.internalFormat,i,r,0,o):e.texImage2D(e.TEXTURE_2D,a,t.internalFormat,i,r,0,t.format,t.type,o),i=Math.max(i>>1,1),r=Math.max(r>>1,1)}}},Eh={id:"image",upload(s,t,e,i){const r=s.alphaMode==="premultiply-alpha-on-upload";e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r);const n=t.width,a=t.height,o=s.pixelWidth,h=s.pixelHeight,c=s.resourceWidth,l=s.resourceHeight;c<o||l<h?((n!==o||a!==h)&&e.texImage2D(t.target,0,t.internalFormat,o,h,0,t.format,t.type,null),i===2?e.texSubImage2D(e.TEXTURE_2D,0,0,0,c,l,t.format,t.type,s.resource):e.texSubImage2D(e.TEXTURE_2D,0,0,0,t.format,t.type,s.resource)):n===o||a===h?e.texSubImage2D(e.TEXTURE_2D,0,0,0,t.format,t.type,s.resource):i===2?e.texImage2D(t.target,0,t.internalFormat,o,h,0,t.format,t.type,s.resource):e.texImage2D(t.target,0,t.internalFormat,t.format,t.type,s.resource),t.width=o,t.height=h}},Gm={id:"video",upload(s,t,e,i){if(!s.isValid){e.texImage2D(t.target,0,t.internalFormat,1,1,0,t.format,t.type,null);return}Eh.upload(s,t,e,i)}},Mh={linear:9729,nearest:9728},Um={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},Zr={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},Dm={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function Bh(s,t,e,i,r,n,a,o){const h=n;if(!o||s.addressModeU!=="repeat"||s.addressModeV!=="repeat"||s.addressModeW!=="repeat"){const c=Zr[a?"clamp-to-edge":s.addressModeU],l=Zr[a?"clamp-to-edge":s.addressModeV],u=Zr[a?"clamp-to-edge":s.addressModeW];t[r](h,t.TEXTURE_WRAP_S,c),t[r](h,t.TEXTURE_WRAP_T,l),t.TEXTURE_WRAP_R&&t[r](h,t.TEXTURE_WRAP_R,u)}if((!o||s.magFilter!=="linear")&&t[r](h,t.TEXTURE_MAG_FILTER,Mh[s.magFilter]),e){if(!o||s.mipmapFilter!=="linear"){const c=Um[s.minFilter][s.mipmapFilter];t[r](h,t.TEXTURE_MIN_FILTER,c)}}else t[r](h,t.TEXTURE_MIN_FILTER,Mh[s.minFilter]);if(i&&s.maxAnisotropy>1){const c=Math.min(s.maxAnisotropy,t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[r](h,i.TEXTURE_MAX_ANISOTROPY_EXT,c)}s.compare&&t[r](h,t.TEXTURE_COMPARE_FUNC,Dm[s.compare])}function Om(s){return{r8unorm:s.RED,r8snorm:s.RED,r8uint:s.RED,r8sint:s.RED,r16uint:s.RED,r16sint:s.RED,r16float:s.RED,rg8unorm:s.RG,rg8snorm:s.RG,rg8uint:s.RG,rg8sint:s.RG,r32uint:s.RED,r32sint:s.RED,r32float:s.RED,rg16uint:s.RG,rg16sint:s.RG,rg16float:s.RG,rgba8unorm:s.RGBA,"rgba8unorm-srgb":s.RGBA,rgba8snorm:s.RGBA,rgba8uint:s.RGBA,rgba8sint:s.RGBA,bgra8unorm:s.RGBA,"bgra8unorm-srgb":s.RGBA,rgb9e5ufloat:s.RGB,rgb10a2unorm:s.RGBA,rg11b10ufloat:s.RGB,rg32uint:s.RG,rg32sint:s.RG,rg32float:s.RG,rgba16uint:s.RGBA,rgba16sint:s.RGBA,rgba16float:s.RGBA,rgba32uint:s.RGBA,rgba32sint:s.RGBA,rgba32float:s.RGBA,stencil8:s.STENCIL_INDEX8,depth16unorm:s.DEPTH_COMPONENT,depth24plus:s.DEPTH_COMPONENT,"depth24plus-stencil8":s.DEPTH_STENCIL,depth32float:s.DEPTH_COMPONENT,"depth32float-stencil8":s.DEPTH_STENCIL}}function Lm(s,t){let e={},i=s.RGBA;return s instanceof L.get().getWebGLRenderingContext()?t.srgb&&(e={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(e={"rgba8unorm-srgb":s.SRGB8_ALPHA8,"bgra8unorm-srgb":s.SRGB8_ALPHA8},i=s.RGBA8),{r8unorm:s.R8,r8snorm:s.R8_SNORM,r8uint:s.R8UI,r8sint:s.R8I,r16uint:s.R16UI,r16sint:s.R16I,r16float:s.R16F,rg8unorm:s.RG8,rg8snorm:s.RG8_SNORM,rg8uint:s.RG8UI,rg8sint:s.RG8I,r32uint:s.R32UI,r32sint:s.R32I,r32float:s.R32F,rg16uint:s.RG16UI,rg16sint:s.RG16I,rg16float:s.RG16F,rgba8unorm:s.RGBA,...e,rgba8snorm:s.RGBA8_SNORM,rgba8uint:s.RGBA8UI,rgba8sint:s.RGBA8I,bgra8unorm:i,rgb9e5ufloat:s.RGB9_E5,rgb10a2unorm:s.RGB10_A2,rg11b10ufloat:s.R11F_G11F_B10F,rg32uint:s.RG32UI,rg32sint:s.RG32I,rg32float:s.RG32F,rgba16uint:s.RGBA16UI,rgba16sint:s.RGBA16I,rgba16float:s.RGBA16F,rgba32uint:s.RGBA32UI,rgba32sint:s.RGBA32I,rgba32float:s.RGBA32F,stencil8:s.STENCIL_INDEX8,depth16unorm:s.DEPTH_COMPONENT16,depth24plus:s.DEPTH_COMPONENT24,"depth24plus-stencil8":s.DEPTH24_STENCIL8,depth32float:s.DEPTH_COMPONENT32F,"depth32float-stencil8":s.DEPTH32F_STENCIL8,...t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}function Hm(s){return{r8unorm:s.UNSIGNED_BYTE,r8snorm:s.BYTE,r8uint:s.UNSIGNED_BYTE,r8sint:s.BYTE,r16uint:s.UNSIGNED_SHORT,r16sint:s.SHORT,r16float:s.HALF_FLOAT,rg8unorm:s.UNSIGNED_BYTE,rg8snorm:s.BYTE,rg8uint:s.UNSIGNED_BYTE,rg8sint:s.BYTE,r32uint:s.UNSIGNED_INT,r32sint:s.INT,r32float:s.FLOAT,rg16uint:s.UNSIGNED_SHORT,rg16sint:s.SHORT,rg16float:s.HALF_FLOAT,rgba8unorm:s.UNSIGNED_BYTE,"rgba8unorm-srgb":s.UNSIGNED_BYTE,rgba8snorm:s.BYTE,rgba8uint:s.UNSIGNED_BYTE,rgba8sint:s.BYTE,bgra8unorm:s.UNSIGNED_BYTE,"bgra8unorm-srgb":s.UNSIGNED_BYTE,rgb9e5ufloat:s.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:s.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:s.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:s.UNSIGNED_INT,rg32sint:s.INT,rg32float:s.FLOAT,rgba16uint:s.UNSIGNED_SHORT,rgba16sint:s.SHORT,rgba16float:s.HALF_FLOAT,rgba32uint:s.UNSIGNED_INT,rgba32sint:s.INT,rgba32float:s.FLOAT,stencil8:s.UNSIGNED_BYTE,depth16unorm:s.UNSIGNED_SHORT,depth24plus:s.UNSIGNED_INT,"depth24plus-stencil8":s.UNSIGNED_INT_24_8,depth32float:s.FLOAT,"depth32float-stencil8":s.FLOAT_32_UNSIGNED_INT_24_8_REV}}const Nm=4;class Rh{constructor(t){this.managedTextures=[],this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._uploads={image:Eh,buffer:km,video:Gm,compressed:Fm},this._useSeparateSamplers=!1,this._renderer=t}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=Lm(t,this._renderer.context.extensions),this._mapFormatToType=Hm(t),this._mapFormatToFormat=Om(t)),this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null);for(let e=0;e<16;e++)this.bind(M.EMPTY,e)}initSource(t){this.bind(t)}bind(t,e=0){const i=t.source;t?(this.bindSource(i,e),this._useSeparateSamplers&&this._bindSampler(i.style,e)):(this.bindSource(null,e),this._useSeparateSamplers&&this._bindSampler(null,e))}bindSource(t,e=0){const i=this._gl;if(t._touched=this._renderer.textureGC.count,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t=t||M.EMPTY.source;const r=this.getGlSource(t);i.bindTexture(r.target,r.texture)}}_bindSampler(t,e=0){const i=this._gl;if(!t){this._boundSamplers[e]=null,i.bindSampler(e,null);return}const r=this._getGlSampler(t);this._boundSamplers[e]!==r&&(this._boundSamplers[e]=r,i.bindSampler(e,r))}unbind(t){const e=t.source,i=this._boundTextures,r=this._gl;for(let n=0;n<i.length;n++)if(i[n]===e){this._activateLocation(n);const a=this.getGlSource(e);r.bindTexture(a.target,null),i[n]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){const e=this._gl,i=new Rm(e.createTexture());if(i.type=this._mapFormatToType[t.format],i.internalFormat=this._mapFormatToInternalFormat[t.format],i.format=this._mapFormatToFormat[t.format],t.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||t.isPowerOfTwo)){const r=Math.max(t.width,t.height);t.mipLevelCount=Math.floor(Math.log2(r))+1}return this._glTextures[t.uid]=i,this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceUpdate,this),t.on("styleChange",this.onStyleChange,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),this.updateStyle(t,!1),i}onStyleChange(t){this.updateStyle(t,!1)}updateStyle(t,e){const i=this._gl,r=this.getGlSource(t);i.bindTexture(i.TEXTURE_2D,r.texture),this._boundTextures[this._activeTextureLocation]=t,Bh(t.style,i,t.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",i.TEXTURE_2D,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t){const e=this._glTextures[t.uid];e&&(this.unbind(t),this._glTextures[t.uid]=null,this._gl.deleteTexture(e.texture))}onSourceUpdate(t){const e=this._gl,i=this.getGlSource(t);e.bindTexture(e.TEXTURE_2D,i.texture),this._boundTextures[this._activeTextureLocation]=t,this._uploads[t.uploadMethodId]?this._uploads[t.uploadMethodId].upload(t,i,e,this._renderer.context.webGLVersion):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t.pixelWidth,t.pixelHeight,0,e.RGBA,e.UNSIGNED_BYTE,null),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);const i=this.getGlSource(t);this._gl.generateMipmap(i.target)}onSourceDestroy(t){t.off("destroy",this.onSourceDestroy,this),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}_initSampler(t){const e=this._gl,i=this._gl.createSampler();return this._glSamplers[t._resourceId]=i,Bh(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",i,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return this._glTextures[t.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:i,height:r}=this.getPixels(t),n=L.get().createCanvas();n.width=i,n.height=r;const a=n.getContext("2d");if(a){const o=a.createImageData(i,r);o.data.set(e),a.putImageData(o,0,0)}return n}getPixels(t){const e=t.source.resolution,i=t.frame,r=Math.max(Math.round(i.width*e),1),n=Math.max(Math.round(i.height*e),1),a=new Uint8Array(Nm*r*n),o=this._renderer,h=o.renderTarget.getRenderTarget(t),c=o.renderTarget.getGpuRenderTarget(h),l=o.gl;return l.bindFramebuffer(l.FRAMEBUFFER,c.resolveTargetFramebuffer),l.readPixels(Math.round(i.x*e),Math.round(i.y*e),r,n,l.RGBA,l.UNSIGNED_BYTE,a),{pixels:new Uint8ClampedArray(a.buffer),width:r,height:n}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._renderer=null}}Rh.extension={type:[b.WebGLSystem],name:"texture"};class kh{init(){const t=new xt({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),e=Ht(),i=os({name:"graphics",bits:[Or,zr(e),Vr,cs]});this.shader=new At({glProgram:i,resources:{localUniforms:t,batchSamplers:Wr(e)}})}execute(t,e){const i=e.context,r=i.customShader||this.shader,n=t.renderer,a=n.graphicsContext,{geometry:o,instructions:h}=a.getContextRenderData(i);r.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(r),n.geometry.bind(o,r.glProgram);const c=h.instructions;for(let l=0;l<h.instructionSize;l++){const u=c[l];if(u.size){for(let d=0;d<u.textures.textures.length;d++)n.texture.bind(u.textures.textures[d],d);n.geometry.draw("triangle-list",u.size,u.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}kh.extension={type:[b.WebGLPipesAdaptor],name:"graphics"};class Ih{init(){const t=os({name:"mesh",bits:[Vr,jp,cs]});this._shader=new At({glProgram:t,resources:{uTexture:M.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new I}}}})}execute(t,e){const i=t.renderer;let r=e._shader;if(r){if(!r.glProgram){D("Mesh shader has no glProgram",e.shader);return}}else{r=this._shader;const n=e.texture,a=n.source;r.resources.uTexture=a,r.resources.uSampler=a.style,r.resources.textureUniforms.uniforms.uTextureMatrix=n.textureMatrix.mapCoord}r.groups[100]=i.globalUniforms.bindGroup,r.groups[101]=t.localUniformsBindGroup,i.encoder.draw({geometry:e._geometry,shader:r,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Ih.extension={type:[b.WebGLPipesAdaptor],name:"mesh"};class Fh{constructor(t){this._renderer=t}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}}Fh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"customRender"};function Gh(s,t){const e=s.instructionSet,i=e.instructions;for(let r=0;r<e.instructionSize;r++){const n=i[r];t[n.renderPipeId].execute(n)}}class Uh{constructor(t){this._renderer=t}addRenderGroup(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&(this._renderer.globalUniforms.push({worldTransformMatrix:t.worldTransform,worldColor:t.worldColorAlpha}),Gh(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop())}destroy(){this._renderer=null}}Uh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"renderGroup"};function Dh(s,t=[]){t.push(s);for(let e=0;e<s.renderGroupChildren.length;e++)Dh(s.renderGroupChildren[e],t);return t}function zm(s,t,e){const i=s>>16&255,r=s>>8&255,n=s&255,a=t>>16&255,o=t>>8&255,h=t&255,c=i+(a-i)*e,l=r+(o-r)*e,u=n+(h-n)*e;return(c<<16)+(l<<8)+u}const Jr=16777215;function Oh(s,t){return s===Jr||t===Jr?s+t-Jr:zm(s,t,.5)}const Wm=new z;function Lh(s,t=!1){Vm(s);const e=s.childrenToUpdate,i=s.updateTick++;for(const r in e){const n=e[r],a=n.list,o=n.index;for(let h=0;h<o;h++){const c=a[h];c.parentRenderGroup===s&&Hh(c,i,0)}n.index=0}if(t)for(let r=0;r<s.renderGroupChildren.length;r++)Lh(s.renderGroupChildren[r],t)}function Vm(s){const t=s.root;let e;if(s.renderGroupParent){const i=s.renderGroupParent;s.worldTransform.appendFrom(t.relativeGroupTransform,i.worldTransform),s.worldColor=Oh(t.groupColor,i.worldColor),e=t.groupAlpha*i.worldAlpha}else s.worldTransform.copyFrom(t.localTransform),s.worldColor=t.localColor,e=t.localAlpha;e=e<0?0:e>1?1:e,s.worldAlpha=e,s.worldColorAlpha=s.worldColor+((e*255|0)<<24)}function Hh(s,t,e){if(t===s.updateTick)return;s.updateTick=t,s.didChange=!1;const i=s.localTransform;s.updateLocalTransform();const r=s.parent;if(r&&!r.renderGroup?(e=e|s._updateFlags,s.relativeGroupTransform.appendFrom(i,r.relativeGroupTransform),e&&Nh(s,r,e)):(e=s._updateFlags,s.relativeGroupTransform.copyFrom(i),e&&Nh(s,Wm,e)),!s.renderGroup){const n=s.children,a=n.length;for(let h=0;h<a;h++)Hh(n[h],t,e);const o=s.parentRenderGroup;s.renderPipeId&&!o.structureDidChange&&o.updateRenderable(s)}}function Nh(s,t,e){if(e&Ui){s.groupColor=Oh(s.localColor,t.groupColor);let i=s.localAlpha*t.groupAlpha;i=i<0?0:i>1?1:i,s.groupAlpha=i,s.groupColorAlpha=s.groupColor+((i*255|0)<<24)}e&Zn&&(s.groupBlendMode=s.localBlendMode==="inherit"?t.groupBlendMode:s.localBlendMode),e&Rs&&(s.globalDisplayStatus=s.localDisplayStatus&t.globalDisplayStatus),s._updateFlags=0}function jm(s,t){const{list:e,index:i}=s.childrenRenderablesToUpdate;let r=!1;for(let n=0;n<i;n++){const a=e[n];if(r=t[a.renderPipeId].validateRenderable(a),r)break}return s.structureDidChange=r,r}const $m=new I;class zh{constructor(t){this._renderer=t}render({container:t,transform:e}){t.isRenderGroup=!0;const i=t.parent,r=t.renderGroup.renderGroupParent;t.parent=null,t.renderGroup.renderGroupParent=null;const n=this._renderer,a=Dh(t.renderGroup,[]);let o=$m;e&&(o=o.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const h=n.renderPipes;for(let c=0;c<a.length;c++){const l=a[c];l.runOnRender(),l.instructionSet.renderPipes=h,l.structureDidChange||jm(l,h),Lh(l),l.structureDidChange?(l.structureDidChange=!1,$p(l,h)):Xm(l),l.childrenRenderablesToUpdate.index=0,n.renderPipes.batch.upload(l.instructionSet)}n.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),Gh(t.renderGroup,h),h.uniformBatch&&h.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(o),t.parent=i,t.renderGroup.renderGroupParent=r}destroy(){this._renderer=null}}zh.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"renderGroup"};function Xm(s){const{list:t,index:e}=s.childrenRenderablesToUpdate;for(let i=0;i<e;i++){const r=t[i];r.didViewUpdate&&s.updateRenderable(r)}}class Qr{constructor(){this.vertexSize=4,this.indexSize=6,this.location=0,this.batcher=null,this.batch=null,this.roundPixels=0}get blendMode(){return this.renderable.groupBlendMode}packAttributes(t,e,i,r){const n=this.renderable,a=this.texture,o=n.groupTransform,h=o.a,c=o.b,l=o.c,u=o.d,d=o.tx,f=o.ty,p=this.bounds,g=p.maxX,m=p.minX,_=p.maxY,x=p.minY,y=a.uvs,v=n.groupColorAlpha,w=r<<16|this.roundPixels&65535;t[i+0]=h*m+l*x+d,t[i+1]=u*x+c*m+f,t[i+2]=y.x0,t[i+3]=y.y0,e[i+4]=v,e[i+5]=w,t[i+6]=h*g+l*x+d,t[i+7]=u*x+c*g+f,t[i+8]=y.x1,t[i+9]=y.y1,e[i+10]=v,e[i+11]=w,t[i+12]=h*g+l*_+d,t[i+13]=u*_+c*g+f,t[i+14]=y.x2,t[i+15]=y.y2,e[i+16]=v,e[i+17]=w,t[i+18]=h*m+l*_+d,t[i+19]=u*_+c*m+f,t[i+20]=y.x3,t[i+21]=y.y3,e[i+22]=v,e[i+23]=w}packIndex(t,e,i){t[e]=i+0,t[e+1]=i+1,t[e+2]=i+2,t[e+3]=i+0,t[e+4]=i+2,t[e+5]=i+3}reset(){this.renderable=null,this.texture=null,this.batcher=null,this.batch=null,this.bounds=null}}class Wh{constructor(t){this._gpuSpriteHash=Object.create(null),this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t._didSpriteUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i)}updateRenderable(t){const e=this._gpuSpriteHash[t.uid];t._didSpriteUpdate&&this._updateBatchableSprite(t,e),e.batcher.updateElement(e)}validateRenderable(t){const e=t._texture,i=this._getGpuSprite(t);return i.texture._source!==e._source?!i.batcher.checkAndUpdateTexture(i,e):!1}destroyRenderable(t){const e=this._gpuSpriteHash[t.uid];$.return(e),this._gpuSpriteHash[t.uid]=null}_updateBatchableSprite(t,e){t._didSpriteUpdate=!1,e.bounds=t.bounds,e.texture=t._texture}_getGpuSprite(t){return this._gpuSpriteHash[t.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=$.get(Qr);return e.renderable=t,e.texture=t._texture,e.bounds=t.bounds,e.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuSpriteHash[t.uid]=e,t._didSpriteUpdate=!1,t.on("destroyed",()=>{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuSpriteHash)$.return(this._gpuSpriteHash[t]);this._gpuSpriteHash=null,this._renderer=null}}Wh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"sprite"};const tn=class wl{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new j(0),this.color=this._backgroundColor,this.alpha=1}init(t){t={...wl.defaultOptions,...t},this.clearBeforeRender=t.clearBeforeRender,this.color=t.background||t.backgroundColor||this._backgroundColor,this.alpha=t.backgroundAlpha,this._backgroundColor.setAlpha(t.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};tn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"background",priority:0},tn.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let Ym=tn;const ds={};O.handle(b.BlendMode,s=>{if(!s.name)throw new Error("BlendMode extension must have a name property");ds[s.name]=s.ref},s=>{delete ds[s.name]});class Vh{constructor(t){this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t}setBlendMode(t,e,i){if(this._activeBlendMode===e){this._isAdvanced&&this._renderableList.push(t);return}this._activeBlendMode=e,this._isAdvanced&&this._endAdvancedBlendMode(i),this._isAdvanced=!!ds[e],this._isAdvanced&&(this._beginAdvancedBlendMode(i),this._renderableList.push(t))}_beginAdvancedBlendMode(t){this._renderer.renderPipes.batch.break(t);const e=this._activeBlendMode;if(!ds[e]){D(`Unable to assign BlendMode: '${e}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}let i=this._filterHash[e];i||(i=this._filterHash[e]=new Ms,i.filters=[new ds[e]]);const r={renderPipeId:"filter",action:"pushFilter",renderables:[],filterEffect:i,canBundle:!1};this._renderableList=r.renderables,t.add(r)}_endAdvancedBlendMode(t){this._renderableList=null,this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(t){this._isAdvanced&&this._endAdvancedBlendMode(t)}destroy(){this._renderer=null,this._renderableList=null;for(const t in this._filterHash)this._filterHash[t].destroy();this._filterHash=null}}Vh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"blendMode"};const en={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},sn=class Tl{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof z||t instanceof M?{target:t,...e}:{...e,...t}}async image(t){const e=new Image;return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,Tl.defaultImageOptions);const{format:e,quality:i}=t,r=this.canvas(t);if(r.toBlob!==void 0)return new Promise((n,a)=>{r.toBlob(o=>{if(!o){a(new Error("ICanvas.toBlob failed!"));return}const h=new FileReader;h.onload=()=>n(h.result),h.onerror=a,h.readAsDataURL(o)},en[e],i)});if(r.toDataURL!==void 0)return r.toDataURL(en[e],i);if(r.convertToBlob!==void 0){const n=await r.convertToBlob({type:en[e],quality:i});return new Promise((a,o)=>{const h=new FileReader;h.onload=()=>a(h.result),h.onerror=o,h.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer;if(e instanceof M)return i.texture.generateCanvas(e);const r=i.textureGenerator.generateTexture(t),n=i.texture.generateCanvas(r);return r.destroy(),n}pixels(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer,r=e instanceof M?e:i.textureGenerator.generateTexture(t),n=i.texture.getPixels(r);return e instanceof z&&r.destroy(),n}texture(t){return t=this._normalizeOptions(t),t.target instanceof M?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){t=this._normalizeOptions(t);const e=this.canvas(t),i=document.createElement("a");i.download=t.filename??"image.png",i.href=e.toDataURL("image/png"),document.body.appendChild(i),i.click(),document.body.removeChild(i)}log(t){const e=t.width??200;t=this._normalizeOptions(t);const i=this.canvas(t),r=i.toDataURL();console.log(`[Pixi Texture] ${i.width}px ${i.height}px`);const n=["font-size: 1px;",`padding: ${e}px 300px;`,`background: url(${r}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}destroy(){this._renderer=null}};sn.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"extract"},sn.defaultImageOptions={format:"png",quality:1};let Km=sn;class qm extends M{static create(t){return new M({source:new ut(t)})}resize(t,e,i){return this.source.resize(t,e,i),this}}const Zm=new Y,Jm=new mt,Qm=[0,0,0,0];class jh{constructor(t){this._renderer=t}generateTexture(t){var c;t instanceof z&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const e=t.resolution||this._renderer.resolution,i=t.antialias||this._renderer.view.antialias,r=t.target;let n=t.clearColor;n?n=Array.isArray(n)&&n.length===4?n:j.shared.setValue(n).toArray():n=Qm;const a=((c=t.frame)==null?void 0:c.copyTo(Zm))||ki(r,Jm).rectangle;a.width=Math.max(a.width,1/e)|0,a.height=Math.max(a.height,1/e)|0;const o=qm.create({...t.textureSourceOptions,width:a.width,height:a.height,resolution:e,antialias:i}),h=I.shared.translate(-a.x,-a.y);return this._renderer.render({container:r,transform:h,target:o,clearColor:n}),o}destroy(){this._renderer=null}}jh.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"textureGenerator"};function ni(s,t,e){const i=(s>>24&255)/255;t[e++]=(s&255)/255*i,t[e++]=(s>>8&255)/255*i,t[e++]=(s>>16&255)/255*i,t[e++]=i}class $h{constructor(t){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=t}reset(){this._stackIndex=0;for(let t=0;t<this._activeUniforms.length;t++)this._uniformsPool.push(this._activeUniforms[t]);for(let t=0;t<this._activeBindGroups.length;t++)this._bindGroupPool.push(this._activeBindGroups[t]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(t){this.reset(),this.push(t)}bind({size:t,projectionMatrix:e,worldTransformMatrix:i,worldColor:r,offset:n}){const a=this._renderer.renderTarget.renderTarget,o=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:a,worldTransformMatrix:new I,worldColor:4294967295,offset:new X},h={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||a.size,worldTransformMatrix:i||o.worldTransformMatrix,worldColor:r||o.worldColor,offset:n||o.offset,bindGroup:null},c=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(c);const l=c.uniforms;l.uProjectionMatrix=h.projectionMatrix,l.uResolution=h.resolution,l.uWorldTransformMatrix.copyFrom(h.worldTransformMatrix),l.uWorldTransformMatrix.tx-=h.offset.x,l.uWorldTransformMatrix.ty-=h.offset.y,ni(h.worldColor,l.uWorldColorAlpha,0),c.update();let u;this._renderer.renderPipes.uniformBatch?u=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(c,!1):(u=this._bindGroupPool.pop()||new Yt,this._activeBindGroups.push(u),u.setResource(c,0)),h.bindGroup=u,this._currentGlobalUniformData=h}push(t){this.bind(t),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===Lt.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new xt({uProjectionMatrix:{value:new I,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new I,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null}}$h.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"globalUniforms"};let Xh=!1;const Yh="8.1.5";function tg(s){if(!Xh){if(L.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c %c %c %c %c PixiJS %c v${Yh} (${s}) http://www.pixijs.com/
|
|
782
|
+
|
|
783
|
+
`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...t)}else globalThis.console&&globalThis.console.log(`PixiJS ${Yh} - ${s} - http://www.pixijs.com/`);Xh=!0}}class rn{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===Lt.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),tg(e)}}}rn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"hello",priority:-2},rn.defaultOptions={hello:!1};const nn=class Al{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(t){t={...Al.defaultOptions,...t},this.checkCountMax=t.textureGCCheckCountMax,this.maxIdle=t.textureGCAMaxIdle,this.active=t.textureGCActive}postrender(){this._renderer.renderingToScreen&&(this.count++,this.active&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this._renderer.texture.managedTextures;for(let e=0;e<t.length;e++){const i=t[e];i.autoGarbageCollect&&i.resource&&i._touched>-1&&this.count-i._touched>this.maxIdle&&(i._touched=-1,i.unload())}}destroy(){this._renderer=null}};nn.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"textureGC"},nn.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:60*60,textureGCCheckCountMax:600};let Kh=nn;O.add(Kh);const an=class Pl{get resolution(){return this.texture.source._resolution}set resolution(t){this.texture.source.resize(this.texture.source.width,this.texture.source.height,t)}init(t){t={...Pl.defaultOptions,...t},t.view&&(N(W,"ViewSystem.view has been renamed to ViewSystem.canvas"),t.canvas=t.view),this.screen=new Y(0,0,t.width,t.height),this.canvas=t.canvas||L.get().createCanvas(),this.antialias=!!t.antialias,this.texture=gh(this.canvas,t),this.renderTarget=new Yr({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.multiView=!!t.multiView,this.autoDensity&&(this.canvas.style.width=`${this.texture.width}px`,this.canvas.style.height=`${this.texture.height}px`),this.resolution=t.resolution}resize(t,e,i){this.texture.source.resize(t,e,i),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height,this.autoDensity&&(this.canvas.style.width=`${t}px`,this.canvas.style.height=`${e}px`)}destroy(t=!1){(typeof t=="boolean"?t:!!(t!=null&&t.removeView))&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}};an.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"view",priority:0},an.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};const qh=[Ym,$h,rn,an,zh,Kh,jh,Km],Zh=[Vh,Jo,Wh,Uh,th,sh,eh,Fh],eg=[...qh,mh,sm,Zp,ih,Rh,yh,oh,Ph,Ah,ch,Bm,lh,hh],sg=[...Zh],ig=[qo,Ih,kh],Jh=[],Qh=[],tc=[];O.handleByNamedList(b.WebGLSystem,Jh),O.handleByNamedList(b.WebGLPipes,Qh),O.handleByNamedList(b.WebGLPipesAdaptor,tc),O.add(...eg,...sg,...ig);class rg extends Ws{constructor(){const t={name:"webgl",type:Lt.WEBGL,systems:Jh,renderPipes:Qh,renderPipeAdaptors:tc};super(t)}}const ng=Object.freeze(Object.defineProperty({__proto__:null,WebGLRenderer:rg},Symbol.toStringTag,{value:"Module"}));class ec{constructor(t){this._hash=Object.create(null),this._renderer=t}contextChange(t){this._gpu=t}getBindGroup(t,e,i){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,i)}_createBindGroup(t,e,i){const r=this._gpu.device,n=e.layout[i],a=[],o=this._renderer;for(const l in n){const u=t.resources[l]??t.resources[n[l]];let d;if(u._resourceType==="uniformGroup"){const f=u;o.ubo.updateUniformGroup(f);const p=f.buffer;d={buffer:o.buffer.getGPUBuffer(p),offset:0,size:p.descriptor.size}}else if(u._resourceType==="buffer"){const f=u;d={buffer:o.buffer.getGPUBuffer(f),offset:0,size:f.descriptor.size}}else if(u._resourceType==="bufferResource"){const f=u;d={buffer:o.buffer.getGPUBuffer(f.buffer),offset:f.offset,size:f.size}}else if(u._resourceType==="textureSampler"){const f=u;d=o.texture.getGpuSampler(f)}else if(u._resourceType==="textureSource"){const f=u;d=o.texture.getGpuSource(f).createView({})}a.push({binding:n[l],resource:d})}const h=o.shader.getProgramData(e).bindGroups[i],c=r.createBindGroup({layout:h,entries:a});return this._hash[t._key]=c,c}destroy(){for(const t of Object.keys(this._hash))this._hash[t]=null;this._hash=null,this._renderer=null}}ec.extension={type:[b.WebGPUSystem],name:"bindGroup"};class sc{constructor(){this._gpuBuffers=Object.create(null),this._managedBuffers=[]}contextChange(t){this._gpu=t}getGPUBuffer(t){return this._gpuBuffers[t.uid]||this.createGPUBuffer(t)}updateBuffer(t){const e=this._gpuBuffers[t.uid]||this.createGPUBuffer(t),i=t.data;return t._updateID&&i&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,i.buffer,0,(t._updateSize||i.byteLength)+3&-4)),e}destroyAll(){for(const t in this._gpuBuffers)this._gpuBuffers[t].destroy();this._gpuBuffers={}}createGPUBuffer(t){this._gpuBuffers[t.uid]||(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this),t.on("destroy",this.onBufferDestroy,this));const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&(pr(t.data.buffer,e.getMappedRange()),e.unmap()),this._gpuBuffers[t.uid]=e,this._managedBuffers.push(t),e}onBufferChange(t){this._gpuBuffers[t.uid].destroy(),t._updateID=0,this._gpuBuffers[t.uid]=this.createGPUBuffer(t)}onBufferDestroy(t){this._managedBuffers.splice(this._managedBuffers.indexOf(t),1),this._destroyBuffer(t)}destroy(){this._managedBuffers.forEach(t=>this._destroyBuffer(t)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(t){this._gpuBuffers[t.uid].destroy(),t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this),t.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[t.uid]=null}}sc.extension={type:[b.WebGPUSystem],name:"buffer"};class ag{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${t*4}`);const e=this.byteIndex;let i=e+t*4;if(i=Math.ceil(i/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,i>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=i,e}addGroup(t){const e=this.addEmptyGroup(t.length);for(let i=0;i<t.length;i++)this.data[e/4+i]=t[i];return e}destroy(){this._buffer.destroy(),this._buffer=null,this.data=null}}class ic{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.pipeline.setColorMask(t))}destroy(){this._renderer=null,this._colorMaskCache=null}}ic.extension={type:[b.WebGPUSystem],name:"colorMask"};class on{constructor(t){this._renderer=t}async init(t){return this._initPromise?this._initPromise:(this._initPromise=this._createDeviceAndAdaptor(t).then(e=>{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await navigator.gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),i=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(n=>e.features.has(n)),r=await e.requestDevice({requiredFeatures:i});return{adapter:e,device:r}}destroy(){this.gpu=null,this._renderer=null}}on.extension={type:[b.WebGPUSystem],name:"device"},on.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class rc{constructor(t){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=t}renderStart(){this.commandFinished=new Promise(t=>{this._resolveCommandFinished=t}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(t){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(t.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(t){this.renderPassEncoder.setViewport(t.x,t.y,t.width,t.height,0,1)}setPipelineFromGeometryProgramAndState(t,e,i,r){const n=this._renderer.pipeline.getPipeline(t,e,i,r);this.setPipeline(n)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=t.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,i){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.textureGC.count);const r=this._renderer.bindGroup.getBindGroup(e,i,t);this.renderPassEncoder.setBindGroup(t,r)}setGeometry(t){for(const e in t.attributes){const i=t.attributes[e];this._setVertexBuffer(i.location,i.buffer)}t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const i in t.groups){const r=t.groups[i];e||this._syncBindGroup(r),this.setBindGroup(i,r,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){const i=t.resources[e];i.isUniformGroup&&this._renderer.ubo.updateUniformGroup(i)}}draw(t){const{geometry:e,shader:i,state:r,topology:n,size:a,start:o,instanceCount:h,skipSync:c}=t;this.setPipelineFromGeometryProgramAndState(e,i.gpuProgram,r,n),this.setGeometry(e),this._setShaderBindGroups(i,c),e.indexBuffer?this.renderPassEncoder.drawIndexed(a||e.indexBuffer.data.length,h||e.instanceCount,o||0):this.renderPassEncoder.draw(a||e.getSize(),h||e.instanceCount,o||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,i={...this._boundVertexBuffer},r=this._boundIndexBuffer,n={...this._boundBindGroup};this._clearCache();const a=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(a.x,a.y,a.width,a.height,0,1),this.setPipeline(e);for(const o in i)this._setVertexBuffer(o,i[o]);for(const o in n)this.setBindGroup(o,n[o],null);this._setIndexBuffer(r)}_clearCache(){for(let t=0;t<16;t++)this._boundBindGroup[t]=null,this._boundVertexBuffer[t]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(t){this._gpu=t}}rc.extension={type:[b.WebGPUSystem],name:"encoder",priority:1};class nc{constructor(t){this._renderTargetStencilState=Object.create(null),this._renderer=t,t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:ht.DISABLED,stencilReference:0}),this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid];i.stencilMode=t,i.stencilReference=e;const r=this._renderer;r.pipeline.setStencilMode(t),r.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}nc.extension={type:[b.WebGPUSystem],name:"stencil"};const ai={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function og(s){const t=s.map(i=>({data:i,offset:0,size:0}));let e=0;for(let i=0;i<t.length;i++){const r=t[i];let n=ai[r.data.type].size;const a=ai[r.data.type].align;if(!ai[r.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${r.data.type}`);r.data.size>1&&(n=Math.max(n,a)*r.data.size),e=Math.ceil(e/a)*a,r.size=n,r.offset=e,e+=n}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}function hg(s,t){const{size:e,align:i}=ai[s.data.type],r=(i-e)/4;return`
|
|
784
|
+
v = uv.${s.data.name};
|
|
785
|
+
${t!==0?`offset += ${t};`:""}
|
|
786
|
+
|
|
787
|
+
arrayOffset = offset;
|
|
788
|
+
|
|
789
|
+
t = 0;
|
|
790
|
+
|
|
791
|
+
for(var i=0; i < ${s.data.size*(e/4)}; i++)
|
|
792
|
+
{
|
|
793
|
+
for(var j = 0; j < ${e/4}; j++)
|
|
794
|
+
{
|
|
795
|
+
data[arrayOffset++] = v[t++];
|
|
796
|
+
}
|
|
797
|
+
${r!==0?`arrayOffset += ${r};`:""}
|
|
798
|
+
}
|
|
799
|
+
`}function cg(s){return fh(s,"uboWgsl",hg,nm)}class ac extends uh{constructor(){super({createUboElements:og,generateUboSync:cg})}}ac.extension={type:[b.WebGPUSystem],name:"ubo"};const ne=128;class oc{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._batchBuffer=new ag({minUniformOffsetAlignment:ne});const e=256/ne;for(let i=0;i<e;i++){let r=V.UNIFORM|V.COPY_DST;i===0&&(r|=V.COPY_SRC),this._buffers.push(new kt({data:this._batchBuffer.data,usage:r}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){for(const t in this._bindGroupHash)this._bindGroupHash[t]=null;this._batchBuffer.clear()}getUniformBindGroup(t,e){if(!e&&this._bindGroupHash[t.uid])return this._bindGroupHash[t.uid];this._renderer.ubo.ensureUniformGroup(t);const i=t.buffer.data,r=this._batchBuffer.addEmptyGroup(i.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,r/4),this._bindGroupHash[t.uid]=this._getBindGroup(r/ne),this._bindGroupHash[t.uid]}getUboResource(t){this._renderer.ubo.updateUniformGroup(t);const e=t.buffer.data,i=this._batchBuffer.addGroup(e);return this._getBufferResource(i/ne)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/ne)}getArrayBufferResource(t){const i=this._batchBuffer.addGroup(t)/ne;return this._getBufferResource(i)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new Kr({buffer:e,offset:(t/2|0)*256,size:ne})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new Yt({0:this._getBufferResource(t)});this._bindGroups[t]=e}return this._bindGroups[t]}_uploadBindGroups(){const t=this._renderer.buffer,e=this._buffers[0];e.update(this._batchBuffer.byteIndex),t.updateBuffer(e);const i=this._renderer.gpu.device.createCommandEncoder();for(let r=1;r<this._buffers.length;r++){const n=this._buffers[r];i.copyBufferToBuffer(t.getGPUBuffer(e),ne,t.getGPUBuffer(n),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([i.finish()])}destroy(){for(let t=0;t<this._bindGroups.length;t++)this._bindGroups[t].destroy();this._bindGroups=null,this._bindGroupHash=null;for(let t=0;t<this._buffers.length;t++)this._buffers[t].destroy();this._buffers=null;for(let t=0;t<this._bufferResources.length;t++)this._bufferResources[t].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._bindGroupHash=null,this._renderer=null}}oc.extension={type:[b.WebGPUPipes],name:"uniformBatch"};const lg={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function ug(s,t,e,i,r){return s<<24|t<<16|e<<10|i<<5|r}function dg(s,t,e,i){return e<<6|s<<3|i<<1|t}class hc{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(ht.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){this._multisampleCount=t.msaaSamples,this._depthStencilAttachment=t.descriptor.depthStencilAttachment?1:0,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=ge[t],this._updatePipeHash())}setPipeline(t,e,i,r){const n=this.getPipeline(t,e,i);r.setPipeline(n)}getPipeline(t,e,i,r){t._layoutKey||(rh(t,e.attributeData),this._generateBufferKey(t)),r=r||t.topology;const n=ug(t._layoutKey,e._layoutKey,i.data,i._blendModeId,lg[r]);return this._pipeCache[n]?this._pipeCache[n]:(this._pipeCache[n]=this._createPipeline(t,e,i,r),this._pipeCache[n])}_createPipeline(t,e,i,r){const n=this._gpu.device,a=this._createVertexBufferLayouts(t),o=this._renderer.state.getColorTargets(i);o[0].writeMask=this._stencilMode===ht.RENDERING_MASK_ADD?0:this._colorMask;const h=this._renderer.shader.getProgramData(e).pipeline,c={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:a},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:o},primitive:{topology:r,cullMode:i.cullMode},layout:h,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(c.depthStencil={...this._stencilState,format:"depth24plus-stencil8",depthWriteEnabled:i.depthTest,depthCompare:i.depthTest?"less":"always"}),n.createRenderPipeline(c)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){const e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){const e=[];let i=0;const r=Object.keys(t.attributes).sort();for(let a=0;a<r.length;a++){const o=t.attributes[r[a]];e[i++]=o.location,e[i++]=o.offset,e[i++]=o.format,e[i++]=o.stride}const n=e.join("");return t._layoutKey=Ds(n,"geometry"),t._layoutKey}_createVertexBufferLayouts(t){if(this._bufferLayoutsCache[t._layoutKey])return this._bufferLayoutsCache[t._layoutKey];const e=[];return t.buffers.forEach(i=>{const r={arrayStride:0,stepMode:"vertex",attributes:[]},n=r.attributes;for(const a in t.attributes){const o=t.attributes[a];o.buffer===i&&(r.arrayStride=o.stride,r.stepMode=o.instance?"instance":"vertex",n.push({shaderLocation:o.location,offset:o.offset,format:o.format}))}n.length&&e.push(r)}),this._bufferLayoutsCache[t._layoutKey]=e,e}_updatePipeHash(){const t=dg(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment);this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}hc.extension={type:[b.WebGPUSystem],name:"pipeline"};class fg{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class pg{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,r,n){const a=this._renderer,o=this._getGpuColorTexture(t),h=a.texture.getGpuSource(e.source);return a.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:i},{texture:h,origin:n},r),e}startRenderPass(t,e=!0,i,r){const a=this._renderTargetSystem.getGpuRenderTarget(t),o=this.getDescriptor(t,e,i);a.descriptor=o,this._renderer.pipeline.setRenderTarget(a),this._renderer.encoder.beginRenderPass(a),this._renderer.encoder.setViewport(r)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,i){typeof e=="boolean"&&(e=e?yt.ALL:yt.NONE);const r=this._renderTargetSystem,n=r.getGpuRenderTarget(t),a=t.colorTextures.map((c,l)=>{const u=n.contexts[l];let d,f;u?d=u.getCurrentTexture().createView():d=this._renderer.texture.getGpuSource(c).createView({mipLevelCount:1}),n.msaaTextures[l]&&(f=d,d=this._renderer.texture.getTextureView(n.msaaTextures[l]));const p=e&yt.COLOR?"clear":"load";return i??(i=r.defaultClearColor),{view:d,resolveTarget:f,clearValue:i,storeOp:"store",loadOp:p}});let o;if((t.stencil||t.depth)&&!t.depthStencilTexture&&(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=n.msaa?4:1),t.depthStencilTexture){const c=e&yt.STENCIL?"clear":"load",l=e&yt.DEPTH?"clear":"load";o={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView(),stencilStoreOp:"store",stencilLoadOp:c,depthClearValue:1,depthLoadOp:l,depthStoreOp:"store"}}return{colorAttachments:a,depthStencilAttachment:o}}clear(t,e=!0,i,r){if(!e)return;const{gpu:n,encoder:a}=this._renderer,o=n.device;if(a.commandEncoder===null){const c=o.createCommandEncoder(),l=this.getDescriptor(t,e,i),u=c.beginRenderPass(l);u.setViewport(r.x,r.y,r.width,r.height,0,1),u.end();const d=c.finish();o.queue.submit([d])}else this.startRenderPass(t,e,i,r)}initGpuRenderTarget(t){t.isRoot=!0;const e=new fg;return t.colorTextures.forEach((i,r)=>{if(Pe.test(i.resource)){const n=i.resource.getContext("webgpu"),a=i.transparent?"premultiplied":"opaque";try{n.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:a})}catch(o){console.error(o)}e.contexts[r]=n}if(e.msaa=i.source.antialias,i.source.antialias){const n=new ut({width:0,height:0,sampleCount:4});e.msaaTextures[r]=n}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(e=>{e.unconfigure()}),t.msaaTextures.forEach(e=>{e.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((i,r)=>{const n=e.msaaTextures[r];n==null||n.resize(i.source.width,i.source.height,i.source._resolution)})}}class cc extends xh{constructor(t){super(t),this.adaptor=new pg,this.adaptor.init(t,this)}}cc.extension={type:[b.WebGPUSystem],name:"renderTarget"};class lc{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,i=t.gpuLayout.map(n=>e.createBindGroupLayout({entries:n})),r={bindGroupLayouts:i};return this._gpuProgramData[t._layoutKey]={bindGroups:i,pipeline:e.createPipelineLayout(r)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}lc.extension={type:[b.WebGPUSystem],name:"shader"};const Ct={};Ct.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},Ct.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},Ct.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},Ct.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Ct.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Ct.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},Ct["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},Ct["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},Ct["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},Ct.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}};class uc{constructor(){this.defaultState=new Kt,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:Ct[t.blendMode]||Ct.normal}]}destroy(){this.gpu=null}}uc.extension={type:[b.WebGPUSystem],name:"state"};const mg={type:"image",upload(s,t,e){const i=s.resource,r=(s.pixelWidth|0)*(s.pixelHeight|0),n=i.byteLength/r;e.device.queue.writeTexture({texture:t},i,{offset:0,rowsPerImage:s.pixelHeight,bytesPerRow:s.pixelHeight*n},{width:s.pixelWidth,height:s.pixelHeight,depthOrArrayLayers:1})}},dc={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},gg={blockBytes:4,blockWidth:1,blockHeight:1},_g={type:"compressed",upload(s,t,e){let i=s.pixelWidth,r=s.pixelHeight;const n=dc[s.format]||gg;for(let a=0;a<s.resource.length;a++){const o=s.resource[a],h=Math.ceil(i/n.blockWidth)*n.blockBytes;e.device.queue.writeTexture({texture:t,mipLevel:a},o,{offset:0,bytesPerRow:h},{width:Math.ceil(i/n.blockWidth)*n.blockWidth,height:Math.ceil(r/n.blockHeight)*n.blockHeight,depthOrArrayLayers:1}),i=Math.max(i>>1,1),r=Math.max(r>>1,1)}}},fc={type:"image",upload(s,t,e){const i=s.resource;if(!i)return;const r=Math.min(t.width,s.resourceWidth||s.pixelWidth),n=Math.min(t.height,s.resourceHeight||s.pixelHeight),a=s.alphaMode==="premultiply-alpha-on-upload";e.device.queue.copyExternalImageToTexture({source:i},{texture:t,premultipliedAlpha:a},{width:r,height:n})}},xg={type:"video",upload(s,t,e){fc.upload(s,t,e)}};class yg{constructor(t){this.device=t,this.sampler=t.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(t){let e=this.pipelines[t];return e||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:`
|
|
800
|
+
var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
|
801
|
+
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
|
|
802
|
+
|
|
803
|
+
struct VertexOutput {
|
|
804
|
+
@builtin(position) position : vec4<f32>,
|
|
805
|
+
@location(0) texCoord : vec2<f32>,
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
@vertex
|
|
809
|
+
fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
|
|
810
|
+
var output : VertexOutput;
|
|
811
|
+
output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
|
|
812
|
+
output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
|
|
813
|
+
return output;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
@group(0) @binding(0) var imgSampler : sampler;
|
|
817
|
+
@group(0) @binding(1) var img : texture_2d<f32>;
|
|
818
|
+
|
|
819
|
+
@fragment
|
|
820
|
+
fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
|
821
|
+
return textureSample(img, imgSampler, texCoord);
|
|
822
|
+
}
|
|
823
|
+
`})),e=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:t}]}}),this.pipelines[t]=e),e}generateMipmap(t){const e=this._getMipmapPipeline(t.format);if(t.dimension==="3d"||t.dimension==="1d")throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let i=t;const r=t.depthOrArrayLayers||1,n=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){const h={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:r},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};i=this.device.createTexture(h)}const a=this.device.createCommandEncoder({}),o=e.getBindGroupLayout(0);for(let h=0;h<r;++h){let c=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:h,arrayLayerCount:1}),l=n?1:0;for(let u=1;u<t.mipLevelCount;++u){const d=i.createView({baseMipLevel:l++,mipLevelCount:1,dimension:"2d",baseArrayLayer:h,arrayLayerCount:1}),f=a.beginRenderPass({colorAttachments:[{view:d,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),p=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.sampler},{binding:1,resource:c}]});f.setPipeline(e),f.setBindGroup(0,p),f.draw(3,1,0,0),f.end(),c=d}}if(!n){const h={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:r};for(let c=1;c<t.mipLevelCount;++c)a.copyTextureToTexture({texture:i,mipLevel:c-1},{texture:t,mipLevel:c},h),h.width=Math.ceil(h.width/2),h.height=Math.ceil(h.height/2)}return this.device.queue.submit([a.finish()]),n||i.destroy(),t}}class pc{constructor(t){this.managedTextures=[],this._gpuSources=Object.create(null),this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._textureViewHash=Object.create(null),this._uploads={image:fc,buffer:mg,video:xg,compressed:_g},this._renderer=t}contextChange(t){this._gpu=t}initSource(t){if(t.autoGenerateMipmaps){const h=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(h))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;t.uploadMethodId!=="compressed"&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);const i=dc[t.format]||{blockBytes:4,blockWidth:1,blockHeight:1},r=Math.ceil(t.pixelWidth/i.blockWidth)*i.blockWidth,n=Math.ceil(t.pixelHeight/i.blockHeight)*i.blockHeight,a={label:t.label,size:{width:r,height:n},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},o=this._gpu.device.createTexture(a);return this._gpuSources[t.uid]=o,this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),o}onSourceUpdate(t){const e=this.getGpuSource(t);e&&(this._uploads[t.uploadMethodId]&&this._uploads[t.uploadMethodId].upload(t,e,this._gpu),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t))}onSourceUnload(t){const e=this._gpuSources[t.uid];e&&(this._gpuSources[t.uid]=null,e.destroy())}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new yg(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceDestroy(t){t.off("update",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("destroy",this.onSourceDestroy,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}onSourceResize(t){const e=this._gpuSources[t.uid];e?(e.width!==t.pixelWidth||e.height!==t.pixelHeight)&&(this._textureViewHash[t.uid]=null,this._bindGroupHash[t.uid]=null,this.onSourceUnload(t),this.initSource(t)):this.initSource(t)}_initSampler(t){return this._gpuSamplers[t._resourceId]=this._gpu.device.createSampler(t),this._gpuSamplers[t._resourceId]}getGpuSampler(t){return this._gpuSamplers[t._resourceId]||this._initSampler(t)}getGpuSource(t){return this._gpuSources[t.uid]||this.initSource(t)}getTextureBindGroup(t){return this._bindGroupHash[t.uid]??this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source,i=e.uid;return this._bindGroupHash[i]=new Yt({0:e,1:e.style}),this._bindGroupHash[i]}getTextureView(t){const e=t.source;return this._textureViewHash[e.uid]??this._createTextureView(e)}_createTextureView(t){return this._textureViewHash[t.uid]=this.getGpuSource(t).createView(),this._textureViewHash[t.uid]}generateCanvas(t){const e=this._renderer,i=e.gpu.device.createCommandEncoder(),r=L.get().createCanvas();r.width=t.source.pixelWidth,r.height=t.source.pixelHeight;const n=r.getContext("webgpu");return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:navigator.gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),i.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:r.width,height:r.height}),e.gpu.device.queue.submit([i.finish()]),r}getPixels(t){const e=this.generateCanvas(t),i=qt.getOptimalCanvasAndContext(e.width,e.height),r=i.context;r.drawImage(e,0,0);const{width:n,height:a}=e,o=r.getImageData(0,0,n,a),h=new Uint8ClampedArray(o.data.buffer);return qt.returnCanvasAndContext(i),{pixels:h,width:n,height:a}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null;for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),i=this._bindGroupHash[e];i==null||i.destroy(),this._bindGroupHash[e]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}pc.extension={type:[b.WebGPUSystem],name:"texture"};class mc{init(){const t=new xt({uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),e=as({name:"graphics",bits:[Dr,Hr(Ht()),Wp,hs]});this.shader=new At({gpuProgram:e,resources:{localUniforms:t}})}execute(t,e){const i=e.context,r=i.customShader||this.shader,n=t.renderer,a=n.graphicsContext,{geometry:o,instructions:h}=a.getContextRenderData(i),c=n.encoder;c.setPipelineFromGeometryProgramAndState(o,r.gpuProgram,t.state),c.setGeometry(o);const l=n.globalUniforms.bindGroup;c.setBindGroup(0,l,r.gpuProgram);const u=n.renderPipes.uniformBatch.getUniformBindGroup(r.resources.localUniforms,!0);c.setBindGroup(2,u,r.gpuProgram);const d=h.instructions;for(let f=0;f<h.instructionSize;f++){const p=d[f];if(r.groups[1]=p.bindGroup,!p.gpuBindGroup){const g=p.textures;p.bindGroup=dr(g.textures,g.count),p.gpuBindGroup=n.bindGroup.getBindGroup(p.bindGroup,r.gpuProgram,1)}c.setBindGroup(1,p.bindGroup,r.gpuProgram),c.renderPassEncoder.drawIndexed(p.size,1,p.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}mc.extension={type:[b.WebGPUPipesAdaptor],name:"graphics"};class gc{init(){const t=as({name:"mesh",bits:[ls,Vp,hs]});this._shader=new At({gpuProgram:t,resources:{uTexture:M.EMPTY._source,uSampler:M.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new I}}}})}execute(t,e){const i=t.renderer;let r=e._shader;if(!r)r=this._shader,r.resources.uTexture=e.texture.source,r.resources.uSampler=e.texture.source.style,r.resources.textureUniforms.uniforms.uTextureMatrix=e.texture.textureMatrix.mapCoord;else if(!r.gpuProgram){D("Mesh shader has no gpuProgram",e.shader);return}const n=r.gpuProgram;if(n.autoAssignGlobalUniforms&&(r.groups[0]=i.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const a=t.localUniforms;r.groups[1]=i.renderPipes.uniformBatch.getUniformBindGroup(a,!0)}i.encoder.draw({geometry:e._geometry,shader:r,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}gc.extension={type:[b.WebGPUPipesAdaptor],name:"mesh"};const bg=[...qh,ac,rc,on,sc,pc,cc,lc,uc,hc,ic,nc,ec],vg=[...Zh,oc],Sg=[Zo,gc,mc],_c=[],xc=[],yc=[];O.handleByNamedList(b.WebGPUSystem,_c),O.handleByNamedList(b.WebGPUPipes,xc),O.handleByNamedList(b.WebGPUPipesAdaptor,yc),O.add(...bg,...vg,...Sg);class wg extends Ws{constructor(){const t={name:"webgpu",type:Lt.WEBGPU,systems:_c,renderPipes:xc,renderPipeAdaptors:yc};super(t)}}const Tg=Object.freeze(Object.defineProperty({__proto__:null,WebGPURenderer:wg},Symbol.toStringTag,{value:"Module"}));class bc{constructor(t,e){this.state=Kt.for2d(),this._graphicsBatchesHash=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=t.context,i=!!this._graphicsBatchesHash[t.uid],r=this.renderer.graphicsContext.updateGpuContext(e);return!!(r.isBatchable||i!==r.isBatchable)}addRenderable(t,e){const i=this.renderer.graphicsContext.updateGpuContext(t.context);t._didGraphicsUpdate&&(t._didGraphicsUpdate=!1,this._rebuild(t)),i.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._graphicsBatchesHash[t.uid];if(e)for(let i=0;i<e.length;i++){const r=e[i];r.batcher.updateElement(r)}}destroyRenderable(t){this._graphicsBatchesHash[t.uid]&&this._removeBatchForRenderable(t.uid)}execute(t){if(!t.isRenderable)return;const e=this.renderer,i=t.context;if(!e.graphicsContext.getGpuContext(i).batches.length)return;const n=i.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const a=n.resources.localUniforms.uniforms;a.uTransformMatrix=t.groupTransform,a.uRound=e._roundPixels|t._roundPixels,ni(t.groupColorAlpha,a.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=!!this._graphicsBatchesHash[t.uid],i=this.renderer.graphicsContext.updateGpuContext(t.context);e&&this._removeBatchForRenderable(t.uid),i.isBatchable&&this._initBatchesForRenderable(t),t.batched=i.isBatchable}_addToBatcher(t,e){const i=this.renderer.renderPipes.batch,r=this._getBatchesForRenderable(t);for(let n=0;n<r.length;n++){const a=r[n];i.addToBatch(a,e)}}_getBatchesForRenderable(t){return this._graphicsBatchesHash[t.uid]||this._initBatchesForRenderable(t)}_initBatchesForRenderable(t){const e=t.context,i=this.renderer.graphicsContext.getGpuContext(e),r=this.renderer._roundPixels|t._roundPixels,n=i.batches.map(a=>{const o=$.get(mr);return a.copyTo(o),o.renderable=t,o.roundPixels=r,o});return this._graphicsBatchesHash[t.uid]===void 0&&t.on("destroyed",()=>{this.destroyRenderable(t)}),this._graphicsBatchesHash[t.uid]=n,n}_removeBatchForRenderable(t){this._graphicsBatchesHash[t].forEach(e=>{$.return(e)}),this._graphicsBatchesHash[t]=null}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null;for(const t in this._graphicsBatchesHash)this._removeBatchForRenderable(t);this._graphicsBatchesHash=null}}bc.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"graphics"};const vc=class Cl extends Rr{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(N(W,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),e={width:e,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(e)}build(t){t={...Cl.defaultOptions,...t},this.verticesX=this.verticesX??t.verticesX,this.verticesY=this.verticesY??t.verticesY,this.width=this.width??t.width,this.height=this.height??t.height;const e=this.verticesX*this.verticesY,i=[],r=[],n=[],a=this.verticesX-1,o=this.verticesY-1,h=this.width/a,c=this.height/o;for(let u=0;u<e;u++){const d=u%this.verticesX,f=u/this.verticesX|0;i.push(d*h,f*c),r.push(d/a,f/o)}const l=a*o;for(let u=0;u<l;u++){const d=u%a,f=u/a|0,p=f*this.verticesX+d,g=f*this.verticesX+d+1,m=(f+1)*this.verticesX+d,_=(f+1)*this.verticesX+d+1;n.push(p,g,m,g,_,m)}this.buffers[0].data=new Float32Array(i),this.buffers[1].data=new Float32Array(r),this.indexBuffer.data=new Uint32Array(n),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};vc.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let Ag=vc;class hn{constructor(){this.batcher=null,this.batch=null,this.roundPixels=0,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get blendMode(){return this.mesh.groupBlendMode}reset(){this.mesh=null,this.texture=null,this.batcher=null,this.batch=null}packIndex(t,e,i){const r=this.geometry.indices;for(let n=0;n<r.length;n++)t[e++]=r[n]+i}packAttributes(t,e,i,r){const n=this.mesh,a=this.geometry,o=n.groupTransform,h=r<<16|this.roundPixels&65535,c=o.a,l=o.b,u=o.c,d=o.d,f=o.tx,p=o.ty,g=a.positions,m=a.getBuffer("aUV"),_=m.data;let x=_;const y=this.texture.textureMatrix;y.isSimple||(x=this._transformedUvs,(this._textureMatrixUpdateId!==y._updateID||this._uvUpdateId!==m._updateID)&&((!x||x.length<_.length)&&(x=this._transformedUvs=new Float32Array(_.length)),this._textureMatrixUpdateId=y._updateID,this._uvUpdateId=m._updateID,y.multiplyUvs(_,x)));const v=n.groupColorAlpha;for(let w=0;w<g.length;w+=2){const E=g[w],C=g[w+1];t[i]=c*E+u*C+f,t[i+1]=l*E+d*C+p,t[i+2]=x[w],t[i+3]=x[w+1],e[i+4]=v,e[i+5]=h,i+=6}}get vertexSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}class Sc{constructor(t,e){this.localUniforms=new xt({uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Yt({0:this.localUniforms}),this._meshDataHash=Object.create(null),this._gpuBatchableMeshHash=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),i=e.batched,r=t.batched;if(e.batched=r,i!==r)return!0;if(r){const n=t._geometry;if(n.indices.length!==e.indexSize||n.positions.length!==e.vertexSize)return e.indexSize=n.indices.length,e.vertexSize=n.positions.length,!0;const a=this._getBatchableMesh(t),o=t.texture;if(a.texture._source!==o._source&&a.texture._source!==o._source)return!a.batcher.checkAndUpdateTexture(a,o)}return!1}addRenderable(t,e){const i=this.renderer.renderPipes.batch,{batched:r}=this._getMeshData(t);if(r){const n=this._getBatchableMesh(t);n.texture=t._texture,n.geometry=t._geometry,i.addToBatch(n)}else i.break(e),e.add({renderPipeId:"mesh",mesh:t})}updateRenderable(t){if(t.batched){const e=this._gpuBatchableMeshHash[t.uid];e.texture=t._texture,e.geometry=t._geometry,e.batcher.updateElement(e)}}destroyRenderable(t){this._meshDataHash[t.uid]=null;const e=this._gpuBatchableMeshHash[t.uid];e&&($.return(e),this._gpuBatchableMeshHash[t.uid]=null)}execute({mesh:t}){if(!t.isRenderable)return;t.state.blendMode=t.groupBlendMode;const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),ni(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){return this._meshDataHash[t.uid]||this._initMeshData(t)}_initMeshData(t){var e,i;return this._meshDataHash[t.uid]={batched:t.batched,indexSize:(e=t._geometry.indices)==null?void 0:e.length,vertexSize:(i=t._geometry.positions)==null?void 0:i.length},t.on("destroyed",()=>{this.destroyRenderable(t)}),this._meshDataHash[t.uid]}_getBatchableMesh(t){return this._gpuBatchableMeshHash[t.uid]||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=$.get(hn);return e.mesh=t,e.texture=t._texture,e.roundPixels=this.renderer._roundPixels|t._roundPixels,this._gpuBatchableMeshHash[t.uid]=e,e.mesh=t,e}destroy(){for(const t in this._gpuBatchableMeshHash)this._gpuBatchableMeshHash[t]&&$.return(this._gpuBatchableMeshHash[t]);this._gpuBatchableMeshHash=null,this._meshDataHash=null,this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}Sc.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"mesh"};const wc=class El extends Ag{constructor(t={}){t={...El.defaultOptions,...t},super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(t){this.width=t.width??this.width,this.height=t.height??this.height,this._originalWidth=t.originalWidth??this._originalWidth,this._originalHeight=t.originalHeight??this._originalHeight,this._leftWidth=t.leftWidth??this._leftWidth,this._rightWidth=t.rightWidth??this._rightWidth,this._topHeight=t.topHeight??this._topHeight,this._bottomHeight=t.bottomHeight??this._bottomHeight,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,e=this._leftWidth+this._rightWidth,i=this.width>e?1:this.width/e,r=this._topHeight+this._bottomHeight,n=this.height>r?1:this.height/r,a=Math.min(i,n);t[9]=t[11]=t[13]=t[15]=this._topHeight*a,t[17]=t[19]=t[21]=t[23]=this.height-this._bottomHeight*a,t[25]=t[27]=t[29]=t[31]=this.height,t[2]=t[10]=t[18]=t[26]=this._leftWidth*a,t[4]=t[12]=t[20]=t[28]=this.width-this._rightWidth*a,t[6]=t[14]=t[22]=t[30]=this.width,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,i=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.getBuffer("aUV").update()}};wc.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let Pg=wc;class Tc{constructor(t){this._gpuSpriteHash=Object.create(null),this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t._didSpriteUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i)}updateRenderable(t){const e=this._gpuSpriteHash[t.uid];t._didSpriteUpdate&&this._updateBatchableSprite(t,e),e.batcher.updateElement(e)}validateRenderable(t){const e=t._texture,i=this._getGpuSprite(t);return i.texture._source!==e._source?!i.batcher.checkAndUpdateTexture(i,e):!1}destroyRenderable(t){const e=this._gpuSpriteHash[t.uid];$.return(e),this._gpuSpriteHash[t.uid]=null}_updateBatchableSprite(t,e){t._didSpriteUpdate=!1,e.geometry.update(t),e.texture=t._texture}_getGpuSprite(t){return this._gpuSpriteHash[t.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=new hn;return e.geometry=new Pg,e.mesh=t,e.texture=t._texture,e.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuSpriteHash[t.uid]=e,t.on("destroyed",()=>{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuSpriteHash)this._gpuSpriteHash[t].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null}}Tc.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"nineSliceSprite"};const Cg={name:"tiling-bit",vertex:{header:`
|
|
824
|
+
struct TilingUniforms {
|
|
825
|
+
uMapCoord:mat3x3<f32>,
|
|
826
|
+
uClampFrame:vec4<f32>,
|
|
827
|
+
uClampOffset:vec2<f32>,
|
|
828
|
+
uTextureTransform:mat3x3<f32>,
|
|
829
|
+
uSizeAnchor:vec4<f32>
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
|
833
|
+
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
|
834
|
+
@group(2) @binding(2) var uSampler: sampler;
|
|
835
|
+
`,main:`
|
|
836
|
+
uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;
|
|
837
|
+
|
|
838
|
+
position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
|
|
839
|
+
`},fragment:{header:`
|
|
840
|
+
struct TilingUniforms {
|
|
841
|
+
uMapCoord:mat3x3<f32>,
|
|
842
|
+
uClampFrame:vec4<f32>,
|
|
843
|
+
uClampOffset:vec2<f32>,
|
|
844
|
+
uTextureTransform:mat3x3<f32>,
|
|
845
|
+
uSizeAnchor:vec4<f32>
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
|
849
|
+
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
|
850
|
+
@group(2) @binding(2) var uSampler: sampler;
|
|
851
|
+
`,main:`
|
|
852
|
+
|
|
853
|
+
var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
|
|
854
|
+
coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
|
|
855
|
+
var unclamped = coord;
|
|
856
|
+
coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);
|
|
857
|
+
|
|
858
|
+
var bias = 0.;
|
|
859
|
+
|
|
860
|
+
if(unclamped.x == coord.x && unclamped.y == coord.y)
|
|
861
|
+
{
|
|
862
|
+
bias = -32.;
|
|
863
|
+
}
|
|
1065
864
|
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
|
|
865
|
+
outColor = textureSampleBias(uTexture, uSampler, coord, bias);
|
|
866
|
+
`}},Eg={name:"tiling-bit",vertex:{header:`
|
|
867
|
+
uniform mat3 uTextureTransform;
|
|
868
|
+
uniform vec4 uSizeAnchor;
|
|
869
|
+
|
|
870
|
+
`,main:`
|
|
871
|
+
uv = (uTextureTransform * vec3(aUV, 1.0)).xy;
|
|
872
|
+
|
|
873
|
+
position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;
|
|
874
|
+
`},fragment:{header:`
|
|
875
|
+
uniform sampler2D uTexture;
|
|
876
|
+
uniform mat3 uMapCoord;
|
|
877
|
+
uniform vec4 uClampFrame;
|
|
878
|
+
uniform vec2 uClampOffset;
|
|
879
|
+
`,main:`
|
|
880
|
+
|
|
881
|
+
vec2 coord = vUV + ceil(uClampOffset - vUV);
|
|
882
|
+
coord = (uMapCoord * vec3(coord, 1.0)).xy;
|
|
883
|
+
vec2 unclamped = coord;
|
|
884
|
+
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
|
|
885
|
+
|
|
886
|
+
outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
|
|
887
|
+
|
|
888
|
+
`}};let cn,ln;class Mg extends At{constructor(){cn??(cn=as({name:"tiling-sprite-shader",bits:[ls,Cg,hs]})),ln??(ln=os({name:"tiling-sprite-shader",bits:[Vr,Eg,cs]}));const t=new xt({uMapCoord:{value:new I,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new I,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:ln,gpuProgram:cn,resources:{localUniforms:new xt({uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:M.EMPTY.source,uSampler:M.EMPTY.source.style}})}updateUniforms(t,e,i,r,n,a){const o=this.resources.tilingUniforms,h=a.width,c=a.height,l=a.textureMatrix,u=o.uniforms.uTextureTransform;u.set(i.a*h/t,i.b*h/e,i.c*c/t,i.d*c/e,i.tx/t,i.ty/e),u.invert(),o.uniforms.uMapCoord=l.mapCoord,o.uniforms.uClampFrame=l.uClampFrame,o.uniforms.uClampOffset=l.uClampOffset,o.uniforms.uTextureTransform=u,o.uniforms.uSizeAnchor[0]=t,o.uniforms.uSizeAnchor[1]=e,o.uniforms.uSizeAnchor[2]=r,o.uniforms.uSizeAnchor[3]=n,a&&(this.resources.uTexture=a.source,this.resources.uSampler=a.source.style)}}class Bg extends Rr{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}}function Rg(s,t){const e=s.anchor.x,i=s.anchor.y;t[0]=-e*s.width,t[1]=-i*s.height,t[2]=(1-e)*s.width,t[3]=-i*s.height,t[4]=(1-e)*s.width,t[5]=(1-i)*s.height,t[6]=-e*s.width,t[7]=(1-i)*s.height}function kg(s,t,e,i){let r=0;const n=s.length/t,a=i.a,o=i.b,h=i.c,c=i.d,l=i.tx,u=i.ty;for(e*=t;r<n;){const d=s[e],f=s[e+1];s[e]=a*d+h*f+l,s[e+1]=o*d+c*f+u,e+=t,r++}}function Ig(s,t){const e=s.texture,i=e.frame.width,r=e.frame.height;let n=0,a=0;s._applyAnchorToTexture&&(n=s.anchor.x,a=s.anchor.y),t[0]=t[6]=-n,t[2]=t[4]=1-n,t[1]=t[3]=-a,t[5]=t[7]=1-a;const o=I.shared;o.copyFrom(s._tileTransform.matrix),o.tx/=s.width,o.ty/=s.height,o.invert(),o.scale(s.width/i,s.height/r),kg(t,2,0,o)}const oi=new Bg;class Ac{constructor(t){this._tilingSpriteDataHash=Object.create(null),this._renderer=t}validateRenderable(t){const e=this._getTilingSpriteData(t),i=e.canBatch;this._updateCanBatch(t);const r=e.canBatch;if(r&&r===i){const{batchableMesh:n}=e;if(n.texture._source!==t.texture._source)return!n.batcher.checkAndUpdateTexture(n,t.texture)}return i!==r}addRenderable(t,e){const i=this._renderer.renderPipes.batch;this._updateCanBatch(t);const r=this._getTilingSpriteData(t),{geometry:n,canBatch:a}=r;if(a){r.batchableMesh||(r.batchableMesh=new hn);const o=r.batchableMesh;t._didTilingSpriteUpdate&&(t._didTilingSpriteUpdate=!1,this._updateBatchableMesh(t),o.geometry=n,o.mesh=t,o.texture=t._texture),o.roundPixels=this._renderer._roundPixels|t._roundPixels,i.addToBatch(o)}else i.break(e),r.shader||(r.shader=new Mg),this.updateRenderable(t),e.add(t)}execute(t){const{shader:e}=this._tilingSpriteDataHash[t.uid];e.groups[0]=this._renderer.globalUniforms.bindGroup;const i=e.resources.localUniforms.uniforms;i.uTransformMatrix=t.groupTransform,i.uRound=this._renderer._roundPixels|t._roundPixels,ni(t.groupColorAlpha,i.uColor,0),this._renderer.encoder.draw({geometry:oi,shader:e,state:Kt.default2d})}updateRenderable(t){const e=this._getTilingSpriteData(t),{canBatch:i}=e;if(i){const{batchableMesh:r}=e;t._didTilingSpriteUpdate&&this._updateBatchableMesh(t),r.batcher.updateElement(r)}else if(t._didTilingSpriteUpdate){const{shader:r}=e;r.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture)}t._didTilingSpriteUpdate=!1}destroyRenderable(t){var i;const e=this._getTilingSpriteData(t);e.batchableMesh=null,(i=e.shader)==null||i.destroy(),this._tilingSpriteDataHash[t.uid]=null}_getTilingSpriteData(t){return this._tilingSpriteDataHash[t.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){const e=new Rr({indices:oi.indices,positions:oi.positions.slice(),uvs:oi.uvs.slice()});return this._tilingSpriteDataHash[t.uid]={canBatch:!0,renderable:t,geometry:e},t.on("destroyed",()=>{this.destroyRenderable(t)}),this._tilingSpriteDataHash[t.uid]}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:i}=e,r=t.texture.source.style;r.addressMode!=="repeat"&&(r.addressMode="repeat",r.update()),Ig(t,i.uvs),Rg(t,i.positions)}destroy(){for(const t in this._tilingSpriteDataHash)this.destroyRenderable(this._tilingSpriteDataHash[t].renderable);this._tilingSpriteDataHash=null,this._renderer=null}_updateCanBatch(t){const e=this._getTilingSpriteData(t),i=t.texture;let r=!0;return this._renderer.type===Lt.WEBGL&&(r=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=i.textureMatrix.isSimple&&(r||i.source.isPowerOfTwo),e.canBatch}}Ac.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"tilingSprite"};const un={test(s){return typeof s=="string"&&s.startsWith("info face=")},parse(s){const t=s.match(/^[a-z]+\s+.+$/gm),e={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const u in t){const d=t[u].match(/^[a-z]+/gm)[0],f=t[u].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),p={};for(const g in f){const m=f[g].split("="),_=m[0],x=m[1].replace(/"/gm,""),y=parseFloat(x),v=isNaN(y)?x:y;p[_]=v}e[d].push(p)}const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[r]=e.info,[n]=e.common,[a]=e.distanceField??[];a&&(i.distanceField={range:parseInt(a.distanceRange,10),type:a.fieldType}),i.fontSize=parseInt(r.size,10),i.fontFamily=r.face,i.lineHeight=parseInt(n.lineHeight,10);const o=e.page;for(let u=0;u<o.length;u++)i.pages.push({id:parseInt(o[u].id,10)||0,file:o[u].file});const h={};i.baseLineOffset=i.lineHeight-parseInt(n.base,10);const c=e.char;for(let u=0;u<c.length;u++){const d=c[u],f=parseInt(d.id,10);let p=d.letter??d.char??String.fromCharCode(f);p==="space"&&(p=" "),h[f]=p,i.chars[p]={id:f,page:parseInt(d.page,10)||0,x:parseInt(d.x,10),y:parseInt(d.y,10),width:parseInt(d.width,10),height:parseInt(d.height,10),xOffset:parseInt(d.xoffset,10),yOffset:parseInt(d.yoffset,10),xAdvance:parseInt(d.xadvance,10),kerning:{}}}const l=e.kerning||[];for(let u=0;u<l.length;u++){const d=parseInt(l[u].first,10),f=parseInt(l[u].second,10),p=parseInt(l[u].amount,10);i.chars[h[f]].kerning[h[d]]=p}return i}},Pc={test(s){const t=s;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(s){const t={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},e=s.getElementsByTagName("info")[0],i=s.getElementsByTagName("common")[0],r=s.getElementsByTagName("distanceField")[0];r&&(t.distanceField={type:r.getAttribute("fieldType"),range:parseInt(r.getAttribute("distanceRange"),10)});const n=s.getElementsByTagName("page"),a=s.getElementsByTagName("char"),o=s.getElementsByTagName("kerning");t.fontSize=parseInt(e.getAttribute("size"),10),t.fontFamily=e.getAttribute("face"),t.lineHeight=parseInt(i.getAttribute("lineHeight"),10);for(let c=0;c<n.length;c++)t.pages.push({id:parseInt(n[c].getAttribute("id"),10)||0,file:n[c].getAttribute("file")});const h={};t.baseLineOffset=t.lineHeight-parseInt(i.getAttribute("base"),10);for(let c=0;c<a.length;c++){const l=a[c],u=parseInt(l.getAttribute("id"),10);let d=l.getAttribute("letter")??l.getAttribute("char")??String.fromCharCode(u);d==="space"&&(d=" "),h[u]=d,t.chars[d]={id:u,page:parseInt(l.getAttribute("page"),10)||0,x:parseInt(l.getAttribute("x"),10),y:parseInt(l.getAttribute("y"),10),width:parseInt(l.getAttribute("width"),10),height:parseInt(l.getAttribute("height"),10),xOffset:parseInt(l.getAttribute("xoffset"),10),yOffset:parseInt(l.getAttribute("yoffset"),10),xAdvance:parseInt(l.getAttribute("xadvance"),10),kerning:{}}}for(let c=0;c<o.length;c++){const l=parseInt(o[c].getAttribute("first"),10),u=parseInt(o[c].getAttribute("second"),10),d=parseInt(o[c].getAttribute("amount"),10);t.chars[h[u]].kerning[h[l]]=d}return t}},Cc={test(s){return typeof s=="string"&&s.includes("<font>")?Pc.test(L.get().parseXML(s)):!1},parse(s){return Pc.parse(L.get().parseXML(s))}};class Ec extends Mo{constructor(t,e){super();const{textures:i,data:r}=t;Object.keys(r.pages).forEach(n=>{const a=r.pages[parseInt(n,10)],o=i[a.id];this.pages.push({texture:o})}),Object.keys(r.chars).forEach(n=>{const a=r.chars[n],{frame:o,source:h}=i[a.page],c=new Y(a.x+o.x,a.y+o.y,a.width,a.height),l=new M({source:h,frame:c});this.chars[n]={id:n.codePointAt(0),xOffset:a.xOffset,yOffset:a.yOffset,xAdvance:a.xAdvance,kerning:a.kerning??{},texture:l}}),this.baseRenderedFontSize=r.fontSize,this.baseMeasurementFontSize=r.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:r.fontSize},this.baseLineOffset=r.baseLineOffset,this.lineHeight=r.lineHeight,this.fontFamily=r.fontFamily,this.distanceField=r.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy(!0)}this.pages=null}static install(t){Fr.install(t)}static uninstall(t){Fr.uninstall(t)}}const Fg=[".xml",".fnt"],Gg={extension:b.CacheParser,test:s=>s instanceof Ec,getCacheableAssets(s,t){const e={};return s.forEach(i=>{e[i]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},Ug={extension:{type:b.LoadParser,priority:te.Normal},test(s){return Fg.includes(gt.extname(s).toLowerCase())},async testParse(s){return un.test(s)||Cc.test(s)},async parse(s,t,e){const i=un.test(s)?un.parse(s):Cc.parse(s),{src:r}=t,{pages:n}=i,a=[];for(let l=0;l<n.length;++l){const u=n[l].file;let d=gt.join(gt.dirname(r),u);d=Hi(d,r),a.push(d)}const o=await e.load(a),h=a.map(l=>o[l]);return new Ec({data:i,textures:h},r)},async load(s,t){return await(await L.get().fetch(s)).text()},async unload(s,t,e){await Promise.all(s.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),s.destroy()}},Dg={name:"local-uniform-msdf-bit",vertex:{header:`
|
|
889
|
+
struct LocalUniforms {
|
|
890
|
+
uColor:vec4<f32>,
|
|
891
|
+
uTransformMatrix:mat3x3<f32>,
|
|
892
|
+
uDistance: f32,
|
|
893
|
+
uRound:f32,
|
|
894
|
+
}
|
|
1070
895
|
|
|
1071
|
-
|
|
896
|
+
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
897
|
+
`,main:`
|
|
898
|
+
vColor *= localUniforms.uColor;
|
|
899
|
+
modelMatrix *= localUniforms.uTransformMatrix;
|
|
900
|
+
`,end:`
|
|
901
|
+
if(localUniforms.uRound == 1)
|
|
902
|
+
{
|
|
903
|
+
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
904
|
+
}
|
|
905
|
+
`},fragment:{header:`
|
|
906
|
+
struct LocalUniforms {
|
|
907
|
+
uColor:vec4<f32>,
|
|
908
|
+
uTransformMatrix:mat3x3<f32>,
|
|
909
|
+
uDistance: f32
|
|
910
|
+
}
|
|
1072
911
|
|
|
1073
|
-
|
|
912
|
+
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
913
|
+
`,main:`
|
|
914
|
+
outColor = vColor * calculateMSDFAlpha(outColor, localUniforms.uDistance);
|
|
915
|
+
`}},Og={name:"local-uniform-msdf-bit",vertex:{header:`
|
|
916
|
+
uniform mat3 uTransformMatrix;
|
|
917
|
+
uniform vec4 uColor;
|
|
918
|
+
uniform float uRound;
|
|
919
|
+
`,main:`
|
|
920
|
+
vColor *= uColor;
|
|
921
|
+
modelMatrix *= uTransformMatrix;
|
|
922
|
+
`,end:`
|
|
923
|
+
if(uRound == 1.)
|
|
924
|
+
{
|
|
925
|
+
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
926
|
+
}
|
|
927
|
+
`},fragment:{header:`
|
|
928
|
+
uniform float uDistance;
|
|
929
|
+
`,main:`
|
|
930
|
+
outColor = vColor * calculateMSDFAlpha(outColor, uDistance);
|
|
931
|
+
`}},Lg={name:"msdf-bit",fragment:{header:`
|
|
932
|
+
fn calculateMSDFAlpha(msdfColor:vec4<f32>, distance:f32) -> f32 {
|
|
933
|
+
|
|
934
|
+
// MSDF
|
|
935
|
+
var median = msdfColor.r + msdfColor.g + msdfColor.b -
|
|
936
|
+
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
|
|
937
|
+
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
|
|
938
|
+
|
|
939
|
+
// SDF
|
|
940
|
+
median = min(median, msdfColor.a);
|
|
941
|
+
|
|
942
|
+
var screenPxDistance = distance * (median - 0.5);
|
|
943
|
+
var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
|
944
|
+
if (median < 0.01) {
|
|
945
|
+
alpha = 0.0;
|
|
946
|
+
} else if (median > 0.99) {
|
|
947
|
+
alpha = 1.0;
|
|
948
|
+
}
|
|
1074
949
|
|
|
1075
|
-
|
|
1076
|
-
|
|
950
|
+
return alpha;
|
|
951
|
+
}
|
|
952
|
+
`}},Hg={name:"msdf-bit",fragment:{header:`
|
|
953
|
+
float calculateMSDFAlpha(vec4 msdfColor, float distance) {
|
|
954
|
+
|
|
955
|
+
// MSDF
|
|
956
|
+
float median = msdfColor.r + msdfColor.g + msdfColor.b -
|
|
957
|
+
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
|
|
958
|
+
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
|
|
959
|
+
|
|
960
|
+
// SDF
|
|
961
|
+
median = min(median, msdfColor.a);
|
|
962
|
+
|
|
963
|
+
float screenPxDistance = distance * (median - 0.5);
|
|
964
|
+
float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
|
965
|
+
|
|
966
|
+
if (median < 0.01) {
|
|
967
|
+
alpha = 0.0;
|
|
968
|
+
} else if (median > 0.99) {
|
|
969
|
+
alpha = 1.0;
|
|
970
|
+
}
|
|
1077
971
|
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
}
|
|
1083
|
-
`;const ws=new rt;class sc extends qr{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new Gh,this.state=le.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=ce.from(rc,W0,e),this.shader=t.context.webGLVersion>1?ce.from(z0,X0,e):ce.from(rc,V0,e)}render(t){const e=this.renderer,r=this.quad;let s=r.vertices;s[0]=s[6]=t._width*-t.anchor.x,s[1]=s[3]=t._height*-t.anchor.y,s[2]=s[4]=t._width*(1-t.anchor.x),s[5]=s[7]=t._height*(1-t.anchor.y);const n=t.uvRespectAnchor?t.anchor.x:0,a=t.uvRespectAnchor?t.anchor.y:0;s=r.uvs,s[0]=s[6]=-n,s[1]=s[3]=-a,s[2]=s[4]=1-n,s[5]=s[7]=1-a,r.invalidate();const o=t._texture,h=o.baseTexture,l=h.alphaMode>0,c=t.tileTransform.localTransform,u=t.uvMatrix;let d=h.isPowerOfTwo&&o.frame.width===h.width&&o.frame.height===h.height;d&&(h._glTextures[e.CONTEXT_UID]?d=h.wrapMode!==Me.CLAMP:h.wrapMode===Me.CLAMP&&(h.wrapMode=Me.REPEAT));const f=d?this.simpleShader:this.shader,p=o.width,m=o.height,g=t._width,_=t._height;ws.set(c.a*p/g,c.b*p/_,c.c*m/g,c.d*m/_,c.tx/g,c.ty/_),ws.invert(),d?ws.prepend(u.mapCoord):(f.uniforms.uMapCoord=u.mapCoord.toArray(!0),f.uniforms.uClampFrame=u.uClampFrame,f.uniforms.uClampOffset=u.uClampOffset),f.uniforms.uTransform=ws.toArray(!0),f.uniforms.uColor=tt.shared.setValue(t.tint).premultiply(t.worldAlpha,l).toArray(f.uniforms.uColor),f.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),f.uniforms.uSampler=o,e.shader.bind(f),e.geometry.bind(r),this.state.blendMode=fh(t.blendMode,l),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}sc.extension={name:"tilingSprite",type:P.RendererPlugin},k.add(sc);const nc=class vr{constructor(t,e,r){this.linkedSheets=[],(t instanceof W||t instanceof L)&&(t={texture:t,data:e,resolutionFilename:r});const{texture:s,data:n,resolutionFilename:a=null,cachePrefix:o=""}=t;this.cachePrefix=o,this._texture=s instanceof L?s:null,this.baseTexture=s instanceof W?s:this._texture.baseTexture,this.textures={},this.animations={},this.data=n;const h=this.baseTexture.resource;this.resolution=this._updateResolution(a||(h?h.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(t=null){const{scale:e}=this.data.meta;let r=Te(t,null);return r===null&&(r=typeof e=="number"?e:parseFloat(e??"1")),r!==1&&this.baseTexture.setResolution(r),r}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=vr.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const r=vr.BATCH_SIZE;for(;e-t<r&&e<this._frameKeys.length;){const s=this._frameKeys[e],n=this._frames[s],a=n.frame;if(a){let o=null,h=null;const l=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,c=new Y(0,0,Math.floor(l.w)/this.resolution,Math.floor(l.h)/this.resolution);n.rotated?o=new Y(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):o=new Y(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(h=new Y(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[s]=new L(this.baseTexture,o,c,h,n.rotated?2:0,n.anchor,n.borders),L.addToCache(this.textures[s],this.cachePrefix+s.toString())}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let r=0;r<t[e].length;r++){const s=t[e][r];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*vr.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*vr.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const r in this.textures)this.textures[r].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};nc.BATCH_SIZE=1e3;let Sa=nc;const j0=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function ac(i,t,e){const r={};if(i.forEach(s=>{r[s]=t}),Object.keys(t.textures).forEach(s=>{r[`${t.cachePrefix}${s}`]=t.textures[s]}),!e){const s=xt.dirname(i[0]);t.linkedSheets.forEach((n,a)=>{Object.assign(r,ac([`${s}/${t.data.meta.related_multi_packs[a]}`],n,!0))})}return r}const Y0={extension:P.Asset,cache:{test:i=>i instanceof Sa,getCacheableAssets:(i,t)=>ac(i,t,!1)},resolver:{test:i=>{const t=i.split("?")[0].split("."),e=t.pop(),r=t.pop();return e==="json"&&j0.includes(r)},parse:i=>{var e;const t=i.split(".");return{resolution:parseFloat(((e=F.RETINA_PREFIX.exec(i))==null?void 0:e[1])??"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",extension:{type:P.LoadParser,priority:Yt.Normal},async testParse(i,t){return xt.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){var c,u;const{texture:r,imageFilename:s,cachePrefix:n}=(t==null?void 0:t.data)??{};let a=xt.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let o;if(r&&r.baseTexture)o=r;else{const d=la(a+(s??i.meta.image),t.src);o=(await e.load([d]))[d]}const h=new Sa({texture:o.baseTexture,data:i,resolutionFilename:t.src,cachePrefix:n});await h.parse();const l=(c=i==null?void 0:i.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(l)){const d=[];for(const p of l){if(typeof p!="string")continue;let m=a+p;(u=t.data)!=null&&u.ignoreMultiPack||(m=la(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);h.linkedSheets=f,f.forEach(p=>{p.linkedSheets=[h].concat(h.linkedSheets.filter(m=>m!==p))})}return h},unload(i){i.destroy(!0)}}};k.add(Y0);class Es{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class As{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),r={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const a=e[n].match(/^[a-z]+/gm)[0],o=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),h={};for(const l in o){const c=o[l].split("="),u=c[0],d=c[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;h[u]=p}r[a].push(h)}const s=new Es;return r.info.forEach(n=>s.info.push({face:n.face,size:parseInt(n.size,10)})),r.common.forEach(n=>s.common.push({lineHeight:parseInt(n.lineHeight,10)})),r.page.forEach(n=>s.page.push({id:parseInt(n.id,10),file:n.file})),r.char.forEach(n=>s.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),r.kerning.forEach(n=>s.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),r.distanceField.forEach(n=>s.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),s}}class Ca{static test(t){const e=t;return typeof t!="string"&&"getElementsByTagName"in t&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const e=new Es,r=t.getElementsByTagName("info"),s=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),a=t.getElementsByTagName("char"),o=t.getElementsByTagName("kerning"),h=t.getElementsByTagName("distanceField");for(let l=0;l<r.length;l++)e.info.push({face:r[l].getAttribute("face"),size:parseInt(r[l].getAttribute("size"),10)});for(let l=0;l<s.length;l++)e.common.push({lineHeight:parseInt(s[l].getAttribute("lineHeight"),10)});for(let l=0;l<n.length;l++)e.page.push({id:parseInt(n[l].getAttribute("id"),10)||0,file:n[l].getAttribute("file")});for(let l=0;l<a.length;l++){const c=a[l];e.char.push({id:parseInt(c.getAttribute("id"),10),page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xoffset:parseInt(c.getAttribute("xoffset"),10),yoffset:parseInt(c.getAttribute("yoffset"),10),xadvance:parseInt(c.getAttribute("xadvance"),10)})}for(let l=0;l<o.length;l++)e.kerning.push({first:parseInt(o[l].getAttribute("first"),10),second:parseInt(o[l].getAttribute("second"),10),amount:parseInt(o[l].getAttribute("amount"),10)});for(let l=0;l<h.length;l++)e.distanceField.push({fieldType:h[l].getAttribute("fieldType"),distanceRange:parseInt(h[l].getAttribute("distanceRange"),10)});return e}}class Ia{static test(t){return typeof t=="string"&&t.includes("<font>")?Ca.test(F.ADAPTER.parseXML(t)):!1}static parse(t){return Ca.parse(F.ADAPTER.parseXML(t))}}const Ra=[As,Ca,Ia];function q0(i){for(let t=0;t<Ra.length;t++)if(Ra[t].test(i))return Ra[t];return null}function K0(i,t,e,r,s,n){const a=e.fill;if(Array.isArray(a)){if(a.length===1)return a[0]}else return a;let o;const h=e.dropShadow?e.dropShadowDistance:0,l=e.padding||0,c=i.width/r-h-l*2,u=i.height/r-h-l*2,d=a.slice(),f=e.fillGradientStops.slice();if(!f.length){const p=d.length+1;for(let m=1;m<p;++m)f.push(m/p)}if(d.unshift(a[0]),f.unshift(0),d.push(a[a.length-1]),f.push(1),e.fillGradientType===vs.LINEAR_VERTICAL){o=t.createLinearGradient(c/2,l,c/2,u+l);let p=0;const m=(n.fontProperties.fontSize+e.strokeThickness)/u;for(let g=0;g<s.length;g++){const _=n.lineHeight*g;for(let x=0;x<d.length;x++){let y=0;typeof f[x]=="number"?y=f[x]:y=x/d.length;const v=_/u+y*m;let T=Math.max(p,v);T=Math.min(T,1),o.addColorStop(T,d[x]),p=T}}}else{o=t.createLinearGradient(l,u/2,c+l,u/2);const p=d.length+1;let m=1;for(let g=0;g<d.length;g++){let _;typeof f[g]=="number"?_=f[g]:_=m/p,o.addColorStop(_,d[g]),m++}}return o}function Z0(i,t,e,r,s,n,a){const o=e.text,h=e.fontProperties;t.translate(r,s),t.scale(n,n);const l=a.strokeThickness/2,c=-(a.strokeThickness/2);if(t.font=a.toFontString(),t.lineWidth=a.strokeThickness,t.textBaseline=a.textBaseline,t.lineJoin=a.lineJoin,t.miterLimit=a.miterLimit,t.fillStyle=K0(i,t,a,n,[o],e),t.strokeStyle=a.stroke,a.dropShadow){const u=a.dropShadowColor,d=a.dropShadowBlur*n,f=a.dropShadowDistance*n;t.shadowColor=tt.shared.setValue(u).setAlpha(a.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(a.dropShadowAngle)*f,t.shadowOffsetY=Math.sin(a.dropShadowAngle)*f}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;a.stroke&&a.strokeThickness&&t.strokeText(o,l,c+e.lineHeight-h.descent),a.fill&&t.fillText(o,l,c+e.lineHeight-h.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Ss(i){return i.codePointAt?i.codePointAt(0):i.charCodeAt(0)}function oc(i){return Array.from?Array.from(i):i.split("")}function J0(i){typeof i=="string"&&(i=[i]);const t=[];for(let e=0,r=i.length;e<r;e++){const s=i[e];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);const n=s[0].charCodeAt(0),a=s[1].charCodeAt(0);if(a<n)throw new Error("[BitmapFont]: Invalid character range.");for(let o=n,h=a;o<=h;o++)t.push(String.fromCharCode(o))}else t.push(...oc(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const $e=class ye{constructor(t,e,r){var c;const[s]=t.info,[n]=t.common,[a]=t.page,[o]=t.distanceField,h=Te(a.file),l={};this._ownsTextures=r,this.font=s.face,this.size=s.size,this.lineHeight=n.lineHeight/h,this.chars={},this.pageTextures=l;for(let u=0;u<t.page.length;u++){const{id:d,file:f}=t.page[u];l[d]=e instanceof Array?e[u]:e[f],o!=null&&o.fieldType&&o.fieldType!=="none"&&(l[d].baseTexture.alphaMode=Ot.NO_PREMULTIPLIED_ALPHA,l[d].baseTexture.mipmap=ee.OFF)}for(let u=0;u<t.char.length;u++){const{id:d,page:f}=t.char[u];let{x:p,y:m,width:g,height:_,xoffset:x,yoffset:y,xadvance:v}=t.char[u];p/=h,m/=h,g/=h,_/=h,x/=h,y/=h,v/=h;const T=new Y(p+l[f].frame.x/h,m+l[f].frame.y/h,g,_);this.chars[d]={xOffset:x,yOffset:y,xAdvance:v,kerning:{},texture:new L(l[f].baseTexture,T),page:f}}for(let u=0;u<t.kerning.length;u++){let{first:d,second:f,amount:p}=t.kerning[u];d/=h,f/=h,p/=h,this.chars[f]&&(this.chars[f].kerning[d]=p)}this.distanceFieldRange=o==null?void 0:o.distanceRange,this.distanceFieldType=((c=o==null?void 0:o.fieldType)==null?void 0:c.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,r){let s;if(t instanceof Es)s=t;else{const a=q0(t);if(!a)throw new Error("Unrecognized data format for font.");s=a.parse(t)}e instanceof L&&(e=[e]);const n=new ye(s,e,r);return ye.available[n.font]=n,n}static uninstall(t){const e=ye.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete ye.available[t]}static from(t,e,r){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:s,padding:n,resolution:a,textureWidth:o,textureHeight:h,...l}=Object.assign({},ye.defaultOptions,r),c=J0(s),u=e instanceof He?e:new He(e),d=o,f=new Es;f.info[0]={face:u.fontFamily,size:u.fontSize},f.common[0]={lineHeight:u.fontSize};let p=0,m=0,g,_,x,y=0;const v=[];for(let C=0;C<c.length;C++){g||(g=F.ADAPTER.createCanvas(),g.width=o,g.height=h,_=g.getContext("2d"),x=new W(g,{resolution:a,...l}),v.push(new L(x)),f.page.push({id:v.length-1,file:""}));const E=c[C],w=Ce.measureText(E,u,!1,g),R=w.width,N=Math.ceil(w.height),q=Math.ceil((u.fontStyle==="italic"?2:1)*R);if(m>=h-N*a){if(m===0)throw new Error(`[BitmapFont] textureHeight ${h}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${E}')`);--C,g=null,_=null,x=null,m=0,p=0,y=0;continue}if(y=Math.max(N+w.fontProperties.descent,y),q*a+p>=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${o}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${E}')`);--C,m+=y*a,m=Math.ceil(m),p=0,y=0;continue}Z0(g,_,w,p,m,a,u);const O=Ss(w.text);f.char.push({id:O,page:v.length-1,x:p/a,y:m/a,width:q,height:N,xoffset:0,yoffset:0,xadvance:R-(u.dropShadow?u.dropShadowDistance:0)-(u.stroke?u.strokeThickness:0)}),p+=(q+2*n)*a,p=Math.ceil(p)}if(!(r!=null&&r.skipKerning))for(let C=0,E=c.length;C<E;C++){const w=c[C];for(let R=0;R<E;R++){const N=c[R],q=_.measureText(w).width,O=_.measureText(N).width,b=_.measureText(w+N).width-(q+O);b&&f.kerning.push({first:Ss(w),second:Ss(N),amount:b})}}const T=new ye(f,v,!0);return ye.available[t]!==void 0&&ye.uninstall(t),ye.available[t]=T,T}};$e.ALPHA=[["a","z"],["A","Z"]," "],$e.NUMERIC=[["0","9"]],$e.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],$e.ASCII=[[" ","~"]],$e.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:$e.ALPHANUMERIC},$e.available={};let Xe=$e;var Q0=`// Pixi texture info\r
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
\r
|
|
1087
|
-
// Tint\r
|
|
1088
|
-
uniform vec4 uColor;\r
|
|
1089
|
-
\r
|
|
1090
|
-
// on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\r
|
|
1091
|
-
uniform float uFWidth;\r
|
|
1092
|
-
\r
|
|
1093
|
-
void main(void) {\r
|
|
1094
|
-
\r
|
|
1095
|
-
// To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\r
|
|
1096
|
-
vec4 texColor = texture2D(uSampler, vTextureCoord);\r
|
|
1097
|
-
\r
|
|
1098
|
-
// MSDF\r
|
|
1099
|
-
float median = texColor.r + texColor.g + texColor.b -\r
|
|
1100
|
-
min(texColor.r, min(texColor.g, texColor.b)) -\r
|
|
1101
|
-
max(texColor.r, max(texColor.g, texColor.b));\r
|
|
1102
|
-
// SDF\r
|
|
1103
|
-
median = min(median, texColor.a);\r
|
|
1104
|
-
\r
|
|
1105
|
-
float screenPxDistance = uFWidth * (median - 0.5);\r
|
|
1106
|
-
float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\r
|
|
1107
|
-
if (median < 0.01) {\r
|
|
1108
|
-
alpha = 0.0;\r
|
|
1109
|
-
} else if (median > 0.99) {\r
|
|
1110
|
-
alpha = 1.0;\r
|
|
1111
|
-
}\r
|
|
1112
|
-
\r
|
|
1113
|
-
// Gamma correction for coverage-like alpha\r
|
|
1114
|
-
float luma = dot(uColor.rgb, vec3(0.299, 0.587, 0.114));\r
|
|
1115
|
-
float gamma = mix(1.0, 1.0 / 2.2, luma);\r
|
|
1116
|
-
float coverage = pow(uColor.a * alpha, gamma); \r
|
|
1117
|
-
\r
|
|
1118
|
-
// NPM Textures, NPM outputs\r
|
|
1119
|
-
gl_FragColor = vec4(uColor.rgb, coverage);\r
|
|
1120
|
-
}\r
|
|
1121
|
-
`,ty=`// Mesh material default fragment\r
|
|
1122
|
-
attribute vec2 aVertexPosition;\r
|
|
1123
|
-
attribute vec2 aTextureCoord;\r
|
|
1124
|
-
\r
|
|
1125
|
-
uniform mat3 projectionMatrix;\r
|
|
1126
|
-
uniform mat3 translationMatrix;\r
|
|
1127
|
-
uniform mat3 uTextureMatrix;\r
|
|
1128
|
-
\r
|
|
1129
|
-
varying vec2 vTextureCoord;\r
|
|
1130
|
-
\r
|
|
1131
|
-
void main(void)\r
|
|
1132
|
-
{\r
|
|
1133
|
-
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\r
|
|
1134
|
-
\r
|
|
1135
|
-
vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
|
|
1136
|
-
}\r
|
|
1137
|
-
`;const hc=[],lc=[],cc=[],ey=class Dc extends bt{constructor(t,e={}){super();const{align:r,tint:s,maxWidth:n,letterSpacing:a,fontName:o,fontSize:h}=Object.assign({},Dc.styleDefaults,e);if(!Xe.available[o])throw new Error(`Missing BitmapFont "${o}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=r,this._tintColor=new tt(s),this._font=void 0,this._fontName=o,this._fontSize=h,this.text=t,this._maxWidth=n,this._maxLineHeight=0,this._letterSpacing=a,this._anchor=new we(()=>{this.dirty=!0},this,0,0),this._roundPixels=F.ROUND_PIXELS,this.dirty=!0,this._resolution=F.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var q;const t=Xe.available[this._fontName],e=this.fontSize,r=e/t.size,s=new J,n=[],a=[],o=[],h=this._text.replace(/(?:\r\n|\r)/g,`
|
|
1138
|
-
`)||" ",l=oc(h),c=this._maxWidth*t.size/e,u=t.distanceFieldType==="none"?hc:lc;let d=null,f=0,p=0,m=0,g=-1,_=0,x=0,y=0,v=0;for(let O=0;O<l.length;O++){const b=l[O],S=Ss(b);if(/(?:\s)/.test(b)&&(g=O,_=f,v++),b==="\r"||b===`
|
|
1139
|
-
`){a.push(f),o.push(-1),p=Math.max(p,f),++m,++x,s.x=0,s.y+=t.lineHeight,d=null,v=0;continue}const G=t.chars[S];if(!G)continue;d&&G.kerning[d]&&(s.x+=G.kerning[d]);const j=cc.pop()||{texture:L.EMPTY,line:0,charCode:0,prevSpaces:0,position:new J};j.texture=G.texture,j.line=m,j.charCode=S,j.position.x=Math.round(s.x+G.xOffset+this._letterSpacing/2),j.position.y=Math.round(s.y+G.yOffset),j.prevSpaces=v,n.push(j),f=j.position.x+Math.max(G.xAdvance-G.xOffset,G.texture.orig.width),s.x+=G.xAdvance+this._letterSpacing,y=Math.max(y,G.yOffset+G.texture.height),d=S,g!==-1&&c>0&&s.x>c&&(++x,Ai(n,1+g-x,1+O-g),O=g,g=-1,a.push(_),o.push(n.length>0?n[n.length-1].prevSpaces:0),p=Math.max(p,_),m++,s.x=0,s.y+=t.lineHeight,d=null,v=0)}const T=l[l.length-1];T!=="\r"&&T!==`
|
|
1140
|
-
`&&(/(?:\s)/.test(T)&&(f=_),a.push(f),p=Math.max(p,f),o.push(-1));const C=[];for(let O=0;O<=m;O++){let b=0;this._align==="right"?b=p-a[O]:this._align==="center"?b=(p-a[O])/2:this._align==="justify"&&(b=o[O]<0?0:(p-a[O])/o[O]),C.push(b)}const E=n.length,w={},R=[],N=this._activePagesMeshData;u.push(...N);for(let O=0;O<E;O++){const b=n[O].texture,S=b.baseTexture.uid;if(!w[S]){let G=u.pop();if(!G){const X=new A0;let V,nt;t.distanceFieldType==="none"?(V=new ql(L.EMPTY),nt=z.NORMAL):(V=new ql(L.EMPTY,{program:Ee.from(ty,Q0),uniforms:{uFWidth:0}}),nt=z.NORMAL_NPM);const I=new Yl(X,V);I.blendMode=nt,G={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:I,vertices:null,uvs:null,indices:null}}G.index=0,G.indexCount=0,G.vertexCount=0,G.uvsCount=0,G.total=0;const{_textureCache:j}=this;j[S]=j[S]||new L(b.baseTexture),G.mesh.texture=j[S],G.mesh.tint=this._tintColor.value,R.push(G),w[S]=G}w[S].total++}for(let O=0;O<N.length;O++)R.includes(N[O])||this.removeChild(N[O].mesh);for(let O=0;O<R.length;O++)R[O].mesh.parent!==this&&this.addChild(R[O].mesh);this._activePagesMeshData=R;for(const O in w){const b=w[O],S=b.total;if(!(((q=b.indices)==null?void 0:q.length)>6*S)||b.vertices.length<Yl.BATCHABLE_SIZE*2)b.vertices=new Float32Array(4*2*S),b.uvs=new Float32Array(4*2*S),b.indices=new Uint16Array(6*S);else{const G=b.total,j=b.vertices;for(let X=G*4*2;X<j.length;X++)j[X]=0}b.mesh.size=6*S}for(let O=0;O<E;O++){const b=n[O];let S=b.position.x+C[b.line]*(this._align==="justify"?b.prevSpaces:1);this._roundPixels&&(S=Math.round(S));const G=S*r,j=b.position.y*r,X=b.texture,V=w[X.baseTexture.uid],nt=X.frame,I=X._uvs,M=V.index++;V.indices[M*6+0]=0+M*4,V.indices[M*6+1]=1+M*4,V.indices[M*6+2]=2+M*4,V.indices[M*6+3]=0+M*4,V.indices[M*6+4]=2+M*4,V.indices[M*6+5]=3+M*4,V.vertices[M*8+0]=G,V.vertices[M*8+1]=j,V.vertices[M*8+2]=G+nt.width*r,V.vertices[M*8+3]=j,V.vertices[M*8+4]=G+nt.width*r,V.vertices[M*8+5]=j+nt.height*r,V.vertices[M*8+6]=G,V.vertices[M*8+7]=j+nt.height*r,V.uvs[M*8+0]=I.x0,V.uvs[M*8+1]=I.y0,V.uvs[M*8+2]=I.x1,V.uvs[M*8+3]=I.y1,V.uvs[M*8+4]=I.x2,V.uvs[M*8+5]=I.y2,V.uvs[M*8+6]=I.x3,V.uvs[M*8+7]=I.y3}this._textWidth=p*r,this._textHeight=(s.y+t.lineHeight)*r;for(const O in w){const b=w[O];if(this.anchor.x!==0||this.anchor.y!==0){let X=0;const V=this._textWidth*this.anchor.x,nt=this._textHeight*this.anchor.y;for(let I=0;I<b.total;I++)b.vertices[X++]-=V,b.vertices[X++]-=nt,b.vertices[X++]-=V,b.vertices[X++]-=nt,b.vertices[X++]-=V,b.vertices[X++]-=nt,b.vertices[X++]-=V,b.vertices[X++]-=nt}this._maxLineHeight=y*r;const S=b.mesh.geometry.getBuffer("aVertexPosition"),G=b.mesh.geometry.getBuffer("aTextureCoord"),j=b.mesh.geometry.getIndex();S.data=b.vertices,G.data=b.uvs,j.data=b.indices,S.update(),G.update(),j.update()}for(let O=0;O<n.length;O++)cc.push(n[O]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:e,distanceFieldType:r,size:s}=Xe.available[this._fontName];if(r!=="none"){const{a:n,b:a,c:o,d:h}=this.worldTransform,l=Math.sqrt(n*n+a*a),c=Math.sqrt(o*o+h*h),u=(Math.abs(l)+Math.abs(c))/2,d=this.fontSize/s,f=t._view.resolution;for(const p of this._activePagesMeshData)p.mesh.shader.uniforms.uFWidth=u*e*d*f}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=Xe.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(!Xe.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??Xe.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:e}=this,r=Xe.available[this._fontName].distanceFieldType==="none"?hc:lc;r.push(...this._activePagesMeshData);for(const s of this._activePagesMeshData)this.removeChild(s.mesh);this._activePagesMeshData=[],r.filter(s=>e[s.mesh.texture.baseTexture.uid]).forEach(s=>{s.mesh.texture=L.EMPTY});for(const s in e)e[s].destroy(),delete e[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};ey.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const iy=[".xml",".fnt"],ry={extension:{type:P.LoadParser,priority:Yt.Normal},name:"loadBitmapFont",test(i){return iy.includes(xt.extname(i).toLowerCase())},async testParse(i){return As.test(i)||Ia.test(i)},async parse(i,t,e){const r=As.test(i)?As.parse(i):Ia.parse(i),{src:s}=t,{page:n}=r,a=[];for(let l=0;l<n.length;++l){const c=n[l].file;let u=xt.join(xt.dirname(s),c);u=la(u,s),a.push(u)}const o=await e.load(a),h=a.map(l=>o[l]);return Xe.install(r,h,!0)},async load(i,t){return(await F.ADAPTER.fetch(i)).text()},unload(i){i.destroy()}};k.add(ry);const Pa=class Hi extends He{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new Hi(Object.keys(Hi.defaultOptions).reduce((e,r)=>({...e,[r]:t[r]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(t=>{URL.revokeObjectURL(t.src),t.refs--,t.refs===0&&(t.fontFace&&document.fonts.delete(t.fontFace),delete Hi.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:r}=Hi;if(r[t]){const s=r[t];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return F.ADAPTER.fetch(t).then(s=>s.blob()).then(async s=>new Promise((n,a)=>{const o=URL.createObjectURL(s),h=new FileReader;h.onload=()=>n([o,h.result]),h.onerror=a,h.readAsDataURL(s)})).then(async([s,n])=>{const a=Object.assign({family:xt.basename(t,xt.extname(t)),weight:"normal",style:"normal",display:"auto",src:s,dataSrc:n,refs:1,originalUrl:t,fontFace:null},e);r[t]=a,this._fonts.push(a),this.styleID++;const o=new FontFace(a.family,`url(${a.src})`,{weight:a.weight,style:a.style,display:a.display});a.fontFace=o,await o.load(),document.fonts.add(o),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...t){const e=t.filter(r=>!this._overrides.includes(r));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter(r=>this._overrides.includes(r));e.length>0&&(this._overrides=this._overrides.filter(r=>!e.includes(r)),this.styleID++)}toCSS(t){return[`transform: scale(${t})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((t,e)=>`${t}
|
|
1141
|
-
@font-face {
|
|
1142
|
-
font-family: "${e.family}";
|
|
1143
|
-
src: url('${e.dataSrc}');
|
|
1144
|
-
font-weight: ${e.weight};
|
|
1145
|
-
font-style: ${e.style};
|
|
1146
|
-
font-display: ${e.display};
|
|
1147
|
-
}`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=Vf(t)),typeof t=="number"?zf(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,r=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),s=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${r}px ${s}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,Hi.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(e=>setTimeout(e,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=F.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}};Pa.availableFonts={},Pa.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let Ma=Pa;const Cs=class $i extends ue{constructor(t="",e={}){super(L.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const r=new Image,s=L.from(r,{scaleMode:F.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new Y,s.trim=new Y,this.texture=s;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"),c=document.createElementNS(a,"style");h.setAttribute("width","10000"),h.setAttribute("height","10000"),h.style.overflow="hidden",o.appendChild(h),this.maxWidth=$i.defaultMaxWidth,this.maxHeight=$i.defaultMaxHeight,this._domElement=l,this._styleElement=c,this._svgRoot=o,this._foreignObject=h,this._foreignObject.appendChild(c),this._foreignObject.appendChild(l),this._image=r,this._loadImage=new Image,this._autoResolution=$i.defaultAutoResolution,this._resolution=$i.defaultResolution??F.RESOLUTION,this.text=t,this.style=e}measureText(t){var c,u;const{text:e,style:r,resolution:s}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:r.toCSS(s)}),this._styleElement.textContent=r.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:a,height:o}=n;(a>this.maxWidth||o>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const h=Math.min(this.maxWidth,Math.ceil(a)),l=Math.min(this.maxHeight,Math.ceil(o));return this._svgRoot.setAttribute("width",h.toString()),this._svgRoot.setAttribute("height",l.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),r!==this._style&&(Object.assign(this._domElement,{style:(c=this._style)==null?void 0:c.toCSS(s)}),this._styleElement.textContent=(u=this._style)==null?void 0:u.toGlobalCSS()),{width:h+r.padding*2,height:l+r.padding*2}}async updateText(t=!0){const{style:e,_image:r,_loadImage:s}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:a}=this.measureText();r.width=s.width=Math.ceil(Math.max(1,n)),r.height=s.height=Math.ceil(Math.max(1,a)),this._updateID++;const o=this._updateID;await new Promise(h=>{s.onload=async()=>{if(o<this._updateID){h();return}await e.onBeforeDraw(),r.src=s.src,s.onload=null,s.src="",this.updateTexture(),h()};const l=new XMLSerializer().serializeToString(this._svgRoot);s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(l)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:r,resolution:s}=this,{padding:n}=t,{baseTexture:a}=e;e.trim.width=e._frame.width=r.width/s,e.trim.height=e._frame.height=r.height/s,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),a.setRealSize(r.width,r.height,s),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 r,s,n,a,o;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},$i.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((r=this._style)==null||r.cleanFonts()),this._style=e,(s=this._svgRoot)==null||s.remove(),this._svgRoot=e,(n=this._domElement)==null||n.remove(),this._domElement=e,(a=this._foreignObject)==null||a.remove(),this._foreignObject=e,(o=this._styleElement)==null||o.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=Oe(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=Oe(this.scale.y)||1;this.scale.y=e*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof Ma?(this.ownsStyle=!1,this._style=t):t instanceof He?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Ma.from(t)):(this.ownsStyle=!0,this._style=new Ma(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/ /gi," ")}};Cs.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Cs.defaultMaxWidth=2024,Cs.defaultMaxHeight=2024,Cs.defaultAutoResolution=!0;const ze=.02*1e3;class Ve{constructor(t=0,e){B(this,"isCompleted",!1);this.current=t,this.onComplete=e}tick(t=ze){var e;this.isCompleted||(this.current-=t,this.current<0&&(this.isCompleted=!0,(e=this.onComplete)==null||e.call(this)))}}class sy{constructor(){B(this,"timers",[])}add(t,e){this.timers.push(new Ve(t,e))}tick(t=ze){const e=[];for(const r of this.timers)r.isCompleted||(r.tick(t),e.push(r));this.timers=e}}const Fa=new sy,uc=i=>i.name=="jump",dc=i=>i.name=="color",fc=i=>i.name=="grow",pc=i=>i.name=="dash",mc=i=>i.name=="sprite";function Is(i){"@babel/helpers - typeof";return Is=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Is(i)}var ny=/^\s+/,ay=/\s+$/;function $(i,t){if(i=i||"",t=t||{},i instanceof $)return i;if(!(this instanceof $))return new $(i,t);var e=oy(i);this._originalInput=i,this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||e.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=e.ok}$.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},getLuminance:function(){var t=this.toRgb(),e,r,s,n,a,o;return e=t.r/255,r=t.g/255,s=t.b/255,e<=.03928?n=e/12.92:n=Math.pow((e+.055)/1.055,2.4),r<=.03928?a=r/12.92:a=Math.pow((r+.055)/1.055,2.4),s<=.03928?o=s/12.92:o=Math.pow((s+.055)/1.055,2.4),.2126*n+.7152*a+.0722*o},setAlpha:function(t){return this._a=bc(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=yc(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=yc(this._r,this._g,this._b),e=Math.round(t.h*360),r=Math.round(t.s*100),s=Math.round(t.v*100);return this._a==1?"hsv("+e+", "+r+"%, "+s+"%)":"hsva("+e+", "+r+"%, "+s+"%, "+this._roundA+")"},toHsl:function(){var t=gc(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=gc(this._r,this._g,this._b),e=Math.round(t.h*360),r=Math.round(t.s*100),s=Math.round(t.l*100);return this._a==1?"hsl("+e+", "+r+"%, "+s+"%)":"hsla("+e+", "+r+"%, "+s+"%, "+this._roundA+")"},toHex:function(t){return _c(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return uy(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(st(this._r,255)*100)+"%",g:Math.round(st(this._g,255)*100)+"%",b:Math.round(st(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(st(this._r,255)*100)+"%, "+Math.round(st(this._g,255)*100)+"%, "+Math.round(st(this._b,255)*100)+"%)":"rgba("+Math.round(st(this._r,255)*100)+"%, "+Math.round(st(this._g,255)*100)+"%, "+Math.round(st(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:wy[_c(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var e="#"+vc(this._r,this._g,this._b,this._a),r=e,s=this._gradientType?"GradientType = 1, ":"";if(t){var n=$(t);r="#"+vc(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+s+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,s=this._a<1&&this._a>=0,n=!e&&s&&(t==="hex"||t==="hex6"||t==="hex3"||t==="hex4"||t==="hex8"||t==="name");return n?t==="name"&&this._a===0?this.toName():this.toRgbString():(t==="rgb"&&(r=this.toRgbString()),t==="prgb"&&(r=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(r=this.toHexString()),t==="hex3"&&(r=this.toHexString(!0)),t==="hex4"&&(r=this.toHex8String(!0)),t==="hex8"&&(r=this.toHex8String()),t==="name"&&(r=this.toName()),t==="hsl"&&(r=this.toHslString()),t==="hsv"&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return $(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(my,arguments)},brighten:function(){return this._applyModification(gy,arguments)},darken:function(){return this._applyModification(yy,arguments)},desaturate:function(){return this._applyModification(dy,arguments)},saturate:function(){return this._applyModification(fy,arguments)},greyscale:function(){return this._applyModification(py,arguments)},spin:function(){return this._applyModification(_y,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(by,arguments)},complement:function(){return this._applyCombination(vy,arguments)},monochromatic:function(){return this._applyCombination(Ty,arguments)},splitcomplement:function(){return this._applyCombination(xy,arguments)},triad:function(){return this._applyCombination(xc,[3])},tetrad:function(){return this._applyCombination(xc,[4])}},$.fromRatio=function(i,t){if(Is(i)=="object"){var e={};for(var r in i)i.hasOwnProperty(r)&&(r==="a"?e[r]=i[r]:e[r]=lr(i[r]));i=e}return $(i,t)};function oy(i){var t={r:0,g:0,b:0},e=1,r=null,s=null,n=null,a=!1,o=!1;return typeof i=="string"&&(i=Cy(i)),Is(i)=="object"&&(Ie(i.r)&&Ie(i.g)&&Ie(i.b)?(t=hy(i.r,i.g,i.b),a=!0,o=String(i.r).substr(-1)==="%"?"prgb":"rgb"):Ie(i.h)&&Ie(i.s)&&Ie(i.v)?(r=lr(i.s),s=lr(i.v),t=cy(i.h,r,s),a=!0,o="hsv"):Ie(i.h)&&Ie(i.s)&&Ie(i.l)&&(r=lr(i.s),n=lr(i.l),t=ly(i.h,r,n),a=!0,o="hsl"),i.hasOwnProperty("a")&&(e=i.a)),e=bc(e),{ok:a,format:i.format||o,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:e}}function hy(i,t,e){return{r:st(i,255)*255,g:st(t,255)*255,b:st(e,255)*255}}function gc(i,t,e){i=st(i,255),t=st(t,255),e=st(e,255);var r=Math.max(i,t,e),s=Math.min(i,t,e),n,a,o=(r+s)/2;if(r==s)n=a=0;else{var h=r-s;switch(a=o>.5?h/(2-r-s):h/(r+s),r){case i:n=(t-e)/h+(t<e?6:0);break;case t:n=(e-i)/h+2;break;case e:n=(i-t)/h+4;break}n/=6}return{h:n,s:a,l:o}}function ly(i,t,e){var r,s,n;i=st(i,360),t=st(t,100),e=st(e,100);function a(l,c,u){return u<0&&(u+=1),u>1&&(u-=1),u<1/6?l+(c-l)*6*u:u<1/2?c:u<2/3?l+(c-l)*(2/3-u)*6:l}if(t===0)r=s=n=e;else{var o=e<.5?e*(1+t):e+t-e*t,h=2*e-o;r=a(h,o,i+1/3),s=a(h,o,i),n=a(h,o,i-1/3)}return{r:r*255,g:s*255,b:n*255}}function yc(i,t,e){i=st(i,255),t=st(t,255),e=st(e,255);var r=Math.max(i,t,e),s=Math.min(i,t,e),n,a,o=r,h=r-s;if(a=r===0?0:h/r,r==s)n=0;else{switch(r){case i:n=(t-e)/h+(t<e?6:0);break;case t:n=(e-i)/h+2;break;case e:n=(i-t)/h+4;break}n/=6}return{h:n,s:a,v:o}}function cy(i,t,e){i=st(i,360)*6,t=st(t,100),e=st(e,100);var r=Math.floor(i),s=i-r,n=e*(1-t),a=e*(1-s*t),o=e*(1-(1-s)*t),h=r%6,l=[e,a,n,n,o,e][h],c=[o,e,e,a,n,n][h],u=[n,n,o,e,e,a][h];return{r:l*255,g:c*255,b:u*255}}function _c(i,t,e,r){var s=[Kt(Math.round(i).toString(16)),Kt(Math.round(t).toString(16)),Kt(Math.round(e).toString(16))];return r&&s[0].charAt(0)==s[0].charAt(1)&&s[1].charAt(0)==s[1].charAt(1)&&s[2].charAt(0)==s[2].charAt(1)?s[0].charAt(0)+s[1].charAt(0)+s[2].charAt(0):s.join("")}function uy(i,t,e,r,s){var n=[Kt(Math.round(i).toString(16)),Kt(Math.round(t).toString(16)),Kt(Math.round(e).toString(16)),Kt(Tc(r))];return s&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)&&n[3].charAt(0)==n[3].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0)+n[3].charAt(0):n.join("")}function vc(i,t,e,r){var s=[Kt(Tc(r)),Kt(Math.round(i).toString(16)),Kt(Math.round(t).toString(16)),Kt(Math.round(e).toString(16))];return s.join("")}$.equals=function(i,t){return!i||!t?!1:$(i).toRgbString()==$(t).toRgbString()},$.random=function(){return $.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function dy(i,t){t=t===0?0:t||10;var e=$(i).toHsl();return e.s-=t/100,e.s=Rs(e.s),$(e)}function fy(i,t){t=t===0?0:t||10;var e=$(i).toHsl();return e.s+=t/100,e.s=Rs(e.s),$(e)}function py(i){return $(i).desaturate(100)}function my(i,t){t=t===0?0:t||10;var e=$(i).toHsl();return e.l+=t/100,e.l=Rs(e.l),$(e)}function gy(i,t){t=t===0?0:t||10;var e=$(i).toRgb();return e.r=Math.max(0,Math.min(255,e.r-Math.round(255*-(t/100)))),e.g=Math.max(0,Math.min(255,e.g-Math.round(255*-(t/100)))),e.b=Math.max(0,Math.min(255,e.b-Math.round(255*-(t/100)))),$(e)}function yy(i,t){t=t===0?0:t||10;var e=$(i).toHsl();return e.l-=t/100,e.l=Rs(e.l),$(e)}function _y(i,t){var e=$(i).toHsl(),r=(e.h+t)%360;return e.h=r<0?360+r:r,$(e)}function vy(i){var t=$(i).toHsl();return t.h=(t.h+180)%360,$(t)}function xc(i,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var e=$(i).toHsl(),r=[$(i)],s=360/t,n=1;n<t;n++)r.push($({h:(e.h+n*s)%360,s:e.s,l:e.l}));return r}function xy(i){var t=$(i).toHsl(),e=t.h;return[$(i),$({h:(e+72)%360,s:t.s,l:t.l}),$({h:(e+216)%360,s:t.s,l:t.l})]}function by(i,t,e){t=t||6,e=e||30;var r=$(i).toHsl(),s=360/e,n=[$(i)];for(r.h=(r.h-(s*t>>1)+720)%360;--t;)r.h=(r.h+s)%360,n.push($(r));return n}function Ty(i,t){t=t||6;for(var e=$(i).toHsv(),r=e.h,s=e.s,n=e.v,a=[],o=1/t;t--;)a.push($({h:r,s,v:n})),n=(n+o)%1;return a}$.mix=function(i,t,e){e=e===0?0:e||50;var r=$(i).toRgb(),s=$(t).toRgb(),n=e/100,a={r:(s.r-r.r)*n+r.r,g:(s.g-r.g)*n+r.g,b:(s.b-r.b)*n+r.b,a:(s.a-r.a)*n+r.a};return $(a)},$.readability=function(i,t){var e=$(i),r=$(t);return(Math.max(e.getLuminance(),r.getLuminance())+.05)/(Math.min(e.getLuminance(),r.getLuminance())+.05)},$.isReadable=function(i,t,e){var r=$.readability(i,t),s,n;switch(n=!1,s=Iy(e),s.level+s.size){case"AAsmall":case"AAAlarge":n=r>=4.5;break;case"AAlarge":n=r>=3;break;case"AAAsmall":n=r>=7;break}return n},$.mostReadable=function(i,t,e){var r=null,s=0,n,a,o,h;e=e||{},a=e.includeFallbackColors,o=e.level,h=e.size;for(var l=0;l<t.length;l++)n=$.readability(i,t[l]),n>s&&(s=n,r=$(t[l]));return $.isReadable(i,r,{level:o,size:h})||!a?r:(e.includeFallbackColors=!1,$.mostReadable(i,["#fff","#000"],e))};var Ba=$.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},wy=$.hexNames=Ey(Ba);function Ey(i){var t={};for(var e in i)i.hasOwnProperty(e)&&(t[i[e]]=e);return t}function bc(i){return i=parseFloat(i),(isNaN(i)||i<0||i>1)&&(i=1),i}function st(i,t){Ay(i)&&(i="100%");var e=Sy(i);return i=Math.min(t,Math.max(0,parseFloat(i))),e&&(i=parseInt(i*t,10)/100),Math.abs(i-t)<1e-6?1:i%t/parseFloat(t)}function Rs(i){return Math.min(1,Math.max(0,i))}function Lt(i){return parseInt(i,16)}function Ay(i){return typeof i=="string"&&i.indexOf(".")!=-1&&parseFloat(i)===1}function Sy(i){return typeof i=="string"&&i.indexOf("%")!=-1}function Kt(i){return i.length==1?"0"+i:""+i}function lr(i){return i<=1&&(i=i*100+"%"),i}function Tc(i){return Math.round(parseFloat(i)*255).toString(16)}function wc(i){return Lt(i)/255}var Zt=function(){var i="[-\\+]?\\d+%?",t="[-\\+]?\\d*\\.\\d+%?",e="(?:"+t+")|(?:"+i+")",r="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",s="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?";return{CSS_UNIT:new RegExp(e),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+s),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+s),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+s),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Ie(i){return!!Zt.CSS_UNIT.exec(i)}function Cy(i){i=i.replace(ny,"").replace(ay,"").toLowerCase();var t=!1;if(Ba[i])i=Ba[i],t=!0;else if(i=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var e;return(e=Zt.rgb.exec(i))?{r:e[1],g:e[2],b:e[3]}:(e=Zt.rgba.exec(i))?{r:e[1],g:e[2],b:e[3],a:e[4]}:(e=Zt.hsl.exec(i))?{h:e[1],s:e[2],l:e[3]}:(e=Zt.hsla.exec(i))?{h:e[1],s:e[2],l:e[3],a:e[4]}:(e=Zt.hsv.exec(i))?{h:e[1],s:e[2],v:e[3]}:(e=Zt.hsva.exec(i))?{h:e[1],s:e[2],v:e[3],a:e[4]}:(e=Zt.hex8.exec(i))?{r:Lt(e[1]),g:Lt(e[2]),b:Lt(e[3]),a:wc(e[4]),format:t?"name":"hex8"}:(e=Zt.hex6.exec(i))?{r:Lt(e[1]),g:Lt(e[2]),b:Lt(e[3]),format:t?"name":"hex"}:(e=Zt.hex4.exec(i))?{r:Lt(e[1]+""+e[1]),g:Lt(e[2]+""+e[2]),b:Lt(e[3]+""+e[3]),a:wc(e[4]+""+e[4]),format:t?"name":"hex8"}:(e=Zt.hex3.exec(i))?{r:Lt(e[1]+""+e[1]),g:Lt(e[2]+""+e[2]),b:Lt(e[3]+""+e[3]),format:t?"name":"hex"}:!1}function Iy(i){var t,e;return i=i||{level:"AA",size:"small"},t=(i.level||"AA").toUpperCase(),e=(i.size||"small").toLowerCase(),t!=="AA"&&t!=="AAA"&&(t="AA"),e!=="small"&&e!=="large"&&(e="small"),{level:t,size:e}}var cr=Object.freeze({Linear:Object.freeze({None:function(i){return i},In:function(i){return i},Out:function(i){return i},InOut:function(i){return i}}),Quadratic:Object.freeze({In:function(i){return i*i},Out:function(i){return i*(2-i)},InOut:function(i){return(i*=2)<1?.5*i*i:-.5*(--i*(i-2)-1)}}),Cubic:Object.freeze({In:function(i){return i*i*i},Out:function(i){return--i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i:.5*((i-=2)*i*i+2)}}),Quartic:Object.freeze({In:function(i){return i*i*i*i},Out:function(i){return 1- --i*i*i*i},InOut:function(i){return(i*=2)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2)}}),Quintic:Object.freeze({In:function(i){return i*i*i*i*i},Out:function(i){return--i*i*i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2)}}),Sinusoidal:Object.freeze({In:function(i){return 1-Math.sin((1-i)*Math.PI/2)},Out:function(i){return Math.sin(i*Math.PI/2)},InOut:function(i){return .5*(1-Math.sin(Math.PI*(.5-i)))}}),Exponential:Object.freeze({In:function(i){return i===0?0:Math.pow(1024,i-1)},Out:function(i){return i===1?1:1-Math.pow(2,-10*i)},InOut:function(i){return i===0?0:i===1?1:(i*=2)<1?.5*Math.pow(1024,i-1):.5*(-Math.pow(2,-10*(i-1))+2)}}),Circular:Object.freeze({In:function(i){return 1-Math.sqrt(1-i*i)},Out:function(i){return Math.sqrt(1- --i*i)},InOut:function(i){return(i*=2)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1)}}),Elastic:Object.freeze({In:function(i){return i===0?0:i===1?1:-Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI)},Out:function(i){return i===0?0:i===1?1:Math.pow(2,-10*i)*Math.sin((i-.1)*5*Math.PI)+1},InOut:function(i){return i===0?0:i===1?1:(i*=2,i<1?-.5*Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI):.5*Math.pow(2,-10*(i-1))*Math.sin((i-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(i){var t=1.70158;return i===1?1:i*i*((t+1)*i-t)},Out:function(i){var t=1.70158;return i===0?0:--i*i*((t+1)*i+t)+1},InOut:function(i){var t=2.5949095;return(i*=2)<1?.5*(i*i*((t+1)*i-t)):.5*((i-=2)*i*((t+1)*i+t)+2)}}),Bounce:Object.freeze({In:function(i){return 1-cr.Bounce.Out(1-i)},Out:function(i){return i<1/2.75?7.5625*i*i:i<2/2.75?7.5625*(i-=1.5/2.75)*i+.75:i<2.5/2.75?7.5625*(i-=2.25/2.75)*i+.9375:7.5625*(i-=2.625/2.75)*i+.984375},InOut:function(i){return i<.5?cr.Bounce.In(i*2)*.5:cr.Bounce.Out(i*2-1)*.5+.5}}),generatePow:function(i){return i===void 0&&(i=4),i=i<Number.EPSILON?Number.EPSILON:i,i=i>1e4?1e4:i,{In:function(t){return Math.pow(t,i)},Out:function(t){return 1-Math.pow(1-t,i)},InOut:function(t){return t<.5?Math.pow(t*2,i)/2:(1-Math.pow(2-t*2,i))/2+.5}}}}),ur=function(){return performance.now()},Ry=function(){function i(){this._tweens={},this._tweensAddedDuringUpdate={}}return i.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map(function(e){return t._tweens[e]})},i.prototype.removeAll=function(){this._tweens={}},i.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},i.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},i.prototype.update=function(t,e){t===void 0&&(t=ur()),e===void 0&&(e=!1);var r=Object.keys(this._tweens);if(r.length===0)return!1;for(;r.length>0;){this._tweensAddedDuringUpdate={};for(var s=0;s<r.length;s++){var n=this._tweens[r[s]],a=!e;n&&n.update(t,a)===!1&&!e&&delete this._tweens[r[s]]}r=Object.keys(this._tweensAddedDuringUpdate)}return!0},i}(),Ni={Linear:function(i,t){var e=i.length-1,r=e*t,s=Math.floor(r),n=Ni.Utils.Linear;return t<0?n(i[0],i[1],r):t>1?n(i[e],i[e-1],e-r):n(i[s],i[s+1>e?e:s+1],r-s)},Bezier:function(i,t){for(var e=0,r=i.length-1,s=Math.pow,n=Ni.Utils.Bernstein,a=0;a<=r;a++)e+=s(1-t,r-a)*s(t,a)*i[a]*n(r,a);return e},CatmullRom:function(i,t){var e=i.length-1,r=e*t,s=Math.floor(r),n=Ni.Utils.CatmullRom;return i[0]===i[e]?(t<0&&(s=Math.floor(r=e*(1+t))),n(i[(s-1+e)%e],i[s],i[(s+1)%e],i[(s+2)%e],r-s)):t<0?i[0]-(n(i[0],i[0],i[1],i[1],-r)-i[0]):t>1?i[e]-(n(i[e],i[e],i[e-1],i[e-1],r-e)-i[e]):n(i[s?s-1:0],i[s],i[e<s+1?e:s+1],i[e<s+2?e:s+2],r-s)},Utils:{Linear:function(i,t,e){return(t-i)*e+i},Bernstein:function(i,t){var e=Ni.Utils.Factorial;return e(i)/e(t)/e(i-t)},Factorial:function(){var i=[1];return function(t){var e=1;if(i[t])return i[t];for(var r=t;r>1;r--)e*=r;return i[t]=e,e}}(),CatmullRom:function(i,t,e,r,s){var n=(e-i)*.5,a=(r-t)*.5,o=s*s,h=s*o;return(2*t-2*e+n+a)*h+(-3*t+3*e-2*n-a)*o+n*s+t}}},Py=function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i}(),Da=new Ry,ki=function(){function i(t,e){e===void 0&&(e=Da),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=cr.Linear.None,this._interpolationFunction=Ni.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Py.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return i.prototype.getId=function(){return this._id},i.prototype.isPlaying=function(){return this._isPlaying},i.prototype.isPaused=function(){return this._isPaused},i.prototype.getDuration=function(){return this._duration},i.prototype.to=function(t,e){if(e===void 0&&(e=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=e<0?0:e,this},i.prototype.duration=function(t){return t===void 0&&(t=1e3),this._duration=t<0?0:t,this},i.prototype.dynamic=function(t){return t===void 0&&(t=!1),this._isDynamic=t,this},i.prototype.start=function(t,e){if(t===void 0&&(t=ur()),e===void 0&&(e=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var r in this._valuesStartRepeat)this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||e){if(this._propertiesAreSetUp=!0,!this._isDynamic){var s={};for(var n in this._valuesEnd)s[n]=this._valuesEnd[n];this._valuesEnd=s}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,e)}return this},i.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},i.prototype._setupProperties=function(t,e,r,s,n){for(var a in r){var o=t[a],h=Array.isArray(o),l=h?"array":typeof o,c=!h&&Array.isArray(r[a]);if(!(l==="undefined"||l==="function")){if(c){var u=r[a];if(u.length===0)continue;for(var d=[o],f=0,p=u.length;f<p;f+=1){var m=this._handleRelativeValue(o,u[f]);if(isNaN(m)){c=!1,console.warn("Found invalid interpolation list. Skipping.");break}d.push(m)}c&&(r[a]=d)}if((l==="object"||h)&&o&&!c){e[a]=h?[]:{};var g=o;for(var _ in g)e[a][_]=g[_];s[a]=h?[]:{};var u=r[a];if(!this._isDynamic){var x={};for(var _ in u)x[_]=u[_];r[a]=u=x}this._setupProperties(g,e[a],u,s[a],n)}else(typeof e[a]>"u"||n)&&(e[a]=o),h||(e[a]*=1),c?s[a]=r[a].slice().reverse():s[a]=e[a]||0}}},i.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},i.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},i.prototype.pause=function(t){return t===void 0&&(t=ur()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this),this)},i.prototype.resume=function(t){return t===void 0&&(t=ur()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},i.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},i.prototype.group=function(t){return t===void 0&&(t=Da),this._group=t,this},i.prototype.delay=function(t){return t===void 0&&(t=0),this._delayTime=t,this},i.prototype.repeat=function(t){return t===void 0&&(t=0),this._initialRepeat=t,this._repeat=t,this},i.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},i.prototype.yoyo=function(t){return t===void 0&&(t=!1),this._yoyo=t,this},i.prototype.easing=function(t){return t===void 0&&(t=cr.Linear.None),this._easingFunction=t,this},i.prototype.interpolation=function(t){return t===void 0&&(t=Ni.Linear),this._interpolationFunction=t,this},i.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},i.prototype.onStart=function(t){return this._onStartCallback=t,this},i.prototype.onEveryStart=function(t){return this._onEveryStartCallback=t,this},i.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},i.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},i.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},i.prototype.onStop=function(t){return this._onStopCallback=t,this},i.prototype.update=function(t,e){var r;if(t===void 0&&(t=ur()),e===void 0&&(e=!0),this._isPaused)return!0;var s=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>s)return!1;e&&this.start(t,!0)}if(this._goToEnd=!1,t<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var n=t-this._startTime,a=this._duration+((r=this._repeatDelayTime)!==null&&r!==void 0?r:this._delayTime),o=this._duration+this._repeat*a,h=this._calculateElapsedPortion(n,a,o),l=this._easingFunction(h),c=this._calculateCompletionStatus(n,a);if(c==="repeat"&&this._processRepetition(n,a),this._updateProperties(this._object,this._valuesStart,this._valuesEnd,l),c==="about-to-repeat"&&this._processRepetition(n,a),this._onUpdateCallback&&this._onUpdateCallback(this._object,h),c==="repeat"||c==="about-to-repeat")this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1;else if(c==="completed"){this._isPlaying=!1,this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var u=0,d=this._chainedTweens.length;u<d;u++)this._chainedTweens[u].start(this._startTime+this._duration,!1)}return c!=="completed"},i.prototype._calculateElapsedPortion=function(t,e,r){if(this._duration===0||t>r)return 1;var s=t%e,n=Math.min(s/this._duration,1);return n===0&&t!==0&&t%this._duration===0?1:n},i.prototype._calculateCompletionStatus=function(t,e){return this._duration!==0&&t<this._duration?"playing":this._repeat<=0?"completed":t===this._duration?"about-to-repeat":"repeat"},i.prototype._processRepetition=function(t,e){var r=Math.min(Math.trunc((t-this._duration)/e)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=r);for(var s in this._valuesStartRepeat){var n=this._valuesEnd[s];!this._yoyo&&typeof n=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(n)),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s]}this._yoyo&&(this._reversed=!this._reversed),this._startTime+=e*r},i.prototype._updateProperties=function(t,e,r,s){for(var n in r)if(e[n]!==void 0){var a=e[n]||0,o=r[n],h=Array.isArray(t[n]),l=Array.isArray(o),c=!h&&l;c?t[n]=this._interpolationFunction(o,s):typeof o=="object"&&o?this._updateProperties(t[n],a,o,s):(o=this._handleRelativeValue(a,o),typeof o=="number"&&(t[n]=a+(o-a)*s))}},i.prototype._handleRelativeValue=function(t,e){return typeof e!="string"?e:e.charAt(0)==="+"||e.charAt(0)==="-"?t+parseFloat(e):parseFloat(e)},i.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],r=this._valuesEnd[t];typeof r=="string"?this._valuesStartRepeat[t]=this._valuesStartRepeat[t]+parseFloat(r):this._valuesStartRepeat[t]=this._valuesEnd[t],this._valuesEnd[t]=e},i}(),pe=Da;pe.getAll.bind(pe),pe.removeAll.bind(pe),pe.add.bind(pe),pe.remove.bind(pe),pe.update.bind(pe);class My{constructor(){B(this,"assets",{})}async initialize(t){this.assets=Object.fromEntries(Array.from(Object.entries(t??{})).map(([e,r])=>[e,new Audio(r.src)]))}play(t){const e=this.assets[t];e&&(e.volume=.2,e.pause(),e.currentTime=0,e.play())}}const Ec=new My;var Dt=(i=>(i.Idle="Idle",i.Jump="Jump",i.Fall="Fall",i.Land="Land",i.Run="Run",i.Die="Die",i))(Dt||{});class Fy{constructor(){B(this,"spriteLoaderFn");B(this,"sprites",{})}initialize(t){this.spriteLoaderFn=t}async getSpriteData(t){const e=await this.spriteLoaderFn(t);if(!e)return;if(this.sprites[t])return this.sprites[t];const r=await Bi.load(e.image),s=new Sa({texture:r,data:e.sprite});return await s.parse(),this.sprites[t]={sheet:s,data:{...e.data,scale:e.data.scale??1}},this.sprites[t]}getAnimatedSprites(t){if(!t)throw Error("Sheet is not defined");if(!this.sprites[t])throw Error("Sprite is not loaded");const e=this.sprites[t].data,r=this.sprites[t].sheet,s={};for(const n of r.data.meta.frameTags??[]){if(!r.data.meta.layers)throw Error("Layers are not defined");const a={};for(const o of r.data.meta.layers){const h=[];for(let c=n.from;c<=n.to;c++){const u=c.toString(),d=e.name+"_"+o.name+"_"+u,f=r.textures[d],p=r.data.frames[d].duration;h.push({texture:f,time:p})}const l=new Ts(h);l.texture.baseTexture.scaleMode=$t.NEAREST,a[o.name]=l}n.name&&(s[n.name]=a)}return s}}const Oa=new Fy;var ci={},Ac={},Re={};Object.defineProperty(Re,"__esModule",{value:!0}),Re.loop=Re.conditional=Re.parse=void 0;var By=function i(t,e){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:r;if(Array.isArray(e))e.forEach(function(a){return i(t,a,r,s)});else if(typeof e=="function")e(t,r,s,i);else{var n=Object.keys(e)[0];Array.isArray(e[n])?(s[n]={},i(t,e[n],r,s[n])):s[n]=e[n](t,r,s,i)}return r};Re.parse=By;var Dy=function(t,e){return function(r,s,n,a){e(r,s,n)&&a(r,t,s,n)}};Re.conditional=Dy;var Oy=function(t,e){return function(r,s,n,a){for(var o=[],h=r.pos;e(r,s,n);){var l={};if(a(r,t,s,l),r.pos===h)break;h=r.pos,o.push(l)}return o}};Re.loop=Oy;var ft={};Object.defineProperty(ft,"__esModule",{value:!0}),ft.readBits=ft.readArray=ft.readUnsigned=ft.readString=ft.peekBytes=ft.readBytes=ft.peekByte=ft.readByte=ft.buildStream=void 0;var Ly=function(t){return{data:t,pos:0}};ft.buildStream=Ly;var Sc=function(){return function(t){return t.data[t.pos++]}};ft.readByte=Sc;var Ny=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(e){return e.data[e.pos+t]}};ft.peekByte=Ny;var Ps=function(t){return function(e){return e.data.subarray(e.pos,e.pos+=t)}};ft.readBytes=Ps;var ky=function(t){return function(e){return e.data.subarray(e.pos,e.pos+t)}};ft.peekBytes=ky;var Uy=function(t){return function(e){return Array.from(Ps(t)(e)).map(function(r){return String.fromCharCode(r)}).join("")}};ft.readString=Uy;var Gy=function(t){return function(e){var r=Ps(2)(e);return t?(r[1]<<8)+r[0]:(r[0]<<8)+r[1]}};ft.readUnsigned=Gy;var Hy=function(t,e){return function(r,s,n){for(var a=typeof e=="function"?e(r,s,n):e,o=Ps(t),h=new Array(a),l=0;l<a;l++)h[l]=o(r);return h}};ft.readArray=Hy;var $y=function(t,e,r){for(var s=0,n=0;n<r;n++)s+=t[e+n]&&Math.pow(2,r-n-1);return s},Xy=function(t){return function(e){for(var r=Sc()(e),s=new Array(8),n=0;n<8;n++)s[7-n]=!!(r&1<<n);return Object.keys(t).reduce(function(a,o){var h=t[o];return h.length?a[o]=$y(s,h.index,h.length):a[o]=s[h.index],a},{})}};ft.readBits=Xy,function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var t=Re,e=ft,r={blocks:function(d){for(var f=0,p=[],m=d.data.length,g=0,_=(0,e.readByte)()(d);_!==f&&_;_=(0,e.readByte)()(d)){if(d.pos+_>=m){var x=m-d.pos;p.push((0,e.readBytes)(x)(d)),g+=x;break}p.push((0,e.readBytes)(_)(d)),g+=_}for(var y=new Uint8Array(g),v=0,T=0;T<p.length;T++)y.set(p[T],v),v+=p[T].length;return y}},s=(0,t.conditional)({gce:[{codes:(0,e.readBytes)(2)},{byteSize:(0,e.readByte)()},{extras:(0,e.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,e.readUnsigned)(!0)},{transparentColorIndex:(0,e.readByte)()},{terminator:(0,e.readByte)()}]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===249}),n=(0,t.conditional)({image:[{code:(0,e.readByte)()},{descriptor:[{left:(0,e.readUnsigned)(!0)},{top:(0,e.readUnsigned)(!0)},{width:(0,e.readUnsigned)(!0)},{height:(0,e.readUnsigned)(!0)},{lct:(0,e.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,t.conditional)({lct:(0,e.readArray)(3,function(u,d,f){return Math.pow(2,f.descriptor.lct.size+1)})},function(u,d,f){return f.descriptor.lct.exists}),{data:[{minCodeSize:(0,e.readByte)()},r]}]},function(u){return(0,e.peekByte)()(u)===44}),a=(0,t.conditional)({text:[{codes:(0,e.readBytes)(2)},{blockSize:(0,e.readByte)()},{preData:function(d,f,p){return(0,e.readBytes)(p.text.blockSize)(d)}},r]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===1}),o=(0,t.conditional)({application:[{codes:(0,e.readBytes)(2)},{blockSize:(0,e.readByte)()},{id:function(d,f,p){return(0,e.readString)(p.blockSize)(d)}},r]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===255}),h=(0,t.conditional)({comment:[{codes:(0,e.readBytes)(2)},r]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===254}),l=[{header:[{signature:(0,e.readString)(3)},{version:(0,e.readString)(3)}]},{lsd:[{width:(0,e.readUnsigned)(!0)},{height:(0,e.readUnsigned)(!0)},{gct:(0,e.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,e.readByte)()},{pixelAspectRatio:(0,e.readByte)()}]},(0,t.conditional)({gct:(0,e.readArray)(3,function(u,d){return Math.pow(2,d.lsd.gct.size+1)})},function(u,d){return d.lsd.gct.exists}),{frames:(0,t.loop)([s,o,h,n,a],function(u){var d=(0,e.peekByte)()(u);return d===33||d===44})}],c=l;i.default=c}(Ac);var Ms={};Object.defineProperty(Ms,"__esModule",{value:!0}),Ms.deinterlace=void 0;var zy=function(t,e){for(var r=new Array(t.length),s=t.length/e,n=function(d,f){var p=t.slice(f*e,(f+1)*e);r.splice.apply(r,[d*e,e].concat(p))},a=[0,4,2,1],o=[8,8,4,2],h=0,l=0;l<4;l++)for(var c=a[l];c<s;c+=o[l])n(c,h),h++;return r};Ms.deinterlace=zy;var Fs={};Object.defineProperty(Fs,"__esModule",{value:!0}),Fs.lzw=void 0;var Vy=function(t,e,r){var s=4096,n=-1,a=r,o,h,l,c,u,d,f,C,p,m,T,g,E,w,N,R,_=new Array(r),x=new Array(s),y=new Array(s),v=new Array(s+1);for(g=t,h=1<<g,u=h+1,o=h+2,f=n,c=g+1,l=(1<<c)-1,p=0;p<h;p++)x[p]=0,y[p]=p;var T,C,E,w,R,N;for(T=C=E=w=R=N=0,m=0;m<a;){if(w===0){if(C<c){T+=e[N]<<C,C+=8,N++;continue}if(p=T&l,T>>=c,C-=c,p>o||p==u)break;if(p==h){c=g+1,l=(1<<c)-1,o=h+2,f=n;continue}if(f==n){v[w++]=y[p],f=p,E=p;continue}for(d=p,p==o&&(v[w++]=E,p=f);p>h;)v[w++]=y[p],p=x[p];E=y[p]&255,v[w++]=E,o<s&&(x[o]=f,y[o]=E,o++,!(o&l)&&o<s&&(c++,l+=o)),f=d}w--,_[R++]=v[w],m++}for(m=R;m<a;m++)_[m]=0;return _};Fs.lzw=Vy,Object.defineProperty(ci,"__esModule",{value:!0});var Cc=ci.decompressFrames=ci.decompressFrame=Ic=ci.parseGIF=void 0,Wy=Zy(Ac),jy=Re,Yy=ft,qy=Ms,Ky=Fs;function Zy(i){return i&&i.__esModule?i:{default:i}}var Jy=function(t){var e=new Uint8Array(t);return(0,jy.parse)((0,Yy.buildStream)(e),Wy.default)},Ic=ci.parseGIF=Jy,Qy=function(t){for(var e=t.pixels.length,r=new Uint8ClampedArray(e*4),s=0;s<e;s++){var n=s*4,a=t.pixels[s],o=t.colorTable[a]||[0,0,0];r[n]=o[0],r[n+1]=o[1],r[n+2]=o[2],r[n+3]=a!==t.transparentIndex?255:0}return r},Rc=function(t,e,r){if(!t.image){console.warn("gif frame does not have associated image.");return}var s=t.image,n=s.descriptor.width*s.descriptor.height,a=(0,Ky.lzw)(s.data.minCodeSize,s.data.blocks,n);s.descriptor.lct.interlaced&&(a=(0,qy.deinterlace)(a,s.descriptor.width));var o={pixels:a,dims:{top:t.image.descriptor.top,left:t.image.descriptor.left,width:t.image.descriptor.width,height:t.image.descriptor.height}};return s.descriptor.lct&&s.descriptor.lct.exists?o.colorTable=s.lct:o.colorTable=e,t.gce&&(o.delay=(t.gce.delay||10)*10,o.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(o.transparentIndex=t.gce.transparentColorIndex)),r&&(o.patch=Qy(o)),o};ci.decompressFrame=Rc;var t_=function(t,e){return t.frames.filter(function(r){return r.image}).map(function(r){return Rc(r,t.gct,e)})};Cc=ci.decompressFrames=t_;const dr=class extends ue{constructor(i,t){super(L.EMPTY),this.animationSpeed=1,this.loop=!0,this.duration=0,this.autoPlay=!0,this.dirty=!1,this._currentFrame=0,this._autoUpdate=!1,this._isConnectedToTicker=!1,this._playing=!1,this._currentTime=0;const{scaleMode:e,width:r,height:s,...n}=Object.assign({},dr.defaultOptions,t),a=document.createElement("canvas"),o=a.getContext("2d");a.width=r,a.height=s,this.texture=L.from(a,{scaleMode:e}),this.duration=i[i.length-1].end,this._frames=i,this._context=o,this._playing=!1,this._currentTime=0,this._isConnectedToTicker=!1,Object.assign(this,n),this.currentFrame=0,n.autoPlay&&this.play()}static fromBuffer(i,t){if(!i||i.byteLength===0)throw new Error("Invalid buffer");const e=g=>{let _=null;for(const x of g.frames)_=x.gce??_,"image"in x&&!("gce"in x)&&(x.gce=_)},r=Ic(i);e(r);const s=Cc(r,!0),n=[],a=document.createElement("canvas"),o=a.getContext("2d",{willReadFrequently:!0}),h=document.createElement("canvas"),l=h.getContext("2d");a.width=r.lsd.width,a.height=r.lsd.height;let c=0,u=null;const{fps:d}=Object.assign({},dr.defaultOptions,t),f=1e3/d;for(let g=0;g<s.length;g++){const{disposalType:_=2,delay:x=f,patch:y,dims:{width:v,height:T,left:C,top:E}}=s[g];h.width=v,h.height=T,l.clearRect(0,0,v,T);const w=l.createImageData(v,T);w.data.set(y),l.putImageData(w,0,0),_===3&&(u=o.getImageData(0,0,a.width,a.height)),o.drawImage(h,C,E);const R=o.getImageData(0,0,a.width,a.height);_===2?o.clearRect(0,0,a.width,a.height):_===3&&o.putImageData(u,0,0),n.push({start:c,end:c+x,imageData:R}),c+=x}a.width=a.height=0,h.width=h.height=0;const{width:p,height:m}=r.lsd;return new dr(n,{width:p,height:m,...t})}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(dt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(dt.shared.add(this.update,this,Se.HIGH),this._isConnectedToTicker=!0),!this.loop&&this.currentFrame===this._frames.length-1&&(this._currentTime=0))}get progress(){return this._currentTime/this.duration}get playing(){return this._playing}update(i){var n,a;if(!this._playing)return;const t=this.animationSpeed*i/F.TARGET_FPMS,e=this._currentTime+t,r=e%this.duration,s=this._frames.findIndex(o=>o.start<=r&&o.end>r);e>=this.duration?this.loop?(this._currentTime=r,this.updateFrameIndex(s),(n=this.onLoop)==null||n.call(this)):(this._currentTime=this.duration,this.updateFrameIndex(this._frames.length-1),(a=this.onComplete)==null||a.call(this),this.stop()):(this._currentTime=r,this.updateFrameIndex(s))}updateFrame(){if(!this.dirty)return;const{imageData:i}=this._frames[this._currentFrame];this._context.putImageData(i,0,0),this._context.fillStyle="transparent",this._context.fillRect(0,0,0,1),this.texture.update(),this.dirty=!1}_render(i){this.updateFrame(),super._render(i)}_renderCanvas(i){this.updateFrame(),super._renderCanvas(i)}get autoUpdate(){return this._autoUpdate}set autoUpdate(i){i!==this._autoUpdate&&(this._autoUpdate=i,!this._autoUpdate&&this._isConnectedToTicker?(dt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(dt.shared.add(this.update,this),this._isConnectedToTicker=!0))}get currentFrame(){return this._currentFrame}set currentFrame(i){this.updateFrameIndex(i),this._currentTime=this._frames[i].start}updateFrameIndex(i){var t;if(i<0||i>=this._frames.length)throw new Error(`Frame index out of range, expecting 0 to ${this.totalFrames}, got ${i}`);this._currentFrame!==i&&(this._currentFrame=i,this.dirty=!0,(t=this.onFrameChange)==null||t.call(this,i))}get totalFrames(){return this._frames.length}destroy(){this.stop(),super.destroy(!0);const i=null;this._context=i,this._frames=i,this.onComplete=i,this.onFrameChange=i,this.onLoop=i}clone(){return new dr([...this._frames],{autoUpdate:this._autoUpdate,loop:this.loop,autoPlay:this.autoPlay,scaleMode:this.texture.baseTexture.scaleMode,animationSpeed:this.animationSpeed,width:this._context.canvas.width,height:this._context.canvas.height,onComplete:this.onComplete,onFrameChange:this.onFrameChange,onLoop:this.onLoop})}};let La=dr;La.defaultOptions={scaleMode:$t.LINEAR,fps:30,loop:!0,animationSpeed:1,autoPlay:!0,autoUpdate:!0,onComplete:null,onFrameChange:null,onLoop:null};const e_={extension:P.Asset,detection:{test:async()=>!0,add:async i=>[...i,"gif"],remove:async i=>i.filter(t=>t!=="gif")},loader:{test:i=>xt.extname(i)===".gif",load:async(i,t)=>{const r=await(await F.ADAPTER.fetch(i)).arrayBuffer();return La.fromBuffer(r,t==null?void 0:t.data)},unload:async i=>{i.destroy()}}};k.add(e_);const Pc={};class i_{constructor(){B(this,"container",new bt);B(this,"emotes",[]);B(this,"moveSpeed",50);B(this,"alphaSpeed",1);B(this,"scaleSpeed",.5);B(this,"timer")}async add(t){const e=Pc[t];let r;if(e)r=e.clone();else{const s=await fetch(t),n=s.headers.get("content-type");switch(n){case"image/gif":{const a=await s.arrayBuffer();r=La.fromBuffer(a),Pc[t]=r;break}case"image/png":{r=ue.from(t);break}default:{console.warn("Unsupported content type: ",n);return}}}r&&(r.anchor.set(.5,.5),r.scale.set(0,0),this.emotes.push(r))}isAnimatedGIF(t){return t.currentFrame}update(t){var e;(e=this.timer)==null||e.tick(),(!this.timer||this.timer.isCompleted)&&this.emotes.length>0&&(this.timer=new Ve(2e3,()=>{const r=this.emotes.shift();r&&(this.isAnimatedGIF(r)&&(r.currentFrame=0),this.container.addChild(r))})),this.container.position.x=t.position.x??this.container.position.x,this.container.position.y=t.position.y??this.container.position.y;for(const r of this.container.children)r.position.y-=ze*this.moveSpeed/1e3,r.scale.x+=ze*this.scaleSpeed/1e3,r.scale.y+=ze*this.scaleSpeed/1e3,r.scale.x>1&&(r.alpha-=ze*this.alphaSpeed/1e3),r.alpha<=0&&this.container.removeChild(r)}}class r_{constructor(t){B(this,"container",new bt);B(this,"animated",new bt);B(this,"text",new bs(void 0,{fontFamily:"Custom Font",fontSize:20,fill:2236962,align:"left",breakWords:!0,wordWrap:!0,wordWrapWidth:200}));B(this,"padding",10);B(this,"borderRadius",10);B(this,"boxColor",15658734);B(this,"fadeShift",10);B(this,"isChecking",!0);B(this,"messageQueue",[]);B(this,"showTween");B(this,"hideTween");B(this,"timer");this.beforeShow=t,this.container.addChild(this.animated),this.text.anchor.set(.5,1),this.text.position.set(0,-this.padding)}trim(t){const e=Ce.measureText(t.text,t.style);return e.lines.length>4?e.lines.slice(0,4).join(" ").slice(0,-3)+"...":t.text}update(t){var r,s,n,a,o;if((r=this.timer)==null||r.tick(),(s=this.showTween)==null||s.update(),(n=this.hideTween)==null||n.update(),this.isChecking&&this.messageQueue.length>0){this.isChecking=!1;const h=this.messageQueue.shift();h&&(this.beforeShow(),this.show(h))}this.container.position.x=t.position.x??this.container.position.x,this.container.position.y=t.position.y??this.container.position.y;const e=((a=this.showTween)==null?void 0:a.isPlaying())||((o=this.hideTween)==null?void 0:o.isPlaying());!this.isChecking&&!e&&this.timer&&(this.animated.position.y=Math.sin(this.timer.current*.0025)*4-2)}add(t){this.messageQueue.push(t)}drawBox(t){const e={x:t.x-this.padding-t.width*t.anchor.x,y:t.y-this.padding-t.height*t.anchor.y,w:t.width+this.padding*2,h:t.height+this.padding*2},r=new ba;return r.beginFill(this.boxColor),r.drawRoundedRect(e.x,e.y,e.w,e.h,this.borderRadius),r.drawPolygon({x:e.x+e.w/2-10,y:e.y+e.h},{x:e.x+e.w/2+10,y:e.y+e.h},{x:e.x+e.w/2,y:e.y+e.h+10-4}),r.endFill(),r}show(t){this.text.text=t,this.text.text=this.trim(this.text),this.animated.alpha=0,this.animated.position.y=this.fadeShift;const e=this.drawBox(this.text);this.animated.removeChildren(),this.animated.addChild(e,this.text);const r={alpha:1,y:this.animated.y-this.fadeShift},s={alpha:0,y:this.animated.y+this.fadeShift};this.hideTween=new ki(this.animated).to(s,500).onComplete(()=>{this.isChecking=!0}),this.showTween=new ki(this.animated).to(r,500).onComplete(()=>{this.timer=new Ve(1e4,()=>{var n;(n=this.hideTween)==null||n.start()})}),this.showTween.start()}}class s_{constructor(){B(this,"text",new bs(void 0,{fontFamily:"Custom Font",fontSize:18,fill:16777215,align:"center",lineJoin:"round",strokeThickness:4,stroke:"black"}));this.text.anchor.set(.5,1),this.text.zIndex=100}update(t){this.text.text=t.name??"",this.text.visible=t.isVisible,this.text.position.x=t.position.x??this.text.position.x,this.text.position.y=t.position.y??this.text.position.y}}class n_{constructor(t){B(this,"container",new bt);B(this,"sprites");this.sprites=t,this.container.sortableChildren=!0;let e=0;for(const r in this.sprites){const s=this.sprites[r];this.container.addChild(s),s.zIndex=++e,s.anchor.set(.5,0),s.autoUpdate=!1,s.play()}}update(t){for(const e in this.sprites){const r=this.sprites[e];if(t.play&&r.update(ze*.06),t.color){for(const s in t.color)if(s==e){const n=t.color[s];n&&(r.alpha=n.alpha,r.tint=n)}}t.scale.x&&(r.animationSpeed=4/Math.abs(t.scale.x))}this.container.scale.set(t.scale.x,t.scale.y)}}class a_{constructor(){B(this,"container",new bt);B(this,"timer");B(this,"sprite");B(this,"opacityStep",.1);B(this,"shadowStep",50);Jt.stage.addChild(this.container)}setSprite(t){this.sprite=t}update(t){for(const e of this.container.children)e.alpha>0&&(e.alpha=e.alpha-this.opacityStep);if(this.timer&&!this.timer.isCompleted)this.timer.tick();else if(t.play){this.timer=new Ve(this.shadowStep);const e=new bt;if(this.sprite)for(const r in this.sprite.sprites){const s=this.sprite.sprites[r],n=s.texture.clone(),a=new ue(n);a.anchor.set(.5,0),a.alpha=s.alpha,a.tint=s.tint,e.addChild(a),e.scale.set(this.sprite.container.scale.x,this.sprite.container.scale.y),e.pivot.set(this.sprite.container.pivot.x,this.sprite.container.pivot.y);const o=this.sprite.container.getGlobalPosition();e.position.set(o.x,o.y)}this.container.addChild(e)}}}class fr{constructor(){B(this,"container",new bt);B(this,"userState",{});B(this,"state",{name:"",sprite:"",color:new tt("#969696"),direction:1,scale:1,isAnonymous:!1,zIndex:0});B(this,"animationState",Dt.Idle);B(this,"sprite");B(this,"spriteData",{name:"evotar",collider:{x:0,y:0,w:0,h:0},size:{w:0,h:0},scale:1,flip:!1,colored:[]});B(this,"animatedSprites");B(this,"trail",new a_);B(this,"name",new s_);B(this,"message",new r_(()=>{this.state.zIndex=We.zIndexEvotarMax(this.container.zIndex)}));B(this,"emoteSpitter",new i_);B(this,"velocity",{x:0,y:0});B(this,"runSpeed",.05);B(this,"gravity",.2);B(this,"dashAcc",3);B(this,"isJumping",!1);B(this,"isDashing",!1);B(this,"isDespawned",!1);B(this,"landTimer");B(this,"stateTimer");B(this,"scaleTimer");B(this,"spawnTween");B(this,"fadeTween");B(this,"scaleTween");B(this,"appBounds",{left:80,right:Jt.renderer.width-80});this.container.addChild(this.name.text),this.container.addChild(this.emoteSpitter.container),this.container.addChild(this.message.container),this.container.sortableChildren=!0}spawn(t={isFalling:!1}){const e=this.spriteData.collider,r=-(e.y+e.h-this.spriteData.size.h/2),s=t.isFalling?r:Jt.renderer.height,n=this.spriteData.size.w*this.state.scale*this.spriteData.scale,a=t.positionX!=null?t.positionX*this.appBounds.right:Math.random()*(this.appBounds.right-n)+n/2,o=s*this.state.scale*this.spriteData.scale;if(this.container.x=a,this.container.y=o,this.state.direction=Math.random()>.5?1:-1,!t.isFalling){const h=We.zIndexEvotarMin(this.container.zIndex);this.state.zIndex=h,this.container.alpha=0,this.spawnTween=new ki(this.container).to({alpha:1},500).onComplete(t.onComplete).start()}this.stateTimer=new Ve(5e3,()=>{this.isJumping||this.setAnimationState(Dt.Run)})}despawn(t={}){this.fadeTween&&this.fadeTween.isPlaying()||(this.fadeTween=new ki(this.container).to({alpha:0},1e3).onComplete(()=>{this.isDespawned=!0,t.onComplete&&t.onComplete()}).start())}scale(t){this.scaleTween&&this.scaleTween.isPlaying()||this.scaleTimer&&!this.scaleTimer.isCompleted||(this.scaleTween=new ki(this).to({state:{scale:t.value??2}},2e3).onComplete(()=>{this.scaleTimer=new Ve((t.duration??10)*1e3,()=>{this.scaleTween=new ki(this).to({state:{scale:1}},2e3).start()})}).start())}jump(t){this.isDespawned||this.isJumping||(this.isJumping=!0,this.velocity.x=this.state.direction*(t.velocityX??3.5),this.velocity.y=t.velocityY??-8,this.setAnimationState(Dt.Jump),Ec.play("jump"))}dash(t){this.isDespawned||this.isDashing||(this.isDashing=!0,this.velocity.x=this.state.direction*(t.force??14))}async setSprite(t){if(t&&t!=this.state.sprite){const e=await Oa.getSpriteData(t);if(!e)return;this.state.sprite=t,this.spriteData=e.data,this.animatedSprites=Oa.getAnimatedSprites(t),this.setAnimationState(this.animationState,!0)}}async setProps(t){t.sprite&&await this.setSprite(t.sprite),this.state={...this.state,...t}}setUserProps(t){this.userState={...this.userState,...t}}move(){var r;const t=this.spriteData.collider,e={x:this.container.position.x,y:this.container.position.y};if(this.isDashing){const s=Math.sign(this.velocity.x);this.velocity.x=this.velocity.x-s*this.dashAcc/Math.abs(this.velocity.x),s!=Math.sign(this.velocity.x)?(this.isDashing=!1,this.velocity.x=0):e.x+=this.velocity.x}else{if((r=this.stateTimer)!=null&&r.isCompleted&&(this.stateTimer=new Ve(Math.random()*5e3,()=>{this.animationState==Dt.Idle?this.setAnimationState(Dt.Run):this.animationState==Dt.Run&&this.setAnimationState(Dt.Idle)})),this.animationState==Dt.Run){const s=this.runSpeed*this.state.direction;this.velocity.x=s*ze}this.velocity.y=this.velocity.y+this.gravity,e.x+=this.velocity.x,e.y+=this.velocity.y,this.isOnGround(e.y)&&(this.velocity.y=0,this.velocity.x=0,e.y=Jt.renderer.height,this.animationState==Dt.Fall&&(this.setAnimationState(Dt.Land),this.landTimer=new Ve(200,()=>{this.setAnimationState(Dt.Idle),this.isJumping=!1}))),this.velocity.y>0&&this.setAnimationState(Dt.Fall)}if(this.animationState!=Dt.Idle||this.isDashing){const s=t.w/2*this.state.scale*this.spriteData.scale,n=this.container.x-s<this.appBounds.left,a=this.container.x+s>this.appBounds.right;(n||a)&&(this.state.direction=-this.state.direction,this.velocity.x=-this.velocity.x,n&&(e.x=this.appBounds.left+s),a&&(e.x=this.appBounds.right-s))}this.container.position.set(e.x,e.y)}update(){var e,r,s,n,a,o;if(this.isDespawned)return;(e=this.landTimer)==null||e.tick(),(r=this.stateTimer)==null||r.tick(),(s=this.scaleTimer)==null||s.tick(),(n=this.fadeTween)==null||n.update(),(a=this.spawnTween)==null||a.update(),(o=this.scaleTween)==null||o.update(),this.container.zIndex=this.state.zIndex;const t=this.spriteData.collider;if(this.name.update({name:this.state.name,isVisible:!this.state.isAnonymous,position:{y:-t.h*this.state.scale*this.spriteData.scale}}),this.message.update({position:{y:this.name.text.position.y-this.name.text.height-6}}),this.emoteSpitter.update({position:{y:this.message.container.position.y-this.message.container.height}}),this.move(),this.sprite){const h=Object.fromEntries(this.spriteData.colored.map(c=>[c,this.userState.color?this.userState.color:this.state.color])),l=this.spriteData.flip?this.state.direction:1;this.sprite.update({color:h,scale:{x:l*this.state.scale*this.spriteData.scale,y:this.state.scale*this.spriteData.scale},play:!this.isDashing})}this.trail.update({play:this.isDashing})}isOnGround(t){return t>Jt.renderer.height}addMessage(t){var e;this.message.add(t),this.state.isAnonymous=!1,(e=this.fadeTween)==null||e.stop(),this.fadeTween=void 0,this.container.alpha=1}async spitEmotes(t){for(const e of t)await this.emoteSpitter.add(e)}async setAnimationState(t,e=!1){if(this.animationState==t&&!e||!this.animatedSprites)return;this.animationState=t,this.sprite&&this.container.removeChild(this.sprite.container);const r=this.animatedSprites[this.animationState]??this.animatedSprites[Dt.Idle];this.sprite=new n_(r),this.trail.setSprite(this.sprite),this.sprite.container.pivot.set(0,this.spriteData.collider.y+this.spriteData.collider.h),this.container.addChild(this.sprite.container)}}const o_=1e3*60*5;class h_{constructor(){B(this,"viewers",{});B(this,"raiders",[]);B(this,"lastEvotarActivity",{});B(this,"subscriptions",[]);B(this,"hasActivity",t=>!!this.lastEvotarActivity[t])}subscribe(t){this.subscriptions.push(t)}update(){for(const t in this.viewers){const e=this.viewers[t];e&&e.update()}for(const t of this.raiders)t.update()}processRaid(t){if(!Jt.settings.fallingRaiders)return;const e=1/t.viewers.count*5e3;for(let a=0;a<t.viewers.count;a++){const o=new fr;o.setProps({isAnonymous:!0,zIndex:-1,sprite:t.viewers.sprite,color:new tt(t.broadcaster.info.color)}),Fa.add(e*a,()=>{this.addRaider(o),o.spawn({isFalling:!0})}),Fa.add(a*e+6e4,()=>{o.despawn({onComplete:()=>{this.deleteRaider(o)}})})}const r=this.viewers[t.broadcaster.id],s={...this.prepareEvotarProps(t.broadcaster.info.displayName,t.broadcaster.info.color,t.broadcaster.info.sprite),scale:2},n=()=>{const a=new fr;a.setProps(s),this.addViewer(t.broadcaster.id,a),a.spawn({isFalling:!0,positionX:.5})};this.lastEvotarActivity[t.broadcaster.id]=performance.now(),r?r.despawn({onComplete:()=>{n()}}):n()}async processChatters(t){for(const e in this.viewers){const r=this.lastEvotarActivity[e],s=!!r&&performance.now()-r<o_;if(t.every(n=>n.userId!=e)&&!s){const n=this.viewers[e];n&&n.despawn({onComplete:()=>{this.deleteViewer(e,n)}})}}if(Jt.settings.showAnonymousEvotars){for(const e of t)if(!this.viewers[e.userId]){const s={name:e.name,isAnonymous:!this.hasActivity(e.userId)},n=new fr;await n.setProps(s),n.spawn(),this.addViewer(e.userId,n)}}}doAction(t,e){if(uc(t)&&e.jump({velocityX:t.data.velocityX,velocityY:t.data.velocityY,cooldown:t.cooldown}),pc(t)&&e.dash({force:t.data.force,cooldown:t.cooldown}),dc(t)){const r=$(t.data.color);r&&r.isValid()&&e.setUserProps({color:new tt(t.data.color)})}fc(t)&&e.scale({value:t.data.scale,duration:t.data.duration,cooldown:t.cooldown}),mc(t)&&e.setSprite(t.data.sprite)}prepareEvotarProps(t,e,r){const s={name:t,isAnonymous:!1};if(r&&(s.sprite=r),e)try{s.color=new tt(e)}catch{}return s}async processAction(t){const e=this.viewers[t.userId],r=this.prepareEvotarProps(t.info.displayName,t.info.color,t.info.sprite);if(e)await e.setProps(r),this.doAction(t,e);else{const s=new fr;await s.setProps(r),s.spawn({onComplete:()=>{const n=this.viewers[t.userId];n&&this.doAction(t,n)}}),this.addViewer(t.userId,s)}}async processMessage(t){const e=this.prepareEvotarProps(t.info.displayName,t.info.color,t.info.sprite);let r=this.viewers[t.userId];if(r)r.setProps(e);else{const s=Jt.settings.fallingEvotars?!this.hasActivity(t.userId):!1;r=new fr,await r.setProps(e),r.spawn({isFalling:s}),this.addViewer(t.userId,r)}this.lastEvotarActivity[t.userId]=performance.now(),t.message&&r.addMessage(t.message),t.emotes.length>0&&r.spitEmotes(t.emotes)}addViewer(t,e){this.subscriptions.forEach(r=>r.onAdd(e)),this.viewers[t]=e}deleteViewer(t,e){this.subscriptions.forEach(r=>r.onDelete(e)),delete this.viewers[t]}addRaider(t){this.subscriptions.forEach(e=>e.onAdd(t)),this.raiders.push(t)}deleteRaider(t){this.subscriptions.forEach(e=>e.onDelete(t)),this.raiders=this.raiders.filter(e=>e!=t)}zIndexEvotarMax(t){return Object.values(this.viewers).reduce((e,r)=>r&&e<=r.container.zIndex?r.container.zIndex+1:e,t)}zIndexEvotarMin(t){return Object.values(this.viewers).reduce((e,r)=>r&&e>=r.container.zIndex?r.container.zIndex-1:e,t)}}const We=new h_;class l_{constructor(){B(this,"stage",new bt);B(this,"evotars",{});B(this,"chatterIds",[]);B(this,"settings",{});B(this,"renderer")}async initialize(t,e){Oa.initialize(e.spriteLoaderFn),Ec.initialize(e.sounds),e.font&&await Bi.load({src:e.font,data:{family:"Custom Font"}}),this.renderer=new ss({width:t.clientWidth,height:t.clientHeight,backgroundAlpha:0}),t.appendChild(this.renderer.view),window.onresize=()=>{this.renderer.resize(t.clientWidth,t.clientHeight)},this.stage.sortableChildren=!0,We.subscribe({onAdd:r=>this.stage.addChild(r.container),onDelete:r=>{this.stage.removeChild(r.container),this.stage.removeChild(r.trail.container)}})}updateSettings(t){this.settings=t}update(){Fa.tick(),We.update(),this.renderer.render(this.stage)}}const Jt=new l_;class c_{constructor(t,e){B(this,"isRendered",!1);B(this,"processMessage",t=>We.processMessage(t));B(this,"processAction",t=>We.processAction(t));B(this,"processChatters",t=>We.processChatters(t));B(this,"processRaid",t=>We.processRaid(t));this.root=t,this.options=e}updateSettings(t){Jt.updateSettings(t)}async run(){if(this.isRendered)return;this.isRendered=!0,await(async()=>{await Jt.initialize(this.root,this.options),performance.now();let e=-1;const s=1e3/60;requestAnimationFrame(n);function n(a=performance.now()){const o=a-e|0;o>s&&(e=a-o%s,Jt.update()),requestAnimationFrame(n)}})()}}Ct.Evotars=c_,Ct.isColorUserActionEntity=dc,Ct.isDashUserActionEntity=pc,Ct.isGrowUserActionEntity=fc,Ct.isJumpUserActionEntity=uc,Ct.isSpriteUserActionEntity=mc,Object.defineProperty(Ct,Symbol.toStringTag,{value:"Module"})});
|
|
972
|
+
return alpha;
|
|
973
|
+
}
|
|
974
|
+
`}};class Ng extends At{constructor(){const t=new xt({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}}),e=Ht(),i=as({name:"sdf-shader",bits:[Dr,Hr(e),Dg,Lg,hs]}),r=os({name:"sdf-shader",bits:[Or,zr(e),Og,Hg,cs]});super({glProgram:r,gpuProgram:i,resources:{localUniforms:t,batchSamplers:Wr(e)}})}}class Mc{constructor(t){this._gpuBitmapText={},this._renderer=t}validateRenderable(t){const e=this._getGpuBitmapText(t);return t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,e)),this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const i=this._getGpuBitmapText(t);Bc(t,i),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,i)),this._renderer.renderPipes.graphics.addRenderable(i,e),i.context.customShader&&this._updateDistanceField(t)}destroyRenderable(t){this._destroyRenderableByUid(t.uid)}_destroyRenderableByUid(t){$.return(this._gpuBitmapText[t]),this._gpuBitmapText[t]=null}updateRenderable(t){const e=this._getGpuBitmapText(t);Bc(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){var f;const{context:i}=e,r=Fr.getFont(t.text,t._style);i.clear(),r.distanceField.type!=="none"&&(i.customShader||(this._sdfShader||(this._sdfShader=new Ng),i.customShader=this._sdfShader));const n=Array.from(t.text),a=t._style;let o=(((f=a._stroke)==null?void 0:f.width)||0)/2;o+=r.baseLineOffset;const h=ko(n,a,r);let c=0;const l=a.padding,u=h.scale;i.translate(-t._anchor._x*h.width-l,-t._anchor._y*(h.height+h.offsetY)-l).scale(u,u);const d=a._fill.color;for(let p=0;p<h.lines.length;p++){const g=h.lines[p];for(let m=0;m<g.charPositions.length;m++){const _=n[c++],x=r.chars[_];x!=null&&x.texture&&i.texture(x.texture,d||"black",Math.round(g.charPositions[m]+x.xOffset),Math.round(o+x.yOffset))}o+=r.lineHeight}}_getGpuBitmapText(t){return this._gpuBitmapText[t.uid]||this.initGpuText(t)}initGpuText(t){const e=$.get(rs);return this._gpuBitmapText[t.uid]=e,this._updateContext(t,e),t.on("destroyed",()=>{this.destroyRenderable(t)}),this._gpuBitmapText[t.uid]}_updateDistanceField(t){const e=this._getGpuBitmapText(t).context,i=t._style.fontFamily,r=K.get(`${i}-bitmap`),{a:n,b:a,c:o,d:h}=t.groupTransform,c=Math.sqrt(n*n+a*a),l=Math.sqrt(o*o+h*h),u=(Math.abs(c)+Math.abs(l))/2,d=r.baseRenderedFontSize/t._style.fontSize,f=t.resolution??this._renderer.resolution,p=u*r.distanceField.range*(1/d)*f;e.customShader.resources.localUniforms.uniforms.uDistance=p}destroy(){var t;for(const e in this._gpuBitmapText)this._destroyRenderableByUid(e);this._gpuBitmapText=null,(t=this._sdfShader)==null||t.destroy(!0),this._sdfShader=null,this._renderer=null}}Mc.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"bitmapText"};function Bc(s,t){t.groupTransform=s.groupTransform,t.groupColorAlpha=s.groupColorAlpha,t.groupColor=s.groupColor,t.groupBlendMode=s.groupBlendMode,t.globalDisplayStatus=s.globalDisplayStatus,t.groupTransform=s.groupTransform,t.localDisplayStatus=s.localDisplayStatus,t.groupAlpha=s.groupAlpha,t._roundPixels=s._roundPixels}class Rc{constructor(t){this._gpuText=Object.create(null),this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),i=t._getKey();return e.textureNeedsUploading?(e.textureNeedsUploading=!1,!0):e.currentKey!==i}addRenderable(t){const i=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(i)}updateRenderable(t){const i=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),i.batcher.updateElement(i)}destroyRenderable(t){this._destroyRenderableById(t.uid)}_destroyRenderableById(t){const e=this._gpuText[t];this._renderer.htmlText.decreaseReferenceCount(e.currentKey),$.return(e.batchableSprite),this._gpuText[t]=null}_updateText(t){const e=t._getKey(),i=this._getGpuText(t),r=i.batchableSprite;i.currentKey!==e&&this._updateGpuText(t).catch(a=>{console.error(a)}),t._didTextUpdate=!1;const n=t._style.padding;Cs(r.bounds,t._anchor,r.texture,n)}async _updateGpuText(t){t._didTextUpdate=!1;const e=this._getGpuText(t);if(e.generatingTexture)return;const i=t._getKey();this._renderer.htmlText.decreaseReferenceCount(e.currentKey),e.generatingTexture=!0,e.currentKey=i;const r=t.resolution??this._renderer.resolution,n=await this._renderer.htmlText.getManagedTexture(t.text,r,t._style,t._getKey()),a=e.batchableSprite;a.texture=e.texture=n,e.generatingTexture=!1,e.textureNeedsUploading=!0,t.onViewUpdate();const o=t._style.padding;Cs(a.bounds,t._anchor,a.texture,o)}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){const e={texture:M.EMPTY,currentKey:"--",batchableSprite:$.get(Qr),textureNeedsUploading:!1,generatingTexture:!1},i=e.batchableSprite;return i.renderable=t,i.texture=M.EMPTY,i.bounds={minX:0,maxX:1,minY:0,maxY:0},i.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuText[t.uid]=e,t.on("destroyed",()=>{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuText)this._destroyRenderableById(t);this._gpuText=null,this._renderer=null}}Rc.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"htmlText"};function zg(){const{userAgent:s}=L.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(s)}const Wg=new mt;function kc(s,t,e,i){const r=Wg;r.minX=0,r.minY=0,r.maxX=s.width/i|0,r.maxY=s.height/i|0;const n=Pt.getOptimalTexture(r.width,r.height,i,!1);return n.source.uploadMethodId="image",n.source.resource=s,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=t/i,n.frame.height=e/i,n.source.emit("update",n.source),n.updateUvs(),n}function Vg(s,t){const e=t.fontFamily,i=[],r={},n=/font-family:([^;"\s]+)/g,a=s.match(n);function o(h){r[h]||(i.push(h),r[h]=!0)}if(Array.isArray(e))for(let h=0;h<e.length;h++)o(e[h]);else o(e);a&&a.forEach(h=>{const c=h.split(":")[1].trim();o(c)});for(const h in t.tagStyles){const c=t.tagStyles[h].fontFamily;o(c)}return i}async function jg(s){const e=await(await L.get().fetch(s)).blob(),i=new FileReader;return await new Promise((n,a)=>{i.onloadend=()=>n(i.result),i.onerror=a,i.readAsDataURL(e)})}async function Ic(s,t){const e=await jg(t);return`@font-face {
|
|
975
|
+
font-family: "${s.fontFamily}";
|
|
976
|
+
src: url('${e}');
|
|
977
|
+
font-weight: ${s.fontWeight};
|
|
978
|
+
font-style: ${s.fontStyle};
|
|
979
|
+
}`}const hi=new Map;async function $g(s,t,e){const i=s.filter(r=>K.has(`${r}-and-url`)).map((r,n)=>{if(!hi.has(r)){const{url:a}=K.get(`${r}-and-url`);n===0?hi.set(r,Ic(t,a)):hi.set(r,Ic({fontWeight:e.fontWeight,fontStyle:e.fontStyle,fontFamily:r},a))}return hi.get(r)});return(await Promise.all(i)).join(`
|
|
980
|
+
`)}function Xg(s,t,e,i,r){const{domElement:n,styleElement:a,svgRoot:o}=r;n.innerHTML=`<style>${t.cssStyle}</style><div>${s}</div>`,n.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),a.textContent=i;const{width:h,height:c}=r.image;return o.setAttribute("width",h.toString()),o.setAttribute("height",c.toString()),new XMLSerializer().serializeToString(o)}function Yg(s,t){const e=qt.getOptimalCanvasAndContext(s.width,s.height,t),{context:i}=e;return i.clearRect(0,0,s.width,s.height),i.drawImage(s,0,0),qt.returnCanvasAndContext(e),e.canvas}function Kg(s,t,e){return new Promise(async i=>{e&&await new Promise(r=>setTimeout(r,100)),s.onload=()=>{i()},s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,s.crossOrigin="anonymous"})}class dn{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===Lt.WEBGPU}getTexture(t){return this._buildTexturePromise(t.text,t.resolution,t.style)}getManagedTexture(t,e,i,r){if(this._activeTextures[r])return this._increaseReferenceCount(r),this._activeTextures[r].promise;const n=this._buildTexturePromise(t,e,i).then(a=>(this._activeTextures[r].texture=a,a));return this._activeTextures[r]={texture:null,promise:n,usageCount:1},n}async _buildTexturePromise(t,e,i){const r=$.get(Lo),n=Vg(t,i),a=await $g(n,i,Gr.defaultTextStyle),o=Ap(t,i,a,r),h=Math.ceil(Math.ceil(Math.max(1,o.width)+i.padding*2)*e),c=Math.ceil(Math.ceil(Math.max(1,o.height)+i.padding*2)*e),l=r.image;l.width=h|0,l.height=c|0;const u=Xg(t,i,e,a,r);await Kg(l,u,zg()&&n.length>0);let d=l;this._createCanvas&&(d=Yg(l,e));const f=kc(d,l.width,l.height,e);return this._createCanvas&&this._renderer.texture.initSource(f.source),$.return(r),f}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e):e.promise.then(i=>{e.texture=i,this._cleanUp(e)}).catch(()=>{D("HTMLTextSystem: Failed to clean texture")}),this._activeTextures[t]=null))}_cleanUp(t){Pt.returnTexture(t.texture),t.texture.source.resource=null,t.texture.source.uploadMethodId="unknown"}getReferenceCount(t){return this._activeTextures[t].usageCount}destroy(){this._activeTextures=null}}dn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"htmlText"},dn.defaultFontOptions={fontFamily:"Arial",fontStyle:"normal",fontWeight:"normal"};class Fc{constructor(t){this._gpuText=Object.create(null),this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),i=t._getKey();if(e.currentKey!==i){const r=t.resolution??this._renderer.resolution,{width:n,height:a}=this._renderer.canvasText.getTextureSize(t.text,r,t._style);return!(this._renderer.canvasText.getReferenceCount(e.currentKey)===1&&n===e.texture._source.width&&a===e.texture._source.height)}return!1}addRenderable(t,e){const r=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(r)}updateRenderable(t){const i=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),i.batcher.updateElement(i)}destroyRenderable(t){this._destroyRenderableById(t.uid)}_destroyRenderableById(t){const e=this._gpuText[t];this._renderer.canvasText.decreaseReferenceCount(e.currentKey),$.return(e.batchableSprite),this._gpuText[t]=null}_updateText(t){const e=t._getKey(),i=this._getGpuText(t),r=i.batchableSprite;i.currentKey!==e&&this._updateGpuText(t),t._didTextUpdate=!1;const n=t._style.padding;Cs(r.bounds,t._anchor,r.texture,n)}_updateGpuText(t){const e=this._getGpuText(t),i=e.batchableSprite;e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),e.texture=i.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t._getKey(),i.texture=e.texture}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){const e={texture:null,currentKey:"--",batchableSprite:$.get(Qr)};return e.batchableSprite.renderable=t,e.batchableSprite.bounds={minX:0,maxX:1,minY:0,maxY:0},e.batchableSprite.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuText[t.uid]=e,this._updateText(t),t.on("destroyed",()=>{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuText)this._destroyRenderableById(t);this._gpuText=null,this._renderer=null}}Fc.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"text"};function Gc(s,t,e){for(let i=0,r=4*e*t;i<t;++i,r+=4)if(s[r+3]!==0)return!1;return!0}function Uc(s,t,e,i,r){const n=4*t;for(let a=i,o=i*n+4*e;a<=r;++a,o+=n)if(s[o+3]!==0)return!1;return!0}function qg(s,t=1){const{width:e,height:i}=s,r=s.getContext("2d",{willReadFrequently:!0});if(r===null)throw new TypeError("Failed to get canvas 2D context");const a=r.getImageData(0,0,e,i).data;let o=0,h=0,c=e-1,l=i-1;for(;h<i&&Gc(a,e,h);)++h;if(h===i)return Y.EMPTY;for(;Gc(a,e,l);)--l;for(;Uc(a,e,o,h,l);)++o;for(;Uc(a,e,c,h,l);)--c;return++c,++l,new Y(o/t,h/t,(c-o)/t,(l-h)/t)}class Dc{constructor(t){this._activeTextures={},this._renderer=t}getTextureSize(t,e,i){const r=Gt.measureText(t||" ",i);let n=Math.ceil(Math.ceil(Math.max(1,r.width)+i.padding*2)*e),a=Math.ceil(Math.ceil(Math.max(1,r.height)+i.padding*2)*e);return n=Math.ceil(n-1e-6),a=Math.ceil(a-1e-6),n=Te(n),a=Te(a),{width:n,height:a}}getTexture(t,e,i,r){typeof t=="string"&&(N("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:i,resolution:e}),t.style instanceof me||(t.style=new me(t.style));const{texture:n,canvasAndContext:a}=this.createTextureAndCanvas(t);return this._renderer.texture.initSource(n._source),qt.returnCanvasAndContext(a),n}createTextureAndCanvas(t){const{text:e,style:i}=t,r=t.resolution??this._renderer.resolution,n=Gt.measureText(e||" ",i),a=Math.ceil(Math.ceil(Math.max(1,n.width)+i.padding*2)*r),o=Math.ceil(Math.ceil(Math.max(1,n.height)+i.padding*2)*r),h=qt.getOptimalCanvasAndContext(a,o),{canvas:c}=h;this.renderTextToCanvas(e,i,r,h);const l=kc(c,a,o,r);if(i.trim){const u=qg(c,r);l.frame.copyFrom(u),l.updateUvs()}return{texture:l,canvasAndContext:h}}getManagedTexture(t){const e=t._getKey();if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const{texture:i,canvasAndContext:r}=this.createTextureAndCanvas(t);return this._activeTextures[e]={canvasAndContext:r,texture:i,usageCount:1},i}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];if(e.usageCount--,e.usageCount===0){qt.returnCanvasAndContext(e.canvasAndContext),Pt.returnTexture(e.texture);const i=e.texture.source;i.resource=null,i.uploadMethodId="unknown",i.alphaMode="no-premultiply-alpha",this._activeTextures[t]=null}}getReferenceCount(t){return this._activeTextures[t].usageCount}renderTextToCanvas(t,e,i,r){var y,v,w,E,C;const{canvas:n,context:a}=r,o=Zs(e),h=Gt.measureText(t||" ",e),c=h.lines,l=h.lineHeight,u=h.lineWidths,d=h.maxLineWidth,f=h.fontProperties,p=n.height;a.resetTransform(),a.scale(i,i);const g=e.padding*2;if(a.clearRect(0,0,h.width+4+g,h.height+4+g),(y=e._stroke)!=null&&y.width){const P=e._stroke;a.lineWidth=P.width,a.miterLimit=P.miterLimit,a.lineJoin=P.join,a.lineCap=P.cap}a.font=o;let m,_;const x=e.dropShadow?2:1;for(let P=0;P<x;++P){const S=e.dropShadow&&P===0,A=S?Math.ceil(Math.max(1,p)+e.padding*2):0,Q=A*i;if(S){a.fillStyle="black",a.strokeStyle="black";const B=e.dropShadow,q=B.color,it=B.alpha;a.shadowColor=j.shared.setValue(q).setAlpha(it).toRgbaString();const vt=B.blur*i,_s=B.distance*i;a.shadowBlur=vt,a.shadowOffsetX=Math.cos(B.angle)*_s,a.shadowOffsetY=Math.sin(B.angle)*_s+Q}else a.globalAlpha=((v=e._fill)==null?void 0:v.alpha)??1,a.fillStyle=e._fill?Qs(e._fill,a):null,(w=e._stroke)!=null&&w.width&&(a.strokeStyle=Qs(e._stroke,a)),a.shadowColor="black";let Mt=(l-f.fontSize)/2;l-f.fontSize<0&&(Mt=0);const F=((E=e._stroke)==null?void 0:E.width)??0;for(let B=0;B<c.length;B++)m=F/2,_=F/2+B*l+f.ascent+Mt,e.align==="right"?m+=d-u[B]:e.align==="center"&&(m+=(d-u[B])/2),(C=e._stroke)!=null&&C.width&&this._drawLetterSpacing(c[B],e,r,m+e.padding,_+e.padding-A,!0),e._fill!==void 0&&this._drawLetterSpacing(c[B],e,r,m+e.padding,_+e.padding-A)}}_drawLetterSpacing(t,e,i,r,n,a=!1){const{context:o}=i,h=e.letterSpacing;let c=!1;if(Gt.experimentalLetterSpacingSupported&&(Gt.experimentalLetterSpacing?(o.letterSpacing=`${h}px`,o.textLetterSpacing=`${h}px`,c=!0):(o.letterSpacing="0px",o.textLetterSpacing="0px")),h===0||c){a?o.strokeText(t,r,n):o.fillText(t,r,n);return}let l=r;const u=Gt.graphemeSegmenter(t);let d=o.measureText(t).width,f=0;for(let p=0;p<u.length;++p){const g=u[p];a?o.strokeText(g,l,n):o.fillText(g,l,n);let m="";for(let _=p+1;_<u.length;++_)m+=u[_];f=o.measureText(m).width,l+=d-f+h,d=f}}destroy(){this._activeTextures=null}}Dc.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"canvasText"},O.add(Ml,Bl);const ae=.02*1e3;class Zt{constructor(t=0,e){T(this,"isCompleted",!1);this.current=t,this.onComplete=e}tick(t=ae){this.isCompleted||(this.current-=t,this.current<0&&this.complete())}complete(){var t;this.isCompleted=!0,(t=this.onComplete)==null||t.call(this)}}class Zg{constructor(){T(this,"timers",[])}add(t,e){this.timers.push(new Zt(t,e))}tick(t=ae){const e=[];for(const i of this.timers)i.isCompleted||(i.tick(t),e.push(i));this.timers=e}}const fn=new Zg,Oc=s=>s.name=="jump",Lc=s=>s.name=="color",Hc=s=>s.name=="grow",Nc=s=>s.name=="dash",zc=s=>s.name=="sprite",Wc=s=>s.name=="add_jump_hits",Vc=s=>s.name=="resurrect";function ci(s){"@babel/helpers - typeof";return ci=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ci(s)}var Jg=/^\s+/,Qg=/\s+$/;function k(s,t){if(s=s||"",t=t||{},s instanceof k)return s;if(!(this instanceof k))return new k(s,t);var e=t_(s);this._originalInput=s,this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||e.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=e.ok}k.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},getLuminance:function(){var t=this.toRgb(),e,i,r,n,a,o;return e=t.r/255,i=t.g/255,r=t.b/255,e<=.03928?n=e/12.92:n=Math.pow((e+.055)/1.055,2.4),i<=.03928?a=i/12.92:a=Math.pow((i+.055)/1.055,2.4),r<=.03928?o=r/12.92:o=Math.pow((r+.055)/1.055,2.4),.2126*n+.7152*a+.0722*o},setAlpha:function(t){return this._a=qc(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=$c(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=$c(this._r,this._g,this._b),e=Math.round(t.h*360),i=Math.round(t.s*100),r=Math.round(t.v*100);return this._a==1?"hsv("+e+", "+i+"%, "+r+"%)":"hsva("+e+", "+i+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=jc(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=jc(this._r,this._g,this._b),e=Math.round(t.h*360),i=Math.round(t.s*100),r=Math.round(t.l*100);return this._a==1?"hsl("+e+", "+i+"%, "+r+"%)":"hsla("+e+", "+i+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return Xc(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return r_(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(J(this._r,255)*100)+"%",g:Math.round(J(this._g,255)*100)+"%",b:Math.round(J(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(J(this._r,255)*100)+"%, "+Math.round(J(this._g,255)*100)+"%, "+Math.round(J(this._b,255)*100)+"%)":"rgba("+Math.round(J(this._r,255)*100)+"%, "+Math.round(J(this._g,255)*100)+"%, "+Math.round(J(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:g_[Xc(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var e="#"+Yc(this._r,this._g,this._b,this._a),i=e,r=this._gradientType?"GradientType = 1, ":"";if(t){var n=k(t);i="#"+Yc(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+e+",endColorstr="+i+")"},toString:function(t){var e=!!t;t=t||this._format;var i=!1,r=this._a<1&&this._a>=0,n=!e&&r&&(t==="hex"||t==="hex6"||t==="hex3"||t==="hex4"||t==="hex8"||t==="name");return n?t==="name"&&this._a===0?this.toName():this.toRgbString():(t==="rgb"&&(i=this.toRgbString()),t==="prgb"&&(i=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(i=this.toHexString()),t==="hex3"&&(i=this.toHexString(!0)),t==="hex4"&&(i=this.toHex8String(!0)),t==="hex8"&&(i=this.toHex8String()),t==="name"&&(i=this.toName()),t==="hsl"&&(i=this.toHslString()),t==="hsv"&&(i=this.toHsvString()),i||this.toHexString())},clone:function(){return k(this.toString())},_applyModification:function(t,e){var i=t.apply(null,[this].concat([].slice.call(e)));return this._r=i._r,this._g=i._g,this._b=i._b,this.setAlpha(i._a),this},lighten:function(){return this._applyModification(h_,arguments)},brighten:function(){return this._applyModification(c_,arguments)},darken:function(){return this._applyModification(l_,arguments)},desaturate:function(){return this._applyModification(n_,arguments)},saturate:function(){return this._applyModification(a_,arguments)},greyscale:function(){return this._applyModification(o_,arguments)},spin:function(){return this._applyModification(u_,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(p_,arguments)},complement:function(){return this._applyCombination(d_,arguments)},monochromatic:function(){return this._applyCombination(m_,arguments)},splitcomplement:function(){return this._applyCombination(f_,arguments)},triad:function(){return this._applyCombination(Kc,[3])},tetrad:function(){return this._applyCombination(Kc,[4])}},k.fromRatio=function(s,t){if(ci(s)=="object"){var e={};for(var i in s)s.hasOwnProperty(i)&&(i==="a"?e[i]=s[i]:e[i]=fs(s[i]));s=e}return k(s,t)};function t_(s){var t={r:0,g:0,b:0},e=1,i=null,r=null,n=null,a=!1,o=!1;return typeof s=="string"&&(s=b_(s)),ci(s)=="object"&&(Jt(s.r)&&Jt(s.g)&&Jt(s.b)?(t=e_(s.r,s.g,s.b),a=!0,o=String(s.r).substr(-1)==="%"?"prgb":"rgb"):Jt(s.h)&&Jt(s.s)&&Jt(s.v)?(i=fs(s.s),r=fs(s.v),t=i_(s.h,i,r),a=!0,o="hsv"):Jt(s.h)&&Jt(s.s)&&Jt(s.l)&&(i=fs(s.s),n=fs(s.l),t=s_(s.h,i,n),a=!0,o="hsl"),s.hasOwnProperty("a")&&(e=s.a)),e=qc(e),{ok:a,format:s.format||o,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:e}}function e_(s,t,e){return{r:J(s,255)*255,g:J(t,255)*255,b:J(e,255)*255}}function jc(s,t,e){s=J(s,255),t=J(t,255),e=J(e,255);var i=Math.max(s,t,e),r=Math.min(s,t,e),n,a,o=(i+r)/2;if(i==r)n=a=0;else{var h=i-r;switch(a=o>.5?h/(2-i-r):h/(i+r),i){case s:n=(t-e)/h+(t<e?6:0);break;case t:n=(e-s)/h+2;break;case e:n=(s-t)/h+4;break}n/=6}return{h:n,s:a,l:o}}function s_(s,t,e){var i,r,n;s=J(s,360),t=J(t,100),e=J(e,100);function a(c,l,u){return u<0&&(u+=1),u>1&&(u-=1),u<1/6?c+(l-c)*6*u:u<1/2?l:u<2/3?c+(l-c)*(2/3-u)*6:c}if(t===0)i=r=n=e;else{var o=e<.5?e*(1+t):e+t-e*t,h=2*e-o;i=a(h,o,s+1/3),r=a(h,o,s),n=a(h,o,s-1/3)}return{r:i*255,g:r*255,b:n*255}}function $c(s,t,e){s=J(s,255),t=J(t,255),e=J(e,255);var i=Math.max(s,t,e),r=Math.min(s,t,e),n,a,o=i,h=i-r;if(a=i===0?0:h/i,i==r)n=0;else{switch(i){case s:n=(t-e)/h+(t<e?6:0);break;case t:n=(e-s)/h+2;break;case e:n=(s-t)/h+4;break}n/=6}return{h:n,s:a,v:o}}function i_(s,t,e){s=J(s,360)*6,t=J(t,100),e=J(e,100);var i=Math.floor(s),r=s-i,n=e*(1-t),a=e*(1-r*t),o=e*(1-(1-r)*t),h=i%6,c=[e,a,n,n,o,e][h],l=[o,e,e,a,n,n][h],u=[n,n,o,e,e,a][h];return{r:c*255,g:l*255,b:u*255}}function Xc(s,t,e,i){var r=[Ut(Math.round(s).toString(16)),Ut(Math.round(t).toString(16)),Ut(Math.round(e).toString(16))];return i&&r[0].charAt(0)==r[0].charAt(1)&&r[1].charAt(0)==r[1].charAt(1)&&r[2].charAt(0)==r[2].charAt(1)?r[0].charAt(0)+r[1].charAt(0)+r[2].charAt(0):r.join("")}function r_(s,t,e,i,r){var n=[Ut(Math.round(s).toString(16)),Ut(Math.round(t).toString(16)),Ut(Math.round(e).toString(16)),Ut(Zc(i))];return r&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)&&n[3].charAt(0)==n[3].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0)+n[3].charAt(0):n.join("")}function Yc(s,t,e,i){var r=[Ut(Zc(i)),Ut(Math.round(s).toString(16)),Ut(Math.round(t).toString(16)),Ut(Math.round(e).toString(16))];return r.join("")}k.equals=function(s,t){return!s||!t?!1:k(s).toRgbString()==k(t).toRgbString()},k.random=function(){return k.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function n_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.s-=t/100,e.s=li(e.s),k(e)}function a_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.s+=t/100,e.s=li(e.s),k(e)}function o_(s){return k(s).desaturate(100)}function h_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.l+=t/100,e.l=li(e.l),k(e)}function c_(s,t){t=t===0?0:t||10;var e=k(s).toRgb();return e.r=Math.max(0,Math.min(255,e.r-Math.round(255*-(t/100)))),e.g=Math.max(0,Math.min(255,e.g-Math.round(255*-(t/100)))),e.b=Math.max(0,Math.min(255,e.b-Math.round(255*-(t/100)))),k(e)}function l_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.l-=t/100,e.l=li(e.l),k(e)}function u_(s,t){var e=k(s).toHsl(),i=(e.h+t)%360;return e.h=i<0?360+i:i,k(e)}function d_(s){var t=k(s).toHsl();return t.h=(t.h+180)%360,k(t)}function Kc(s,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var e=k(s).toHsl(),i=[k(s)],r=360/t,n=1;n<t;n++)i.push(k({h:(e.h+n*r)%360,s:e.s,l:e.l}));return i}function f_(s){var t=k(s).toHsl(),e=t.h;return[k(s),k({h:(e+72)%360,s:t.s,l:t.l}),k({h:(e+216)%360,s:t.s,l:t.l})]}function p_(s,t,e){t=t||6,e=e||30;var i=k(s).toHsl(),r=360/e,n=[k(s)];for(i.h=(i.h-(r*t>>1)+720)%360;--t;)i.h=(i.h+r)%360,n.push(k(i));return n}function m_(s,t){t=t||6;for(var e=k(s).toHsv(),i=e.h,r=e.s,n=e.v,a=[],o=1/t;t--;)a.push(k({h:i,s:r,v:n})),n=(n+o)%1;return a}k.mix=function(s,t,e){e=e===0?0:e||50;var i=k(s).toRgb(),r=k(t).toRgb(),n=e/100,a={r:(r.r-i.r)*n+i.r,g:(r.g-i.g)*n+i.g,b:(r.b-i.b)*n+i.b,a:(r.a-i.a)*n+i.a};return k(a)},k.readability=function(s,t){var e=k(s),i=k(t);return(Math.max(e.getLuminance(),i.getLuminance())+.05)/(Math.min(e.getLuminance(),i.getLuminance())+.05)},k.isReadable=function(s,t,e){var i=k.readability(s,t),r,n;switch(n=!1,r=v_(e),r.level+r.size){case"AAsmall":case"AAAlarge":n=i>=4.5;break;case"AAlarge":n=i>=3;break;case"AAAsmall":n=i>=7;break}return n},k.mostReadable=function(s,t,e){var i=null,r=0,n,a,o,h;e=e||{},a=e.includeFallbackColors,o=e.level,h=e.size;for(var c=0;c<t.length;c++)n=k.readability(s,t[c]),n>r&&(r=n,i=k(t[c]));return k.isReadable(s,i,{level:o,size:h})||!a?i:(e.includeFallbackColors=!1,k.mostReadable(s,["#fff","#000"],e))};var pn=k.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},g_=k.hexNames=__(pn);function __(s){var t={};for(var e in s)s.hasOwnProperty(e)&&(t[s[e]]=e);return t}function qc(s){return s=parseFloat(s),(isNaN(s)||s<0||s>1)&&(s=1),s}function J(s,t){x_(s)&&(s="100%");var e=y_(s);return s=Math.min(t,Math.max(0,parseFloat(s))),e&&(s=parseInt(s*t,10)/100),Math.abs(s-t)<1e-6?1:s%t/parseFloat(t)}function li(s){return Math.min(1,Math.max(0,s))}function bt(s){return parseInt(s,16)}function x_(s){return typeof s=="string"&&s.indexOf(".")!=-1&&parseFloat(s)===1}function y_(s){return typeof s=="string"&&s.indexOf("%")!=-1}function Ut(s){return s.length==1?"0"+s:""+s}function fs(s){return s<=1&&(s=s*100+"%"),s}function Zc(s){return Math.round(parseFloat(s)*255).toString(16)}function Jc(s){return bt(s)/255}var Dt=function(){var s="[-\\+]?\\d+%?",t="[-\\+]?\\d*\\.\\d+%?",e="(?:"+t+")|(?:"+s+")",i="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",r="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?";return{CSS_UNIT:new RegExp(e),rgb:new RegExp("rgb"+i),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+i),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+i),hsva:new RegExp("hsva"+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Jt(s){return!!Dt.CSS_UNIT.exec(s)}function b_(s){s=s.replace(Jg,"").replace(Qg,"").toLowerCase();var t=!1;if(pn[s])s=pn[s],t=!0;else if(s=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var e;return(e=Dt.rgb.exec(s))?{r:e[1],g:e[2],b:e[3]}:(e=Dt.rgba.exec(s))?{r:e[1],g:e[2],b:e[3],a:e[4]}:(e=Dt.hsl.exec(s))?{h:e[1],s:e[2],l:e[3]}:(e=Dt.hsla.exec(s))?{h:e[1],s:e[2],l:e[3],a:e[4]}:(e=Dt.hsv.exec(s))?{h:e[1],s:e[2],v:e[3]}:(e=Dt.hsva.exec(s))?{h:e[1],s:e[2],v:e[3],a:e[4]}:(e=Dt.hex8.exec(s))?{r:bt(e[1]),g:bt(e[2]),b:bt(e[3]),a:Jc(e[4]),format:t?"name":"hex8"}:(e=Dt.hex6.exec(s))?{r:bt(e[1]),g:bt(e[2]),b:bt(e[3]),format:t?"name":"hex"}:(e=Dt.hex4.exec(s))?{r:bt(e[1]+""+e[1]),g:bt(e[2]+""+e[2]),b:bt(e[3]+""+e[3]),a:Jc(e[4]+""+e[4]),format:t?"name":"hex8"}:(e=Dt.hex3.exec(s))?{r:bt(e[1]+""+e[1]),g:bt(e[2]+""+e[2]),b:bt(e[3]+""+e[3]),format:t?"name":"hex"}:!1}function v_(s){var t,e;return s=s||{level:"AA",size:"small"},t=(s.level||"AA").toUpperCase(),e=(s.size||"small").toLowerCase(),t!=="AA"&&t!=="AAA"&&(t="AA"),e!=="small"&&e!=="large"&&(e="small"),{level:t,size:e}}var ps=Object.freeze({Linear:Object.freeze({None:function(s){return s},In:function(s){return s},Out:function(s){return s},InOut:function(s){return s}}),Quadratic:Object.freeze({In:function(s){return s*s},Out:function(s){return s*(2-s)},InOut:function(s){return(s*=2)<1?.5*s*s:-.5*(--s*(s-2)-1)}}),Cubic:Object.freeze({In:function(s){return s*s*s},Out:function(s){return--s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s:.5*((s-=2)*s*s+2)}}),Quartic:Object.freeze({In:function(s){return s*s*s*s},Out:function(s){return 1- --s*s*s*s},InOut:function(s){return(s*=2)<1?.5*s*s*s*s:-.5*((s-=2)*s*s*s-2)}}),Quintic:Object.freeze({In:function(s){return s*s*s*s*s},Out:function(s){return--s*s*s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s*s*s:.5*((s-=2)*s*s*s*s+2)}}),Sinusoidal:Object.freeze({In:function(s){return 1-Math.sin((1-s)*Math.PI/2)},Out:function(s){return Math.sin(s*Math.PI/2)},InOut:function(s){return .5*(1-Math.sin(Math.PI*(.5-s)))}}),Exponential:Object.freeze({In:function(s){return s===0?0:Math.pow(1024,s-1)},Out:function(s){return s===1?1:1-Math.pow(2,-10*s)},InOut:function(s){return s===0?0:s===1?1:(s*=2)<1?.5*Math.pow(1024,s-1):.5*(-Math.pow(2,-10*(s-1))+2)}}),Circular:Object.freeze({In:function(s){return 1-Math.sqrt(1-s*s)},Out:function(s){return Math.sqrt(1- --s*s)},InOut:function(s){return(s*=2)<1?-.5*(Math.sqrt(1-s*s)-1):.5*(Math.sqrt(1-(s-=2)*s)+1)}}),Elastic:Object.freeze({In:function(s){return s===0?0:s===1?1:-Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI)},Out:function(s){return s===0?0:s===1?1:Math.pow(2,-10*s)*Math.sin((s-.1)*5*Math.PI)+1},InOut:function(s){return s===0?0:s===1?1:(s*=2,s<1?-.5*Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI):.5*Math.pow(2,-10*(s-1))*Math.sin((s-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(s){var t=1.70158;return s===1?1:s*s*((t+1)*s-t)},Out:function(s){var t=1.70158;return s===0?0:--s*s*((t+1)*s+t)+1},InOut:function(s){var t=2.5949095;return(s*=2)<1?.5*(s*s*((t+1)*s-t)):.5*((s-=2)*s*((t+1)*s+t)+2)}}),Bounce:Object.freeze({In:function(s){return 1-ps.Bounce.Out(1-s)},Out:function(s){return s<1/2.75?7.5625*s*s:s<2/2.75?7.5625*(s-=1.5/2.75)*s+.75:s<2.5/2.75?7.5625*(s-=2.25/2.75)*s+.9375:7.5625*(s-=2.625/2.75)*s+.984375},InOut:function(s){return s<.5?ps.Bounce.In(s*2)*.5:ps.Bounce.Out(s*2-1)*.5+.5}}),generatePow:function(s){return s===void 0&&(s=4),s=s<Number.EPSILON?Number.EPSILON:s,s=s>1e4?1e4:s,{In:function(t){return Math.pow(t,s)},Out:function(t){return 1-Math.pow(1-t,s)},InOut:function(t){return t<.5?Math.pow(t*2,s)/2:(1-Math.pow(2-t*2,s))/2+.5}}}}),ms=function(){return performance.now()},S_=function(){function s(){this._tweens={},this._tweensAddedDuringUpdate={}}return s.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map(function(e){return t._tweens[e]})},s.prototype.removeAll=function(){this._tweens={}},s.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},s.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},s.prototype.update=function(t,e){t===void 0&&(t=ms()),e===void 0&&(e=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<i.length;r++){var n=this._tweens[i[r]],a=!e;n&&n.update(t,a)===!1&&!e&&delete this._tweens[i[r]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},s}(),He={Linear:function(s,t){var e=s.length-1,i=e*t,r=Math.floor(i),n=He.Utils.Linear;return t<0?n(s[0],s[1],i):t>1?n(s[e],s[e-1],e-i):n(s[r],s[r+1>e?e:r+1],i-r)},Bezier:function(s,t){for(var e=0,i=s.length-1,r=Math.pow,n=He.Utils.Bernstein,a=0;a<=i;a++)e+=r(1-t,i-a)*r(t,a)*s[a]*n(i,a);return e},CatmullRom:function(s,t){var e=s.length-1,i=e*t,r=Math.floor(i),n=He.Utils.CatmullRom;return s[0]===s[e]?(t<0&&(r=Math.floor(i=e*(1+t))),n(s[(r-1+e)%e],s[r],s[(r+1)%e],s[(r+2)%e],i-r)):t<0?s[0]-(n(s[0],s[0],s[1],s[1],-i)-s[0]):t>1?s[e]-(n(s[e],s[e],s[e-1],s[e-1],i-e)-s[e]):n(s[r?r-1:0],s[r],s[e<r+1?e:r+1],s[e<r+2?e:r+2],i-r)},Utils:{Linear:function(s,t,e){return(t-s)*e+s},Bernstein:function(s,t){var e=He.Utils.Factorial;return e(s)/e(t)/e(s-t)},Factorial:function(){var s=[1];return function(t){var e=1;if(s[t])return s[t];for(var i=t;i>1;i--)e*=i;return s[t]=e,e}}(),CatmullRom:function(s,t,e,i,r){var n=(e-s)*.5,a=(i-t)*.5,o=r*r,h=r*o;return(2*t-2*e+n+a)*h+(-3*t+3*e-2*n-a)*o+n*r+t}}},w_=function(){function s(){}return s.nextId=function(){return s._nextId++},s._nextId=0,s}(),mn=new S_,xe=function(){function s(t,e){e===void 0&&(e=mn),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=ps.Linear.None,this._interpolationFunction=He.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=w_.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return s.prototype.getId=function(){return this._id},s.prototype.isPlaying=function(){return this._isPlaying},s.prototype.isPaused=function(){return this._isPaused},s.prototype.getDuration=function(){return this._duration},s.prototype.to=function(t,e){if(e===void 0&&(e=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=e<0?0:e,this},s.prototype.duration=function(t){return t===void 0&&(t=1e3),this._duration=t<0?0:t,this},s.prototype.dynamic=function(t){return t===void 0&&(t=!1),this._isDynamic=t,this},s.prototype.start=function(t,e){if(t===void 0&&(t=ms()),e===void 0&&(e=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||e){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var n in this._valuesEnd)r[n]=this._valuesEnd[n];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,e)}return this},s.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},s.prototype._setupProperties=function(t,e,i,r,n){for(var a in i){var o=t[a],h=Array.isArray(o),c=h?"array":typeof o,l=!h&&Array.isArray(i[a]);if(!(c==="undefined"||c==="function")){if(l){var u=i[a];if(u.length===0)continue;for(var d=[o],f=0,p=u.length;f<p;f+=1){var g=this._handleRelativeValue(o,u[f]);if(isNaN(g)){l=!1,console.warn("Found invalid interpolation list. Skipping.");break}d.push(g)}l&&(i[a]=d)}if((c==="object"||h)&&o&&!l){e[a]=h?[]:{};var m=o;for(var _ in m)e[a][_]=m[_];r[a]=h?[]:{};var u=i[a];if(!this._isDynamic){var x={};for(var _ in u)x[_]=u[_];i[a]=u=x}this._setupProperties(m,e[a],u,r[a],n)}else(typeof e[a]>"u"||n)&&(e[a]=o),h||(e[a]*=1),l?r[a]=i[a].slice().reverse():r[a]=e[a]||0}}},s.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},s.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},s.prototype.pause=function(t){return t===void 0&&(t=ms()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this),this)},s.prototype.resume=function(t){return t===void 0&&(t=ms()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},s.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},s.prototype.group=function(t){return t===void 0&&(t=mn),this._group=t,this},s.prototype.delay=function(t){return t===void 0&&(t=0),this._delayTime=t,this},s.prototype.repeat=function(t){return t===void 0&&(t=0),this._initialRepeat=t,this._repeat=t,this},s.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},s.prototype.yoyo=function(t){return t===void 0&&(t=!1),this._yoyo=t,this},s.prototype.easing=function(t){return t===void 0&&(t=ps.Linear.None),this._easingFunction=t,this},s.prototype.interpolation=function(t){return t===void 0&&(t=He.Linear),this._interpolationFunction=t,this},s.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},s.prototype.onStart=function(t){return this._onStartCallback=t,this},s.prototype.onEveryStart=function(t){return this._onEveryStartCallback=t,this},s.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},s.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},s.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},s.prototype.onStop=function(t){return this._onStopCallback=t,this},s.prototype.update=function(t,e){var i;if(t===void 0&&(t=ms()),e===void 0&&(e=!0),this._isPaused)return!0;var r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>r)return!1;e&&this.start(t,!0)}if(this._goToEnd=!1,t<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var n=t-this._startTime,a=this._duration+((i=this._repeatDelayTime)!==null&&i!==void 0?i:this._delayTime),o=this._duration+this._repeat*a,h=this._calculateElapsedPortion(n,a,o),c=this._easingFunction(h),l=this._calculateCompletionStatus(n,a);if(l==="repeat"&&this._processRepetition(n,a),this._updateProperties(this._object,this._valuesStart,this._valuesEnd,c),l==="about-to-repeat"&&this._processRepetition(n,a),this._onUpdateCallback&&this._onUpdateCallback(this._object,h),l==="repeat"||l==="about-to-repeat")this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1;else if(l==="completed"){this._isPlaying=!1,this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var u=0,d=this._chainedTweens.length;u<d;u++)this._chainedTweens[u].start(this._startTime+this._duration,!1)}return l!=="completed"},s.prototype._calculateElapsedPortion=function(t,e,i){if(this._duration===0||t>i)return 1;var r=t%e,n=Math.min(r/this._duration,1);return n===0&&t!==0&&t%this._duration===0?1:n},s.prototype._calculateCompletionStatus=function(t,e){return this._duration!==0&&t<this._duration?"playing":this._repeat<=0?"completed":t===this._duration?"about-to-repeat":"repeat"},s.prototype._processRepetition=function(t,e){var i=Math.min(Math.trunc((t-this._duration)/e)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=i);for(var r in this._valuesStartRepeat){var n=this._valuesEnd[r];!this._yoyo&&typeof n=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(n)),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r]}this._yoyo&&(this._reversed=!this._reversed),this._startTime+=e*i},s.prototype._updateProperties=function(t,e,i,r){for(var n in i)if(e[n]!==void 0){var a=e[n]||0,o=i[n],h=Array.isArray(t[n]),c=Array.isArray(o),l=!h&&c;l?t[n]=this._interpolationFunction(o,r):typeof o=="object"&&o?this._updateProperties(t[n],a,o,r):(o=this._handleRelativeValue(a,o),typeof o=="number"&&(t[n]=a+(o-a)*r))}},s.prototype._handleRelativeValue=function(t,e){return typeof e!="string"?e:e.charAt(0)==="+"||e.charAt(0)==="-"?t+parseFloat(e):parseFloat(e)},s.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],i=this._valuesEnd[t];typeof i=="string"?this._valuesStartRepeat[t]=this._valuesStartRepeat[t]+parseFloat(i):this._valuesStartRepeat[t]=this._valuesEnd[t],this._valuesEnd[t]=e},s}(),Nt=mn;Nt.getAll.bind(Nt),Nt.removeAll.bind(Nt),Nt.add.bind(Nt),Nt.remove.bind(Nt),Nt.update.bind(Nt);class T_{constructor(){T(this,"assets",{})}async initialize(t){this.assets=Object.fromEntries(Array.from(Object.entries(t??{})).map(([e,i])=>[e,new Audio(i.src)]))}play(t){const e=this.assets[t];e&&(e.volume=.3,e.pause(),e.currentTime=0,e.play())}}const Qc=new T_;var dt=(s=>(s.Idle="Idle",s.Jump="Jump",s.Fall="Fall",s.Land="Land",s.Run="Run",s.Die="Die",s))(dt||{});class A_{constructor(){T(this,"spriteLoaderFn");T(this,"sprites",{})}initialize(t){this.spriteLoaderFn=t}async getSpriteData(t){const e=await this.spriteLoaderFn(t);if(!e)return;if(this.sprites[t])return this.sprites[t];const i=await ft.load(e.image),r=new Ni(i,e.sprite);return await r.parse(),this.sprites[t]={sheet:r,data:{...e.data,scale:e.data.scale??1}},this.sprites[t]}createAnimatedSprite(t,e){for(const i of e.data.meta.frameTags??[]){const r=[];for(let a=i.from;a<=i.to;a++){const o=a.toString(),h=t+"_"+o,c=e.textures[h],l=e.data.frames[h].duration;r.push({texture:c,time:l})}const n=new ns(r);return n.texture.source.scaleMode="nearest",n}}getAnimatedSprites(t){if(!t)throw Error("Sheet is not defined");if(!this.sprites[t])throw Error("Sprite is not loaded");const e=this.sprites[t].data,i=this.sprites[t].sheet,r={};for(const n of i.data.meta.frameTags??[]){if(!i.data.meta.layers)throw Error("Layers are not defined");const a={};for(const o of i.data.meta.layers){const h=[];for(let l=n.from;l<=n.to;l++){const u=l.toString(),d=e.name+"_"+o.name+"_"+u,f=i.textures[d],p=i.data.frames[d].duration;h.push({texture:f,time:p})}const c=new ns(h);c.texture.source.scaleMode="nearest",a[o.name]=c}n.name&&(r[n.name]=a)}return r}}const ui=new A_;var ye={},tl={},Qt={};Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.loop=Qt.conditional=Qt.parse=void 0;var P_=function s(t,e){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;if(Array.isArray(e))e.forEach(function(a){return s(t,a,i,r)});else if(typeof e=="function")e(t,i,r,s);else{var n=Object.keys(e)[0];Array.isArray(e[n])?(r[n]={},s(t,e[n],i,r[n])):r[n]=e[n](t,i,r,s)}return i};Qt.parse=P_;var C_=function(t,e){return function(i,r,n,a){e(i,r,n)&&a(i,t,r,n)}};Qt.conditional=C_;var E_=function(t,e){return function(i,r,n,a){for(var o=[],h=i.pos;e(i,r,n);){var c={};if(a(i,t,r,c),i.pos===h)break;h=i.pos,o.push(c)}return o}};Qt.loop=E_;var rt={};Object.defineProperty(rt,"__esModule",{value:!0}),rt.readBits=rt.readArray=rt.readUnsigned=rt.readString=rt.peekBytes=rt.readBytes=rt.peekByte=rt.readByte=rt.buildStream=void 0;var M_=function(t){return{data:t,pos:0}};rt.buildStream=M_;var el=function(){return function(t){return t.data[t.pos++]}};rt.readByte=el;var B_=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(e){return e.data[e.pos+t]}};rt.peekByte=B_;var di=function(t){return function(e){return e.data.subarray(e.pos,e.pos+=t)}};rt.readBytes=di;var R_=function(t){return function(e){return e.data.subarray(e.pos,e.pos+t)}};rt.peekBytes=R_;var k_=function(t){return function(e){return Array.from(di(t)(e)).map(function(i){return String.fromCharCode(i)}).join("")}};rt.readString=k_;var I_=function(t){return function(e){var i=di(2)(e);return t?(i[1]<<8)+i[0]:(i[0]<<8)+i[1]}};rt.readUnsigned=I_;var F_=function(t,e){return function(i,r,n){for(var a=typeof e=="function"?e(i,r,n):e,o=di(t),h=new Array(a),c=0;c<a;c++)h[c]=o(i);return h}};rt.readArray=F_;var G_=function(t,e,i){for(var r=0,n=0;n<i;n++)r+=t[e+n]&&Math.pow(2,i-n-1);return r},U_=function(t){return function(e){for(var i=el()(e),r=new Array(8),n=0;n<8;n++)r[7-n]=!!(i&1<<n);return Object.keys(t).reduce(function(a,o){var h=t[o];return h.length?a[o]=G_(r,h.index,h.length):a[o]=r[h.index],a},{})}};rt.readBits=U_,function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0;var t=Qt,e=rt,i={blocks:function(d){for(var f=0,p=[],g=d.data.length,m=0,_=(0,e.readByte)()(d);_!==f&&_;_=(0,e.readByte)()(d)){if(d.pos+_>=g){var x=g-d.pos;p.push((0,e.readBytes)(x)(d)),m+=x;break}p.push((0,e.readBytes)(_)(d)),m+=_}for(var y=new Uint8Array(m),v=0,w=0;w<p.length;w++)y.set(p[w],v),v+=p[w].length;return y}},r=(0,t.conditional)({gce:[{codes:(0,e.readBytes)(2)},{byteSize:(0,e.readByte)()},{extras:(0,e.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,e.readUnsigned)(!0)},{transparentColorIndex:(0,e.readByte)()},{terminator:(0,e.readByte)()}]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===249}),n=(0,t.conditional)({image:[{code:(0,e.readByte)()},{descriptor:[{left:(0,e.readUnsigned)(!0)},{top:(0,e.readUnsigned)(!0)},{width:(0,e.readUnsigned)(!0)},{height:(0,e.readUnsigned)(!0)},{lct:(0,e.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,t.conditional)({lct:(0,e.readArray)(3,function(u,d,f){return Math.pow(2,f.descriptor.lct.size+1)})},function(u,d,f){return f.descriptor.lct.exists}),{data:[{minCodeSize:(0,e.readByte)()},i]}]},function(u){return(0,e.peekByte)()(u)===44}),a=(0,t.conditional)({text:[{codes:(0,e.readBytes)(2)},{blockSize:(0,e.readByte)()},{preData:function(d,f,p){return(0,e.readBytes)(p.text.blockSize)(d)}},i]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===1}),o=(0,t.conditional)({application:[{codes:(0,e.readBytes)(2)},{blockSize:(0,e.readByte)()},{id:function(d,f,p){return(0,e.readString)(p.blockSize)(d)}},i]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===255}),h=(0,t.conditional)({comment:[{codes:(0,e.readBytes)(2)},i]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===254}),c=[{header:[{signature:(0,e.readString)(3)},{version:(0,e.readString)(3)}]},{lsd:[{width:(0,e.readUnsigned)(!0)},{height:(0,e.readUnsigned)(!0)},{gct:(0,e.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,e.readByte)()},{pixelAspectRatio:(0,e.readByte)()}]},(0,t.conditional)({gct:(0,e.readArray)(3,function(u,d){return Math.pow(2,d.lsd.gct.size+1)})},function(u,d){return d.lsd.gct.exists}),{frames:(0,t.loop)([r,o,h,n,a],function(u){var d=(0,e.peekByte)()(u);return d===33||d===44})}],l=c;s.default=l}(tl);var fi={};Object.defineProperty(fi,"__esModule",{value:!0}),fi.deinterlace=void 0;var D_=function(t,e){for(var i=new Array(t.length),r=t.length/e,n=function(d,f){var p=t.slice(f*e,(f+1)*e);i.splice.apply(i,[d*e,e].concat(p))},a=[0,4,2,1],o=[8,8,4,2],h=0,c=0;c<4;c++)for(var l=a[c];l<r;l+=o[c])n(l,h),h++;return i};fi.deinterlace=D_;var pi={};Object.defineProperty(pi,"__esModule",{value:!0}),pi.lzw=void 0;var O_=function(t,e,i){var r=4096,n=-1,a=i,o,h,c,l,u,d,f,E,p,g,w,m,C,P,A,S,_=new Array(i),x=new Array(r),y=new Array(r),v=new Array(r+1);for(m=t,h=1<<m,u=h+1,o=h+2,f=n,l=m+1,c=(1<<l)-1,p=0;p<h;p++)x[p]=0,y[p]=p;var w,E,C,P,S,A;for(w=E=C=P=S=A=0,g=0;g<a;){if(P===0){if(E<l){w+=e[A]<<E,E+=8,A++;continue}if(p=w&c,w>>=l,E-=l,p>o||p==u)break;if(p==h){l=m+1,c=(1<<l)-1,o=h+2,f=n;continue}if(f==n){v[P++]=y[p],f=p,C=p;continue}for(d=p,p==o&&(v[P++]=C,p=f);p>h;)v[P++]=y[p],p=x[p];C=y[p]&255,v[P++]=C,o<r&&(x[o]=f,y[o]=C,o++,!(o&c)&&o<r&&(l++,c+=o)),f=d}P--,_[S++]=v[P],g++}for(g=S;g<a;g++)_[g]=0;return _};pi.lzw=O_,Object.defineProperty(ye,"__esModule",{value:!0});var sl=ye.decompressFrames=ye.decompressFrame=il=ye.parseGIF=void 0,L_=V_(tl),H_=Qt,N_=rt,z_=fi,W_=pi;function V_(s){return s&&s.__esModule?s:{default:s}}var j_=function(t){var e=new Uint8Array(t);return(0,H_.parse)((0,N_.buildStream)(e),L_.default)},il=ye.parseGIF=j_,$_=function(t){for(var e=t.pixels.length,i=new Uint8ClampedArray(e*4),r=0;r<e;r++){var n=r*4,a=t.pixels[r],o=t.colorTable[a]||[0,0,0];i[n]=o[0],i[n+1]=o[1],i[n+2]=o[2],i[n+3]=a!==t.transparentIndex?255:0}return i},rl=function(t,e,i){if(!t.image){console.warn("gif frame does not have associated image.");return}var r=t.image,n=r.descriptor.width*r.descriptor.height,a=(0,W_.lzw)(r.data.minCodeSize,r.data.blocks,n);r.descriptor.lct.interlaced&&(a=(0,z_.deinterlace)(a,r.descriptor.width));var o={pixels:a,dims:{top:t.image.descriptor.top,left:t.image.descriptor.left,width:t.image.descriptor.width,height:t.image.descriptor.height}};return r.descriptor.lct&&r.descriptor.lct.exists?o.colorTable=r.lct:o.colorTable=e,t.gce&&(o.delay=(t.gce.delay||10)*10,o.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(o.transparentIndex=t.gce.transparentColorIndex)),i&&(o.patch=$_(o)),o};ye.decompressFrame=rl;var X_=function(t,e){return t.frames.filter(function(i){return i.image}).map(function(i){return rl(i,t.gct,e)})};sl=ye.decompressFrames=X_;const gs=class extends Tt{constructor(s,t){super(M.EMPTY),this.animationSpeed=1,this.loop=!0,this.duration=0,this.autoPlay=!0,this.dirty=!1,this._currentFrame=0,this._autoUpdate=!1,this._isConnectedToTicker=!1,this._playing=!1,this._currentTime=0,this.onRender=()=>this.updateFrame();const{scaleMode:e,width:i,height:r,...n}=Object.assign({},gs.defaultOptions,t),a=L.get().createCanvas(i,r),o=a.getContext("2d");this.texture=M.from(a),this.texture.source.scaleMode=e,this.duration=s[s.length-1].end,this._frames=s,this._context=o,this._playing=!1,this._currentTime=0,this._isConnectedToTicker=!1,Object.assign(this,n),this.currentFrame=0,n.autoPlay&&this.play()}static fromBuffer(s,t){if(!s||s.byteLength===0)throw new Error("Invalid buffer");const e=m=>{let _=null;for(const x of m.frames)_=x.gce??_,"image"in x&&!("gce"in x)&&(x.gce=_)},i=il(s);e(i);const r=sl(i,!0),n=[],a=L.get().createCanvas(i.lsd.width,i.lsd.height),o=a.getContext("2d",{willReadFrequently:!0}),h=L.get().createCanvas(),c=h.getContext("2d");let l=0,u=null;const{fps:d}=Object.assign({},gs.defaultOptions,t),f=1e3/d;for(let m=0;m<r.length;m++){const{disposalType:_=2,delay:x=f,patch:y,dims:{width:v,height:w,left:E,top:C}}=r[m];h.width=v,h.height=w,c.clearRect(0,0,v,w);const P=c.createImageData(v,w);P.data.set(y),c.putImageData(P,0,0),_===3&&(u=o.getImageData(0,0,a.width,a.height)),o.drawImage(h,E,C);const S=o.getImageData(0,0,a.width,a.height);_===2?o.clearRect(0,0,a.width,a.height):_===3&&o.putImageData(u,0,0),n.push({start:l,end:l+x,imageData:S}),l+=x}a.width=a.height=0,h.width=h.height=0;const{width:p,height:g}=i.lsd;return new gs(n,{width:p,height:g,...t})}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(ot.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(ot.shared.add(this.update,this,de.HIGH),this._isConnectedToTicker=!0),!this.loop&&this.currentFrame===this._frames.length-1&&(this._currentTime=0))}get progress(){return this._currentTime/this.duration}get playing(){return this._playing}update(s){var n,a;if(!this._playing)return;const t=this.animationSpeed*s.deltaTime/ot.targetFPMS,e=this._currentTime+t,i=e%this.duration,r=this._frames.findIndex(o=>o.start<=i&&o.end>i);e>=this.duration?this.loop?(this._currentTime=i,this.updateFrameIndex(r),(n=this.onLoop)==null||n.call(this)):(this._currentTime=this.duration,this.updateFrameIndex(this._frames.length-1),(a=this.onComplete)==null||a.call(this),this.stop()):(this._currentTime=i,this.updateFrameIndex(r))}updateFrame(){if(!this.dirty)return;const{imageData:s}=this._frames[this._currentFrame];this._context.putImageData(s,0,0),this._context.fillStyle="transparent",this._context.fillRect(0,0,0,1),this.texture.source.update(),this.dirty=!1}get autoUpdate(){return this._autoUpdate}set autoUpdate(s){s!==this._autoUpdate&&(this._autoUpdate=s,!this._autoUpdate&&this._isConnectedToTicker?(ot.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(ot.shared.add(this.update,this),this._isConnectedToTicker=!0))}get currentFrame(){return this._currentFrame}set currentFrame(s){this.updateFrameIndex(s),this._currentTime=this._frames[s].start}updateFrameIndex(s){var t;if(s<0||s>=this._frames.length)throw new Error(`Frame index out of range, expecting 0 to ${this.totalFrames}, got ${s}`);this._currentFrame!==s&&(this._currentFrame=s,this.dirty=!0,(t=this.onFrameChange)==null||t.call(this,s))}get totalFrames(){return this._frames.length}destroy(){this.stop(),super.destroy(!0);const s=null;this._context=s,this._frames=s,this.onComplete=s,this.onFrameChange=s,this.onLoop=s}clone(){const s=new gs([...this._frames],{autoUpdate:this._autoUpdate,loop:this.loop,autoPlay:this.autoPlay,scaleMode:this.texture.source.scaleMode,animationSpeed:this.animationSpeed,width:this._context.canvas.width,height:this._context.canvas.height,onComplete:this.onComplete,onFrameChange:this.onFrameChange,onLoop:this.onLoop});return s.dirty=!0,s}};let gn=gs;gn.defaultOptions={scaleMode:"linear",fps:30,loop:!0,animationSpeed:1,autoPlay:!0,autoUpdate:!0,onComplete:null,onFrameChange:null,onLoop:null};const Y_={extension:b.Asset,detection:{test:async()=>!0,add:async s=>[...s,"gif"],remove:async s=>s.filter(t=>t!=="gif")},loader:{name:"gifLoader",test:s=>gt.extname(s)===".gif",load:async(s,t)=>{const i=await(await L.get().fetch(s)).arrayBuffer();return gn.fromBuffer(i,t==null?void 0:t.data)},unload:async s=>{s.destroy()}}};O.add(Y_);const nl={};class K_{constructor(){T(this,"container",new z);T(this,"emotes",[]);T(this,"moveSpeed",50);T(this,"alphaSpeed",1);T(this,"scaleSpeed",.5);T(this,"timer")}async add(t){const e=nl[t];let i;if(e)i=e.clone();else{const r=await fetch(t),n=r.headers.get("content-type");switch(n){case"image/gif":{const a=await r.arrayBuffer();i=gn.fromBuffer(a),nl[t]=i;break}case"image/png":{i=Tt.from(t);break}default:{console.warn("Unsupported content type: ",n);return}}}i&&(i.anchor.set(.5,.5),i.scale.set(0,0),this.emotes.push(i))}isAnimatedGIF(t){return t.currentFrame}update(t){var e;(e=this.timer)==null||e.tick(),(!this.timer||this.timer.isCompleted)&&this.emotes.length>0&&(this.timer=new Zt(2e3,()=>{const i=this.emotes.shift();i&&(this.isAnimatedGIF(i)&&(i.currentFrame=0),this.container.addChild(i))})),this.container.position.x=t.position.x??this.container.position.x,this.container.position.y=t.position.y??this.container.position.y;for(const i of this.container.children)i.position.y-=ae*this.moveSpeed/1e3,i.scale.x+=ae*this.scaleSpeed/1e3,i.scale.y+=ae*this.scaleSpeed/1e3,i.scale.x>1&&(i.alpha-=ae*this.alphaSpeed/1e3),i.alpha<=0&&this.container.removeChild(i)}}class q_{constructor(t){T(this,"container",new z);T(this,"animated",new z);T(this,"text",new Js({text:void 0,style:{fontFamily:"Custom Font",fontSize:20,fill:2236962,align:"left",breakWords:!0,wordWrap:!0,wordWrapWidth:200}}));T(this,"padding",10);T(this,"borderRadius",10);T(this,"boxColor",15658734);T(this,"boxBorderColor",2236962);T(this,"fadeShift",10);T(this,"isChecking",!0);T(this,"messageQueue",[]);T(this,"showTween");T(this,"hideTween");T(this,"timer");this.beforeShow=t,this.container.addChild(this.animated),this.text.anchor.set(.5,1),this.text.position.set(0,-this.padding)}trim(t){const e=Gt.measureText(t.text,t.style);return e.lines.length>4?e.lines.slice(0,4).join(" ").slice(0,-3)+"...":t.text}update(t){var i,r,n,a,o;if((i=this.timer)==null||i.tick(),(r=this.showTween)==null||r.update(),(n=this.hideTween)==null||n.update(),this.isChecking&&this.messageQueue.length>0){this.isChecking=!1;const h=this.messageQueue.shift();h&&(this.beforeShow(),this.show(h))}this.container.position.x=t.position.x??this.container.position.x,this.container.position.y=t.position.y??this.container.position.y;const e=((a=this.showTween)==null?void 0:a.isPlaying())||((o=this.hideTween)==null?void 0:o.isPlaying());!this.isChecking&&!e&&this.timer&&(this.animated.position.y=Math.sin(this.timer.current*.0025)*4-2)}add(t){this.messageQueue.push(t)}drawBox(t){const e={x:t.x-this.padding-t.width*t.anchor.x,y:t.y-this.padding-t.height*t.anchor.y,w:t.width+this.padding*2,h:t.height+this.padding*2},i=20,r=5,n=new rs;return n.moveTo(e.x+this.borderRadius,e.y),n.quadraticCurveTo(e.x,e.y,e.x,e.y+this.borderRadius,5),n.lineTo(e.x,e.y+e.h-this.borderRadius),n.quadraticCurveTo(e.x,e.y+e.h,e.x+this.borderRadius,e.y+e.h,5),n.lineTo(e.x+e.w/2-i/2,e.y+e.h),n.lineTo(e.x+e.w/2,e.y+e.h+r),n.lineTo(e.x+e.w/2+i/2,e.y+e.h),n.lineTo(e.x+e.w-this.borderRadius,e.y+e.h),n.quadraticCurveTo(e.x+e.w,e.y+e.h,e.x+e.w,e.y+e.h-this.borderRadius,5),n.lineTo(e.x+e.w,e.y+this.borderRadius),n.quadraticCurveTo(e.x+e.w,e.y,e.x+e.w-this.borderRadius,e.y,5),n.lineTo(e.x+this.borderRadius,e.y),n.fill({color:this.boxColor}),n.stroke({color:this.boxBorderColor,width:2}),n}show(t){this.text.text=t,this.text.text=this.trim(this.text),this.animated.alpha=0,this.animated.position.y=this.fadeShift;const e=this.drawBox(this.text);this.animated.removeChildren(),this.animated.addChild(e,this.text);const i={alpha:1,y:this.animated.y-this.fadeShift},r={alpha:0,y:this.animated.y+this.fadeShift};this.hideTween=new xe(this.animated).to(r,500).onComplete(()=>{this.isChecking=!0}),this.showTween=new xe(this.animated).to(i,500).onComplete(()=>{this.timer=new Zt(1e4,()=>{var n;(n=this.hideTween)==null||n.start()})}),this.showTween.start()}}class Z_{constructor(){T(this,"text",new Js({text:void 0,style:{fontFamily:"Custom Font",fontSize:18,fill:16777215,align:"center",stroke:{width:4,color:"black",join:"round"}}}));this.text.anchor.set(.5,1),this.text.zIndex=100}update(t){this.text.text=t.name??"",this.text.visible=t.isVisible,this.text.position.x=t.position.x??this.text.position.x,this.text.position.y=t.position.y??this.text.position.y}}class J_{constructor(t,e){T(this,"container",new z);T(this,"currentTag",dt.Idle);this.sprites=t,this.data=e,this.container.pivot.set(0,e.collider.y+e.collider.h),this.container.sortableChildren=!0;let i=0;for(const r in this.sprites){const n=this.sprites[r];for(const a in n){const o=n[a];o.zIndex=++i,o.anchor.set(.5,0),o.autoUpdate=!1,o.play()}}}getLayersByTag(t){return this.sprites[t]}setTag(t=dt.Idle){this.currentTag!=t&&this.container.removeChildren(),this.currentTag=t;const e=this.sprites[this.currentTag];for(const i in e){const r=e[i];this.container.addChild(r)}}update(t){const e=this.sprites[this.currentTag];for(const i in e){const r=e[i];if(t.play&&r.update(lt.ticker),t.color){for(const n in t.color)if(n==i){const a=t.color[n];a&&(r.alpha=a.alpha,r.tint=a)}}t.scale.x&&(r.animationSpeed=4/Math.abs(t.scale.x))}this.container.scale.set(t.scale.x,t.scale.y)}}class Q_{constructor(){T(this,"container",new z);T(this,"timer");T(this,"sprite");T(this,"opacityStep",.1);T(this,"shadowStep",50);lt.stage.addChild(this.container),this.container.zIndex=-100}setSprite(t){this.sprite=t}update(t){for(const e of this.container.children)e.alpha>0&&(e.alpha=e.alpha-this.opacityStep);if(this.timer&&!this.timer.isCompleted)this.timer.tick();else if(t.play){this.timer=new Zt(this.shadowStep);const e=new z;if(this.sprite){const i=this.sprite.getLayersByTag(dt.Idle);for(const r in i){const n=i[r],a=n.texture,o=new Tt(a);o.anchor.set(.5,0),o.alpha=n.alpha,o.tint=n.tint,e.addChild(o),e.scale.set(this.sprite.container.scale.x,this.sprite.container.scale.y),e.pivot.set(this.sprite.container.pivot.x,this.sprite.container.pivot.y);const h=this.sprite.container.getGlobalPosition();e.position.set(h.x,h.y)}}this.container.addChild(e)}}}const tx=async s=>{await new Promise(t=>setTimeout(()=>{t(void 0)},s))},al={fontFamily:"Custom Font",fontSize:14,fill:"white",align:"center",stroke:{width:4,color:"black",join:"round"}};class ex{constructor(){T(this,"containter",new z);T(this,"killText",new Js({text:void 0,style:al}));T(this,"killSprite");T(this,"jumpText",new Js({text:void 0,style:al}));T(this,"jumpSprite");T(this,"kills",0);T(this,"jumps",0);this.containter.zIndex=100,this.killSprite=this.createSprite("skull"),this.killText.anchor.set(0,.5),this.jumpSprite=this.createSprite("weight"),this.jumpText.anchor.set(0,.5)}addJumps(t){this.jumps+=t,this.draw()}addKill(){this.kills+=1,this.draw()}useJump(){this.jumps-=1,this.draw()}createSprite(t){const e=ft.get(t),i=Tt.from(e);return i.anchor.set(0,.5),i.scale.set(2,2),i.texture.source.scaleMode="nearest",i}draw(){const t=[];this.kills>0&&(t.push(this.killSprite),t.push(this.killText),this.killText.text=this.kills),this.jumps>0&&(t.push(this.jumpSprite),t.push(this.jumpText),this.jumpText.text=this.jumps);const e=4;let r=-(t.reduce((n,a)=>n+a.width,0)+e*(t.length-1))/2;this.containter.removeChildren();for(const n of t)n.position.set(r,0),r+=n.width+e,this.containter.addChild(n)}update(t){this.containter.position.x=t.position.x??this.containter.position.x,this.containter.position.y=t.position.y??this.containter.position.y}}const sx=(s,t)=>s.x<t.x+t.w&&s.x+s.w>t.x&&s.y<t.y+t.h&&s.y+s.h>t.y,ix=(s,t,e)=>{const i={...s,x:s.x+(e.x??0),y:s.y+(e.y??0)};return sx(i,t)?s.y+s.h<t.y&&i.y+i.h>=t.y:!1};class Ne{constructor(){T(this,"container",new z);T(this,"userState",{});T(this,"state",{name:"",sprite:"",color:new j("#969696"),direction:1,scale:1,isAnonymous:!1,isImmortal:!1,zIndex:0});T(this,"animationState",dt.Idle);T(this,"sprite");T(this,"trail",new Q_);T(this,"name",new Z_);T(this,"info",new ex);T(this,"message",new q_(()=>{this.state.zIndex=Et.zIndexEvotarMax(this.container.zIndex)}));T(this,"emoteSpitter",new K_);T(this,"velocity",{x:0,y:0});T(this,"runSpeed",.05);T(this,"gravity",.2);T(this,"dashAcc",3);T(this,"isJumping",!1);T(this,"isHitJumping",!1);T(this,"isDashing",!1);T(this,"isDespawned",!1);T(this,"isDead",!1);T(this,"deathTimer");T(this,"landTimer");T(this,"stateTimer");T(this,"scaleTimer");T(this,"spawnTween");T(this,"fadeTween");T(this,"scaleTween");T(this,"offset",0);T(this,"screenBounds",{left:this.offset,right:lt.renderer.width-this.offset});this.container.addChild(this.name.text),this.container.addChild(this.info.containter),this.container.addChild(this.emoteSpitter.container),this.container.addChild(this.message.container),this.container.sortableChildren=!0}getCenterOffsetY(){return this.sprite?this.sprite.data.collider.h/2*this.getScale():0}getCenterPosition(){return{x:this.container.position.x,y:this.container.position.y-this.getCenterOffsetY()}}setPosition(t){this.container.position=t}getScale(){return this.sprite?this.state.scale*this.sprite.data.scale:this.state.scale}getCollider(){if(this.sprite){const t=this.sprite.data.collider.x*this.getScale(),e=this.sprite.data.collider.h*this.getScale();return{x:this.container.position.x-t,y:this.container.position.y-e,w:this.sprite.data.collider.w*this.getScale(),h:this.sprite.data.collider.h*this.getScale()}}return{x:0,y:0,w:0,h:0}}async resurrect(){this.deathTimer&&this.deathTimer.complete()}async die(){this.state.isImmortal||(this.isDead=!0,this.container.visible=!1,Et.kill(this),this.deathTimer=new Zt(1e3*60*1,()=>{!this.isDespawned&&this.isDead&&(this.isDead=!1,this.container.visible=!0,this.state.scale=1,Et.resurrect(this))}))}spawn(t={isFalling:!1}){if(!this.sprite)return;const e=this.sprite.data.collider,i=this.sprite.data.size,r=-(e.y+e.h-i.h/2),n=t.isFalling?r:lt.renderer.height,a=i.w*this.getScale(),o=t.positionX!=null?t.positionX*this.screenBounds.right:Math.random()*(this.screenBounds.right-a)+a/2,h=n*this.getScale();if(this.container.x=o,this.container.y=h,this.state.direction=Math.random()>.5?1:-1,!t.isFalling){const c=Et.zIndexEvotarMin(this.container.zIndex);this.state.zIndex=c,this.container.alpha=0,this.spawnTween=new xe(this.container).to({alpha:1},500).onComplete(t.onComplete).start()}this.stateTimer=new Zt(5e3,()=>{!this.isJumping&&!this.isDead&&this.setAnimationState(dt.Run)})}despawn(t={}){this.fadeTween&&this.fadeTween.isPlaying()||(this.fadeTween=new xe(this.container).to({alpha:0},1e3).onComplete(()=>{this.isDespawned=!0,t.onComplete&&t.onComplete()}).start())}scale(t){this.scaleTween&&this.scaleTween.isPlaying()||this.scaleTimer&&!this.scaleTimer.isCompleted||(this.scaleTween=new xe(this).to({state:{scale:t.value??2}},2e3).onComplete(()=>{this.scaleTimer=new Zt((t.duration??10)*1e3,()=>{this.scaleTween=new xe(this).to({state:{scale:1}},2e3).start()})}).start())}addJumpHit(t){this.info.addJumps(t)}async jump(t){this.isDespawned||this.isJumping||(this.isJumping=!0,Qc.play("jump"),await tx(300),this.velocity.x=this.state.direction*((t==null?void 0:t.velocityX)??3.5),this.velocity.y=(t==null?void 0:t.velocityY)??-8,this.setAnimationState(dt.Jump),this.info.jumps>0&&(this.info.useJump(),this.isHitJumping=!0))}dash(t){this.isDespawned||this.isDashing||(this.isDashing=!0,this.velocity.x=this.state.direction*(t.force??14))}async setSprite(t){if(t&&t!=this.state.sprite){const e=await ui.getSpriteData(t);if(!e)return;this.sprite&&this.container.removeChild(this.sprite.container),this.state.sprite=t;const i=ui.getAnimatedSprites(t);this.sprite=new J_(i,e.data),this.container.addChild(this.sprite.container),this.trail.setSprite(this.sprite),this.setAnimationState(this.animationState,!0)}}async setProps(t){t.sprite&&await this.setSprite(t.sprite),this.state={...this.state,...t}}setUserProps(t){this.userState={...this.userState,...t}}move(){var i;if(!this.sprite)return;const t=this.sprite.data.collider,e={x:this.container.position.x,y:this.container.position.y};if(this.isDashing){const r=Math.sign(this.velocity.x);this.velocity.x=this.velocity.x-r*this.dashAcc/Math.abs(this.velocity.x),r!=Math.sign(this.velocity.x)?(this.isDashing=!1,this.velocity.x=0):e.x+=this.velocity.x}else{if((i=this.stateTimer)!=null&&i.isCompleted&&(this.stateTimer=new Zt(Math.random()*5e3,()=>{this.animationState==dt.Idle?this.setAnimationState(dt.Run):this.animationState==dt.Run&&this.setAnimationState(dt.Idle)})),this.animationState==dt.Run){const r=this.runSpeed*this.state.direction;this.velocity.x=r*ae}this.velocity.y=this.velocity.y+this.gravity,e.x+=this.velocity.x,e.y+=this.velocity.y,this.isOnGround(e.y)&&(this.velocity.y=0,this.velocity.x=0,e.y=lt.renderer.height,this.animationState==dt.Fall&&(this.setAnimationState(dt.Land),this.landTimer=new Zt(200,()=>{this.setAnimationState(dt.Idle),this.isJumping=!1,this.isHitJumping=!1}))),this.velocity.y>0&&this.setAnimationState(dt.Fall)}if(this.animationState!=dt.Idle||this.isDashing){const r=t.w/2*this.getScale(),n=this.container.x-r<this.screenBounds.left,a=this.container.x+r>this.screenBounds.right;(n||a)&&(this.state.direction=-this.state.direction,this.velocity.x=-this.velocity.x,n&&(e.x=this.screenBounds.left+r),a&&(e.x=this.screenBounds.right-r))}this.container.position.set(e.x,e.y),this.isHitJumping&&this.jumpHit()}jumpHit(){const t=Et.getViewerEvotars();for(const e in t){const i=t[e];if(i){const r=this.getCollider(),n=i.getCollider();i!=this&&ix(r,n,{x:this.velocity.x,y:this.velocity.y})&&!i.isDead&&!i.state.isImmortal&&(i.die(),this.info.addKill())}}}update(){var r,n,a,o,h,c,l;if(this.isDespawned||!this.sprite)return;(r=this.landTimer)==null||r.tick(),(n=this.stateTimer)==null||n.tick(),(a=this.scaleTimer)==null||a.tick(),(o=this.fadeTween)==null||o.update(),(h=this.spawnTween)==null||h.update(),(c=this.scaleTween)==null||c.update(),(l=this.deathTimer)==null||l.tick(),this.container.zIndex=this.state.zIndex;const t=this.sprite.data.collider;this.name.update({name:this.state.name,isVisible:!this.state.isAnonymous,position:{y:-t.h*this.getScale()}}),this.info.update({position:{y:this.name.text.position.y-this.name.text.height-6}}),this.message.update({position:{y:this.info.containter.position.y-this.info.containter.height-6}}),this.emoteSpitter.update({position:{y:this.message.container.position.y-this.message.container.height}}),this.isDead||this.move();const e=Object.fromEntries(this.sprite.data.colored.map(u=>[u,this.userState.color?this.userState.color:this.state.color])),i=this.sprite.data.flip?this.state.direction:1;this.sprite.update({color:e,scale:{x:i*this.getScale(),y:this.getScale()},play:!this.isDashing}),this.trail.update({play:this.isDashing})}isOnGround(t){return t>lt.renderer.height}addMessage(t){var e;this.message.add(t),this.state.isAnonymous=!1,(e=this.fadeTween)==null||e.stop(),this.fadeTween=void 0,this.container.alpha=1}async spitEmotes(t){for(const e of t)await this.emoteSpitter.add(e)}async setAnimationState(t,e=!1){this.animationState==t&&!e||(this.animationState=t,this.sprite&&this.sprite.setTag(t))}}class rx{play(t,e,i){const r=ft.get(t),n=ui.createAnimatedSprite(t,r);n&&(lt.stage.addChild(n),n.zIndex=1e3,n.scale.set(i,i),n.position.set(e.x,e.y),n.anchor.set(.5,.5),n.loop=!1,n.texture.source.scaleMode="nearest",n.play(),n.onComplete=()=>{lt.stage.removeChild(n)})}}const ol=new rx,nx=4;class ax{constructor(t){T(this,"container",new z);T(this,"sprite");T(this,"gravity",.2);T(this,"velocity",{x:0,y:0});T(this,"fadeTween");this.id=t;const e=Math.random()>.5?"rip1":"rip2",i=ft.get(e);this.sprite=Tt.from(i)}isOnGround(t){return t>lt.renderer.height}update(){const t={x:this.container.position.x,y:this.container.position.y};this.velocity.y=this.velocity.y+this.gravity,t.x+=this.velocity.x,t.y+=this.velocity.y,this.isOnGround(t.y)&&(this.velocity.y=0,this.velocity.x=0,t.y=lt.renderer.height),this.container.position.set(t.x,t.y)}despawn(t=!1,e=()=>{}){if(t)this.fadeTween=new xe(this.container).to({alpha:0},1e3).onComplete(e).start();else{const i={x:this.container.position.x,y:this.container.position.y-8*this.container.scale.x};ol.play("poof",i,this.container.scale.x),e()}}spawn(t){this.container.removeChildren(),this.container.addChild(this.sprite),this.container.position.set(t.position.x,(t.position.y??0)+this.sprite.height/2*t.scale),this.container.scale.set(nx),this.sprite.anchor.set(.5,1),this.sprite.texture.source.scaleMode="nearest",ol.play("poof",{x:t.position.x,y:t.position.y},t.scale)}}const ox=1e3*60*5;class hx{constructor(){T(this,"viewers",{});T(this,"tombstones",[]);T(this,"raiders",[]);T(this,"recentEvotarActivity",{});T(this,"subscriptions",[]);T(this,"hasActivity",t=>!!this.recentEvotarActivity[t])}subscribe(t){this.subscriptions.push(t)}update(){for(const t in this.viewers){const e=this.viewers[t];e&&e.update()}for(const t of this.raiders)t.update();for(const t of this.tombstones)t.update()}getViewerEvotars(){return this.viewers}getViewerEvotar(t){return this.viewers[t]}async spawnViewerEvotar(t,e,i){const r=new Ne;return this.addViewer(t,r),await r.setProps(e),r.spawn(i),this.recentEvotarActivity[t]=performance.now(),r}processRaid(t){if(!lt.settings.fallingRaiders)return;const e=1/t.viewers.count*5e3;for(let a=0;a<t.viewers.count;a++){const o=new Ne;o.setProps({isAnonymous:!0,zIndex:-1,sprite:t.viewers.sprite,color:new j(t.broadcaster.info.color)}),fn.add(e*a,()=>{this.addRaider(o),o.spawn({isFalling:!0})}),fn.add(a*e+6e4,()=>{o.despawn({onComplete:()=>{this.deleteRaider(o)}})})}const i=this.viewers[t.broadcaster.id],r={...this.prepareEvotarProps(t.broadcaster.info.displayName,t.broadcaster.info.color,t.broadcaster.info.sprite),scale:2,isImmortal:!0},n=()=>{const a=new Ne;a.setProps(r),this.addViewer(t.broadcaster.id,a),a.spawn({isFalling:!0,positionX:.5})};this.recentEvotarActivity[t.broadcaster.id]=performance.now(),i?i.despawn({onComplete:()=>{n()}}):n()}despawnEvotar(t,e){e.despawn({onComplete:()=>{this.deleteViewer(t,e)}});const i=this.tombstones.find(r=>r.id==t);i&&i.despawn(!0,()=>{this.deleteTombStone(i)})}async processChatters(t){for(const e in this.viewers){const i=this.recentEvotarActivity[e],r=!!i&&performance.now()-i<ox;if(t.every(n=>n.userId!=e)&&!r){const n=this.viewers[e];n&&this.despawnEvotar(e,n)}}if(lt.settings.showAnonymousEvotars){for(const e of t)if(!this.viewers[e.userId]){const r={name:e.name,isAnonymous:!this.hasActivity(e.userId)},n=new Ne;await n.setProps(r),n.spawn(),this.addViewer(e.userId,n)}}}doAction(t,e){if(Oc(t)&&e.jump({velocityX:t.data.velocityX,velocityY:t.data.velocityY}),Nc(t)&&e.dash({force:t.data.force}),Lc(t)){const i=k(t.data.color);i&&i.isValid()&&e.setUserProps({color:new j(t.data.color)})}Hc(t)&&e.scale({value:t.data.scale,duration:t.data.duration}),zc(t)&&e.setSprite(t.data.sprite),Wc(t)&&e.addJumpHit(t.data.count),Vc(t)&&e.resurrect()}prepareEvotarProps(t,e,i){const r={name:t,isAnonymous:!1};if(i&&(r.sprite=i),e)try{r.color=new j(e)}catch{}return r}async processAction(t){const e=this.viewers[t.userId],i=this.prepareEvotarProps(t.info.displayName,t.info.color,t.info.sprite);if(e)await e.setProps(i),this.doAction(t,e);else{const r=new Ne;this.addViewer(t.userId,r),await r.setProps(i),r.spawn({onComplete:()=>{const n=this.viewers[t.userId];n&&this.doAction(t,n)}})}}async processMessage(t){const e=this.prepareEvotarProps(t.info.displayName,t.info.color,t.info.sprite);let i=this.viewers[t.userId];if(i)i.setProps(e);else{const r=lt.settings.fallingEvotars?!this.hasActivity(t.userId):!1;i=new Ne,this.addViewer(t.userId,i),await i.setProps(e),i.spawn({isFalling:r})}this.recentEvotarActivity[t.userId]=performance.now(),t.message&&i.addMessage(t.message),t.emotes.length>0&&i.spitEmotes(t.emotes)}getViewerId(t){for(const e in this.viewers)if(this.viewers[e]==t)return e}resurrect(t){const e=this.getViewerId(t);if(e){const i=this.tombstones.find(r=>r.id==e);i&&(t.setPosition(i.container.position),i.despawn(),this.deleteTombStone(i))}}kill(t){const e=this.getViewerId(t);if(e){const i=new ax(e),r=t.getCenterPosition();this.addTombStone(i),i.spawn({position:r,scale:t.getScale()})}}addTombStone(t){lt.stage.addChild(t.container),this.tombstones.push(t)}deleteTombStone(t){lt.stage.removeChild(t.container),this.tombstones=this.tombstones.filter(e=>e!=t)}addViewer(t,e){this.subscriptions.forEach(i=>i.onAdd(e)),this.viewers[t]=e}deleteViewer(t,e){this.subscriptions.forEach(i=>i.onDelete(e)),delete this.viewers[t]}addRaider(t){this.subscriptions.forEach(e=>e.onAdd(t)),this.raiders.push(t)}deleteRaider(t){this.subscriptions.forEach(e=>e.onDelete(t)),this.raiders=this.raiders.filter(e=>e!=t)}zIndexEvotarMax(t){return Object.values(this.viewers).reduce((e,i)=>i&&e<=i.container.zIndex?i.container.zIndex+1:e,t)}zIndexEvotarMin(t){return Object.values(this.viewers).reduce((e,i)=>i&&e>=i.container.zIndex?i.container.zIndex-1:e,t)}}const Et=new hx;class cx{constructor(){T(this,"stage",new z);T(this,"evotars",{});T(this,"chatterIds",[]);T(this,"settings",{});T(this,"renderer");T(this,"ticker")}async initialize(t,e){ui.initialize(e.spriteLoaderFn),Qc.initialize(e.sounds),e.font&&await ft.load({src:e.font,data:{family:"Custom Font"}}),ft.add({alias:"poof",src:"/client/poof.json"}),ft.add({alias:"rip1",src:"/client/rip1.png"}),ft.add({alias:"rip2",src:"/client/rip2.png"}),ft.add({alias:"skull",src:"/client/skull.png"}),ft.add({alias:"weight",src:"/client/weight.png"}),await ft.load(["skull","weight","poof","rip1","rip2"]),this.ticker=new ot,this.ticker.deltaTime=ae*.06,this.renderer=await md({preference:"webgl"}),await this.renderer.init({width:t.clientWidth,height:t.clientHeight,backgroundAlpha:0}),t.appendChild(this.renderer.canvas),window.onresize=()=>{this.renderer.resize(t.clientWidth,t.clientHeight)},this.stage.sortableChildren=!0,Et.subscribe({onAdd:i=>this.stage.addChild(i.container),onDelete:i=>{this.stage.removeChild(i.container),this.stage.removeChild(i.trail.container)}})}updateSettings(t){this.settings=t}update(){fn.tick(),Et.update(),this.renderer.render(this.stage)}}const lt=new cx;class lx{constructor(t,e){T(this,"isRendered",!1);T(this,"processMessage",t=>Et.processMessage(t));T(this,"processAction",t=>Et.processAction(t));T(this,"processChatters",t=>Et.processChatters(t));T(this,"processRaid",t=>Et.processRaid(t));this.root=t,this.options=e}get manager(){return Et}updateSettings(t){lt.updateSettings(t)}async run(){if(this.isRendered)return;this.isRendered=!0,await(async()=>{await lt.initialize(this.root,this.options),performance.now();let e=-1;const r=1e3/60;requestAnimationFrame(n);function n(a=performance.now()){const o=a-e|0;o>r&&(e=a-o%r,lt.update()),requestAnimationFrame(n)}})()}}O.add(Ta),z.mixin(Bu),O.add(Ha),O.add(Na),O.add(bo),z.mixin(ip),O.add(bc),O.add(yr),O.add(Sc),O.add(Dc),O.add(Fc),O.add(Mc,Ug,Gg),O.add(dn),O.add(Rc),O.add(Ac),O.add(Tc),O.add(wo),O.add(vo);const ux=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),dx=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));nt.Evotars=lx,nt.isAddJumpHitsUserActionEntity=Wc,nt.isColorUserActionEntity=Lc,nt.isDashUserActionEntity=Nc,nt.isGrowUserActionEntity=Hc,nt.isJumpUserActionEntity=Oc,nt.isResurrectUserActionEntity=Vc,nt.isSpriteUserActionEntity=zc,Object.defineProperty(nt,Symbol.toStringTag,{value:"Module"})});
|